Received: by 10.223.185.116 with SMTP id b49csp4860373wrg; Tue, 27 Feb 2018 04:01:30 -0800 (PST) X-Google-Smtp-Source: AH8x224o5w1mBYmcyR1diS9oe9/zj0v+N/worMmxH50cq6t04VB7D2zRo5+pF7WQGHNKsC3BxEui X-Received: by 10.98.13.24 with SMTP id v24mr13806673pfi.89.1519732890200; Tue, 27 Feb 2018 04:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519732890; cv=none; d=google.com; s=arc-20160816; b=muQiy7WXcXm3DcGbyX8bl5QZcV0WCxr40eb91lnt43h08gnJoXkwk09OLkHwUi6SGj x/ZkK2IwlWhahgaeiRMLUhfWC+SsIkoff7PnNBM2PQDdjjPXEuV9Va0ID7QF3qjafw1I xLI7n6ANYKKppuNBfat1PQF9kZxf5teZ/YHctQcKiGBIYlgYnb5MMGHa73cu5PMV4ghn gP5JU40Lhq/aog04EJVGDv+TOu4ACn3be0Elp0iU82U1j+ssl8+MGdY3+pgEALRbJ5cr akOMraHFtoK+13kuy3scZten/jbvtgkgQ3eTtXcK4hpmdsSap6/Nv+/ks6VDiXtv73T5 JOLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4ysCwTXE5XZrlklCCK4N3kV6Z15iwvbQtvPTcTUjvgU=; b=rFJ+hAuqetKXcjXkKR/OsYHAskMYQPMshKnhlivHsj5tHyvej30TNTBAtfoENkQ1Rb jEioLh+d9vrkuJusBYTkP49YpJpbQWpZYjXXlfyGAS3M+ikytEMqJGTHzJ7pT1ZsGvX+ MUZC/2mSnZieBJk7UkinItPRr/lK70PEjx+rOoAoS+FL7t6vAJ9L6gV+IoVu3vb7Kc1i LbE43y4ioT7kInHFmm8g3QYSg+xx+oYYx1MrTl2LBEyi2bIrUfiITHiFuulutJk2/czC a0cSh3kE7Ngl2434dGfkIy8Ab1eaBXVPMnJ/0pbpck3SbV4ETtp1XHuQgqmScKk2mZLD Su9w== ARC-Authentication-Results: i=1; mx.google.com; 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 70si8423089pfk.60.2018.02.27.04.01.15; Tue, 27 Feb 2018 04:01:30 -0800 (PST) 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; 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 S1753061AbeB0L7e (ORCPT + 99 others); Tue, 27 Feb 2018 06:59:34 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:58868 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbeB0L7c (ORCPT ); Tue, 27 Feb 2018 06:59:32 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 36098184E2; Tue, 27 Feb 2018 12:59:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id xF22xNa7DgRW; Tue, 27 Feb 2018 12:59:30 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 4CC88184C4; Tue, 27 Feb 2018 12:59:30 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0ACB31A067; Tue, 27 Feb 2018 12:59:30 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F39411A062; Tue, 27 Feb 2018 12:59:29 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Tue, 27 Feb 2018 12:59:29 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id E6B005A4; Tue, 27 Feb 2018 12:59:29 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id E0962401A5; Tue, 27 Feb 2018 12:59:29 +0100 (CET) From: Niklas Cassel To: kishon@ti.com, Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] PCI: designware-ep: Return an error when requesting a too large BAR size Date: Tue, 27 Feb 2018 12:59:07 +0100 Message-Id: <20180227115908.14593-4-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180227115908.14593-1-niklas.cassel@axis.com> References: <20180227115908.14593-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pci_epc_set_bar() can be called with flag PCI_BASE_ADDRESS_MEM_TYPE_64, and can thus request a BAR size larger than 4 GB. However, the pcie-designware-ep.c driver currently doesn't handle BAR sizes larger than 4 GB. (Since we are only writing the BAR_mask[x] register and not the BAR_mask[x+1] register.) For now, return an error when requesting a BAR size larger than 4 GB. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-designware-ep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 3a6feeff5f5b..efb65a7c06b8 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -126,6 +126,11 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, enum dw_pcie_as_type as_type; u32 reg = PCI_BASE_ADDRESS_0 + (4 * bar); + if (upper_32_bits(size)) { + dev_err(pci->dev, "can't handle BAR larger than 4GB\n"); + return -EINVAL; + } + if (!(flags & PCI_BASE_ADDRESS_SPACE)) as_type = DW_PCIE_AS_MEM; else -- 2.14.2