From patchwork Wed May 12 18:40:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stuart hayes X-Patchwork-Id: 12254675 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBAEC433ED for ; Wed, 12 May 2021 21:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEE9E613D6 for ; Wed, 12 May 2021 21:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231894AbhELVH0 (ORCPT ); Wed, 12 May 2021 17:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358191AbhELSnF (ORCPT ); Wed, 12 May 2021 14:43:05 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6136BC06138E for ; Wed, 12 May 2021 11:41:03 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id d21so23129547oic.11 for ; Wed, 12 May 2021 11:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XmDVrHusp4k4TH4Rdds8NJAp7ze1VCqnR4KQ0dA02nk=; b=cPiUw8YKF0IlUEvOkwooUMppYUibeTT+1Zm71RcrPyneGieTvof4BZfCFGB2zlY8Xe a9mHHvlfJe8o8wWTt60H9qUplhz5axzLKmjBzr1Q5lCvms+VIkbuDIdWgjXPIus/+hhn trHBoqby3bveL7IFhFVfLqDemFHKFd8MktxmCUJA216ZT2jLMHa9bRRFi6/jOHYO3V6X 48LDR0UgxIFTyvdJSW13Jgj+O5Pe5dIkJJsmgB+rcvJ4d2SCdpcaE8zSy5xMFKJKOfx8 FYAXywDrWCLliHnFwNgGRmTQamSKpWTBlMm9RynkpOmmg3rl6kXzALbCZZzsSod3Ltb9 yCjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XmDVrHusp4k4TH4Rdds8NJAp7ze1VCqnR4KQ0dA02nk=; b=UZ4cOmnTnxJSOMD0q/ulgKuPSRk/QqEHZ+uG46QsGlQsihkaghQ47c9Fg1ilGt5acl 8EMLUBMGrLwa6dzAXmYPntufm0v37Oo/noXfFwSFeR3eV40nxyMA1rGpWK5F2BdOZ1o7 iawi+SfRiFC22rtVrUpywOJBZwOUlpoYX0wcNvX0GGJ579JWNTYFJc06RdIut3ZZ/O3J prU+uceHoad4z5FxSrA3enLkLHwrYXeYDZOzZTDXWm9SbAyJsAprx4aRiv+akQizUxD1 YbQS2GP/i7eZSxQ8e7TSSyUSq9RwEDPgC0lSR3gW+mNELRX/jis3NKPwNUq6QAfpj7Kt Uv2Q== X-Gm-Message-State: AOAM5319dlwwHVHp7XEP86D9Z3JkWzXojVMuOYGvnYYLvngn70E8HdTP cIAwe2t6+PuzfcIODIQEatM= X-Google-Smtp-Source: ABdhPJxsFh1OjdlMaKOCeIzMXu3fgb8RyPetNQYo+w2MJstEs8Brpdo+0bp5yklgNKEp/pmPaAWkgg== X-Received: by 2002:a05:6808:d:: with SMTP id u13mr11221249oic.103.1620844862861; Wed, 12 May 2021 11:41:02 -0700 (PDT) Received: from localhost.localdomain ([14.141.145.218]) by smtp.gmail.com with ESMTPSA id o1sm137432otj.39.2021.05.12.11.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 11:41:02 -0700 (PDT) From: Stuart Hayes To: Bjorn Helgaas , linux-pci@vger.kernel.org Cc: Lukas Wunner , Stuart Hayes Subject: [PATCH] PCI/portdrv: Use link bandwidth notification capability bit Date: Thu, 13 May 2021 00:10:50 +0530 Message-Id: <20210512184050.2915-1-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The pcieport driver can fail to attach to a downstream port that doesn't support bandwidth notificaion. This can happen when, in pcie_port_device_register(), pci_init_service_irqs() tries (and fails) to set up a bandwidth notificaion IRQ for a device that doesn't support it. This patch changes get_port_device_capability() to look at the link bandwidth notification capability bit in the link capabilities register of the port, instead of assuming that all downstream ports have that capability. Signed-off-by: Stuart Hayes Reviewed-by: Lukas Wunner --- drivers/pci/pcie/portdrv_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index e1fed6649c41..3ee63968deaa 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -257,8 +257,13 @@ static int get_port_device_capability(struct pci_dev *dev) services |= PCIE_PORT_SERVICE_DPC; if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM || - pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) - services |= PCIE_PORT_SERVICE_BWNOTIF; + pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { + u32 linkcap; + + pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &linkcap); + if (linkcap & PCI_EXP_LNKCAP_LBNC) + services |= PCIE_PORT_SERVICE_BWNOTIF; + } return services; }