Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933010AbaKMNAE (ORCPT ); Thu, 13 Nov 2014 08:00:04 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:57272 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932650AbaKMNAC (ORCPT ); Thu, 13 Nov 2014 08:00:02 -0500 Message-ID: <5464AAD3.2020908@huawei.com> Date: Thu, 13 Nov 2014 20:57:55 +0800 From: Yijing Wang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Jiang Liu , Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Grant Likely , Marc Zyngier , Yingjoe Chen , "Borislav Petkov" , "H. Peter Anvin" , Matthias Brugger , Alexander Gordeev CC: Tony Luck , , , Subject: Re: [Patch V1 3/6] genirq: Introduce msi_irq_domain_{alloc|free}_irqs() References: <1415879029-20098-1-git-send-email-jiang.liu@linux.intel.com> <1415879029-20098-5-git-send-email-jiang.liu@linux.intel.com> <5464A569.5060300@huawei.com> <5464A6F6.3070506@linux.intel.com> In-Reply-To: <5464A6F6.3070506@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.27.212] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2014/11/13 20:41, Jiang Liu wrote: > On 2014/11/13 20:34, Yijing Wang wrote: >> Gerry, this patch seems to be the same as last one. > Do you means patch 6/6? They are different:) Oh, it's not the patch problem, I received two double patch. > >> >> >> On 2014/11/13 19:43, Jiang Liu wrote: >>> Introduce msi_irq_domain_{alloc|free}_irqs() to alloc/free interrupts >>> from irqdomain for generic MSI interrupts. >>> >>> Signed-off-by: Jiang Liu >>> --- >>> include/linux/msi.h | 35 ++++++++++++++++++++++++++++++ >>> kernel/irq/msi.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ >>> 2 files changed, 94 insertions(+) >>> >>> diff --git a/include/linux/msi.h b/include/linux/msi.h >>> index 714716a3ffdd..6b356a1410b2 100644 >>> --- a/include/linux/msi.h >>> +++ b/include/linux/msi.h >>> @@ -3,6 +3,7 @@ >>> >>> #include >>> #include >>> +#include /* for msi_alloc_info_t */ >>> >>> struct msi_msg { >>> u32 address_lo; /* low 32 bits of msi message address */ >>> @@ -100,7 +101,26 @@ struct irq_chip; >>> struct device_node; >>> struct msi_domain_info; >>> >>> +#ifndef NUM_MSI_ALLOC_SCRATCHPAD_REGS >>> +#define NUM_MSI_ALLOC_SCRATCHPAD_REGS 2 >>> +#endif >>> + >>> +/* >>> + * Default structure for MSI interrupt allocation. >>> + * Arch may overwrite it by define msi_alloc_info_t. >>> + */ >>> +struct msi_alloc_info { >>> + struct msi_desc *desc; >>> + irq_hw_number_t hwirq; >>> + long scratchpad[NUM_MSI_ALLOC_SCRATCHPAD_REGS]; >>> +}; >>> + >>> +#ifndef msi_alloc_info_t >>> +typedef struct msi_alloc_info msi_alloc_info_t; >>> +#endif >>> + >>> struct msi_domain_ops { >>> + /* Callbacks for msi_create_irq_domain() */ >>> void (*calc_hwirq)(struct msi_domain_info *info, void *arg, >>> struct msi_desc *desc); >>> irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info, void *arg); >>> @@ -111,6 +131,19 @@ struct msi_domain_ops { >>> void (*msi_free)(struct irq_domain *domain, >>> struct msi_domain_info *info, >>> unsigned int virq); >>> + >>> + /* Callbacks for msi_irq_domain_alloc_irqs() based on msi_descs */ >>> + int (*msi_check)(struct irq_domain *domain, >>> + struct msi_domain_info *info, >>> + struct device *dev); >>> + int (*msi_prepare)(struct irq_domain *domain, >>> + struct device *dev, >>> + msi_alloc_info_t *arg); >>> + void (*msi_finish)(msi_alloc_info_t *arg, int retval); >>> + void (*set_desc)(msi_alloc_info_t *arg, >>> + struct msi_desc *desc); >>> + int (*handle_error)(struct irq_domain *domain, >>> + struct msi_desc *desc, int error); >>> }; >>> >>> struct msi_domain_info { >>> @@ -125,6 +158,8 @@ int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, >>> struct irq_domain *msi_create_irq_domain(struct device_node *of_node, >>> struct msi_domain_info *info, >>> struct irq_domain *parent); >>> +int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev); >>> +void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); >>> struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); >>> >>> #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ >>> diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c >>> index 94d6d87ee23e..0b6665de3a60 100644 >>> --- a/kernel/irq/msi.c >>> +++ b/kernel/irq/msi.c >>> @@ -13,6 +13,9 @@ >>> #include >>> #include >>> >>> +/* Temparory solution for building, will be removed later */ >>> +#include >>> + >>> void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg) >>> { >>> *msg = entry->msg; >>> @@ -124,6 +127,62 @@ struct irq_domain *msi_create_irq_domain(struct device_node *of_node, >>> return domain; >>> } >>> >>> +int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev) >>> +{ >>> + int i, ret, virq = -1; >>> + msi_alloc_info_t arg; >>> + struct msi_desc *desc; >>> + struct msi_domain_info *info = domain->host_data; >>> + struct msi_domain_ops *ops = info->ops; >>> + >>> + ret = ops->msi_check(domain, info, dev); >>> + if (ret == 0) >>> + ret = ops->msi_prepare(domain, dev, &arg); >>> + if (ret) >>> + return ret; >>> + >>> + for_each_msi_entry(desc, dev) { >>> + ops->set_desc(&arg, desc); >>> + >>> + virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, >>> + dev_to_node(dev), &arg, false); >>> + if (virq < 0) { >>> + ret = -ENOSPC; >>> + if (ops->handle_error) >>> + ret = ops->handle_error(domain, desc, ret); >>> + if (ops->msi_finish) >>> + ops->msi_finish(&arg, ret); >>> + return ret; >>> + } >>> + >>> + for (i = 0; i < desc->nvec_used; i++) >>> + irq_set_msi_desc_off(virq, i, desc); >>> + } >>> + >>> + if (ops->msi_finish) >>> + ops->msi_finish(&arg, 0); >>> + >>> + for_each_msi_entry(desc, dev) { >>> + if (desc->nvec_used == 1) >>> + dev_dbg(dev, "irq %d for MSI\n", virq); >>> + else >>> + dev_dbg(dev, "irq [%d-%d] for MSI\n", >>> + virq, virq + desc->nvec_used - 1); >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) >>> +{ >>> + struct msi_desc *desc; >>> + >>> + for_each_msi_entry(desc, dev) { >>> + irq_domain_free_irqs(desc->irq, desc->nvec_used); >>> + desc->irq = 0; >>> + } >>> +} >>> + >>> struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain) >>> { >>> return (struct msi_domain_info *)domain->host_data; >>> >> >> > > . > -- Thanks! Yijing -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/