Skip to contentSkip to conversation

Patch "ALSA: ctxfi: Fallback DMA mask to 32bit" has been added to the 4.4-stable tree

PATCH [email protected] 3 participants 5 messages Mar 8, 2017 – Mar 20, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

ALSA: ctxfi: Fallback DMA mask to 32bit

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
alsa-ctxfi-fallback-dma-mask-to-32bit.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 15c75b09f8d190f89ab4db463b87d411ca349dfe Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Tue, 28 Feb 2017 17:16:48 +0100
Subject: ALSA: ctxfi: Fallback DMA mask to 32bit

From: Takashi Iwai <[email protected]>

commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit architectures, and bails out if it fails. This causes a problem on some platforms since the 64bit DMA isn't always guaranteed. We should fall back to the default 32bit DMA when 64bit DMA fails.

Fixes 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")
---
 sound/pci/ctxfi/cthw20k1.c |   19 ++++++-------------
 sound/pci/ctxfi/cthw20k2.c |   19 ++++++-------------
 2 files changed, 12 insertions(+), 26 deletions(-)
sound/pci/ctxfi/cthw20k1.c +6 -13
@@ -27,12 +27,6 @@
 #include "cthw20k1.h"
 #include "ct20k1reg.h"
 
-#if BITS_PER_LONG == 32
-#define CT_XFI_DMA_MASK		DMA_BIT_MASK(32) /* 32 bit PTE */
-#else
-#define CT_XFI_DMA_MASK		DMA_BIT_MASK(64) /* 64 bit PTE */
-#endif
-
 struct hw20k1 {
 	struct hw hw;
 	spinlock_t reg_20k1_lock;
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
 	int err;
 	struct pci_dev *pci = hw->pci;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
 	}
 
 	if (!hw->io_base) {
sound/pci/ctxfi/cthw20k2.c +6 -13
@@ -26,12 +26,6 @@
 #include "cthw20k2.h"
 #include "ct20k2reg.h"
 
-#if BITS_PER_LONG == 32
-#define CT_XFI_DMA_MASK		DMA_BIT_MASK(32) /* 32 bit PTE */
-#else
-#define CT_XFI_DMA_MASK		DMA_BIT_MASK(64) /* 64 bit PTE */
-#endif
-
 struct hw20k2 {
 	struct hw hw;
 	/* for i2c */
@@ -2029,19 +2023,18 @@ static int hw_card_start(struct hw *hw)
 	int err = 0;
 	struct pci_dev *pci = hw->pci;
 	unsigned int gctl;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
 	}
 
 	if (!hw->io_base) {

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/alsa-hda-add-subwoofer-support-for-dell-inspiron-17-7000-gaming.patch queue-4.4/alsa-seq-fix-link-corruption-by-event-error-handling.patch queue-4.4/alsa-hda-fix-micmute-hotkey-problem-for-a-lenovo-aio-machine.patch queue-4.4/alsa-ctxfi-fallback-dma-mask-to-32bit.patch queue-4.4/alsa-timer-reject-user-params-with-too-small-ticks.patch queue-4.4/alsa-hda-fix-lewisburg-audio-issue.patch queue-4.4/alsa-hda-realtek-cannot-adjust-speaker-s-volume-on-a-dell-aio.patch

#1 lore raw
Quoted 17 lines · On 03/08/2017, 11:27 AM, [email protected] wrote:

From 15c75b09f8d190f89ab4db463b87d411ca349dfe Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 28 Feb 2017 17:16:48 +0100
Subject: ALSA: ctxfi: Fallback DMA mask to 32bit

From: Takashi Iwai <[email protected]>

commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit architectures, and bails out if it fails. This causes a problem on some platforms since the 64bit DMA isn't always guaranteed. We should fall back to the default 32bit DMA when 64bit DMA fails.

Fixes 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")

...

Quoted 9 lines
sound/pci/ctxfi/cthw20k1.c +1 -0
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
 	int err;
 	struct pci_dev *pci = hw->pci;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1908

Quoted 10 lines
sound/pci/ctxfi/cthw20k1.c +1 -7
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {

I believe the condition is inverted here.

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1912

Quoted 4 lines
sound/pci/ctxfi/cthw20k1.c +4 -0
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));

thanks,

Signature · 2 lines
js
suse labs
author maintainer
#2 lore raw
Quoted 41 lines · Jiri Slaby
Quoted 17 lines · On 03/08/2017, 11:27 AM, [email protected] wrote:

From 15c75b09f8d190f89ab4db463b87d411ca349dfe Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 28 Feb 2017 17:16:48 +0100
Subject: ALSA: ctxfi: Fallback DMA mask to 32bit

From: Takashi Iwai <[email protected]>

commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit architectures, and bails out if it fails. This causes a problem on some platforms since the 64bit DMA isn't always guaranteed. We should fall back to the default 32bit DMA when 64bit DMA fails.

Fixes 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")

...

Quoted 9 lines
sound/pci/ctxfi/cthw20k1.c +1 -0
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
 	int err;
 	struct pci_dev *pci = hw->pci;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1908

Quoted 10 lines
sound/pci/ctxfi/cthw20k1.c +1 -7
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {

I believe the condition is inverted here.

Quoted 4 lines

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1912

Quoted 4 lines
sound/pci/ctxfi/cthw20k1.c +4 -0
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));

