From patchwork Thu Nov 24 23:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3663369wrr; Thu, 24 Nov 2022 15:35:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DY0M4TWF2hiQH8flFaTUb94nmY29ZVtEn3M/UcxfzjYuocbpgRiQ9nKQGVmjP5AYVfZmC X-Received: by 2002:a63:1151:0:b0:438:a750:99b7 with SMTP id 17-20020a631151000000b00438a75099b7mr13316712pgr.605.1669332953958; Thu, 24 Nov 2022 15:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669332953; cv=none; d=google.com; s=arc-20160816; b=PHaHnsJ1g+IGSHGLLiqvlnCVGBa2HuAwDllBgTg95hSFJsBHTD2sPb8E2+cWcWpEIn fPY1OgggSH0ipPG5cGWaDG+OyMy0WmzFPdIfbnC+CObkuz51FOt86d2PBAPTqkz3UGS6 CBX94oppXprAEGvm8RjzDFIE30HJhahruWjXTn+jxorg2Vr3cKg31IQN2xljjKuxbcEk Rv5lDJlrsdTtXRG+gNWBJNbs0A03qPXhnvvrThCa8K+yOS2nGDbJ7dv81DF8VU6rzq26 M2CIKwll/MO2H+G70Ul7EW842W23GzlKVAQz3uZ0kb5H7UFpgo0bhFUhcKI2jb4ws1rb NCFA== 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=SwZQXuxaOnLugPp7faog3c8WnwPvQUn41gyOKCZSnRg=; b=nouoHiLxpe+MDFtwDwoJev2FT99ga4pRyH6Q4oMUKCpkZJPCnqr5A2MGXHD6Bto5/d 1JvDnoREBgIAWaAI1pZ4mfv8mPsJy5qyQBQ84gOWVuuuca11e+hY/y+AIVOjnX8eSbop dM9vQ6TTJ4fBUcBiF9PN+fWpOog6k4zXoA8t5t93DZ/4nUe9ds3xzLL0k6bDqi4x6e0s PyNyzASduhNUFJgnbMsqGi2qM12WzSlCJzTykBrFRqobE3AAw8JDSqIfJkQ0yBjZV6Ee yLFcvHWsy3zsfCehgpGrYwls1FEfAhjjVPn9jeQw+YwAHZBe2bL1MbdJ03uutIGI6y5j f3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="z/qUj+0Z"; dkim=neutral (no key) header.i=@linutronix.de header.b=VVq7nShs; 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 p14-20020a635b0e000000b00476bfca38b0si2401824pgb.71.2022.11.24.15.35.40; Thu, 24 Nov 2022 15:35:53 -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="z/qUj+0Z"; dkim=neutral (no key) header.i=@linutronix.de header.b=VVq7nShs; 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 S229895AbiKXX3X (ORCPT + 99 others); Thu, 24 Nov 2022 18:29:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiKXX2q (ORCPT ); Thu, 24 Nov 2022 18:28:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89117A659B; Thu, 24 Nov 2022 15:27:11 -0800 (PST) Message-ID: <20221124232326.444560717@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669332377; 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=SwZQXuxaOnLugPp7faog3c8WnwPvQUn41gyOKCZSnRg=; b=z/qUj+0ZX580lDfONL6nr+qyUfMMm+bqwfYDl3W0KqLSqd1NP4i6neAwJybpfqu8swNAXn VHPxTVfg/R0+HDZ5NeoOaAogMPL7LGi96EnA1kTIEn/QgHPP0ljuHKtyQXcat2Gb+VNdl7 pzBncxrUqou4blZzJ0sNFSUwbn0xGDORcf8GGwppOxsGp0Q+f51bLNQlI4mHTMOwnZNtOG tGhKSbUmH/pEn40O4efPSXEMRFJqz2HqplLt6FWKCfPTDs2ODY2qMzo0fam+ofvhpj3Ucn QJCX3Gwm+xNkwWI94KR0oDF0ym7Wr6Wwj2TqVsWqrAJmavVuj48GBBAhzUssFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669332377; 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=SwZQXuxaOnLugPp7faog3c8WnwPvQUn41gyOKCZSnRg=; b=VVq7nShsZR+BBAI9DISoLr6eYJjlRI40UorrLD+fHB21R+wkHEydKh7dWrYS+rrFOYOZDr bPtALm88nUIlFtAQ== 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 V3 20/33] genirq/msi: Provide msi_domain_ops::prepare_desc() References: <20221124230505.073418677@linutronix.de> MIME-Version: 1.0 Date: Fri, 25 Nov 2022 00:26:16 +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?1750422471516626939?= X-GMAIL-MSGID: =?utf-8?q?1750422471516626939?= 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 @@ -410,6 +410,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. @@ -421,7 +423,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 @@ -444,6 +446,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 @@ -1260,6 +1260,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,