Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3799903ybi; Mon, 29 Jul 2019 12:52:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIC/APKw9zVRqisw3Vu5ek0Gd/xBaNWoCz3A0qRcL6vtnl+fWZnltuxM4kr1G5Nj092aQJ X-Received: by 2002:a17:90a:5806:: with SMTP id h6mr110391322pji.126.1564429954925; Mon, 29 Jul 2019 12:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429954; cv=none; d=google.com; s=arc-20160816; b=la5q7yEWoHcbIBpB6OvPF8xvkn58Fydj+2OCvAhI5Md3TCuMWUe9y63XiOSMh7Onba FyyJZl5mMtH4jXKXlNRDspk9SH+ellVaiBl3nhchyjhUY9CmnrZinciqdgNuN5JrIbuP 0OPqHpGvZGmmD6JJxtLJUxMUSmJOEGDWYZ3wa826eTh0/94AHbzN4rXdad9f+MJfIYfp F2fDY+GHaS7PMG9TySgfzWi1TuvZJEfD7nLIavu2d/HrEcoYWt9uQl1+fUMgQaLChrum MzVcKtY32oVGXp+EzKFIyt6vYCbBAACmd+hSGuAdty3u3KidSLSL9lDho+ekLw85c1j1 Bsog== 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=xpEOFuJW1GhD3tD0F1sZ5xC//IEMFM5BxyLH5VjQR9k=; b=RXtfwV2b1RfKGv6uCeqfvMVcWF0MR23szfoaD/95LOi93ML1HNI7UtjGaE1l+nd7LN DcHX62d/4YJtQ7gavQITkLKx8ucpY9dahntpAINBBsFfR8BscLnApBIXpSkagv2VcmiW CNNFWBqrbbe0eNHJm5tWlrniVMRy9x+1thyiHCeBDPw01Q8+yXtJ5oWx6AWOuFHAKDQT QzrpK6KUXOleGtpiiNhBQ5B4CnXIpzNQuLO67sTy3SDXbSsXtpG5WyKxRDJ5j3WsA6EH 1PiRO1anT/oqXwO4c+agHH6ojMtrbJcE/M3Qq3y4LHhu4NY3S7MCEqs8CP5cn/wb1jtY y+pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lVk4POuA; 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 u15si29236924pfh.213.2019.07.29.12.52.19; Mon, 29 Jul 2019 12:52:34 -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=lVk4POuA; 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 S2390725AbfG2Tu4 (ORCPT + 99 others); Mon, 29 Jul 2019 15:50:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:41964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390715AbfG2Tuy (ORCPT ); Mon, 29 Jul 2019 15:50:54 -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 8F6042054F; Mon, 29 Jul 2019 19:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429853; bh=rZ6BEF+/vB0pxBk7idytzu53Gz6bfW7NZdFFkIUd7Mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVk4POuAZ2fnVI9F7Myx8FLoAfMPfO9qa0vt2zM+Szr9z2ZC87dpueMMMJ2jI768d /pFE0szJvDZWjFA8ysH54JnGPLw4aX4ctsoCueO7+s4LfZAlbaua+BvI47Tyvw3KRW s9oDzsnneegioWc537wU7uSyqkvUBe3/7Wv1OS5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , Sam Bobroff , Oliver OHalloran , Shawn Anastasio , Michael Ellerman , Sasha Levin Subject: [PATCH 5.2 077/215] powerpc/pci/of: Fix OF flags parsing for 64bit BARs Date: Mon, 29 Jul 2019 21:21:13 +0200 Message-Id: <20190729190753.294904333@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 [ Upstream commit df5be5be8735ef2ae80d5ae1f2453cd81a035c4b ] When the firmware does PCI BAR resource allocation, it passes the assigned addresses and flags (prefetch/64bit/...) via the "reg" property of a PCI device device tree node so the kernel does not need to do resource allocation. The flags are stored in resource::flags - the lower byte stores PCI_BASE_ADDRESS_SPACE/etc bits and the other bytes are IORESOURCE_IO/etc. Some flags from PCI_BASE_ADDRESS_xxx and IORESOURCE_xxx are duplicated, such as PCI_BASE_ADDRESS_MEM_PREFETCH/PCI_BASE_ADDRESS_MEM_TYPE_64/etc. When parsing the "reg" property, we copy the prefetch flag but we skip on PCI_BASE_ADDRESS_MEM_TYPE_64 which leaves the flags out of sync. The missing IORESOURCE_MEM_64 flag comes into play under 2 conditions: 1. we remove PCI_PROBE_ONLY for pseries (by hacking pSeries_setup_arch() or by passing "/chosen/linux,pci-probe-only"); 2. we request resource alignment (by passing pci=resource_alignment= via the kernel cmd line to request PAGE_SIZE alignment or defining ppc_md.pcibios_default_alignment which returns anything but 0). Note that the alignment requests are ignored if PCI_PROBE_ONLY is enabled. With 1) and 2), the generic PCI code in the kernel unconditionally decides to: - reassign the BARs in pci_specified_resource_alignment() (works fine) - write new BARs to the device - this fails for 64bit BARs as the generic code looks at IORESOURCE_MEM_64 (not set) and writes only lower 32bits of the BAR and leaves the upper 32bit unmodified which breaks BAR mapping in the hypervisor. This fixes the issue by copying the flag. This is useful if we want to enforce certain BAR alignment per platform as handling subpage sized BARs is proven to cause problems with hotplug (SLOF already aligns BARs to 64k). Signed-off-by: Alexey Kardashevskiy Reviewed-by: Sam Bobroff Reviewed-by: Oliver O'Halloran Reviewed-by: Shawn Anastasio Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/pci_of_scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 24522aa37665..c63c53b37e8e 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -42,6 +42,8 @@ unsigned int pci_parse_of_flags(u32 addr0, int bridge) if (addr0 & 0x02000000) { flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY; flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64; + if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64) + flags |= IORESOURCE_MEM_64; flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M; if (addr0 & 0x40000000) flags |= IORESOURCE_PREFETCH -- 2.20.1