Skip to content

Commit 2132fca

Browse files
committed
net: mana: Add handler for hardware servicing events
jira LE-4385 Rebuild_History Non-Buildable kernel-5.14.0-570.52.1.el9_6 commit-author Haiyang Zhang <[email protected]> commit 7768c5f To collaborate with hardware servicing events, upon receiving the special EQE notification from the HW channel, remove the devices on this bus. Then, after a waiting period based on the device specs, rescan the parent bus to recover the devices. Signed-off-by: Haiyang Zhang <[email protected]> Reviewed-by: Shradha Gupta <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit 7768c5f) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 5e9c277 commit 2132fca

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

drivers/net/ethernet/microsoft/mana/gdma_main.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,59 @@ void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit)
354354
head, arm_bit);
355355
}
356356

357+
#define MANA_SERVICE_PERIOD 10
358+
359+
struct mana_serv_work {
360+
struct work_struct serv_work;
361+
struct pci_dev *pdev;
362+
};
363+
364+
static void mana_serv_func(struct work_struct *w)
365+
{
366+
struct mana_serv_work *mns_wk;
367+
struct pci_bus *bus, *parent;
368+
struct pci_dev *pdev;
369+
370+
mns_wk = container_of(w, struct mana_serv_work, serv_work);
371+
pdev = mns_wk->pdev;
372+
373+
pci_lock_rescan_remove();
374+
375+
if (!pdev)
376+
goto out;
377+
378+
bus = pdev->bus;
379+
if (!bus) {
380+
dev_err(&pdev->dev, "MANA service: no bus\n");
381+
goto out;
382+
}
383+
384+
parent = bus->parent;
385+
if (!parent) {
386+
dev_err(&pdev->dev, "MANA service: no parent bus\n");
387+
goto out;
388+
}
389+
390+
pci_stop_and_remove_bus_device(bus->self);
391+
392+
msleep(MANA_SERVICE_PERIOD * 1000);
393+
394+
pci_rescan_bus(parent);
395+
396+
out:
397+
pci_unlock_rescan_remove();
398+
399+
pci_dev_put(pdev);
400+
kfree(mns_wk);
401+
module_put(THIS_MODULE);
402+
}
403+
357404
static void mana_gd_process_eqe(struct gdma_queue *eq)
358405
{
359406
u32 head = eq->head % (eq->queue_size / GDMA_EQE_SIZE);
360407
struct gdma_context *gc = eq->gdma_dev->gdma_context;
361408
struct gdma_eqe *eq_eqe_ptr = eq->queue_mem_ptr;
409+
struct mana_serv_work *mns_wk;
362410
union gdma_eqe_info eqe_info;
363411
enum gdma_eqe_type type;
364412
struct gdma_event event;
@@ -402,6 +450,33 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)
402450
eq->eq.callback(eq->eq.context, eq, &event);
403451
break;
404452

453+
case GDMA_EQE_HWC_FPGA_RECONFIG:
454+
dev_info(gc->dev, "Recv MANA service type:%d\n", type);
455+
456+
if (gc->in_service) {
457+
dev_info(gc->dev, "Already in service\n");
458+
break;
459+
}
460+
461+
if (!try_module_get(THIS_MODULE)) {
462+
dev_info(gc->dev, "Module is unloading\n");
463+
break;
464+
}
465+
466+
mns_wk = kzalloc(sizeof(*mns_wk), GFP_ATOMIC);
467+
if (!mns_wk) {
468+
module_put(THIS_MODULE);
469+
break;
470+
}
471+
472+
dev_info(gc->dev, "Start MANA service type:%d\n", type);
473+
gc->in_service = true;
474+
mns_wk->pdev = to_pci_dev(gc->dev);
475+
pci_dev_get(mns_wk->pdev);
476+
INIT_WORK(&mns_wk->serv_work, mana_serv_func);
477+
schedule_work(&mns_wk->serv_work);
478+
break;
479+
405480
default:
406481
break;
407482
}

include/net/mana/gdma.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum gdma_eqe_type {
5858
GDMA_EQE_HWC_INIT_EQ_ID_DB = 129,
5959
GDMA_EQE_HWC_INIT_DATA = 130,
6060
GDMA_EQE_HWC_INIT_DONE = 131,
61-
GDMA_EQE_HWC_SOC_RECONFIG = 132,
61+
GDMA_EQE_HWC_FPGA_RECONFIG = 132,
6262
GDMA_EQE_HWC_SOC_RECONFIG_DATA = 133,
6363
GDMA_EQE_RNIC_QP_FATAL = 176,
6464
};
@@ -388,6 +388,8 @@ struct gdma_context {
388388
u32 test_event_eq_id;
389389

390390
bool is_pf;
391+
bool in_service;
392+
391393
phys_addr_t bar0_pa;
392394
void __iomem *bar0_va;
393395
void __iomem *shm_base;
@@ -558,12 +560,16 @@ enum {
558560
/* Driver can handle holes (zeros) in the device list */
559561
#define GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP BIT(11)
560562

563+
/* Driver can self reset on FPGA Reconfig EQE notification */
564+
#define GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE BIT(17)
565+
561566
#define GDMA_DRV_CAP_FLAGS1 \
562567
(GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \
563568
GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \
564569
GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG | \
565570
GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT | \
566-
GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP)
571+
GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP | \
572+
GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE)
567573

568574
#define GDMA_DRV_CAP_FLAGS2 0
569575

0 commit comments

Comments
 (0)