Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp893439rwb; Wed, 7 Dec 2022 06:20:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DWy9Y0GcTUo3HZAUYvCYXR4M7OmarelrWb4S2HW3+1qIKKFfpnh3SemB1i2wyso3zPF/c X-Received: by 2002:a17:906:682:b0:78d:a632:59d2 with SMTP id u2-20020a170906068200b0078da63259d2mr61694021ejb.459.1670422802017; Wed, 07 Dec 2022 06:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670422802; cv=none; d=google.com; s=arc-20160816; b=U5Lh1pDFdaCVMbFMexmT/GEnR/b5rYJzf2mmtsqmbkT0MGbNMXICLcBvooOQ+jhI0c 6h+9KYewJLL4KHVZYrsAa/l/1WMnStxu3eJ40yXG9seoDkXZ+YjDi97n/zjUCgghl2r5 x6qeODk1s2sgggHCENgp8yvQPBTNC3JK7G2uDWSQCy4QHIxNCJDbANaShpEzfLhCXMzw nuUPhz48dMinHqIgB93gZbDzHMpOYS7KM1RboQa2U8DYgJSYq9QXqH3EmvqnxiL7Cn9d tmzroObPV2nyRJC09Jkusvvsg3P6v4ykS48sGcVehqpKit+LtFp7V+YlsQrLMdfpaNtK +zsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+GXkP58FsgYtEtV2kltJdQIO7NbuSAa5+nIq85bqPZc=; b=z2jg4KQu5FaB7YzArXGGKWxnrsugJhsBZX+rlHAGHquN6sURhmh/XdVZCWJ6vd0yzO ul6F/G2VCCsnygCqukDKZm9nICqOuPVtJ+jtL2Kht+5s+Z2dbrytjBA10w2T6YrnwKOx +B3SCg1qUB4AgNydIM3UZYZ9IDDDlXpwEnm3YlxEDXG/uJO7P0PJlH/Uzj8tmGoR/en5 0oQ/lqPa9zv07fOml8he0D64/iLmCfUDNIkWgU+TfuMcs8O/b1PiwCGEsXAdq2LRnLVL Jxq+oodmApU7fx8z3wss0Ns0BsfWZPd1nX4yDuWpBdkN0gtdROoVZt3+8AT3ztD3pyKl vVlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VV1HQQXI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc9-20020a1709071c0900b007bc5528a4d7si18531138ejc.47.2022.12.07.06.19.42; Wed, 07 Dec 2022 06:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VV1HQQXI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbiLGNi4 (ORCPT + 75 others); Wed, 7 Dec 2022 08:38:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiLGNiy (ORCPT ); Wed, 7 Dec 2022 08:38:54 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76B329C8A for ; Wed, 7 Dec 2022 05:38:53 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id o127so22686730yba.5 for ; Wed, 07 Dec 2022 05:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+GXkP58FsgYtEtV2kltJdQIO7NbuSAa5+nIq85bqPZc=; b=VV1HQQXIg4IQoL/RTe8WTrB4W1JmiXDCo19eUo8d4rajcTHkrDsI5eLFjOY8ySkRmq 5+y5sDmoGbPTBHNlac4cxxD5rVcpmGaO6FeJ1wNsxxaIMo6tLWEFhrU9KSUCSPWmaHvS ODgFs2lGeFgYlPY+wWNt45cF2srmGSOZ+OhJjsE0Gug/Pi8fW3FdTgY7lMz9CWq++YXV LenGjA8X+TV8+k3iI0BQR6Alz3VY3ItruQgLyBfTuubLtf6/tyvDW9w4pQZuPB32Dqzc PbCcYG6C20dUXqknwfagM9fckxA4vUqZ/ZYVEkl6lmDQWfw8U/Hjszgi/6azC7UL0ZLS LATw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+GXkP58FsgYtEtV2kltJdQIO7NbuSAa5+nIq85bqPZc=; b=5u+osIWBmTgm92LPt23hWBt087qd7nkYe+7kCmekxqBllLickDw7cKcCqr/ZjoH4E4 3mqHjM3oqniToKqcqvrT8ovpm3Q5BIKg7pjf+txLi6zYi8D2y0+EIvfnHtRvbhenH1Tu fsAJiaMwxs7xo/2wIaU+NabLKD21xRCuaX/zNobWTVhZ8cDZ21wzcQii3cYJ6ogvV9rI uKL/uBdflxNUApzbXslRLCLu3sRzC0c/vOcdvXMz9344TfYslciRxwM0dodJpKaEscn9 jR/iGdLlHSFWKQvMNg31rA4nHlWVdhM9z13sTWuAFPnRR7JRJ5zJHaz6556lThY5nYQQ DFrQ== X-Gm-Message-State: ANoB5pl3Dg0p18Pa0jOs7Y+ZlBkYjMS8PSEWdwnPNazHRBuief8z5dra RHaHmBSeBlp1eq/9rLcKI9ZDhpvnc52tAdvxWc8kXx58h80EyovTmKM= X-Received: by 2002:a25:1843:0:b0:6dc:b9ec:7c87 with SMTP id 64-20020a251843000000b006dcb9ec7c87mr70316385yby.322.1670420333032; Wed, 07 Dec 2022 05:38:53 -0800 (PST) MIME-Version: 1.0 References: <20221205105931.410686-1-vadym.kochan@plvision.eu> <20221205105931.410686-4-vadym.kochan@plvision.eu> In-Reply-To: <20221205105931.410686-4-vadym.kochan@plvision.eu> From: Linus Walleij Date: Wed, 7 Dec 2022 14:40:09 +0100 Message-ID: Subject: Re: [PATCH v3 3/3] mmc: xenon: Fix 2G limitation on AC5 SoC To: Vadym Kochan Cc: Hu Ziji , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Adrian Hunter , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Elad Nachman , Chris Packham Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 5, 2022 at 12:00 PM Vadym Kochan wrote: > There is a limitation on AC5 SoC that mmc controller > can't have DMA access over 2G memory, That sounds like a pretty common problem when someone uses a 32bit address register in their DMA controller, or the integration engineer not connecting all address lines... :/ > so use SDMA with a bounce buffer. Swiotlb can't help because > on arm64 arch it reserves memblock's at the end of the memory. OK This: > Additionally set mask to 34 bit since on AC5 SoC RAM starts > at 0x2_00000000. (...) > +static int xenon_set_dma_mask(struct sdhci_host *host) > +{ > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); > + struct mmc_host *mmc = host->mmc; > + struct device *dev = mmc_dev(mmc); > + > + if (priv->hw_version == XENON_AC5) { > + host->flags &= ~SDHCI_USE_64_BIT_DMA; > + > + return dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34)); > + } > + > + return sdhci_set_dma_mask(host); > +} (...) > + .set_dma_mask = xenon_set_dma_mask, I don't know if is so good to assume the size and location of the SoC RAM like you do, that looks really fragile. Can't you check what physical RAM Linux actually think it has and where? You partly check it with meminfo below. > +static int xenon_ac5_probe(struct sdhci_host *host) > +{ > + struct sysinfo si; > + > + si_meminfo(&si); > + > + if ((si.totalram * si.mem_unit) > SZ_2G) This looks like a bug since you mention that the RAM does not start at 0x00000000 this means if the memory is 2G it will partly be at physical addresses above 2G.... > + host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; > + > + return 0; > +} Here you check how big the RAM is using meminfo (if the bug is fixed). But is this really a good solution? ADMA still works on the lower 2GB does it not? What you want is a new quirk that bounces only when you go above SZ_4G. There *is* SDHCI_QUIRK_32BIT_DMA_ADDR have you tried this? A 32bit DMA address is literally 4GB. I think all you need to do is set this flag for xenon. Yours, Linus Walleij