linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: Print default strict or lazy mode at init time
@ 2021-05-28 13:37 John Garry
  2021-06-01  9:09 ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: John Garry @ 2021-05-28 13:37 UTC (permalink / raw)
  To: joro, will; +Cc: iommu, linux-kernel, hch, robin.murphy, John Garry

As well as the default domain type, it's useful to know whether strict
or lazy mode is default for DMA domains, so add this info in a separate
print.

Signed-off-by: John Garry <john.garry@huawei.com>

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 808ab70d5df5..f25fae62f077 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -138,6 +138,11 @@ static int __init iommu_subsys_init(void)
 		(iommu_cmd_line & IOMMU_CMD_LINE_DMA_API) ?
 			"(set via kernel command line)" : "");
 
+	pr_info("Default DMA domain mode: %s %s\n",
+		iommu_dma_strict ? "strict" : "lazy",
+		(iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ?
+			"(set via kernel command line)" : "");
+
 	return 0;
 }
 subsys_initcall(iommu_subsys_init);
-- 
2.26.2


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

* Re: [PATCH] iommu: Print default strict or lazy mode at init time
  2021-05-28 13:37 [PATCH] iommu: Print default strict or lazy mode at init time John Garry
@ 2021-06-01  9:09 ` Robin Murphy
  2021-06-01 15:50   ` John Garry
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2021-06-01  9:09 UTC (permalink / raw)
  To: John Garry, joro, will; +Cc: iommu, linux-kernel, hch

On 2021-05-28 14:37, John Garry wrote:
> As well as the default domain type, it's useful to know whether strict
> or lazy mode is default for DMA domains, so add this info in a separate
> print.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 808ab70d5df5..f25fae62f077 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -138,6 +138,11 @@ static int __init iommu_subsys_init(void)
>   		(iommu_cmd_line & IOMMU_CMD_LINE_DMA_API) ?
>   			"(set via kernel command line)" : "");
>   
> +	pr_info("Default DMA domain mode: %s %s\n",

Nit: I think this might be a little unclear for end-users - *I'm* not 
even sure whether "Default" here is meant to refer to the mode setting 
itself or to default domains (of DMA type). Maybe something like "DMA 
domain TLB invalidation policy"? Certainly it seems like a good idea to 
explicitly mention invalidation to correlate with the documentation of 
the "iommu.strict" parameter.

Ack to the general idea though.

Thanks,
Robin.

> +		iommu_dma_strict ? "strict" : "lazy",
> +		(iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ?
> +			"(set via kernel command line)" : "");
> +
>   	return 0;
>   }
>   subsys_initcall(iommu_subsys_init);
> 

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

* Re: [PATCH] iommu: Print default strict or lazy mode at init time
  2021-06-01  9:09 ` Robin Murphy
@ 2021-06-01 15:50   ` John Garry
  2021-06-01 16:42     ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: John Garry @ 2021-06-01 15:50 UTC (permalink / raw)
  To: Robin Murphy, joro, will; +Cc: iommu, linux-kernel, hch

