Patch "vfio/pci: Prepare for dynamic interrupt context storage" has been added to the 6.1-stable tree
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 50 lines · On Wed, 27 Mar 2024 07:41:33 -0400 Sasha Levin <[email protected]> wrote:
This is a note to let you know that I've just added the patch titled
vfio/pci: Prepare for dynamic interrupt context storage
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
vfio-pci-prepare-for-dynamic-interrupt-context-stora.patch
and it can be found in the queue-6.1 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
commit
bca808da62c6a87ef168554caa318c2801d19b70Author: Reinette Chatre <[email protected]> Date: Thu May 11 08:44:30 2023 -0700vfio/pci: Prepare for dynamic interrupt context storage
[ Upstream commit
d977e0f7663961368f6442589e52d27484c2f5c2]Interrupt context storage is statically allocated at the time interrupts are allocated. Following allocation, the interrupt context is managed by directly accessing the elements of the array using the vector as index.
It is possible to allocate additional MSI-X vectors after MSI-X has been enabled. Dynamic storage of interrupt context is needed to support adding new MSI-X vectors after initial allocation.
Replace direct access of array elements with pointers to the array elements. Doing so reduces impact of moving to a new data structure. Move interactions with the array to helpers to mostly contain changes needed to transition to a dynamic data structure.
No functional change intended.
Signed-off-by Reinette Chatre <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Thomas Gleixner <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Link https://lore.kernel.org/r/eab289693c8325ede9aba99380f8b8d5143980a4.1683740667.git.reinette.chatre@intel.com open hereSigned-off-by Alex Williamson <[email protected]>Stable-dep-of:
fe9a7082684e("vfio/pci: Disable auto-enable of exclusive INTx IRQ")Signed-off-by Sasha Levin <[email protected]>
...
Quoted 17 lines
(quoted diff) +4
-3@@ -171,15 +225,24 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id) static int vfio_intx_enable(struct vfio_pci_core_device *vdev) { + struct vfio_pci_irq_ctx *ctx; + int ret; + if (!is_irq_none(vdev)) return -EINVAL; if (!vdev->pdev->irq) return -ENODEV; - vdev->ctx = kzalloc(sizeof(struct vfio_pci_irq_ctx), GFP_KERNEL_ACCOUNT); - if (!vdev->ctx) - return -ENOMEM; + ret = vfio_irq_ctx_alloc_num(vdev, 1);
Review static irqreturn_t vfio_intx_handler(int irq, void *dev_id) · line 247
Quoted 10 lines
(quoted diff) +8
-0+ if (ret) + return ret; + + ctx = vfio_irq_ctx_get(vdev, 0); + if (!ctx) { + vfio_irq_ctx_free_all(vdev); + return -EINVAL; + } vdev->num_ctx = 1;
This is broken on it's own, vfio_irq_ctx_get() depends on a valid num_ctx, therefore this function always returns -EINVAL. This was resolved upstream by b156e48fffa9 ("vfio/pci: Use xarray for interrupt context storage") which was from the same series, so this issue was never apparent upstream. Suggest dropping this and fe9a7082684e ("vfio/pci: Disable auto-enable of exclusive INTx IRQ") for now and we'll try to rework the latter to remove the dependency. Thanks,
Alex
Greg KH
maintainerQuoted 79 lines · Alex Williamson
Quoted 50 lines · On Wed, 27 Mar 2024 07:41:33 -0400 Sasha Levin <[email protected]> wrote:
This is a note to let you know that I've just added the patch titled
vfio/pci: Prepare for dynamic interrupt context storage
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
vfio-pci-prepare-for-dynamic-interrupt-context-stora.patch
and it can be found in the queue-6.1 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
commit
bca808da62c6a87ef168554caa318c2801d19b70Author: Reinette Chatre <[email protected]> Date: Thu May 11 08:44:30 2023 -0700vfio/pci: Prepare for dynamic interrupt context storage
[ Upstream commit
d977e0f7663961368f6442589e52d27484c2f5c2]Interrupt context storage is statically allocated at the time interrupts are allocated. Following allocation, the interrupt context is managed by directly accessing the elements of the array using the vector as index.
It is possible to allocate additional MSI-X vectors after MSI-X has been enabled. Dynamic storage of interrupt context is needed to support adding new MSI-X vectors after initial allocation.
Replace direct access of array elements with pointers to the array elements. Doing so reduces impact of moving to a new data structure. Move interactions with the array to helpers to mostly contain changes needed to transition to a dynamic data structure.
No functional change intended.
Signed-off-by Reinette Chatre <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Thomas Gleixner <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Link https://lore.kernel.org/r/eab289693c8325ede9aba99380f8b8d5143980a4.1683740667.git.reinette.chatre@intel.com open hereSigned-off-by Alex Williamson <[email protected]>Stable-dep-of:
fe9a7082684e("vfio/pci: Disable auto-enable of exclusive INTx IRQ")Signed-off-by Sasha Levin <[email protected]>...
Quoted 26 lines
(quoted diff) +12
-3@@ -171,15 +225,24 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id) static int vfio_intx_enable(struct vfio_pci_core_device *vdev) { + struct vfio_pci_irq_ctx *ctx; + int ret; + if (!is_irq_none(vdev)) return -EINVAL; if (!vdev->pdev->irq) return -ENODEV; - vdev->ctx = kzalloc(sizeof(struct vfio_pci_irq_ctx), GFP_KERNEL_ACCOUNT); - if (!vdev->ctx) - return -ENOMEM; + ret = vfio_irq_ctx_alloc_num(vdev, 1); + if (ret) + return ret; + + ctx = vfio_irq_ctx_get(vdev, 0); + if (!ctx) { + vfio_irq_ctx_free_all(vdev); + return -EINVAL; + }
Quoted 9 lines
Review static irqreturn_t vfio_intx_handler(int irq, void *dev_id) · line 247
Quoted 1 line
(quoted diff) +0
-0vdev->num_ctx = 1;This is broken on it's own,
vfio_irq_ctx_get()depends on a validnum_ctx, therefore this function always returns-EINVAL. This was resolved upstream byb156e48fffa9("vfio/pci: Use xarray for interrupt context storage") which was from the same series, so this issue was never apparent upstream. Suggest dropping this andfe9a7082684e("vfio/pci: Disable auto-enable of exclusive INTx IRQ") for now and we'll try to rework the latter to remove the dependency. Thanks,
Ok, I'll go drop both of these and take the series you just sent, thanks.
greg k-h