From patchwork Thu Nov 24 23:24:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3659880wrr; Thu, 24 Nov 2022 15:26:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7eC1jT29sWcQobcuWP3B0zpQIu3BmXji9wD5FheEoQJg6QPuz0H9k8BCLeUJOn7OwYQN/c X-Received: by 2002:a63:de01:0:b0:476:32a2:253 with SMTP id f1-20020a63de01000000b0047632a20253mr16451130pgg.133.1669332376374; Thu, 24 Nov 2022 15:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669332376; cv=none; d=google.com; s=arc-20160816; b=hOcC9+QS6zRECf61grjbEvdmPHyYjvgyIk/kmFQovV2vQT3PDdMXW2NcRpZEGphY9q WM45MeNGY86AJ9n6u4Em1wMFqy6S9PZK0cpGWzMvyO4j3jCZBv+mmjaHTPhZVTzvg/rn sP3AWeiJbwZRZ/Ecy/QeAGZIHxY4B0D8HuypfXpU/hpTEFHKWoZF+Er6SL7SZfnYvUde FBNakiHCL9XLGppVuOzwJxWVIAV825tHjgj3RJ1wG145RF6UYGA0ZS9gIGuRIKEYHgGO wJwBL1X5phnQgX9jQR7as8iKYJJygUN+pgA5KakGYpllYO9ADRAwHltpR0P56/G/bw5c cvmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=1/0X92agTvjRjQzuL4lsTq7huP6SoYkhEuMMwl1ZamE=; b=kvA3pvF2EZXzDYsQ9c0tA66XDR89UFYrMzFelM9mGz9yO1XCI3qnKu03SBujkTa86j SCR+VuXj2P8V1J/t9+ei6qSkNxQadcCPJ+8MrAt2ImANmJtd1EpWtfCP+Q3xqp2TrBLA lLaMPyn2F+U5Uk+3qx5nWNEmndKs9zmatT0A6fTbCo9aftn4ayP7JGlNmlcuzC7VXFvI jzKNTsR67K3/1E411H0fKeo+gHbfQWtahTV2BZLpLTUYfX7CKljuLHPY6oIgDSSHQQpD XtGEK1Cl6ea9C5hiXk0FR0z+FDNbPzFBBogha185jcysbfS+NcF/SIKfgpKQlHP32aTl aYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hwD5d3aq; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a63070d000000b0046ec058379bsi2438516pgh.99.2022.11.24.15.26.02; Thu, 24 Nov 2022 15:26:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hwD5d3aq; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbiKXXZa (ORCPT + 99 others); Thu, 24 Nov 2022 18:25:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiKXXYx (ORCPT ); Thu, 24 Nov 2022 18:24:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E193A65A1; Thu, 24 Nov 2022 15:24:31 -0800 (PST) Message-ID: <20221124230314.163043028@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669332269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1/0X92agTvjRjQzuL4lsTq7huP6SoYkhEuMMwl1ZamE=; b=hwD5d3aqQLl2DGymQxv0DOqxN2X0T2oe+RcE6wc2WBaEjdPcVtK203DQyFSfCaPwzTPknV qq/xtxoYKPCexWPCPRjqetiesdM8jxRr1/jq+F3VMaT3EEys9bTY8x3OpXEmFggG889XJ2 qV9rpXdgyWUI9neFVAOL5rx+xXcTgAi7d+8MLt8/dfCHqOR0UOhXNd/8SYAHxpDWioB931 2iPY8empjkEDpJ3MBqLrfRGN6H4sHj/x8Lao0FE9dHylp7Y4yq6F0RJz9Jt8QuDGZ+Y8Gq DhPS/CwCDJsMc6sO0AgxK1Q08dlN+mbZmuATyZZ9WzEkAejnQXHH/OyoViXTEg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669332269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1/0X92agTvjRjQzuL4lsTq7huP6SoYkhEuMMwl1ZamE=; b=+qxLZDiyXYQT2USH+0qUG2LwZo4EgBYRce9frjtPYQCJ0p7/zkLObQUhsheUPbDNlPdd5P aM4o74JQYSybbZBA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V3 13/22] genirq/msi: Make descriptor allocation device domain aware References: <20221124225331.464480443@linutronix.de> MIME-Version: 1.0 Date: Fri, 25 Nov 2022 00:24:29 +0100 (CET) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750421865849645314?= X-GMAIL-MSGID: =?utf-8?q?1750421865849645314?= Change the descriptor allocation and insertion functions to take a domain id to prepare for the upcoming multi MSI domain per device support. Signed-off-by: Thomas Gleixner --- V3: Adopt to the domain/xarray storage change --- include/linux/msi.h | 16 +++++++++++++++- kernel/irq/msi.c | 20 ++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -286,7 +286,21 @@ static inline void msi_desc_set_iommu_co } #endif -int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc); +int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid, + struct msi_desc *init_desc); +/** + * msi_insert_msi_desc - Allocate and initialize a MSI descriptor in the + * default irqdomain and insert it at @init_desc->msi_index + * @dev: Pointer to the device for which the descriptor is allocated + * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor + * + * Return: 0 on success or an appropriate failure code. + */ +static inline int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) +{ + return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc); +} + void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); /** --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -39,7 +39,7 @@ static inline int msi_sysfs_create_group * Return: pointer to allocated &msi_desc on success or %NULL on failure */ static struct msi_desc *msi_alloc_desc(struct device *dev, int nvec, - const struct irq_affinity_desc *affinity) + const struct irq_affinity_desc *affinity) { struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL); @@ -64,9 +64,10 @@ static void msi_free_desc(struct msi_des kfree(desc); } -static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, unsigned int index) +static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, + unsigned int domid, unsigned int index) { - struct xarray *xa = &md->__domains[MSI_DEFAULT_DOMAIN].store; + struct xarray *xa = &md->__domains[domid].store; int ret; desc->msi_index = index; @@ -77,15 +78,17 @@ static int msi_insert_desc(struct msi_de } /** - * msi_insert_msi_desc - Allocate and initialize a MSI descriptor and - * insert it at @init_desc->msi_index + * msi_domain_insert_msi_desc - Allocate and initialize a MSI descriptor and + * insert it at @init_desc->msi_index * * @dev: Pointer to the device for which the descriptor is allocated + * @domid: The id of the interrupt domain to which the desriptor is added * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor * * Return: 0 on success or an appropriate failure code. */ -int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) +int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid, + struct msi_desc *init_desc) { struct msi_desc *desc; @@ -97,7 +100,8 @@ int msi_insert_msi_desc(struct device *d /* Copy type specific data to the new descriptor. */ desc->pci = init_desc->pci; - return msi_insert_desc(dev->msi.data, desc, init_desc->msi_index); + + return msi_insert_desc(dev->msi.data, desc, domid, init_desc->msi_index); } /** @@ -120,7 +124,7 @@ static int msi_add_simple_msi_descs(stru desc = msi_alloc_desc(dev, 1, NULL); if (!desc) goto fail_mem; - ret = msi_insert_desc(dev->msi.data, desc, idx); + ret = msi_insert_desc(dev->msi.data, desc, MSI_DEFAULT_DOMAIN, idx); if (ret) goto fail; }