mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Jean-Philippe Brucker](/assets/img/avatar_default.png)
Some devices might support multiple DMA address spaces, in particular those that have the PCI PASID feature. PASID (Process Address Space ID) allows to share process address spaces with devices (SVA), partition a device into VM-assignable entities (VFIO mdev) or simply provide multiple DMA address space to kernel drivers. Add a global PASID allocator usable by different drivers at the same time. Name it I/O ASID to avoid confusion with ASIDs allocated by arch code, which are usually a separate ID space. The IOASID space is global. Each device can have its own PASID space, but by convention the IOMMU ended up having a global PASID space, so that with SVA, each mm_struct is associated to a single PASID. The allocator is primarily used by IOMMU subsystem but in rare occasions drivers would like to allocate PASIDs for devices that aren't managed by an IOMMU, using the same ID space as IOMMU. Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_IOASID_H
|
|
#define __LINUX_IOASID_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/errno.h>
|
|
|
|
#define INVALID_IOASID ((ioasid_t)-1)
|
|
typedef unsigned int ioasid_t;
|
|
|
|
struct ioasid_set {
|
|
int dummy;
|
|
};
|
|
|
|
#define DECLARE_IOASID_SET(name) struct ioasid_set name = { 0 }
|
|
|
|
#if IS_ENABLED(CONFIG_IOASID)
|
|
ioasid_t ioasid_alloc(struct ioasid_set *set, ioasid_t min, ioasid_t max,
|
|
void *private);
|
|
void ioasid_free(ioasid_t ioasid);
|
|
void *ioasid_find(struct ioasid_set *set, ioasid_t ioasid,
|
|
bool (*getter)(void *));
|
|
int ioasid_set_data(ioasid_t ioasid, void *data);
|
|
|
|
#else /* !CONFIG_IOASID */
|
|
static inline ioasid_t ioasid_alloc(struct ioasid_set *set, ioasid_t min,
|
|
ioasid_t max, void *private)
|
|
{
|
|
return INVALID_IOASID;
|
|
}
|
|
|
|
static inline void ioasid_free(ioasid_t ioasid)
|
|
{
|
|
}
|
|
|
|
static inline void *ioasid_find(struct ioasid_set *set, ioasid_t ioasid,
|
|
bool (*getter)(void *))
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline int ioasid_set_data(ioasid_t ioasid, void *data)
|
|
{
|
|
return -ENOTSUPP;
|
|
}
|
|
|
|
#endif /* CONFIG_IOASID */
|
|
#endif /* __LINUX_IOASID_H */
|