Received: by 10.223.176.5 with SMTP id f5csp1848553wra; Thu, 8 Feb 2018 04:35:47 -0800 (PST) X-Google-Smtp-Source: AH8x225UoGqZw0/6YlbfWoqUoxs8cIWI6s8t0vLT51M7oV3gekm/+7HsBJIK94EHFdwHg6uTa6MG X-Received: by 2002:a17:902:d917:: with SMTP id c23-v6mr518415plz.231.1518093347081; Thu, 08 Feb 2018 04:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518093347; cv=none; d=google.com; s=arc-20160816; b=n1V/XhNvYaeULnPiVwEVCISSiPEKM6x84Ce0V59nTJ5Kwef6WsbNllV2NiE07Z1rEy GMQL8aIawEHQP4ofB/5qKFWJ685GYzVF6RiaR0i1dM+pINY4nUsZXoqOAHUBwlSAflsx 9ujVYt/h2I0pnyNBnThZ45B1ofV2XpL9VZGCgzsiRctrLllXAgOI0MYbUpvJUVHwvnyY X5dL1Xw1Mz2lZDJbZIg1PhXsQEfpbFqEBLb6IZUeviZUSY2lJrvwRSUIXSGghEpUwvAM HRPIK48aMpE5EUSCwrTMWwVMCeAdAJlMeHjw+gz1HHLIlR8iX8FAT3mz5BTbqii8C2db s1Bg== 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=uupRsy4gQHHLlR48DlNkJEYFxgofFob0SPTZW1DD248=; b=k0Iyj9cIeLTZWgEfQT6hXbDgj0dgiAP8IsCKW/k4gLTrxJuMY+oqPY1t3C4fgLWAR8 2x/uNjOPyBVHlSxmf5wwJE5FuWf8j0A8QII1qXVBMTvui6lqIDXBHTcMrvimwM6Dea3A PQ8NLVqAsvkA/F5SlTxP4RpdiV/KaGkrIsSJJj1UU6BMdznBQfrdev1u1sPyKz7PFBbV VtFn6S7/voA2Af1YE5NLbaFFaT22EdZ81kzdi+xDWBh6Wcx+9+hRVSsaJsYEzmopdvHQ zHO1QnVb+fgjeEloo32L7ST17HeLoSrTW6auja8kuOn6BUWTh6dyVu+ANHtf6txo73DX klnw== 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 bg8-v6si2704389plb.748.2018.02.08.04.35.32; Thu, 08 Feb 2018 04:35:47 -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 S1752292AbeBHMeN (ORCPT + 99 others); Thu, 8 Feb 2018 07:34:13 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:49137 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752255AbeBHMeK (ORCPT ); Thu, 8 Feb 2018 07:34:10 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 17A651889F; Thu, 8 Feb 2018 13:34:09 +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 6BoJ0Tla33n7; Thu, 8 Feb 2018 13:34:08 +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 7152B188A5; Thu, 8 Feb 2018 13:34:08 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3465F1A06F; Thu, 8 Feb 2018 13:34:08 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 291F71A073; Thu, 8 Feb 2018 13:34:08 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Thu, 8 Feb 2018 13:34:08 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 1D06A2D60; Thu, 8 Feb 2018 13:34:08 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 185DD401B8; Thu, 8 Feb 2018 13:34:07 +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 v2 3/3] PCI: designware-ep: Return an error when requesting a too large BAR size Date: Thu, 8 Feb 2018 13:33:46 +0100 Message-Id: <20180208123346.20784-4-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180208123346.20784-1-niklas.cassel@axis.com> References: <20180208123346.20784-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 --- Changes since v1: Use upper_32_bits() to avoid build warning on systems with 32-bit size_t. 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