From patchwork Wed Dec 15 14:16:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 12678405 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF054C433EF for ; Wed, 15 Dec 2021 14:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243238AbhLOORA (ORCPT ); Wed, 15 Dec 2021 09:17:00 -0500 Received: from mga02.intel.com ([134.134.136.20]:37982 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243259AbhLOOQ7 (ORCPT ); Wed, 15 Dec 2021 09:16:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639577819; x=1671113819; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=KMvhkk6usIByMbzw+cv/apgyMjiq4ru49hJ3EjEocQw=; b=jaOUHOem/FKXWqIkQmhpOXNVPWgPohRWwrPC/hbtPBSqc4P93JmA7/vE aEyHOQzsBFXbsWzfjQ7j4gjCUuz+3CMJMs/p6Pi6X1WQ6Gek4/UtJ5Tj4 qSz9+x0EBz/NF/Qq0+2p2RBy1m+vBPO9Ipm9NbmyciuBnsAzXzk5SqP/3 zfD0y7QqEutJ/zX7EflrEnDwcG1aQ4klX9SYRB511N/0I9brj1r4dIKrw PBepbO/95r95+wQqnKTh9CKXfm54+UlOvztrjoI968h2HHNSDtVbweyav izPM2KYHNMaWuW2r7LldY8SZQDGHyIrcbFHY6dMAwn6j4IQS8rkvF1bDE w==; X-IronPort-AV: E=McAfee;i="6200,9189,10198"; a="226516564" X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="226516564" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2021 06:16:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="567937522" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP; 15 Dec 2021 06:16:58 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 15 Dec 2021 06:16:57 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Wed, 15 Dec 2021 06:16:57 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.177) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Wed, 15 Dec 2021 06:16:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LNIPcgArHJNgN5ZkDdHv4W3py0uD0RsuaR8xsH7DOwIFJDAg11L3iIyW0TOXxBI5hHcbTGkFmYQS5u3jprKrLDYlzhrsiwqAFZm06To4MHhxK1dfpqn7dVfEw+tK6G0MOFMATkiAlD4oxkqpbsGTiaRDypkZbk6OzI1XF0L3Qg8HvwuTwU6sfOEVYw4ci0tDhZbH+KGL6t3fMwU7I/Wmc5b1HzNI6XtX4RoWKAffa7y1GHvmf9zlYbrPgYltq0lSDug75rHcfNHtoeFOjlZk3mxrXh1kAg97NnqqXHNbvhvF63v4LpAtEXeVuTLYuM5PexsTtGBvLs8v++mbJCEz7g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2XR1iu2fghQXq8zY3CEx5tgP6YcAnzyzBG13HDzqaN8=; b=YRGo0kXCk+bHhZaAOZxvOboN6aJZAOcqXtTdkHPEV79aDrbVeReAIiKmREUe3K2/EnZFi49YNP0rDKYunzdM6rUP/wh70hbQPpK42A7wnOUxaJCQ5gtNsmsk+uhJFd3oz5ghfNhJXuptIbZZjW/Mvww3OTeoDPg1xv4fbO6cZ/bpFSgrbT04TNYc1pZZRURNEADHWUTg8RB4gw7nxuMmXAX/qy0OzrXJgjusiZWerlNuFFkN0jrieyPqyJQEm7wwcyaG2smbkAMXnwlgnykaOUV8ctxfJ3rfQVO5lN9fLcmzkpTWuevAX330+zivMckLF1RjXFWQ6uHbPcZ2NKDYZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by DM6PR11MB4740.namprd11.prod.outlook.com (2603:10b6:5:2ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.15; Wed, 15 Dec 2021 14:16:55 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::54fb:8c9f:670:3658]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::54fb:8c9f:670:3658%4]) with mapi id 15.20.4801.014; Wed, 15 Dec 2021 14:16:55 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Bjorn Helgaas CC: =?utf-8?q?Christian_K=C3=B6nig?= , "Ard Biesheuvel" , "Michael J . Ruhl" , Rodrigo Vivi , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [PATCH 1/2] PCI: Add support for VF Resizable Bar extended cap Date: Wed, 15 Dec 2021 15:16:25 +0100 Message-ID: <20211215141626.3090807-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211215141626.3090807-1-michal.winiarski@intel.com> References: <20211215141626.3090807-1-michal.winiarski@intel.com> X-ClientProxiedBy: LO2P123CA0030.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::18) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8261a6ff-9f20-4331-eec6-08d9bfd58c6e X-MS-TrafficTypeDiagnostic: DM6PR11MB4740:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7OT8SY43X20PcDdsU90NOkCGx3CKuNs7wKUovucbDK8s22HnC1QHN5rKb3TSQ4ZyCPIYvnYKODoukKKc4IvKhPIjkBiVA4oFKsaus05/6VY6DnKfTye5EqryfiTzyk/CS6Nc6H/OBTOU2ilT4Kh8RP/Uack1vBYFrswEjYEzXJINuV/oYJBRWb7FGwE5nk2izd+U3f2gzCkISJojXRZbdidRxd83QLfnELQ9G/yhM4Dz4erPueKwBgJ0WMTy3H0/J9hveuDt/omhq7aJ4a/iIKcUGfAIJ6koP5JtKof7pCX5NsYnQGPSG9RMKI1HvXOBD2wuZbUU4aA6cQztOA6JQtG9HHojH4wm7h0zHqRJQSMEIyKHWyO0DrNRssETOOPie+kMI3oCVDDHx8IsVZb/mgAtHilU0wruqZPNYpqAtzoGrtu3edZdGrYS9aw9xqyj4dXT//3qpWNlcjbzsT8nVoiW51B+is14SpaAwyyB+zwUVPQMDQhPKuzAJ27pffqfq+g3e9uyMbMBU5Cdlvo00l+eWUfNuYxSyc6DIyHQzFIHSAdx4WBKMQDjEajopiR6ZCmJxIDhhvQDVAkBwe6yahaaIeLWs+WYnmFLRmPu/7SKI0fSFRfKLuZIF58ntcuqeVetHhi4J/Cy/Za7095fWA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5373.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38100700002)(508600001)(6666004)(83380400001)(107886003)(54906003)(2906002)(8936002)(4326008)(5660300002)(6512007)(26005)(66476007)(82960400001)(6506007)(316002)(6486002)(6916009)(36756003)(66556008)(86362001)(66946007)(8676002)(1076003)(186003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IR69CtLCgI4ZNAalDgWAi1KYHK1v?= =?utf-8?q?bXogoXe1N8BFRHmSi/+QVAK5Dvr8gkF75Rwf7AY0qFcL+/Kgkrs7hlAdVSIW0xrx2?= =?utf-8?q?tvU97SpSypR2MriGrecTlvv3HLqbN2jb0LNF2xaBrsz99ZnZsruyc4c+9DosdmIOt?= =?utf-8?q?o55dxCBssOJNGO/4AHs5owQp6Bnkf01RE2jmTbdd7hFtcRr4fFtIZIkrJk/LAOb+W?= =?utf-8?q?w1yFSyn7HPlgUsip3ahNtBnbCdQ+uQnXOQZktfO9lafb4W1YE6zhxEi8uGHcffX3S?= =?utf-8?q?8byYuQyPMd4+pFumGwtkr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W/IReVezhEkDAWMxUR+j0niuvCc48e6eDYLh2Puqz04?= =?utf-8?q?Z7DSGWq1FG7uuIFN5Hpn9yZOf+HNfLG7D+7LoUUV0liNakL2LSIe70A952wxNpxBq?= =?utf-8?q?Dzjztx1VSxeYjPHGTjWacRZLGiPkawSdNwsDCLUon4FA0vWbqUpivGCtHDJnGd+tH?= =?utf-8?q?v+f/HMmPwQUZx0tnmAGiVkK8+IG4y4aFeEpXy7izaLszpwPwAvPC/ZHqixTUPliUm?= =?utf-8?q?VWFqmxS1Xkv6ozxDRTk5ryJ4EMVZrxPcl4Qgz4Enmly6DF6rXLooycIr7myekS3P6?= =?utf-8?q?AKeB4uyN/etrGojNpucmC3cXZr14yi/vQ3hI9tlv9OsJTDN/5qy4d+c/C7yEwCsdO?= =?utf-8?q?tb/R3VrvUGN3Mjs0ckXslggsQRaHkwexyUv+pTLOGgBHfU9UBP3EiFpD5HaIks6Uc?= =?utf-8?q?HVxKk9b4+cG1ItQN351gu/upGSUb5KD0w=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8261a6ff-9f20-4331-eec6-08d9bfd58c6e X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2021 14:16:55.6061 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Usw4MKCsCAYE9y/I8PCWxXVDVky1DwWw6SJYRRL/e/lxmQi2J/18DTrHe+Mi5tAPR9/P4FNDye70jLb65ab5G/ySDyNS7hvfOS13sfn1q2I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4740 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Similar to regular resizable BAR, VF BAR can also be resized. The structures are very similar, which means we can reuse most of the implementation. See PCIe r4.0, sec 9.3.7.4. Signed-off-by: Michał Winiarski --- drivers/pci/pci.c | 25 +++++++++++++++-- drivers/pci/setup-res.c | 53 ++++++++++++++++++++++++++++++++--- include/uapi/linux/pci_regs.h | 1 + 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3d2fb394986a4..89448c5104e46 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1682,12 +1682,15 @@ static void pci_restore_config_space(struct pci_dev *pdev) } } -static void pci_restore_rebar_state(struct pci_dev *pdev) +static void __pci_restore_rebar_state(struct pci_dev *pdev, int cap) { unsigned int pos, nbars, i; u32 ctrl; - pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR); + if (WARN_ON(cap != PCI_EXT_CAP_ID_REBAR && cap != PCI_EXT_CAP_ID_VF_REBAR)) + return; + + pos = pci_find_ext_capability(pdev, cap); if (!pos) return; @@ -1709,6 +1712,14 @@ static void pci_restore_rebar_state(struct pci_dev *pdev) } } +static void pci_restore_rebar_state(struct pci_dev *pdev) +{ + __pci_restore_rebar_state(pdev, PCI_EXT_CAP_ID_REBAR); +#ifdef CONFIG_PCI_IOV + __pci_restore_rebar_state(pdev, PCI_EXT_CAP_ID_VF_REBAR); +#endif +} + /** * pci_restore_state - Restore the saved state of a PCI device * @dev: PCI device that we're dealing with @@ -3639,10 +3650,18 @@ void pci_acs_init(struct pci_dev *dev) */ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar) { + int cap = PCI_EXT_CAP_ID_REBAR; unsigned int pos, nbars, i; u32 ctrl; - pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR); +#ifdef CONFIG_PCI_IOV + if (bar >= PCI_IOV_RESOURCES) { + cap = PCI_EXT_CAP_ID_VF_REBAR; + bar -= PCI_IOV_RESOURCES; + } +#endif + + pos = pci_find_ext_capability(pdev, cap); if (!pos) return -ENOTSUPP; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 7f1acb3918d0c..1946e52e7678a 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -407,13 +407,36 @@ void pci_release_resource(struct pci_dev *dev, int resno) } EXPORT_SYMBOL(pci_release_resource); +static int pci_memory_decoding(struct pci_dev *dev) +{ + u16 cmd; + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + if (cmd & PCI_COMMAND_MEMORY) + return -EBUSY; + + return 0; +} + +#ifdef CONFIG_PCI_IOV +static int pci_vf_memory_decoding(struct pci_dev *dev) +{ + u16 cmd; + + pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_CTRL, &cmd); + if (cmd & PCI_SRIOV_CTRL_MSE) + return -EBUSY; + + return 0; +} +#endif + int pci_resize_resource(struct pci_dev *dev, int resno, int size) { struct resource *res = dev->resource + resno; struct pci_host_bridge *host; int old, ret; u32 sizes; - u16 cmd; /* Check if we must preserve the firmware's resource assignment */ host = pci_find_host_bridge(dev->bus); @@ -424,9 +447,14 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size) if (!(res->flags & IORESOURCE_UNSET)) return -EBUSY; - pci_read_config_word(dev, PCI_COMMAND, &cmd); - if (cmd & PCI_COMMAND_MEMORY) - return -EBUSY; +#ifdef CONFIG_PCI_IOV + if (resno >= PCI_IOV_RESOURCES) + ret = pci_vf_memory_decoding(dev); + else +#endif + ret = pci_memory_decoding(dev); + if (ret) + return ret; sizes = pci_rebar_get_possible_sizes(dev, resno); if (!sizes) @@ -445,6 +473,14 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size) res->end = res->start + pci_rebar_size_to_bytes(size) - 1; +#ifdef CONFIG_PCI_IOV + if (resno >= PCI_IOV_RESOURCES) { + dev->sriov->barsz[resno - PCI_IOV_RESOURCES] = pci_rebar_size_to_bytes(size); + res->end = res->start + + resource_size(res) * pci_sriov_get_totalvfs(dev) - 1; + } +#endif + /* Check if the new config works by trying to assign everything. */ if (dev->bus->self) { ret = pci_reassign_bridge_resources(dev->bus->self, res->flags); @@ -456,6 +492,15 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size) error_resize: pci_rebar_set_size(dev, resno, old); res->end = res->start + pci_rebar_size_to_bytes(old) - 1; + +#ifdef CONFIG_PCI_IOV + if (resno >= PCI_IOV_RESOURCES) { + dev->sriov->barsz[resno - PCI_IOV_RESOURCES] = pci_rebar_size_to_bytes(old); + res->end = res->start + + pci_rebar_size_to_bytes(old) * pci_sriov_get_totalvfs(dev) - 1; + } +#endif + return ret; } EXPORT_SYMBOL(pci_resize_resource); diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index ff6ccbc6efe96..7f5726d23b038 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -734,6 +734,7 @@ #define PCI_EXT_CAP_ID_L1SS 0x1E /* L1 PM Substates */ #define PCI_EXT_CAP_ID_PTM 0x1F /* Precision Time Measurement */ #define PCI_EXT_CAP_ID_DVSEC 0x23 /* Designated Vendor-Specific */ +#define PCI_EXT_CAP_ID_VF_REBAR 0x24 /* VF Resizable BAR */ #define PCI_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ #define PCI_EXT_CAP_ID_PL_16GT 0x26 /* Physical Layer 16.0 GT/s */ #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_16GT From patchwork Wed Dec 15 14:16:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 12678407 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E15B2C433F5 for ; Wed, 15 Dec 2021 14:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243274AbhLOORJ (ORCPT ); Wed, 15 Dec 2021 09:17:09 -0500 Received: from mga01.intel.com ([192.55.52.88]:61506 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243270AbhLOORD (ORCPT ); Wed, 15 Dec 2021 09:17:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639577823; x=1671113823; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=WbKGQwzNFtHUjDhP3/EZTCvTtjBwzUn8wYIkln3iTjs=; b=OUwUCRGRokEaQqc2D3Mj3M6QOseSGiKc1ZlIL9EZY5IJ64j4Uu9POBjc 2Ky2AmG0iPvYFJWhEIFUInUQstVp2nFwgfcMK0oCuOFB/K8bCB0mgn9ji UaTc2tp7jPAhsQ2H+hOmBcBy1RgYwUHNCPEFjcAlGjchgtqGz2nlSEXCU s9fLlusoGeZEjWK1DP2U74TM9ThEca2QGTKK5415HdIxImmVf1LCA76Vl /ROLL430QJMXnlBVNprK55WHtwjKjf/nnwXP34LAZ72ntuEJ8ISXu+Ccz FGfRyQYqhx/HgyJcaMh37jK/5BzCg0fsouqmAuS2Agr3pqGsfmX6UPRuu w==; X-IronPort-AV: E=McAfee;i="6200,9189,10198"; a="263385685" X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="263385685" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2021 06:17:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="755378755" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga005.fm.intel.com with ESMTP; 15 Dec 2021 06:17:03 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 15 Dec 2021 06:17:03 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Wed, 15 Dec 2021 06:17:03 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Wed, 15 Dec 2021 06:17:03 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dw9nf5f0hUYKGcLW1hagJJdJX2jZAJ/LLJZfjvE0w0et5cxIAczvbTP2wVdJ8B//LkJbJubpEBgtT4EJWkQhO8qwgERKvPCYXnZjoVg0n+7LTE1G2NrLiAzKevlwiPOPUdp71nexlv6XIHjGX9GYi1fK6gXP0mN72ZMG0hbmePgF6P4HHn0YRaarb231gNwNPMKRLyY9ulq5yGUg55GNGaM80utzZn8citFVjAivReivzeP0psVq3jmWCRqE9Zmt8onBKdgptRn4tLsqFZC9KLC6Jz/m3qzAh002Gnuy506tY0yyH0yvrZUED6Y2tj3XhdvGvpeAt6pA5I55pSPDgw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QVlrTDWM4h97SXpRYcoAm1AWlO/yIzV1Qu2W4wzILsk=; b=TSym8PcqPiNLvfLFNsKHlQLrvwYuDgrmYmgusXxf+Sj7fxFmcPv7MnwZzM4YhBmc5DZy69+GK2+2iRhQ3jEQsFiioZS3g3qDtuYklaJty6kb08EAzXH2ohtq6oWs8DTPhqNaTOceFOodwO6XfTtiMxTYDApxnlrBiAfKygWHRxUQVutFcyltEUYTFE5vMSwk2L7daK0ZDOPat2LUQoqSB0NrwKrG8zifJdIa4G8/VKtOO6wG4JMLvd9suT/QHNbh3Mo5dxqdJhzghRM6eGLm0VM5WUA4WHsygqiKFSIQp/UGLs8Zk0MhyU87h3kGLqgPx4f7c5+H5ll+UOMiJpNIsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by DM6PR11MB4740.namprd11.prod.outlook.com (2603:10b6:5:2ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.15; Wed, 15 Dec 2021 14:17:01 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::54fb:8c9f:670:3658]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::54fb:8c9f:670:3658%4]) with mapi id 15.20.4801.014; Wed, 15 Dec 2021 14:17:01 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Bjorn Helgaas CC: =?utf-8?q?Christian_K=C3=B6nig?= , "Ard Biesheuvel" , "Michael J . Ruhl" , Rodrigo Vivi , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [PATCH 2/2] PCI: Don't fail BAR resize if nothing is reassigned Date: Wed, 15 Dec 2021 15:16:26 +0100 Message-ID: <20211215141626.3090807-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211215141626.3090807-1-michal.winiarski@intel.com> References: <20211215141626.3090807-1-michal.winiarski@intel.com> X-ClientProxiedBy: AS9PR06CA0257.eurprd06.prod.outlook.com (2603:10a6:20b:45f::11) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec133b13-6eea-4dbe-0a76-08d9bfd58fda X-MS-TrafficTypeDiagnostic: DM6PR11MB4740:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wgPRr5FZ+J8fmdUhUzeRW6Q88jm33nFpw4gDBbwpPwQlO4TSETwme4xUJOnhLxT1SC6ATdzIHHi95OV39LUePM8G48ySLaRUU1ilkJIeh6CnyubI14HgfZi/kUSzgMA1pT5gaXrzHUzm6hIMzLAdsZw+dnZ4gQDgkaW6SWsz/stzkG4OTozxmTnhFVfbEdEQDhKP0nyZF7GqX00D+aq10lr1BTHNNem0FFCQL9oQFIa3+21trBCP48aT17AcoeGMi4Gmyf8TRfDnuGi8+usd3GsbF0H/0p5ty8pGPralm08JD7Px2aHY2Z6jj4SjLH6vYy2XYX8yetBjJSun+maD1xJKseiKx7bKOq8+I6aV1Fx5Ok60WHm1S95elxVuVg68SSPK0GfRFoI9YhUnoul/pEWNuR6Xs0BTIIFlVnlpY9MjLhBFrLQSzXGrhfeQ1f4q/m3lUdOjnysmmBApAh/ykvGZPlRV1dU/jcYRqo5rOkqMO8oHfz8fCx80iVTnyiqxpazCwOekiAh3bhr8isXmOBLt7sVLJYcaMfdXjUT+t+sOT9qhIx8PalOMOlJ8MZRCXf2FJtGDSlX/huII/s+lkxloTv5quKgE8Dvcx57h2dStfvm9UVibYV26ClqssLNhXunFtwA/DqVGSETve92l6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5373.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38100700002)(508600001)(6666004)(83380400001)(107886003)(54906003)(2906002)(8936002)(4326008)(5660300002)(6512007)(26005)(66476007)(82960400001)(6506007)(316002)(6486002)(6916009)(36756003)(66556008)(86362001)(66946007)(4744005)(8676002)(1076003)(186003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dfh6a4TeCMzHV/YJ+mN3bLs6s45Q?= =?utf-8?q?f2Nv0GB8L2WJrduSX+VWrvy9EcaJ0DmbIW05GC8HHI4OAsAOMpimH6ds45srMkjHz?= =?utf-8?q?RavATL+6XJ4audy4SgGqv8q8/0iPbH+4FttSHov8lyYhpSnLtCHGO9y0CMpL8kAaE?= =?utf-8?q?ryqer27ng/k2UylapvEKDI7ChMyb6h92SUT5eihLZ/0ETiGiW021cufLjP5Vl0kkL?= =?utf-8?q?Xua3KGLkU8wGcEMbLcIjNKA5jd2oFqRPJpLektyL1wW6wRkrxUXirwJ14so86mjgk?= =?utf-8?q?0yXQvrh7s1v7vpckAC12q/lmoUVpI9yH2gupbOWGldGl2+awBlFAVbj/vkBENQYo/?= =?utf-8?q?T+qZ1UxDRML0fhmFT+ETZo7iiLmvz1zMpGJp1jbiu1umayMTqdWrAA6iGJvImPNg3?= =?utf-8?q?wNS0Gm0mdXtv/inR4zJhfEke2JDiI/ig5u1wsVlwiJYQaTdrghI9xyLejmlD0pHs7?= =?utf-8?q?u7dhMZ7hkm0bxK9WZcOIOd/dEgRV7+A7SF0De6U9GaAmWQ1DV1qchdVJpURY+HdbB?= =?utf-8?q?d+Gm7oRiQG3NOnjns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MSDPiwlS8chY/H82xOFvCSkDkSk2Du6g0OxtaUuBKBVFU?= =?utf-8?q?mlxjsLAkwimx1mH9mUBisF8LgGl/e2EnngzcOFEHqCuDvTKhjcKU2Bq0gDrsduUoU?= =?utf-8?q?hFP2frBM2elrdMBingVZLKAmG0jz8Ly/9Z6vgoJMahP0yh09toPOINjq+ausCt7/e?= =?utf-8?q?LKF2n2EmvbVl/PQUW9ORe+svB6twICP+w=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ec133b13-6eea-4dbe-0a76-08d9bfd58fda X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2021 14:17:01.2787 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: InFRK2bTR8lGCkfDtZFX9YzgFnI/v/CfyqzmAtqDmGvqKlGKairqK9I2+p8rqfOcgW1dbFONQrfSkG7Pv7VFNRDoM8nWUy8HAwhAd7dy0sw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4740 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When pci_reassign_bridge_resources returns -ENOENT, it means that no resources needed to be "moved". This can happen when the resource was resized to be smaller, and it's completely fine - there's no need to treat this as an error and go back to the original BAR size. Signed-off-by: Michał Winiarski --- drivers/pci/setup-res.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 1946e52e7678a..5de5129055e0a 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -484,7 +484,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size) /* Check if the new config works by trying to assign everything. */ if (dev->bus->self) { ret = pci_reassign_bridge_resources(dev->bus->self, res->flags); - if (ret) + if (ret && ret != -ENOENT) goto error_resize; } return 0;