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

2020-10-01 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 11:51:52AM +0200, Thierry Reding 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 fo

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

2020-10-01 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 12:23:16PM +0200, Thierry Reding 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 sup

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

2020-10-01 Thread Nicolin Chen
On Thu, Oct 01, 2020 at 11:33:38PM +0300, Dmitry Osipenko wrote: > >>> If we can't come to an agreement on globalizing mc pointer, would > >>> it be possible to pass tegra_mc_driver through tegra_smmu_probe() > >>> so we can continue to use driver_find_device_by_fwnode() as v1? > >>> > >>> v1: http

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

2020-10-01 Thread Nicolin Chen
ngs via reserved-memory regions). If so, I > think it should be safe to remove this. I am attaching a patch that works with both IOMMU_DOMAIN_UNMANAGED and IOMMU_DOMAIN_DMA. Would it be possible for you to give a test? The implementation of getting mc->smmu is using a parent_driver as I was aski

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

2020-10-01 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 04:55:34AM +0300, Dmitry Osipenko wrote: > 02.10.2020 04:07, Nicolin Chen пишет: > > On Thu, Oct 01, 2020 at 11:33:38PM +0300, Dmitry Osipenko wrote: > >>>>> If we can't come to an agreement on globalizing mc pointer, would > >>&

[PATCH v4 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-01 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Seperated the change, as a cleanup, from the rework patch v1->v3: * N/A drivers/iommu/tegra-smmu.c | 50 +++--

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

2020-10-01 Thread Nicolin Chen
Added PATCH-1 suggested by Dmitry * Reworked PATCH-2 to unify certain code Nicolin Chen (3): iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev iommu/tegra-smmu: Rework tegra_smmu_probe_device() iommu/tegra-smmu: Add PCI support drivers/iommu/tegr

[PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-01 Thread Nicolin Chen
in tegra_smmu_probe_device() during stage of tegra_smmu_probe/tegra_mc_probe(). 2) Moving dev_iommu_priv_set() to of_xlate() so we can get smmu pointer in tegra_smmu_probe_device() to replace DTB polling. 3) Removing tegra_smmu_configure() accordingly since iommu core takes care of

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

