From patchwork Sat Jan 27 16:17:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13534137 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 DB8B7C46CD2 for ; Sat, 27 Jan 2024 16:22:01 +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=bnRb6RQYU/eD88DYBPgbKcii6o6ERDNJQz6dsFqqWww=; b=reJbPhghBYRl9Z 3vqikvsHPhB+uiy1fLKotOvE1KBUYbe5GXB0+xHen4tT/VD5UciHzRe0qnGLZ0B4ZI5xyXTNLEpho Ham31ynuSiAPw4h5oP3kB+Acw6IWl8QWZkNWt4si1Muf7g1iWHcvQ9fv2DQIQ46mv6sx3y4Mrtx8R LUonuRwTz7WjiQNIHCyXxIrH3ls18AsG4tD3jRbpCb/rkA/HEMCs5OOPNQk9Ym9jE8X13i09y2CWF +WkcmF/LL14jkO+9uqb8Gm57PK6AeGlKQZgOCGZiv4X4e40k2USiOfEQL/y0Gee8YINcSRtdWqSMO t9W9h5CNG1ChaqS2Lx3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTlRE-00000007mDp-2q2f; Sat, 27 Jan 2024 16:21:48 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTlOx-00000007kgB-2hzX for linux-arm-kernel@lists.infradead.org; Sat, 27 Jan 2024 16:19:35 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2906dffd8ddso1097153a91.3 for ; Sat, 27 Jan 2024 08:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706372366; x=1706977166; 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; bh=+4yC/aDtV6KBGHtbSqNeK69fWufSyNkr8dJJVArWQoc=; b=IwnOZOksmPCqwbCLZQEiASWjcWzyT0ttLCPha9/bobMa+IhnhJ5hEmeTihpg9ibfg5 lb35gMGM379MXd34oUSpyniWUolTEQPeI2vrq7E2aerfdQmkKNSSzYoh6imssRhdwA0U OnLINkmRatdTTncaB/nFQGra8eXbtUOf34gSpInHeHOp5FLegR75LGuZC+bEFZg64MPl XcT8pl238C7lwXl/zmzrMWDL5GuaWgEiriGtO177zH0zHK7/wxPPN7yMaVIvYV2cTcig dDZiYp6RHI06Ix4vAaLZvnzcBd1ucSt+il9j4jYs+vVWqhbXiXAX4yBSUbF94oyy8woV JTlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706372366; x=1706977166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+4yC/aDtV6KBGHtbSqNeK69fWufSyNkr8dJJVArWQoc=; b=dM2mmwI6AyWRCFQja+mJ9sxnAFvFvNW3WhRB4VOE5dIJieFjzqjjmEgZS8Z7W4NxnD ymLablUIundnG2k0AB6olxb12dj2UcAk3biSSmo7Gvm1NFHdkFTtTr+JMuF2XvJEStji 5pQa6BRPHRyfCr+96Ez/8W6+HaCMoq+Q2Yv0EVfu9DiB06gM4pWI+/reERffixAaJiV7 ATcQpz0U37vHKjpeoEDJFS3xCazPn39Rnp8Q3OWTgRcvWXyU4u0S+O4AbAAxSN+y81EQ ZgvT2ElEFCPHxYrkUqkjftA1wKxckOBqZiq5MWsNdZCe6EOCWKUtAJC5X4HdWQgAf2B8 T8bw== X-Gm-Message-State: AOJu0YzM3hNiKUIm4/1t2cS95kXnBK5tdIMTOTF2XPGl9hx2XtJUmZrs g7+GNIMllmSHMZZpL8CQanTxXtci+2cL6trz9F8j6ud5VITSNkV24+X2/YnJAoY= X-Google-Smtp-Source: AGHT+IEdn8vgLUGX2eDHAqn3V+MPuHc8ggNPbo8L4egywusYdrINzdqDh00M1BqTAPj6pqFfggQNNg== X-Received: by 2002:a17:90a:8981:b0:28c:f504:12a with SMTP id v1-20020a17090a898100b0028cf504012amr1237917pjn.24.1706372366213; Sat, 27 Jan 2024 08:19:26 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.17]) by smtp.gmail.com with ESMTPSA id d11-20020a17090ac24b00b00290f8c708d0sm5091620pjx.57.2024.01.27.08.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:19:25 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Marc Zyngier , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v12 12/25] genirq/irqdomain: Reroute device MSI create_mapping Date: Sat, 27 Jan 2024 21:47:40 +0530 Message-Id: <20240127161753.114685-13-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240127161753.114685-1-apatel@ventanamicro.com> References: <20240127161753.114685-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240127_081927_846106_0E7D42EA X-CRM114-Status: GOOD ( 16.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Reroute interrupt allocation in irq_create_fwspec_mapping() if the domain is a MSI device domain. This is required to convert the support for wire to MSI bridges to per device MSI domains. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- kernel/irq/irqdomain.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8fee37918195..aeb41655d6de 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -29,6 +29,7 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, unsigned int nr_irqs, int node, void *arg, bool realloc, const struct irq_affinity_desc *affinity); static void irq_domain_check_hierarchy(struct irq_domain *domain); +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq); struct irqchip_fwid { struct fwnode_handle fwnode; @@ -858,8 +859,13 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) } if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs_locked(domain, -1, 1, NUMA_NO_NODE, - fwspec, false, NULL); + if (irq_domain_is_msi_device(domain)) { + mutex_unlock(&domain->root->mutex); + virq = msi_device_domain_alloc_wired(domain, hwirq, type); + mutex_lock(&domain->root->mutex); + } else + virq = irq_domain_alloc_irqs_locked(domain, -1, 1, NUMA_NO_NODE, + fwspec, false, NULL); if (virq <= 0) { virq = 0; goto out; @@ -914,7 +920,7 @@ void irq_dispose_mapping(unsigned int virq) return; if (irq_domain_is_hierarchy(domain)) { - irq_domain_free_irqs(virq, 1); + irq_domain_free_one_irq(domain, virq); } else { irq_domain_disassociate(domain, virq); irq_free_desc(virq); @@ -1755,6 +1761,14 @@ void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs) irq_free_descs(virq, nr_irqs); } +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq) +{ + if (irq_domain_is_msi_device(domain)) + msi_device_domain_free_wired(domain, virq); + else + irq_domain_free_irqs(virq, 1); +} + /** * irq_domain_alloc_irqs_parent - Allocate interrupts from parent domain * @domain: Domain below which interrupts must be allocated @@ -1907,9 +1921,9 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, return -EINVAL; } -static void irq_domain_check_hierarchy(struct irq_domain *domain) -{ -} +static void irq_domain_check_hierarchy(struct irq_domain *domain) { } +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq) { } + #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ #ifdef CONFIG_GENERIC_IRQ_DEBUGFS