From patchwork Sat Jan 27 16:17:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 193041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp565908dyb; Sat, 27 Jan 2024 08:21:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGszjorR0qx0K5+6uB8a483jKOHkcEr2Mipr2gImIsQpbJpISbDbg6D2iJZnOg06NPKb6oL X-Received: by 2002:aa7:d5c4:0:b0:55c:d3e3:9d8 with SMTP id d4-20020aa7d5c4000000b0055cd3e309d8mr947598eds.41.1706372510432; Sat, 27 Jan 2024 08:21:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372510; cv=pass; d=google.com; s=arc-20160816; b=Lq5TSYZo8SUMG8kw0rmd1iXahKWzdO5sjocdPZqquETvYNzpgkPFndVQiya8heg8DJ xnG65UzIwZr6S+wzfZLFp6reBaKMu0IBYJfUIJB1atR3ZuEE2r4NjS35OVvv/B0p0XNH l82SDrYG5nDu1NJpZHMGUVBvXvbZ4z4csLVdyH5GK+jSGSYP/n8+C16KK4F2h3TPJitc ynKAQJwS7XTwPF21biZxc19iuzb1F/t5F90bSwTmDtcMtxVHGjolyn4XVzOVrL8IXptU lGnswBTJHq2thbEiW9jqByPZt4Cewi5DyQobcSRDM7tV5iJmnhsg4hHqTXwEfwBrYvZU hNsQ== 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=GSirNz5MKgvKyg3PpEGC1NXiMt4KceVCwKab+ZPE5BY=; fh=706cnY5t7hpwBXQypCTGH3HYLPe+/lcVAB5kbpxvl24=; b=T9PZmn4jEWdJuaz6fj3LSp42Tw8EVNThAgCZAqO1040LeMquYUaA5AOOmH8vtAPdh/ jiFBb/jMt1yO+sMVxU6EEKHAVFqQvGPl/7RePc4YlxIxeNK/43tOlY//jYW8AtylNhwO iDlzZO9x7LoUY6Zmv0EXaXNpdWSmZ/15fWotd/YLXvRQDEjj/EYqV4Wn7KG3qDyswCrc O6lt7og7DB0XD0W+HcirvtsUGK3u9OKiGsOE/7YtGe7Z/PghC7aujc8jFNQQD/KylVyP em7FB2n6J12tpzzPV0b5HJ2tz2g0cUJqSSC+jTKOZbph/9ExqwH4WJe1ohand2rDQoWZ CNZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=LnOKs7s0; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41284-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41284-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i3-20020a0564020f0300b0055ebc164cd1si579997eda.119.2024.01.27.08.21.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:21:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41284-ouuuleilei=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=LnOKs7s0; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41284-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41284-ouuuleilei=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 CE1101F22836 for ; Sat, 27 Jan 2024 16:21:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6882B2D05E; Sat, 27 Jan 2024 16:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="LnOKs7s0" Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 191A345944 for ; Sat, 27 Jan 2024 16:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372357; cv=none; b=KJHVPilGE31NMm7dvS2/HLnjXRS70wfxjQUQVLiZWc492A/z35L0y1EHMljJbZu14+eJqTm5PMnzrQMLZ+3kJ82TZttp+bQuvdF77He056bzpZBw1g+MQ4a4NrXXJ3Jg0l+SEK87gBhH/mfpLaDPZGzyJhc9CZNVgWhy+3IAfDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372357; c=relaxed/simple; bh=xcH/TMHnoQ/ciOIvqOw1HinQeQmtN3UXgJ/miOYB6K4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AW05JpWwBJ55/HPCEPTge3mcQILwmWYwa42o4mOUEigDMASzBbmX4XkxkMuXDXywYWvF2Ffvh3Yas4kdb8aXV007Q8N2MhWkGpGedZ3WJJGQN/euWSt7+br73YO5p2V6EO0tpMuSiV25hKz5HWtMqN9HpfFA1KK+pBrvbtRa9i0= 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=LnOKs7s0; arc=none smtp.client-ip=209.85.216.44 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-f44.google.com with SMTP id 98e67ed59e1d1-290b219a60cso893699a91.0 for ; Sat, 27 Jan 2024 08:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706372355; x=1706977155; 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=GSirNz5MKgvKyg3PpEGC1NXiMt4KceVCwKab+ZPE5BY=; b=LnOKs7s04JnW2pbRtAMDtY66UPBwsdvJPAfs7w7p+AnLEOqr7PQmBTpV1MNYfIJPHE SfigJzaP8BZOmEMli6WUhUADWCug/hLSJKnswN2Wsr2CABf7PWOx7mr2q8nrPpb7dTlr oqYBtq7McqAKGDj6ecyZdwVGozlurnj/sta3Kt6ccJ9jZOBr1GQk0QiJbQUxgKHQ1ykf 5IxdWRfSCta2KbSucCtR9BVevvfZiktFUCYsXhAhOjgq0sHjk7BYbLBfWP4bsve8PeeU bITog5O10wPmkIIrSYRM0gGb0kbYghGEXInHA5ImMBtcN1aDwJ0jbsc3saTIaFBCif6o eltg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706372355; x=1706977155; 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=GSirNz5MKgvKyg3PpEGC1NXiMt4KceVCwKab+ZPE5BY=; b=iPNeJ0ZGhl5dk8awHOPdAgFdQ3UZr2b+B1Hcm0Mp+aiHZYVcLTKl5fRpeWQpJx6xKp JU5FTuwJHEjHRDl1hGnQZuKGTvY3THu7khodSA4/Z30kjR1q+LRoBB1rboB0UzQEFu98 sckkhrQ15/+xPg1da9YV6qxri+JfQJzYt033uUKrhHvSmc0mD1+B80PCj4fbeM7kMUS7 6NpTvlyHDPgx/FVA9Fwh8WqEYN7o0vlBwtK7vpyRB//a7qzLRUTMYMMU3U7fmuR3lNh9 x4Rmk9OIaJwsH5hRAg3iARmlotbD+pBlKYWHKWYvvWe2bvSWgU+r8vkN4j1oDM2mfh9o pT4w== X-Gm-Message-State: AOJu0YxE22MbUUUvkK9400Vj8rFTSigNauJePOvwqzTfWG6yQmT7beL3 tXTq3pUyBrbspq3C/mZtUXahgY9vHISHxQDPdWd/XoxjpZqNwZ0A2MBa2+qkBJE= X-Received: by 2002:a17:90a:a606:b0:28c:fec9:f205 with SMTP id c6-20020a17090aa60600b0028cfec9f205mr844337pjq.29.1706372355334; Sat, 27 Jan 2024 08:19:15 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:19:14 -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 10/25] genirq/msi: Optionally use dev->fwnode for device domain Date: Sat, 27 Jan 2024 21:47:38 +0530 Message-Id: <20240127161753.114685-11-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789261261468049591 X-GMAIL-MSGID: 1789261261468049591 From: Thomas Gleixner To support wire to MSI domains via the MSI infrastructure it is required to use the firmware node of the device which implements this for creating the MSI domain. Otherwise the existing firmware match mechanisms to find the correct irqdomain for a wired interrupt which is connected to a wire to MSI bridge would fail. This cannot be used for the general case because not all devices provide firmware nodes and all regular per device MSI domains are directly associated to the device and have not be searched for. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/linux/msi.h b/include/linux/msi.h index fd184309a429..ac73f678da7d 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -552,6 +552,8 @@ enum { MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 5), /* Free MSI descriptors */ MSI_FLAG_FREE_MSI_DESCS = (1 << 6), + /* Use dev->fwnode for MSI device domain creation */ + MSI_FLAG_USE_DEV_FWNODE = (1 << 7), /* Mask for the generic functionality */ MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0), diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 8d463901c864..5289fc2c7630 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -960,9 +960,9 @@ bool msi_create_device_irq_domain(struct device *dev, unsigned int domid, void *chip_data) { struct irq_domain *domain, *parent = dev->msi.domain; - const struct msi_parent_ops *pops; + struct fwnode_handle *fwnode, *fwnalloced = NULL; struct msi_domain_template *bundle; - struct fwnode_handle *fwnode; + const struct msi_parent_ops *pops; if (!irq_domain_is_msi_parent(parent)) return false; @@ -985,7 +985,19 @@ bool msi_create_device_irq_domain(struct device *dev, unsigned int domid, pops->prefix ? : "", bundle->chip.name, dev_name(dev)); bundle->chip.name = bundle->name; - fwnode = irq_domain_alloc_named_fwnode(bundle->name); + /* + * Using the device firmware node is required for wire to MSI + * device domains so that the existing firmware results in a domain + * match. + * All other device domains like PCI/MSI use the named firmware + * node as they are not guaranteed to have a fwnode. They are never + * looked up and always handled in the context of the device. + */ + if (bundle->info.flags & MSI_FLAG_USE_DEV_FWNODE) + fwnode = dev->fwnode; + else + fwnode = fwnalloced = irq_domain_alloc_named_fwnode(bundle->name); + if (!fwnode) goto free_bundle; @@ -1012,7 +1024,7 @@ bool msi_create_device_irq_domain(struct device *dev, unsigned int domid, fail: msi_unlock_descs(dev); free_fwnode: - irq_domain_free_fwnode(fwnode); + irq_domain_free_fwnode(fwnalloced); free_bundle: kfree(bundle); return false;