From patchwork Wed Oct 7 10:49:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Fedin X-Patchwork-Id: 7344131 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55639BEEA4 for ; Wed, 7 Oct 2015 10:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 855EA20751 for ; Wed, 7 Oct 2015 10:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 915C82074E for ; Wed, 7 Oct 2015 10:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbbJGKuB (ORCPT ); Wed, 7 Oct 2015 06:50:01 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:60189 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751984AbbJGKt4 (ORCPT ); Wed, 7 Oct 2015 06:49:56 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NVU006GWJF6RN60@mailout1.w1.samsung.com>; Wed, 07 Oct 2015 11:49:54 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-52-5614f8d1fdd1 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id C5.38.04846.1D8F4165; Wed, 7 Oct 2015 11:49:53 +0100 (BST) Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NVU00JOXJE9II60@eusync4.samsung.com>; Wed, 07 Oct 2015 11:49:53 +0100 (BST) From: Pavel Fedin To: linux-pci@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Frank Rowand , Grant Likely , Peter Maydell Subject: [PATCH 1/2] PCI: of: Add 64-bit address recognition without LPAE support Date: Wed, 07 Oct 2015 13:49:20 +0300 Message-id: X-Mailer: git-send-email 2.4.4 In-reply-to: References: In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t/xa7oXf4iEGRw5qWsx/8g5VouZb/6z WRz4s4PR4uy842wWc848YLFo3XuE3YHNY+esu+wem1Z1snncubaHzePzJrkAligum5TUnMyy 1CJ9uwSujMeHLjEV7OeueHfoHXsD41HOLkZODgkBE4mrz7rZIWwxiQv31rN1MXJxCAksZZSY 9u02O4TTxiSx++s+JpAqNgF1idNfP7CA2CIClhK7m24zghQxCyxklNiybwaQw8EhLBAsMesK WA2LgKrE2TMr2EBsXoFoiZ+XN7FBbJOTuHJ9OpjNKWAu0TuliRnEFhIwk3hzdho7LvEJjPwL GBlWMYqmliYXFCel5xrqFSfmFpfmpesl5+duYoSE3JcdjIuPWR1iFOBgVOLh/WEsEibEmlhW XJl7iFGCg1lJhLfxO1CINyWxsiq1KD++qDQntfgQozQHi5I479xd70OEBNITS1KzU1MLUotg skwcnFINjCn3FtQ9LJ995SL/pL9PN1ZtjT986NKGiyt+vNn68FqGvDtfkXVzHPvMd3kzRTu2 3ub9zFX+wnKrZ6zdBl2Rdv78T/4ikY0NvxJqNQ7X3BbTaJQ8ZS7+0PRuNIdNR+Isd+lnpp8s /O02Sf2cs8izLnOWZPMRCyVrb52e4ssJMza5t6sd+pq3UomlOCPRUIu5qDgRAPIu47Q1AgAA Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If non-LPAE kernel is booted up on a machine with 64-bit PCI resources, PCI controller probe fails with: PCI host bridge /pcie@10000000 ranges: IO 0x3eff0000..0x3effffff -> 0x00000000 MEM 0x10000000..0x3efeffff -> 0x10000000 MEM 0x8000000000..0xffffffffff -> 0x8000000000 pci-host-generic 3f000000.pcie: resource collision: [mem 0x00000000-0xffffffff] conflicts with /pl011@9000000 [mem 0x09000000-0x09000fff] pci-host-generic: probe of 3f000000.pcie failed with error -16 This happens because res->start assignment in of_pci_range_to_resource() truncates the upper part of the address, because res->start is of phys_addr_t type, which is 32-bit on non-LPAE kernels. This patch adds explicit recognition of 64-bit resources, preventing from potential problems when e. g. 0x8000001234 would be converted to 0x00001234. Signed-off-by: Pavel Fedin --- drivers/of/address.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 384574c..9a8f8c3 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -330,6 +330,12 @@ int of_pci_range_to_resource(struct of_pci_range *range, } res->start = port; } else { +#ifndef CONFIG_PHYS_ADDR_T_64BIT + if (upper_32_bits(range->cpu_addr)) { + err = -EINVAL; + goto invalid_range; + } +#endif res->start = range->cpu_addr; } res->end = res->start + range->size - 1;