Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9644065rwb; Thu, 24 Nov 2022 16:32:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zekLIUv1hQtURW2nRunNuE5b0ecRL5GAuxQWBt+ht5+7rOqwkWWisLw9XRE7Me6tFwM+E X-Received: by 2002:a17:902:c206:b0:189:502e:4ec8 with SMTP id 6-20020a170902c20600b00189502e4ec8mr8448371pll.134.1669336379293; Thu, 24 Nov 2022 16:32:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669336379; cv=none; d=google.com; s=arc-20160816; b=TpT7ga2uh8MScm0jHGBb0CBlT4iYbROoLIheuy2nfW0YeUI0RDJxzmZ95fPcMbIVRv 4yBv4gCLkagFa6giqd/SnYR2LE1tSfHsvL7HwLWqFSb3Wd2sn009h7IYgPaE83HFbYYp cMiH0nE1rc+CFlqAAyMDttoB3qW6+32kQXtVtLQ41m0jL/3kbiUVPpRs+q7Gg/6Zj+Nj vfNf++YrC0HWZdNn2okl9VF0MIMaFz0hj3Qg9DUX3uGZhtliR9edjXsD+EjaXuS3rmkT 2y6t2raX9S6a8w6sVMCEquojU4yyNEO35bOxNEA+iejwcwOEW3xaGEOCG8bpYadbPTPG SjAQ== 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=TlIkyzTTSvqR6KrJj1PQdSVRNaBSTUiGHoaI0+IdJ9c=; b=KoOTCHsaGESZaIgGJWP/0VoZKo/ZGFRI7ZFntPF7mBgZLhJqWmHOJUrAQVKaqBTCfQ m7lwEyTFKg/IQg3Aw4AYV4bF3qPkRzXCZ+xh2pHSpHAhjHxuHsq91dffT94bCrqLXX50 GN0oIuwIHVv1xkDIc7BQGbg3IGbTguDerQRi3/B/YGa88kMC8KxBmzIhJQSUbA1lm4yD +DOBbljx9quxQggi0P+DC/FHcc8LLFJK1IGxyKlU4hQTpm+cGLOld7rRGOaLGC5boxAo cWzkN6H684SAbOqR4AfIKC9z/Ytly+x7cSkP/cHY0flYY+O3f2nt+ZSvWFXIr4NzPzCf 8NiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EUoFqgAX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a1709026b0200b00176c891c8a0si1885317plk.6.2022.11.24.16.32.47; Thu, 24 Nov 2022 16:32:59 -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=EUoFqgAX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S230052AbiKXXaN (ORCPT + 87 others); Thu, 24 Nov 2022 18:30:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiKXX3s (ORCPT ); Thu, 24 Nov 2022 18:29:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3A23C6C1; Thu, 24 Nov 2022 15:27:50 -0800 (PST) Message-ID: <20221124232326.673658806@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669332383; 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=TlIkyzTTSvqR6KrJj1PQdSVRNaBSTUiGHoaI0+IdJ9c=; b=EUoFqgAXkfl7YAb9sfhRXkRzdebVXqr9nvfDRvKe0xNeMGXnXUS/RjfUs0CWKgl9C/35U8 stR9uXLyUVh8zZ3Wy/97dZn806sEYliKITeL1qlE2qk/c0aIXqVfzbf8fWwuatrebatmjl g57NpwGqhmq5+zoTYAfss2YKXnzwmDlYKhDBZzZdfo0OfeH0yw5yH7zvZ49veYVFbbuWEw q79fPtz3BEOSMIk/ynGb6TvgJFGZuT5iwOFAGhQyWJS10fZgk/FgotgeYX43lBWURsCvTg EU+Q4+/pbThL08M/8oG/ayOQiWvA4jFUELPBpcQA8kLNUnWzAaI2dM9GVodocQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669332383; 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=TlIkyzTTSvqR6KrJj1PQdSVRNaBSTUiGHoaI0+IdJ9c=; b=vzdLTkxSP4LCa9Pxc3Pi1rv/Qg8a4qEGdY3fbmBj9MchY2As9EtRCN5fVVcBkVhl79ny3X sguIA9J1MueylECg== 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 , Jason Gunthorpe Subject: [patch V3 24/33] PCI/MSI: Provide prepare_desc() MSI domain op References: <20221124230505.073418677@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Fri, 25 Nov 2022 00:26:23 +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 The setup of MSI descriptors for PCI/MSI-X interrupts depends partially on the MSI index for which the descriptor is initialized. Dynamic MSI-X vector allocation post MSI-X enablement allows to allocate vectors at a given index or at any free index in the available table range. The latter requires that the descriptor is initialized after the MSI core has chosen an index. 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 --- V2: Reworded changelog (Bjorn) --- 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_irq_unmask_msix(struct i 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, },