On 01/06/2021 10:09, Robin Murphy wrote:
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index 808ab70d5df5..f25fae62f077 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -138,6 +138,11 @@ static int __init iommu_subsys_init(void)
>>           (iommu_cmd_line & IOMMU_CMD_LINE_DMA_API) ?
>>               "(set via kernel command line)" : "");
>> +    pr_info("Default DMA domain mode: %s %s\n",
> 
> Nit: I think this might be a little unclear for end-users - *I'm* not 
> even sure whether "Default" here is meant to refer to the mode setting 
> itself or to default domains (of DMA type). Maybe something like "DMA 
> domain TLB invalidation policy"? Certainly it seems like a good idea to 
> explicitly mention invalidation to correlate with the documentation of 
> the "iommu.strict" parameter.
> 
> Ack to the general idea though.

ok, so I'll go with this:

pr_info("DMA domain default TLB invalidation policy: %s mode %s\n",
               iommu_dma_strict ? "strict" : "lazy",
                (iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ?
                        "(set via kernel command line)" : "");

I think it's worth mentioning "default" somewhere, as not all IOMMUs or 
devices will use lazy mode even if it's default.

Thanks,
John

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

* Re: [PATCH] iommu: Print default strict or lazy mode at init time
  2021-06-01 15:50   ` John Garry
@ 2021-06-01 16:42     ` Robin Murphy
  2021-06-01 17:44       ` John Garry
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2021-06-01 16:42 UTC (permalink / raw)
  To: John Garry, joro, will; +Cc: iommu, linux-kernel, hch

On 2021-06-01 16:50, John Garry wrote:
> On 01/06/2021 10:09, Robin Murphy wrote:
>>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>>> index 808ab70d5df5..f25fae62f077 100644
>>> --- a/drivers/iommu/iommu.c
>>> +++ b/drivers/iommu/iommu.c
>>> @@ -138,6 +138,11 @@ static int __init iommu_subsys_init(void)
>>>           (iommu_cmd_line & IOMMU_CMD_LINE_DMA_API) ?
>>>               "(set via kernel command line)" : "");
>>> +    pr_info("Default DMA domain mode: %s %s\n",
>>
>> Nit: I think this might be a little unclear for end-users - *I'm* not 
>> even sure whether "Default" here is meant to refer to the mode setting 
>> itself or to default domains (of DMA type). Maybe something like "DMA 
>> domain TLB invalidation policy"? Certainly it seems like a good idea 
>> to explicitly mention invalidation to correlate with the documentation 
>> of the "iommu.strict" parameter.
>>
>> Ack to the general idea though.
> 
> ok, so I'll go with this:
> 
> pr_info("DMA domain default TLB invalidation policy: %s mode %s\n",
>                iommu_dma_strict ? "strict" : "lazy",
>                 (iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ?
>                         "(set via kernel command line)" : "");
> 
> I think it's worth mentioning "default" somewhere, as not all IOMMUs or 
> devices will use lazy mode even if it's default.

But that's part of what I think is misleading - I boot and see that the 
default is something, so I reboot with iommu.strict to explicitly set it 
the other way, but now that's the default... huh?

The way I see it, we're saying what the current IOMMU API policy is - 
the value of iommu_dma_strict at any given time is fact - but we're not 
necessarily saying how widely that policy is enforced. We similarly 
report the type for default domains from global policy even though that 
may also be overridden per-group by drivers and/or userspace later; we 
don't say it's the *default* default domain type.

However, having now debugged the AMD issue from another thread, I think 
doing this at subsys_initcall is in fact going to be too early to be 
meaningful, since it ignores drivers' ability to change the global policy :(

Robin.

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

* Re: [PATCH] iommu: Print default strict or lazy mode at init time
  2021-06-01 16:42     ` Robin Murphy
@ 2021-06-01 17:44       ` John Garry
  0 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2021-06-01 17:44 UTC (permalink / raw)
  To: Robin Murphy, joro, will; +Cc: iommu, linux-kernel, hch

>>
>> pr_info("DMA domain default TLB invalidation policy: %s mode %s\n",
>>                iommu_dma_strict ? "strict" : "lazy",
>>                 (iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ?
>>                         "(set via kernel command line)" : "");
>>
>> I think it's worth mentioning "default" somewhere, as not all IOMMUs 
>> or devices will use lazy mode even if it's default.
> 
> But that's part of what I think is misleading - I boot and see that the 
> default is something, so I reboot with iommu.strict to explicitly set it 
> the other way, but now that's the default... huh?
> 
> The way I see it, we're saying what the current IOMMU API policy is - 
> the value of iommu_dma_strict at any given time is fact - but we're not 
> necessarily saying how widely that policy is enforced. We similarly 
> report the type for default domains from global policy even though that 
> may also be overridden per-group by drivers and/or userspace later; 

> we 
> don't say it's the *default* default domain type.

I think that is this is the behavior a user would understand from that 
message.

However from a glance at the intel IOMMU driver, it seems possible to 
change default domain type after iommu_subsys_init().

> 
> However, having now debugged the AMD issue from another thread, I think 
> doing this at subsys_initcall is in fact going to be too early to be 
> meaningful, since it ignores drivers' ability to change the global 
> policy :(

A user may still learn the IOMMU group domain type from sysfs. There is 
no such thing for TLB invalidation mode - how about add a file for this? 
It would be useful.

Thanks,
John

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

end of thread, other threads:[~2021-06-01 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 13:37 [PATCH] iommu: Print default strict or lazy mode at init time John Garry
2021-06-01  9:09 ` Robin Murphy
2021-06-01 15:50   ` John Garry
2021-06-01 16:42     ` Robin Murphy
2021-06-01 17:44       ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).