Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3411135pxb; Mon, 30 Aug 2021 01:10:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUhRsTC0HitwDewvqvKIXysj95gfpOJbL1b3/D3zhu0mANZfMLJAmGkw7CxWDQn6WAnV36 X-Received: by 2002:a17:906:1382:: with SMTP id f2mr24011273ejc.536.1630311005057; Mon, 30 Aug 2021 01:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630311005; cv=none; d=google.com; s=arc-20160816; b=P3PPtXvLctQmwvtWZxGJMo711GZKSyo+tdsTdAnp0X+6VDRVTMxtdZTQx2etWcDX2Q jqKde4yDctLFzRkXHTEwbklL1jbTsNoMAgGV7qjL0Ek8yrZ4yE782oEjHFUZZXZKmvsH JtSkS1WE4mvqHBA3Q6uulzmrm5iiQQ6r5pw2hkhNqPb1/QuR8Oi2AOTyg4g4XBnvbDD1 K7CskEuNnwq9rwMOy1wVeq4g0eSmVRBQ7jx8SaZeTxg3n8N0UeI9QuDynmpXXvYO90ro /WwZVkXupWad7GJcfEO54pEBPZ7Zj995XKOWD+VY2dbDVCq5+K9XrfrZSbv/Z41mGJGI sqcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:cc:to:subject:from; bh=xmPfA15Oz0d05f0Ct9CUQLPxqec6bXBkUdDMTyzto8c=; b=RAbCouF27CjvkHBvLphpDfTEffVZZ8RKunmw2X0uV+TaxNgZGiZ9M3OPKeiOuGfhFj GFDOOa9Aj0DikSeBuhPZRxbvl1Fm9jPsIPwNieqeHB94bcSdGaSu42tWRrdDMEbP9jMz BWEcjy0efyfoighuojDDEpUwkHY0VHSnsy8FLdkvXuacLBZ100yMF+vJE4eFgGSzXOWk YLb4KtKCuT6mkobn2KJJvUDYnxp1K4EK3fUB3/MM1aOyOpw/D9tRP6Jc9l7zi6soyzMQ 9ExBvBsszky9w6NToqruMeCIQhwJe76nY0MVTji7f5Nfe0538ADW5MQCuMb1FcgTjhhd 1KKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 29si2583894ejf.457.2021.08.30.01.09.40; Mon, 30 Aug 2021 01:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234499AbhH3IJN (ORCPT + 99 others); Mon, 30 Aug 2021 04:09:13 -0400 Received: from thoth.sbs.de ([192.35.17.2]:52077 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233318AbhH3IJM (ORCPT ); Mon, 30 Aug 2021 04:09:12 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 17U88BLP018646 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Aug 2021 10:08:11 +0200 Received: from [167.87.2.75] ([167.87.2.75]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 17U88AWF007376; Mon, 30 Aug 2021 10:08:11 +0200 From: Jan Kiszka Subject: [PATCH v2] PCI/portdrv: Do not setup up IRQs if there are no users To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Linux Kernel Mailing List Message-ID: <8f9a13ac-8ab1-15ac-06cb-c131b488a36f@siemens.com> Date: Mon, 30 Aug 2021 10:08:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka Avoid registering service IRQs if there is no service that offers them or no driver to register a handler against them. This saves IRQ vectors when they are limited (e.g. on x86) and also avoids that spurious events could hit a missing handler. Such spurious events need to be generated by the Jailhouse hypervisor for active MSI vectors when enabling or disabling itself. Signed-off-by: Jan Kiszka --- Changes in v2: - move initialization of irqs to address test bot finding drivers/pci/pcie/portdrv_core.c | 47 +++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index e1fed6649c41..0e2556269429 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -166,9 +166,6 @@ static int pcie_init_service_irqs(struct pci_dev *dev, int *irqs, int mask) { int ret, i; - for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) - irqs[i] = -1; - /* * If we support PME but can't use MSI/MSI-X for it, we have to * fall back to INTx or other interrupts, e.g., a system shared @@ -312,8 +309,10 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq) */ int pcie_port_device_register(struct pci_dev *dev) { - int status, capabilities, i, nr_service; - int irqs[PCIE_PORT_DEVICE_MAXSERVICES]; + int status, capabilities, irq_services, i, nr_service; + int irqs[PCIE_PORT_DEVICE_MAXSERVICES] = { + [0 ... PCIE_PORT_DEVICE_MAXSERVICES-1] = -1 + }; /* Enable PCI Express port device */ status = pci_enable_device(dev); @@ -326,18 +325,32 @@ int pcie_port_device_register(struct pci_dev *dev) return 0; pci_set_master(dev); - /* - * Initialize service irqs. Don't use service devices that - * require interrupts if there is no way to generate them. - * However, some drivers may have a polling mode (e.g. pciehp_poll_mode) - * that can be used in the absence of irqs. Allow them to determine - * if that is to be used. - */ - status = pcie_init_service_irqs(dev, irqs, capabilities); - if (status) { - capabilities &= PCIE_PORT_SERVICE_HP; - if (!capabilities) - goto error_disable; + + irq_services = 0; + if (IS_ENABLED(CONFIG_PCIE_PME)) + irq_services |= PCIE_PORT_SERVICE_PME; + if (IS_ENABLED(CONFIG_PCIEAER)) + irq_services |= PCIE_PORT_SERVICE_AER; + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)) + irq_services |= PCIE_PORT_SERVICE_HP; + if (IS_ENABLED(CONFIG_PCIE_DPC)) + irq_services |= PCIE_PORT_SERVICE_DPC; + irq_services &= capabilities; + + if (irq_services) { + /* + * Initialize service irqs. Don't use service devices that + * require interrupts if there is no way to generate them. + * However, some drivers may have a polling mode (e.g. + * pciehp_poll_mode) that can be used in the absence of irqs. + * Allow them to determine if that is to be used. + */ + status = pcie_init_service_irqs(dev, irqs, irq_services); + if (status) { + irq_services &= PCIE_PORT_SERVICE_HP; + if (!irq_services) + goto error_disable; + } } /* Allocate child services if any */ -- 2.31.1