Commit 66a65128 authored by Edward Cree's avatar Edward Cree Committed by David S. Miller

sfc: track which BAR is mapped

EF100 needs to map multiple BARs (sequentially, not concurrently) in
 order to read the Function Control Window during probe.
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 53e1f21a
...@@ -1074,7 +1074,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) ...@@ -1074,7 +1074,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
efx_pci_remove_main(efx); efx_pci_remove_main(efx);
efx_fini_io(efx, efx->type->mem_bar(efx)); efx_fini_io(efx);
netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n"); netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
efx_fini_struct(efx); efx_fini_struct(efx);
...@@ -1342,7 +1342,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -1342,7 +1342,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
return 0; return 0;
fail3: fail3:
efx_fini_io(efx, efx->type->mem_bar(efx)); efx_fini_io(efx);
fail2: fail2:
efx_fini_struct(efx); efx_fini_struct(efx);
fail1: fail1:
......
...@@ -953,6 +953,8 @@ int efx_init_struct(struct efx_nic *efx, ...@@ -953,6 +953,8 @@ int efx_init_struct(struct efx_nic *efx,
INIT_WORK(&efx->mac_work, efx_mac_work); INIT_WORK(&efx->mac_work, efx_mac_work);
init_waitqueue_head(&efx->flush_wq); init_waitqueue_head(&efx->flush_wq);
efx->mem_bar = UINT_MAX;
rc = efx_init_channels(efx); rc = efx_init_channels(efx);
if (rc) if (rc)
goto fail; goto fail;
...@@ -996,7 +998,9 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask, ...@@ -996,7 +998,9 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
struct pci_dev *pci_dev = efx->pci_dev; struct pci_dev *pci_dev = efx->pci_dev;
int rc; int rc;
netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n"); efx->mem_bar = UINT_MAX;
netif_dbg(efx, probe, efx->net_dev, "initialising I/O bar=%d\n", bar);
rc = pci_enable_device(pci_dev); rc = pci_enable_device(pci_dev);
if (rc) { if (rc) {
...@@ -1038,21 +1042,21 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask, ...@@ -1038,21 +1042,21 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
rc = pci_request_region(pci_dev, bar, "sfc"); rc = pci_request_region(pci_dev, bar, "sfc");
if (rc) { if (rc) {
netif_err(efx, probe, efx->net_dev, netif_err(efx, probe, efx->net_dev,
"request for memory BAR failed\n"); "request for memory BAR[%d] failed\n", bar);
rc = -EIO; rc = -EIO;
goto fail3; goto fail3;
} }
efx->mem_bar = bar;
efx->membase = ioremap(efx->membase_phys, mem_map_size); efx->membase = ioremap(efx->membase_phys, mem_map_size);
if (!efx->membase) { if (!efx->membase) {
netif_err(efx, probe, efx->net_dev, netif_err(efx, probe, efx->net_dev,
"could not map memory BAR at %llx+%x\n", "could not map memory BAR[%d] at %llx+%x\n", bar,
(unsigned long long)efx->membase_phys, mem_map_size); (unsigned long long)efx->membase_phys, mem_map_size);
rc = -ENOMEM; rc = -ENOMEM;
goto fail4; goto fail4;
} }
netif_dbg(efx, probe, efx->net_dev, netif_dbg(efx, probe, efx->net_dev,
"memory BAR at %llx+%x (virtual %p)\n", "memory BAR[%d] at %llx+%x (virtual %p)\n", bar,
(unsigned long long)efx->membase_phys, mem_map_size, (unsigned long long)efx->membase_phys, mem_map_size,
efx->membase); efx->membase);
...@@ -1068,7 +1072,7 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask, ...@@ -1068,7 +1072,7 @@ int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
return rc; return rc;
} }
void efx_fini_io(struct efx_nic *efx, int bar) void efx_fini_io(struct efx_nic *efx)
{ {
netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n"); netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n");
...@@ -1078,8 +1082,9 @@ void efx_fini_io(struct efx_nic *efx, int bar) ...@@ -1078,8 +1082,9 @@ void efx_fini_io(struct efx_nic *efx, int bar)
} }
if (efx->membase_phys) { if (efx->membase_phys) {
pci_release_region(efx->pci_dev, bar); pci_release_region(efx->pci_dev, efx->mem_bar);
efx->membase_phys = 0; efx->membase_phys = 0;
efx->mem_bar = UINT_MAX;
} }
/* Don't disable bus-mastering if VFs are assigned */ /* Don't disable bus-mastering if VFs are assigned */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask, int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
unsigned int mem_map_size); unsigned int mem_map_size);
void efx_fini_io(struct efx_nic *efx, int bar); void efx_fini_io(struct efx_nic *efx);
int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev, int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev,
struct net_device *net_dev); struct net_device *net_dev);
void efx_fini_struct(struct efx_nic *efx); void efx_fini_struct(struct efx_nic *efx);
......
...@@ -961,6 +961,7 @@ struct efx_async_filter_insertion { ...@@ -961,6 +961,7 @@ struct efx_async_filter_insertion {
* @vpd_sn: Serial number read from VPD * @vpd_sn: Serial number read from VPD
* @xdp_rxq_info_failed: Have any of the rx queues failed to initialise their * @xdp_rxq_info_failed: Have any of the rx queues failed to initialise their
* xdp_rxq_info structures? * xdp_rxq_info structures?
* @mem_bar: The BAR that is mapped into membase.
* @monitor_work: Hardware monitor workitem * @monitor_work: Hardware monitor workitem
* @biu_lock: BIU (bus interface unit) lock * @biu_lock: BIU (bus interface unit) lock
* @last_irq_cpu: Last CPU to handle a possible test interrupt. This * @last_irq_cpu: Last CPU to handle a possible test interrupt. This
...@@ -1137,6 +1138,8 @@ struct efx_nic { ...@@ -1137,6 +1138,8 @@ struct efx_nic {
char *vpd_sn; char *vpd_sn;
bool xdp_rxq_info_failed; bool xdp_rxq_info_failed;
unsigned int mem_bar;
/* The following fields may be written more often */ /* The following fields may be written more often */
struct delayed_work monitor_work ____cacheline_aligned_in_smp; struct delayed_work monitor_work ____cacheline_aligned_in_smp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment