Skip to content

Commit

Permalink
iommu/ioasid: Rename INVALID_IOASID
Browse files Browse the repository at this point in the history
INVALID_IOASID and IOMMU_PASID_INVALID are duplicated. Rename
INVALID_IOASID and consolidate since we are moving away from IOASID
infrastructure.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Link: https://lore.kernel.org/r/20230322200803.869130-7-jacob.jun.pan@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Jacob Pan authored and Joerg Roedel committed Mar 31, 2023
1 parent 1a14bf0 commit fffaed1
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Documentation/x86/sva.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ process share the same page tables, thus the same MSR value.
PASID Life Cycle Management
===========================

PASID is initialized as INVALID_IOASID (-1) when a process is created.
PASID is initialized as IOMMU_PASID_INVALID (-1) when a process is created.

Only processes that access SVA-capable devices need to have a PASID
allocated. This allocation happens when a process opens/binds an SVA-capable
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <linux/io.h>
#include <linux/hardirq.h>
#include <linux/atomic.h>
#include <linux/ioasid.h>
#include <linux/iommu.h>

#include <asm/stacktrace.h>
#include <asm/processor.h>
Expand Down
8 changes: 4 additions & 4 deletions drivers/dma/idxd/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ static void idxd_device_set_perm_entry(struct idxd_device *idxd,
{
union msix_perm mperm;

if (ie->pasid == INVALID_IOASID)
if (ie->pasid == IOMMU_PASID_INVALID)
return;

mperm.bits = 0;
Expand Down Expand Up @@ -1224,7 +1224,7 @@ void idxd_wq_free_irq(struct idxd_wq *wq)
idxd_device_clear_perm_entry(idxd, ie);
ie->vector = -1;
ie->int_handle = INVALID_INT_HANDLE;
ie->pasid = INVALID_IOASID;
ie->pasid = IOMMU_PASID_INVALID;
}

int idxd_wq_request_irq(struct idxd_wq *wq)
Expand All @@ -1240,7 +1240,7 @@ int idxd_wq_request_irq(struct idxd_wq *wq)

ie = &wq->ie;
ie->vector = pci_irq_vector(pdev, ie->id);
ie->pasid = device_pasid_enabled(idxd) ? idxd->pasid : INVALID_IOASID;
ie->pasid = device_pasid_enabled(idxd) ? idxd->pasid : IOMMU_PASID_INVALID;
idxd_device_set_perm_entry(idxd, ie);

rc = request_threaded_irq(ie->vector, NULL, idxd_wq_thread, 0, "idxd-portal", ie);
Expand All @@ -1265,7 +1265,7 @@ int idxd_wq_request_irq(struct idxd_wq *wq)
free_irq(ie->vector, ie);
err_irq:
idxd_device_clear_perm_entry(idxd, ie);
ie->pasid = INVALID_IOASID;
ie->pasid = IOMMU_PASID_INVALID;
return rc;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/dma/idxd/idxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/ioasid.h>
#include <linux/bitmap.h>
#include <linux/perf_event.h>
#include <linux/iommu.h>
#include <uapi/linux/idxd.h>
#include "registers.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/idxd/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int idxd_setup_interrupts(struct idxd_device *idxd)
ie = idxd_get_ie(idxd, msix_idx);
ie->id = msix_idx;
ie->int_handle = INVALID_INT_HANDLE;
ie->pasid = INVALID_IOASID;
ie->pasid = IOMMU_PASID_INVALID;

spin_lock_init(&ie->list_lock);
init_llist_head(&ie->pending_llist);
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/idxd/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void idxd_int_handle_revoke_drain(struct idxd_irq_entry *ie)
desc.opcode = DSA_OPCODE_DRAIN;
desc.priv = 1;

if (ie->pasid != INVALID_IOASID)
if (ie->pasid != IOMMU_PASID_INVALID)
desc.pasid = ie->pasid;
desc.int_handle = ie->int_handle;
portal = idxd_wq_portal_addr(wq);
Expand Down
4 changes: 2 additions & 2 deletions drivers/iommu/intel/dmar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
return 0;
}

if (pasid == INVALID_IOASID)
if (pasid == IOMMU_PASID_INVALID)
pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
type ? "DMA Read" : "DMA Write",
source_id >> 8, PCI_SLOT(source_id & 0xFF),
Expand Down Expand Up @@ -2039,7 +2039,7 @@ irqreturn_t dmar_fault(int irq, void *dev_id)
if (!ratelimited)
/* Using pasid -1 if pasid is not present */
dmar_fault_do_one(iommu, type, fault_reason,
pasid_present ? pasid : INVALID_IOASID,
pasid_present ? pasid : IOMMU_PASID_INVALID,
source_id, guest_addr);

fault_index++;
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/intel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ void dmar_fault_dump_ptes(struct intel_iommu *iommu, u16 source_id,
return;
}
/* For request-without-pasid, get the pasid from context entry */
if (intel_iommu_sm && pasid == INVALID_IOASID)
if (intel_iommu_sm && pasid == IOMMU_PASID_INVALID)
pasid = PASID_RID2PASID;

dir_index = pasid >> PASID_PDE_SHIFT;
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/intel/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int pasid_to_svm_sdev(struct device *dev, unsigned int pasid,
if (WARN_ON(!mutex_is_locked(&pasid_mutex)))
return -EINVAL;

if (pasid == INVALID_IOASID || pasid >= PASID_MAX)
if (pasid == IOMMU_PASID_INVALID || pasid >= PASID_MAX)
return -EINVAL;

svm = pasid_private_find(pasid);
Expand Down
1 change: 1 addition & 0 deletions include/linux/ioasid.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/iommu.h>

typedef unsigned int ioasid_t;
#define INVALID_IOASID ((ioasid_t)-1)
typedef ioasid_t (*ioasid_alloc_fn_t)(ioasid_t min, ioasid_t max, void *data);
typedef void (*ioasid_free_fn_t)(ioasid_t ioasid, void *data);

Expand Down
6 changes: 3 additions & 3 deletions include/linux/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ enum iommu_dev_features {

#define IOMMU_PASID_INVALID (-1U)
typedef unsigned int ioasid_t;
#define INVALID_IOASID ((ioasid_t)-1)

#ifdef CONFIG_IOMMU_API

Expand Down Expand Up @@ -1175,12 +1174,13 @@ static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream

static inline bool pasid_valid(ioasid_t ioasid)
{
return ioasid != INVALID_IOASID;
return ioasid != IOMMU_PASID_INVALID;
}

#ifdef CONFIG_IOMMU_SVA
static inline void mm_pasid_init(struct mm_struct *mm)
{
mm->pasid = INVALID_IOASID;
mm->pasid = IOMMU_PASID_INVALID;
}
void mm_pasid_drop(struct mm_struct *mm);
struct iommu_sva *iommu_sva_bind_device(struct device *dev,
Expand Down
4 changes: 2 additions & 2 deletions mm/init-mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <linux/atomic.h>
#include <linux/user_namespace.h>
#include <linux/ioasid.h>
#include <linux/iommu.h>
#include <asm/mmu.h>

#ifndef INIT_MM_CONTEXT
Expand Down Expand Up @@ -40,7 +40,7 @@ struct mm_struct init_mm = {
.user_ns = &init_user_ns,
.cpu_bitmap = CPU_BITS_NONE,
#ifdef CONFIG_IOMMU_SVA
.pasid = INVALID_IOASID,
.pasid = IOMMU_PASID_INVALID,
#endif
INIT_MM_CONTEXT(init_mm)
};
Expand Down

0 comments on commit fffaed1

Please sign in to comment.