All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Alex Deucher <alexdeucher@gmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Dave Airlie <airlied@linux.ie>,
	Brian King <brking@linux.vnet.ibm.com>,
	linux-pci@vger.kernel.org, Yijing Wang <wangyijing@huawei.com>,
	Anton Blanchard <anton@au1.ibm.com>,
	linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 4/4] sounds/hda/radeon: Disable 64-bit DMA on radeon
Date: Wed, 01 Oct 2014 10:09:28 +0200	[thread overview]
Message-ID: <s5hr3ys43ev.wl-tiwai@suse.de> (raw)
In-Reply-To: <1412149289.4285.204.camel@pasglop>

At Wed, 01 Oct 2014 17:41:29 +1000,
Benjamin Herrenschmidt wrote:
> 
> On Wed, 2014-10-01 at 09:38 +0200, Takashi Iwai wrote:
> 
> > > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> > > index 3e6d22d..2b679d5 100644
> > > --- a/sound/pci/hda/hda_intel.c
> > > +++ b/sound/pci/hda/hda_intel.c
> > > @@ -297,7 +297,7 @@ enum {
> > >  /* quirks for ATI/AMD HDMI */
> > >  #define AZX_DCAPS_PRESET_ATI_HDMI \
> > >  	(AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB|\
> > > -	 AZX_DCAPS_NO_MSI64)
> > > +	 AZX_DCAPS_NO_MSI64 | AZX_DCAPS_NO_64BIT)
> > 
> > The only concern is that this will disable 64bit DMA also on x86 where
> > it has been working fine.  Can we add an ifdef CONFIG_PPC for this?
> 
> I don't like that approach because technically the chip doesn't do
> 64-bit DMA ... it does something like 40 or 48 (might actually depend on
> the chip version) and for all I know it will break on future x86 with
> more memory or other platforms with similar address encodings as
> powerpc...
> 
> The right thing might be to get the exact number of bits and do the
> appropriate dma_set_mask() like the graphics driver does, but that's a
> bit tricky unless we add a DMA mask field in that big array of chips in
> there...

I think setting the dma mask explicitly would be a better approach
although it results in a bit bigger change.  At least, it would impact
less than forcing 32bit DMA, as most desktop machines have less than
40bit address.  How about a patch like below?  Only compile tested,
and feel free to add more tags or edit comments appropriately.
(I'm on vacation now, so have little time to type :)


thanks,

Takashi

---
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: hda - Limit 40bit DMA for AMD HDMI controllers

AMD/ATI HDMI controller chip models, we already have a filter to lower
to 32bit DMA, but the rest are supposed to be working with 64bit
although the hardware doesn't really work with 64bit but only with 40
or 48bit DMA.  In this patch, we take 40bit DMA for safety for the
AMD/ATI controllers as the graphics drivers does.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_intel.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index aa302fb03fc5..6410a3edf8ff 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1482,6 +1482,7 @@ static int azx_first_init(struct azx *chip)
 	struct snd_card *card = chip->card;
 	int err;
 	unsigned short gcap;
+	unsigned int dma_bits = 64;
 
 #if BITS_PER_LONG != 64
 	/* Fix up base address on ULI M5461 */
@@ -1521,6 +1522,8 @@ static int azx_first_init(struct azx *chip)
 	/* disable SB600 64bit support for safety */
 	if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
 		struct pci_dev *p_smbus;
+		/* AMD devices support 40 or 48bit DMA, take the safe one */
+		dma_bits = 40;
 		p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
 					 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
 					 NULL);
@@ -1550,9 +1553,11 @@ static int azx_first_init(struct azx *chip)
 	}
 
 	/* allow 64bit DMA address if supported by H/W */
