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

2022-07-01 Thread Nicolin Chen via iommu
: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 333 +--- 1 file changed, 180 insertions(+), 153 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 5624bbf02ab7..d3a4cedcd082 100644 --- a

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

2022-07-01 Thread Nicolin Chen via iommu
Gunthorpe Reviewed-by: Kevin Tian 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.c index 5992ee2345a0..5624bbf02ab7 10

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

2022-07-01 Thread Nicolin Chen via iommu
-967750ddf...@arm.com/ So remove the check in VFIO for simplicity. Reviewed-by: Kevin Tian 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_t

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

2022-07-01 Thread Nicolin Chen via iommu
;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 Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type

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

2022-07-01 Thread Nicolin Chen via iommu
lity. Also remove adjacent error prints for these soft failures, to prevent a kernel log spam, since -EMEDIUMTYPE is clear enough to indicate an incompatability error. Add kdocs describing this behavior. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Ni

[PATCH v5 0/5] cover-letter: Simplify vfio_iommu_type1 attach/detach routine

2022-07-01 Thread Nicolin Chen via iommu
main pathways, like the code previously did. * Fixed a typo in EMEDIUMTYPE patch. v1: https://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

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

2022-07-01 Thread Nicolin Chen via iommu
On Fri, Jul 01, 2022 at 07:17:38PM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 01/07/2022 5:43 pm, Nicolin Chen wrote: > > On Fri, Jul 01, 2022 at 11:21:48AM +0100, Robin Murphy wrote: > > > > > > diff --

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

2022-07-01 Thread Nicolin Chen via iommu
On Fri, Jul 01, 2022 at 11:21:48AM +0100, Robin Murphy wrote: > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c > > b/drivers/iommu/arm/arm-smmu/arm-smmu.c > > index 2ed3594f384e..072cac5ab5a4 100644 > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > > +++ b/drivers/iommu/arm/arm-smmu/arm-smm

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

2022-06-30 Thread Nicolin Chen via iommu
Gunthorpe Reviewed-by: Kevin Tian 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.c index 11be5f95580b..b9ccb3cfac5d 10

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

2022-06-30 Thread Nicolin Chen via iommu
: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 321 +--- 1 file changed, 174 insertions(+), 147 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index b9ccb3cfac5d..3ffa4e2d9d18 100644 --- a

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

2022-06-30 Thread Nicolin Chen via iommu
;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 Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type

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

2022-06-30 Thread Nicolin Chen via iommu
-967750ddf...@arm.com/ So remove the check in VFIO for simplicity. Reviewed-by: Kevin Tian 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_t

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

2022-06-30 Thread Nicolin Chen via iommu
lity. Also remove adjacent error prints for these soft failures, to prevent a kernel log spam, since -EMEDIUMTYPE is clear enough to indicate an incompatability error. Add kdocs describing this behavior. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- dri

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

2022-06-30 Thread Nicolin Chen via iommu
"num_non_pinned_groups++" in PATCH-5 to the common path between domain-reusing and new-domain pathways, like the code previously did. * Fixed a typo in EMEDIUMTYPE patch. v1: https://lore.kernel.org/kvm/20220606061927.26049-1-nicol...@nvidia.com/ Jason Gunthorpe (1): vfio/iommu_t

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

2022-06-30 Thread Nicolin Chen via iommu
On Thu, Jun 30, 2022 at 09:21:42AM +0100, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2022-06-29 20:47, Nicolin Chen wrote: > > On Fri, Jun 24, 2022 at 03:19:43PM -0300, Jason Gunthorpe wrote: > > > On Fri, Jun 24, 2022 a

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

2022-06-30 Thread Nicolin Chen via iommu
On Thu, Jun 30, 2022 at 05:33:16PM +0800, Yong Wu wrote: > External email: Use caution opening links or attachments > > > On Wed, 2022-06-29 at 12:47 -0700, Nicolin Chen wrote: > > On Fri, Jun 24, 2022 at 03:19:43PM -0300, Jason Gunthorpe wrote: > > > On Fri, Jun 2

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

2022-06-29 Thread Nicolin Chen via iommu
On Fri, Jun 24, 2022 at 03:19:43PM -0300, Jason Gunthorpe wrote: > On Fri, Jun 24, 2022 at 06:35:49PM +0800, Yong Wu wrote: > > > > > It's not used in VFIO context. "return 0" just satisfy the iommu > > > > framework to go ahead. and yes, here we only allow the shared > > > > "mapping-domain" (All

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

2022-06-23 Thread Nicolin Chen via iommu
On Fri, Jun 24, 2022 at 01:38:58PM +0800, Yong Wu wrote: > > > > diff --git a/drivers/iommu/mtk_iommu_v1.c > > > > b/drivers/iommu/mtk_iommu_v1.c > > > > index e1cb51b9866c..5386d889429d 100644 > > > > --- a/drivers/iommu/mtk_iommu_v1.c > > > > +++ b/drivers/iommu/mtk_iommu_v1.c > > > > @@ -304,7

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

2022-06-23 Thread Nicolin Chen via iommu
On Fri, Jun 24, 2022 at 09:35:49AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/6/24 04:00, Nicolin Chen wrote: > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > > index e1cb51b9866c..5386d

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

2022-06-23 Thread Nicolin Chen via iommu
-967750ddf...@arm.com/ So remove the check in VFIO for simplicity. Reviewed-by: Kevin Tian 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_t

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

2022-06-23 Thread Nicolin Chen via iommu
Gunthorpe Reviewed-by: Kevin Tian 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.c index 11be5f95580b..b9ccb3cfac5d 10

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

2022-06-23 Thread Nicolin Chen via iommu
-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 321 +--- 1 file changed, 174 insertions(+), 147 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index b9ccb3cfac5d..3ffa4e2d9d18 100644 --- a/drivers/vfio

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

2022-06-23 Thread Nicolin Chen via iommu
;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 Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/vfio/vfio_iommu_type1.c | 4 +--- 1 file change

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

2022-06-23 Thread Nicolin Chen via iommu
lity. Also remove adjacent error prints for these soft failures, to prevent a kernel log spam, since -EMEDIUMTYPE is clear enough to indicate an incompatability error. Add kdocs describing this behavior. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- dri

