diff mbox series

enic: Use dma_set_mask_and_coherent()

Message ID f926eab883a3e5c4dbfd3eb5108b3e1828e6513b.1641045708.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit c5180ad0c2784924b3526ec2bd3ee9e0aa05724b
Delegated to: Netdev Maintainers
Headers show
Series enic: Use dma_set_mask_and_coherent() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 1 maintainers not CCed: _govind@gmx.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Christophe JAILLET Jan. 1, 2022, 2:02 p.m. UTC
Use dma_set_mask_and_coherent() instead of unrolling it with some
dma_set_mask()+dma_set_coherent_mask().

This simplifies code and removes some dead code (dma_set_coherent_mask()
can not fail after a successful dma_set_mask())

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Jan. 2, 2022, 12:30 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Sat,  1 Jan 2022 15:02:45 +0100 you wrote:
> Use dma_set_mask_and_coherent() instead of unrolling it with some
> dma_set_mask()+dma_set_coherent_mask().
> 
> This simplifies code and removes some dead code (dma_set_coherent_mask()
> can not fail after a successful dma_set_mask())
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> [...]

Here is the summary with links:
  - enic: Use dma_set_mask_and_coherent()
    https://git.kernel.org/netdev/net-next/c/c5180ad0c278

You are awesome, thank you!
Christoph Hellwig Jan. 3, 2022, 8:47 a.m. UTC | #2
On Sat, Jan 01, 2022 at 03:02:45PM +0100, Christophe JAILLET wrote:
> -	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(47));
> +	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
>  	if (err) {
> +		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>  		if (err) {
>  			dev_err(dev, "No usable DMA configuration, aborting\n");
>  			goto err_out_release_regions;
>  		}
>  	} else {
>  		using_dac = 1;

There is no need for the callback.  All the routines to set a DMA mask
will only fail if the passed in mask is too small, but never if it is
larger than what is supported.  Also the using_dac variable is not
needed, NETIF_F_HIGHDMA can and should be set unconditionally.
Christophe JAILLET Jan. 5, 2022, 7:51 p.m. UTC | #3
Le 03/01/2022 à 09:47, Christoph Hellwig a écrit :
> On Sat, Jan 01, 2022 at 03:02:45PM +0100, Christophe JAILLET wrote:
>> -	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(47));
>> +	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
>>   	if (err) {
>> +		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>>   		if (err) {
>>   			dev_err(dev, "No usable DMA configuration, aborting\n");
>>   			goto err_out_release_regions;
>>   		}
>>   	} else {
>>   		using_dac = 1;
> 
> There is no need for the callback.  All the routines to set a DMA mask
> will only fail if the passed in mask is too small, but never if it is
> larger than what is supported.  Also the using_dac variable is not
> needed, NETIF_F_HIGHDMA can and should be set unconditionally.
> 

Ok, thanks.
I was only aware of the 64 bits case.
The patch has already reached -next.

I'll send another patch on to of it to go one step further.

CJ
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 2faba079b4fb..1c81b161de52 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2718,26 +2718,14 @@  static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * fail to 32-bit.
 	 */
 
-	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(47));
+	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
 	if (err) {
-		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 		if (err) {
 			dev_err(dev, "No usable DMA configuration, aborting\n");
 			goto err_out_release_regions;
 		}
-		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-		if (err) {
-			dev_err(dev, "Unable to obtain %u-bit DMA "
-				"for consistent allocations, aborting\n", 32);
-			goto err_out_release_regions;
-		}
 	} else {
-		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(47));
-		if (err) {
-			dev_err(dev, "Unable to obtain %u-bit DMA "
-				"for consistent allocations, aborting\n", 47);
-			goto err_out_release_regions;
-		}
 		using_dac = 1;
 	}