Re: [PATCH 4/5] iommu/tegra-smmu: Add PCI support

2020-09-26 Thread Dmitry Osipenko
26.09.2020 11:07, Nicolin Chen пишет: ... > +#ifdef CONFIG_PCI > + if (!iommu_present(_bus_type)) { Is this iommu_present() check really needed? > + pci_request_acs(); Shouldn't pci_request_acs() be invoked *after* bus_set_iommu() succeeds? > + err =

Re: [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Dmitry Osipenko
26.09.2020 23:47, Nicolin Chen пишет: ... >>> + for (pd_index = 0; pd_index < SMMU_NUM_PDE; pd_index++) { >>> + struct page *pt; >>> + u32 *addr; >>> + >>> + if (!as->count[pd_index] || !pd[pd_index]) >>> + continue; >>> + >>> +

Re: [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Dmitry Osipenko
27.09.2020 00:24, Dmitry Osipenko пишет: > 26.09.2020 11:07, Nicolin Chen пишет: > ... >> +for (pd_index = 0; pd_index < SMMU_NUM_PDE; pd_index++) { >> +struct page *pt; >> +u32 *addr; >> + >> +if (!as->count[pd_index] || !pd[pd_index]) >> +

Re: [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Dmitry Osipenko
26.09.2020 11:07, Nicolin Chen пишет: ... > + for (pd_index = 0; pd_index < SMMU_NUM_PDE; pd_index++) { > + struct page *pt; > + u32 *addr; > + > + if (!as->count[pd_index] || !pd[pd_index]) > + continue; I guess the idea of this patch

Re: [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Nicolin Chen
Hi Dmitry, Thank you for the review. On Sat, Sep 26, 2020 at 05:48:54PM +0300, Dmitry Osipenko wrote: > 26.09.2020 11:07, Nicolin Chen пишет: > ... > > +static int tegra_smmu_mappings_show(struct seq_file *s, void *data) > > +{ > > + struct tegra_smmu_group_debug *group_debug = s->private; > >

Re: [PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device()

2020-09-26 Thread Nicolin Chen
Hi Dmitry, Thank you for the review and comments! On Sat, Sep 26, 2020 at 05:48:17PM +0300, Dmitry Osipenko wrote: > 26.09.2020 11:07, Nicolin Chen пишет: > ... > > + /* NULL smmu pointer means that SMMU driver is not probed yet */ > > + if (unlikely(!smmu)) > > + return

Re: [PATCH 17/18] dma-iommu: implement ->alloc_noncoherent

2020-09-26 Thread Tomasz Figa
On Sat, Sep 26, 2020 at 4:14 PM Christoph Hellwig wrote: > > On Fri, Sep 25, 2020 at 06:46:22PM +, Tomasz Figa wrote: > > > +static void *iommu_dma_alloc_noncoherent(struct device *dev, size_t size, > > > + dma_addr_t *handle, enum dma_data_direction dir, gfp_t gfp) > > > +{ > > > +

Re: [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Dmitry Osipenko
26.09.2020 11:07, Nicolin Chen пишет: ... > +static int tegra_smmu_mappings_show(struct seq_file *s, void *data) > +{ > + struct tegra_smmu_group_debug *group_debug = s->private; > + const struct tegra_smmu_swgroup *group; > + struct tegra_smmu_as *as; > + struct tegra_smmu *smmu;

Re: [PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device()

2020-09-26 Thread Dmitry Osipenko
26.09.2020 11:07, Nicolin Chen пишет: ... > + /* NULL smmu pointer means that SMMU driver is not probed yet */ > + if (unlikely(!smmu)) > + return ERR_PTR(-EPROBE_DEFER); Hello, Nicolin! Please don't pollute code with likely/unlikely. This is not a performance-critical code.

Re: [PATCH 17/18] dma-iommu: implement ->alloc_noncoherent

2020-09-26 Thread Christoph Hellwig
On Fri, Sep 25, 2020 at 06:46:22PM +, Tomasz Figa wrote: > > +static void *iommu_dma_alloc_noncoherent(struct device *dev, size_t size, > > + dma_addr_t *handle, enum dma_data_direction dir, gfp_t gfp) > > +{ > > + if (!gfpflags_allow_blocking(gfp)) { > > + struct page

Re: [patch V2 34/46] PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable

2020-09-26 Thread Vasily Gorbik
On Fri, Sep 25, 2020 at 09:54:52AM -0400, Qian Cai wrote: > On Wed, 2020-08-26 at 13:17 +0200, Thomas Gleixner wrote: > > From: Thomas Gleixner > > > > The arch_.*_msi_irq[s] fallbacks are compiled in whether an architecture > > requires them or not. Architectures which are fully utilizing

[PATCH 1/1] iommu/amd: Fix the overwritten field in IVMD header

2020-09-26 Thread Adrian Huang
From: Adrian Huang Commit 387caf0b759a ("iommu/amd: Treat per-device exclusion ranges as r/w unity-mapped regions") accidentally overwrites the 'flags' field in IVMD (struct ivmd_header) when the I/O virtualization memory definition is associated with the exclusion range entry. This leads to the

[PATCH 2/5] iommu/tegra-smmu: Expend mutex protection range

2020-09-26 Thread Nicolin Chen
This is used to protect potential race condition at use_count. since probes of client drivers, calling attach_dev(), may run concurrently. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 34 +- 1 file changed, 21 insertions(+), 13 deletions(-) diff

[PATCH 0/5] iommu/tegra-smmu: Adding PCI support and mappings debugfs node

2020-09-26 Thread Nicolin Chen
This series of patches are some followup patches for tegra-smmu. There are four parts: 1, PATCH-1 is a clean-up patch for the recently applied SWGROUP change. 2, PATCH-2 fixes a potential race condition 3, PATCH-3/4 adds PCI device support 4, PATCH-5 adds a debugfs node for phys<=>iova mappings

[PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs

2020-09-26 Thread Nicolin Chen
This patch dumps all active mapping entries from pagetable to a debugfs directory named "mappings". Ataching an example: SWGROUP: hc ASID: 0 reg: 0x250 PTB_ASID: 0xe00bb880 as->pd_dma: 0xbb88 { [1023] 0xf00bb882 (1) { PDE ATTR PHYS IOVA

[PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device()

2020-09-26 Thread Nicolin Chen
The tegra_smmu_probe_device() function searches in DT for the iommu phandler to get "smmu" pointer. This works for most of SMMU clients that exist in the DTB. But a PCI device will not be added to iommu, since it doesn't have a DT node. Fortunately, for a client with a DT node,

[PATCH 1/5] iommu/tegra-smmu: Unwrap tegra_smmu_group_get

2020-09-26 Thread Nicolin Chen
The tegra_smmu_group_get was added to group devices in different SWGROUPs and it'd return a NULL group pointer upon a mismatch at tegra_smmu_find_group(), so for most of clients/devices, it very likely would mismatch and need a fallback generic_device_group(). But now tegra_smmu_group_get handles

[PATCH 4/5] iommu/tegra-smmu: Add PCI support

2020-09-26 Thread Nicolin Chen
This patch simply adds support for PCI devices. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 97a7185b4578..9dbc5d7183cc 100644 ---