As this matches what is in Linus's tree, that means I didn't mess up the backport :)

But I don't understand the issue, what is wrong here? Should it try 32 first?

Takashi, any thoughts?

thanks,

greg k-h

#3 lore raw
Quoted 42 lines · Greg KH
Quoted 41 lines · Jiri Slaby
Quoted 17 lines · On 03/08/2017, 11:27 AM, [email protected] wrote:

From 15c75b09f8d190f89ab4db463b87d411ca349dfe Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 28 Feb 2017 17:16:48 +0100
Subject: ALSA: ctxfi: Fallback DMA mask to 32bit

From: Takashi Iwai <[email protected]>

commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit architectures, and bails out if it fails. This causes a problem on some platforms since the 64bit DMA isn't always guaranteed. We should fall back to the default 32bit DMA when 64bit DMA fails.

Fixes 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")

...

Quoted 9 lines
sound/pci/ctxfi/cthw20k1.c +1 -0
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
 	int err;
 	struct pci_dev *pci = hw->pci;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1908

Quoted 10 lines
sound/pci/ctxfi/cthw20k1.c +1 -7
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {

I believe the condition is inverted here.

Quoted 7 lines
Quoted 4 lines

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1912

Quoted 4 lines
sound/pci/ctxfi/cthw20k1.c +4 -0
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));

As this matches what is in Linus's tree, that means I didn't mess up the backport :)

Sure, I didn't mean to point out your failure, rather Takashi wrote the check wrong :). I found it in 4.4 patches while applying them, so I replied to that particular one.

Quoted 2 lines

But I don't understand the issue, what is wrong here? Should it try 32 first?

It should be:
dma_set_mask(dma_bits) fails => fall back to 32 bits dma_set_mask(dma_bits) does not fail => set also the coherent mask

As it stands now, it is the opposite.

Quoted 1 line

Takashi, any thoughts?

IMO, it should write:

Quoted 2 lines
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
   dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));

thanks,

Signature · 2 lines
js
suse labs
#4 lore raw
Quoted 52 lines · Jiri Slaby
Quoted 42 lines · Greg KH
Quoted 41 lines · Jiri Slaby
Quoted 17 lines · On 03/08/2017, 11:27 AM, [email protected] wrote:

From 15c75b09f8d190f89ab4db463b87d411ca349dfe Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 28 Feb 2017 17:16:48 +0100
Subject: ALSA: ctxfi: Fallback DMA mask to 32bit

From: Takashi Iwai <[email protected]>

commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit architectures, and bails out if it fails. This causes a problem on some platforms since the 64bit DMA isn't always guaranteed. We should fall back to the default 32bit DMA when 64bit DMA fails.

Fixes 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")

...

Quoted 9 lines
sound/pci/ctxfi/cthw20k1.c +1 -0
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
 	int err;
 	struct pci_dev *pci = hw->pci;
+	const unsigned int dma_bits = BITS_PER_LONG;
 
 	err = pci_enable_device(pci);
 	if (err < 0)
 		return err;

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1908

Quoted 10 lines
sound/pci/ctxfi/cthw20k1.c +1 -7
 
 	/* Set DMA transfer mask */
-	if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-	    dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-		dev_err(hw->card->dev,
-			"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-			CT_XFI_DMA_MASK);
-		err = -ENXIO;
-		goto error1;
+	if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {

I believe the condition is inverted here.

Quoted 7 lines
Quoted 4 lines

sound/pci/ctxfi/cthw20k1.c static int hw_card_start(struct hw *hw) · line 1912

Quoted 4 lines
sound/pci/ctxfi/cthw20k1.c +4 -0
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+	} else {
+		dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+		dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));

As this matches what is in Linus's tree, that means I didn't mess up the backport :)

Quoted 2 lines

Sure, I didn't mean to point out your failure, rather Takashi wrote the check wrong :).

Sorry for the late response, as I've been on vacation over two weeks.

And another sorry about the patch -- it's simply an incorrect cut & paste & modify sequence.

I'll queue up the correction patch for the next 4.11-rc soon later.

thanks,

Takashi