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

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
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;

+1 −1
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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 */
Loading