All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
@ 2018-04-16  9:26 David Wang
  2018-04-16 12:33 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: David Wang @ 2018-04-16  9:26 UTC (permalink / raw)
  To: tglx, mingo, hpa, gregkh, x86, linux-kernel
  Cc: brucechang, cooperyan, qiyuanwang, benjaminpan, lukelin, timguo,
	David Wang

PCI bridges integrated in new VIA chipset/SoC have no DAC issue.
Enable DAC for the platforms with these chipset/SoC can improve DMA performance about
20% when DRAM size > 4GB.

Signed-off-by: David Wang <davidwang@zhaoxin.com>
---
 arch/x86/kernel/pci-dma.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index cb9c1fa..6e37b0e 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -47,6 +47,10 @@
 
 extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
 
+#ifdef CONFIG_PCI
+static int override_via_dac __read_mostly;
+#endif
+
 /* Dummy device used for NULL arguments (normally ISA). */
 struct device x86_dma_fallback_dev = {
 	.init_name = "fallback device",
@@ -279,6 +283,9 @@ static int __init pci_iommu_init(void)
 
 static void via_no_dac(struct pci_dev *dev)
 {
+	if (override_via_dac)
+		return;
+
 	if (forbid_dac == 0) {
 		dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n");
 		forbid_dac = 1;
@@ -286,4 +293,19 @@ static void via_no_dac(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
 				PCI_CLASS_BRIDGE_PCI, 8, via_no_dac);
+
+static void via_can_dac(struct pci_dev *dev)
+{
+	/*
+	 * New VIA bridges have no issues for DAC.
+	 * Disable the "via_no_dac" fixup code for these new VIA bridges.
+	 */
+	override_via_dac = 1;
+}
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, 0x345B,
+				PCI_CLASS_BRIDGE_ISA, 8, via_can_dac);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, 0x1001,
+				PCI_CLASS_BRIDGE_ISA, 8, via_can_dac);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, 0x300A,
+				PCI_CLASS_BRIDGE_ISA, 8, via_can_dac);
 #endif
-- 
1.9.1

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

* Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
  2018-04-16  9:26 [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges David Wang
@ 2018-04-16 12:33 ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-04-16 12:33 UTC (permalink / raw)
  To: David Wang
  Cc: tglx, mingo, hpa, gregkh, x86, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan, lukelin, timguo

On Mon, Apr 16, 2018 at 05:26:56PM +0800, David Wang wrote:
> PCI bridges integrated in new VIA chipset/SoC have no DAC issue.
> Enable DAC for the platforms with these chipset/SoC can improve DMA performance about
> 20% when DRAM size > 4GB.
> 

So we get an exception to an exception?  Is there any way to figure
out the PCI IDs actually affected?

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

* Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
  2018-04-17 13:00   ` 'Christoph Hellwig'
@ 2018-04-17 13:33     ` Thomas Gleixner
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Gleixner @ 2018-04-17 13:33 UTC (permalink / raw)
  To: 'Christoph Hellwig'
  Cc: David Wang, mingo, hpa, gregkh, x86, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan, lukelin, timguo

On Tue, 17 Apr 2018, 'Christoph Hellwig' wrote:
> On Tue, Apr 17, 2018 at 10:54:37AM +0200, Thomas Gleixner wrote:
> > The question was rather to have a list of PCI IDs for those chipsets which
> > have the problem and set the 'disable' flag only for those. That makes a lot
> > more sense than making a list of new chips which disable the disable flag.
> 
> Agreed.
> 
> There are a few other things I'd like to do in this area while we're
> at it (I'm happy to do the work, not trying to offload it to David
> or Thomas):
> 
>  (1) make the nodac flag a per-device flag.  Set for every device
>      under one of the affected VIA bridges, or for all PCI devices
>      if the nodac command line option is used
>  (2) move that flag into the common struct device (or the to be
>      designed dma struct hanging off it in the future) and make that
>      bit handled in common code as there is a common Xilinx host
>      bridge with a 32-bit dma limitation
>  (3) kill of the forcesac option, which was a strange performance
>      tweak back in plain PCI days, which probably didn't even work
>      as expected to start with.

Sounds good.

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

* Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
  2018-04-17  8:54 ` Thomas Gleixner
@ 2018-04-17 13:00   ` 'Christoph Hellwig'
  2018-04-17 13:33     ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: 'Christoph Hellwig' @ 2018-04-17 13:00 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Wang, 'Christoph Hellwig',
	mingo, hpa, gregkh, x86, linux-kernel, brucechang, cooperyan,
	qiyuanwang, benjaminpan, lukelin, timguo

On Tue, Apr 17, 2018 at 10:54:37AM +0200, Thomas Gleixner wrote:
> The question was rather to have a list of PCI IDs for those chipsets which
> have the problem and set the 'disable' flag only for those. That makes a lot
> more sense than making a list of new chips which disable the disable flag.

Agreed.

There are a few other things I'd like to do in this area while we're
at it (I'm happy to do the work, not trying to offload it to David
or Thomas):

 (1) make the nodac flag a per-device flag.  Set for every device
     under one of the affected VIA bridges, or for all PCI devices
     if the nodac command line option is used
 (2) move that flag into the common struct device (or the to be
     designed dma struct hanging off it in the future) and make that
     bit handled in common code as there is a common Xilinx host
     bridge with a 32-bit dma limitation
 (3) kill of the forcesac option, which was a strange performance
     tweak back in plain PCI days, which probably didn't even work
     as expected to start with.

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

* Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
  2018-04-17  8:44 David Wang
@ 2018-04-17  8:54 ` Thomas Gleixner
  2018-04-17 13:00   ` 'Christoph Hellwig'
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2018-04-17  8:54 UTC (permalink / raw)
  To: David Wang
  Cc: 'Christoph Hellwig',
	mingo, hpa, gregkh, x86, linux-kernel, brucechang, cooperyan,
	qiyuanwang, benjaminpan, lukelin, timguo

On Tue, 17 Apr 2018, David Wang wrote:
> > On Mon, Apr 16, 2018 at 05:26:56PM +0800, David Wang wrote:
> > > PCI bridges integrated in new VIA chipset/SoC have no DAC issue.
> > > Enable DAC for the platforms with these chipset/SoC can improve DMA
> > > performance about 20% when DRAM size > 4GB.
> > >
> > 
> > So we get an exception to an exception?  Is there any way to figure out
> the
> > PCI IDs actually affected?
> Yes.
> 
> Do you mean we should list the PCI IDs of the PCI bridges which have no DAC
> issue?

The question was rather to have a list of PCI IDs for those chipsets which
have the problem and set the 'disable' flag only for those. That makes a lot
more sense than making a list of new chips which disable the disable flag.

Thanks,

	tglx

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

* Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges
@ 2018-04-17  8:44 David Wang
  2018-04-17  8:54 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: David Wang @ 2018-04-17  8:44 UTC (permalink / raw)
  To: 'Christoph Hellwig'
  Cc: tglx, mingo, hpa, gregkh, x86, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan, lukelin, timguo



> -----邮件原件-----
> 发件人: Christoph Hellwig [mailto:hch@infradead.org]
> 发送时间: 2018年4月16日 20:34
> 收件人: David Wang <davidwang@zhaoxin.com>
> 抄送: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com;
> gregkh@linuxfoundation.org; x86@kernel.org; linux-
> kernel@vger.kernel.org; brucechang@via-alliance.com;
> cooperyan@zhaoxin.com; qiyuanwang@zhaoxin.com;
> benjaminpan@viatech.com; lukelin@viacpu.com; timguo@zhaoxin.com
> 主题: Re: [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI
> bridges
> 
> On Mon, Apr 16, 2018 at 05:26:56PM +0800, David Wang wrote:
> > PCI bridges integrated in new VIA chipset/SoC have no DAC issue.
> > Enable DAC for the platforms with these chipset/SoC can improve DMA
> > performance about 20% when DRAM size > 4GB.
> >
> 
> So we get an exception to an exception?  Is there any way to figure out
the
> PCI IDs actually affected?
Yes.

Do you mean we should list the PCI IDs of the PCI bridges which have no DAC
issue?
There are lots of PCI bridges(PCIE root ports) in our new chipsets/SoCs. And
no DMA issues found. 
So, we only want to recognize the chipset/SoC by reading VID/DID of Bus 0,
Device 17, function 0.

Thx.
---
David

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

end of thread, other threads:[~2018-04-17 13:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16  9:26 [PATCH] x86/dma-mapping: override via_no_dac for new VIA PCI bridges David Wang
2018-04-16 12:33 ` Christoph Hellwig
2018-04-17  8:44 David Wang
2018-04-17  8:54 ` Thomas Gleixner
2018-04-17 13:00   ` 'Christoph Hellwig'
2018-04-17 13:33     ` Thomas Gleixner

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.