Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1494834pxb; Fri, 20 Aug 2021 06:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYT/WR82vk6DXH6gSinbD1YeJEfxQc9zkIV/Xj9jQHhcB8Q0cX+Qqw2OA21Shs4vF8ARhL X-Received: by 2002:a17:906:8310:: with SMTP id j16mr21605367ejx.135.1629467666233; Fri, 20 Aug 2021 06:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629467666; cv=none; d=google.com; s=arc-20160816; b=Guy6vkxRSksJfp08RsDP2Rncru4FLgsjhVVbUKaztOc9cHb6IdVoHH59pHHcuFHBH9 pC0GwziwXuDJmsQBKPLRM2NMM45vfx6qLB/sC2CA4rZU+cTlpgvqmLBmy4RptsXckuDy i4HjT5yMShzgxlBBKyl9ZqD86EZbFZb3Pfhcc2JwQ3tymGCgsNq4oRyAPK8TDjezxhIw sFas8wVopqVXiA51+/WkNPM0NlvjeQuoYsFLbaDR8dMQywzWqx5x4pbMbe0pJ3zd/ftV 5YN9aNUGw5OMQ1vi/SM3RhFO+g9WLpyeH+aJi+1hijGOISV5d0qTOtngvlWbtum9n12Q yluA== 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=Gi//1QUm+FMvJ1kal/ofT0H2aGaVw7NPGYYmZKK3VqE=; b=r02IWgqdbB//nXC9gjIJiby31n3gqI2QVfxRgrmSNBwdhn5wndDqo/S+nvaTkR4xYO S4hpK1THgIz+yS4qsqIYvY+O3tSgoeU8n2Wf1hEv5Ma3fkO8E/NJehkfFNoZXdKEA4va pzHqIlTH6vWSHAzKABsU94HyRRvNAJ5jKeR8qP1OS1xdg4t3gPGxZINyXeZG3sMgSipP PRS5y6ysPQ63/vuwvtZMKLIxQILyrXTrK53l+2qDPxtcJgnFUlHn8ISNFS4amBc5s2GB +cqxwZPWaiLFrZQN6UGaFH38SgEsoqIDU5BLsWByvJ5vfOi2z8lgjK/Rr4pzFY+5vf4j VoxA== 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 x42si6094155edy.566.2021.08.20.06.53.59; Fri, 20 Aug 2021 06:54:26 -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 S234189AbhHTNxC (ORCPT + 99 others); Fri, 20 Aug 2021 09:53:02 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:58011 "EHLO lizzard.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbhHTNxB (ORCPT ); Fri, 20 Aug 2021 09:53:01 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 17KDqIjq007098 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Aug 2021 15:52:19 +0200 Received: from [167.87.0.29] ([167.87.0.29]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 17KDqItv026769; Fri, 20 Aug 2021 15:52:18 +0200 From: Jan Kiszka Subject: [PATCH] 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: <43e1591d-51ed-39fa-3bc5-c11777f27b62@siemens.com> Date: Fri, 20 Aug 2021 15:52:18 +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 --- drivers/pci/pcie/portdrv_core.c | 40 ++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index e1fed6649c41..2a702ccffaac 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -312,7 +312,7 @@ 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 status, capabilities, irq_services, i, nr_service; int irqs[PCIE_PORT_DEVICE_MAXSERVICES]; /* Enable PCI Express port device */ @@ -326,18 +326,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