From patchwork Mon Nov 21 14:37:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627921wrr; Mon, 21 Nov 2022 06:40:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf7x9rmhZKjG79Vj8lDfd+X4BWgTBb9m5i2x3XItXy3itwfe/+K0oSRz/E8l1R4IQoHeIry+ X-Received: by 2002:a63:2144:0:b0:470:8a45:32a8 with SMTP id s4-20020a632144000000b004708a4532a8mr17442961pgm.543.1669041619337; Mon, 21 Nov 2022 06:40:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041619; cv=none; d=google.com; s=arc-20160816; b=chdm4XPNuMpnRlibatdR3YHEMXaAcUSnzMTMotEO5sk+lLHF3smVSLXOBITbDlt5WG 2XxMr9gkjZAO2Dybpzfs7YtiYbVYuZuxPvShjCn7XHDW0SIdJA6Vaue9Az1fiwgBf/w8 YL58bVmP/fCz4YXoxq5E6LP3v34C6XUVEq+O/pbHw936f/XAyt/v8ia2YfRCravP+paC Q4kJ63SzWBCO7zjw9EnWZ0Rb7J+RYukPg0PLK4ChQwVYvir2pNXC6h+DFyqxxZr4N85g nu/2vNQgyY5Ixp0l4aj0RSimhBabfCMgCq5pBPlGA+zZP8GiSZXAIifRRSzSRbhRrgzy uEIw== 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=dNla760VftgKp2xT4MRMyY8D/XKPi4S0TfNof3crvXM=; b=OinHCzwJD3kV3/a+eHRA4QyRAEVbzUO2fJYYHySlgzjh39/kOSunxtj/g5TZw6gV+1 DFtVsIQ1nBdNSw2fJtNVvoYz/3fHgo+AUXcxmTbQurHvDlnQW1O6v5XFN9PVKbaCBbQj 3NBytGpDFBDP62bCs4lmSjulSJ7EgVZhADnGIAoLdoDr8qw/o1E0wor9nDbmboHimyg9 /o3qaJPDBedsqAde5xZ652f55macW5oc1GD9VuV8mIVDBwQPhlVzYhNqnJst+F1sg29R WQgXoxgi2o2PUJ/K0/OKJ+zQpxyHdIFsfyQnfjcAM8Z41/u0NQUtW4vGcwHD94F0s0Hz uTCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=P+HYXuVq; 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 i8-20020aa78d88000000b0056e48944895si10557280pfr.317.2022.11.21.06.40.05; Mon, 21 Nov 2022 06:40:19 -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=P+HYXuVq; 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 S231800AbiKUOjf (ORCPT + 99 others); Mon, 21 Nov 2022 09:39:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbiKUOh6 (ORCPT ); Mon, 21 Nov 2022 09:37:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13ADC1EC; Mon, 21 Nov 2022 06:37:58 -0800 (PST) Message-ID: <20221121091326.938173210@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041476; 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=dNla760VftgKp2xT4MRMyY8D/XKPi4S0TfNof3crvXM=; b=P+HYXuVqYFhqGfbPERnzjNDCBVcKkJNXxsNo4ft1ia61H91Q3hdAryUicSolv5BMOUp0UA JXz/7ubQ152DLVF8uJsQsbyoPug1bkilzs+gI6+dJTmbFEynVGmOtmP5sDStayCZcqfwJO 9rsqkUGjGN1ohYfKR+E8JxsVaidNqMVDRlgw9c9VIe8uJsvNWezISe2NJQ9yC0XmGH2a2F iPM8XUvr9N90AtoH+eBqRSb7C1L49FUOHGvGXgS2LK/fplfSj2AiLil6PYz8v/kXt9ZtG+ UNJNaqMKvQFfenF7eDYFhIx/TGsn97SqIhfxj/eQU33BDJuOX+55rYMyt7s/nA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041476; 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=dNla760VftgKp2xT4MRMyY8D/XKPi4S0TfNof3crvXM=; b=WLGiQULCYKxQSd1OjNwNkXBQuflUzZVliowZe+kfm4peS/o+dR+N7F67JTaTt2BpCs21jg /NFLqHdQ54tSU6Cw== 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 V2 08/33] genirq/msi: Provide msi_match_device_domain() References: <20221121083657.157152924@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:37:56 +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?1750116984857321608?= X-GMAIL-MSGID: =?utf-8?q?1750116984857321608?= Provide an interface to match a per device domain bus token. This allows to query which type of domain is installed for a particular domain id. Will be used for PCI to avoid frequent create/remove cycles for the MSI resp. MSI-X domains. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 3 +++ kernel/irq/msi.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -542,6 +542,9 @@ bool msi_create_device_irq_domain(struct void *chip_data); void msi_remove_device_irq_domain(struct device *dev, unsigned int domid); +bool msi_match_device_irq_domain(struct device *dev, unsigned int domid, + enum irq_domain_bus_token bus_token); + int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid, unsigned int first, unsigned int last); int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1021,6 +1021,31 @@ void msi_remove_device_irq_domain(struct msi_unlock_descs(dev); } +/** + * msi_match_device_irq_domain - Match a device irq domain against a bus token + * @dev: Pointer to the device + * @domid: Domain id + * @bus_token: Bus token to match against the domain bus token + * + * Return: True if device domain exists and bus tokens match. + */ +bool msi_match_device_irq_domain(struct device *dev, unsigned int domid, + enum irq_domain_bus_token bus_token) +{ + struct msi_domain_info *info; + struct irq_domain *domain; + bool ret = false; + + msi_lock_descs(dev); + domain = msi_get_device_domain(dev, domid); + if (domain && irq_domain_is_msi_device(domain)) { + info = domain->host_data; + ret = info->bus_token == bus_token; + } + msi_unlock_descs(dev); + return ret; +} + int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg) {