Re: [PATCH v10 2/5] iommu/arm-smmu: ioremap smmu mmio region before implementation init

2020-07-08 Thread Nicolin Chen
On Tue, Jul 07, 2020 at 10:00:14PM -0700, Krishna Reddy wrote: > ioremap smmu mmio region before calling into implementation init. > This is necessary to allow mapped address available during vendor > specific implementation init. > > Signed-off-by: Krishna Reddy Reviewed-b

Re: [PATCH] dma-contiguous: cleanup dma_alloc_contiguous

2020-07-22 Thread Nicolin Chen
On Wed, Jul 22, 2020 at 04:43:07PM +0200, Christoph Hellwig wrote: > Split out a cma_alloc_aligned helper to deal with the "interesting" > calling conventions for cma_alloc, which then allows to the main > function to be written straight forward. This also takes advantage > of the fact that NULL d

Re: [PATCH v2] dma-contiguous: cleanup dma_alloc_contiguous

2020-07-23 Thread Nicolin Chen
don't feel that it hurts to check the dev pointer as we do now, but if you are confident with this version: Reviewed-by: Nicolin Chen Thanks ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v3] dma-mapping: set default segment_boundary_mask to ULONG_MAX

2020-08-14 Thread Nicolin Chen
ly limits those devices capable of 32+ bits addressing. So this patch sets default segment_boundary_mask to ULONG_MAX. Signed-off-by: Nicolin Chen --- Changelog: v2->v3 * Resent -- no change v2 was sent 4 months ago https://lkml.org/lkml/2020/4/6/881 but it has not got replied yet

[PATCH 3/3] iommu/tegra-smmu: Allow to group clients in same swgroup

2020-09-11 Thread Nicolin Chen
be also added to the same IOMMU group so as to share an asid. Otherwise, the asid register may get overwritten every time a new device is attached. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers

[PATCH 2/3] iommu/tegra-smmu: Fix iova->phys translation

2020-09-11 Thread Nicolin Chen
IOVA might not be always 4KB aligned. So tegra_smmu_iova_to_phys function needs to add on the lower 12-bit offset from input iova. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers

[PATCH 0/3] iommu/tegra-smmu: Some small fixes

2020-09-11 Thread Nicolin Chen
These are a series of small fixes for tegra-smmu driver. They might not be critial bugs as current mainline does not enable a lot of clients, but be nicer to have since we are going to enable the DMA domain for other clients in the near future. Nicolin Chen (3): iommu/tegra-smmu: Do not use

Re: [PATCH RESEND v2 4/5] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2021-02-04 Thread Nicolin Chen
Hi Guillaume, On Thu, Feb 04, 2021 at 11:10:15AM +, Guillaume Tucker wrote: > Hi Nicolin, > > A regression was detected by kernelci.org in IGT's drm_read tests > on mainline, it was first seen on 17th December 2020. You can > find some details here: > > https://kernelci.org/test/case/id/6

Re: [PATCH RESEND v2 4/5] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2021-02-05 Thread Nicolin Chen
Hi Guillaume, On Thu, Feb 04, 2021 at 09:24:23PM -0800, Nicolin Chen wrote: > > Please let us know if you need any help debugging this issue or > > to try a fix on this platform. > > Yes, I don't have any Tegra124 platform to run. It'd be very nice > if you can

Re: [PATCH RESEND v2 4/5] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2021-02-10 Thread Nicolin Chen
illa kernel + debug patch 2. Vanilla kernel + Reverted + debug patch Thank you Nicolin >From dce84731e12900b0e98dffc0ff981638a0bb3405 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Fri, 5 Feb 2021 01:41:07 -0800 Subject: [PATCH] iommu: debug tegra-smmu v2 Signed-off-by: Nicolin Chen --- ar

Re: [PATCH RESEND v2 4/5] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2021-02-18 Thread Nicolin Chen
to revert my previous change, not necessarily being a complete revert though. I attached my partial reverting change in this email. Would it be possible for you to run one more test for me to confirm it? It'd keep the tests passing while eliminating all error prints above. If the fix works, I'l

[PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-02-18 Thread Nicolin Chen
ication] Fixes: 25938c73cd79 ("iommu/tegra-smmu: Rework tegra_smmu_probe_device()") Reported-by: Guillaume Tucker Signed-off-by: Nicolin Chen --- Guillaume, would you please give a "Tested-by" to this change? Thanks! drivers/iommu/tegra-smmu.c | 72 +

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-02-22 Thread Nicolin Chen
Hi Dmitry, On Sat, Feb 20, 2021 at 08:16:22AM +0300, Dmitry Osipenko wrote: > 19.02.2021 01:07, Nicolin Chen пишет: > > Commit 25938c73cd79 ("iommu/tegra-smmu: Rework tegra_smmu_probe_device()") > > removed certain hack in the tegra_smmu_probe() by relying on IOMMU core t

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-02-24 Thread Nicolin Chen
On Tue, Feb 23, 2021 at 08:10:41AM +0300, Dmitry Osipenko wrote: > 23.02.2021 05:13, Nicolin Chen пишет: > > Hi Dmitry, > > > > On Sat, Feb 20, 2021 at 08:16:22AM +0300, Dmitry Osipenko wrote: > >> 19.02.2021 01:07, Nicolin Chen пишет: > >>> Comm

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-03-03 Thread Nicolin Chen
On Sat, Feb 27, 2021 at 12:59:17PM +0300, Dmitry Osipenko wrote: > 25.02.2021 09:27, Nicolin Chen пишет: > ... > >> The partially revert should be okay, but it's not clear to me what makes > >> difference for T124 since I don't see that problem on T30, which also

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

2021-03-09 Thread Nicolin Chen
IOVASIZEATTR #1023 - #1023 0x122e5e0000xf000 0x1000 0x5 } } Total PDE count: 1 Total PTE count: 1 Signed-off-by: Nicolin Chen --- Changelog v2: * Expanded mutex range to the entire function * Added as->lock to protect paget

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

2021-03-10 Thread Nicolin Chen
On Wed, Mar 10, 2021 at 11:38:47PM +0300, Dmitry Osipenko wrote: > 10.03.2021 06:36, Nicolin Chen пишет: > > This patch dumps all active mapping entries from pagetable > > to a debugfs directory named "mappings". > > > > Ataching an example: > >

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-03-10 Thread Nicolin Chen
On Wed, Mar 10, 2021 at 11:22:57PM +0300, Dmitry Osipenko wrote: > 10.03.2021 22:13, Dmitry Osipenko пишет: > > I found that this patch introduced a serious regression on Tegra30 using > > today's linux-next. Tegra30 has two 3d h/w blocks connected in SLI and > > only one of the blocks is now attac

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-03-11 Thread Nicolin Chen
On Thu, Mar 11, 2021 at 03:06:25PM +0300, Dmitry Osipenko wrote: > 11.03.2021 01:17, Nicolin Chen пишет: > > On Wed, Mar 10, 2021 at 11:22:57PM +0300, Dmitry Osipenko wrote: > >> 10.03.2021 22:13, Dmitry Osipenko пишет: > >>> I found that this patch introduced a serio

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

2021-03-11 Thread Nicolin Chen
On Thu, Mar 11, 2021 at 05:04:06PM +0300, Dmitry Osipenko wrote: > 10.03.2021 06:36, 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 v1] iommu/tegra-smmu: Make tegra_smmu_probe_device() to handle all IOMMU phandles

2021-03-13 Thread Nicolin Chen
ra30 and now GPU > works properly once again. > > Fixes: 765a9d1d02b2 ("iommu/tegra-smmu: Fix mc errors on tegra124-nyan") > Signed-off-by: Dmitry Osipenko Tested-by: Nicolin Chen ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

