netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ATHEROS-ALX: Use dma_set_mask_and_coherent and fix a bug
@ 2014-03-15 18:19 Peter Senna Tschudin
  2014-03-15 23:56 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Senna Tschudin @ 2014-03-15 18:19 UTC (permalink / raw)
  To: jcliburn, chris.snook, davem, johannes, jg1.han, wangyijing,
	linux, sd, hahnjo, netdev, linux-kernel, kernel-janitors
  Cc: Peter Senna Tschudin

 1. For the 64 bits dma mask use dma_set_mask_and_coherent instead of
 dma_set_mask and dma_set_coherent_mask.

 2. For the 32 bits dma mask dma_set_coherent_mask is only called if
 dma_set_mask fails, which is unusual. Assuming this as a bug, fixes
 it by replacing calls to dma_set_mask and dma_set_coherent_mask by a
 call to dma_set_coherent_mask.
 
 Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---

 Tested by compilation only.

 drivers/net/ethernet/atheros/alx/main.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 2e45f6e..380d249 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1248,19 +1248,13 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * shared register for the high 32 bits, so only a single, aligned,
 	 * 4 GB physical address range can be used for descriptors.
 	 */
-	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
-	    !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+	if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
 		dev_dbg(&pdev->dev, "DMA to 64-BIT addresses\n");
 	} else {
-		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 		if (err) {
-			err = dma_set_coherent_mask(&pdev->dev,
-						    DMA_BIT_MASK(32));
-			if (err) {
-				dev_err(&pdev->dev,
-					"No usable DMA config, aborting\n");
-				goto out_pci_disable;
-			}
+			dev_err(&pdev->dev, "No usable DMA config, aborting\n");
+			goto out_pci_disable;
 		}
 	}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ATHEROS-ALX: Use dma_set_mask_and_coherent and fix a bug
  2014-03-15 18:19 [PATCH] ATHEROS-ALX: Use dma_set_mask_and_coherent and fix a bug Peter Senna Tschudin
@ 2014-03-15 23:56 ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2014-03-15 23:56 UTC (permalink / raw)
  To: Peter Senna Tschudin, jcliburn, chris.snook, davem, johannes,
	jg1.han, wangyijing, linux, sd, hahnjo, netdev, linux-kernel,
	kernel-janitors

Hello.

On 03/15/2014 09:19 PM, Peter Senna Tschudin wrote:

>   1. For the 64 bits dma mask use dma_set_mask_and_coherent instead of
>   dma_set_mask and dma_set_coherent_mask.

>   2. For the 32 bits dma mask dma_set_coherent_mask is only called if
>   dma_set_mask fails, which is unusual. Assuming this as a bug, fixes
>   it by replacing calls to dma_set_mask and dma_set_coherent_mask by a
>   call to dma_set_coherent_mask.

    You meant to say dma_set_mask_and_coherent() here?

>   Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> ---

>   Tested by compilation only.

>   drivers/net/ethernet/atheros/alx/main.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)

> diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
> index 2e45f6e..380d249 100644
> --- a/drivers/net/ethernet/atheros/alx/main.c
> +++ b/drivers/net/ethernet/atheros/alx/main.c
> @@ -1248,19 +1248,13 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	 * shared register for the high 32 bits, so only a single, aligned,
>   	 * 4 GB physical address range can be used for descriptors.
>   	 */
> -	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
> -	    !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
> +	if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
>   		dev_dbg(&pdev->dev, "DMA to 64-BIT addresses\n");
>   	} else {
> -		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> +		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>   		if (err) {
> -			err = dma_set_coherent_mask(&pdev->dev,
> -						    DMA_BIT_MASK(32));
> -			if (err) {
> -				dev_err(&pdev->dev,
> -					"No usable DMA config, aborting\n");
> -				goto out_pci_disable;
> -			}
> +			dev_err(&pdev->dev, "No usable DMA config, aborting\n");
> +			goto out_pci_disable;
>   		}
>   	}

WBR, Sergei

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-15 23:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 18:19 [PATCH] ATHEROS-ALX: Use dma_set_mask_and_coherent and fix a bug Peter Senna Tschudin
2014-03-15 23:56 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).