Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1402724imm; Fri, 29 Jun 2018 18:07:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJ5FlZW7jnzuOlEhFIDqcQY8Ua6ZkRcf5GzUjmdx4LZMUySa66tmmcbJo6Bo6l8RS/DQ7D X-Received: by 2002:a17:902:bf01:: with SMTP id bi1-v6mr16928242plb.43.1530320834703; Fri, 29 Jun 2018 18:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530320834; cv=none; d=google.com; s=arc-20160816; b=ZX77pobJb9hU5UCqbOSwWcPoRMlN/Fv2q1SN+MaXAvGUH4Lw7bPSO2tY9/8zqztkG1 FnAQ7QwvklVZK7qX4NfPlGm1aypMDmVPc+UrkCQJxHWrkWyu3Zvbp6+FT21x9G4AFH0E hiQ1yhNYUb+UUOGH8v3IUjMWPvCPrK3hza2fcO/27zF/76ceAxU8Ajl2ZARzzhmTc9hI M1Zexln+WqNMYtqwZQbSpdX/r0DKkc0HqZN1x0yStIlRWohUt847YwnKaMG6xHAOg59n ngBaSNMjMCkVjaPhBEruAoWNBhB12SHTZ5KDxbZxDkwEAz5Er8Iy46tvmpqmxwBZj/on lJZg== 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=tQNHerczOEl/mquyQF8gO6dKwFXxpUhd1QyXfRUkLZ8=; b=BUfWTr7hutMLVfERNrORGDj81NOktgVoo11ftkj3xFLkeoy2lYmxkffow69K0AycFX jJSWwxGbASdIHjFcbzAPs906OnEmiUO1zFi7NI7lJ0LZ0H9XNiabQgK/FXdOOIojXTxl UitIE/tPZJUtqy+zw4+Ijgxz3HwECv0YsVzbvcTzs7YpPkIBcEdB3F3BpmHRxAdQHQFp a7DpgiATRfgI0zv76Q52L2L2E59qLRDNLEWNZjStA+Tq6TPLEwlF00Rb9OuSv2KzsCrm xucbJisHk97JO0BPcHf1w3jG9vDjEVV1bmJiVbVtLH/xettoZH6M5GE9s0StignubZs3 JHrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JfCqnF5i; 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 97-v6si10558839pld.345.2018.06.29.18.07.00; Fri, 29 Jun 2018 18:07:14 -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=JfCqnF5i; 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 S933858AbeF3A5X (ORCPT + 99 others); Fri, 29 Jun 2018 20:57:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:60428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755091AbeF3A5U (ORCPT ); Fri, 29 Jun 2018 20:57:20 -0400 Received: from localhost (unknown [69.71.4.100]) (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 CA8B8280C4; Sat, 30 Jun 2018 00:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530320240; bh=ZZg5zPuu2IzYemSYo2JLZccnFHgur4vPESMpdPn8Qg0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JfCqnF5imsAwQ1Sf1jYHCfOQAyqGnKkAB4bMuRKglpRoy/gtvsugmFh71wwTfetaN k03XUtR2rgrlSpC1yCUDmgsfq47ts6cs6MZhjlJI5A5gOYDXKvmgZvbL7wrYl2WMYV DfiWLa3+qF1BFIRO8Yf9HBm7Wkbyusmwm3CZ7i3k= Date: Fri, 29 Jun 2018 19:57:18 -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: <20180630005718.GJ40928@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 applied both of these to pci/resource for v4.19, thanks! It'd be nice to have them in v4.18, but since it's not a regression and the problem has been there since v4.15, I'm not sure I could justify it. > --- > 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 >