From patchwork Mon Nov 21 14:38:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1628333wrr; Mon, 21 Nov 2022 06:41:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4pbojHtScYT8MnA3bsXzmi0Bcbqmk8XsyR3/zAu+4xdE9og9SNG7toqGSXssT6i0zYbRzY X-Received: by 2002:a17:903:41c8:b0:186:5eab:8631 with SMTP id u8-20020a17090341c800b001865eab8631mr336125ple.134.1669041664946; Mon, 21 Nov 2022 06:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041664; cv=none; d=google.com; s=arc-20160816; b=ymOhN07iWj9hibDUIWtPXVreIak5Kni+Cq6aTnyFn0NMUcC0Iyf6r6P0+6JRBOBvyP 0K3A6r6ORO4tYR17zw8OC3iDY6CN01VQ11Lq0pQolhRmdD2xYE6VLvKhz/K2+6oU7T5x Zp+pMeq0v/q/hM5QrmNF52pMuVLtkQkPsjn3FGLqKp4hsPDPZIGjYVRdQw29K8F0AkUG SvHfEJ7e8e3/R5ixSrPaV7uwXqdUbEHRSD1EsTDoLFmVH0LPJepRc7h8cI8HaBggRHYJ azQtA9utaa/xMAt2AYcf1lgVOf61yuT4VNU2Ry3YAhRoSZPErgxYVmaEF1JoLOu3unoE yEag== 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=1Ia7eZriEUpBkiV/NLqg7niZ6fMKSxoDJkKbYDvtHyI=; b=gG5EYHGLqKplEo1XyR1188wamvp0egaRcHDXb0Nn51src7ykqTkVaNSnKaAcvn5bA0 daTIGKi/dca6ax1YD96JZGEO5772w00FOxeP/bZ2RHkR5rFxC9NHGOaDoopMcNWKbHzI s6asnTtgsAOFHqrvjl985kB1SgKw8zn6OSdk6nbeN9JKGpnb+KnajuG0gJGWr37HkXa+ pNsRS2LlxtrPFu48/V66j2HS6N1SQsHF0iONdkliWZDNtC2RFT6G69eeVHcCCFkbpUcU NE9kXx0l+p+1J6jcEDYkN/YJUuFJhsIrzfatJmwoFMygHYs9pZ5fX2FaStOI0/EFN6TK C4rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4ALiouWm; 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 dc8-20020a056a0035c800b005732e831bbbsi8620438pfb.336.2022.11.21.06.40.49; Mon, 21 Nov 2022 06:41:04 -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=4ALiouWm; 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 S231548AbiKUOkW (ORCPT + 99 others); Mon, 21 Nov 2022 09:40:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbiKUOiN (ORCPT ); Mon, 21 Nov 2022 09:38:13 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A209FC7687; Mon, 21 Nov 2022 06:38:12 -0800 (PST) Message-ID: <20221121091327.604532862@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041491; 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=1Ia7eZriEUpBkiV/NLqg7niZ6fMKSxoDJkKbYDvtHyI=; b=4ALiouWmVkPRnT0vTcSPsOaIdfz4pn6W50xbL45ycypOo/a78qwl3e4jYa9vI28IfBmqlD FDnvxoiuLyiB9PmRDyjIKiLV8pvbWdhvgwD0p/bSalOqrXyEs2OoXTWzXgAr4fdrshc4Gu g7e49ttJnijI06uYdFUELqJb6GFnAitKSHuT8tYoe3tt1nAdhJ/uRUqgQytgH2qkSBf5W1 R+r+4+uvLWXIkylOfnDsRadgug9ShopI1nm54EloqDXQW/crZdZNZ7BpOPFQy9LDpYXiRV xreGFARzGdap8ROM1ZHuk1FQIm1MjhX/0/GOuCRkDhn/mCSEgPYOd6wRK9V9lQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041491; 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=1Ia7eZriEUpBkiV/NLqg7niZ6fMKSxoDJkKbYDvtHyI=; b=AxaLkvG0WXuwHg5a829R4zwLLIr7zTby4dzJQ5g4oyZ1A/gtehkDNr3C+ECAXdMfwXzlIT YSlZB34oKn7fdsCA== 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 20/33] genirq/msi: Provide msi_domain_ops::prepare_desc() References: <20221121083657.157152924@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:38:11 +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?1750117032672576802?= X-GMAIL-MSGID: =?utf-8?q?1750117032672576802?= 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 @@ -402,6 +402,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. @@ -413,7 +415,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 @@ -436,6 +438,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 @@ -1285,6 +1285,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,