From patchwork Mon Nov 21 14:39:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1643019wrr; Mon, 21 Nov 2022 07:07:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WW7NVUD4KHD6hLC4yZ2XqKY/EWOSYpqb1UxkcD7+GfIJp97ZvRRzO02ad0irWZs1ZxQRp X-Received: by 2002:a17:906:9c47:b0:78d:8fa5:c326 with SMTP id fg7-20020a1709069c4700b0078d8fa5c326mr4070384ejc.25.1669043220110; Mon, 21 Nov 2022 07:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669043220; cv=none; d=google.com; s=arc-20160816; b=kHX1AJRHfQg+uX3fTxqdo4/W8kGxtfLU9ZSdca+wTgd3A2Iy9JBa7C/kKfd8x2xlOH PkLBKS6sf95uqMqwdAKsyy7zri96KBee5iInas0ZtOxZ2JjAhhmtnAXjGVifizh5ttWx w2t/KaX1vDFOCg+aJxU/kX28ooorX5RSXzKRgY5axEhjS4SjWqO16qVJPQoZqsdRrO9Y RWZhVbbor/p+vL+XUNgBrgSGtSCVYkgyyvox66RwxJjDO/+1scEd2/lfIFIQXa5nYCoa 01S70Iksa3SZovA6vUkS+ec1gG8j/2EjO7Pg+4xx2z5e9MWylvUlOS+6W3SQJnq2xtsu s76A== 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=JA4DJhkL/SLZbiCPUtuJ/m0vEuiHsTx0BFOI4LdR10Q=; b=Iln/zkQftHASvaHrisFXaw8VWin2T9OxiQG7BMIAZgoAZ0aobolH8up0aaJXm+t/un LemV7Wi6UbsaEcN5+YV+doJ+l/MvEnJasUvYGKa4+22Uxif0xYZyZJF4sHIgUHeVvzNa GWsBJ7DOKsjlwovEns32hYlknCSbbOTQRxsLx/5pbNwDG7CjhDiH9DrMkqYURFcY+LTo n1LXvgxPfNYpXkGx7JF1sYn/KPVk+FPNp5lWWA0mZ1bgVdWxp2hZBTeB4ECpX1oUsu4F dD1E+gD8kp4Xi5wl3WUYF/ug1Bx5fY0Bm07BprrgPN3aEKomg1IVAQCmpTeSGHJYv608 fk+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="ydxHf/DS"; dkim=neutral (no key) header.i=@linutronix.de header.b=tpDw1REh; 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 t15-20020a056402524f00b0046714f73377si10202086edd.293.2022.11.21.07.06.11; Mon, 21 Nov 2022 07:07:00 -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="ydxHf/DS"; dkim=neutral (no key) header.i=@linutronix.de header.b=tpDw1REh; 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 S231297AbiKUOtu (ORCPT + 99 others); Mon, 21 Nov 2022 09:49:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbiKUOsO (ORCPT ); Mon, 21 Nov 2022 09:48:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B15D33B9; Mon, 21 Nov 2022 06:42:10 -0800 (PST) Message-ID: <20221121140049.617825672@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041595; 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=JA4DJhkL/SLZbiCPUtuJ/m0vEuiHsTx0BFOI4LdR10Q=; b=ydxHf/DSO9NqBzlSdDCOGZV8yc29f1kRL496Hy5wKB99tucPeKGC07lk3cKpyK9+2COl8c hjpk4rku7hZme1xQb60Ze8od18AYw/U/L2FQTdDLhNWxF1q2REtqR5/VICsDuxiJDB+qC0 lePu9FthiNaXK0Rayd8iIfrfZy6hntLOUUWK3SvBG0wHXaB3rlJfUg+mmaV1yVMogOQ0qO iyNdELpqvPfrCQ2G9j99NQ/+0mbIKlUkx7U34Vo67IglWB5tvwZKq+IEfLuluvvIjHQSQs ovcOyuCpqFarEwyiIVojI+sCJBBvrZpvQMmJdRhtj7dFDiaAwRJeSDubKzD7Wg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041595; 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=JA4DJhkL/SLZbiCPUtuJ/m0vEuiHsTx0BFOI4LdR10Q=; b=tpDw1REhwrgyCWZKJtswkMSb0d8Ir1QxPnOwIaV2QLUMOPSg/Ophl8ZWx4MgtiwRW5aUTF J3CTK4CKHP0XrJCw== From: Thomas Gleixner To: LKML Cc: Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Ammar Faizi , Robin Murphy , Lorenzo Pieralisi , Nishanth Menon , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Vinod Koul , Sinan Kaya , Andy Gross , Bjorn Andersson , Mark Rutland , Shameerali Kolothum Thodi , Zenghui Yu , Shawn Guo , Sascha Hauer , Fabio Estevam Subject: [patch V2 21/40] genirq/msi: Optionally use dev->fwnode for device domain References: <20221121135653.208611233@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:39:54 +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?1750118663911727740?= X-GMAIL-MSGID: =?utf-8?q?1750118663911727740?= 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 --- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -536,6 +536,8 @@ enum { * handled in the core MSI code. */ MSI_FLAG_NOMASK_QUIRK = (1 << 7), + /* Use dev->fwnode for MSI device domain creation */ + MSI_FLAG_USE_DEV_FWNODE = (1 << 8), /* Mask for the generic functionality */ MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0), --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -998,9 +998,9 @@ bool msi_create_device_irq_domain(struct 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; @@ -1023,7 +1023,19 @@ bool msi_create_device_irq_domain(struct 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; @@ -1050,7 +1062,7 @@ bool msi_create_device_irq_domain(struct fail: msi_unlock_descs(dev); free_fwnode: - kfree(fwnode); + kfree(fwnalloced); free_bundle: kfree(bundle); return false;