dm: Use new ptdev interrupt management ioctls

IC_SET_PTDEV_INTR_INFO	 ->	ACRN_IOCTL_SET_PTDEV_INTR
IC_RESET_PTDEV_INTR_INFO ->	ACRN_IOCTL_RESET_PTDEV_INTR
struct ic_ptdev_irq	 ->	struct acrn_ptdev_irq
IRQ_INTX		 ->	ACRN_PTDEV_IRQ_INTX
IRQ_MSI			 ->	ACRN_PTDEV_IRQ_MSI

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
Shuo A Liu 2021-07-07 16:23:23 +08:00 committed by wenlingz
parent 7e01d90b87
commit 9d67745037
3 changed files with 22 additions and 20 deletions

View File

@ -611,33 +611,33 @@ int
vm_set_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf, uint16_t phys_bdf, vm_set_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf, uint16_t phys_bdf,
int virt_pin, int phys_pin, bool pic_pin) int virt_pin, int phys_pin, bool pic_pin)
{ {
struct ic_ptdev_irq ptirq; struct acrn_ptdev_irq ptirq;
bzero(&ptirq, sizeof(ptirq)); bzero(&ptirq, sizeof(ptirq));
ptirq.type = IRQ_INTX; ptirq.type = ACRN_PTDEV_IRQ_INTX;
ptirq.virt_bdf = virt_bdf; ptirq.virt_bdf = virt_bdf;
ptirq.phys_bdf = phys_bdf; ptirq.phys_bdf = phys_bdf;
ptirq.intx.virt_pin = virt_pin; ptirq.intx.virt_pin = virt_pin;
ptirq.intx.phys_pin = phys_pin; ptirq.intx.phys_pin = phys_pin;
ptirq.intx.is_pic_pin = pic_pin; ptirq.intx.is_pic_pin = pic_pin;
return ioctl(ctx->fd, IC_SET_PTDEV_INTR_INFO, &ptirq); return ioctl(ctx->fd, ACRN_IOCTL_SET_PTDEV_INTR, &ptirq);
} }
int int
vm_reset_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf, uint16_t phys_bdf, vm_reset_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf, uint16_t phys_bdf,
int virt_pin, bool pic_pin) int virt_pin, bool pic_pin)
{ {
struct ic_ptdev_irq ptirq; struct acrn_ptdev_irq ptirq;
bzero(&ptirq, sizeof(ptirq)); bzero(&ptirq, sizeof(ptirq));
ptirq.type = IRQ_INTX; ptirq.type = ACRN_PTDEV_IRQ_INTX;
ptirq.intx.virt_pin = virt_pin; ptirq.intx.virt_pin = virt_pin;
ptirq.intx.is_pic_pin = pic_pin; ptirq.intx.is_pic_pin = pic_pin;
ptirq.virt_bdf = virt_bdf; ptirq.virt_bdf = virt_bdf;
ptirq.phys_bdf = phys_bdf; ptirq.phys_bdf = phys_bdf;
return ioctl(ctx->fd, IC_RESET_PTDEV_INTR_INFO, &ptirq); return ioctl(ctx->fd, ACRN_IOCTL_RESET_PTDEV_INTR, &ptirq);
} }
int int

View File

@ -286,14 +286,14 @@ cfginitbar(struct vmctx *ctx, struct passthru_dev *ptdev)
* return value: * return value:
* -1 : fail * -1 : fail
* >=0: succeed * >=0: succeed
* IRQ_INTX(0): phy dev has no MSI support * ACRN_PTDEV_IRQ_INTX(0): phy dev has no MSI support
* IRQ_MSI(1): phy dev has MSI support * ACRN_PTDEV_IRQ_MSI(1): phy dev has MSI support
*/ */
static int static int
cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus, cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
int slot, int func) int slot, int func)
{ {
int irq_type = IRQ_MSI; int irq_type = ACRN_PTDEV_IRQ_MSI;
char reset_path[60]; char reset_path[60];
int fd; int fd;
@ -312,7 +312,7 @@ cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus,
if (ptdev->msi.capoff == 0 && ptdev->msix.capoff == 0) { if (ptdev->msi.capoff == 0 && ptdev->msix.capoff == 0) {
pr_dbg("MSI not supported for PCI %x/%x/%x", pr_dbg("MSI not supported for PCI %x/%x/%x",
bus, slot, func); bus, slot, func);
irq_type = IRQ_INTX; irq_type = ACRN_PTDEV_IRQ_INTX;
} }
/* If SOS kernel provides 'reset' entry in sysfs, related dev has some /* If SOS kernel provides 'reset' entry in sysfs, related dev has some
@ -671,7 +671,7 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
error = pci_emul_alloc_pbar(dev, vmsix_on_msi_bar_id, 0, PCIBAR_MEM32, 4096); error = pci_emul_alloc_pbar(dev, vmsix_on_msi_bar_id, 0, PCIBAR_MEM32, 4096);
if (error < 0) if (error < 0)
goto done; goto done;
error = IRQ_MSI; error = ACRN_PTDEV_IRQ_MSI;
} }
if (ptdev->phys_bdf == PCI_BDF_GPU) if (ptdev->phys_bdf == PCI_BDF_GPU)
@ -687,7 +687,7 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
* Forge Guest to use MSI/MSIX in this case to mitigate IRQ sharing * Forge Guest to use MSI/MSIX in this case to mitigate IRQ sharing
* issue * issue
*/ */
if (error != IRQ_MSI || keep_gsi) { if (error != ACRN_PTDEV_IRQ_MSI || keep_gsi) {
/* Allocates the virq if ptdev only support INTx */ /* Allocates the virq if ptdev only support INTx */
pci_lintr_request(dev); pci_lintr_request(dev);

View File

@ -113,10 +113,10 @@
/* PCI assignment*/ /* PCI assignment*/
#define IC_ID_PCI_BASE 0x50UL #define IC_ID_PCI_BASE 0x50UL
#define IC_ASSIGN_PTDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x00) #define ACRN_IOCTL_SET_PTDEV_INTR \
#define IC_DEASSIGN_PTDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x01) _IOW(ACRN_IOCTL_TYPE, 0x53, struct acrn_ptdev_irq)
#define IC_VM_PCI_MSIX_REMAP _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x02) #define ACRN_IOCTL_RESET_PTDEV_INTR \
#define IC_SET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x03) _IOW(ACRN_IOCTL_TYPE, 0x54, struct acrn_ptdev_irq)
#define IC_RESET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x04) #define IC_RESET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x04)
#define IC_ASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x05) #define IC_ASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x05)
#define IC_DEASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x06) #define IC_DEASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x06)
@ -273,13 +273,15 @@ struct acrn_emul_dev {
} __attribute__((aligned(8))); } __attribute__((aligned(8)));
/* Type of interrupt of a passthrough device */
#define ACRN_PTDEV_IRQ_INTX 0
#define ACRN_PTDEV_IRQ_MSI 1
#define ACRN_PTDEV_IRQ_MSIX 2
/** /**
* @brief pass thru device irq data structure * @brief pass thru device irq data structure
*/ */
struct ic_ptdev_irq { struct acrn_ptdev_irq {
#define IRQ_INTX 0
#define IRQ_MSI 1
#define IRQ_MSIX 2
/** irq type */ /** irq type */
uint32_t type; uint32_t type;
/** virtual bdf description of pass thru device */ /** virtual bdf description of pass thru device */