Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp838515ybh; Tue, 21 Jul 2020 09:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoaXeol1v2mLnOh07RpHZh8oA3VjAE2CJ7juH16MJUM88eZDtZ2XRLJlrg+AdIKEFXG4p6 X-Received: by 2002:aa7:d58c:: with SMTP id r12mr27724278edq.160.1595347554607; Tue, 21 Jul 2020 09:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595347554; cv=none; d=google.com; s=arc-20160816; b=bHU5Whbtzy9dAHSHsI0NIXq3ON9omMipF6bysqs7EsSnknyAtypwlbTkzAn+9L/AvM JlI/YRtb0iEkT6Xr04BVu27+QoD5eLLG10+TiUqiM9MNstO18hBoTdnCGlr1rGDf5AOs EX5iaQ149D57PV/ZeF/FJmQfmqg4HZqIOkD+Zh9PvfMYPs6sclkKTEeFKyeC5RvEh1KK Fp8lx+zUE3rPxsDJsw/5gs43TwIN1j148L9z/2qPHecgyUD+5/MBF9xPXQUkQkEVRFuW E4fxIQMQiDjHrRV+gSfiop2Nqb0Phy5X5LCd2WUCTxR7/keUsq8/W1BqAqlGXU3oriIs AQaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=GrUAmHp7Odwqn3EkF2NMTDJ+OQWVj3mbzUF6+YIXPSI=; b=hI9aiU9NuPU8YWi75ttSpysldamSri7x7wv1vyPqZJfY+yWd9c93/jAxewAvl0CWHP b8bFSp+xEjtWE0+TWgYSiL21Keh9z7zUPnUNXm+vzlqYke9CstvLg9jSDZuIXzh8dvaZ tVtOAfhHpCB2jg8wmI21WAsAdS6SctifrFSxBATbeCQ1XvtxyM3Qp2GuJZK3wIKSzYsa EviKMzXCEdD96TK/yRVWYaEvJeIh23Y8UYxHT14c69yTgwfRDoWDHbktJF1t91UtZtmv EN9Ryvb4hv+9e6BZzaZdOz/5S/0ONKD/9smQSF2ss1EB0/mHNh0VegrEqUlb5mP1RW34 ijjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si12457703ejk.740.2020.07.21.09.05.31; Tue, 21 Jul 2020 09:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730123AbgGUQCo (ORCPT + 99 others); Tue, 21 Jul 2020 12:02:44 -0400 Received: from mga03.intel.com ([134.134.136.65]:30545 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728342AbgGUQCo (ORCPT ); Tue, 21 Jul 2020 12:02:44 -0400 IronPort-SDR: YydCq5NOClKvzf8lJdKr0JulIEHL2oQ+gFO2v+2vO4zgxngM7MOINyn3D6gaWUUuNkiJOo++Qd 32Tx/ZurOVUg== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="150143040" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="150143040" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 09:02:43 -0700 IronPort-SDR: +j90kn5v9Tgl0Cb2KqBMPe25kTMzUBivffLJ8Vm8x7FzmO/N993eiKojud0fo0UNMorDHUVrez ZYQ2dl7ticKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="326413312" Received: from djiang5-desk3.ch.intel.com ([143.182.136.137]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jul 2020 09:02:41 -0700 Subject: [PATCH RFC v2 04/18] irq/dev-msi: Introduce APIs to allocate/free dev-msi interrupts From: Dave Jiang To: vkoul@kernel.org, megha.dey@intel.com, maz@kernel.org, bhelgaas@google.com, rafael@kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de, hpa@zytor.com, alex.williamson@redhat.com, jacob.jun.pan@intel.com, ashok.raj@intel.com, jgg@mellanox.com, yi.l.liu@intel.com, baolu.lu@intel.com, kevin.tian@intel.com, sanjay.k.kumar@intel.com, tony.luck@intel.com, jing.lin@intel.com, dan.j.williams@intel.com, kwankhede@nvidia.com, eric.auger@redhat.com, parav@mellanox.com, jgg@mellanox.com, rafael@kernel.org, dave.hansen@intel.com, netanelg@mellanox.com, shahafs@mellanox.com, yan.y.zhao@linux.intel.com, pbonzini@redhat.com, samuel.ortiz@intel.com, mona.hossain@intel.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org Date: Tue, 21 Jul 2020 09:02:41 -0700 Message-ID: <159534736176.28840.5547007059232964457.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <159534667974.28840.2045034360240786644.stgit@djiang5-desk3.ch.intel.com> References: <159534667974.28840.2045034360240786644.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Megha Dey The dev-msi interrupts are to be allocated/freed only for custom devices, not standard PCI-MSIX devices. These interrupts are device-defined and they are distinct from the already existing msi interrupts: pci-msi: Standard PCI MSI/MSI-X setup format platform-msi: Platform custom, but device-driver opaque MSI setup/control arch-msi: fallback for devices not assigned to the generic PCI domain dev-msi: device defined IRQ domain for ancillary devices. For e.g. DSA portal devices use device specific IMS(Interrupt message store) interrupts. dev-msi interrupts are represented by their own device-type. That means dev->msi_list is never contended for different interrupt types. It will either be all PCI-MSI or all device-defined. Reviewed-by: Dan Williams Signed-off-by: Megha Dey Signed-off-by: Dave Jiang --- drivers/base/dev-msi.c | 23 +++++++++++++++++++++++ include/linux/msi.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/dev-msi.c b/drivers/base/dev-msi.c index 43d6ed3ba10f..4cc75bfd62da 100644 --- a/drivers/base/dev-msi.c +++ b/drivers/base/dev-msi.c @@ -145,3 +145,26 @@ struct irq_domain *create_remap_dev_msi_irq_domain(struct irq_domain *parent, return domain; } #endif + +int dev_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, + const struct platform_msi_ops *platform_ops) +{ + if (!dev->msi_domain) { + dev->msi_domain = dev_msi_default_domain; + } else if (dev->msi_domain != dev_msi_default_domain) { + dev_WARN_ONCE(dev, 1, "already registered to another irq domain?\n"); + return -ENXIO; + } + + return platform_msi_domain_alloc_irqs(dev, nvec, platform_ops); +} +EXPORT_SYMBOL_GPL(dev_msi_domain_alloc_irqs); + +void dev_msi_domain_free_irqs(struct device *dev) +{ + if (dev->msi_domain != dev_msi_default_domain) + dev_WARN_ONCE(dev, 1, "registered to incorrect irq domain?\n"); + + platform_msi_domain_free_irqs(dev); +} +EXPORT_SYMBOL_GPL(dev_msi_domain_free_irqs); diff --git a/include/linux/msi.h b/include/linux/msi.h index 7098ba566bcd..9dde8a43a0f7 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -381,6 +381,10 @@ void platform_msi_mask_irq(struct irq_data *data); int dev_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg); + +int dev_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, + const struct platform_msi_ops *platform_ops); +void dev_msi_domain_free_irqs(struct device *dev); #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN