Skip to content

Commit

Permalink
r8169: allocate with GFP_KERNEL flag when able to sleep
Browse files Browse the repository at this point in the history
We have fedora bug report where driver fail to initialize after
suspend/resume because of memory allocation errors:
https://bugzilla.redhat.com/show_bug.cgi?id=629158

To fix use GFP_KERNEL allocation where possible.

Tested-by: Neal Becker <ndbecker2@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stanislaw Gruszka authored and David S. Miller committed Oct 9, 2010
1 parent ae6df5f commit aeb19f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -4000,15 +4000,15 @@ static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev,
struct net_device *dev,
struct RxDesc *desc, int rx_buf_sz,
unsigned int align)
unsigned int align, gfp_t gfp)
{
struct sk_buff *skb;
dma_addr_t mapping;
unsigned int pad;

pad = align ? align : NET_IP_ALIGN;

skb = netdev_alloc_skb(dev, rx_buf_sz + pad);
skb = __netdev_alloc_skb(dev, rx_buf_sz + pad, gfp);
if (!skb)
goto err_out;

Expand Down Expand Up @@ -4039,7 +4039,7 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp)
}

static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev,
u32 start, u32 end)
u32 start, u32 end, gfp_t gfp)
{
u32 cur;

Expand All @@ -4054,7 +4054,7 @@ static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev,

skb = rtl8169_alloc_rx_skb(tp->pci_dev, dev,
tp->RxDescArray + i,
tp->rx_buf_sz, tp->align);
tp->rx_buf_sz, tp->align, gfp);
if (!skb)
break;

Expand Down Expand Up @@ -4082,7 +4082,7 @@ static int rtl8169_init_ring(struct net_device *dev)
memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info));
memset(tp->Rx_skbuff, 0x0, NUM_RX_DESC * sizeof(struct sk_buff *));

if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC) != NUM_RX_DESC)
if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC)
goto err_out;

rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
Expand Down Expand Up @@ -4583,7 +4583,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
count = cur_rx - tp->cur_rx;
tp->cur_rx = cur_rx;

delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx);
delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx, GFP_ATOMIC);
if (!delta && count)
netif_info(tp, intr, dev, "no Rx buffer allocated\n");
tp->dirty_rx += delta;
Expand Down

0 comments on commit aeb19f6

Please sign in to comment.