diff mbox

[net] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation

Message ID 20151203155905.GA31974@amd
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Pavel Machek Dec. 3, 2015, 3:59 p.m. UTC
atl1c driver is doing order-4 allocation with GFP_ATOMIC
priority. That often breaks  networking after resume. Switch to
GFP_KERNEL. Still not ideal, but should be significantly better.

atl1c_setup_ring_resources() is called from .open() function, and
already uses GFP_KERNEL, so this change is safe.
    
Signed-off-by: Pavel Machek <pavel@ucw.cz>

Comments

Michal Hocko Dec. 3, 2015, 4:13 p.m. UTC | #1
On Thu 03-12-15 16:59:05, Pavel Machek wrote:
> 
> atl1c driver is doing order-4 allocation with GFP_ATOMIC
> priority. That often breaks  networking after resume. Switch to
> GFP_KERNEL. Still not ideal, but should be significantly better.
> 
> atl1c_setup_ring_resources() is called from .open() function, and
> already uses GFP_KERNEL, so this change is safe.

Thanks for updating the changelog

> Signed-off-by: Pavel Machek <pavel@ucw.cz>

Acked-by: Michal Hocko <mhocko@suse.com>

> 
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 2795d6d..afb71e0 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -1016,10 +1016,10 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
>  		sizeof(struct atl1c_recv_ret_status) * rx_desc_count +
>  		8 * 4;
>  
> -	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
> -				&ring_header->dma);
> +	ring_header->desc = dma_alloc_coherent(&pdev->dev, ring_header->size,
> +					       &ring_header->dma, GFP_KERNEL);
>  	if (unlikely(!ring_header->desc)) {
> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
>  		goto err_nomem;
>  	}
>  	memset(ring_header->desc, 0, ring_header->size);
> 
> 
> -- 
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Eric Dumazet Dec. 3, 2015, 5:17 p.m. UTC | #2
On Thu, 2015-12-03 at 16:59 +0100, Pavel Machek wrote:
> atl1c driver is doing order-4 allocation with GFP_ATOMIC
> priority. That often breaks  networking after resume. Switch to
> GFP_KERNEL. Still not ideal, but should be significantly better.
> 
> atl1c_setup_ring_resources() is called from .open() function, and
> already uses GFP_KERNEL, so this change is safe.
>     
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
> 
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 2795d6d..afb71e0 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -1016,10 +1016,10 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
>  		sizeof(struct atl1c_recv_ret_status) * rx_desc_count +
>  		8 * 4;
>  
> -	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
> -				&ring_header->dma);
> +	ring_header->desc = dma_alloc_coherent(&pdev->dev, ring_header->size,
> +					       &ring_header->dma, GFP_KERNEL);
>  	if (unlikely(!ring_header->desc)) {
> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
>  		goto err_nomem;
>  	}
>  	memset(ring_header->desc, 0, ring_header->size);
> 
> 

So this memset() will really require a different patch to get removed ?

Sigh, not sure why I review patches.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Dec. 3, 2015, 5:32 p.m. UTC | #3
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 03 Dec 2015 09:17:28 -0800

> On Thu, 2015-12-03 at 16:59 +0100, Pavel Machek wrote:
>> atl1c driver is doing order-4 allocation with GFP_ATOMIC
>> priority. That often breaks  networking after resume. Switch to
>> GFP_KERNEL. Still not ideal, but should be significantly better.
>> 
>> atl1c_setup_ring_resources() is called from .open() function, and
>> already uses GFP_KERNEL, so this change is safe.
>>     
>> Signed-off-by: Pavel Machek <pavel@ucw.cz>
>> 
>> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
>> index 2795d6d..afb71e0 100644
>> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
>> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
>> @@ -1016,10 +1016,10 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
>>  		sizeof(struct atl1c_recv_ret_status) * rx_desc_count +
>>  		8 * 4;
>>  
>> -	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
>> -				&ring_header->dma);
>> +	ring_header->desc = dma_alloc_coherent(&pdev->dev, ring_header->size,
>> +					       &ring_header->dma, GFP_KERNEL);
>>  	if (unlikely(!ring_header->desc)) {
>> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
>> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
>>  		goto err_nomem;
>>  	}
>>  	memset(ring_header->desc, 0, ring_header->size);
>> 
>> 
> 
> So this memset() will really require a different patch to get removed ?
> 
> Sigh, not sure why I review patches.

