Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1880imm; Thu, 28 Jun 2018 12:44:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJEhCKNByEVJrRWqrRNVMbQjg3bKPU/2UY25LJH/QtoF6uTn+YgH1JjJDgrSLxlmgk4Rati X-Received: by 2002:a63:107:: with SMTP id 7-v6mr9769370pgb.289.1530215083326; Thu, 28 Jun 2018 12:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530215083; cv=none; d=google.com; s=arc-20160816; b=uO8ZpMQ67AugPXNZICqOrxaBY1scKbA4Jcwi9Ix7BWkHXcWglR421y1TG+B1AxVWhg FcK4XHVcGbSaVC2cB/sROxTySK0dk7a4XwTdQfd7EJfZyOI0M+dUJqsibbC8uLUC6/zv UVjZFbwMfy9P2cvo9FGuBnJI3i4iLz+AB3cqLo+hDLxz15Pa9MUKzt1GJXO+4mP2D/e5 yhy5TDFqHxW6AstYdL60jpWzCoEDFpGRnsTvowh5dtd1/xRL4eIHPhCr5KGKbWnENn7D WdHvkC3VC7mdrB68Pm5AxxQw7UxP9eCrmoSwjxYYQGZGFKnDIX6IWbL4bJ2GDFffRqQG tN4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=k2GI9IE519mokT5HqukR7gXoGEn7swhf7CCiXDLS7PM=; b=j+6ahqeoXh9Xzb6RPBOLFqfwymX6ahz8J689vvq2w5wJI27/5L5TqJ5ATyxnbtNBXz LRjp6jD9xQ84nQsgAslHYH8y2OAucsa2LPQcx5j3ayp5/6u8e1477WPFJ84DXsEIOKkO VsoK/KqiMD/JtcIrxHwVtesukRwDcGscjA7gDv4OkN3SWILQducofTHGvJA3SelE9s57 SzQfiAT+b8gWYJF+9yT5Gx1hbAOCJIMBSiw08AbekMayHegtyHCLEeFO9/tOkQ3WZydU FtQxUiW0Z32QAIhMQSkWBXz3TvNdkwwPhSyLn1Z3eMJJD/A8GQe0CvcSbN7PFZwmvpT0 xfTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IkSl0Xod; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13-v6si6885299plm.99.2018.06.28.12.44.29; Thu, 28 Jun 2018 12:44:43 -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=IkSl0Xod; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967872AbeF1S15 (ORCPT + 99 others); Thu, 28 Jun 2018 14:27:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:40626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966340AbeF1S14 (ORCPT ); Thu, 28 Jun 2018 14:27:56 -0400 Received: from localhost (unknown [146.7.4.71]) (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 F35D625272; Thu, 28 Jun 2018 18:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530210476; bh=7TqJQmI+4f2mDDdpqOv3VmukRmgPSkpiKbm7emSNBy0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IkSl0XodEOOt23IMP251kNN3wfmm5Ik7ef/fWtbbVyIHL2YRnx6K5UboxbPGKrh/x j51rD/npX4SotvASCd7TegEGGRVg6xaVJYRGQKmYyT7zUZmevTkhyFdfl0Znw+u43Z 8jLKAcW445fOSUvh67QjRgwDCtka2Y6orN2iYhx0= Date: Thu, 28 Jun 2018 13:27:55 -0500 From: Bjorn Helgaas To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] PCI: fix restoring resized BAR state on resume Message-ID: <20180628182755.GC120578@bhelgaas-glaptop.roam.corp.google.com> References: <20180614122146.62118-1-christian.koenig@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180614122146.62118-1-christian.koenig@amd.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 14, 2018 at 02:21:45PM +0200, Christian K?nig wrote: > Resize BARs after resume to the expected size again. > > Signed-off-by: Christian K?nig > BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199959 > CC: stable@vger.kernel.org # v4.15+ I added Fixes: d6895ad39f3b ("drm/amdgpu: resize VRAM BAR for CPU access v6") Fixes: 276b738deb5b ("PCI: Add resizable BAR infrastructure") Per the bugzilla, the bug was bisected to d6895ad39f3b, which appeared in v4.16. But 276b738deb5b appeared in v4.15, so I'm OK with the v4.15+ stable tag. > --- > drivers/pci/pci.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index bd6f156dc3cf..d4685090378b 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -1159,6 +1159,33 @@ static void pci_restore_config_space(struct pci_dev *pdev) > } > } > > +static void pci_restore_rebar_state(struct pci_dev *pdev) > +{ > + unsigned int pos, nbars, i; > + u32 ctrl; > + > + pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR); > + if (!pos) > + return; > + > + pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); > + nbars = (ctrl & PCI_REBAR_CTRL_NBAR_MASK) >> > + PCI_REBAR_CTRL_NBAR_SHIFT; > + > + for (i = 0; i < nbars; i++, pos += 8) { > + struct resource *res; > + int bar_idx, size; > + > + 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; > + ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE; > + ctrl |= size << 8; > + pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl); > + } > +} > + > /** > * pci_restore_state - Restore the saved state of a PCI device > * @dev: - PCI device that we're dealing with > @@ -1174,6 +1201,7 @@ void pci_restore_state(struct pci_dev *dev) > pci_restore_pri_state(dev); > pci_restore_ats_state(dev); > pci_restore_vc_state(dev); > + pci_restore_rebar_state(dev); > > pci_cleanup_aer_error_status_regs(dev); > > -- > 2.14.1 >