sfc: Add GFP flags to efx_nic_alloc_buffer() and make most callers allow blocking
authorBen Hutchings <bhutchings@solarflare.com>
Tue, 18 Sep 2012 20:59:52 +0000 (21:59 +0100)
committerBen Hutchings <bhutchings@solarflare.com>
Wed, 21 Aug 2013 18:43:47 +0000 (19:43 +0100)
Most call sites for efx_nic_alloc_buffer() are part of the probe or
reconfiguration paths and can allocate with GFP_KERNEL.  A few others
should use GFP_NOIO (I think).  Only one is in atomic context and
must use the current GFP_ATOMIC.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
drivers/net/ethernet/sfc/falcon.c
drivers/net/ethernet/sfc/mcdi_mon.c
drivers/net/ethernet/sfc/mcdi_port.c
drivers/net/ethernet/sfc/nic.c
drivers/net/ethernet/sfc/nic.h
drivers/net/ethernet/sfc/ptp.c
drivers/net/ethernet/sfc/siena.c
drivers/net/ethernet/sfc/siena_sriov.c
drivers/net/ethernet/sfc/tx.c

index 522850036c9b151132d335fd8fc4de98772a7b1b..395d89d3963e58cdf313c96e733cdac5995f8d17 100644 (file)
@@ -1418,7 +1418,7 @@ static int falcon_probe_port(struct efx_nic *efx)
 
        /* Allocate buffer for stats */
        rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
-                                 FALCON_MAC_STATS_SIZE);
+                                 FALCON_MAC_STATS_SIZE, GFP_KERNEL);
        if (rc)
                return rc;
        netif_dbg(efx, probe, efx->net_dev,
@@ -2035,7 +2035,8 @@ static int falcon_probe_nic(struct efx_nic *efx)
        }
 
        /* Allocate memory for INT_KER */
-       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t));
+       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t),
+                                 GFP_KERNEL);
        if (rc)
                goto fail4;
        BUG_ON(efx->irq_status.dma_addr & 0x0f);
index 3179b2ba316ef4fa06e0edda8759e004a6b2f411..958c73faa523bab7be85c705fefdf3766129acdf 100644 (file)
@@ -261,7 +261,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
                return -EIO;
 
        rc = efx_nic_alloc_buffer(efx, &hwmon->dma_buf,
-                                 4 * MC_CMD_SENSOR_ENTRY_MAXNUM);
+                                 4 * MC_CMD_SENSOR_ENTRY_MAXNUM, GFP_KERNEL);
        if (rc)
                return rc;
 
index 8f31e3d3f30430cac1a1366ef4d44bfaee3c5bd5..91df43fe0cdad3f457968c81f5ba7f82492ef660 100644 (file)
@@ -989,7 +989,7 @@ int efx_mcdi_port_probe(struct efx_nic *efx)
 
        /* Allocate buffer for stats */
        rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
-                                 MC_CMD_MAC_NSTATS * sizeof(u64));
+                                 MC_CMD_MAC_NSTATS * sizeof(u64), GFP_KERNEL);
        if (rc)
                return rc;
        netif_dbg(efx, probe, efx->net_dev,
index 56ed3bc71e00e0a4a24717e40d18918e4fd22fd6..efe27738b18e9529287af82a741b667f7965e510 100644 (file)
@@ -303,11 +303,11 @@ efx_free_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
  **************************************************************************/
 
 int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
-                        unsigned int len)
+                        unsigned int len, gfp_t gfp_flags)
 {
        buffer->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
                                          &buffer->dma_addr,
-                                         GFP_ATOMIC | __GFP_ZERO);
+                                         gfp_flags | __GFP_ZERO);
        if (!buffer->addr)
                return -ENOMEM;
        buffer->len = len;
index c699203a210b5e3384b28d59bc1abae9f0ed7bf8..9120e8b824e0ec0b6759b73bd25c663a9d0396ad 100644 (file)
@@ -332,7 +332,7 @@ extern void efx_nic_init_common(struct efx_nic *efx);
 extern void efx_nic_push_rx_indir_table(struct efx_nic *efx);
 
 int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
-                        unsigned int len);
+                        unsigned int len, gfp_t gfp_flags);
 void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
 
 /* Tests */
index d96bfc41c14992a3589df1695c9dd2a29b686822..56a8b8898c4700dc923d3780e80fe9761f9e4e6c 100644 (file)
@@ -875,7 +875,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
        if (!efx->ptp_data)
                return -ENOMEM;
 
-       rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int));
+       rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int), GFP_KERNEL);
        if (rc != 0)
                goto fail1;
 
index 73b511af33f9036a91e1a6628534d91ab3078f48..f0ae262b91ab2b05a52953f301f10da3878e0064 100644 (file)
@@ -237,7 +237,8 @@ static int siena_probe_nic(struct efx_nic *efx)
        siena_init_wol(efx);
 
        /* Allocate memory for INT_KER */
-       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t));
+       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t),
+                                 GFP_KERNEL);
        if (rc)
                goto fail4;
        BUG_ON(efx->irq_status.dma_addr & 0x0f);
index 2587d308234a7f421341a726bfb10760f4855fa5..6258e7f934e418faebbc3554f5c8f9131d5d4d4f 100644 (file)
@@ -997,7 +997,7 @@ static void efx_sriov_reset_vf_work(struct work_struct *work)
        struct efx_nic *efx = vf->efx;
        struct efx_buffer buf;
 
-       if (!efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE)) {
+       if (!efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE, GFP_NOIO)) {
                efx_sriov_reset_vf(vf, &buf);
                efx_nic_free_buffer(efx, &buf);
        }
@@ -1241,7 +1241,8 @@ static int efx_sriov_vfs_init(struct efx_nic *efx)
                         pci_domain_nr(pci_dev->bus), pci_dev->bus->number,
                         PCI_SLOT(devfn), PCI_FUNC(devfn));
 
-               rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE);
+               rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE,
+                                         GFP_KERNEL);
                if (rc)
                        goto fail;
 
@@ -1273,7 +1274,8 @@ int efx_sriov_init(struct efx_nic *efx)
        if (rc)
                goto fail_cmd;
 
-       rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status));
+       rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status),
+                                 GFP_KERNEL);
        if (rc)
                goto fail_status;
        vfdi_status = efx->vfdi_status.addr;
@@ -1528,7 +1530,7 @@ void efx_sriov_reset(struct efx_nic *efx)
        efx_sriov_usrev(efx, true);
        (void)efx_sriov_cmd(efx, true, NULL, NULL);
 
-       if (efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE))
+       if (efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE, GFP_NOIO))
                return;
 
        for (vf_i = 0; vf_i < efx->vf_init_count; ++vf_i) {
index 5e090e54298e667a732c53ece789bb03e40aef5e..c0d40403db23b31648ae451046028dcf93525891 100644 (file)
@@ -708,7 +708,8 @@ static u8 *efx_tsoh_get_buffer(struct efx_tx_queue *tx_queue,
                        TSOH_STD_SIZE * (index % TSOH_PER_PAGE) + TSOH_OFFSET;
 
                if (unlikely(!page_buf->addr) &&
-                   efx_nic_alloc_buffer(tx_queue->efx, page_buf, PAGE_SIZE))
+                   efx_nic_alloc_buffer(tx_queue->efx, page_buf, PAGE_SIZE,
+                                        GFP_ATOMIC))
                        return NULL;
 
                result = (u8 *)page_buf->addr + offset;