2020-10-01 Thread Nicolin Chen
This patch simply adds support for PCI devices. Signed-off-by: Nicolin Chen --- Changelog v3->v4 * Dropped !iommu_present() check * Added CONFIG_PCI check in the exit path v2->v3 * Replaced ternary conditional operator with if-else in .device_group() * Dropped change in tegra_smmu_

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

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 05:35:24PM +0300, Dmitry Osipenko wrote: > 02.10.2020 09:08, Nicolin Chen пишет: > > @@ -865,7 +866,11 @@ static struct iommu_group > > *tegra_smmu_device_group(struct device *dev) > > group->smmu = smmu; > > group->soc

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 05:23:14PM +0300, Dmitry Osipenko wrote: > 02.10.2020 09:08, Nicolin Chen пишет: > > static struct iommu_device *tegra_smmu_probe_device(struct device *dev) > > { > > - struct device_node *np = dev->of_node; > > - struct tegra_smm

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 06:02:18PM +0300, Dmitry Osipenko wrote: > 02.10.2020 09:08, Nicolin Chen пишет: > > static int tegra_smmu_of_xlate(struct device *dev, > >struct of_phandle_args *args) > > { > > + struct platform_device *iommu_pd

Re: [PATCH v4 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 05:41:50PM +0300, Dmitry Osipenko wrote: > 02.10.2020 09:08, Nicolin Chen пишет: > > static int tegra_smmu_attach_dev(struct iommu_domain *domain, > > struct device *dev) > > { > > + struct iommu_fwspec *fwspec

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 05:58:29PM +0300, Dmitry Osipenko wrote: > 02.10.2020 17:22, Dmitry Osipenko пишет: > > 02.10.2020 09:08, Nicolin Chen пишет: > >> -static void tegra_smmu_release_device(struct device *dev) > >> -{ > >> - dev_iommu_priv_set(d

Re: [PATCH v4 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 05:52:00PM +0300, Dmitry Osipenko wrote: > 02.10.2020 17:22, Dmitry Osipenko пишет: > > 02.10.2020 09:08, Nicolin Chen пишет: > >> static int tegra_smmu_attach_dev(struct iommu_domain *domain, > >> struct device *

Re: [PATCH v4 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-02 Thread Nicolin Chen
On Fri, Oct 02, 2020 at 11:12:18PM +0300, Dmitry Osipenko wrote: > 02.10.2020 22:45, Nicolin Chen пишет: > > On Fri, Oct 02, 2020 at 05:41:50PM +0300, Dmitry Osipenko wrote: > >> 02.10.2020 09:08, Nicolin Chen пишет: > >>> static int tegra_smmu_attach_d

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

2020-10-03 Thread Nicolin Chen
This patch simply adds support for PCI devices. Signed-off-by: Nicolin Chen Reviewed-by: Dmitry Osipenko --- Changelog v4->v5 * Added Dmitry's Reviewed-by v3->v4 * Dropped !iommu_present() check * Added CONFIG_PCI check in the exit path v2->v3 * Replaced ternary conditional

[PATCH v5 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-03 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Removed "index" and "err" assigning to 0 v3->v4: * Seperated the change, as a cleanup, from the rework patch v1

[PATCH v5 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-03 Thread Nicolin Chen
tegra-i2c 7000c500.i2c: Adding to iommu group 0 tegra-i2c 7000d000.i2c: Adding to iommu group 0 tegra-pcie 1003000.pcie: Adding to iommu group 1 ... Note that dmesg log above is testing with IOMMU_DOMAIN_UNMANAGED. Signed-off-by: Nicolin Chen --- Changelog v4->v5 * Replaced of

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

2020-10-03 Thread Nicolin Chen
another way to get smmu pointer v2->v3 * Replaced with devm_tegra_get_memory_controller * Updated changes by following Dmitry's comments v1->v2 * Added PATCH-1 suggested by Dmitry * Reworked PATCH-2 to unify certain code Nicolin Chen (3): iommu/tegra-smmu: Use fwspec in tegra_sm

Re: [PATCH v5 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-04 Thread Nicolin Chen
On Sat, Oct 03, 2020 at 05:06:42PM +0300, Dmitry Osipenko wrote: > 03.10.2020 09:59, Nicolin Chen пишет: > > static int tegra_smmu_of_xlate(struct device *dev, > >struct of_phandle_args *args) > > { > > + struct platform_device *iommu_pd

Re: [PATCH v5 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-04 Thread Nicolin Chen
On Sat, Oct 03, 2020 at 05:05:52PM +0300, Dmitry Osipenko wrote: > 03.10.2020 09:59, Nicolin Chen пишет: > > ubuntu@jetson:~$ dmesg | grep iommu > > iommu: Default domain type: Translated > > tegra-i2c 7000c400.i2c: Adding to iommu group 0 > > tegra-

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

2020-10-04 Thread Nicolin Chen
On Sat, Oct 03, 2020 at 05:16:20PM +0300, Dmitry Osipenko wrote: > 03.10.2020 09:59, Nicolin Chen пишет: > > This patch simply adds support for PCI devices. > > > > Signed-off-by: Nicolin Chen > > Reviewed-by: Dmitry Osipenko > > Small nit: yours s-b tag alwa

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

2020-10-04 Thread Nicolin Chen
>v2 * Added PATCH-1 suggested by Dmitry * Reworked PATCH-2 to unify certain code Nicolin Chen (3): iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev iommu/tegra-smmu: Rework tegra_smmu_probe_device() iommu/tegra-smmu: Add PCI support drivers/iommu/tegra-smmu.c | 180 --

[PATCH v6 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-04 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v5->v6: * Added Dmitry's Reviewed-by and Tested-by v4->v5: * Removed "ind

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

2020-10-04 Thread Nicolin Chen
This patch simply adds support for PCI devices. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v5->v6 * Added Dmitry's Reviewed-by and Tested-by. v4->v5 * Added Dmitry's Reviewed-by v3->v4 * Dropped !iommu_prese

[PATCH v6 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-04 Thread Nicolin Chen
p 2 nouveau 5700.gpu: Adding to iommu group 3 Note that dmesg log above is testing with IOMMU_DOMAIN_UNMANAGED. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v5->v6 * Dropped NULL mc/smmu pointer check, suggested by Dmitry. *

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

2020-10-05 Thread Nicolin Chen
On Mon, Oct 05, 2020 at 12:04:19PM +0200, Thierry Reding wrote: > > +err_bus_set: __maybe_unused; > > + bus_set_iommu(&platform_bus_type, NULL); > > +err_unregister: > > + iommu_device_unregister(&smmu->iommu); > > +err_sysfs: > > + iommu_device_sysfs_remove(&smmu->iommu); > > Can you please

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-05 Thread Nicolin Chen
On Mon, Oct 05, 2020 at 11:57:54AM +0200, Thierry Reding wrote: > On Fri, Oct 02, 2020 at 11:58:29AM -0700, Nicolin Chen wrote: > > On Fri, Oct 02, 2020 at 06:02:18PM +0300, Dmitry Osipenko wrote: > > > 02.10.2020 09:08, Nicolin Chen пишет: > > > > static int teg

Re: [PATCH v5 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-05 Thread Nicolin Chen
On Mon, Oct 05, 2020 at 12:56:38PM +0200, Thierry Reding wrote: > On Mon, Oct 05, 2020 at 11:41:08AM +0300, Dmitry Osipenko wrote: > > 05.10.2020 00:57, Nicolin Chen пишет: > > > On Sat, Oct 03, 2020 at 05:06:42PM +0300, Dmitry Osipenko wrote: > > >> 03.10.

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-08 Thread Nicolin Chen
On Thu, Oct 08, 2020 at 11:53:43AM +0200, Thierry Reding wrote: > On Mon, Oct 05, 2020 at 06:05:46PM -0700, Nicolin Chen wrote: > > On Mon, Oct 05, 2020 at 11:57:54AM +0200, Thierry Reding wrote: > > > On Fri, Oct 02, 2020 at 11:58:29AM -0700, Nicolin Chen wrote: > > > &

Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-09 Thread Nicolin Chen
On Fri, Oct 09, 2020 at 02:25:56PM +0200, Thierry Reding wrote: > On Thu, Oct 08, 2020 at 02:12:10PM -0700, Nicolin Chen wrote: > > On Thu, Oct 08, 2020 at 11:53:43AM +0200, Thierry Reding wrote: > > > On Mon, Oct 05, 2020 at 06:05:46PM -0700, Nicolin Chen wrote: > > > &

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

2020-10-09 Thread Nicolin Chen
This patch simply adds support for PCI devices. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v6->v7 * Renamed goto labels, suggested by Thierry. v5->v6 * Added Dmitry's Reviewed-by and Tested-by. v4->v5 * Added Dmitry&#x

[PATCH v7 1/3] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-10-09 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v6->v7: * No change v5->v6: * Added Dmitry's Reviewed-by and Tested-by v4-&

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

2020-10-09 Thread Nicolin Chen
d another way to get smmu pointer v2->v3 * Replaced with devm_tegra_get_memory_controller * Updated changes by following Dmitry's comments v1->v2 * Added PATCH-1 suggested by Dmitry * Reworked PATCH-2 to unify certain code Nicolin Chen (3): iommu/tegra-smmu: Use fwspec in t

[PATCH v7 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()

2020-10-09 Thread Nicolin Chen
p 2 nouveau 5700.gpu: Adding to iommu group 3 Note that dmesg log above is testing with IOMMU_DOMAIN_UNMANAGED. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- Changelog v6->v7 * Added comments for put_device(), suggested by Thierry. v5->v6

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

2020-10-14 Thread Nicolin Chen
On Wed, Oct 14, 2020 at 06:42:36PM +0100, Robin Murphy wrote: > On 2020-10-09 17:19, Nicolin Chen wrote: > > This patch simply adds support for PCI devices. > > > > Reviewed-by: Dmitry Osipenko > > Tested-by: Dmitry Osipenko > > Signed-off-by: Nicolin Chen >

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

2020-10-15 Thread Nicolin Chen
On Thu, Oct 15, 2020 at 10:55:52AM +0100, Robin Murphy wrote: > On 2020-10-15 05:13, Nicolin Chen wrote: > > On Wed, Oct 14, 2020 at 06:42:36PM +0100, Robin Murphy wrote: > > > On 2020-10-09 17:19, Nicolin Chen wrote: > > > > This patch simpl

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

2020-10-16 Thread Nicolin Chen
On Fri, Oct 16, 2020 at 03:10:26PM +0100, Robin Murphy wrote: > On 2020-10-16 04:53, Nicolin Chen wrote: > > On Thu, Oct 15, 2020 at 10:55:52AM +0100, Robin Murphy wrote: > > > On 2020-10-15 05:13, Nicolin Chen wrote: > > > > On Wed, Oct 14, 2020 at 06:42:

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

2020-11-07 Thread Nicolin Chen
On Mon, Sep 28, 2020 at 11:13:23PM -0700, Nicolin Chen wrote: > Two followup patches for tegra-smmu: > PATCH-1 is a clean-up patch for the recently applied SWGROUP change. > PATCH-2 fixes a potential race condition These two changes have Acked-by and Reviewed-by for a month already. Who

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

2020-11-07 Thread Nicolin Chen
On Fri, Oct 09, 2020 at 09:19:33AM -0700, Nicolin Chen wrote: > This series is to add PCI support in tegra-smmu driver. This v7 has fixed all the existing comments and been in the maillist for nearly a month. Can anyone please apply them? Thanks Nic > Changelog (Detail in each patch) &g

[PATCH RESEND 0/5] iommu/tegra-smmu: Some pending reviewed changes

2020-11-11 Thread Nicolin Chen
t;[PATCH v7 0/3] iommu/tegra-smmu: Add PCI support" Nicolin Chen (5): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expand mutex protection range iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev iommu/tegra-smmu: Rework tegra_smmu_probe_device() iommu/tegra-s

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

2020-11-11 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. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 34

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

2020-11-11 Thread Nicolin Chen
This patch simply adds support for PCI devices. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 35 +-- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/tegra

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

2020-11-11 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 19 --- 1 file changed, 4 insertions(+),

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

2020-11-11 Thread Nicolin Chen
p 2 nouveau 5700.gpu: Adding to iommu group 3 Note that dmesg log above is testing with IOMMU_DOMAIN_UNMANAGED. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 96 ++ 1 file changed, 15

[PATCH RESEND 3/5] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-11-11 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 56 -- 1 file changed, 23 in

Re: [PATCH RESEND 0/5] iommu/tegra-smmu: Some pending reviewed changes

2020-11-24 Thread Nicolin Chen
Hi Joerg, These five patches were acked by Thierry and acked-n-tested by Dmitry a while ago. Would it be possible for you to apply them? Thanks! On Wed, Nov 11, 2020 at 02:21:24PM -0800, Nicolin Chen wrote: > This is a merged set of resend for previously two series of patches > tha

Re: [PATCH RESEND 0/5] iommu/tegra-smmu: Some pending reviewed changes

2020-11-24 Thread Nicolin Chen
On Wed, Nov 25, 2020 at 02:05:14AM +0300, Dmitry Osipenko wrote: > 25.11.2020 00:21, Nicolin Chen пишет: > > Hi Joerg, > > > > These five patches were acked by Thierry and acked-n-tested by > > Dmitry a while ago. Would it be possible for you to apply them? > &g

Re: [PATCH RESEND 0/5] iommu/tegra-smmu: Some pending reviewed changes

2020-11-25 Thread Nicolin Chen
On Wed, Nov 25, 2020 at 09:55:10AM +, Will Deacon wrote: > On Tue, Nov 24, 2020 at 03:12:16PM -0800, Nicolin Chen wrote: > > On Wed, Nov 25, 2020 at 02:05:14AM +0300, Dmitry Osipenko wrote: > > > 25.11.2020 00:21, Nicolin Chen пишет: > > > > These five patches wer

[PATCH RESEND v2 0/5] iommu/tegra-smmu: Some pending reviewed changes

2020-11-25 Thread Nicolin Chen
es" Series-2: https://lkml.org/lkml/2020/10/9/808 "[PATCH v7 0/3] iommu/tegra-smmu: Add PCI support" Nicolin Chen (5): iommu/tegra-smmu: Unwrap tegra_smmu_group_get iommu/tegra-smmu: Expand mutex protection range iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_de

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

2020-11-25 Thread Nicolin Chen
->list for other devices to match. This patch simply unwraps the function to clean it up. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 19 --- 1 file changed, 4 insertions(+),

[PATCH RESEND v2 2/5] iommu/tegra-smmu: Expand mutex protection range

2020-11-25 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. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 34

[PATCH RESEND v2 3/5] iommu/tegra-smmu: Use fwspec in tegra_smmu_(de)attach_dev

2020-11-25 Thread Nicolin Chen
So this patch uses fwspec in tegra_smmu_(de)attach_dev() so as to replace the redundant DT polling code. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 56 -- 1 f

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

2020-11-25 Thread Nicolin Chen
p 2 nouveau 5700.gpu: Adding to iommu group 3 Note that dmesg log above is testing with IOMMU_DOMAIN_UNMANAGED. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 96 ++-

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

2020-11-25 Thread Nicolin Chen
This patch simply adds support for PCI devices. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 35 +-- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git

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

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 06:50:52PM +0200, Thierry Reding wrote: > > static const struct tegra_smmu_group_soc * > > -tegra_smmu_find_group(struct tegra_smmu *smmu, unsigned int swgroup) > > +tegra_smmu_find_group_soc(struct tegra_smmu *smmu, unsigned int swgroup) > > This one might be okay to dis

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

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 06:57:31PM +0200, Thierry Reding wrote: > On Mon, Sep 13, 2021 at 06:38:55PM -0700, Nicolin Chen wrote: > > There are both tegra_smmu_swgroup and tegra_smmu_group structs > > using "group" for their pointer instances. This gets confusing > &g

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

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 07:13:25PM +0200, Thierry Reding wrote: > > @@ -496,6 +506,8 @@ static void tegra_smmu_as_unprepare(struct tegra_smmu > > *smmu, > > mutex_unlock(&smmu->lock); > > } > > > > +static const struct file_operations tegra_smmu_debugfs_mappings_fops; > > Could the impleme

[PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-12 Thread Nicolin Chen via iommu
To calculate num_pages, the size should be aligned with "page size", determined by the tg value. Otherwise, its following "while (iova < end)" might become an infinite loop if unaligned size is slightly greater than 1 << tg. Signed-off-by: Nicolin Chen --- drivers/i

Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-13 Thread Nicolin Chen via iommu
Hi Robin, On Wed, Apr 13, 2022 at 02:40:31PM +0100, Robin Murphy wrote: > On 2022-04-13 05:17, Nicolin Chen wrote: > > To calculate num_pages, the size should be aligned with > > "page size", determined by the tg value. Otherwise, its > > following "while (i

Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-14 Thread Nicolin Chen via iommu
On Thu, Apr 14, 2022 at 11:32:38AM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2022-04-13 21:19, Nicolin Chen wrote: > > Hi Robin, > > > > On Wed, Apr 13, 2022 at 02:40:31PM +0100, Robin Murphy wrote: > >

Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-15 Thread Nicolin Chen via iommu
On Thu, Apr 14, 2022 at 11:32:38AM +0100, Robin Murphy wrote: > > By looking at the call trace within arm_smmu_* functions: > >__arm_smmu_tlb_inv_range > >arm_smmu_tlb_inv_range_asid > >arm_smmu_mm_invalidate_range > >{from mm_notifier_* functions} > > > > There's no address alignm

Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-19 Thread Nicolin Chen via iommu
On Tue, Apr 19, 2022 at 05:02:33PM -0300, Jason Gunthorpe wrote: > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > > index d816759a6bcf..e280568bb513 100644 > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > > @@ -183

[PATCH] iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()

2022-04-19 Thread Nicolin Chen via iommu
uot;) Cc: sta...@vger.kernel.org Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 22dd

Re: [PATCH] iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()

2022-04-19 Thread Nicolin Chen via iommu
On Tue, Apr 19, 2022 at 08:10:34PM -0300, Jason Gunthorpe wrote: > > - size_t size = end - start + 1; > > + size_t size; > > + > > + /* > > + * The mm_types defines vm_end as the first byte after the end > > address, > > + * different from IOMMU subsystem using the last addr

Re: [PATCH] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-04 Thread Nicolin Chen via iommu
On Tue, May 03, 2022 at 09:11:02PM -0300, Jason Gunthorpe wrote: > This is based on Robins draft here: > > https://lore.kernel.org/linux-iommu/18831161-473f-e04f-4a81-1c7062ad1...@arm.com/ > > With some rework. I re-organized the call chains instead of introducing > iommu_group_user_attached(),

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-10 Thread Nicolin Chen via iommu
it including the > enable_nesting iommu_domain_op. > > Just in-case there is some userspace using this continue to treat > requesting it as a NOP, but do not advertise support any more. > > Signed-off-by: Jason Gunthorpe Sanity-tested with qemu-system-aarch64 using "iommu

[PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-12 Thread Nicolin Chen via iommu
Local boot test and VFIO sanity test show that info->iommu can be used in device_to_iommu() as a fast path. So this patch adds it. Signed-off-by: Nicolin Chen --- drivers/iommu/intel/iommu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/io

Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-12 Thread Nicolin Chen via iommu
On Fri, May 13, 2022 at 11:32:11AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/5/13 08:32, Nicolin Chen wrote: > > Local boot test and VFIO sanity test show that info->iommu can be > > used in device_to_iommu() as

Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-13 Thread Nicolin Chen via iommu
On Fri, May 13, 2022 at 08:50:32AM -0300, Jason Gunthorpe wrote: > > Perhaps, we can make device_to_iommu() only for probe_device() where the > > per-device info data is not initialized yet. After probe_device(), iommu > > and sid are retrieved through other helpers by looking up the device > > in

[PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-05 Thread Nicolin Chen via iommu
lity. Add kdocs describing this behavior. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/apple-dart.c | 4 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++--- drivers/iommu/ar

[PATCH 0/5] Simplify vfio_iommu_type1 attach/detach routine

2022-06-05 Thread Nicolin Chen via iommu
nforced cache coherency Nicolin Chen (4): iommu: Return -EMEDIUMTYPE for incompatible domain and device/group iommu: Ensure device has the same iommu_ops as the domain vfio/iommu_type1: Clean up update_dirty_scope in detach_group() vfio/iommu_type1: Simplify group attachment drivers/iomm

[PATCH 2/5] iommu: Ensure device has the same iommu_ops as the domain

2022-06-05 Thread Nicolin Chen via iommu
the iommu_domain and use it as a check to validate that the struct device is correct before invoking any domain op that accepts a struct device. This allows removing the check of the domain op equality in VFIO. Co-developed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin

[PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-05 Thread Nicolin Chen via iommu
cache coherency mode. Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index c13b9290e357..f4e3b423a453 100644

[PATCH 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group()

2022-06-05 Thread Nicolin Chen via iommu
roup_done" goto label accordingly. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 27 --- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.

[PATCH 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-05 Thread Nicolin Chen via iommu
the IOMMU core. Co-developed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 306 +--- 1 file changed, 161 insertions(+), 145 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/v

Re: [PATCH 2/5] iommu: Ensure device has the same iommu_ops as the domain

2022-06-06 Thread Nicolin Chen via iommu
Hi Robin, On Mon, Jun 06, 2022 at 03:33:42PM +0100, Robin Murphy wrote: > On 2022-06-06 07:19, Nicolin Chen wrote: > > The core code should not call an iommu driver op with a struct device > > parameter unless it knows that the dev_iommu_priv_get() for that struct > > device

Re: [PATCH 2/5] iommu: Ensure device has the same iommu_ops as the domain

2022-06-06 Thread Nicolin Chen via iommu
On Mon, Jun 06, 2022 at 06:50:33PM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2022-06-06 17:51, Nicolin Chen wrote: > > Hi Robin, > > > > On Mon, Jun 06, 2022 at 03:33:42PM +0100, Robin Murphy wrote: > >

Re: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-06 Thread Nicolin Chen via iommu
On Tue, Jun 07, 2022 at 11:23:27AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/6/6 14:19, Nicolin Chen wrote: > > +/** > > + * iommu_attach_group - Attach an IOMMU group to an IOMMU domain > > + * @domain: IOMMU

Re: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-08 Thread Nicolin Chen via iommu
Hi Kevin, On Wed, Jun 08, 2022 at 07:49:10AM +, Tian, Kevin wrote: > External email: Use caution opening links or attachments > > > > From: Nicolin Chen > > Sent: Monday, June 6, 2022 2:19 PM > > > > Cases like VFIO wish to attach a device to an existing

Re: [PATCH 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group()

2022-06-08 Thread Nicolin Chen via iommu
On Wed, Jun 08, 2022 at 08:35:47AM +, Tian, Kevin wrote: > > @@ -2519,7 +2515,17 @@ static void vfio_iommu_type1_detach_group(void > > *iommu_data, > > kfree(domain); > > vfio_iommu_aper_expand(iommu, &iova_copy); > > vfio_updat

Re: [PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-14 Thread Nicolin Chen via iommu
Hi Kevin, On Wed, Jun 08, 2022 at 11:48:27PM +, Tian, Kevin wrote: > > > > The KVM mechanism for controlling wbinvd is only triggered during > > > > kvm_vfio_group_add(), meaning it is a one-shot test done once the > > devices > > > > are setup. > > > > > > It's not one-shot. kvm_vfio_update_c

Re: [PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-15 Thread Nicolin Chen via iommu
On Wed, Jun 15, 2022 at 07:35:00AM +, Tian, Kevin wrote: > External email: Use caution opening links or attachments > > > > From: Nicolin Chen > > Sent: Wednesday, June 15, 2022 4:45 AM > > > > Hi Kevin, > > > > On Wed, Jun 08, 2022 at 11:48:2

[PATCH v2 0/5] Simplify vfio_iommu_type1 attach/detach routine

2022-06-15 Thread Nicolin Chen via iommu
s://lore.kernel.org/kvm/20220606061927.26049-1-nicol...@nvidia.com/ Jason Gunthorpe (1): vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Nicolin Chen (4): iommu: Return -EMEDIUMTYPE for incompatible domain and device/group vfio/iommu_type1: Remove the domai

[PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-15 Thread Nicolin Chen via iommu
vcpu load, write_cr0, ept, etc.). In reality we don't see an usage requiring such optimization as the only device which imposes such non-coherency is Intel GPU which even doesn't support hotplug/hot remove. Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vf

[PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-15 Thread Nicolin Chen via iommu
lity. Also turn adjacent error prints into debug prints, for these soft failures, to prevent a kernel log spam. Add kdocs describing this behavior. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/ap

[PATCH v2 3/5] vfio/iommu_type1: Remove the domain->ops comparison

2022-06-15 Thread Nicolin Chen via iommu
https://lore.kernel.org/linux-iommu/6575de6d-94ba-c427-5b1e-967750ddf...@arm.com/ Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 32 +++- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_t

[PATCH v2 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group()

2022-06-15 Thread Nicolin Chen via iommu
roup_done" goto label accordingly. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 27 --- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.

[PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-15 Thread Nicolin Chen via iommu
-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 298 +--- 1 file changed, 163 insertions(+), 135 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 573caf320788..5986c68e59ee 100644 --- a/drivers/vfio

Re: [PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-15 Thread Nicolin Chen via iommu
On Thu, Jun 16, 2022 at 10:09:49AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/6/16 08:03, Nicolin Chen wrote: > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > > index 44016594831d..0dd13

Re: [PATCH v2 3/5] vfio/iommu_type1: Remove the domain->ops comparison

2022-06-16 Thread Nicolin Chen via iommu
On Thu, Jun 16, 2022 at 06:40:14AM +, Tian, Kevin wrote: > > The domain->ops validation was added, as a precaution, for mixed-driver > > systems. However, at this moment only one iommu driver is possible. So > > remove it. > > It's true on a physical platform. But I'm not sure whether a virtu

Re: [PATCH v2 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group()

2022-06-16 Thread Nicolin Chen via iommu
On Thu, Jun 16, 2022 at 06:45:09AM +, Tian, Kevin wrote: > > +out_unlock: > > mutex_unlock(&iommu->lock); > > } > > > > I'd just replace the goto with a direct unlock and then return there. > the readability is slightly better. OK. Will do that. ___

Re: [PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-16 Thread Nicolin Chen via iommu
On Thu, Jun 16, 2022 at 07:08:10AM +, Tian, Kevin wrote: > ... > > +static struct vfio_domain * > > +vfio_iommu_alloc_attach_domain(struct bus_type *bus, struct vfio_iommu > > *iommu, > > +struct vfio_iommu_group *group) > > +{ > > + struct iommu_domain *new_doma

Re: [PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-17 Thread Nicolin Chen via iommu
On Fri, Jun 17, 2022 at 02:53:13AM +, Tian, Kevin wrote: > > > ... > > > > - if (resv_msi) { > > > > + if (resv_msi && !domain->msi_cookie) { > > > > ret = iommu_get_msi_cookie(domain->domain, > > > > resv_msi_base); > > > > if (ret && ret != -ENODEV) > > > >

Re: [PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-21 Thread Nicolin Chen via iommu
On Mon, Jun 20, 2022 at 01:03:17AM -0300, Jason Gunthorpe wrote: > On Fri, Jun 17, 2022 at 04:07:20PM -0700, Nicolin Chen wrote: > > > > > > > + vfio_iommu_aper_expand(iommu, &iova_copy); > > > > > > > > > > but now it's done for

Re: [PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-21 Thread Nicolin Chen via iommu
On Mon, Jun 20, 2022 at 11:11:01AM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2022-06-17 03:53, Tian, Kevin wrote: > > > From: Nicolin Chen > > > Sent: Friday, June 17, 2022 6:41 AM > > > &

Re: [PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-21 Thread Nicolin Chen via iommu
On Tue, Jun 21, 2022 at 04:46:02PM -0600, Alex Williamson wrote: > External email: Use caution opening links or attachments > > > On Wed, 15 Jun 2022 17:03:01 -0700 > Nicolin Chen wrote: > > > From: Jason Gunthorpe > > > > The KVM mechanism for cont

Re: [PATCH v2 3/5] vfio/iommu_type1: Remove the domain->ops comparison

2022-06-23 Thread Nicolin Chen via iommu
On Thu, Jun 23, 2022 at 03:50:22AM +, Tian, Kevin wrote: > External email: Use caution opening links or attachments > > > > From: Robin Murphy > > Sent: Wednesday, June 22, 2022 3:55 PM > > > > On 2022-06-16 23:23, Nicolin Chen wrote: > > > On T

[PATCH v3 0/5] Simplify vfio_iommu_type1 attach/detach routine

2022-06-23 Thread Nicolin Chen via iommu
s://lore.kernel.org/kvm/20220606061927.26049-1-nicol...@nvidia.com/ Jason Gunthorpe (1): vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Nicolin Chen (4): iommu: Return -EMEDIUMTYPE for incompatible domain and device/group vfio/iommu_type1: Remove the domain->o

<    1   2   3   4   >