mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: Magnus Kalland <magnus@dolphinics.com>
Cc: DheerajKumar.Srivastava@amd.com, dhsrivas@amd.com,
	iommu@lists.linux.dev, jonas@dolphinics.com, joro@8bytes.org,
	larsk@dolphinics.com, linux-kernel@vger.kernel.org,
	suravee.suthikulpanit@amd.com, torel@simula.no
Subject: Re: [PATCH v3 3/3] iommu/amd: Invalidate IRT cache for DMA aliases
Date: Wed, 1 Apr 2026 16:16:08 +0530	[thread overview]
Message-ID: <ea4cfd4d-9ad2-4451-a896-9f0435e72a06@amd.com> (raw)
In-Reply-To: <20260401103559.63865-1-magnus@dolphinics.com>

Hi Magnus,


On 4/1/2026 4:04 PM, Magnus Kalland wrote:
> Hi Vasant,
> 
>> I went back to those reports and reviewed it again. It looks like
>> pci_get_domain_bus_and_slot() takes spinlock which is causing the lockdep issue.
> 
>> I think V2 is good w/ some changes to get the pdev.
>> Instead of pci_get_domain_bus_and_slot(), we should use dev_data (like we do in
>> other places).
> 

.../...

> 
> 
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index 050178cf388f..eb23b9e7bf03 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -3118,12 +3118,10 @@ static void iommu_flush_irt_and_complete(struct
>> amd_iommu *iommu, u16 devid)
>> {
>> 	int ret;
>> 	u64 data;
>> -	int domain = iommu->pci_seg->id;
>> -	unsigned int bus = PCI_BUS_NUM(devid);
>> -	unsigned int devfn = devid & 0xff;
>> 	unsigned long flags;
>> 	struct iommu_cmd cmd;
>> 	struct pci_dev *pdev = NULL;
>> +	struct iommu_dev_data *dev_data = search_dev_data(iommu, devid);
>>
>> 	if (iommu->irtcachedis_enabled)
>> 		return;
>> @@ -3131,11 +3129,12 @@ static void iommu_flush_irt_and_complete(struct
>> amd_iommu *iommu, u16 devid)
>> 	data = atomic64_inc_return(&iommu->cmd_sem_val);
>> 	build_completion_wait(&cmd, iommu, data);
>>
>> -	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
>> +	if (dev_data && dev_data->dev && dev_is_pci(dev_data->dev))
>> +		pdev = to_pci_dev(dev_data->dev);
>> +
>> 	raw_spin_lock_irqsave(&iommu->lock, flags);
>> 	if (pdev) {
>> 		ret = pci_for_each_dma_alias(pdev, iommu_flush_dev_irt, iommu);
>> -		pci_dev_put(pdev);
>> 	} else {
>> 		ret = iommu_flush_dev_irt(NULL, devid, iommu);
>> 	}
> 
> Thanks for the fix. I've tested it and it looks good on our end.

Nice! Please send v4.

Also I have sent one more fix. Can you please test that patch in your setup?

https://lore.kernel.org/linux-iommu/20260401080017.117549-1-vasant.hegde@amd.com/T/#u

-Vasant


  reply	other threads:[~2026-04-01 10:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 20:23 [PATCH v3 0/3] " Magnus Kalland
2026-02-25 20:23 ` [PATCH v3 1/3] iommu/amd: Use raw spinlock for interrupt remapping tables Magnus Kalland
2026-03-30 15:23   ` Vasant Hegde
2026-03-31 13:10     ` Magnus Kalland
2026-02-25 20:23 ` [PATCH v3 2/3] iommu/amd: Track PCIe DMA aliases in set_remap_table_entry_alias Magnus Kalland
2026-02-25 20:23 ` [PATCH v3 3/3] iommu/amd: Invalidate IRT cache for DMA aliases Magnus Kalland
2026-03-30 11:18   ` Vasant Hegde
2026-03-31 12:48     ` Magnus Kalland
2026-04-01  7:44       ` Vasant Hegde
2026-04-01 10:34         ` Magnus Kalland
2026-04-01 10:46           ` Vasant Hegde [this message]
2026-04-01 11:38             ` Magnus Kalland
2026-03-06  9:22 [PATCH v3 0/3] " Magnus Kalland
2026-03-06  9:22 ` [PATCH v3 3/3] " Magnus Kalland

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=ea4cfd4d-9ad2-4451-a896-9f0435e72a06@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=DheerajKumar.Srivastava@amd.com \
    --cc=dhsrivas@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jonas@dolphinics.com \
    --cc=joro@8bytes.org \
    --cc=larsk@dolphinics.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus@dolphinics.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=torel@simula.no \
    /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

all inboxes | Powered by JetHome®