* [PATCH 2/7] ia64: remove the dead iommu_sac_force variable
2018-05-25 14:35 refactor 32-bit dma limit quirks Christoph Hellwig
@ 2018-05-25 14:35 ` Christoph Hellwig
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
` (3 subsequent siblings)
4 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: x86, iommu, linux-kernel, linux-ia64, netdev
Looks like copy and paste from x86 that never actually got used.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/ia64/kernel/pci-dma.c | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index b5df084c0af4..50b6ad282a90 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -18,8 +18,6 @@
dma_addr_t bad_dma_address __read_mostly;
EXPORT_SYMBOL(bad_dma_address);
-static int iommu_sac_force __read_mostly;
-
int no_iommu __read_mostly;
#ifdef CONFIG_IOMMU_DEBUG
int force_iommu __read_mostly = 1;
@@ -61,23 +59,6 @@ int iommu_dma_supported(struct device *dev, u64 mask)
if (mask < DMA_BIT_MASK(24))
return 0;
- /* Tell the device to use SAC when IOMMU force is on. This
- allows the driver to use cheaper accesses in some cases.
-
- Problem with this is that if we overflow the IOMMU area and
- return DAC as fallback address the device may not handle it
- correctly.
-
- As a special case some controllers have a 39bit address
- mode that is as efficient as 32bit (aic79xx). Don't force
- SAC for these. Assume all masks <= 40 bits are of this
- type. Normally this doesn't make any difference, but gives
- more gentle handling of IOMMU overflow. */
- if (iommu_sac_force && (mask >= DMA_BIT_MASK(40))) {
- dev_info(dev, "Force SAC with mask %llx\n", mask);
- return 0;
- }
-
return 1;
}
EXPORT_SYMBOL(iommu_dma_supported);
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread[parent not found: <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>]
* [PATCH 1/7] core, dma-direct: add a flag 32-bit dma limits
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
@ 2018-05-25 14:35 ` Christoph Hellwig
[not found] ` <20180525143512.1466-2-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` [PATCH 3/7] ia64: remove iommu_dma_supported Christoph Hellwig
2018-05-25 14:35 ` [PATCH 4/7] x86: remove a stray reference to pci-nommu.c Christoph Hellwig
2 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-ia64-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Various PCI bridges (VIA PCI, Xilinx PCIe) limit DMA to only 32-bits
even if the device itself supports more. Add a single bit flag to
struct device (to be moved into the dma extension once we around it)
to flag such devices and reject larger DMA to them.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
include/linux/device.h | 3 +++
lib/dma-direct.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 477956990f5e..fa317e45f5e6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -904,6 +904,8 @@ struct dev_links_info {
* @offline: Set after successful invocation of bus type's .offline().
* @of_node_reused: Set if the device-tree node is shared with an ancestor
* device.
+ * @dma_32bit_limit: bridge limited to 32bit DMA even if the device itself
+ * indicates support for a higher limit in the dma_mask field.
*
* At the lowest level, every device in a Linux system is represented by an
* instance of struct device. The device structure contains the information
@@ -992,6 +994,7 @@ struct device {
bool offline_disabled:1;
bool offline:1;
bool of_node_reused:1;
+ bool dma_32bit_limit:1;
};
static inline struct device *kobj_to_dev(struct kobject *kobj)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index bbfb229aa067..0151a7b2bc87 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -165,6 +165,12 @@ int dma_direct_supported(struct device *dev, u64 mask)
if (mask < DMA_BIT_MASK(32))
return 0;
#endif
+ /*
+ * Various PCI/PCIe bridges have broken support for > 32bit DMA even
+ * if the device itself might support it.
+ */
+ if (dev->dma_32bit_limit && mask > DMA_BIT_MASK(32))
+ return 0;
return 1;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH 3/7] ia64: remove iommu_dma_supported
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` [PATCH 1/7] core, dma-direct: add a flag 32-bit dma limits Christoph Hellwig
@ 2018-05-25 14:35 ` Christoph Hellwig
2018-05-25 14:35 ` [PATCH 4/7] x86: remove a stray reference to pci-nommu.c Christoph Hellwig
2 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-ia64-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
The generic dma_direct_supported helper already used by intel-iommu on
x86 does a better job than the ia64 reimplementation.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
arch/ia64/kernel/pci-dma.c | 13 -------------
drivers/iommu/intel-iommu.c | 2 --
2 files changed, 15 deletions(-)
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 50b6ad282a90..3c2884bef3d4 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -51,18 +51,6 @@ iommu_dma_init(void)
return;
}
-int iommu_dma_supported(struct device *dev, u64 mask)
-{
- /* Copied from i386. Doesn't make much sense, because it will
- only work for pci_alloc_coherent.
- The caller just has to use GFP_DMA in this case. */
- if (mask < DMA_BIT_MASK(24))
- return 0;
-
- return 1;
-}
-EXPORT_SYMBOL(iommu_dma_supported);
-
void __init pci_iommu_alloc(void)
{
dma_ops = &intel_dma_ops;
@@ -71,7 +59,6 @@ void __init pci_iommu_alloc(void)
intel_dma_ops.sync_sg_for_cpu = machvec_dma_sync_sg;
intel_dma_ops.sync_single_for_device = machvec_dma_sync_single;
intel_dma_ops.sync_sg_for_device = machvec_dma_sync_sg;
- intel_dma_ops.dma_supported = iommu_dma_supported;
/*
* The order of these functions is important for
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 749d8f235346..5e0bef3754d1 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3841,9 +3841,7 @@ const struct dma_map_ops intel_dma_ops = {
.map_page = intel_map_page,
.unmap_page = intel_unmap_page,
.mapping_error = intel_mapping_error,
-#ifdef CONFIG_X86
.dma_supported = dma_direct_supported,
-#endif
};
static inline int iommu_domain_cache_init(void)
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH 4/7] x86: remove a stray reference to pci-nommu.c
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` [PATCH 1/7] core, dma-direct: add a flag 32-bit dma limits Christoph Hellwig
2018-05-25 14:35 ` [PATCH 3/7] ia64: remove iommu_dma_supported Christoph Hellwig
@ 2018-05-25 14:35 ` Christoph Hellwig
2018-05-26 19:23 ` Thomas Gleixner
2 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-ia64-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
This is just the minimal workaround. The file file is mostly either stale
and/or duplicative of Documentation/admin-guide/kernel-parameters.txt,
but that is much more work than I'm willing to do right now.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
Documentation/x86/x86_64/boot-options.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
index b297c48389b9..153b3a57fba2 100644
--- a/Documentation/x86/x86_64/boot-options.txt
+++ b/Documentation/x86/x86_64/boot-options.txt
@@ -187,9 +187,9 @@ PCI
IOMMU (input/output memory management unit)
- Currently four x86-64 PCI-DMA mapping implementations exist:
+ Multiple x86-64 PCI-DMA mapping implementations exist, for example:
- 1. <arch/x86_64/kernel/pci-nommu.c>: use no hardware/software IOMMU at all
+ 1. <lib/dma-direct.c>: use no hardware/software IOMMU at all
(e.g. because you have < 3 GB memory).
Kernel boot message: "PCI-DMA: Disabling IOMMU"
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 4/7] x86: remove a stray reference to pci-nommu.c
2018-05-25 14:35 ` [PATCH 4/7] x86: remove a stray reference to pci-nommu.c Christoph Hellwig
@ 2018-05-26 19:23 ` Thomas Gleixner
0 siblings, 0 replies; 21+ messages in thread
From: Thomas Gleixner @ 2018-05-26 19:23 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Ingo Molnar, Tony Luck, Fenghua Yu, Greg Kroah-Hartman, x86,
iommu, linux-kernel, linux-ia64, netdev
On Fri, 25 May 2018, Christoph Hellwig wrote:
Subject should be: Documentation/x86: Remove .....
please
> This is just the minimal workaround. The file file is mostly either stale
file file?
> and/or duplicative of Documentation/admin-guide/kernel-parameters.txt,
> but that is much more work than I'm willing to do right now.
Yeah, this thing is on the todo list ...
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Other than the above nits:
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> Documentation/x86/x86_64/boot-options.txt | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
> index b297c48389b9..153b3a57fba2 100644
> --- a/Documentation/x86/x86_64/boot-options.txt
> +++ b/Documentation/x86/x86_64/boot-options.txt
> @@ -187,9 +187,9 @@ PCI
>
> IOMMU (input/output memory management unit)
>
> - Currently four x86-64 PCI-DMA mapping implementations exist:
> + Multiple x86-64 PCI-DMA mapping implementations exist, for example:
>
> - 1. <arch/x86_64/kernel/pci-nommu.c>: use no hardware/software IOMMU at all
> + 1. <lib/dma-direct.c>: use no hardware/software IOMMU at all
> (e.g. because you have < 3 GB memory).
> Kernel boot message: "PCI-DMA: Disabling IOMMU"
>
> --
> 2.17.0
>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/7] x86: remove the experimental forcesac boot option
2018-05-25 14:35 refactor 32-bit dma limit quirks Christoph Hellwig
2018-05-25 14:35 ` [PATCH 2/7] ia64: remove the dead iommu_sac_force variable Christoph Hellwig
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
@ 2018-05-25 14:35 ` Christoph Hellwig
[not found] ` <20180525143512.1466-6-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` [PATCH 6/7] x86: remove the explicit nodac and allowdac option Christoph Hellwig
2018-05-25 14:35 ` [PATCH 7/7] x86: switch the VIA 32-bit DMA quirk to use the struct device flag Christoph Hellwig
4 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: x86, iommu, linux-kernel, linux-ia64, netdev
Limiting the dma mask to avoid PCI (pre-PCIe) DAC cycles while paying
the huge overhead of an IOMMU is rather pointless, and this seriously
gets in the way of dma mapping work.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
.../admin-guide/kernel-parameters.txt | 1 -
Documentation/x86/x86_64/boot-options.txt | 4 +---
arch/x86/kernel/pci-dma.c | 21 +------------------
drivers/net/ethernet/sfc/efx.c | 5 ++---
drivers/net/ethernet/sfc/falcon/efx.c | 5 ++---
5 files changed, 6 insertions(+), 30 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index f2040d46f095..cc0ac035b8fe 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1705,7 +1705,6 @@
nopanic
merge
nomerge
- forcesac
soft
pt [x86, IA-64]
nobypass [PPC/POWERNV]
diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
index 153b3a57fba2..341588ec4e29 100644
--- a/Documentation/x86/x86_64/boot-options.txt
+++ b/Documentation/x86/x86_64/boot-options.txt
@@ -208,7 +208,7 @@ IOMMU (input/output memory management unit)
Kernel boot message: "PCI-DMA: Using Calgary IOMMU"
iommu=[<size>][,noagp][,off][,force][,noforce][,leak[=<nr_of_leak_pages>]
- [,memaper[=<order>]][,merge][,forcesac][,fullflush][,nomerge]
+ [,memaper[=<order>]][,merge][,fullflush][,nomerge]
[,noaperture][,calgary]
General iommu options:
@@ -235,8 +235,6 @@ IOMMU (input/output memory management unit)
(experimental).
nomerge Don't do scatter-gather (SG) merging.
noaperture Ask the IOMMU not to touch the aperture for AGP.
- forcesac Force single-address cycle (SAC) mode for masks <40bits
- (experimental).
noagp Don't initialize the AGP driver and use full aperture.
allowdac Allow double-address cycle (DAC) mode, i.e. DMA >4GB.
DAC is used with 32-bit PCI to push a 64-bit address in
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 77625b60a510..91dff954b745 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -20,8 +20,6 @@ static int forbid_dac __read_mostly;
const struct dma_map_ops *dma_ops = &dma_direct_ops;
EXPORT_SYMBOL(dma_ops);
-static int iommu_sac_force __read_mostly;
-
#ifdef CONFIG_IOMMU_DEBUG
int panic_on_overflow __read_mostly = 1;
int force_iommu __read_mostly = 1;
@@ -125,7 +123,7 @@ static __init int iommu_setup(char *p)
if (!strncmp(p, "nomerge", 7))
iommu_merge = 0;
if (!strncmp(p, "forcesac", 8))
- iommu_sac_force = 1;
+ pr_warn("forcesac option ignored.\n");
if (!strncmp(p, "allowdac", 8))
forbid_dac = 0;
if (!strncmp(p, "nodac", 5))
@@ -165,23 +163,6 @@ int arch_dma_supported(struct device *dev, u64 mask)
}
#endif
- /* Tell the device to use SAC when IOMMU force is on. This
- allows the driver to use cheaper accesses in some cases.
-
- Problem with this is that if we overflow the IOMMU area and
- return DAC as fallback address the device may not handle it
- correctly.
-
- As a special case some controllers have a 39bit address
- mode that is as efficient as 32bit (aic79xx). Don't force
- SAC for these. Assume all masks <= 40 bits are of this
- type. Normally this doesn't make any difference, but gives
- more gentle handling of IOMMU overflow. */
- if (iommu_sac_force && (mask >= DMA_BIT_MASK(40))) {
- dev_info(dev, "Force SAC with mask %Lx\n", mask);
- return 0;
- }
-
return 1;
}
EXPORT_SYMBOL(arch_dma_supported);
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index a4ebd8715494..661828e8fdcf 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -1289,9 +1289,8 @@ static int efx_init_io(struct efx_nic *efx)
pci_set_master(pci_dev);
- /* Set the PCI DMA mask. Try all possibilities from our
- * genuine mask down to 32 bits, because some architectures
- * (e.g. x86_64 with iommu_sac_force set) will allow 40 bit
+ /* Set the PCI DMA mask. Try all possibilities from our genuine mask
+ * down to 32 bits, because some architectures will allow 40 bit
* masks event though they reject 46 bit masks.
*/
while (dma_mask > 0x7fffffffUL) {
diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c
index 3d6c91e96589..dd5530a4f8c8 100644
--- a/drivers/net/ethernet/sfc/falcon/efx.c
+++ b/drivers/net/ethernet/sfc/falcon/efx.c
@@ -1242,9 +1242,8 @@ static int ef4_init_io(struct ef4_nic *efx)
pci_set_master(pci_dev);
- /* Set the PCI DMA mask. Try all possibilities from our
- * genuine mask down to 32 bits, because some architectures
- * (e.g. x86_64 with iommu_sac_force set) will allow 40 bit
+ /* Set the PCI DMA mask. Try all possibilities from our genuine mask
+ * down to 32 bits, because some architectures will allow 40 bit
* masks event though they reject 46 bit masks.
*/
while (dma_mask > 0x7fffffffUL) {
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH 6/7] x86: remove the explicit nodac and allowdac option
2018-05-25 14:35 refactor 32-bit dma limit quirks Christoph Hellwig
` (2 preceding siblings ...)
2018-05-25 14:35 ` [PATCH 5/7] x86: remove the experimental forcesac boot option Christoph Hellwig
@ 2018-05-25 14:35 ` Christoph Hellwig
[not found] ` <20180525143512.1466-7-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` [PATCH 7/7] x86: switch the VIA 32-bit DMA quirk to use the struct device flag Christoph Hellwig
4 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: x86, iommu, linux-kernel, linux-ia64, netdev
This is something drivers should decide (modulo chipset quirks like
for VIA), which as far as I can tell is how things have been handled
for the last 15 years.
Note that we keep the usedac option for now, as it is used in the wild
to override the too generic VIA quirk.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Documentation/x86/x86_64/boot-options.txt | 5 -----
arch/x86/kernel/pci-dma.c | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
index 341588ec4e29..8d109ef67ab6 100644
--- a/Documentation/x86/x86_64/boot-options.txt
+++ b/Documentation/x86/x86_64/boot-options.txt
@@ -236,11 +236,6 @@ IOMMU (input/output memory management unit)
nomerge Don't do scatter-gather (SG) merging.
noaperture Ask the IOMMU not to touch the aperture for AGP.
noagp Don't initialize the AGP driver and use full aperture.
- allowdac Allow double-address cycle (DAC) mode, i.e. DMA >4GB.
- DAC is used with 32-bit PCI to push a 64-bit address in
- two cycles. When off all DMA over >4GB is forced through
- an IOMMU or software bounce buffering.
- nodac Forbid DAC mode, i.e. DMA >4GB.
panic Always panic when IOMMU overflows.
calgary Use the Calgary IOMMU if it is available
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 91dff954b745..b5cbef974bd1 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -125,9 +125,9 @@ static __init int iommu_setup(char *p)
if (!strncmp(p, "forcesac", 8))
pr_warn("forcesac option ignored.\n");
if (!strncmp(p, "allowdac", 8))
- forbid_dac = 0;
+ pr_warn("allowdac option ignored.\n");
if (!strncmp(p, "nodac", 5))
- forbid_dac = 1;
+ pr_warn("nodac option ignored.\n");
if (!strncmp(p, "usedac", 6)) {
forbid_dac = -1;
return 1;
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH 7/7] x86: switch the VIA 32-bit DMA quirk to use the struct device flag
2018-05-25 14:35 refactor 32-bit dma limit quirks Christoph Hellwig
` (3 preceding siblings ...)
2018-05-25 14:35 ` [PATCH 6/7] x86: remove the explicit nodac and allowdac option Christoph Hellwig
@ 2018-05-25 14:35 ` Christoph Hellwig
[not found] ` <20180525143512.1466-8-hch-jcswGhMUV9g@public.gmane.org>
4 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2018-05-25 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Tony Luck, Fenghua Yu,
Greg Kroah-Hartman
Cc: x86, iommu, linux-kernel, linux-ia64, netdev
Instead of globally disabling > 32bit DMA using the arch_dma_supported
hook walk the PCI bus under the actually affected bridge and mark every
device with the dma_32bit_limit flag. This also gets rid of the
arch_dma_supported hook entirely.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/x86/include/asm/dma-mapping.h | 3 ---
arch/x86/kernel/pci-dma.c | 27 ++++++++++-----------------
include/linux/dma-mapping.h | 11 -----------
3 files changed, 10 insertions(+), 31 deletions(-)
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 89ce4bfd241f..eb4e1352e403 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -30,9 +30,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
return dma_ops;
}
-int arch_dma_supported(struct device *dev, u64 mask);
-#define arch_dma_supported arch_dma_supported
-
bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp);
#define arch_dma_alloc_attrs arch_dma_alloc_attrs
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index b5cbef974bd1..0d6fd0d1c14f 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -15,7 +15,7 @@
#include <asm/x86_init.h>
#include <asm/iommu_table.h>
-static int forbid_dac __read_mostly;
+static bool disable_dac_quirk __read_mostly;
const struct dma_map_ops *dma_ops = &dma_direct_ops;
EXPORT_SYMBOL(dma_ops);
@@ -129,7 +129,7 @@ static __init int iommu_setup(char *p)
if (!strncmp(p, "nodac", 5))
pr_warn("nodac option ignored.\n");
if (!strncmp(p, "usedac", 6)) {
- forbid_dac = -1;
+ disable_dac_quirk = true;
return 1;
}
#ifdef CONFIG_SWIOTLB
@@ -154,19 +154,6 @@ static __init int iommu_setup(char *p)
}
early_param("iommu", iommu_setup);
-int arch_dma_supported(struct device *dev, u64 mask)
-{
-#ifdef CONFIG_PCI
- if (mask > 0xffffffff && forbid_dac > 0) {
- dev_info(dev, "PCI: Disallowing DAC for device\n");
- return 0;
- }
-#endif
-
- return 1;
-}
-EXPORT_SYMBOL(arch_dma_supported);
-
static int __init pci_iommu_init(void)
{
struct iommu_table_entry *p;
@@ -190,11 +177,17 @@ rootfs_initcall(pci_iommu_init);
#ifdef CONFIG_PCI
/* Many VIA bridges seem to corrupt data for DAC. Disable it here */
+static int via_no_dac_cb(struct pci_dev *pdev, void *data)
+{
+ pdev->dev.dma_32bit_limit = true;
+ return 0;
+}
+
static void via_no_dac(struct pci_dev *dev)
{
- if (forbid_dac == 0) {
+ if (!disable_dac_quirk) {
dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n");
- forbid_dac = 1;
+ pci_walk_bus(dev->subordinate, via_no_dac_cb, NULL);
}
}
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index f8ab1c0f589e..0249bce7c5e7 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -572,14 +572,6 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
return 0;
}
-/*
- * This is a hack for the legacy x86 forbid_dac and iommu_sac_force. Please
- * don't use this in new code.
- */
-#ifndef arch_dma_supported
-#define arch_dma_supported(dev, mask) (1)
-#endif
-
static inline void dma_check_mask(struct device *dev, u64 mask)
{
if (sme_active() && (mask < (((u64)sme_get_me_mask() << 1) - 1)))
@@ -592,9 +584,6 @@ static inline int dma_supported(struct device *dev, u64 mask)
if (!ops)
return 0;
- if (!arch_dma_supported(dev, mask))
- return 0;
-
if (!ops->dma_supported)
return 1;
return ops->dma_supported(dev, mask);
--
2.17.0
^ permalink raw reply related [flat|nested] 21+ messages in thread