Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3133152ybi; Thu, 18 Jul 2019 21:40:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7DT/3uV5es6YKl6s7QzJ7nd0/nPwRMBrR8gL3x5o/DXse1BR+DqssF9+Bms/N9/wCG1+R X-Received: by 2002:a63:6ecf:: with SMTP id j198mr51420646pgc.437.1563511245529; Thu, 18 Jul 2019 21:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511245; cv=none; d=google.com; s=arc-20160816; b=BRon19ysm2XpbdOVHhjioTiITKpxRCf1mfGfcnthqibVGdZ5T/9EQH2EYglbLWj3cK pdzBWXR5+TcvpNuE4ev3GRPZ5FPtdLRNfwJQVi4sXUKnKk2cik2JcFdbONhxE2pF04l0 u+7umPRfF7QtYR05yaFCkDP/bZ9e2MYP8GH6gkGBlrrc5q2SevbG9QiphnzFUkXUXMAE wQrFPPtLgg8zWya+7YFmcx8/gTocwBnYV1t9RRGLxEJg+4LPeg2T8dfdSfvkJQbqOEO5 5vZR/QVDUphFGa2blVOQX06i/FM1zNfP+lk52a+6TIR2cMZ9A+0Oi0nn5pTjHbwoxv0k 13Xw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FtpSmohDBvTzydm8ac5AZ4/phn+ktRkfWvHmZk9ccPg=; b=iBA2YBnrHtiVMGvSkZjxP00VbAtkZxK0Q0iTq8jehfrdataK8YXIVH5psZDkuzTESO jwsJE6h92IJlYaAWLzaoT6+midZqelCHZaTUVnJIcs6kD5XtspfL7crZIl9Q0jm2ytri 6xFR3rIqFRxaFvpGt5tjHTArzGHPjrqOrNAaUd8F4rbWv/Pj74bth5A+JuM7lOpKHI4W 3sJhrwNTwi7fE7GN6jivJgZfOKgK2IiUQ3KoByrhVrqx5myLpykI1QlUFUejinWL7a3U PUm1ITTpJIuDV1ESyFnrIuY7DnqdFucnwlYZEzQLaJPgCYUGiOsa/YM4GU4Wf1yD6ntl 7D8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mxFbYoJl; 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 bh4si514615plb.198.2019.07.18.21.40.29; Thu, 18 Jul 2019 21:40:45 -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=mxFbYoJl; 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 S1729751AbfGSEiN (ORCPT + 99 others); Fri, 19 Jul 2019 00:38:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728705AbfGSD70 (ORCPT ); Thu, 18 Jul 2019 23:59:26 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BFFF21855; Fri, 19 Jul 2019 03:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508765; bh=k9Z0PZaDpi4CULLhNh5P7Ql5oV//CD2Fz8mJtLtweNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxFbYoJlkACLRZ11kDdb+ONdYm+uMWqv8K7QwwND3k/kt3t4aIf4nmFGcSZkd9Q2E vZvtwvWjPxoWFzTdC+ZmV1k1Zq7Apx6lj2SW1ykZFgOC+BLKwFEm9Gmhggi1quh+xI fEJwzR7gM40c0ceKfYYjM1uBFP+cIa2Uxk57XCsA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexey Kardashevskiy , Sam Bobroff , Oliver O'Halloran , Shawn Anastasio , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.2 077/171] powerpc/pci/of: Fix OF flags parsing for 64bit BARs Date: Thu, 18 Jul 2019 23:55:08 -0400 Message-Id: <20190719035643.14300-77-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Kardashevskiy [ 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