From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1119FC624C6 for ; Mon, 31 Aug 2026 15:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0U+zfVwuHftANnH/7omSrhVV92cTBDrtnvGfa7J6o50=; b=RuiuGFlrIeTCXF BBFtpAJve7qUCmSQhU4/n731zYXZmW8RJeg6in8DOchzyiNbfkdZgL6r+p/ekIUDWcVRs8RQfu6hj J2yAue6dW6RWN8eCpnDubEOlRr2F2oS9TQSWeNyNB51OJl680mRVIcv6MOx+BzvXQ38KPhDG4CJrR LoS4mAOrFmWi3YN7rJPTw+qfdS1ECcI/o/FQsITLr7Ulj/V8x1kOdGojGbb7OOwhL4oXnPGFXoIE+ 3vHi9cYdxgbe4XG9hc6J7ycG2A0XrYwjcHn7U9fKELwBKaEd9Xq216f3KNTqCYAhDN+7LoJ2JMY2G YsJmKTXMDN9+OLip2Mmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x13UZ-00000009kiJ-0w6w; Mon, 31 Aug 2026 15:00:11 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x13UO-00000009kUg-3XOZ for linux-riscv@lists.infradead.org; Mon, 31 Aug 2026 15:00:02 +0000 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67VETYYb3969372 for ; Mon, 31 Aug 2026 15:00:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=zpaaBsor5YI 74G39irsbNb4XZr4VVwzRwDQMT7L/5rI=; b=IPUQa0PwLv4BhD+iOx+WUbO91c/ rqVNB+19og2ZNQ01/n6ZCbmNO5sUy0nCyGIm+LoK1RaZD8TEDNZg41w0ITRVHoz4 r5yUySpRfnRsHsuLTsqJmzbDv8Kxt7UbB/YoJRZrlbFPtc16Mnk2J87MDyQGdysc nNmm+ZTv0Dv6zYUkpRjYavgpIdbSsRUCPgzG3/AUOeQxJoJDCANP/2pS+GIc1hm3 5ZHx/puvEYtZA2i70bupg3ToFPFqZre/TAjUGLePWlsx0OqYkpH0V6JR62oO9Hrb eH9J2s17CBpF9yn6uDVukCX4AehkOCH7Nh2Xyb4WX8usM7tznlKc4G1hmLg== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gd6h91gwm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 31 Aug 2026 14:59:59 +0000 (GMT) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-90cc915d1d9so49625056d6.2 for ; Mon, 31 Aug 2026 07:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788188399; x=1788793199; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zpaaBsor5YI74G39irsbNb4XZr4VVwzRwDQMT7L/5rI=; b=hduNG8jOQH1mrKDOH/DcOcewBKOG2OeDH55FVWXxl6HKZrcsLetoVEo9t5b5jJXYfi FipHygz5Xcvedb/fCeTP9PaPxXmYjac16EqEKcoyPPsl+CMNvGX8jbf/GS2ZCHL5ZByM mohznxNUSG5C+gFNl3K7Bav23nLTIcGRZ+d9aR5bd7qmOdYbh3iVRMRzrMhojtVVEM6C FsIhTQH2pLTbrmd2noZwk/4UX7RrcZ+LKLmztS3yIOBJLEXG/1knrpz06XApn2ntioce kFecGMOE9KVATVySVGi0GHQGj/eDdfapQvKY8Hnqdq/iX1psePV9Ezrla5m4M8Ijf4wD 23zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788188399; x=1788793199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=zpaaBsor5YI74G39irsbNb4XZr4VVwzRwDQMT7L/5rI=; b=cRQv5cHh0yeWb1spvca6Grt7qUaCuOjR4xhmhUeE/RfNG1O9mLJyx/XyVgHYMFXY++ 6PD79qhDyhLEDIkPx4gq2Rzboghp3llZY+lIbsSkgcqToef8pZsw/lJZk/oynS6xFrD3 1pP0kQXzIuXdIq8ym9RaTSp5YcvyeBYSRbs14b2FCDhwJTODVh7XlVzsgb8zM3Z3gCZV e7v60kqipV9oRMvqw3MKoMyDdsbzV//31VP2p4LZfGahZbk6TIQfY4BhuCpUaEEgZWvG 0RdNVwcnaUZEuaRYze8Sf9+3upDwo5pAPLXRpK9nPNi0aFVbNT/h3lZSRi5Bo5ygsH3w yLag== X-Gm-Message-State: AFuF++kAMQtU5iaBWxadRnBXtEt/qVVbzLW1jd9tx6afry6KNtVCRp0E z3uPTsVV6dMHunN4hvbsKBqk6J4TqYMDeF51ZtUBSS1U6EgSz13ZLGdkk5Vqf2X+AfGxlKXgx+1 NZDiwHssJmHaVVas8wRaWJHJmrUSLVXXjKr6EDBb0SoRbf6KDEAVpQoS5328XGJyrKwYtofDaZX GTW/E= X-Gm-Gg: AR+sD11hdNOtwlr0NkYt/Ge3D6PxKUTp/4gxAiNliDgJRqb3tbt3v+kAMZMvUgzMgar nrFkMg9wo98lkPWCimkZvpvOBDO83wLdM3c1osj/UdGXQp3rixbJgH3iB2WKZrLQVW1d9YPGUrN wl2CANHLr/mhmKEJjl39FdtroDSPGim8Wm8h5C+wt5eIZWzhUEvaRtaTJynZTSOQyDVGe+9W1wy JPvEF7euRUzMQHjlM/zMVHg+3ArCwPvoYxdpr8FcY0OimhZLe81Cc2jEfAKDrrTA6kALygXEct5 m2YJTXBmdXrDB03h0gnYe+KQC5sdS/z3hONTP32n+lPZ68ojfiLIsuMoEIqlpF5aD/KD278JNcQ bVpEBTq4Gxq4SMC8rohL9fS4zjSpFqFrKVMI= X-Received: by 2002:ae9:f70b:0:b0:932:ddff:123d with SMTP id af79cd13be357-93913940a19mr2492738785a.29.1788188399100; Mon, 31 Aug 2026 07:59:59 -0700 (PDT) X-Received: by 2002:ae9:f70b:0:b0:932:ddff:123d with SMTP id af79cd13be357-93913940a19mr2492733185a.29.1788188398551; Mon, 31 Aug 2026 07:59:58 -0700 (PDT) Received: from localhost (ip-86-49-251-7.bb.vodafone.cz. [86.49.251.7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49ccea6b814sm180435205e9.0.2026.08.31.07.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 07:59:57 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, iommu@lists.linux.dev Cc: linux-kernel@vger.kernel.org, tomasz.jeznach@linux.dev, tjeznach@rivosinc.com, jgg@ziepe.ca, jgg@nvidia.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com, anup@brainfault.org, tglx@kernel.org, kevin.tian@intel.com, fangyu.yu@linux.alibaba.com Subject: [PATCH v5 08/17] iommu/dma: Introduce iommu_dma_prepare_msi_list() Date: Mon, 31 Aug 2026 16:59:34 +0200 Message-ID: <20260831145943.313726-9-andrew.jones@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260831145943.313726-1-andrew.jones@oss.qualcomm.com> References: <20260831145943.313726-1-andrew.jones@oss.qualcomm.com> MIME-Version: 1.0 X-Authority-Analysis: v=2.4 cv=W6UIkxWk c=1 sm=1 tr=0 ts=6a9596ef cx=c_pps a=oc9J++0uMp73DTRD5QyR2A==:117 a=on9AXyaqQ0RhfYpiXjjEXA==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=2ceW4JgIosI8Fxwmn1gA:9 a=iYH6xdkBrDN1Jqds4HTS:22 X-Proofpoint-ORIG-GUID: zGbiRA2_P1FZ7dJnKn72zYXPhmnVzKMU X-Proofpoint-GUID: zGbiRA2_P1FZ7dJnKn72zYXPhmnVzKMU X-Proofpoint-Spam-Info: AW1haW4tMjYwODMxMDEyOSBTYWx0ZWRfX8r0hkyiv+lgi HzhHMafpfltcgUkUCyH18A3mrrocvAKWrqBKBcuU/9EEKp++/1wyqG89O1qcmkHfW/74oWkdgyc eO1zVZSlLPe/+VhXH1zV649UU4D2Pls= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODMxMDEyOSBTYWx0ZWRfX+Ww2howNONWo 0kOTsKSdGRkSBLvHYn6lbdyYUWZJRDAN3K0I1zMtJOvtjBKa7z8P7VTbN+nRY9rBxSGPcvi9ntf qNIAKY1cNI8d4jm6stLDHfzP6KDqTJV7NCAAOHS08J7i0oNYWtCdMDKkDvzcMglD655urIa7K9A iumxfAnvhyDeSzpIamat2Vc+SR5FChgbUErwai0/V2mBXq/tJ3kmfrcGklyXp8ZjmDUbBR+rRuK vvifHHgp86qpwsYj5Z+jABe8ACJaN4VsNVSL2t8Wh17HIQL069oSf5OEdgNAuRQpXqhTBU3TgLq loT/Li9ClHstOH8Def2uohk3YM8sGsrjTdkQZgR5ExVo98v/Of37/oBZKqWKrpPFssv1/pJNB1q Nd7Nkp7Zb+r6FWeF3X9hebO5Zx/tbvV9UdKp55aeccvV4rZLEC3pM/bmdgBgS+85gOEFYBp59lI dfrajZqIUnExSAPLu8g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-31_05,2026-08-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608310129 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260831_080001_076966_51AF8977 X-CRM114-Status: GOOD ( 24.83 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add iommu_dma_prepare_msi_list() to map an ordered physical address list through the current domain backend. Validate that the requested granule is a power of two no smaller than PAGE_SIZE and that every address is aligned to it. Refactor iommu_dma_prepare_msi() to obtain the backend granule and align its single address before using the same list dispatcher. Convert the DMA-IOMMU and iommufd backend entry points to consume address lists directly. Signed-off-by: Andrew Jones --- drivers/iommu/dma-iommu.c | 13 ++-- drivers/iommu/dma-iommu.h | 13 +++- drivers/iommu/iommu-priv.h | 7 ++- drivers/iommu/iommu.c | 109 +++++++++++++++++++++++++++------ drivers/iommu/iommufd/driver.c | 24 +++----- include/linux/iommu.h | 8 +++ 6 files changed, 126 insertions(+), 48 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 38a0c4e244d6..c9fdc792416c 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -2173,7 +2173,7 @@ static bool has_msi_cookie(const struct iommu_domain *domain) domain->cookie_type == IOMMU_COOKIE_DMA_MSI); } -static size_t cookie_msi_granule(const struct iommu_domain *domain) +size_t iommu_dma_msi_granule(const struct iommu_domain *domain) { switch (domain->cookie_type) { case IOMMU_COOKIE_DMA_IOVA: @@ -2304,23 +2304,20 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, } int iommu_dma_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, - phys_addr_t msi_addr) + const phys_addr_t *phys_addrs, unsigned int nr_addrs, size_t granule) { struct device *dev = msi_desc_to_dev(desc); const struct iommu_dma_msi_page *msi_page; - phys_addr_t phys_addr; - size_t granule; if (!has_msi_cookie(domain)) { msi_desc_set_iommu_msi_iova(desc, 0, 0); return 0; } - - granule = cookie_msi_granule(domain); - phys_addr = ALIGN_DOWN(msi_addr, granule); + if (granule != iommu_dma_msi_granule(domain)) + return -EOPNOTSUPP; iommu_group_mutex_assert(dev); - msi_page = iommu_dma_get_msi_page(dev, &phys_addr, 1, granule, domain); + msi_page = iommu_dma_get_msi_page(dev, phys_addrs, nr_addrs, granule, domain); if (!msi_page) return -ENOMEM; diff --git a/drivers/iommu/dma-iommu.h b/drivers/iommu/dma-iommu.h index 040d00252563..bf9cd4102d35 100644 --- a/drivers/iommu/dma-iommu.h +++ b/drivers/iommu/dma-iommu.h @@ -19,8 +19,9 @@ int iommu_dma_init_fq(struct iommu_domain *domain); void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); +size_t iommu_dma_msi_granule(const struct iommu_domain *domain); int iommu_dma_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, - phys_addr_t msi_addr); + const phys_addr_t *phys_addrs, unsigned int nr_addrs, size_t granule); extern bool iommu_dma_forcedac; @@ -53,8 +54,14 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he { } -static inline int iommu_dma_sw_msi(struct iommu_domain *domain, - struct msi_desc *desc, phys_addr_t msi_addr) +static inline size_t iommu_dma_msi_granule(const struct iommu_domain *domain) +{ + return 0; +} + +static inline int iommu_dma_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, + const phys_addr_t *phys_addrs, unsigned int nr_addrs, + size_t granule) { return -ENODEV; } diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h index aaffad5854fc..1122c99566d5 100644 --- a/drivers/iommu/iommu-priv.h +++ b/drivers/iommu/iommu-priv.h @@ -54,10 +54,11 @@ int iommu_replace_group_handle(struct iommu_group *group, #if IS_ENABLED(CONFIG_IOMMUFD_DRIVER_CORE) && IS_ENABLED(CONFIG_IRQ_MSI_IOMMU) int iommufd_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, - phys_addr_t msi_addr); + const phys_addr_t *phys_addrs, unsigned int nr_addrs, size_t granule); #else /* !CONFIG_IOMMUFD_DRIVER_CORE || !CONFIG_IRQ_MSI_IOMMU */ -static inline int iommufd_sw_msi(struct iommu_domain *domain, - struct msi_desc *desc, phys_addr_t msi_addr) +static inline int iommufd_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, + const phys_addr_t *phys_addrs, unsigned int nr_addrs, + size_t granule) { return -EOPNOTSUPP; } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index a3dea7353500..692e793c624e 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -4223,42 +4223,115 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) EXPORT_SYMBOL_GPL(pci_dev_reset_iommu_done); #if IS_ENABLED(CONFIG_IRQ_MSI_IOMMU) +static int __iommu_dma_prepare_msi_list(struct iommu_group *group, struct msi_desc *desc, + const phys_addr_t *phys_addrs, unsigned int nr_addrs, + size_t granule) +{ + if (!group->domain || group->domain->type == IOMMU_DOMAIN_IDENTITY) + return 0; + + switch (group->domain->cookie_type) { + case IOMMU_COOKIE_DMA_MSI: + case IOMMU_COOKIE_DMA_IOVA: + return iommu_dma_sw_msi(group->domain, desc, phys_addrs, nr_addrs, granule); + case IOMMU_COOKIE_IOMMUFD: + return iommufd_sw_msi(group->domain, desc, phys_addrs, nr_addrs, granule); + default: + return -EOPNOTSUPP; + } +} + +static int iommu_dma_validate_msi_list(const phys_addr_t *phys_addrs, unsigned int nr_addrs, + size_t granule) +{ + unsigned int i; + + if (!nr_addrs || granule < PAGE_SIZE || !is_power_of_2(granule) || + nr_addrs > SIZE_MAX / granule) + return -EINVAL; + + for (i = 0; i < nr_addrs; i++) + if (!IS_ALIGNED(phys_addrs[i], granule)) + return -EINVAL; + + return 0; +} + +/** + * iommu_dma_prepare_msi_list() - Map MSI pages in the IOMMU domain + * @desc: MSI descriptor to update with the base IOVA + * @phys_addrs: Ordered MSI target physical addresses + * @nr_addrs: Number of addresses in @phys_addrs + * @granule: Mapping granule for every address + * + * @nr_addrs must be nonzero and @granule must be a power of two no smaller than + * PAGE_SIZE. Every address must be aligned to @granule. The addresses are mapped + * in order to one contiguous IOVA range and may repeat. The list is consumed + * synchronously and is not retained. + * + * When a software MSI mapping is required, the backend records the base IOVA + * and granule shift in @desc. Otherwise, @desc is left unchanged. + * + * Return: 0 on success, -EINVAL if the parameters are invalid, -EOPNOTSUPP if + * the domain backend cannot provide the mapping, or another negative error + * code from the backend. + */ +int iommu_dma_prepare_msi_list(struct msi_desc *desc, const phys_addr_t *phys_addrs, + unsigned int nr_addrs, size_t granule) +{ + struct device *dev = msi_desc_to_dev(desc); + struct iommu_group *group = dev->iommu_group; + int ret; + + ret = iommu_dma_validate_msi_list(phys_addrs, nr_addrs, granule); + if (ret || !group) + return ret; + + mutex_lock(&group->mutex); + ret = __iommu_dma_prepare_msi_list(group, desc, phys_addrs, nr_addrs, granule); + mutex_unlock(&group->mutex); + return ret; +} + /** * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU domain * @desc: MSI descriptor, will store the MSI page * @msi_addr: MSI target address to be mapped * - * The implementation of sw_msi() should take msi_addr and map it to - * an IOVA in the domain and call msi_desc_set_iommu_msi_iova() with the - * mapping information. - * * Return: 0 on success or negative error code if the mapping failed. */ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) { struct device *dev = msi_desc_to_dev(desc); struct iommu_group *group = dev->iommu_group; + phys_addr_t phys_addr; + size_t granule; int ret = 0; if (!group) return 0; mutex_lock(&group->mutex); - /* An IDENTITY domain must pass through */ - if (group->domain && group->domain->type != IOMMU_DOMAIN_IDENTITY) { - switch (group->domain->cookie_type) { - case IOMMU_COOKIE_DMA_MSI: - case IOMMU_COOKIE_DMA_IOVA: - ret = iommu_dma_sw_msi(group->domain, desc, msi_addr); - break; - case IOMMU_COOKIE_IOMMUFD: - ret = iommufd_sw_msi(group->domain, desc, msi_addr); - break; - default: - ret = -EOPNOTSUPP; - break; - } + if (!group->domain || group->domain->type == IOMMU_DOMAIN_IDENTITY) + goto out_unlock; + + switch (group->domain->cookie_type) { + case IOMMU_COOKIE_DMA_MSI: + case IOMMU_COOKIE_DMA_IOVA: + granule = iommu_dma_msi_granule(group->domain); + break; + case IOMMU_COOKIE_IOMMUFD: + granule = PAGE_SIZE; + break; + default: + ret = -EOPNOTSUPP; + goto out_unlock; } + + phys_addr = ALIGN_DOWN(msi_addr, granule); + ret = __iommu_dma_prepare_msi_list(group, desc, &phys_addr, 1, granule); + +out_unlock: mutex_unlock(&group->mutex); return ret; } diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c index 45278c11c688..72e9ce63a5ee 100644 --- a/drivers/iommu/iommufd/driver.c +++ b/drivers/iommu/iommufd/driver.c @@ -419,9 +419,14 @@ static void iommufd_sw_msi_set_required(struct iommufd_group *igroup, } } -static int iommufd_sw_msi_list(struct iommu_domain *domain, struct msi_desc *desc, - const phys_addr_t *phys_addrs, unsigned int nr_addrs, - size_t granule) +/* + * Called by the irq code if the platform translates the MSI addresses through the + * IOMMU. phys_addrs are the physical addresses of the MSI pages. iommufd will + * allocate contiguous fd global iovas for the physical pages that are the same on + * all domains and devices. + */ +int iommufd_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, + const phys_addr_t *phys_addrs, unsigned int nr_addrs, size_t granule) { struct device *dev = msi_desc_to_dev(desc); struct iommufd_hwpt_paging *hwpt_paging; @@ -505,19 +510,6 @@ static int iommufd_sw_msi_list(struct iommu_domain *domain, struct msi_desc *des return rc; } -/* - * Called by the irq code if the platform translates the MSI address through the - * IOMMU. msi_addr is the physical address of the MSI page. iommufd will - * allocate a fd global iova for the physical page that is the same on all - * domains and devices. - */ -int iommufd_sw_msi(struct iommu_domain *domain, struct msi_desc *desc, - phys_addr_t msi_addr) -{ - phys_addr_t phys_addr = msi_addr & PAGE_MASK; - - return iommufd_sw_msi_list(domain, desc, &phys_addr, 1, PAGE_SIZE); -} EXPORT_SYMBOL_NS_GPL(iommufd_sw_msi, "IOMMUFD"); #endif diff --git a/include/linux/iommu.h b/include/linux/iommu.h index ac43b8b93f14..bf08be172e40 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1561,8 +1561,16 @@ static inline void pci_dev_reset_iommu_done(struct pci_dev *pdev) #ifdef CONFIG_IRQ_MSI_IOMMU #ifdef CONFIG_IOMMU_API +int iommu_dma_prepare_msi_list(struct msi_desc *desc, const phys_addr_t *phys_addrs, + unsigned int nr_addrs, size_t granule); int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr); #else +static inline int iommu_dma_prepare_msi_list(struct msi_desc *desc, const phys_addr_t *phys_addrs, + unsigned int nr_addrs, size_t granule) +{ + return 0; +} + static inline int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) { -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv