From patchwork Fri Nov 11 13:58:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760574wru; Fri, 11 Nov 2022 06:09:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4TC+c5BY23wAHN4e1nP5ie/sFXMmiqm+sBIsPpejffBRbdABnbgOEdAbdCOfJQr0iDn6ly X-Received: by 2002:a63:4146:0:b0:46f:8c3a:8b2b with SMTP id o67-20020a634146000000b0046f8c3a8b2bmr1816644pga.477.1668175746582; Fri, 11 Nov 2022 06:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175746; cv=none; d=google.com; s=arc-20160816; b=ajsMbKJp0qTWFF1GDjq32+MB14WQAwthw6CBrE7/UEL5vC0M90bIomwvOsvq6CA4Lp AWB17EwzQ49km5w0GnQmA4ilazL7xNoiQ+JOy0mGDg2ICZO2czysO5h50ZAwgsvvIOqF 2a0MOhFEwp57WhJVn+5sAY/ChrF5Z8ynWApsFJtGtL6peKFclL/8xpNxur6flszzfdaj EdxuppfNtCwC7dEkfinbeBKZZgA822/EW4G1UVcg5hiYWJABkCIz31Jt3BDlOcbQzbOk YVjUfoqVlyE4C4FGMJtgNr8E8eWwL5rT2OQxm5w6+OvtownjNfviA/EZTBXBj1gBbwDr vpjQ== 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=JjWom/9kwklaxMWDn9npHnU2VscMDs0fiXQjZmDEcT0=; b=wC3zklymvqhpG0znMrfWJkNaeWcFwt2K1jqaUmFQFF+qKIJxSEDbOC01TGIEA+alGp sjt9uvDk0b8R16/aVGr8CdmV1tYKxJxhro/GMm8oyl6ds8YRx648BoNOs6yyGBg+Jya1 q8Ras4hLgfhaML6TPIvksq7LcBR3bs82gmatASRBe1nT45PqcuQYIltlTRcl7RjS8n4w bqSlRIKdUc44ArNk+qXrwptpWz5HxTmpQkEg4LfVIve1q1bR48abCWfrGwAPCbZDRUHx RkCZMKrg+nI9J7JFGQ1Y8VtIKUY4VSdyfdNsTBkOHVuNgoluXlDyhyRBiQBHiimcyoSg lk2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ahkaO7sq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="+b/g6Jio"; 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 x8-20020a63cc08000000b00451b094d74bsi2198494pgf.454.2022.11.11.06.08.52; Fri, 11 Nov 2022 06:09:06 -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=ahkaO7sq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="+b/g6Jio"; 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 S234448AbiKKOIF (ORCPT + 99 others); Fri, 11 Nov 2022 09:08:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234536AbiKKOHE (ORCPT ); Fri, 11 Nov 2022 09:07:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D79F677237; Fri, 11 Nov 2022 05:59:54 -0800 (PST) Message-ID: <20221111135206.632756918@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668175130; 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=JjWom/9kwklaxMWDn9npHnU2VscMDs0fiXQjZmDEcT0=; b=ahkaO7sqkimzmk6FJeJUgu/hLpTvx0v/QYQSZDVSusTaHvT0AS0egLjhY0gDh9d3l7aC5d JOCmTrDecGH6fwBAzw81LaIpP0SIg7GG8lJDwKV+qyF7Sq8ywytE/fn26YUPKNgjIwzeaM 8zoBtB6JFML0TVmSjs8+oBmDJc+QXr8idQ6jUzLfVO98s9998QWH9LCb68ozS3+8KJefaZ ZgZ9pWA+j+qSJZPCpS3plvrNZFxh6t8USlKyvenpxR6i8WaxZ9lL8CG4mQvgbbrr4Qs4Jj pG0pgHTaDcJYDRXxMEWwsavIilJDioMvqc5HhYkc2sORGFDaLpF4ad63CTuMXg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668175130; 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=JjWom/9kwklaxMWDn9npHnU2VscMDs0fiXQjZmDEcT0=; b=+b/g6JiogzgLkTDTxXLbWJyXPVwUYqVIHPR/EvFzo1OTXU0ubv9AkPFRSAfcBNkcO3NUnG yiwORE0zYF02WvAQ== 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 24/33] PCI/MSI: Provide prepare_desc() MSI domain op References: <20221111133158.196269823@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:58:49 +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?1749209052120306999?= X-GMAIL-MSGID: =?utf-8?q?1749209052120306999?= Dynamic MSI-X vector allocation post MSI-X allows to allocate vectors at a given index or at any free index in the available table range. The latter requires that the core code selects the index at descriptor allocation time. This requires that the PCI/MSI-X specific setup of the MSI-X descriptor, which is partially depending on the chosen index happens after allocation. Implement the prepare_desc() op in the PCI/MSI-X specific msi_domain_ops which is invoked before the core interrupt descriptor and the associated Linux interrupt number is allocated. That callback is also provided for the upcoming PCI/IMS implementations so the implementation specific interrupt domain can do their domain specific initialization of the MSI descriptors. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/msi/irqdomain.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -202,6 +202,14 @@ static void pci_unmask_msix(struct irq_d pci_msix_unmask(irq_data_get_msi_desc(data)); } +static void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg, + struct msi_desc *desc) +{ + /* Don't fiddle with preallocated MSI descriptors */ + if (!desc->pci.mask_base) + msix_prepare_msi_desc(to_pci_dev(desc->dev), desc); +} + static struct msi_domain_template pci_msix_template = { .chip = { .name = "PCI-MSIX", @@ -212,6 +220,7 @@ static struct msi_domain_template pci_ms }, .ops = { + .prepare_desc = pci_msix_prepare_desc, .set_desc = pci_device_domain_set_desc, },