From: Ethan Zhao <etzhao1900@gmail.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Ethan Zhao <haifeng.zhao@linux.intel.com>,
"Wang, Wei W" <wei.w.wang@intel.com>,
"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"jroedel@suse.de" <jroedel@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v1] iommu/vt-d: Remove the redundant logic in first_level_by_default()
Date: Wed, 4 Jun 2025 15:25:42 +0800 [thread overview]
Message-ID: <5fed2452-ae2a-4fca-8483-85ecf645ec1b@gmail.com> (raw)
In-Reply-To: <BN9PR11MB5276CFBD4CF795CCB3ADCD1B8C66A@BN9PR11MB5276.namprd11.prod.outlook.com>
On 5/29/2025 2:11 PM, Tian, Kevin wrote:
>> From: Ethan Zhao <haifeng.zhao@linux.intel.com>
>> Sent: Thursday, May 29, 2025 1:48 PM
>>
>> 在 2025/5/23 16:10, Wei Wang 写道:
>>> This original implementation included redundant logic to determine
>> whether
>>> first-stage translation should be used by default. Simplify it and
>>> preserve the original behavior:
>>> - Returns false in legacy mode (no scalable mode support).
>>> - Defaults to first-level translation when both FLTS and SLTS are
>>> supported.
>>>
>>> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
>>> ---
>>> drivers/iommu/intel/iommu.c | 10 +---------
>>> 1 file changed, 1 insertion(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
>>> index cb0b993bebb4..228da47ab7cd 100644
>>> --- a/drivers/iommu/intel/iommu.c
>>> +++ b/drivers/iommu/intel/iommu.c
>>> @@ -1366,15 +1366,7 @@ static void free_dmar_iommu(struct
>> intel_iommu *iommu)
>>> */
>>> static bool first_level_by_default(struct intel_iommu *iommu)
>>> {
>>> - /* Only SL is available in legacy mode */
>>> - if (!sm_supported(iommu))
>>> - return false;
>>> -
>>> - /* Only level (either FL or SL) is available, just use it */
>>> - if (ecap_flts(iommu->ecap) ^ ecap_slts(iommu->ecap))
>>> - return ecap_flts(iommu->ecap);
>>> -
>>> - return true;
>>
>> The function works like a digital circurt has 3 single bit inputs sm,
>> flts, slts and one bit output ret.
>>
>> so the true value table of the orignal function looks like
>>
>> sm flts slts ret
>> a 0 x x false
>> b 1 1 0 true
>> c 1 0 1 false
>> d 1 1 1 true
>> e 1 0 0 true
>
> 'e' is actually wrong. We should not return true when the 1st level
> cap doesn't exist.
If so, this patch should mention it fixes such case with fix tag, not
"removing the redundant logic with the same behavior".
Thanks,
Ethan
>
>>
>>> + return sm_supported(iommu) && ecap_flts(iommu->ecap);
>>
>> And the true value table of this new one looks like
>>
>> sm flts slts ret
>>
>> f 1 1 x true
>> g 1 0 x false
>>
>> h 0 1 x false
>> i 0 0 x false
>
> so this table is correct.
next prev parent reply other threads:[~2025-06-04 7:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 8:10 [PATCH v1] iommu/vt-d: Remove the redundant logic in first_level_by_default() Wei Wang
2025-05-23 8:15 ` Tian, Kevin
2025-05-29 5:48 ` Ethan Zhao
2025-05-29 6:11 ` Tian, Kevin
2025-06-04 7:25 ` Ethan Zhao [this message]
2025-06-05 1:04 ` Wang, Wei W
2025-06-05 3:33 ` Ethan Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5fed2452-ae2a-4fca-8483-85ecf645ec1b@gmail.com \
--to=etzhao1900@gmail.com \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=haifeng.zhao@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jroedel@suse.de \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wei.w.wang@intel.com \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox