···4848};49495050static void efx_mcdi_timeout_async(unsigned long context);5151+static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,5252+ bool *was_attached_out);51535254static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)5355{···6058int efx_mcdi_init(struct efx_nic *efx)6159{6260 struct efx_mcdi_iface *mcdi;6161+ bool already_attached;6262+ int rc;63636464 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL);6565 if (!efx->mcdi)···8278 mcdi->new_epoch = true;83798480 /* Recover from a failed assertion before probing */8585- return efx_mcdi_handle_assertion(efx);8181+ rc = efx_mcdi_handle_assertion(efx);8282+ if (rc)8383+ return rc;8484+8585+ /* Let the MC (and BMC, if this is a LOM) know that the driver8686+ * is loaded. We should do this before we reset the NIC.8787+ */8888+ rc = efx_mcdi_drv_attach(efx, true, &already_attached);8989+ if (rc) {9090+ netif_err(efx, probe, efx->net_dev,9191+ "Unable to register driver with MCPU\n");9292+ return rc;9393+ }9494+ if (already_attached)9595+ /* Not a fatal error */9696+ netif_err(efx, probe, efx->net_dev,9797+ "Host already registered with MCPU\n");9898+9999+ return 0;86100}8710188102void efx_mcdi_fini(struct efx_nic *efx)89103{9090- BUG_ON(efx->mcdi && efx->mcdi->iface.state != MCDI_STATE_QUIESCENT);104104+ if (!efx->mcdi)105105+ return;106106+107107+ BUG_ON(efx->mcdi->iface.state != MCDI_STATE_QUIESCENT);108108+109109+ /* Relinquish the device (back to the BMC, if this is a LOM) */110110+ efx_mcdi_drv_attach(efx, false, NULL);111111+91112 kfree(efx->mcdi);92113}93114···918889 buf[0] = 0;919890}920891921921-int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,922922- bool *was_attached)892892+static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,893893+ bool *was_attached)923894{924895 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN);925896 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN);
···196196static int siena_probe_nic(struct efx_nic *efx)197197{198198 struct siena_nic_data *nic_data;199199- bool already_attached = false;200199 efx_oword_t reg;201200 int rc;202201···220221 rc = efx_mcdi_init(efx);221222 if (rc)222223 goto fail1;223223-224224- /* Let the BMC know that the driver is now in charge of link and225225- * filter settings. We must do this before we reset the NIC */226226- rc = efx_mcdi_drv_attach(efx, true, &already_attached);227227- if (rc) {228228- netif_err(efx, probe, efx->net_dev,229229- "Unable to register driver with MCPU\n");230230- goto fail2;231231- }232232- if (already_attached)233233- /* Not a fatal error */234234- netif_err(efx, probe, efx->net_dev,235235- "Host already registered with MCPU\n");236224237225 /* Now we can reset the NIC */238226 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL);···267281 efx_nic_free_buffer(efx, &efx->irq_status);268282fail4:269283fail3:270270- efx_mcdi_drv_attach(efx, false, NULL);271271-fail2:272284 efx_mcdi_fini(efx);273285fail1:274286 kfree(efx->nic_data);···355371356372 efx_mcdi_reset(efx, RESET_TYPE_ALL);357373358358- /* Relinquish the device back to the BMC */359359- efx_mcdi_drv_attach(efx, false, NULL);374374+ efx_mcdi_fini(efx);360375361376 /* Tear down the private nic state */362377 kfree(efx->nic_data);363378 efx->nic_data = NULL;364364-365365- efx_mcdi_fini(efx);366379}367380368381#define SIENA_DMA_STAT(ext_name, mcdi_name) \