Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro
@ 2024-08-29  2:10 Jinjie Ruan
  2024-09-05 13:40 ` Jason Gunthorpe
  2024-10-29  4:39 ` Baolu Lu
  0 siblings, 2 replies; 3+ messages in thread
From: Jinjie Ruan @ 2024-08-29  2:10 UTC (permalink / raw)
  To: dwmw2, baolu.lu, joro, will, robin.murphy, iommu, linux-kernel; +Cc: ruanjinjie

The macro PCI_DEVID() can be used instead of compose it manually.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/iommu/intel/iommu.c         | 4 ++--
 drivers/iommu/intel/irq_remapping.c | 4 ++--
 drivers/iommu/intel/pasid.c         | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 71e934c75034..27652daa143c 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1677,7 +1677,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
 
 		if (did_old < cap_ndoms(iommu->cap)) {
 			iommu->flush.flush_context(iommu, did_old,
-						   (((u16)bus) << 8) | devfn,
+						   PCI_DEVID(bus, devfn),
 						   DMA_CCMD_MASK_NOBIT,
 						   DMA_CCMD_DEVICE_INVL);
 			iommu->flush.flush_iotlb(iommu, did_old, 0, 0,
@@ -1732,7 +1732,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
 	 */
 	if (cap_caching_mode(iommu->cap)) {
 		iommu->flush.flush_context(iommu, 0,
-					   (((u16)bus) << 8) | devfn,
+					   PCI_DEVID(bus, devfn),
 					   DMA_CCMD_MASK_NOBIT,
 					   DMA_CCMD_DEVICE_INVL);
 		iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
index 7a6d188e3bea..466c1412dd45 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -312,7 +312,7 @@ static int set_ioapic_sid(struct irte *irte, int apic)
 
 	for (i = 0; i < MAX_IO_APICS; i++) {
 		if (ir_ioapic[i].iommu && ir_ioapic[i].id == apic) {
-			sid = (ir_ioapic[i].bus << 8) | ir_ioapic[i].devfn;
+			sid = PCI_DEVID(ir_ioapic[i].bus, ir_ioapic[i].devfn);
 			break;
 		}
 	}
@@ -337,7 +337,7 @@ static int set_hpet_sid(struct irte *irte, u8 id)
 
 	for (i = 0; i < MAX_HPET_TBS; i++) {
 		if (ir_hpet[i].iommu && ir_hpet[i].id == id) {
-			sid = (ir_hpet[i].bus << 8) | ir_hpet[i].devfn;
+			sid = PCI_DEVID(ir_hpet[i].bus, ir_hpet[i].devfn);
 			break;
 		}
 	}
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index b51fc268dc84..c206c0eac97c 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -220,7 +220,7 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu,
 	if (pci_dev_is_disconnected(to_pci_dev(dev)))
 		return;
 
-	sid = info->bus << 8 | info->devfn;
+	sid = PCI_DEVID(info->bus, info->devfn);
 	qdep = info->ats_qdep;
 	pfsid = info->pfsid;
 
-- 
2.34.1


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

* Re: [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro
  2024-08-29  2:10 [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro Jinjie Ruan
@ 2024-09-05 13:40 ` Jason Gunthorpe
  2024-10-29  4:39 ` Baolu Lu
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2024-09-05 13:40 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: dwmw2, baolu.lu, joro, will, robin.murphy, iommu, linux-kernel

On Thu, Aug 29, 2024 at 10:10:11AM +0800, Jinjie Ruan wrote:
> The macro PCI_DEVID() can be used instead of compose it manually.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  drivers/iommu/intel/iommu.c         | 4 ++--
>  drivers/iommu/intel/irq_remapping.c | 4 ++--
>  drivers/iommu/intel/pasid.c         | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

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

* Re: [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro
  2024-08-29  2:10 [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro Jinjie Ruan
  2024-09-05 13:40 ` Jason Gunthorpe
@ 2024-10-29  4:39 ` Baolu Lu
  1 sibling, 0 replies; 3+ messages in thread
From: Baolu Lu @ 2024-10-29  4:39 UTC (permalink / raw)
  To: Jinjie Ruan, dwmw2, joro, will, robin.murphy, iommu, linux-kernel
  Cc: baolu.lu

On 2024/8/29 10:10, Jinjie Ruan wrote:
> The macro PCI_DEVID() can be used instead of compose it manually.
> 
> Signed-off-by: Jinjie Ruan<ruanjinjie@huawei.com>
> ---
>   drivers/iommu/intel/iommu.c         | 4 ++--
>   drivers/iommu/intel/irq_remapping.c | 4 ++--
>   drivers/iommu/intel/pasid.c         | 2 +-
>   3 files changed, 5 insertions(+), 5 deletions(-)

Queued for v6.13. Thank you!

--
baolu

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

end of thread, other threads:[~2024-10-29  4:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29  2:10 [PATCH -next] iommu/vt-d: Use PCI_DEVID() macro Jinjie Ruan
2024-09-05 13:40 ` Jason Gunthorpe
2024-10-29  4:39 ` Baolu Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox