Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3490364pxb; Mon, 4 Apr 2022 18:39:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7/u/OltY4Wf2oFWnuAbqV9+0B6ElYe9QS9APnNsRhrsm6dR+PrXSC2olahPAXjROhuhjL X-Received: by 2002:a17:902:e547:b0:156:c4e4:c0c7 with SMTP id n7-20020a170902e54700b00156c4e4c0c7mr1059624plf.61.1649122771227; Mon, 04 Apr 2022 18:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122771; cv=none; d=google.com; s=arc-20160816; b=ZtCF4nWq9NYlagxk5l4d1QiSwFjC3ZXId098X6awD/wWy5O7KEW/esrbaBeRq9tkl1 GSscQvKQnVDGOW9yevgutu2S9dWbxA+88W8VsejMZFWlyQ/IUMOXsrkWik9pPPR5HgHH xhHCwjzLjqJyVSjYLUxlpyWMhv4dmeTlxBP6uArfXHzIFSXcB1pOe4J2RlNbR7VSJJlZ R1W7nsQRJfzvpysc5iMAUeqTmu/Wns7s4+l7A5KhYrsnNpdcQd0ZhdGPU+3rDQJzQM9u +zVj9Xx2QSi96SGcT50WJC6n4BK0hNUZ3GjLElJzOTVrHGrxW8GtuG0esJyg2edWOMCH bpLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=DjmQ/60oEsUOVlbM/+sAzXrdxlHPtL6WOZl1FVBOfSw=; b=YWoVbIiqelKtrFljUzbNB9wwDMpNOfesh1nNmFzdVg8XrskJ0FEgbRV78pjFS0MiKv xD5vCw8WJop+xnFdXbiGXvaLFJbw49F5Fu8EfBs/urm9MwQbr47rJMdsdZJEzkV/gkZk gBA3AqepUy4385pS9wu9Qurm0wn8o3b2PxveTDiWbuUW9joeFmaEs+ImbW50MTIBp4pt snaBJply/R1ZeAFailX8BlW2XGCWR6IGyCofxadE+s4Sx9ylDvCAWP2sY7DnA/ytcedw V/9Y/b/Rz6AngYG4lpVwr2jcM7vZHBd6bIszsoz5hNGmRG/clU9DWr82VXtUeaBz3lq+ ekRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NzTuwFGA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j2-20020a17090276c200b00153b2d1649bsi10419603plt.163.2022.04.04.18.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:39:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NzTuwFGA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 801F2887AE; Mon, 4 Apr 2022 17:33:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356370AbiDCKWP (ORCPT + 99 others); Sun, 3 Apr 2022 06:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356297AbiDCKWK (ORCPT ); Sun, 3 Apr 2022 06:22:10 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6242A3057C; Sun, 3 Apr 2022 03:20:16 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id h4so10246739wrc.13; Sun, 03 Apr 2022 03:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DjmQ/60oEsUOVlbM/+sAzXrdxlHPtL6WOZl1FVBOfSw=; b=NzTuwFGAvevnkfF2CZiC+nsjkjYF26Bz9yF89nT6ur11+Kc5dEcSs/miXSJdcez6mt e/NU2JcPoxFu5OKQVbJcyfaFYpPYv3/YgERmuC+r5VLBfQr1GEHE1LG0Zezz4QBqLTdy cdt0OWA8rAkX1dHefmBN/bm5zEeE5Icncp4JU7OTjmtJFpkXfmmFd2s73FaWX0+6/U1S wMzbTgO0SG4Ya0jBsyU1nXCU6xfHkl/bmVtSZMW9mBr59Qh0TVS3/M9E4UYjbnAELkqL pjGLSLyLBDhvWp/gh+iEgWd2edNi3v+V5liO8/iue8vQzQe1ppc5Ao+jYI6pevJ1T04b ohxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DjmQ/60oEsUOVlbM/+sAzXrdxlHPtL6WOZl1FVBOfSw=; b=Q6eGyTPQHkDYSgtFeuzW4XqRMSUA58fnef+ECcTKRpYjS7Gi6/lpyfYbsScv59hdEP dGGkf3hg4PZf3nRNWS03Igx05LNfX5ekIssrxyi/5GbsPMasDNB6CzMWiZ/4w7KJZbVQ A/zpkkhhPQQ1KqyUWIv78kuu6Y4RGOXBaZUyiGzfiRZHQ6M6mql+kMzqCDe3tnjmWJf3 sKQU0xJi0otHo4lHouoIJ7oXT5hDNV200dIPApixvYr0ZyM1QnOO+hdpIV93Q3CUo+vS XaERK8fMS3mu/Fu39GxEr30l5Z1yROfEr9jPNwio9J4/lbpxzhOssJXWKI8qVFwctEdH oPMw== X-Gm-Message-State: AOAM5314ZUxNXGrojO/Ds3MFj+9IJPRZcJkLfuo+jTIpoKTrvpp9FDj6 BklIm3mUwwwi3d7FLJsFMNef19GV55I= X-Received: by 2002:adf:d1e7:0:b0:205:8909:a67f with SMTP id g7-20020adfd1e7000000b002058909a67fmr13419004wrd.66.1648981214536; Sun, 03 Apr 2022 03:20:14 -0700 (PDT) Received: from Dev-shlomop.pliops.ent (bzq-219-32-62.isdn.bezeqint.net. [62.219.32.62]) by smtp.googlemail.com with ESMTPSA id k23-20020a7bc417000000b0038ccada7566sm13639895wmi.11.2022.04.03.03.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 03:20:14 -0700 (PDT) From: Shlomo Pongratz X-Google-Original-From: Shlomo Pongratz To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, andrew.maier@eideticom.com, logang@deltatee.com, bhelgaas@google.com, jgg@nvidia.com, helgaas@kernel.org, Shlomo Pongratz Subject: [PATCH V6 1/1] Intel Sky Lake-E host root ports check. Date: Sun, 3 Apr 2022 13:20:08 +0300 Message-Id: <20220403102008.7122-2-shlomop@pliops.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220403102008.7122-1-shlomop@pliops.com> References: <20220403102008.7122-1-shlomop@pliops.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 In commit 7b94b53db34f ("PCI/P2PDMA: Add Intel Sky Lake-E Root Ports B, C, D to the whitelist") Andrew Maier added the Sky Lake-E additional devices 2031, 2032 and 2033 root ports to the already existing 2030 device. The Intel devices 2030, 2031, 2032 and 2033 which are root ports A, B, C and D, respectively and if all exist they will occupy slots 0 till 3 in that order. The original code handled only the case where the devices in the whitelist are host bridges and assumed that they will be found on slot 0. Since this assumption doesn't hold for root ports, add a test to cover this case. Signed-off-by: Shlomo Pongratz --- drivers/pci/p2pdma.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 30b1df3c9d2f..c281bf5b304a 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -327,15 +327,19 @@ static const struct pci_p2pdma_whitelist_entry { /* * This lookup function tries to find the PCI device corresponding to a given - * host bridge. + * host bridge or a root port. * * It assumes the host bridge device is the first PCI device in the - * bus->devices list and that the devfn is 00.0. These assumptions should hold - * for all the devices in the whitelist above. + * bus->devices list and that the devfn is 00.0. The first assumption should + * hold for all the devices in the whitelist above, however the second + * assumption doesn't always hold for root ports. + * For example for Intel Skylake devices 2030, 2031, 2032 and 2033, + * which are root ports (A, B, C and D respectively). + * So the function checks explicitly that the device is a root port. * - * This function is equivalent to pci_get_slot(host->bus, 0), however it does - * not take the pci_bus_sem lock seeing __host_bridge_whitelist() must not - * sleep. + * This function is equivalent to pci_get_slot(host->bus, 0) (except for + * the root port test), however it does not take the pci_bus_sem lock seeing + * __host_bridge_whitelist() must not sleep. * * For this to be safe, the caller should hold a reference to a device on the * bridge, which should ensure the host_bridge device will not be freed @@ -350,7 +354,14 @@ static struct pci_dev *pci_host_bridge_dev(struct pci_host_bridge *host) if (!root) return NULL; - if (root->devfn != PCI_DEVFN(0, 0)) + + /* Verify that the device is a host bridge or a root port + * It is assumed that host bridges have a 0 devfn, (common practice) + * but some of the entries in the whitelist are root ports that can + * have any devfn + */ + if (root->devfn != PCI_DEVFN(0, 0) && + pci_pcie_type(root) != PCI_EXP_TYPE_ROOT_PORT) return NULL; return root; -- 2.17.1