-	if ((gcap & AZX_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
-		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
-	else {
+	if (!(gcap & AZX_GCAP_64OK))
+		dma_bits = 32;
+	if (!pci_set_dma_mask(pci, DMA_BIT_MASK(dma_bits))) {
+		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(dma_bits));
+	} else {
 		pci_set_dma_mask(pci, DMA_BIT_MASK(32));
 		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
 	}
-- 
2.1.0


WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, Dave Airlie <airlied@linux.ie>,
	linux-pci@vger.kernel.org, Brian King <brking@linux.vnet.ibm.com>,
	Anton Blanchard <anton@au1.ibm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Yijing Wang <wangyijing@huawei.com>,
	Alex Deucher <alexdeucher@gmail.com>
Subject: Re: [PATCH 4/4] sounds/hda/radeon: Disable 64-bit DMA on radeon
Date: Wed, 01 Oct 2014 10:09:28 +0200	[thread overview]
Message-ID: <s5hr3ys43ev.wl-tiwai@suse.de> (raw)
In-Reply-To: <1412149289.4285.204.camel@pasglop>

At Wed, 01 Oct 2014 17:41:29 +1000,
Benjamin Herrenschmidt wrote:
> 
> On Wed, 2014-10-01 at 09:38 +0200, Takashi Iwai wrote:
> 
> > > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> > > index 3e6d22d..2b679d5 100644
> > > --- a/sound/pci/hda/hda_intel.c
> > > +++ b/sound/pci/hda/hda_intel.c
> > > @@ -297,7 +297,7 @@ enum {
> > >  /* quirks for ATI/AMD HDMI */
> > >  #define AZX_DCAPS_PRESET_ATI_HDMI \
> > >  	(AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB|\
> > > -	 AZX_DCAPS_NO_MSI64)
> > > +	 AZX_DCAPS_NO_MSI64 | AZX_DCAPS_NO_64BIT)
> > 
> > The only concern is that this will disable 64bit DMA also on x86 where
> > it has been working fine.  Can we add an ifdef CONFIG_PPC for this?
> 
> I don't like that approach because technically the chip doesn't do
> 64-bit DMA ... it does something like 40 or 48 (might actually depend on
> the chip version) and for all I know it will break on future x86 with
> more memory or other platforms with similar address encodings as
> powerpc...
> 
> The right thing might be to get the exact number of bits and do the
> appropriate dma_set_mask() like the graphics driver does, but that's a
> bit tricky unless we add a DMA mask field in that big array of chips in
> there...

I think setting the dma mask explicitly would be a better approach
although it results in a bit bigger change.  At least, it would impact
less than forcing 32bit DMA, as most desktop machines have less than
40bit address.  How about a patch like below?  Only compile tested,
and feel free to add more tags or edit comments appropriately.
(I'm on vacation now, so have little time to type :)


thanks,

Takashi

---
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: hda - Limit 40bit DMA for AMD HDMI controllers

AMD/ATI HDMI controller chip models, we already have a filter to lower
to 32bit DMA, but the rest are supposed to be working with 64bit
although the hardware doesn't really work with 64bit but only with 40
or 48bit DMA.  In this patch, we take 40bit DMA for safety for the
AMD/ATI controllers as the graphics drivers does.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_intel.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index aa302fb03fc5..6410a3edf8ff 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1482,6 +1482,7 @@ static int azx_first_init(struct azx *chip)
 	struct snd_card *card = chip->card;
 	int err;
 	unsigned short gcap;
+	unsigned int dma_bits = 64;
 
 #if BITS_PER_LONG != 64
 	/* Fix up base address on ULI M5461 */
@@ -1521,6 +1522,8 @@ static int azx_first_init(struct azx *chip)
 	/* disable SB600 64bit support for safety */
 	if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
 		struct pci_dev *p_smbus;
+		/* AMD devices support 40 or 48bit DMA, take the safe one */
+		dma_bits = 40;
 		p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
 					 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
 					 NULL);
@@ -1550,9 +1553,11 @@ static int azx_first_init(struct azx *chip)
 	}
 
 	/* allow 64bit DMA address if supported by H/W */
-	if ((gcap & AZX_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
-		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
-	else {
+	if (!(gcap & AZX_GCAP_64OK))
+		dma_bits = 32;
+	if (!pci_set_dma_mask(pci, DMA_BIT_MASK(dma_bits))) {
+		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(dma_bits));
+	} else {
 		pci_set_dma_mask(pci, DMA_BIT_MASK(32));
 		pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
 	}
-- 
2.1.0

  parent reply	other threads:[~2014-10-01  8:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-01  2:09 [PATCH 4/4] sounds/hda/radeon: Disable 64-bit DMA on radeon Benjamin Herrenschmidt
2014-10-01  2:09 ` Benjamin Herrenschmidt
2014-10-01  7:38 ` Takashi Iwai
2014-10-01  7:38   ` Takashi Iwai
2014-10-01  7:41   ` Benjamin Herrenschmidt
2014-10-01  7:41     ` Benjamin Herrenschmidt
2014-10-01  7:48     ` Benjamin Herrenschmidt
2014-10-01  7:48       ` Benjamin Herrenschmidt
2014-10-01  8:09     ` Takashi Iwai [this message]
2014-10-01  8:09       ` Takashi Iwai
2014-10-01  8:30       ` Takashi Iwai
2014-10-01  8:30         ` Takashi Iwai
2014-10-01 17:58         ` Alex Deucher
2014-10-01 17:58           ` Alex Deucher
2014-10-01 22:08           ` Benjamin Herrenschmidt
2014-10-01 22:08             ` Benjamin Herrenschmidt
2014-10-02  0:15             ` Benjamin Herrenschmidt
2014-10-02  0:15               ` Benjamin Herrenschmidt
2014-10-02  1:19             ` Alex Deucher
2014-10-02  1:19               ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hr3ys43ev.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=airlied@linux.ie \
    --cc=alexdeucher@gmail.com \
    --cc=anton@au1.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=wangyijing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.