2021-03-14 Thread Nicolin Chen
| ATTR | PHYS | IOVA | SIZE [#1023, #1023] | 0x5 | 0x000111a8d000 | 0xf000 | 0x1000 } } Total PDE count: 1 Total PTE count: 1 Signed-off-by: Nicolin Chen --- Changelog v3: * Fixed PHYS and IOVA print formats * Changed variables to unsi

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

2021-03-14 Thread Nicolin Chen
On Sun, Mar 14, 2021 at 06:08:00PM +0300, Dmitry Osipenko wrote: > 14.03.2021 11:06, Nicolin Chen пишет: > > + for (pd_index = 0; pd_index < SMMU_NUM_PDE; pd_index++) { > > + struct page *pt_page; > > + u32 *addr; > > + int i; > &g

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

2021-03-14 Thread Nicolin Chen
| ATTR | PHYS | IOVA | SIZE [#1023, #1023] | 0x5 | 0x000111a8d000 | 0xf000 | 0x1000 } } Total PDE count: 1 Total PTE count: 1 Signed-off-by: Nicolin Chen --- Changelog v4: * Changed %d to %u for unsigned variables * Fixed print fo

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

2021-03-15 Thread Nicolin Chen
On Mon, Mar 15, 2021 at 09:53:09PM +0300, Dmitry Osipenko wrote: > 15.03.2021 06:35, Nicolin Chen пишет: > > This patch dumps all active mapping entries from pagetable > > to a debugfs directory named "mappings". > > > > Ataching an example: > > At

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

2021-03-15 Thread Nicolin Chen
| ATTR | PHYS | IOVA | SIZE [#1023, #1023] | 0x5 | 0x000111a8d000 | 0xf000 | 0x1000 } } Total PDE count: 1 Total PTE count: 1 Tested-by: Dmitry Osipenko Reviewed-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v5: * Fi

Re: [PATCH v1 2/2] iommu/tegra-smmu: Revert workaround that was needed for Nyan Big Chromebook

2021-04-01 Thread Nicolin Chen
On Mon, Mar 29, 2021 at 02:32:56AM +0300, Dmitry Osipenko wrote: > The previous commit fixes problem where display client was attaching too > early to IOMMU during kernel boot in a multi-platform kernel configuration > which enables CONFIG_ARM_DMA_USE_IOMMU=y. The workaround that helped to > defer

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

2021-04-01 Thread Nicolin Chen
On Tue, Mar 16, 2021 at 12:16:43PM +0100, Thierry Reding wrote: > > +struct tegra_smmu_group_debug { > > + const struct tegra_smmu_swgroup *group; > > + void *priv; > > This always stores the address space, so why not make this: > > struct tegra_smmu_as *as; > > ? While at it, perhaps

Re: [PATCH v1 1/2] iommu/tegra-smmu: Defer attachment of display clients

2021-04-08 Thread Nicolin Chen
ich works good enough in practice because by that time h/w is already > stopped. > > Signed-off-by: Dmitry Osipenko For both patches: Acked-by: Nicolin Chen Tested-by: Nicolin Chen The WAR looks good to me. Perhaps Thierry would give some input. Another topic: I think this may help wo

[PATCH v6 0/6] iommu/tegra-smmu: Add pagetable mappings to debugfs

2021-09-13 Thread Nicolin Chen
ped as->count check * Added WARN_ON when as->count mismatches pd[pd_index] v1: https://lkml.org/lkml/2020/9/26/70 Nicolin Chen (6): iommu/tegra-smmu: Rename struct iommu_group *group to *grp iommu/tegra-smmu: Rename struct tegra_smmu_group_soc *soc to *group_soc iommu/tegra-smmu:

[PATCH v6 2/6] iommu/tegra-smmu: Rename struct tegra_smmu_group_soc *soc to *group_soc

2021-09-13 Thread Nicolin Chen
There are both tegra_smmu_soc and tegra_smmu_group_soc using "soc" for their pointer instances. This patch renames the one of struct tegra_smmu_group_soc from "soc" to "group_soc" to distinguish it. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c

[PATCH v6 3/6] iommu/tegra-smmu: Rename struct tegra_smmu_swgroup *group to *swgrp

2021-09-13 Thread Nicolin Chen
nd" function. Note that we already have "swgroup" being used for an unsigned int type variable that is inside struct tegra_smmu_swgroup, so it's not able to use "swgroup" but only something like "swgrp". Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-sm

[PATCH v6 1/6] iommu/tegra-smmu: Rename struct iommu_group *group to *grp

2021-09-13 Thread Nicolin Chen
t;grp" as a cleanup. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 0a281833f611..6ebae635d3aa 100644 --- a/drivers/iommu/tegra-smmu.c +

[PATCH v6 5/6] iommu/tegra-smmu: Attach as pointer to tegra_smmu_group

2021-09-13 Thread Nicolin Chen
tions together. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 94 +++--- 1 file changed, 78 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 8fd4985ac91e..68c34a4a0ecc 100644 --- a/drivers/iommu/

[PATCH v6 4/6] iommu/tegra-smmu: Use swgrp pointer instead of swgroup id

2021-09-13 Thread Nicolin Chen
This patch changes in struct tegra_smmu_group to use swgrp pointer instead of swgroup, as a preparational change for the "mappings" debugfs feature. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) di

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

2021-09-13 Thread Nicolin Chen
| ATTR | PHYS | IOVA | SIZE [#1022, #1023] | 0x5 | 0x00010bbf1000 | 0xe000 | 0x2000 } } Total PDE count: 1 Total PTE count: 2 Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 145 ++

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

2021-09-14 Thread Nicolin Chen
On Tue, Sep 14, 2021 at 04:29:15PM +0300, Dmitry Osipenko wrote: > 14.09.2021 04:38, Nicolin Chen пишет: > > +static unsigned long pd_pt_index_iova(unsigned int pd_index, unsigned int > > pt_index) > > +{ > > + return ((dma_addr_t)pd_index & (SMMU_

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

2021-09-14 Thread Nicolin Chen
On Tue, Sep 14, 2021 at 10:20:30PM +0300, Dmitry Osipenko wrote: > 14.09.2021 21:49, Nicolin Chen пишет: > > On Tue, Sep 14, 2021 at 04:29:15PM +0300, Dmitry Osipenko wrote: > >> 14.09.2021 04:38, Nicolin Chen пишет: > >>> +static unsigned long pd_pt_index_iova(u

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

2021-09-15 Thread Nicolin Chen
On Wed, Sep 15, 2021 at 03:09:48PM +0300, Dmitry Osipenko wrote: > 15.09.2021 07:38, Nicolin Chen пишет: > > On Tue, Sep 14, 2021 at 10:20:30PM +0300, Dmitry Osipenko wrote: > >> 14.09.2021 21:49, Nicolin Chen пишет: > >>> On Tue, Sep 14, 2021 at 04:29:15P

[PATCH 1/3] iommu/tegra-smmu: Do not use PAGE_SHIFT and PAGE_MASK

2020-09-11 Thread Nicolin Chen
references with the macros defined with SMMU_PTE_SHIFT. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 046add7acb61..789d21c01b77 100644 --- a

[PATCH] iommu/tegra-smmu: Fix tlb_mask

2020-09-15 Thread Nicolin Chen
The "num_tlb_lines" might not be a power-of-2 value, being 48 on Tegra210 for example. So the current way of calculating tlb_mask using the num_tlb_lines is not correct: tlb_mask=0x5f in case of num_tlb_lines=48, which will trim a setting of 0x30 (48) to 0x10. Signed-off-by: Ni

[RESEND][PATCH 1/2] iommu/tegra-smmu: Fix tlb_mask

2020-09-17 Thread Nicolin Chen
The "num_tlb_lines" might not be a power-of-2 value, being 48 on Tegra210 for example. So the current way of calculating tlb_mask using the num_tlb_lines is not correct: tlb_mask=0x5f in case of num_tlb_lines=48, which will trim a setting of 0x30 (48) to 0x10. Signed-off-by: Nicolin C

[RESEND][PATCH 0/2] iommu/tegra-smmu: Fix TLB line for Tegra210

2020-09-17 Thread Nicolin Chen
These two patches fix ACTIVE_TLB_LINES field setting in tegra-smmu driver for Tegra210 platforms. This resend in series groups two previous seperate changes that're corelated, being pointed out by Thierry. Also adding his Acked-by. Nicolin Chen (2): iommu/tegra-smmu: Fix tlb_mask m

[RESEND][PATCH 2/2] memory: tegra: Correct num_tlb_lines for tegra210

2020-09-17 Thread Nicolin Chen
According to Tegra210 TRM, the default value of TLB_ACTIVE_LINES field of register MC_SMMU_TLB_CONFIG_0 is 0x30. So num_tlb_lines should be 48 (0x30) rather than 32 (0x20). Signed-off-by: Nicolin Chen Acked-by: Thierry Reding --- drivers/memory/tegra/tegra210.c | 2 +- 1 file changed, 1

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

2020-09-26 Thread Nicolin Chen
IOVA #1023 0x50x159f5d0000xf000 } } Total PDE count: 1 Total PTE count: 1 Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 130 +++-- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/t

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

2020-09-26 Thread Nicolin Chen
llows us to get the mc->smmu pointer via dev_get_drvdata() by calling driver_find_device_by_fwnode(). So this patch uses iommu_fwspec in .probe_device() and related code for a client that does not exist in the DTB, especially a PCI one. Signed-off-by: Nicolin Chen --- drivers/iommu

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

2020-09-26 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra

[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 --- a

[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
ppings Each of the four parts is sort of functional independent, so we may apply them separately or incrementally depending on the reviews. Nicolin Chen (5): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expend mutex protection range iommu/tegra-smmu: Use iommu_fwspec in .

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)) > > +

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 *

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

2020-09-28 Thread Nicolin Chen
Hi Thierry, Thanks for the review. On Mon, Sep 28, 2020 at 09:13:56AM +0200, Thierry Reding wrote: > > -static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu, > > - unsigned int swgroup) > > +static struct iommu_group *tegra_smmu_device_

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

2020-09-28 Thread Nicolin Chen
On Mon, Sep 28, 2020 at 09:52:12AM +0200, Thierry Reding wrote: > On Sat, Sep 26, 2020 at 01:07:17AM -0700, Nicolin Chen wrote: > > @@ -13,6 +13,7 @@ > > #include > > #include > > #include > > +#include > > Why is this needed? I don't see any

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

2020-09-28 Thread Nicolin Chen
On Sun, Sep 27, 2020 at 01:18:15AM +0300, Dmitry Osipenko wrote: > 26.09.2020 11:07, Nicolin Chen пишет: > ... > > +#ifdef CONFIG_PCI > > + if (!iommu_present(&pci_bus_type)) { > > Is this iommu_present() check really needed? > > > + pci_request_

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

2020-09-28 Thread Nicolin Chen
On Mon, Sep 28, 2020 at 09:55:45AM +0200, Thierry Reding wrote: > On Sat, Sep 26, 2020 at 01:07:18AM -0700, Nicolin Chen wrote: > > +#ifdef CONFIG_PCI > > + if (!iommu_present(&pci_bus_type)) { > > + pci_request_acs(); > > + err = bus_set_iommu

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

2020-09-28 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Changed type of swgroup to "unsigned int", following Thierry's commnets. drivers/iommu/tegra-smmu.c | 19 --

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

2020-09-28 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 --- Changelog v1->v2: * N/A drivers/iommu/tegra-smmu.c | 34 +- 1 file changed, 21 inserti

[PATCH v2 0/2] iommu/tegra-smmu: Two followup changes

2020-09-28 Thread Nicolin Chen
ize. Nicolin Chen (2): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expend mutex protection range drivers/iommu/tegra-smmu.c | 53 ++ 1 file changed, 25 insertions(+), 28 deletions(-) -- 2.1

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

2020-09-28 Thread Nicolin Chen
On Tue, Sep 29, 2020 at 03:17:58AM +0300, Dmitry Osipenko wrote: > ... > > static bool tegra_smmu_capable(enum iommu_cap cap) > > @@ -420,17 +413,21 @@ static int tegra_smmu_as_prepare(struct tegra_smmu > > *smmu, > > struct tegra_smmu_as *as) > > { > > u32 value

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

2020-09-28 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 --- Changelog v2->v3: * Renamed label "err_unlock" to "unlock" v1->v2: * N/A drive

[PATCH v3 0/2] iommu/tegra-smmu: Two followup changes

2020-09-28 Thread Nicolin Chen
pplied first, since the other three changes need some extra time to finalize. Nicolin Chen (2): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expend mutex protection range drivers/iommu/tegra-smmu.c | 53 ++ 1 file changed, 25 i

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

2020-09-28 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * N/A v1->v2: * Changed type of swgroup to "unsigned int", following Thierry's commnets. drivers/iommu/tegra-smmu.c | 19

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

2020-09-28 Thread Nicolin Chen
On Tue, Sep 29, 2020 at 07:06:37AM +0300, Dmitry Osipenko wrote: > ... > >> As I mentioned in another reply, I think tegra_smmu_find() should be all > >> you need in this case. > > > > This function is used by .probe_device() where its dev pointer is > > an SMMU client. IIUC, tegra_smmu_find() nee

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

2020-09-28 Thread Nicolin Chen
On Tue, Sep 29, 2020 at 07:03:36AM +0100, Christoph Hellwig wrote: > On Mon, Sep 28, 2020 at 09:52:47PM -0700, Nicolin Chen wrote: > > This is used to protect potential race condition at use_count. > > since probes of client drivers, calling attach_dev(), may run > > concurr

[PATCH v4 0/2] iommu/tegra-smmu: Two followup changes

2020-09-28 Thread Nicolin Chen
arated first two changs of V1 so they may get applied first, since the other three changes need some extra time to finalize. Nicolin Chen (2): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expand mutex protection range drivers/iommu/tegra-smmu.c | 53 +

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

2020-09-28 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Signed-off-by: Nicolin Chen --- Changelog v2->v4: * N/A v1->v2: * Changed type of swgroup to "unsigned int", following Thierry's commnets. drivers/iommu/tegra-smmu.c | 19

[PATCH v4 2/2] iommu/tegra-smmu: Expand mutex protection range

2020-09-28 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 --- Changelog v3->v4: * Fixed typo "Expend" => "Expand" v2->v3: * Renamed label "err_

[PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-29 Thread Nicolin Chen
This patch simply adds support for PCI devices. Also reverses bus_set_iommu in tegra_smmu_remove(). Signed-off-by: Nicolin Chen --- Changelog v1->v2 * Added error-out labels in tegra_smmu_probe() * Dropped pci_request_acs() since IOMMU core would call it. drivers/iommu/tegra-smmu.c |

[PATCH v2 1/3] memory: tegra: Add helper function tegra_get_memory_controller

2020-09-29 Thread Nicolin Chen
This can be used by both tegra-smmu and tegra20-devfreq drivers. Suggested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v1->v2 * N/A drivers/memory/tegra/mc.c | 23 +++ include/soc/tegra/mc.h| 1 + 2 files changed, 24 insertions(+) diff --gi

[PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
emoving DT polling code, tegra_smmu_find/tegra_smmu_configure() 3) Calling tegra_get_memory_controller() in .probe_device() instead 4) Also dropping the hack in .probe() that's no longer needed. Signed-off-by: Nicolin Chen --- Changelog v1->v2 * Replaced in .probe_device() tegra_smmu

[PATCH v2 0/3] iommu/tegra-smmu: Add PCI support

2020-09-29 Thread Nicolin Chen
ain code Prvious versions v1: https://lkml.org/lkml/2020/9/26/66 Nicolin Chen (3): memory: tegra: Add helper function tegra_get_memory_controller iommu/tegra-smmu: Rework .probe_device and .attach_dev iommu/tegra-smmu: Add PCI support drivers/iommu/tegra-smmu

Re: [PATCH v4 2/2] iommu/tegra-smmu: Expand mutex protection range

2020-09-29 Thread Nicolin Chen
On Tue, Sep 29, 2020 at 08:42:52PM +0300, Dmitry Osipenko wrote: > 29.09.2020 09:13, Nicolin Chen пишет: > > This is used to protect potential race condition at use_count. > > since probes of client drivers, calling attach_dev(), may run > > concurrently. > > >

Re: [PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:10:00AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > ... > > +#ifdef CONFIG_PCI > > + if (!iommu_present(&pci_bus_type)) { > > Could you please explain why this check is needed? That's referencing what&#

Re: [PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-29 Thread Nicolin Chen
Hi Dmitry, On Wed, Sep 30, 2020 at 08:10:07AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > - group->group = iommu_group_alloc(); > > + group->group = pci ? pci_device_group(dev) : iommu_group_alloc(); > > This will be nicer to write

Re: [PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:10:35AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > void tegra_smmu_remove(struct tegra_smmu *smmu) > > { > > + bus_set_iommu(&platform_bus_type, NULL); > > Why only platform_bus? Is this really needed a

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:24:02AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > + /* > > +* IOMMU core allows -ENODEV return to carry on. So bypass any call > > +* from bus_set_iommu() during tegra_smmu_probe(), as a device will > &g

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:39:54AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > static int tegra_smmu_attach_dev(struct iommu_domain *domain, > > struct device *dev) > > { > > + struct iommu_fwspec *fwspec

Re: [PATCH v2 1/3] memory: tegra: Add helper function tegra_get_memory_controller

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:12:10AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > ... > > int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long > > rate); > > unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *m

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > + /* An invalid mc pointer means mc and smmu drivers are not ready */ > > + if (IS_ERR_OR_NULL(mc)) > > tegra_get_memory_controller() doesn't return NULL. We

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:20:50AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:10, Dmitry Osipenko пишет: > > 30.09.2020 03:30, Nicolin Chen пишет: > >> static void tegra_smmu_release_device(struct device *dev) > > > > The tegra_get_memory_controller() uses o

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 09:10:38AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:49, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> + /* An invalid mc pointer means mc

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:59:45AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:41, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:39:54AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> static int tegra_smmu_attach_d

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:20:50AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:10, Dmitry Osipenko пишет: > > 30.09.2020 03:30, Nicolin Chen пишет: > >> static void tegra_smmu_release_device(struct device *dev) > > > > The tegra_get_memory_controller() uses o

Re: [PATCH v2 1/3] memory: tegra: Add helper function tegra_get_memory_controller

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 09:32:20AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:44, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:12:10AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >> ... > >>> int tegra_mc_write

Re: [PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 09:01:09AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:34, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:10:35AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> void tegra_smmu_

Re: [PATCH v2 3/3] iommu/tegra-smmu: Add PCI support

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:58:50AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:29, Nicolin Chen пишет: > > Hi Dmitry, > > > > On Wed, Sep 30, 2020 at 08:10:07AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> - group-&

Re: [PATCH v2 1/3] memory: tegra: Add helper function tegra_get_memory_controller

2020-09-30 Thread Nicolin Chen
Hi Krzysztof, On Wed, Sep 30, 2020 at 09:21:39AM +0200, Krzysztof Kozlowski wrote: > On Wed, 30 Sep 2020 at 02:35, Nicolin Chen wrote: > > > > This can be used by both tegra-smmu and tegra20-devfreq drivers. > > > > Suggested-by: Dmitry Osipenko >

[PATCH v3 3/3] iommu/tegra-smmu: Add PCI support

2020-09-30 Thread Nicolin Chen
This patch simply adds support for PCI devices. Signed-off-by: Nicolin Chen --- Changelog v2->v3 * Replaced ternary conditional operator with if-else in .device_group() * Dropped change in tegra_smmu_remove() v1->v2 * Added error-out labels in tegra_smmu_probe() * Dropped pci_reque

[PATCH v3 0/3] iommu/tegra-smmu: Add PCI support

2020-09-30 Thread Nicolin Chen
Updated changes by following Dmitry's comments v1->v2 * Added PATCH-1 suggested by Dmitry * Reworked PATCH-2 to unify certain code Dmitry Osipenko (1): memory: tegra: Add devm_tegra_get_memory_controller() Nicolin Chen (2): iommu/tegra-smmu: Rework .probe_device and .attach_dev

[PATCH v3 1/3] memory: tegra: Add devm_tegra_get_memory_controller()

2020-09-30 Thread Nicolin Chen
From: Dmitry Osipenko Multiple Tegra drivers need to retrieve Memory Controller and hence there is quite some duplication of the retrieval code among the drivers. Let's add a new common helper for the retrieval of the MC. Signed-off-by: Dmitry Osipenko Signed-off-by: Nicolin

[PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
ng DT polling code, tegra_smmu_find/tegra_smmu_configure() 3) Calling devm_tegra_get_memory_controller() in .probe_device() 4) Also dropping the hack in .probe() that's no longer needed. Signed-off-by: Nicolin Chen --- Changelog v2->v3 * Used devm_tegra_get_memory_controller() to

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 11:21:14AM +0200, Krzysztof Kozlowski wrote: > On Wed, 30 Sep 2020 at 10:48, Nicolin Chen wrote: > > > > Previously the driver relies on bus_set_iommu() in .probe() to call > > in .probe_device() function so each client can poll iommus property &g

Re: [PATCH v3 1/3] memory: tegra: Add devm_tegra_get_memory_controller()

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 11:07:32AM +0200, Krzysztof Kozlowski wrote: > "On Wed, 30 Sep 2020 at 10:48, Nicolin Chen wrote: > > > > From: Dmitry Osipenko > > > > Multiple Tegra drivers need to retrieve Memory Controller and hence there > > is quite some dupli

Re: [PATCH v3 3/3] iommu/tegra-smmu: Add PCI support

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 05:53:20PM +0300, Dmitry Osipenko wrote: > ... > > +#ifdef CONFIG_PCI > > + if (!iommu_present(&pci_bus_type)) { > > > In the previous reply you said that you're borrowing this check from the > arm-smmu driver, but arm-smmu also has a similar check for > platform_bus_typ

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 05:31:31PM +0200, Thierry Reding wrote: > On Wed, Sep 30, 2020 at 01:42:57AM -0700, Nicolin Chen wrote: > > Previously the driver relies on bus_set_iommu() in .probe() to call > > in .probe_device() function so each client can poll iommus property > >

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 06:09:43PM +0300, Dmitry Osipenko wrote: > ... > > static int tegra_smmu_attach_dev(struct iommu_domain *domain, > > struct device *dev) > > { > > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > > struct tegra_smmu *smmu = de

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 12:24:25AM +0300, Dmitry Osipenko wrote: > ... > >> It looks to me like the only reason why you need this new global API is > >> because PCI devices may not have a device tree node with a phandle to > >> the IOMMU. However, SMMU support for PCI will only be enabled if the >

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 12:56:46AM +0300, Dmitry Osipenko wrote: > 01.10.2020 00:32, Nicolin Chen пишет: > > On Thu, Oct 01, 2020 at 12:24:25AM +0300, Dmitry Osipenko wrote: > >> ... > >>>> It looks to me like the only reason why you need this new global API is &

Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-30 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 05:06:19AM +0300, Dmitry Osipenko wrote: > 01.10.2020 04:26, Nicolin Chen пишет: > > On Thu, Oct 01, 2020 at 12:56:46AM +0300, Dmitry Osipenko wrote: > >> 01.10.2020 00:32, Nicolin Chen пишет: > >>> On Thu, Oct 01, 2020 at 12:24:25A

<    1   2   3   4   >