From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5ED8C761AF for ; Thu, 23 Mar 2023 00:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t0LrWKRpp2/aOXkPcW6ODAVhj3IBje5ABj9vd+PWDb8=; b=juTSfBbaZ6ir8f NKlpQWmAhPuBTezU1DRzgrB2YFFUaexfV8csF9P2fUDLPOVDO0vMsV6vkNDi3epGg4lzZ6HOxiaSa bqp5EFsKV4pZtdQW8jdarb2tt8aKyTt5/g8cVNDdUX/lcX0sGOWau6iulWTRlyFrRXKuaRBevzU/H iwWJvYE4ZFXH8FP3WvUOljykQ310Gexk3fCsSjgLhoAp3iYB4X9wlaW5kmw9iaJzam39tAIQ2FeHx voBEafXpRnNvLpOTd8y4SStCz03p7sBtEdGwA53ih3VPj4IRbJ7N5wQa7MY4YVs6fvYl36kwXJloJ RKLlQIr9qQwv524aUZFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pf8Yf-000IH7-1c; Thu, 23 Mar 2023 00:11:57 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pf8Yb-000IET-0J for linux-arm-kernel@lists.infradead.org; Thu, 23 Mar 2023 00:11:54 +0000 Received: by mail-lf1-x130.google.com with SMTP id q16so14769182lfe.10 for ; Wed, 22 Mar 2023 17:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679530309; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nYCkHAsN3JrF68S01DrynayfL1Jyb7WCod+z/Y3H2No=; b=UReGMPhbM2n9pWALFzS1ncK2UDdmdcBDjv/VT2DMUe6/7gh85hvxWUuv7VNGDdxUkw bwWVoGbj9DofIhFE5Oi4/LRu2cQsrvXYmhqrT4t1v3UIU57DtU4kCLRXH5VQ5Or2Mj8H 9scxNqBrU17PRtN67nR5XOVdOnwgP8twk1WHnnKYiupozmblhhRK0M8B8uKSIo+NqYqb 8pty7I8ttBkVKGNix0CJ1YtUEkO0W4aO2asoYHfISz0a/hvrcT1siikRVU7arTi8ycI0 DZuEHJNwNLBELo0bTTYlYdI94mjET6TVPuHvD3md2OtjchjDszjTEMjUVKkdu/bLPYQV Zclg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679530309; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nYCkHAsN3JrF68S01DrynayfL1Jyb7WCod+z/Y3H2No=; b=DrwnR02LZpTqQevqQ5xDFCjAwC/NXgFUSElbFhJEFmQhgVVudTJbKFzIhz+g8vhGvn VeO6wh1Pt8mDyfY3VyK/U2xvZrXPWNBeqWi/W1bIXNMISlNS7Z/kNk/TN/qQwwLuuJeJ g+SvsMwNCLvmPXbOC3e4K9RVsKugRW5yer/30/4DeA7i7y3XF5VAdUpybevrHFmYJMUF QtthpVTFLQy/F7smTaAda+xfMySqI4yTsmyxFPDzxJ+i2IzbaaNv0vOrwYVErbldsCXS pezldbKHlhlRNfu1uY718DVcSaawHV20eSz1J1uqACH2lc9D9xSHWizs4Jq3MBW9R7Dz SrQA== X-Gm-Message-State: AO0yUKXBRl6f12VTqxWku15qJ6WFag46djPUFHKJeQMnpICw/4HJBPQq QnngrJsX//vgq4o23Odz3Jc= X-Google-Smtp-Source: AKy350bDuYFrnVk394IZKDlUf38O/h63IIdgWnxEF5JXKF4nDJRgmGsB2j8L2Iqx3XraDJb6ZG1suQ== X-Received: by 2002:a19:ee13:0:b0:4dd:9e4a:4c3b with SMTP id g19-20020a19ee13000000b004dd9e4a4c3bmr2545136lfb.17.1679530308868; Wed, 22 Mar 2023 17:11:48 -0700 (PDT) Received: from mobilestation ([95.79.133.202]) by smtp.gmail.com with ESMTPSA id o15-20020ac2434f000000b004dd6c325311sm2747359lfl.248.2023.03.22.17.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 17:11:48 -0700 (PDT) Date: Thu, 23 Mar 2023 03:11:46 +0300 From: Serge Semin To: Elad Nachman Cc: thomas.petazzoni@bootlin.com, bhelgaas@google.com, lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, krzysztof.kozlowski+dt@linaro.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 8/8] PCI: dwc: Introduce region limit from DT Message-ID: <20230323001146.xbqbav2fu2qelsub@mobilestation> References: <20230313124016.17102-1-enachman@marvell.com> <20230313124016.17102-9-enachman@marvell.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230313124016.17102-9-enachman@marvell.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230322_171153_155950_63507B2C X-CRM114-Status: GOOD ( 26.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 13, 2023 at 02:40:16PM +0200, Elad Nachman wrote: > From: Elad Nachman > > Allow dts override of region limit for SOCs with older Synopsis > Designware PCIe IP but with greater than 32-bit address range support, > such as the Armada 7020/7040/8040 family of SOCs by Marvell, > when the DT file places the PCIe window above the 4GB region. > The Synopsis Designware PCIe IP in these SOCs is too old to specify the > highest memory location supported by the PCIe, but practically supports > such locations. Allow these locations to be specified in the DT file. > DT property is called num-regionmask , and can range between 33 and 64. The implemented algorithm doesn't prevents you from specifying the outbound MW base above 4GB. It prevents you from overflowing the limit address which is of the 32-bits width only for the chips older v4.60a and if the INCREASE_REGION_SIZE IP-core synthesize parameter is set to zero. In other words you must make sure that dma-ranges/ranges entries size when combined with the source address doesn't cause the limit address overflow (4GB boundary cross in your case). For instance, you want to map 0x1F0000000 CPU-address region of 512MB size to 0x0 PCIe address. In that case you'd specify the ranges property like this: < ranges = <0x82000000 0 0 0x1 0xf0000000 0 0x20000000>; The CPU-base address is ok since iATU always supports 64-bit base addresses. But after you add 0x20000000 to 0x1f0000000 you'll get the 4GB boundary overflow (0x210000000) which can't be described with the 32-bit limit address CSR. In this particular case the maximum range size you can specify is 0x10000000 (256MB). Anyway judging by the patch content you do nothing but hacking the ranges entries sanity check procedure which I don't think is a good thing to do. -Serge(y) > > Signed-off-by: Elad Nachman > --- > v4: > 1) Fix blank lines removal / addition > > 2) Remove usage of variable with same name as dt binding property > > drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c > index 53a16b8b6ac2..9773c110c733 100644 > --- a/drivers/pci/controller/dwc/pcie-designware.c > +++ b/drivers/pci/controller/dwc/pcie-designware.c > @@ -735,8 +735,10 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen) > void dw_pcie_iatu_detect(struct dw_pcie *pci) > { > int max_region, ob, ib; > - u32 val, min, dir; > + u32 val, min, dir, ret; > u64 max; > + struct device *dev = pci->dev; > + struct device_node *np = dev->of_node; > > val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT); > if (val == 0xFFFFFFFF) { > @@ -781,7 +783,13 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci) > dw_pcie_writel_atu(pci, dir, 0, PCIE_ATU_UPPER_LIMIT, 0xFFFFFFFF); > max = dw_pcie_readl_atu(pci, dir, 0, PCIE_ATU_UPPER_LIMIT); > } else { > - max = 0; > + /* Allow dts override of region limit for older IP with above 32-bit support: */ > + ret = of_property_read_u32(np, "num-regionmask", &val); > + if (!ret && val > 32) { > + max = GENMASK(val - 33, 0); > + dev_info(pci->dev, "Overriding region limit to %u bits\n", val); > + } else > + max = 0; > } > > pci->num_ob_windows = ob; > -- > 2.17.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel