Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2074433ybp; Thu, 10 Oct 2019 01:43:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1h70hqmtxcNu1RD3tbowxXqzFT5Tuum2dwTv7qWwyuEyxSFXsDxkJNLt7ga1E4BNF8LW4 X-Received: by 2002:a50:ab10:: with SMTP id s16mr6885955edc.118.1570697005318; Thu, 10 Oct 2019 01:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697005; cv=none; d=google.com; s=arc-20160816; b=zBYPCz6jV8fSwEFmWHZd46/XaN3TSvttSG5hLv2pKmCmF2VOx4lQgRUQ66FzkOqa6I yfyqeBr9+AKTLQ6lz1EZLGHpTmciC6zVPLuKCpakpM/G+mjvtnQwWE/MzFwubvbQHVcH bnnD+KPH+srMLE65VlvgDe9dKnfoQz/f5syTv2Ct9E0emUU/wEECRWiljd/hrW8m2Tzm +6NgFmixKqSi5hIyMXjCDdqp9odGnrI3TQffTEHEFRc5S+LcRt45QWseigtMnhtqMEk5 KIO4AZiVSonNFvl1BMSh9/aimx5HDu0bfpuksaY3tLnq4vMipW5pv5SM7Dt4zbDiXYHx ghzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mPIiHoXlTF4/NQySqJARV0sDd/jDg3XrzUB/kCySlDY=; b=MNmsmiR4TPuF7Js2VkaaPVRA2dQkyXy014X98dMFfkwGtuVE8r+emb3KlapLUfzoa5 EXu/bgWq1F4C+9Uf7ObnM4iPX7lvyHAIW5al0ck05FaseH4HlJGpesYPhIdgP46F+rm+ GrHDefQYqM3UYK/9sgCaXCJBDhbLApu/7C6y53xTDv94xIAPuUjhRZgBrJHhIWYeMdsA 8V7mDmqvWCh+8HVVHtEpu8nX4iLmSkoTLFJXwEPfR3WH/6FFdLFGqkePA2rRCplhqYCz muw9cjfdWR9PfmVfYRcTZdq1PjGuJy3s3hSn3Df10RKgCTpeFomv5e32d0F/HiHDwPtt AusA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UAOSjTg0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33si3071373edf.121.2019.10.10.01.43.02; Thu, 10 Oct 2019 01:43:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UAOSjTg0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388017AbfJJIkC (ORCPT + 99 others); Thu, 10 Oct 2019 04:40:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733089AbfJJIj6 (ORCPT ); Thu, 10 Oct 2019 04:39:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF3E520B7C; Thu, 10 Oct 2019 08:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696797; bh=ZJWDCC2fU/a/3yXYhKk3XyY44xVH0QvR1aJCNfPUzJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAOSjTg0LNYa9RG+++67/I9oojVCtNLnNMURXR581PwutS2Kz+kjUmWxA6F0RfaUO nE4WtACxJ1wusOiCedru/+nBNQBomPOLNL1sccGDUt5zuVQh/sWlzTAB/5F1XFmS9I HT0NIxoBiHeXeA2bNq7zKC8tbOs69ZvFvWrAAO88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Saxena , Bjorn Helgaas , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH 5.3 056/148] PCI: Restore Resizable BAR size bits correctly for 1MB BARs Date: Thu, 10 Oct 2019 10:35:17 +0200 Message-Id: <20191010083614.542332247@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sumit Saxena commit d2182b2d4b71ff0549a07f414d921525fade707b upstream. In a Resizable BAR Control Register, bits 13:8 control the size of the BAR. The encoded values of these bits are as follows (see PCIe r5.0, sec 7.8.6.3): Value BAR size 0 1 MB (2^20 bytes) 1 2 MB (2^21 bytes) 2 4 MB (2^22 bytes) ... 43 8 EB (2^63 bytes) Previously we incorrectly set the BAR size bits for a 1 MB BAR to 0x1f instead of 0, so devices that support that size, e.g., new megaraid_sas and mpt3sas adapters, fail to initialize during resume from S3 sleep. Correctly calculate the BAR size bits for Resizable BAR control registers. Link: https://lore.kernel.org/r/20190725192552.24295-1-sumit.saxena@broadcom.com Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203939 Fixes: d3252ace0bc6 ("PCI: Restore resized BAR state on resume") Signed-off-by: Sumit Saxena Signed-off-by: Bjorn Helgaas Reviewed-by: Christian König Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1443,7 +1443,7 @@ static void pci_restore_rebar_state(stru pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX; res = pdev->resource + bar_idx; - size = order_base_2((resource_size(res) >> 20) | 1) - 1; + size = ilog2(resource_size(res)) - 20; ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE; ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT; pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);