[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

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

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

[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

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

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

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

[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

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

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

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

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

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] 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

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

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

[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 v3 5/5] iommu/nvidia-grace-cmdqv: Limit CMDs for guest owned VINTF

2021-12-27 Thread Nicolin Chen via iommu
On Fri, Dec 24, 2021 at 12:13:57PM +, Robin Murphy wrote: > > > > > > @@ -176,6 +177,24 @@ struct arm_smmu_cmdq > > > > > > *nvidia_grace_cmdqv_get_cmdq(struct arm_smmu_device *smmu) > > > > > > if (!FIELD_GET(VINTF_STATUS, vintf0->status)) > > > > > > return &smmu->cm

Re: [PATCH v3 5/5] iommu/nvidia-grace-cmdqv: Limit CMDs for guest owned VINTF

2021-12-24 Thread Nicolin Chen via iommu
On Thu, Dec 23, 2021 at 11:14:17AM +, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2021-12-22 22:52, Nicolin Chen wrote: > > On Wed, Dec 22, 2021 at 12:32:29PM +, Robin Murphy wrote: > > > External email: Use caution o

Re: [PATCH v3 5/5] iommu/nvidia-grace-cmdqv: Limit CMDs for guest owned VINTF

2021-12-22 Thread Nicolin Chen via iommu
On Wed, Dec 22, 2021 at 12:32:29PM +, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2021-11-19 07:19, Nicolin Chen via iommu wrote: > > When VCMDQs are assigned to a VINTF that is owned by a guest, not > > hypervisor (HYP_OWN

Re: [PATCH v3 4/5] iommu/arm-smmu-v3: Add host support for NVIDIA Grace CMDQ-V

2021-12-21 Thread Nicolin Chen via iommu
On Tue, Dec 21, 2021 at 06:55:20PM +, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2021-12-20 19:27, Nicolin Chen wrote: > > Hi Robin, > > > > Thank you for the reply! > > > > On Mon, Dec 20, 2021 at 06:4

Re: [PATCH v3 4/5] iommu/arm-smmu-v3: Add host support for NVIDIA Grace CMDQ-V

2021-12-20 Thread Nicolin Chen via iommu
Hi Robin, Thank you for the reply! On Mon, Dec 20, 2021 at 06:42:26PM +, Robin Murphy wrote: > On 2021-11-19 07:19, Nicolin Chen wrote: > > From: Nate Watterson > > > > NVIDIA's Grace Soc has a CMDQ-Virtualization (CMDQV) hardware, > > which extends the st

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 10:58:15PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 22:51, Nicolin Chen пишет: > > On Thu, Dec 09, 2021 at 10:40:42PM +0300, Dmitry Osipenko wrote: > >> External email: U

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 10:58:32PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 22:54, Nicolin Chen пишет: > > On Thu, Dec 09, 2021 at 10:44:25PM +0300, Dmitry Osipenko wrote: > >> External email: U

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 10:44:25PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 22:24, Nicolin Chen пишет: > > On Thu, Dec 09, 2021 at 05:49:09PM +0300, Dmitry Osipenko wrote: > >> External email: U

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 10:40:42PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 22:32, Nicolin Chen пишет: > > On Thu, Dec 09, 2021 at 05:47:18PM +0300, Dmitry Osipenko wrote: > >> External email: U

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 05:47:18PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 10:38, Nicolin Chen пишет: > > @@ -545,6 +719,15 @@ static void tegra_smmu_detach_as(struct tegra_smmu > > *smmu, > >

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

2021-12-09 Thread Nicolin Chen via iommu
On Thu, Dec 09, 2021 at 05:49:09PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 09.12.2021 10:38, Nicolin Chen пишет: > > +static unsigned long pd_pt_index_iova(unsigned int pd_index, unsigned int > > pt_index) > >

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

2021-12-08 Thread Nicolin Chen via iommu
total PTEs: 52 Note that the example above was output after I locally enabled IOMMU_DOMAIN_DMA, which is not merged to mainline yet due to a known framebuffer issue. Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 185 + 1 file changed, 185

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

2021-12-08 Thread Nicolin Chen via iommu
This patch changes in struct tegra_smmu_group to use swgrp pointer instead of swgroup, as a preparational change for the "mappings" debugfs feature. Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 12 1 file changed, 8 insert

[PATCH v8 2/6] iommu/tegra-smmu: Rename tegra_smmu_find_group to tegra_smmu_find_group_soc

2021-12-08 Thread Nicolin Chen via iommu
The existing function tegra_smmu_find_group really finds group->soc pointer, so naming it "find_group" might not be clear by looking at it alone. This patch renames it to tegra_smmu_group_soc in order to disambiguate the use of "group" in this driver. Signed-off-by: Nic

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

2021-12-08 Thread Nicolin Chen via iommu
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 v8 5/6] iommu/tegra-smmu: Attach as pointer to tegra_smmu_group

2021-12-08 Thread Nicolin Chen via iommu
tions together. Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 96 +++--- 1 file changed, 80 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 532c843eb631..454504aa6602 1

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

2021-12-08 Thread Nicolin Chen via iommu
E RANGE" and "SIZE" columns to group contiguous mappings * Dropped 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: Ren

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

2021-12-08 Thread Nicolin Chen via iommu
p" as a cleanup. Acked-by: Thierry Reding 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 8e906504882d..fd9ef08cb7d9 100644 --- a/driver

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

2021-12-08 Thread Nicolin Chen via iommu
On Wed, Dec 08, 2021 at 07:09:37PM +0300, Dmitry Osipenko wrote: > External email: Use caution opening links or attachments > > > 08.12.2021 11:47, Nicolin Chen пишет: > > static void tegra_smmu_attach_as(struct tegra_smmu *smmu, > >

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

2021-12-08 Thread Nicolin Chen via iommu
0932.GB29926@Asurada-Nvidia/T/ * Expanded mutex range to the entire function * Added as->lock to protect pagetable walkthrough * Replaced devm_kzalloc with devm_kcalloc for group_debug * Added "PTE RANGE" and "SIZE" columns to group contiguous mappings * Dropped as->count

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

2021-12-08 Thread Nicolin Chen via iommu
p" as a cleanup. Acked-by: Thierry Reding 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 c5fa8b8673b6..f874ee2600e5 100644 --- a/driver

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

2021-12-08 Thread Nicolin Chen via iommu
92 ] | 0x7 | 0x0001025ea000 | 0xfffc | 0x21000 } } Total PDEs: 1, total PTEs: 52 Note that the example above was output after I locally enabled IOMMU_DOMAIN_DMA, which is not merged to mainline yet due to a known framebuffer issue. Signed-off-by: Nicolin Chen --- drivers/i

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

2021-12-08 Thread Nicolin Chen via iommu
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 v7 4/6] iommu/tegra-smmu: Use swgrp pointer instead of swgroup id

