All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/dart: Remove iommu_flush_ops
@ 2021-09-21 15:39 ` Sven Peter via iommu
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Peter @ 2021-09-21 15:39 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon; +Cc: Sven Peter, Marc Zyngier, iommu, linux-kernel

apple_dart_tlb_flush_{all,walk} expect to get a struct apple_dart_domain
but instead get a struct iommu_domain right now. This breaks those two
functions and can lead to kernel panics like the one below.
DART can only invalidate the entire TLB and apple_dart_iotlb_sync will
already flush everything. There's no need to do that again inside those
two functions. Let's just drop them.

  pci 0000:03:00.0: Removing from iommu group 1
  Unable to handle kernel paging request at virtual address 0000000100000023
  [...]
  Call trace:
   _raw_spin_lock_irqsave+0x54/0xbc
   apple_dart_hw_stream_command.constprop.0+0x2c/0x130
   apple_dart_tlb_flush_all+0x48/0x90
   free_io_pgtable_ops+0x40/0x70
   apple_dart_domain_free+0x2c/0x44
   iommu_group_release+0x68/0xac
   kobject_cleanup+0x4c/0x1fc
   kobject_cleanup+0x14c/0x1fc
   kobject_put+0x64/0x84
   iommu_group_remove_device+0x110/0x180
   iommu_release_device+0x50/0xa0
  [...]

Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
Reported-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/iommu/apple-dart.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index c37fb4790e8a..47ffe9e49abb 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -181,7 +181,6 @@ struct apple_dart_master_cfg {
 
 static struct platform_driver apple_dart_driver;
 static const struct iommu_ops apple_dart_iommu_ops;
-static const struct iommu_flush_ops apple_dart_tlb_ops;
 
 static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom)
 {
@@ -336,22 +335,6 @@ static void apple_dart_iotlb_sync_map(struct iommu_domain *domain,
 	apple_dart_domain_flush_tlb(to_dart_domain(domain));
 }
 
-static void apple_dart_tlb_flush_all(void *cookie)
-{
-	apple_dart_domain_flush_tlb(cookie);
-}
-
-static void apple_dart_tlb_flush_walk(unsigned long iova, size_t size,
-				      size_t granule, void *cookie)
-{
-	apple_dart_domain_flush_tlb(cookie);
-}
-
-static const struct iommu_flush_ops apple_dart_tlb_ops = {
-	.tlb_flush_all = apple_dart_tlb_flush_all,
-	.tlb_flush_walk = apple_dart_tlb_flush_walk,
-};
-
 static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain,
 					   dma_addr_t iova)
 {
@@ -433,7 +416,6 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
 		.ias = 32,
 		.oas = 36,
 		.coherent_walk = 1,
-		.tlb = &apple_dart_tlb_ops,
 		.iommu_dev = dart->dev,
 	};
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] iommu/dart: Remove iommu_flush_ops
@ 2021-09-21 15:39 ` Sven Peter via iommu
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Peter via iommu @ 2021-09-21 15:39 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon; +Cc: Marc Zyngier, iommu, linux-kernel, Sven Peter

apple_dart_tlb_flush_{all,walk} expect to get a struct apple_dart_domain
but instead get a struct iommu_domain right now. This breaks those two
functions and can lead to kernel panics like the one below.
DART can only invalidate the entire TLB and apple_dart_iotlb_sync will
already flush everything. There's no need to do that again inside those
two functions. Let's just drop them.

  pci 0000:03:00.0: Removing from iommu group 1
  Unable to handle kernel paging request at virtual address 0000000100000023
  [...]
  Call trace:
   _raw_spin_lock_irqsave+0x54/0xbc
   apple_dart_hw_stream_command.constprop.0+0x2c/0x130
   apple_dart_tlb_flush_all+0x48/0x90
   free_io_pgtable_ops+0x40/0x70
   apple_dart_domain_free+0x2c/0x44
   iommu_group_release+0x68/0xac
   kobject_cleanup+0x4c/0x1fc
   kobject_cleanup+0x14c/0x1fc
   kobject_put+0x64/0x84
   iommu_group_remove_device+0x110/0x180
   iommu_release_device+0x50/0xa0
  [...]

Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
Reported-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/iommu/apple-dart.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index c37fb4790e8a..47ffe9e49abb 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -181,7 +181,6 @@ struct apple_dart_master_cfg {
 
 static struct platform_driver apple_dart_driver;
 static const struct iommu_ops apple_dart_iommu_ops;
-static const struct iommu_flush_ops apple_dart_tlb_ops;
 
 static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom)
 {
@@ -336,22 +335,6 @@ static void apple_dart_iotlb_sync_map(struct iommu_domain *domain,
 	apple_dart_domain_flush_tlb(to_dart_domain(domain));
 }
 
-static void apple_dart_tlb_flush_all(void *cookie)
-{
-	apple_dart_domain_flush_tlb(cookie);
-}
-
-static void apple_dart_tlb_flush_walk(unsigned long iova, size_t size,
-				      size_t granule, void *cookie)
-{
-	apple_dart_domain_flush_tlb(cookie);
-}
-
-static const struct iommu_flush_ops apple_dart_tlb_ops = {
-	.tlb_flush_all = apple_dart_tlb_flush_all,
-	.tlb_flush_walk = apple_dart_tlb_flush_walk,
-};
-
 static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain,
 					   dma_addr_t iova)
 {
@@ -433,7 +416,6 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
 		.ias = 32,
 		.oas = 36,
 		.coherent_walk = 1,
-		.tlb = &apple_dart_tlb_ops,
 		.iommu_dev = dart->dev,
 	};
 
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/dart: Remove iommu_flush_ops
  2021-09-21 15:39 ` Sven Peter via iommu
@ 2021-09-21 15:49   ` Marc Zyngier
  -1 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2021-09-21 15:49 UTC (permalink / raw)
  To: Sven Peter; +Cc: Joerg Roedel, Will Deacon, iommu, linux-kernel

