linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: intel_hdmi: Check for error num after setting mask
@ 2022-01-06  1:24 Jiasheng Jiang
  2022-01-06  8:18 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-06  1:24 UTC (permalink / raw)
  To: perex, tiwai, leon, broonie, joe; +Cc: alsa-devel, linux-kernel, Jiasheng Jiang

As the dma_supported() may fail, the dma_set_mask_and_coherent() may
fail too.
Therefore, it should be better to check it and return error if fails.

Fixes: da8648097497 ("ALSA: x86: Flatten two abstraction layers")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 sound/x86/intel_hdmi_audio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 33b12aa67cf5..6caea517f07f 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1770,7 +1770,9 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 	card_ctx->irq = irq;
 
 	/* only 32bit addressable */
-	dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (ret)
+		goto err;
 
 	init_channel_allocations();
 
-- 
2.25.1


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

* Re: [PATCH] ALSA: intel_hdmi: Check for error num after setting mask
  2022-01-06  1:24 [PATCH] ALSA: intel_hdmi: Check for error num after setting mask Jiasheng Jiang
@ 2022-01-06  8:18 ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2022-01-06  8:18 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: perex, tiwai, leon, broonie, joe, alsa-devel, linux-kernel

On Thu, 06 Jan 2022 02:24:28 +0100,
Jiasheng Jiang wrote:
> 
> As the dma_supported() may fail, the dma_set_mask_and_coherent() may
> fail too.
> Therefore, it should be better to check it and return error if fails.
> 
> Fixes: da8648097497 ("ALSA: x86: Flatten two abstraction layers")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Well, 32bit DMA mask practically never fails on x86 (and other
architectures, IIRC).  It's fine to add a sanity check, but it's
better to be mentioned that it never fails.


thanks,

Takashi

> ---
>  sound/x86/intel_hdmi_audio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
> index 33b12aa67cf5..6caea517f07f 100644
> --- a/sound/x86/intel_hdmi_audio.c
> +++ b/sound/x86/intel_hdmi_audio.c
> @@ -1770,7 +1770,9 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
>  	card_ctx->irq = irq;
>  
>  	/* only 32bit addressable */
> -	dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		goto err;
>  
>  	init_channel_allocations();
>  
> -- 
> 2.25.1
> 

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

* Re: [PATCH] ALSA: intel_hdmi: Check for error num after setting mask
  2022-01-06  8:41 Jiasheng Jiang
@ 2022-01-06  9:34 ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2022-01-06  9:34 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: perex, tiwai, leon, broonie, joe, alsa-devel, linux-kernel

On Thu, 06 Jan 2022 09:41:10 +0100,
Jiasheng Jiang wrote:
> 
> On Thu, Jan 06, 2022 at 04:18:01PM +0800, Takashi Iwai wrote:
> > Well, 32bit DMA mask practically never fails on x86 (and other
> > architectures, IIRC).  It's fine to add a sanity check, but it's
> > better to be mentioned that it never fails.
> 
> Actually, I have already found many place check the 32bit DMA mask.
> For example:
> snd_ad1889_create() in `sound/pci/ad1889.c`, 
> snd_vortex_create() in `sound/pci/au88x0/au88x0.c`
> tegra_pcm_dma_allocate() in `sound/soc/tegra/tegra_pcm.c`.
> Therefore, I think there must be some reason that 32bit may fail.
> So, to make the system more robust, it should be better to add the
> sanity check.

Yes, as mentioned, it's fine to add a sanity check, but it's rather
for consistency of the code, not actually fixing any real issue.
At least it's better to rephrase the commit message for avoiding
confusion for readers.


thanks,

Takashi

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

end of thread, other threads:[~2022-01-06  9:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  1:24 [PATCH] ALSA: intel_hdmi: Check for error num after setting mask Jiasheng Jiang
2022-01-06  8:18 ` Takashi Iwai
2022-01-06  8:41 Jiasheng Jiang
2022-01-06  9:34 ` Takashi Iwai

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).