Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp334698rdb; Sat, 27 Jan 2024 08:22:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiPi2QWFzATUey3haaXiQGLR+YowYNXtGq9MQij+0+UpX0Ehq/iQw4P6ceehPma5kK6mby X-Received: by 2002:aa7:d4c1:0:b0:55c:96da:16dc with SMTP id t1-20020aa7d4c1000000b0055c96da16dcmr4224226edr.18.1706372535049; Sat, 27 Jan 2024 08:22:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372535; cv=pass; d=google.com; s=arc-20160816; b=rgWmcq5rhdWFUVdJDCSaTTtwzhrywPy2z/fdtxw5dHVQBAGFGe95KOeX7foiJZDETl TWAqeyp1nNqxVjfD/5hTk+Ebvu8X81SF3yk1oF/yQ8gp2kapmmIxL1NmXWh0PzGhaLEL u5yl0UEmzRrnwWb1nRPRSgO4zBMEsbZKlfpqitpB5f4qCYwj5FRo77wfzDClfk1XsoS1 JBT3RcUWVcV/adEQzgLiptBJ0wbDK+d5rb57ALySqLGXI91ycbRgjobXgLwBfFeURFQI kJBbLxCY7G2AB/rHzBSgnCfhjpqME9gLnf5/QZR4B9ilatuFdPL4gQBLBh9nt0xhCJGQ qPZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+4yC/aDtV6KBGHtbSqNeK69fWufSyNkr8dJJVArWQoc=; fh=706cnY5t7hpwBXQypCTGH3HYLPe+/lcVAB5kbpxvl24=; b=hhrZQjkf+p/P4ApZsu9JygNRKlYUCSf8JoV1owQCN1mzt5MZkWvl9D+Njv1+pbs+S5 RdPOHveambqqU1B1w8mzjbWMgHgw4ZaEi1c/GdMegF00E4KYh5jnOtwjSy2z/iX/P770 Et1U5Ro3doTNRT9ezhtqkxTVoHaiYnwBAwEZm9QTa5VVX7tnlrLDRCWDb4hQXMMkYuSH LAC7r0bIcn7EJPUYESlxxiBeW8utyZA/t+3TRdG4f8qHq9PqeWQazdV1cjWkyY4HU2/i 9FXWd7lAbR0cBoga7XuuXzOgUSkKXeLF2VGGVVR4kB7PAfU/JN21nZ4BoiwnDJiC1ici vKhg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=e41GROJr; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41286-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b13-20020aa7c6cd000000b00553b42fb10dsi1832550eds.358.2024.01.27.08.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=e41GROJr; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41286-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A2E211F22DB1 for ; Sat, 27 Jan 2024 16:22:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2042F5822F; Sat, 27 Jan 2024 16:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="e41GROJr" Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D547D48790 for ; Sat, 27 Jan 2024 16:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372368; cv=none; b=grU732f53wqHBQprHKtPhq268A3ifID0yZuwaflwVMuKjeUAYrOTMBtlkjpZXQj2F3DFeFzF+NK7As0vi3kQ9TJFcclZVgtHf9C9IPrbD2lR+wIy7NuUn0OQxHJ9dmFz+l6rIh41zzdW6etY99uLhfpfa2pBBX4FEJB5PF63qPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372368; c=relaxed/simple; bh=T3dXW581jZ06BKj8dm+t015SP9YB2Ce67L9Tnar7yYE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D/c2+KXamW7zfx+/QXvAaaF3Gnf0NQovsnhAYqsQ4VqxJJ8r2j1rUsg+5SkZZHKWkXp/Aab0quGLZR7Z7N7qJgl73xWTvsfTKPmkQ3XOHD9BD8l8KgL26LSvPYI+BTh9XS+P9UBoa7p48e0f68zPMpCt/IHfqbr8Yblm1Fjtiik= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=e41GROJr; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-29080973530so1345785a91.1 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=vger.kernel.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=e41GROJrZubuDqaitcptE80UwunbKIbRLvTdfNa7UfXgq+RqaDNLoI3cXRr6uLE63S s8pPPXSGeB8d6XkjxMgTP9U8QuZD6PCDdc4Vjs6Fndv6utQe2FTnTvuO2t51E689fx2z 8cb3X+90XZoCVqFGMeIZREhLLDDFGZwBZknXXDcNItjDYVLC5vm6Lds1AfWt7owltC5b COUMkYwj9RUtNyBesU++xUHS5f/+T5fvD1GVmy7Y3hDMqmA9VhxFuonAM2sdLNu4G0PV 70AR4stra1EFRAX+azmY0Z5QSgCKBHtmQEoPkdfYh2oVJ5Uqy5OJvq82ahTpeGYbPZAc 1T2g== 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=X3Q2WIwmkcoykizMzYBXkB64d+LY92+kbPZ7F/VzNUlSLK0RiDwci6qRBnmhWTnnGr vcRRSZ8J1CHs4vXZwjz4c0U7hvJPlQvq6bF3qYHP0UpOkzuHZHubolQhc8h2javOAFD4 PMk48Lx9oMFBgYxJ22tMqu9lX4GQl/vwfgah0D2uyHbNpyWn8QQ8vvq82N8V0l6pzgDj Ctrr9FSgawX2VAs37BV/nIjmSxdsfxEBld9Uw6xlU/x1JgdjTmYURDCbP2zMBNAoCIz1 jbSV4hF+OxJA5pfgOW8rQNy9MS/xFACgwUarkPXHSCf28yW0pSVEjMtnyjq63zI+gh7R RHzg== X-Gm-Message-State: AOJu0YzQelQ5vLMj8RlM7/mjsMck+o0Ae9YcZoOeQ0opy2atEMel7r6p ncjXATvyK/ILvUgamCM2LhiznO5S5urDTMl6YJVZ1UDOLtSFth21kgaexlAEOrc= 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?q?Bj=C3=B6rn=20T=C3=B6pel?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.34.1