lkml.org 
[lkml]   [2022]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[tip: irq/core] genirq/msi: Remove filter from msi_free_descs_free_range()
    The following commit has been merged into the irq/core branch of tip:

    Commit-ID: 2f2940d168236a92df524a1bd99fc7b0325918b5
    Gitweb: https://git.kernel.org/tip/2f2940d168236a92df524a1bd99fc7b0325918b5
    Author: Thomas Gleixner <tglx@linutronix.de>
    AuthorDate: Fri, 11 Nov 2022 14:54:22 +01:00
    Committer: Thomas Gleixner <tglx@linutronix.de>
    CommitterDate: Thu, 17 Nov 2022 15:15:18 +01:00

    genirq/msi: Remove filter from msi_free_descs_free_range()

    When a range of descriptors is freed then all of them are not associated to
    a linux interrupt. Remove the filter and add a warning to the free function.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
    Link: https://lore.kernel.org/r/20221111122013.888850936@linutronix.de

    ---
    drivers/base/platform-msi.c | 2 +-
    include/linux/msi.h | 5 ++---
    kernel/irq/msi.c | 19 ++++++++++---------
    3 files changed, 13 insertions(+), 13 deletions(-)

    diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
    index 12b0441..dddafa1 100644
    --- a/drivers/base/platform-msi.c
    +++ b/drivers/base/platform-msi.c
    @@ -325,7 +325,7 @@ void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int vir

    msi_lock_descs(data->dev);
    irq_domain_free_irqs_common(domain, virq, nr_irqs);
    - msi_free_msi_descs_range(data->dev, MSI_DESC_ALL, virq, virq + nr_irqs - 1);
    + msi_free_msi_descs_range(data->dev, virq, virq + nr_irqs - 1);
    msi_unlock_descs(data->dev);
    }

    diff --git a/include/linux/msi.h b/include/linux/msi.h
    index fc918a6..969ce46 100644
    --- a/include/linux/msi.h
    +++ b/include/linux/msi.h
    @@ -247,8 +247,7 @@ static inline void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg)
    #endif /* CONFIG_PCI_MSI */

    int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc);
    -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter,
    - unsigned int first_index, unsigned int last_index);
    +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index);

    /**
    * msi_free_msi_descs - Free MSI descriptors of a device
    @@ -256,7 +255,7 @@ void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter,
    */
    static inline void msi_free_msi_descs(struct device *dev)
    {
    - msi_free_msi_descs_range(dev, MSI_DESC_ALL, 0, MSI_MAX_INDEX);
    + msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX);
    }

    void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
    diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
    index bba6359..1ca4846 100644
    --- a/kernel/irq/msi.c
    +++ b/kernel/irq/msi.c
    @@ -120,7 +120,7 @@ static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsi
    fail_mem:
    ret = -ENOMEM;
    fail:
    - msi_free_msi_descs_range(dev, MSI_DESC_ALL, index, last);
    + msi_free_msi_descs_range(dev, index, last);
    return ret;
    }

    @@ -141,12 +141,11 @@ static bool msi_desc_match(struct msi_desc *desc, enum msi_desc_filter filter)
    /**
    * msi_free_msi_descs_range - Free MSI descriptors of a device
    * @dev: Device to free the descriptors
    - * @filter: Descriptor state filter
    * @first_index: Index to start freeing from
    * @last_index: Last index to be freed
    */
    -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter,
    - unsigned int first_index, unsigned int last_index)
    +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index,
    + unsigned int last_index)
    {
    struct xarray *xa = &dev->msi.data->__store;
    struct msi_desc *desc;
    @@ -155,10 +154,12 @@ void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter,
    lockdep_assert_held(&dev->msi.data->mutex);

    xa_for_each_range(xa, idx, desc, first_index, last_index) {
    - if (msi_desc_match(desc, filter)) {
    - xa_erase(xa, idx);
    - msi_free_desc(desc);
    - }
    + xa_erase(xa, idx);
    +
    + /* Leak the descriptor when it is still referenced */
    + if (WARN_ON_ONCE(msi_desc_match(desc, MSI_DESC_ASSOCIATED)))
    + continue;
    + msi_free_desc(desc);
    }
    }

    @@ -739,7 +740,7 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
    fail:
    for (--virq; virq >= virq_base; virq--)
    irq_domain_free_irqs_common(domain, virq, 1);
    - msi_free_msi_descs_range(dev, MSI_DESC_ALL, virq_base, virq_base + nvec - 1);
    + msi_free_msi_descs_range(dev, virq_base, virq_base + nvec - 1);
    unlock:
    msi_unlock_descs(dev);
    return ret;
    \
     
     \ /
      Last update: 2022-11-17 16:12    [W:4.032 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site