2021-12-08 Thread Nicolin Chen via iommu
This patch changes in struct tegra_smmu_group to use swgrp pointer instead of swgroup, as a preparational change for the "mappings" debugfs feature. Acked-by: Thierry Reding Signed-off-by: Nicolin Chen --- drivers/iommu/tegra-smmu.c | 12 1 file changed, 8 insert

[PATCH v7 2/6] iommu/tegra-smmu: Rename tegra_smmu_find_group to tegra_smmu_find_group_soc

2021-12-08 Thread Nicolin Chen via iommu
The existing function tegra_smmu_find_group really finds group->soc pointer, so naming it "find_group" might not be clear by looking at it alone. This patch renames it to tegra_smmu_group_soc in order to disambiguate the use of "group" in this driver. Signed-off-by: Nic

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

2021-12-08 Thread Nicolin Chen via iommu
tions together. Acked-by: Thierry Reding 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 b0a04cc8f560..1fbb93215463 1

[PATCH v3 4/5] iommu/arm-smmu-v3: Add host support for NVIDIA Grace CMDQ-V

2021-11-18 Thread Nicolin Chen via iommu
at for the current plan the CMDQV driver only supports ACPI configuration. Signed-off-by: Nate Watterson Signed-off-by: Nicolin Chen --- Changelog: v2->v3: * Replaced impl design with simpler "nvidia_grace_cmdqv" pointer * Aligned all the namings to "nvidia_grace_cmdqv" or

[PATCH v3 2/5] iommu/arm-smmu-v3: Make arm_smmu_cmdq_init reusable

2021-11-18 Thread Nicolin Chen via iommu
The CMDQV extension in NVIDIA Grace SoC resues the arm_smmu_cmdq structure while the queue location isn't same as smmu->cmdq. So, this patch adds a cmdq argument to arm_smmu_cmdq_init() function and shares its define in the header for CMDQV driver to use. Signed-off-by: Nicolin Chen ---

[PATCH v3 5/5] iommu/nvidia-grace-cmdqv: Limit CMDs for guest owned VINTF

2021-11-18 Thread Nicolin Chen via iommu
est kernel. So instead of using the existing regval, this patch reads out the register value explicitly to cache in vintf->cfg. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 +-- .../arm/arm-smmu-v3/nvi

[PATCH v3 3/5] iommu/arm-smmu-v3: Pass cmdq pointer in arm_smmu_cmdq_issue_cmdlist()

2021-11-18 Thread Nicolin Chen via iommu
() every time. This also helps CMDQV extension in NVIDIA Grace SoC, whose driver'd maintain its own cmdq pointers and needs to redirect arm_smmu->cmdq to that upon seeing a supported command by checking its opcode. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v

[PATCH v3 1/5] iommu/arm-smmu-v3: Add CS_NONE quirk

2021-11-18 Thread Nicolin Chen via iommu
The CMDQV extension in NVIDIA Grace SoC only supports CS_NONE in the CS field of CMD_SYNC. So this patch adds a quirk flag to accommodate that. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 4 2 files

[PATCH v3 0/5] iommu/arm-smmu-v3: Add NVIDIA Grace CMDQ-V Support

2021-11-18 Thread Nicolin Chen via iommu
From: Nicolin Chen NVIDIA's Grace SoC has a CMDQ-Virtualization (CMDQV) hardware that extends standard ARM SMMUv3 to support multiple command queues with virtualization capabilities. Though this is similar to the ECMDQ in SMMUv3.3, CMDQV provides additional V-Interfaces that allow VMs to

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

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

  1   2   3   4   >