From patchwork Thu Jan 7 17:50:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Das, Nirmoy" X-Patchwork-Id: 12004605 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 5DB4CC433E0 for ; Thu, 7 Jan 2021 17:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23BD6233FD for ; Thu, 7 Jan 2021 17:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbhAGRwM (ORCPT ); Thu, 7 Jan 2021 12:52:12 -0500 Received: from mail-dm6nam10on2047.outbound.protection.outlook.com ([40.107.93.47]:61472 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728123AbhAGRwL (ORCPT ); Thu, 7 Jan 2021 12:52:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nd4PU4QGVndNbfJZv01/Mpfr9Qg+Ae5lyYuANuw00aNqoVxhscFU+eSHq75Qu1eRO5WQBXvfGLA4Ni7GQNBUEZmnw7ihRgK5WRq4N5PXwLavLK+LzHOPZR3YjnugYnzWC5KwoJr+vkhbFvOyVobF1Jrdbs3Q2H0F86Odmq6DOunvk3YOxGVMBBR2wfLtpHPkZYToFppYg8lgJfe6au9DqXEKWXqO8ukU7ZW6gqEa9qydhjsaqoqAbiN7GTOEmsPn507BqY1H6RPJCL+Qtdy/MAuZQATT5HGj8XsTb3KBZZGW6aHhJhD2d/3ns4qOjflGVyes3VUHAMMu66x5cZkxJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0/1G0B1l+fxaKiI5DDkuCkUDT7DWrbJ06MepZ5MCo5E=; b=YQLvgHm/4BhlDZxsQABWY3OTjPXvHs8Jh63facl2EJTwa6TWTSn5giQvaJGE6mzDXZAd0p0mQH7LkIHN1WfBRoIaJeCMpUfseNhNtFy+2OHwZiwT96O65Gky0Hiek4g7vyA3OEHMNtoKHcVHl+8g4wuxvxjTRYlyy1qPq5aDnPIRnlP1qXQC2ao2Z+FO3BKOlIzg1t8PiAe4cXirtXEulEjIIlxABJXl61dwRD/q8+s5lwg+tHuIj4f3yH+NOpPbV/awFZSJIYr34HlV/FOBjjDVKf03JnZ7sEoJe13f+DR1E2THNrzWoGnrNeywrJpKyS1NKfoQO+GnG5Ra7g/Qfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0/1G0B1l+fxaKiI5DDkuCkUDT7DWrbJ06MepZ5MCo5E=; b=G/daZmDZj59Nm65aPnUXdi1dLMRgoxa0azDvk3gfNdyVqa7JO5nEhv760tYCpRfh2OOmsmfFfMvhvOJ5emgZ6OVfKsVBCMJgnwnZpYphhKnZl/Exw4IYcnoUFq1sAzANwmkEf0MYkv+MVMYwG9mxtLmUlsekIq7cfrnpaKTUtGs= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) by DM6PR12MB3066.namprd12.prod.outlook.com (2603:10b6:5:11a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 17:50:48 +0000 Received: from DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b]) by DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b%5]) with mapi id 15.20.3721.024; Thu, 7 Jan 2021 17:50:48 +0000 From: Nirmoy Das To: bhelgaas@google.com Cc: ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, devspam@moreofthesa.me.uk, Nirmoy Das Subject: [PATCH 1/4] PCI: Export pci_rebar_get_possible_sizes() Date: Thu, 7 Jan 2021 18:50:14 +0100 Message-Id: <20210107175017.15893-2-nirmoy.das@amd.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107175017.15893-1-nirmoy.das@amd.com> References: <20210107175017.15893-1-nirmoy.das@amd.com> X-Originating-IP: [217.86.111.165] X-ClientProxiedBy: AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) To DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from brihaspati.fritz.box (217.86.111.165) by AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 17:50:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bd92a075-55a5-47ea-20dd-08d8b334c414 X-MS-TrafficTypeDiagnostic: DM6PR12MB3066: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cEIIQpZvXoJI3V98iaHi26xedGg28HFw6eliifHO7epE2OAY+VKKHb1noqX0vFexhJTd/FvGsOx7s6hU1svNVivNXafxtKywYVh10TpBbB7nq1EEOSwKljlWvT9N0tiT2U4SDuqdt9Ovq66amj3XKOWL6BATAZRTH0LKxM9d6tESnruSlKnxpE03AHsrCrHqlNq7g//3kKLcRwVdQlkzLDJJd8+Dp/S6kUajgSGUZxS6zoQQzlA1TQtg2hqGhElCTdkVFsDl7NUkH+9oubq2hi8oH7WkWBBUsb3YXdGffeJA+rk7mw31Yo1emwTYLif9HVaggjHFK4PkpuIRYg3bHJ3FP3WZH8/3vUDag9Y8da6bW6R080575+p+IQDjHj/5Fo8x/n1umNC0gWtOUS4p0Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3916.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(4326008)(6916009)(316002)(1076003)(83380400001)(478600001)(6486002)(36756003)(26005)(66476007)(66556008)(5660300002)(8936002)(66946007)(2616005)(16526019)(44832011)(2906002)(52116002)(6506007)(8676002)(86362001)(6666004)(956004)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Gh1KzXsgT2H1KUAIKwHC7ysH+FKmWzJYDM096E8r2jVFbSb1LWEWCuGk4BPZ25xoQwy3puB9ozI/mVTOmo4ub/6lYuuu720tgsOsZ7/mURm0qD8ojAtjCu9xiXypcSwlbwAg+zQXcUBb74dCVDG+WMbq9zkfGUEEB2Bv9HwGM5gw7MO+0ekOiY2ErT0UPkkCIdGaxSoUw8yCI8JzchiekDg88QMZCT7JKQUuMd7RkWtQaTd/oA3xhK1ZnvrOFM2vYRiqek386d8lhF/s8gZuhvr9/t57NVLP4/jE2lSInzpLGV2VN0FzRisL6Hy+gthpq9KqM/yQ1u7JVVv0N8woJkClEl3MLQ3xF41W6I24+iXOLqlwZZgge0tNelBsoHjzlxd19vEhEHS+3GXt5qmLQPp8gWbHu77ymC7jueggaOmshjROgCxlUENxeuHvGb9RfwB2QmlI0NX0jAYVw/adsFs10KAz0au4ELUJYTTOXLtM8wz4C1eZxUXOxZ488bM5x8tpEwKD7ET5ylpkEH0iDpfdSOZJJMYOKZJXDhdLN8Jd4HZtwmSgiJdj+IIFfa1IFn+ipWyJM5boimJvx5mBQIJgiIeHz6Gzf/F28n16U7T9ZqdnG8C+AGyE5FPxRFZLiO+vToEYYnHVmkhfh25NlzgB+P4ZfScQOpfMGj9/P9OtQNzQT8wfU10e6O8UZHsL76JuT9AP5rvY+bbAgxGhL96cz0igohA0ZtsUmkpQYRzW52fOMUov2eCsg5fMj4ol8adeeBzzVKY7xREz5yW2pDHU0B3UnPLOU+xtXMxGa/pfAkxaNL3DuRUkkyLiSuyQDjahumioBlcug3/FVAAdmGt6a06+j21KCibOAeaL2SoEigZnh9bEhHhMalpQZ9Dei/IE93TNM81O4JfvVj/GSLNxdUihm9WYdy/KudDc+ZPSvDZ+3KGgneQbcg+qwtyQ7Xac9WQKRMz7tEMT7qP8S9afnDmM4LfeJRuWxINdv801wDZTuu69JMEp0k0qbmix X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3916.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 17:50:48.1230 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: bd92a075-55a5-47ea-20dd-08d8b334c414 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5V0uovua8qgxEk068eHfmk4UW/lztFTHFdM+Zly+6JzBSmK61lys7BL6S7wo5rtNjpOZdhbcubeQbmwGzxItTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3066 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Darren Salt Export pci_rebar_get_possible_sizes() for use by modular drivers. Signed-off-by: Darren Salt Signed-off-by: Nirmoy Das Acked-by: Bjorn Helgaas --- drivers/pci/pci.c | 1 + drivers/pci/pci.h | 1 - include/linux/pci.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e578d34095e9..ef80ed451415 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3579,6 +3579,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap); return (cap & PCI_REBAR_CAP_SIZES) >> 4; } +EXPORT_SYMBOL(pci_rebar_get_possible_sizes); /** * pci_rebar_get_current_size - get the current size of a BAR diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f86cae9aa1f4..640ae7d74fc3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -608,7 +608,6 @@ int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment, struct resource *res); #endif -u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar); int pci_rebar_get_current_size(struct pci_dev *pdev, int bar); int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size); static inline u64 pci_rebar_size_to_bytes(int size) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c..9999040cfad9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1226,6 +1226,7 @@ void pci_update_resource(struct pci_dev *dev, int resno); int __must_check pci_assign_resource(struct pci_dev *dev, int i); int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align); void pci_release_resource(struct pci_dev *dev, int resno); +u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar); int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size); int pci_select_bars(struct pci_dev *dev, unsigned long flags); bool pci_device_is_present(struct pci_dev *pdev); From patchwork Thu Jan 7 17:50:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Das, Nirmoy" X-Patchwork-Id: 12004603 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 33A6CC433DB for ; Thu, 7 Jan 2021 17:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1C67233FD for ; Thu, 7 Jan 2021 17:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbhAGRwD (ORCPT ); Thu, 7 Jan 2021 12:52:03 -0500 Received: from mail-dm6nam10on2080.outbound.protection.outlook.com ([40.107.93.80]:54976 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728066AbhAGRwD (ORCPT ); Thu, 7 Jan 2021 12:52:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cXSBxPqa7RkT9eZ+9VrcKB+u3O352xiObA06KhsjiukdbFD4y5UBYpSzUBCjUh0g+YzsNwQAc1EW8AWf1PWryuYQOfWalJ52bbeg1rmyWqWc1CcTm588oOt3Rhsg/jiuzDLd9tzNNgdhwW0x2QiqHAGo0CkZieqajDWOX0Acohe66Jjt/7n06aicGUcrCUQENU/VO3w6upgNZlRGQ5Y6FlpRroNiJVUaX8ts3VXOI3QB/VP6GrTp99Vi43XH4yKMcJdACAJA0aOWEhkUaTaZZDUrEfaJm+CEf2HS1aBMqWWsztMYSh1YofF8oIhga5VrF8xygl24Adad7aWX0Yxgaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sg/CDzXyze3tWUJxj0mz1HiBNVrEWG7Jo2YIZ4wHVUk=; b=lRAbROB/o7M3+hXHDCtR4qjyDcFabWowkDQ42dDDGR5v7mnOrGYceD7m2C00hMPfOtYgJxIBFmCEoRuk980zmdYfR5KtjDVCej4QEwT5TajVXShCoiluWFX6eBIrmm15gA6nb91ygQs2h6tNDQZui2lIzFh/YeC1kdNCeLEjZjVXHSGftSXtKe5nxfHMvnyVxBjEdCcBRf6qfLyhPxOd3TwiSnbGBSxdiKM4TuWji+R9jSiI2vjECE8i0HjGoWlzNy84GFHFbRxswyIVYcjmmVYwoOpUOg47UAWT9Sz4IIiwWnLMH7dOPK32XZFy9eCNgXXVZKObDtXRWxW+X2toPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sg/CDzXyze3tWUJxj0mz1HiBNVrEWG7Jo2YIZ4wHVUk=; b=fC9Pd8JQuIWgGTx0qc0tFEvyoP3CgaJ4qKoF97572WQNwYRmi/zpWCe1wkZc66cmo5YrmWAfOekMQZlugs64F7QNRZDljqoC8eLj6+U9KAjyX1bJ89qsAymHzJN42fLvHtQDRcUP/AFr3Ynrm5/Jo/0a3s17e3WESx8Zb9yF64U= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) by DM6PR12MB3066.namprd12.prod.outlook.com (2603:10b6:5:11a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 17:50:50 +0000 Received: from DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b]) by DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b%5]) with mapi id 15.20.3721.024; Thu, 7 Jan 2021 17:50:50 +0000 From: Nirmoy Das To: bhelgaas@google.com Cc: ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, devspam@moreofthesa.me.uk, Nirmoy Das , =?utf-8?q?Christian_K=C3=B6nig?= Subject: [PATCH 2/4] PCI: Add pci_rebar_bytes_to_size() Date: Thu, 7 Jan 2021 18:50:15 +0100 Message-Id: <20210107175017.15893-3-nirmoy.das@amd.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107175017.15893-1-nirmoy.das@amd.com> References: <20210107175017.15893-1-nirmoy.das@amd.com> X-Originating-IP: [217.86.111.165] X-ClientProxiedBy: AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) To DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from brihaspati.fritz.box (217.86.111.165) by AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 17:50:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1659d772-1a1e-4a33-07b1-08d8b334c536 X-MS-TrafficTypeDiagnostic: DM6PR12MB3066: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8fZVVfVQKUhK4jHgy0xx2FcF5EODaYXNclS8auonvf6NDsJnnpZhztuNSHp/N6VmU6EAiTBsP9NNZRtdd268f2SnW9Q18Zg1A8MbJUFD0zqtejNYn89P+XLsbnaE/0+JYFJFtjuTWP299mswkTFuw5BNMVgLbCslxytGijBmOakD8tVBeWIaSA2cCSIZrEUBG2uod1zPeO5d5OLlop/5k/TYhkD5U9TWOJalyBlY0+8a0cuOYaRIAOMfboz2xrg7iii62QMe1jCNL6yHfYr1CxnM5Dfc/IYnK3xxLuA8iW9hI10GEpqsQd7oVAFOmDIz087AsxImzn5EAi+pXVZ7gU3bS8lIoYiJgbNzQ/bFIP6W+jLC7OS2NcEWyp2k8qmCyXGFKFur6G2eHzPq+1mWjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3916.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(4326008)(6916009)(316002)(1076003)(66574015)(83380400001)(478600001)(6486002)(54906003)(36756003)(26005)(66476007)(66556008)(5660300002)(8936002)(66946007)(2616005)(16526019)(44832011)(2906002)(52116002)(6506007)(8676002)(86362001)(6666004)(956004)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?j2rZriMjHIZBklWbK1QBjW1i0vE7Nw?= =?utf-8?q?fF3aaKSoAN0dPhEhg5YysMi2v3k8lju4hr7iA3EjAj4VOxJVkucbaSsPeEBkc6uaH?= =?utf-8?q?Y1+LZyxyqRDQR1DjuMFW+fe2wPqdL/UlNooVnUsre8ZO53U5f/CdhNRN4xkJGyhDr?= =?utf-8?q?ZjZHYqbS6TCABIn1LNAG2kpx2e4w3RNUImZdRwyNADpI692hmgNzI15zmfmHAfI7E?= =?utf-8?q?DMKM8Ajp6WsK2OugldVw86Pmy61cbzVB/UpzBdVBBoYauFyjKniZ9tNVRy2nKyPOU?= =?utf-8?q?VpsbUIjYYbpZxsNvPxWwS+zMRtzakYppJN3/Nce3uapTF/iq75bTgY1X7gMz4QOMI?= =?utf-8?q?APVdaHEj9HQrAsTLZrSSWbCDxJP6MrGgWpOLPJA+qszyTaRZZ7Anc8yIXxk+9egu3?= =?utf-8?q?df5lVUpV8+Mc+HYfu8v5cPliPv2YGLNd8H1mrn1Vy8sWE3c4zQxPouXvrLS9WJVfI?= =?utf-8?q?XYas/a4/fMvMX7kLfP6YUCHyZdYhEmKlwmDR/P/qe3r7Jj+Szv6GsaStxpB8IdT1N?= =?utf-8?q?G9Y/Fq+S9jxCcA8mHq4+lekmYPmCqraae4Wsds93LCyfHhIcQL87M8WK+4dxvNJUB?= =?utf-8?q?J6v9t/6Sedi9ZG8sRhCeRaOTOX8V7iI8FJOxlNBuclzKMiiG0Bo6CwSqr7Saz0z8d?= =?utf-8?q?6acFEfN2cszZGOdSI0VojNfRmvI74NmDQXto9tT54j/0JwNwyQhE8+bqBfhwo+3ib?= =?utf-8?q?BVKDJ2igG90720xTu5saUHXLO7PhtuTKtzls0vEoWptMZkp6lsosVS6k8tnbnbqLX?= =?utf-8?q?xDdaINM2fr3V3v7mc3O/flhHCV/MZna2TWwbWSXoxcSQSkN159NCy6cWdXyHarcdU?= =?utf-8?q?0FMIrpEbKKE2G0wSj/Y4JBa+4EeZ6hHmboSY1H8VbQl78mzvSVJ6qaUj4vzIJFws+?= =?utf-8?q?6nGoaW5xDtz0r87BeutE88ijn8dMAGGnquXHH9GnytN7PsYQvIfhHJbS2zEG8yj1E?= =?utf-8?q?aaIs5IN1PyWt9VdspsN?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3916.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 17:50:50.0039 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 1659d772-1a1e-4a33-07b1-08d8b334c536 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cvmwmxmnAHZyZeyNm+GhAqb96CSZkvyjrdQvBLiS+FL7R7PgdhYzE0pXLLBEkidf24ITTHsPCF8xKc2vogT67A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3066 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Users of pci_resize_resource() need a way to calculate bar size from desired bytes. Add a helper function and export it so that modular drivers can use it. Signed-off-by: Darren Salt Signed-off-by: Christian König Signed-off-by: Nirmoy Das Acked-by: Bjorn Helgaas --- drivers/pci/pci.c | 2 +- include/linux/pci.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ef80ed451415..16216186b51c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1648,7 +1648,7 @@ static void pci_restore_rebar_state(struct pci_dev *pdev) pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX; res = pdev->resource + bar_idx; - size = ilog2(resource_size(res)) - 20; + size = pci_rebar_bytes_to_size(resource_size(res)); ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE; ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT; pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl); diff --git a/include/linux/pci.h b/include/linux/pci.h index 9999040cfad9..77fed01523e0 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1226,6 +1226,12 @@ void pci_update_resource(struct pci_dev *dev, int resno); int __must_check pci_assign_resource(struct pci_dev *dev, int i); int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align); void pci_release_resource(struct pci_dev *dev, int resno); +static inline int pci_rebar_bytes_to_size(u64 bytes) +{ + bytes = roundup_pow_of_two(bytes); + return max(ilog2(bytes), 20) - 20; +} + u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar); int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size); int pci_select_bars(struct pci_dev *dev, unsigned long flags); From patchwork Thu Jan 7 17:50:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Das, Nirmoy" X-Patchwork-Id: 12004609 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 C8CE3C433E0 for ; Thu, 7 Jan 2021 17:52:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85CB8233FB for ; Thu, 7 Jan 2021 17:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726319AbhAGRw0 (ORCPT ); Thu, 7 Jan 2021 12:52:26 -0500 Received: from mail-dm6nam10on2080.outbound.protection.outlook.com ([40.107.93.80]:54976 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725835AbhAGRwZ (ORCPT ); Thu, 7 Jan 2021 12:52:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+YipzHL5ARfy68vGcgcId+cknt3XfwtLfY42afdqAfpla50tSW2UBZCXIwQmzd7BzpI0+xj82L68VaW8QsmrRWDpeIiOsMMgHFN3NLK3mnDd8efghgqEdJkFsxn70gll8EIek1OdbgXn/UyLoJQ50ROfTM05IRyGZUnzmFG/NLDEmp66MH1cliIPNPRxqCPSA5bzYpgK0rxhfXMT0N4uuKYVjJuutC7cIlmoGsoStAaroryb7z98ZV6X+tfOeLwntWo64YcrKHk33N03gi8n93befEdk5xAVGetEmrm6387qeFSQvqwIbpa5bqKF8Mj9WocEaBvrMylxI9xw6k7KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1f/85AnEGElOJ9U09MFwycRi+XzCeG5VJ58qVhGop10=; b=nP1EDWk8VjbE22TrsgCWaFwkPGWF1SG/TBiunTkyTZ2ndk9Pddj1zPdkFJQTNHxXoiA1U+WJiGrZuVrSFt140D0Mm3mi2PuLtE66o2+RbD5HtVJKod3QhwqbOXcwol+sdoHENO2EpxCvQ4un6TndA38/Hd6xysK9TEoTR1Snyvm7GxEoI/cX08Bq+RrQzivj5QmYPkxSRERwO6xptLYM7/hdSfMMTh7Nedc7VFe85Ju8f/+gXFWR6GHv9OJi628gH8hk3gCZzLFfiQqarAdpEl3/L+XtZHmBlvxPzRRPfc2Nr/vnXwg/zsz5gM6Qx0vKk/gYx8IuNI6cqFjezK1BUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1f/85AnEGElOJ9U09MFwycRi+XzCeG5VJ58qVhGop10=; b=n9wczHft+d2Af7u3XJRrF7NHtzmPXZ9QqQD06BCGorOiKHUSPeVJA+ad7dHYvUOd8oOLrVz0Wvv6sTgY6dM8BEi2FDGa64mhMGj1E1/wc+9a8h+XQ2BS9x8S9hpwszXPqi3y5D60Hq8LGWE1nTc/hqsnSXG9SlktPAbHZuFults= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) by DM6PR12MB3066.namprd12.prod.outlook.com (2603:10b6:5:11a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 17:50:52 +0000 Received: from DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b]) by DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b%5]) with mapi id 15.20.3721.024; Thu, 7 Jan 2021 17:50:51 +0000 From: Nirmoy Das To: bhelgaas@google.com Cc: ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, devspam@moreofthesa.me.uk, Nirmoy Das , =?utf-8?q?Christian_K=C3=B6nig?= Subject: [PATCH 3/4] drm/amdgpu: Resize BAR0 to the maximum available size, even if it doesn't cover VRAM Date: Thu, 7 Jan 2021 18:50:16 +0100 Message-Id: <20210107175017.15893-4-nirmoy.das@amd.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107175017.15893-1-nirmoy.das@amd.com> References: <20210107175017.15893-1-nirmoy.das@amd.com> X-Originating-IP: [217.86.111.165] X-ClientProxiedBy: AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) To DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from brihaspati.fritz.box (217.86.111.165) by AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 17:50:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: edd9db93-ea7f-48f5-006a-08d8b334c650 X-MS-TrafficTypeDiagnostic: DM6PR12MB3066: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6qN7Tt43VL5Hu2uXoCtC1Pzb73+y4vOQgZSOExDawJ9fsEUsIcfFMpZsalHcqo5br5PFHOrAcpdGv5ZXQ2QuEBvpXNNIRGy+yvTiN9LtWkaTz/u7QHQRv7TFGRk5o5tIuiCgux8GXxR3nQrmUALhjs+g9aN1xucCMxsoFWNZu/BfsZz4nLCqjx2f0HIMkrHypB0DpRaDQ67zMnTRaF/Ofrf8eW1FUna/mtmS5YUoksAVVq0OSTyt3deRyZPP+B904ZUnbJv9tuhixptrwGN7SwLw45dmcEtyyPNXtULdiaIEvQE0ltQDe+F2wGHrfAD8rCyWuqpO56jhntm9DrI+sKJPf8yL21MFLUXCQVRhktvlgFZtEe/wojN2Ghxrkd2R8ilDECinvfL+Uos60OW7lA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3916.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(4326008)(6916009)(316002)(1076003)(66574015)(83380400001)(478600001)(6486002)(54906003)(36756003)(26005)(66476007)(66556008)(5660300002)(8936002)(66946007)(2616005)(16526019)(44832011)(2906002)(52116002)(6506007)(8676002)(86362001)(6666004)(956004)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?hRZYttNSti+kpZ/gvORjjrR1OnfTqM?= =?utf-8?q?n4O8EJ3BNQwxp77D9LSUHT2R6s904e3Rj+Aj97FyJ/LBYXU3yJTeNkrT2j5RggZQF?= =?utf-8?q?qammWBo5fIzlgRC0oj0ANjeSXCiTqiI2ZjFbQptu63t8xK3/hXHMHByxJD7Be5ox/?= =?utf-8?q?VKOKKCm/WDGtzqWe0YbUDdGHnqtDNoJhMvydJg2cEvhC8rn5wD2GcY10gkIEn+cme?= =?utf-8?q?JJyVsE0cLKGR0ZsEPuG/Gz+cpddQUhlIhlxT/zAO0Z+BadsdZV86DZl63zFXUdDXT?= =?utf-8?q?xrJEYzc67Mnqs7J6T25nnHWaRD/ZjbdH4gcN8qhR5jbtzBBy+NQg4gop2LL4cGQav?= =?utf-8?q?wtKNpp9P0BeY6b6PUGoW3e7CxyxyacQHMewua7MNxmnbclnVFq2kfQUEns4Ts3pX8?= =?utf-8?q?g0KC+PIza5+RabbCLvgvSHRyPBD2snD525cpp0AZrI3h28Lz1nnmWrx8p8too4Gjy?= =?utf-8?q?QINoNT0eiiZ3cMxCPfBBYiEkQlwlXRvvqvucYRvmoc5TX5ZRoVD+uFz7jo/i9Cnp6?= =?utf-8?q?R6MYuzC4r+I2Al55AukFq6hM7z4LVRoyuCJOLWmgOYOLCqY3oUYjjkw+1n1HxplSC?= =?utf-8?q?0F160uadYkj+y1XyHV+P+Q4eobaAOrqx+BHOxngkZ+JRfIUuOBCzNlLu2KXirl+nC?= =?utf-8?q?RFydR6AZKEG6mCdDV3k6s6HxQRJ3UaQgvhkJT7qPDv/TB5cPPOHD+luLryZlKS52w?= =?utf-8?q?L1CK7lxQeubWip+MkSw2a/WiWwTg+1QbWZm8GwuN7ApK3AcN1v0m3hQHZ3fIIuIib?= =?utf-8?q?4R6942JUawkEhWenI4BG4yciaWaD2hg7aPjRhXjhWoCaJCEy4biDkwXime/FTi8+i?= =?utf-8?q?TDC7jZ8dalsectOxOyk5sJ8mZfj53O/Leh5FJOh+YeZ0Og0wiokCGHemhIZQIc0Wi?= =?utf-8?q?jA6xytK+At6nN7nSbsAC0aUE2xCSzRbEt2C5TbBcYN4cd2hTOvdXQzCxY2Ve6lV8j?= =?utf-8?q?vwapAZFhwLf3dtvBT2b?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3916.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 17:50:51.8968 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: edd9db93-ea7f-48f5-006a-08d8b334c650 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bew4ubldRdVU+id4hHT2Au74SXWOgCtWFXOPm3SUVmGl6sMGIkmboWDIM43IWFqhFvm/yo210wQLUEkaS70c2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3066 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This allows BAR0 resizing to be done for cards which don't advertise support for a size large enough to cover the VRAM but which do advertise at least one size larger than the default. For example, my RX 5600 XT, which advertises 256MB, 512MB and 1GB. Signed-off-by: Darren Salt Signed-off-by: Christian König Signed-off-by: Nirmoy Das --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index dce0e66b2364..390f2cc13df7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1090,7 +1090,7 @@ void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb) int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) { u64 space_needed = roundup_pow_of_two(adev->gmc.real_vram_size); - u32 rbar_size = order_base_2(((space_needed >> 20) | 1)) - 1; + int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size); struct pci_bus *root; struct resource *res; unsigned i; @@ -1121,6 +1121,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) if (!res) return 0; + /* Limit the BAR size to what is available */ + rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1, + rbar_size); + /* Disable memory decoding while we change the BAR addresses and size */ pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd); pci_write_config_word(adev->pdev, PCI_COMMAND, From patchwork Thu Jan 7 17:50:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Das, Nirmoy" X-Patchwork-Id: 12004607 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 E01AFC433DB for ; Thu, 7 Jan 2021 17:52:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8E19233FD for ; Thu, 7 Jan 2021 17:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbhAGRwd (ORCPT ); Thu, 7 Jan 2021 12:52:33 -0500 Received: from mail-dm6nam10on2047.outbound.protection.outlook.com ([40.107.93.47]:61472 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725835AbhAGRwc (ORCPT ); Thu, 7 Jan 2021 12:52:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LkBEkK/s8IKzy3X5F5rxu+MKfhRPoSqbQz4p0pUYg86Dsg41xmupqjOoLAWa3Zk8hVqFOiDoqzqRms172cTD/E7PzA2o6AdT2ayYOB3me5t2V4W2Y9mgFsw2qHVOWwLNunBod6QaV7bCIpHiCIfyqEmSTPWokb0brE9pUxa+8sN2pb5GyZQXHUKi4WJyHdKI/9Yfd53lVVdTXtPj1KnsoOiH2r00R0eveXwVcWRhVRiIYyh+Ar9N1PjzCEJWd5pl6j7CZ+IMLhcoRkSq4BDi7bKYNhb2vLPYjIRXGmAKRXJZ2ms6XSPoHlbpA4Pn2AcD/bdg9NwISewC2BrEXGixBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nqo0XN9w5s1W+dvGkDagPDeomYvgxU34Cpkxni469KM=; b=VFU1o5DBROif/a9UE0VIZ5RMv4x+6sV0bEt9QELiiOde8v8MvTCtPHD1Lywi8qQFPhz6nGKg2Zx5/quiLkA01H2IZlmVTfhJZzVVvxymLmQrxNfehfJTCzK5ekYuSh8zvRFEL5UDebhDSqcvemmTAiGnx9UQcZlbJF1dQ6m4cgq4zdYlup1QaVyFFDpX9B9C3Qh+prMkgvWrGsu59AyvXmhV29rbXllY1/q2GCUWn/76puUdStERWHXVMwoB7HFvoWg26u4z4sMkYQ8t0MmEPM6qbFkTwXTqdA7RJmzOL2Me3TrFq6b/76caCoBLdrecFCWH0z0RI72AmJSLFOCcWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nqo0XN9w5s1W+dvGkDagPDeomYvgxU34Cpkxni469KM=; b=D3PCz7HXFnbSSsxL02L7Fmy1fuUN+tJ7AYc+SX6z/T3Snr3hjKdZ9dBDyDwuMPWfp5DEEsnfCyLhbI9UP9GP0Fu9sHw7efQ9UQVZ2BgFoS2iXHHbrLKx8dWHxNgAMgdCXVI84fSg7UVpCjETG8HGyEGJ9sN96YKgnZYl7s0L0Dw= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) by DM6PR12MB3066.namprd12.prod.outlook.com (2603:10b6:5:11a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 17:50:54 +0000 Received: from DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b]) by DM6PR12MB3916.namprd12.prod.outlook.com ([fe80::f872:3677:28c3:660b%5]) with mapi id 15.20.3721.024; Thu, 7 Jan 2021 17:50:53 +0000 From: Nirmoy Das To: bhelgaas@google.com Cc: ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, devspam@moreofthesa.me.uk, Nirmoy Das , =?utf-8?q?Christian_K=C3=B6nig?= , kernel test robot , Dan Carpenter Subject: [PATCH 4/4] PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse Date: Thu, 7 Jan 2021 18:50:17 +0100 Message-Id: <20210107175017.15893-5-nirmoy.das@amd.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107175017.15893-1-nirmoy.das@amd.com> References: <20210107175017.15893-1-nirmoy.das@amd.com> X-Originating-IP: [217.86.111.165] X-ClientProxiedBy: AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) To DM6PR12MB3916.namprd12.prod.outlook.com (2603:10b6:5:1ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from brihaspati.fritz.box (217.86.111.165) by AM0PR03CA0093.eurprd03.prod.outlook.com (2603:10a6:208:69::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 17:50:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6963acd3-640f-4aa5-d02f-08d8b334c784 X-MS-TrafficTypeDiagnostic: DM6PR12MB3066: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ArjC5EaHuX8NhcuV3FpOUcFk1GWSRl0lO8HjkVAzp1BeyQsyIot8qQ0EknxqpLwESsfQeOMel3UCqK020tUug3IgTw0o86n1rswjVdspQzaCaF3cuujZ4UOz4cjGsf9IwDzGZQml492TZjAgtWizuxsZ+FEGwbor3eP25tVnwh/D1vQFvi/7SbWXw687v+4LD84Uo6wx0cDLCWZWQUffO75twXnqcHlsLX7xpUxqfxHc19/JYwF/PtdbZJv2TtFNg4CGaMkVrZBQVnecU2K/Q3FGuz0Ara+JVgt7/r/XtsRnIXrK+WcncO132V1fy8l+eW9kApQtkjZ1bPQhdXe3UW07B5pROZUEYFU38eZVZ7i1SQleNMk9G1HyQu0McWR0XN/TCeBkHhAAPRihgZyBJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3916.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(4326008)(6916009)(316002)(1076003)(66574015)(83380400001)(478600001)(6486002)(54906003)(36756003)(26005)(66476007)(66556008)(5660300002)(8936002)(66946007)(2616005)(16526019)(44832011)(2906002)(52116002)(6506007)(8676002)(86362001)(6666004)(956004)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?6put+sMivubgGJf7J9TE/AaZ5yQ4dp?= =?utf-8?q?DEl7E+dj3nQROkuRN9KAQ210IQjRb33ZsR/YxgmLnEaBxzT6Eeg05q2ySCgHX8IyC?= =?utf-8?q?WD/H3E5X19GrXvz3Unkf2VMsYoLNOgfdNka0Z2YECKFcTyhmgffnWFtcxXF8k+ZJ0?= =?utf-8?q?eXVcRskGvecyPikqLUSquj1e62X0aGuv0Ygi7ECekaH3iCx9N0jWIWX5Z/kPqIZla?= =?utf-8?q?oRtbuIyPOHYQ68B9KD+pzQTW+UrPiV9Z+6jL7Gf6ubDeMZCsgJF3TyuYBwL/jJwuL?= =?utf-8?q?T0ZkJm7ynbj9Gs8Gw1aSvOdIWikXsWF9IAXsd/XLNYOC9kd9sE/n/pyzgB6if+z3s?= =?utf-8?q?AgQZ8wP6d7xIb93zpxneT3ppMjJ2H4GR//TT8/ww6jGM8XD0FBv2gWkuTDvd0WmGU?= =?utf-8?q?vZ1VNYh9+JaAoi+AQ0TL/w9odsZzm/nSnR1XpRmEcc6B30V0aeZMB31Be3nGfz2wb?= =?utf-8?q?DVhqgHuxdwAB4qvT907gIS/fMUrKFrdM8CNE6GS5FesiKtf/TQcDi1lic4lQGRYO9?= =?utf-8?q?gu7ehC7ivLvkOQr+eFFbBiWtzh4g99YJwlWCULOnScgqKsIqhbQ4Y4yZXHuow0sx2?= =?utf-8?q?rh73lLwxGMPiPyYJSbAGZHnPTGVQU/g7o0C8VEgRZvey/g2UMFsJ/bcFAzEOEcTFs?= =?utf-8?q?d/vtVFIqU5eg2qgMCTXPN2PU/BeBMDQuHDvCZjWg3TKizQX51m7kTSw9GyABHXdDA?= =?utf-8?q?t4v7Nb/gMvEVr/8SDUhAx3Ey7z0aZDoBvbbyG4ufsesuKygr02POCFSAIFwmH8KE0?= =?utf-8?q?6jKygN9Ht0294jLUKeE86a0ZHAo1bAg0ci/4LG6BISxLhcKIOZ3rB4OMOCFtsMuy2?= =?utf-8?q?QLWSNBQCLb9kvGe9YlGi1ZKAxOy96/FC8m/dtIxNZWtnRR5myEHzvWWnTRdXqCSBx?= =?utf-8?q?AZ823Y0FjNWgLFSiXPc8TeDAm8eQYzpgCmK3M6bC786Z1ZpKACsmoiJDMRKAM0Oed?= =?utf-8?q?+7LPA6k0h8S9UAp6xLy?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3916.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 17:50:53.8637 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 6963acd3-640f-4aa5-d02f-08d8b334c784 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fHVbAVxDIg4R1MvrgQZwjAMxiMiw2VDOpH6+8oIzRYQlxYlNfx67AkJ+ENvasg0R9VJVAb3v2+0pfOd5RWQP+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3066 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org RX 5600 XT Pulse advertises support for BAR0 being 256MB, 512MB, or 1GB, but it also supports 2GB, 4GB, and 8GB. Add a rebar size quirk so that CPU can fully access the BAR0. Signed-off-by: Christian König Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Nirmoy Das Acked-by: Bjorn Helgaas --- drivers/pci/pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 16216186b51c..b061bbd4afb1 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3577,7 +3577,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) return 0; pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap); - return (cap & PCI_REBAR_CAP_SIZES) >> 4; + cap = (cap & PCI_REBAR_CAP_SIZES) >> 4; + + /* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ + if (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x731f && + bar == 0 && cap == 0x700) + cap = 0x3f00; + + return cap; } EXPORT_SYMBOL(pci_rebar_get_possible_sizes);