On Tue, 21 Sep 2021 16:39:34 +0100,
Sven Peter <sven@svenpeter.dev> wrote:
> 
> apple_dart_tlb_flush_{all,walk} expect to get a struct apple_dart_domain
> but instead get a struct iommu_domain right now. This breaks those two
> functions and can lead to kernel panics like the one below.
> DART can only invalidate the entire TLB and apple_dart_iotlb_sync will
> already flush everything. There's no need to do that again inside those
> two functions. Let's just drop them.
> 
>   pci 0000:03:00.0: Removing from iommu group 1
>   Unable to handle kernel paging request at virtual address 0000000100000023
>   [...]
>   Call trace:
>    _raw_spin_lock_irqsave+0x54/0xbc
>    apple_dart_hw_stream_command.constprop.0+0x2c/0x130
>    apple_dart_tlb_flush_all+0x48/0x90
>    free_io_pgtable_ops+0x40/0x70
>    apple_dart_domain_free+0x2c/0x44
>    iommu_group_release+0x68/0xac
>    kobject_cleanup+0x4c/0x1fc
>    kobject_cleanup+0x14c/0x1fc
>    kobject_put+0x64/0x84
>    iommu_group_remove_device+0x110/0x180
>    iommu_release_device+0x50/0xa0
>   [...]
> 
> Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
> Reported-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>

Thanks for addressing this so quickly.

Acked-by: Marc Zyngier <maz@kernel.org>
Tested-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/dart: Remove iommu_flush_ops
@ 2021-09-21 15:49   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2021-09-21 15:49 UTC (permalink / raw)
  To: Sven Peter; +Cc: Will Deacon, iommu, linux-kernel

On Tue, 21 Sep 2021 16:39:34 +0100,
Sven Peter <sven@svenpeter.dev> wrote:
> 
> apple_dart_tlb_flush_{all,walk} expect to get a struct apple_dart_domain
> but instead get a struct iommu_domain right now. This breaks those two
> functions and can lead to kernel panics like the one below.
> DART can only invalidate the entire TLB and apple_dart_iotlb_sync will
> already flush everything. There's no need to do that again inside those
> two functions. Let's just drop them.
> 
>   pci 0000:03:00.0: Removing from iommu group 1
>   Unable to handle kernel paging request at virtual address 0000000100000023
>   [...]
>   Call trace:
>    _raw_spin_lock_irqsave+0x54/0xbc
>    apple_dart_hw_stream_command.constprop.0+0x2c/0x130
>    apple_dart_tlb_flush_all+0x48/0x90
>    free_io_pgtable_ops+0x40/0x70
>    apple_dart_domain_free+0x2c/0x44
>    iommu_group_release+0x68/0xac
>    kobject_cleanup+0x4c/0x1fc
>    kobject_cleanup+0x14c/0x1fc
>    kobject_put+0x64/0x84
>    iommu_group_remove_device+0x110/0x180
>    iommu_release_device+0x50/0xa0
>   [...]
> 
> Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
> Reported-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>

Thanks for addressing this so quickly.

Acked-by: Marc Zyngier <maz@kernel.org>
Tested-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/dart: Remove iommu_flush_ops
  2021-09-21 15:39 ` Sven Peter via iommu
@ 2021-09-28  9:38   ` Joerg Roedel
  -1 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2021-09-28  9:38 UTC (permalink / raw)
  To: Sven Peter; +Cc: Will Deacon, Marc Zyngier, iommu, linux-kernel

On Tue, Sep 21, 2021 at 05:39:34PM +0200, Sven Peter wrote:
 
> Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
> Reported-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
>  drivers/iommu/apple-dart.c | 18 ------------------
>  1 file changed, 18 deletions(-)

Applied for v5.15, thanks Sven.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/dart: Remove iommu_flush_ops
@ 2021-09-28  9:38   ` Joerg Roedel
  0 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2021-09-28  9:38 UTC (permalink / raw)
  To: Sven Peter; +Cc: Marc Zyngier, iommu, Will Deacon, linux-kernel

On Tue, Sep 21, 2021 at 05:39:34PM +0200, Sven Peter wrote:
 
> Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
> Reported-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
>  drivers/iommu/apple-dart.c | 18 ------------------
>  1 file changed, 18 deletions(-)

Applied for v5.15, thanks Sven.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-28  9:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 15:39 [PATCH] iommu/dart: Remove iommu_flush_ops Sven Peter
2021-09-21 15:39 ` Sven Peter via iommu
2021-09-21 15:49 ` Marc Zyngier
2021-09-21 15:49   ` Marc Zyngier
2021-09-28  9:38 ` Joerg Roedel
2021-09-28  9:38   ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.