Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2091707ybp; Thu, 10 Oct 2019 02:02:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNTpC+Pcr9QH4oc2E8qJ1o94nohB5CVwMc6+HTLf0fzE95KXZ4R8bjXXSLVdTRER1gIhff X-Received: by 2002:a50:f192:: with SMTP id x18mr7204018edl.305.1570698176504; Thu, 10 Oct 2019 02:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698176; cv=none; d=google.com; s=arc-20160816; b=FFG8aqR4S8Bh99jgeyf7MVAJTRe3SO+wlm7BUs/oypYsGEO3wUIr8CbBQjoIJW/k3/ sqBx0Zsex4gmhfwcQDAvQsQGQKrlWl+Ta9qf+nzntCmGjPPzCqmIA6MSkRbcjsnHghyW 6stCAqPNo0pxCqS883HSQktxPMV5sy5tqNRrKmQKGx5HgfzcXRLdTcC5tF4I8A1GUJCc SYcD76C3mGIDiSLYLBKhiXam4R5oEEa39CnU268z+mgQakZNOEJsr1sAOrMR0bW4pdwj +SfuZs0FlS/K547xzXNPIMvOMVVDB/3uRgPgqjtwUd95HqJ/s86SkLp0gJWzDvZ4+gi/ PYgw== 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=LlgAYBs+J0cVXzC82PVK+kt2gmo9YcGV62G4XgdUn9w=; b=ezKAwUGKaC/8HDS/Rd72ggesmOqtYyYFH8yq2y71FNACJP2uecax9jS8oF9EK6jFf2 hDLZw6EG9HrycXvrAgubIgzo7B7VgwWottxYr3WgFyvMWcmv/Y6YrZCdz/bw8hn0OAfo TW1BQTGNwacGJDm0EsZ2tEyM4p76H/4cxQPeBb3OyMrF5kcfFb+pZCWmwCDNWB+1y7v3 UjHrG8AGs4ggixruq+a/axd4LuUmssQGu0VJ2r9msfdD74aIVypJRdWwki/5twlU+gYi x0xc03trM82201Hn5rMbF2d0vBOIlE7zgFunDIo5EoZmW2VWSLbr4zU7ac1VJAfCaFqY tGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fQCchUFv; 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 x51si3005108eda.272.2019.10.10.02.02.33; Thu, 10 Oct 2019 02:02:56 -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=fQCchUFv; 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 S2387980AbfJJIjv (ORCPT + 99 others); Thu, 10 Oct 2019 04:39:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:43642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387971AbfJJIju (ORCPT ); Thu, 10 Oct 2019 04:39:50 -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 CEA8F21920; Thu, 10 Oct 2019 08:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696789; bh=TGYeBg12/iq0HiGgbjcQSknzFHxK4TpcgEVOsKH/c/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQCchUFvBE03VyozYOmkfipj1Ek4XiDidZh1l7c9e8aQhWB0+sP50A0CzFAGUVQLI Wee3ZQ9DjtvM9mnPsAlgsyobzQXCqwoEj5m25+1jrxVtjzcM7bWCBstVYVN7Gks4kv yuQwC6GVvpsnXbkB3IbgAW0i+VIsFPJbnHPLGxIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Derrick , Lorenzo Pieralisi Subject: [PATCH 5.3 053/148] PCI: vmd: Fix config addressing when using bus offsets Date: Thu, 10 Oct 2019 10:35:14 +0200 Message-Id: <20191010083614.366709635@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: Jon Derrick commit e3dffa4f6c3612dea337c9c59191bd418afc941b upstream. VMD maps child device config spaces to the VMD Config BAR linearly regardless of the starting bus offset. Because of this, the config address decode must ignore starting bus offsets when mapping the BDF to the config space address. Fixes: 2a5a9c9a20f9 ("PCI: vmd: Add offset to bus numbers if necessary") Signed-off-by: Jon Derrick Signed-off-by: Lorenzo Pieralisi Cc: stable@vger.kernel.org # v5.2+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/vmd.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -94,6 +94,7 @@ struct vmd_dev { struct resource resources[3]; struct irq_domain *irq_domain; struct pci_bus *bus; + u8 busn_start; struct dma_map_ops dma_ops; struct dma_domain dma_domain; @@ -440,7 +441,8 @@ static char __iomem *vmd_cfg_addr(struct unsigned int devfn, int reg, int len) { char __iomem *addr = vmd->cfgbar + - (bus->number << 20) + (devfn << 12) + reg; + ((bus->number - vmd->busn_start) << 20) + + (devfn << 12) + reg; if ((addr - vmd->cfgbar) + len >= resource_size(&vmd->dev->resource[VMD_CFGBAR])) @@ -563,7 +565,7 @@ static int vmd_enable_domain(struct vmd_ unsigned long flags; LIST_HEAD(resources); resource_size_t offset[2] = {0}; - resource_size_t membar2_offset = 0x2000, busn_start = 0; + resource_size_t membar2_offset = 0x2000; struct pci_bus *child; /* @@ -606,14 +608,14 @@ static int vmd_enable_domain(struct vmd_ pci_read_config_dword(vmd->dev, PCI_REG_VMCONFIG, &vmconfig); if (BUS_RESTRICT_CAP(vmcap) && (BUS_RESTRICT_CFG(vmconfig) == 0x1)) - busn_start = 128; + vmd->busn_start = 128; } res = &vmd->dev->resource[VMD_CFGBAR]; vmd->resources[0] = (struct resource) { .name = "VMD CFGBAR", - .start = busn_start, - .end = busn_start + (resource_size(res) >> 20) - 1, + .start = vmd->busn_start, + .end = vmd->busn_start + (resource_size(res) >> 20) - 1, .flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED, }; @@ -681,8 +683,8 @@ static int vmd_enable_domain(struct vmd_ pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]); pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]); - vmd->bus = pci_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops, - sd, &resources); + vmd->bus = pci_create_root_bus(&vmd->dev->dev, vmd->busn_start, + &vmd_ops, sd, &resources); if (!vmd->bus) { pci_free_resource_list(&resources); irq_domain_remove(vmd->irq_domain);