From patchwork Fri Nov 11 13:58:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760772wru; Fri, 11 Nov 2022 06:09:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AxpT1046FwDItEMXILxuVsEza5HVbM9c+MbKeTgAILWEonprCBWuHsHtxnJN2C8n0d40C X-Received: by 2002:a17:902:9684:b0:187:4467:7aba with SMTP id n4-20020a170902968400b0018744677abamr2427983plp.61.1668175766274; Fri, 11 Nov 2022 06:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175766; cv=none; d=google.com; s=arc-20160816; b=n3I/I4gTPkrghELHiXhIapmusgcAjuUKzDpFar4PSmyfVhw14rhAkYqM//2Tca7UMF NhoD0Y9ZncVpDTsRqS3J2hrV27aS/rxSWLyMR3uAUlMawJhYRIIXcnz38a0tJ9Udg7VD lAqfxWUaWtbLj8mdnlddOQtgxGnHrruPZJWV+LRiLA176p6Zi73sIyrQKxV7qkD6B4n7 /aTznZS2lqHmLKRDvXLtld1VyRpiAOdNhCeU6jpsAr0CorpcCFQP858hRC/Ti2bVTLeS nMeilofAIkRqKqkSDDx/CNrOv1Gh6x/H1JTU1QfcM6AfaNfcVK0FD5H0aOQaxdlt5JHL dqTw== 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=cGLnImP++QaosYDzBZBUnGto50NkhFSNjBnCsi02MnQ=; b=1CI5s4JbsD5rgBXXq79M055z5vZQAbuwbyj6gq1C0oP7F93Gz9/JE0A/b02pVJP2bS vtbU97AaA/t79sHfTwXsdrAwMhbTUWcd0c+CDLl12Hdz1i16HzDUNbfVgGda07TZBzng qT93Rwh7ryFuH7itOdHjqA4RDHsTHylXEkEjEX+nGSQl5HU37yNPAauUdlYRGIa6bMOv C1Ds/uxLkaKrxMgmBuAR6+QjtUrmzPox7MqQumwgVAS3kyBQhEe8Psu6JypzoDUZXVYx oQTFWdz3+GOy+S03ko4gi+mhgxNjBoWLvSgQTQPjIWTKBjgW9OIlUHrXHYosD3yLNcXC bevw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qfvperWG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=v3L5zUf2; 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 189-20020a6306c6000000b0044fb332e9c2si2416081pgg.560.2022.11.11.06.09.10; Fri, 11 Nov 2022 06:09:26 -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=qfvperWG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=v3L5zUf2; 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 S234477AbiKKOIQ (ORCPT + 99 others); Fri, 11 Nov 2022 09:08:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234602AbiKKOHM (ORCPT ); Fri, 11 Nov 2022 09:07:12 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC7C78A8D5; Fri, 11 Nov 2022 06:00:01 -0800 (PST) Message-ID: <20221111135206.406883343@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668175123; 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=cGLnImP++QaosYDzBZBUnGto50NkhFSNjBnCsi02MnQ=; b=qfvperWGjkfJNozEsSouIgE/VudvhsIG+is6vXIvkjLnCjmFki9GuooJijW/Cpw6Qc+yDt qIXGBdaoV4Zeh5D6WGe19uU39+vMnK6XMJzCY4jzDKeWfMLyA103H++zWnsFbqQTHP3MIm PkLVBpHRAQimzZJ1O3wPmXgumKW8NGCNmc4FsUa6XzpmC1UD7sZ1SKD2cZH0cXjm99iBjI F1f6fFs0r3O6aTYjC6xt03EcNAe/OvYD5OLQ3oACZM+pkVrSiFPfQ6G5Z8ArVHIn3QOHR/ A7Z22jQVC/K94tgBn4t2mWhn0rqB1wMkTrlM8Ryd3+qtvxpeQ/MX0GN29/pmaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668175123; 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=cGLnImP++QaosYDzBZBUnGto50NkhFSNjBnCsi02MnQ=; b=v3L5zUf2VLairh9ucPPjVk/k1bfNBGpvEaxB1GV5CF1yCXHMMLFwnrchUDBnz30PbLtKuc J63HQhQgwqN53MDg== 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 , "Ahmed S. Darwish" , Reinette Chatre Subject: [patch 20/33] genirq/msi: Provide msi_domain_ops::prepare_desc() References: <20221111133158.196269823@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:58:43 +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?1749209072554097289?= X-GMAIL-MSGID: =?utf-8?q?1749209072554097289?= The existing MSI domain ops msi_prepare() and set_desc() turned out to be unsuitable for implementing IMS support. msi_prepare() does not operate on the MSI descriptors. set_desc() lacks an irq_domain pointer and has a completely different purpose. Introduce a prepare_desc() op which allows IMS implementations to amend an MSI descriptor which was allocated by the core code, e.g. by adjusting the iomem base or adding some data based on the allocated index. This is way better than requiring that all IMS domain implementations preallocate the MSI descriptor and then allocate the interrupt. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 6 +++++- kernel/irq/msi.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -379,6 +379,8 @@ struct msi_domain_info; * @msi_init: Domain specific init function for MSI interrupts * @msi_free: Domain specific function to free a MSI interrupts * @msi_prepare: Prepare the allocation of the interrupts in the domain + * @prepare_desc: Optional function to prepare the allocated MSI descriptor + * in the domain * @set_desc: Set the msi descriptor for an interrupt * @domain_alloc_irqs: Optional function to override the default allocation * function. @@ -390,7 +392,7 @@ struct msi_domain_info; * @get_hwirq, @msi_init and @msi_free are callbacks used by the underlying * irqdomain. * - * @msi_check, @msi_prepare and @set_desc are callbacks used by the + * @msi_check, @msi_prepare, @prepare_desc and @set_desc are callbacks used by the * msi_domain_alloc/free_irqs*() variants. * * @domain_alloc_irqs, @domain_free_irqs can be used to override the @@ -413,6 +415,8 @@ struct msi_domain_ops { int (*msi_prepare)(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg); + void (*prepare_desc)(struct irq_domain *domain, msi_alloc_info_t *arg, + struct msi_desc *desc); void (*set_desc)(msi_alloc_info_t *arg, struct msi_desc *desc); int (*domain_alloc_irqs)(struct irq_domain *domain, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1275,6 +1275,9 @@ static int __msi_domain_alloc_irqs(struc if (WARN_ON_ONCE(allocated >= ctrl->nirqs)) return -EINVAL; + if (ops->prepare_desc) + ops->prepare_desc(domain, &arg, desc); + ops->set_desc(&arg, desc); virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used,