Linux IOMMU Development
 help / color / mirror / Atom feed
From: Ethan Zhao <etzhao1900@gmail.com>
To: Baolu Lu <baolu.lu@linux.intel.com>,
	Wei Wang <wei.w.wang@intel.com>,
	kevin.tian@intel.com, yi.l.liu@intel.com, dwmw2@infradead.org,
	jroedel@suse.de, linux-kernel@vger.kernel.org,
	iommu@lists.linux.dev
Subject: Re: [PATCH v1] iommu/vt-d: Remove dead code in intel_iommu_domain_alloc_paging_flags()
Date: Thu, 5 Jun 2025 11:55:20 +0800	[thread overview]
Message-ID: <d32ac499-fadb-401c-bb8c-9c3616da302a@gmail.com> (raw)
In-Reply-To: <f1f55968-28e0-4c5d-876b-1c5499b3c01a@linux.intel.com>



On 6/3/2025 10:39 AM, Baolu Lu wrote:
> On 5/30/25 17:13, Wei Wang wrote:
>> When dirty_tracking is enabled, first_stage is set to false to use the
>> second stage translation table. dmar_domain->use_first_level, which is
>> assigned from first_page, is guaranteed to be false when the execution
>> reaches the location of the code to be removed by this patch. So the
>> handling for dmar_domain->use_first_level being true there will never
>> be executed.
>>
>> Signed-off-by: Wei Wang<wei.w.wang@intel.com>
>> ---
>>   drivers/iommu/intel/iommu.c | 7 +------
>>   1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
>> index cb0b993bebb4..1145567c60f9 100644
>> --- a/drivers/iommu/intel/iommu.c
>> +++ b/drivers/iommu/intel/iommu.c
>> @@ -3418,13 +3418,8 @@ intel_iommu_domain_alloc_paging_flags(struct 
>> device *dev, u32 flags,
>>           spin_lock_init(&dmar_domain->s1_lock);
>>       }
>> -    if (dirty_tracking) {
>> -        if (dmar_domain->use_first_level) {
> 
> This *explicit* check enforces that dirty tracking cannot be supported
> for a domain that relies on first-stage translation due to the lack of
> enabling/disabling dirty tracking support.
> 
> While this might appear redundant, this prevents potential issues
> if related code is modified without awareness of this dependency. 
There would always something sooner or later like this to stop the 
improper configuration/coding , under an assumption that caller path 
always coded perfect, indeed, we could remove a lot of error stopper code.

But that world seems never works like that.

Thanks,
Ethan
> 
>> -            iommu_domain_free(domain);
>> -            return ERR_PTR(-EOPNOTSUPP);
>> -        }
> 
> Thanks,
> baolu
> 


  parent reply	other threads:[~2025-06-05  3:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30  9:13 [PATCH v1] iommu/vt-d: Remove dead code in intel_iommu_domain_alloc_paging_flags() Wei Wang
2025-06-03  2:39 ` Baolu Lu
2025-06-03  3:31   ` Wang, Wei W
2025-06-05  3:55   ` Ethan Zhao [this message]
2025-06-03 15:06 ` Jason Gunthorpe

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=d32ac499-fadb-401c-bb8c-9c3616da302a@gmail.com \
    --to=etzhao1900@gmail.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --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