Received: by 10.223.176.5 with SMTP id f5csp2931537wra; Thu, 1 Feb 2018 08:12:46 -0800 (PST) X-Google-Smtp-Source: AH8x225z8Piqvg+KkYNKU7MYokbwPQqIAqJvbJzY+if8eDEG9eXFavSj9GK2H1z0d8L8cG2lzG2h X-Received: by 10.99.110.3 with SMTP id j3mr29649638pgc.85.1517501565870; Thu, 01 Feb 2018 08:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517501565; cv=none; d=google.com; s=arc-20160816; b=TbCUq632swBlVG7+Fl3wDqVE2okWgvkNHZxNBOkBeDqag4JTcqpqv7iDcfMUjQyozu E4Ef3TsI5SIIYI8a0HKinw6NKR+DSmIei34XQfmIg9zFXSKt+p8WcQ1DYrnxnHL1h2q3 IpSHYYRbJoBcIKZOESrLSE4JnLMVDpR+FAmxOPggVKyVhLSvjqbbEFUFdXSOn/FT7ohu qEJI+LhrOp3LacWN7zxWmbz48miZggo5SY1IS+eDUSRTO66bq7mWDg52cSIYMSEXNaoJ vAMlkDWr4kKg72Yb72N2x45kqgwGjKRYj0DsoX0g80yDVAtyDLYuFuoSSiRyHX3kXHAJ JZUg== 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=6U90Zs+rXmS8ssh9tO0/sZ6jzTxwrE4JCpp7D2OvrV4=; b=YriCXo7n1w+i2ytrDwQjonFNmkmtMHM6VATpuKrHpKgk5JoQhJyF5ZozZuOr+gWF+N 0MzLBil0XtXez+m1m/8CY1YGLxhkgUmQrPYEjSKL2BpZhPYcJOKiRUX5X4IEWcfhskoD 04eMGnQf6ptTLsib9RHRIKVDtROKL1qkygVANTmkMnZz8g8pB4E10OAEXfIn3bCruLbk z38S3ahOU3Jhw5a5/VDHqxygyp6n1YRrekRVr+yP0VEBJ3OWBTdtJMSneT57FRhSjkDz jceOM63yZ0xz5mOeAqV6drjkNWrqq2qPUV8FuamWy+bEC9qV+fiM6nmi9vWk1/eyJlGF WS9g== 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 u127si3502377pgc.23.2018.02.01.08.12.31; Thu, 01 Feb 2018 08:12:45 -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 S1752682AbeBAQLv (ORCPT + 99 others); Thu, 1 Feb 2018 11:11:51 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:40575 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbeBAQLr (ORCPT ); Thu, 1 Feb 2018 11:11:47 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id E335C187E6; Thu, 1 Feb 2018 17:11:45 +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 BwuiP7lkFkey; Thu, 1 Feb 2018 17:11:45 +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 40E79187C8; Thu, 1 Feb 2018 17:11:45 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FAA51A073; Thu, 1 Feb 2018 17:11:45 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2478F1A072; Thu, 1 Feb 2018 17:11:45 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Thu, 1 Feb 2018 17:11:45 +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 186CD25EC; Thu, 1 Feb 2018 17:11:45 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 13927401AF; Thu, 1 Feb 2018 17:11:45 +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 3/3] PCI: designware-ep: Return an error when requesting a too large BAR size Date: Thu, 1 Feb 2018 17:11:19 +0100 Message-Id: <20180201161119.3852-4-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180201161119.3852-1-niklas.cassel@axis.com> References: <20180201161119.3852-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..4a0085ead1e3 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 (size > 0x100000000ULL) { + 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