Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Make efx_mcdi_{init,fini}() call efx_mcdi_drv_attach()

This should be done during MCDI initialisation for any NIC.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>

+34 -26
+33 -4
drivers/net/ethernet/sfc/mcdi.c
··· 48 48 }; 49 49 50 50 static void efx_mcdi_timeout_async(unsigned long context); 51 + static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 52 + bool *was_attached_out); 51 53 52 54 static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx) 53 55 { ··· 60 58 int efx_mcdi_init(struct efx_nic *efx) 61 59 { 62 60 struct efx_mcdi_iface *mcdi; 61 + bool already_attached; 62 + int rc; 63 63 64 64 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL); 65 65 if (!efx->mcdi) ··· 82 78 mcdi->new_epoch = true; 83 79 84 80 /* Recover from a failed assertion before probing */ 85 - return efx_mcdi_handle_assertion(efx); 81 + rc = efx_mcdi_handle_assertion(efx); 82 + if (rc) 83 + return rc; 84 + 85 + /* Let the MC (and BMC, if this is a LOM) know that the driver 86 + * is loaded. We should do this before we reset the NIC. 87 + */ 88 + rc = efx_mcdi_drv_attach(efx, true, &already_attached); 89 + if (rc) { 90 + netif_err(efx, probe, efx->net_dev, 91 + "Unable to register driver with MCPU\n"); 92 + return rc; 93 + } 94 + if (already_attached) 95 + /* Not a fatal error */ 96 + netif_err(efx, probe, efx->net_dev, 97 + "Host already registered with MCPU\n"); 98 + 99 + return 0; 86 100 } 87 101 88 102 void efx_mcdi_fini(struct efx_nic *efx) 89 103 { 90 - BUG_ON(efx->mcdi && efx->mcdi->iface.state != MCDI_STATE_QUIESCENT); 104 + if (!efx->mcdi) 105 + return; 106 + 107 + BUG_ON(efx->mcdi->iface.state != MCDI_STATE_QUIESCENT); 108 + 109 + /* Relinquish the device (back to the BMC, if this is a LOM) */ 110 + efx_mcdi_drv_attach(efx, false, NULL); 111 + 91 112 kfree(efx->mcdi); 92 113 } 93 114 ··· 918 889 buf[0] = 0; 919 890 } 920 891 921 - int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 922 - bool *was_attached) 892 + static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 893 + bool *was_attached) 923 894 { 924 895 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN); 925 896 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN);
-2
drivers/net/ethernet/sfc/mcdi.h
··· 273 273 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) 274 274 275 275 extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); 276 - extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 277 - bool *was_attached_out); 278 276 extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 279 277 u16 *fw_subtype_list, u32 *capabilities); 280 278 extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart,
+1 -20
drivers/net/ethernet/sfc/siena.c
··· 196 196 static int siena_probe_nic(struct efx_nic *efx) 197 197 { 198 198 struct siena_nic_data *nic_data; 199 - bool already_attached = false; 200 199 efx_oword_t reg; 201 200 int rc; 202 201 ··· 220 221 rc = efx_mcdi_init(efx); 221 222 if (rc) 222 223 goto fail1; 223 - 224 - /* Let the BMC know that the driver is now in charge of link and 225 - * filter settings. We must do this before we reset the NIC */ 226 - rc = efx_mcdi_drv_attach(efx, true, &already_attached); 227 - if (rc) { 228 - netif_err(efx, probe, efx->net_dev, 229 - "Unable to register driver with MCPU\n"); 230 - goto fail2; 231 - } 232 - if (already_attached) 233 - /* Not a fatal error */ 234 - netif_err(efx, probe, efx->net_dev, 235 - "Host already registered with MCPU\n"); 236 224 237 225 /* Now we can reset the NIC */ 238 226 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL); ··· 267 281 efx_nic_free_buffer(efx, &efx->irq_status); 268 282 fail4: 269 283 fail3: 270 - efx_mcdi_drv_attach(efx, false, NULL); 271 - fail2: 272 284 efx_mcdi_fini(efx); 273 285 fail1: 274 286 kfree(efx->nic_data); ··· 355 371 356 372 efx_mcdi_reset(efx, RESET_TYPE_ALL); 357 373 358 - /* Relinquish the device back to the BMC */ 359 - efx_mcdi_drv_attach(efx, false, NULL); 374 + efx_mcdi_fini(efx); 360 375 361 376 /* Tear down the private nic state */ 362 377 kfree(efx->nic_data); 363 378 efx->nic_data = NULL; 364 - 365 - efx_mcdi_fini(efx); 366 379 } 367 380 368 381 #define SIENA_DMA_STAT(ext_name, mcdi_name) \