mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
RDMA/hfi1: Create workqueues before device initialization
create_workqueues() only needs fields set up by hfi1_alloc_devdata(). Call it before hfi1_init_dd() so a workqueue allocation failure happens before chip resources are initialized. To keep the reordered error paths safe, make init_one() own hfi1_devdata. hfi1_init_dd() unwinds its partial setup but leaves the allocation for the caller to free. If device initialization fails, destroy the workqueues before freeing the device data. Link: https://patch.msgid.link/20260708-clean-init-one-hfi1-v1-6-b9e9641268a5@nvidia.com Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
parent
4ebd241071
commit
0d5618c1b2
|
|
@ -15008,7 +15008,7 @@ int hfi1_init_dd(struct hfi1_devdata *dd)
|
|||
*/
|
||||
ret = hfi1_pcie_ddinit(dd, pdev);
|
||||
if (ret < 0)
|
||||
goto bail_free;
|
||||
goto bail;
|
||||
|
||||
/* Save PCI space registers to rewrite after device reset */
|
||||
ret = save_pci_variables(dd);
|
||||
|
|
@ -15263,8 +15263,6 @@ int hfi1_init_dd(struct hfi1_devdata *dd)
|
|||
bail_cleanup:
|
||||
hfi1_free_rx(dd);
|
||||
hfi1_pcie_ddcleanup(dd);
|
||||
bail_free:
|
||||
hfi1_free_devdata(dd);
|
||||
bail:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2024,9 +2024,7 @@ struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd)
|
|||
/* waiting for an urgent packet to arrive */
|
||||
#define HFI1_CTXT_WAITING_URG 4
|
||||
|
||||
/* free up any allocated data at closes */
|
||||
int hfi1_init_dd(struct hfi1_devdata *dd);
|
||||
void hfi1_free_devdata(struct hfi1_devdata *dd);
|
||||
|
||||
/* LED beaconing functions */
|
||||
void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
|
||||
|
|
|
|||
|
|
@ -629,8 +629,6 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
|
|||
ppd->sm_trap_qp = 0x0;
|
||||
ppd->sa_qp = 0x1;
|
||||
|
||||
ppd->hfi1_wq = NULL;
|
||||
|
||||
spin_lock_init(&ppd->cca_timer_lock);
|
||||
|
||||
for (i = 0; i < OPA_MAX_SLS; i++) {
|
||||
|
|
@ -1161,7 +1159,7 @@ static void finalize_asic_data(struct hfi1_devdata *dd,
|
|||
* It cleans up and frees all data structures set up by
|
||||
* by hfi1_alloc_devdata().
|
||||
*/
|
||||
void hfi1_free_devdata(struct hfi1_devdata *dd)
|
||||
static void hfi1_free_devdata(struct hfi1_devdata *dd)
|
||||
{
|
||||
struct hfi1_asic_data *ad;
|
||||
unsigned long flags;
|
||||
|
|
@ -1624,17 +1622,17 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
if (ret)
|
||||
goto bail;
|
||||
|
||||
ret = create_workqueues(dd);
|
||||
if (ret)
|
||||
goto free_devdata;
|
||||
|
||||
/*
|
||||
* Do device-specific initialization, function table setup, dd
|
||||
* allocation, etc.
|
||||
*/
|
||||
ret = hfi1_init_dd(dd);
|
||||
if (ret)
|
||||
goto clean_bail; /* error already printed */
|
||||
|
||||
ret = create_workqueues(dd);
|
||||
if (ret)
|
||||
goto clean_bail;
|
||||
goto destroy_workqueues; /* error already printed */
|
||||
|
||||
/* do the generic initialization */
|
||||
initfail = hfi1_init(dd, 0);
|
||||
|
|
@ -1687,7 +1685,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
|
||||
return 0;
|
||||
|
||||
clean_bail:
|
||||
destroy_workqueues:
|
||||
destroy_workqueues(dd);
|
||||
free_devdata:
|
||||
hfi1_free_devdata(dd);
|
||||
hfi1_pcie_cleanup(pdev);
|
||||
bail:
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user