Commit 0d19a540 authored by Ben Hutchings's avatar Ben Hutchings

sfc: Add GFP flags to efx_nic_alloc_buffer() and make most callers allow blocking

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: default avatarBen Hutchings <bhutchings@solarflare.com>
parent f3ad5003
...@@ -1418,7 +1418,7 @@ static int falcon_probe_port(struct efx_nic *efx) ...@@ -1418,7 +1418,7 @@ static int falcon_probe_port(struct efx_nic *efx)
/* Allocate buffer for stats */ /* Allocate buffer for stats */
rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
FALCON_MAC_STATS_SIZE); FALCON_MAC_STATS_SIZE, GFP_KERNEL);
if (rc) if (rc)
return rc; return rc;
netif_dbg(efx, probe, efx->net_dev, netif_dbg(efx, probe, efx->net_dev,
...@@ -2035,7 +2035,8 @@ static int falcon_probe_nic(struct efx_nic *efx) ...@@ -2035,7 +2035,8 @@ static int falcon_probe_nic(struct efx_nic *efx)
} }
/* Allocate memory for INT_KER */ /* 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) if (rc)
goto fail4; goto fail4;
BUG_ON(efx->irq_status.dma_addr & 0x0f); BUG_ON(efx->irq_status.dma_addr & 0x0f);
......
...@@ -261,7 +261,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx) ...@@ -261,7 +261,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
return -EIO; return -EIO;
rc = efx_nic_alloc_buffer(efx, &hwmon->dma_buf, 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) if (rc)
return rc; return rc;
......
...@@ -989,7 +989,7 @@ int efx_mcdi_port_probe(struct efx_nic *efx) ...@@ -989,7 +989,7 @@ int efx_mcdi_port_probe(struct efx_nic *efx)
/* Allocate buffer for stats */ /* Allocate buffer for stats */
rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, 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) if (rc)
return rc; return rc;
netif_dbg(efx, probe, efx->net_dev, netif_dbg(efx, probe, efx->net_dev,
......
...@@ -303,11 +303,11 @@ efx_free_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) ...@@ -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, 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->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
&buffer->dma_addr, &buffer->dma_addr,
GFP_ATOMIC | __GFP_ZERO); gfp_flags | __GFP_ZERO);
if (!buffer->addr) if (!buffer->addr)
return -ENOMEM; return -ENOMEM;
buffer->len = len; buffer->len = len;
......
...@@ -332,7 +332,7 @@ extern void efx_nic_init_common(struct efx_nic *efx); ...@@ -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); 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, 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); void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
/* Tests */ /* Tests */
......
...@@ -875,7 +875,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel) ...@@ -875,7 +875,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
if (!efx->ptp_data) if (!efx->ptp_data)
return -ENOMEM; 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) if (rc != 0)
goto fail1; goto fail1;
......
...@@ -237,7 +237,8 @@ static int siena_probe_nic(struct efx_nic *efx) ...@@ -237,7 +237,8 @@ static int siena_probe_nic(struct efx_nic *efx)
siena_init_wol(efx); siena_init_wol(efx);
/* Allocate memory for INT_KER */ /* 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) if (rc)
goto fail4; goto fail4;
BUG_ON(efx->irq_status.dma_addr & 0x0f); BUG_ON(efx->irq_status.dma_addr & 0x0f);
......
...@@ -997,7 +997,7 @@ static void efx_sriov_reset_vf_work(struct work_struct *work) ...@@ -997,7 +997,7 @@ static void efx_sriov_reset_vf_work(struct work_struct *work)
struct efx_nic *efx = vf->efx; struct efx_nic *efx = vf->efx;
struct efx_buffer buf; 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_sriov_reset_vf(vf, &buf);
efx_nic_free_buffer(efx, &buf); efx_nic_free_buffer(efx, &buf);
} }
...@@ -1241,7 +1241,8 @@ static int efx_sriov_vfs_init(struct efx_nic *efx) ...@@ -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_domain_nr(pci_dev->bus), pci_dev->bus->number,
PCI_SLOT(devfn), PCI_FUNC(devfn)); 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) if (rc)
goto fail; goto fail;
...@@ -1273,7 +1274,8 @@ int efx_sriov_init(struct efx_nic *efx) ...@@ -1273,7 +1274,8 @@ int efx_sriov_init(struct efx_nic *efx)
if (rc) if (rc)
goto fail_cmd; 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) if (rc)
goto fail_status; goto fail_status;
vfdi_status = efx->vfdi_status.addr; vfdi_status = efx->vfdi_status.addr;
...@@ -1528,7 +1530,7 @@ void efx_sriov_reset(struct efx_nic *efx) ...@@ -1528,7 +1530,7 @@ void efx_sriov_reset(struct efx_nic *efx)
efx_sriov_usrev(efx, true); efx_sriov_usrev(efx, true);
(void)efx_sriov_cmd(efx, true, NULL, NULL); (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; return;
for (vf_i = 0; vf_i < efx->vf_init_count; ++vf_i) { for (vf_i = 0; vf_i < efx->vf_init_count; ++vf_i) {
......
...@@ -708,7 +708,8 @@ static u8 *efx_tsoh_get_buffer(struct efx_tx_queue *tx_queue, ...@@ -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; TSOH_STD_SIZE * (index % TSOH_PER_PAGE) + TSOH_OFFSET;
if (unlikely(!page_buf->addr) && 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; return NULL;
result = (u8 *)page_buf->addr + offset; result = (u8 *)page_buf->addr + offset;
......
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