Agreed, please use dma_zalloc_coherent() and kill that memset().

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek Dec. 4, 2015, 8:11 a.m. UTC | #4
> >>  	if (unlikely(!ring_header->desc)) {
> >> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
> >> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
> >>  		goto err_nomem;
> >>  	}
> >>  	memset(ring_header->desc, 0, ring_header->size);
> >> 
> >> 
> > 
> > So this memset() will really require a different patch to get removed ?
> > 
> > Sigh, not sure why I review patches.
> 
> Agreed, please use dma_zalloc_coherent() and kill that memset().

Ok, updated. I'll also add cc: stable, because it makes notebooks with
affected chipset unusable.

									Pavel
David Miller Dec. 4, 2015, 4:21 p.m. UTC | #5
From: Pavel Machek <pavel@ucw.cz>
Date: Fri, 4 Dec 2015 09:11:27 +0100

>> >>  	if (unlikely(!ring_header->desc)) {
>> >> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
>> >> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
>> >>  		goto err_nomem;
>> >>  	}
>> >>  	memset(ring_header->desc, 0, ring_header->size);
>> >> 
>> >> 
>> > 
>> > So this memset() will really require a different patch to get removed ?
>> > 
>> > Sigh, not sure why I review patches.
>> 
>> Agreed, please use dma_zalloc_coherent() and kill that memset().
> 
> Ok, updated. I'll also add cc: stable, because it makes notebooks with
> affected chipset unusable.

Networking patches do not use CC: stable, instead you simply ask me
to queue it up and then I batch submit networking fixes to -stable
periodically myself.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek Dec. 4, 2015, 9:30 p.m. UTC | #6
On Fri 2015-12-04 11:21:40, David Miller wrote:
> From: Pavel Machek <pavel@ucw.cz>
> Date: Fri, 4 Dec 2015 09:11:27 +0100
> 
> >> >>  	if (unlikely(!ring_header->desc)) {
> >> >> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
> >> >> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
> >> >>  		goto err_nomem;
> >> >>  	}
> >> >>  	memset(ring_header->desc, 0, ring_header->size);
> >> >> 
> >> >> 
> >> > 
> >> > So this memset() will really require a different patch to get removed ?
> >> > 
> >> > Sigh, not sure why I review patches.
> >> 
> >> Agreed, please use dma_zalloc_coherent() and kill that memset().
> > 
> > Ok, updated. I'll also add cc: stable, because it makes notebooks with
> > affected chipset unusable.
> 
> Networking patches do not use CC: stable, instead you simply ask me
> to queue it up and then I batch submit networking fixes to -stable
> periodically myself.

Ok, can you take the patch and ignore the Cc, or should I do one more
iteration?

Thanks,
									Pavel
David Miller Dec. 4, 2015, 10:01 p.m. UTC | #7
From: Pavel Machek <pavel@ucw.cz>
Date: Fri, 4 Dec 2015 22:30:27 +0100

> On Fri 2015-12-04 11:21:40, David Miller wrote:
>> From: Pavel Machek <pavel@ucw.cz>
>> Date: Fri, 4 Dec 2015 09:11:27 +0100
>> 
>> >> >>  	if (unlikely(!ring_header->desc)) {
>> >> >> -		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
>> >> >> +		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
>> >> >>  		goto err_nomem;
>> >> >>  	}
>> >> >>  	memset(ring_header->desc, 0, ring_header->size);
>> >> >> 
>> >> >> 
>> >> > 
>> >> > So this memset() will really require a different patch to get removed ?
>> >> > 
>> >> > Sigh, not sure why I review patches.
>> >> 
>> >> Agreed, please use dma_zalloc_coherent() and kill that memset().
>> > 
>> > Ok, updated. I'll also add cc: stable, because it makes notebooks with
>> > affected chipset unusable.
>> 
>> Networking patches do not use CC: stable, instead you simply ask me
>> to queue it up and then I batch submit networking fixes to -stable
>> periodically myself.
> 
> Ok, can you take the patch and ignore the Cc, or should I do one more
> iteration?

I took care of it.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 2795d6d..afb71e0 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1016,10 +1016,10 @@  static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
 		sizeof(struct atl1c_recv_ret_status) * rx_desc_count +
 		8 * 4;
 
-	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
-				&ring_header->dma);
+	ring_header->desc = dma_alloc_coherent(&pdev->dev, ring_header->size,
+					       &ring_header->dma, GFP_KERNEL);
 	if (unlikely(!ring_header->desc)) {
-		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
+		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
 		goto err_nomem;
 	}
 	memset(ring_header->desc, 0, ring_header->size);