diff mbox series

net: altera: Handle dma_set_coherent_mask error codes

Message ID 20220714132342.13051-1-kda@linux-powerpc.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: altera: Handle dma_set_coherent_mask error codes | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
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: 0 this patch: 0
netdev/cc_maintainers fail 2 blamed authors not CCed: vbridgers2013@gmail.com davem@davemloft.net; 6 maintainers not CCed: edumazet@google.com pabeni@redhat.com vbridgers2013@gmail.com davem@davemloft.net kuba@kernel.org joyce.ooi@intel.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/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning CHECK: Alignment should match open parenthesis
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Denis Kirjanov July 14, 2022, 1:23 p.m. UTC
handle the error in the case that DMA mask is not supportyed

Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski July 15, 2022, 11:44 p.m. UTC | #1
On Thu, 14 Jul 2022 16:23:42 +0300 Denis Kirjanov wrote:
> handle the error in the case that DMA mask is not supportyed
> 
> Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
>  drivers/net/ethernet/altera/altera_tse_main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index 8c5828582c21..7773d978321a 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -1439,10 +1439,14 @@ static int altera_tse_probe(struct platform_device *pdev)
>  	}
>  
>  	if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) {
> -		dma_set_coherent_mask(priv->device,
> +		ret = dma_set_coherent_mask(priv->device,
>  				      DMA_BIT_MASK(priv->dmaops->dmamask));
> +		if (ret)
> +			goto err_free_netdev;
>  	} else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) {
> -		dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
> +		ret = dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
> +		if (ret)
> +			goto err_free_netdev;
>  	} else {
>  		ret = -EIO;
>  		goto err_free_netdev;

Practically speaking this can't fail, see Christophe's patches like 
b6f2f0352c0302

If you want to be on the safe side just replace the dma_set_mask()
with dma_set_mask_and_coherent() and let the else branch handle the
failure.

Please CC maintainers when reposting.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 8c5828582c21..7773d978321a 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -1439,10 +1439,14 @@  static int altera_tse_probe(struct platform_device *pdev)
 	}
 
 	if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) {
-		dma_set_coherent_mask(priv->device,
+		ret = dma_set_coherent_mask(priv->device,
 				      DMA_BIT_MASK(priv->dmaops->dmamask));
+		if (ret)
+			goto err_free_netdev;
 	} else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) {
-		dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
+		ret = dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
+		if (ret)
+			goto err_free_netdev;
 	} else {
 		ret = -EIO;
 		goto err_free_netdev;