Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2584137rwb; Fri, 9 Dec 2022 04:07:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CDL9vOFILm1XTEXRZnVFbcPNrZnobGXEd+1mBT++s+KtgGAJlV4Gy9uK01cPdV04NuGJC X-Received: by 2002:a05:6a20:939c:b0:a4:77b0:836c with SMTP id x28-20020a056a20939c00b000a477b0836cmr7902187pzh.45.1670587637043; Fri, 09 Dec 2022 04:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670587637; cv=none; d=google.com; s=arc-20160816; b=go6gaJS/NdJB3Zj4dn8Cr76JK4B/L39EE1e/omKRLORZ/H19Bxawz/hND7Zmw7iR2v BgrYUiZHFx9Xx9A5rQeBTYuuVoLbx+eP51iqvIygoct+Xtq5Atm6aa+oUzcyXXEdw4ts sqfqBXXgstAXDJf9P5bfLS/OqFt6A9SLCOICxhD0kMsN7O9oolZeNU41Djd/2WDErdfa 9oDQ/7YiZogF3EJqLaTeqLPXLSfXwTxsNOSbud0sQMteF78xjj9BDqHtT3I52E/AjAdl kcJQ9tzp8zZGaPum75xWByIrHU/g5hjc/TYRui83O46kL4t6TyYQ3tMcpTL8Mxg9cQAo hMfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=IqNWWMtCeD1tuKeQGutBG+gcn+0iE9XvZ04hLSvuOW4=; b=ZVCEYUgFdkqi3/Bl6N9jsuIB5xpWIia6hxblDdrrQo3UJWvbzWoyb40gvUzVr2rvcF V+TDc58OPFtmNkoDNAtmKDVcuk+qG9HRDvHQV2Iv7vKaq6E7UIy0yG6xiB+QEivgbZQw 8RROCN3z1pomSF24z+hjj2d2vH2cb2KwaZSftpEHbw5lDzXXSDoYUA2mtmG8FuAzeoBL FuIa62EahN8n3Dw6e8cycWH4fGsy5gtz4hn6GI/S1OomyEdX5h3yNdwi5qP9kgzLKnmD jWJyoAr0TGr7Qt3oJJfwCozJckMNq+9jvUvcLQfG4JcoHrt+SkzTDuhlwnQ6/5ICvquD TiMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UNCLoAoD; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a656a14000000b00478a6de4d30si1473980pgu.201.2022.12.09.04.07.05; Fri, 09 Dec 2022 04:07:17 -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=@intel.com header.s=Intel header.b=UNCLoAoD; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbiLILyR (ORCPT + 77 others); Fri, 9 Dec 2022 06:54:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiLILyG (ORCPT ); Fri, 9 Dec 2022 06:54:06 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21FD2F66D; Fri, 9 Dec 2022 03:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670586845; x=1702122845; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=4SHazouiElxUjOC4Flye5c70aBAsz/8pI1HA43DONeM=; b=UNCLoAoDFOXtEUZMBYivQ5W66vUGbMhwr5PmKi35Ii1lhhzUcHmmrbJC b704oZvlxmFhk8faNrHy8+heRas+GN4l0EDJdNVdiqpYucO3C40zQZn8H qQFKClfUeFMMryg933wetTTwoPnZXwViKH2qPsvHZr8yFHwrdv4IxQ7zZ SGJ2crzON9NRdz5S77xSnXhQKaVo5jWw+9ov5HW4deOvpImDPkvjooB1G VqwvuTGNETJEaOBm7Q6TYOMOaV8CN/ZtTDRZHthEow31SddBoJKgOSf6Q htu1E0L/+27waXmuSo9XGJUtP9bwaPNe+0eRi5cEA4QCIh80ES7RgIcwB g==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="315078915" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="315078915" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2022 03:54:05 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="892649410" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="892649410" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.56.86]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2022 03:54:02 -0800 Message-ID: Date: Fri, 9 Dec 2022 13:53:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.5.1 Subject: Re: [PATCH v3 3/3] mmc: xenon: Fix 2G limitation on AC5 SoC Content-Language: en-US To: Vadym Kochan , Hu Ziji , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Elad Nachman , Chris Packham References: <20221205105931.410686-1-vadym.kochan@plvision.eu> <20221205105931.410686-4-vadym.kochan@plvision.eu> <18cf4197-adce-3e47-7802-80b0d078368b@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE 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 9/12/22 13:39, Vadym Kochan wrote: > Hi Adrian, > > On Fri, 9 Dec 2022 09:23:05 +0200, Adrian Hunter wrote: >> On 5/12/22 12:59, Vadym Kochan wrote: >>> There is a limitation on AC5 SoC that mmc controller >>> can't have DMA access over 2G memory, 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. >>> >>> Additionally set mask to 34 bit since on AC5 SoC RAM starts >>> at 0x2_00000000. >> >> Can you explain more about how a 34-bit DMA mask works when >> SDMA only supports 32-bit addresses? >> > > So, after I set > >>> + host->flags &= ~SDHCI_USE_64_BIT_DMA; > > then sdhc core sets mask to 32 bit, but then dma_map fails to map > bounce buffer because the base address is higher than 32bit - 0x2_00000000, > and 34bit mask fixed it. What happens if the bounce buffer gets mapped in the range 0x1_00000000 to 0x1_ffffffff ? > >>> >>> Co-developed-by: Elad Nachman >>> Signed-off-by: Elad Nachman >>> Signed-off-by: Vadym Kochan >>> --- >>> drivers/mmc/host/sdhci-xenon.c | 38 ++++++++++++++++++++++++++++++++++ >>> drivers/mmc/host/sdhci-xenon.h | 3 ++- >>> 2 files changed, 40 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c >>> index 08e838400b52..5f3db0425674 100644 >>> --- a/drivers/mmc/host/sdhci-xenon.c >>> +++ b/drivers/mmc/host/sdhci-xenon.c >>> @@ -13,7 +13,9 @@ >>> >>> #include >>> #include >>> +#include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -253,6 +255,22 @@ static unsigned int xenon_get_max_clock(struct sdhci_host *host) >>> return pltfm_host->clock; >>> } >>> >>> +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); >>> +} >>> + >>> static const struct sdhci_ops sdhci_xenon_ops = { >>> .voltage_switch = xenon_voltage_switch, >>> .set_clock = sdhci_set_clock, >>> @@ -261,6 +279,7 @@ static const struct sdhci_ops sdhci_xenon_ops = { >>> .reset = xenon_reset, >>> .set_uhs_signaling = xenon_set_uhs_signaling, >>> .get_max_clock = xenon_get_max_clock, >>> + .set_dma_mask = xenon_set_dma_mask, >>> }; >>> >>> static const struct sdhci_pltfm_data sdhci_xenon_pdata = { >>> @@ -486,6 +505,18 @@ static void xenon_sdhc_unprepare(struct sdhci_host *host) >>> xenon_disable_sdhc(host, sdhc_id); >>> } >>> >>> +static int xenon_ac5_probe(struct sdhci_host *host) >>> +{ >>> + struct sysinfo si; >>> + >>> + si_meminfo(&si); >>> + >>> + if ((si.totalram * si.mem_unit) > SZ_2G) >>> + host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; >>> + >>> + return 0; >>> +} >>> + >>> static int xenon_probe(struct platform_device *pdev) >>> { >>> struct sdhci_pltfm_host *pltfm_host; >>> @@ -533,6 +564,12 @@ static int xenon_probe(struct platform_device *pdev) >>> } >>> } >>> >>> + if (priv->hw_version == XENON_AC5) { >>> + err = xenon_ac5_probe(host); >>> + if (err) >>> + goto err_clk_axi; >>> + } >>> + >>> err = mmc_of_parse(host->mmc); >>> if (err) >>> goto err_clk_axi; >>> @@ -682,6 +719,7 @@ static const struct of_device_id sdhci_xenon_dt_ids[] = { >>> { .compatible = "marvell,armada-ap807-sdhci", .data = (void *)XENON_AP807}, >>> { .compatible = "marvell,armada-cp110-sdhci", .data = (void *)XENON_CP110}, >>> { .compatible = "marvell,armada-3700-sdhci", .data = (void *)XENON_A3700}, >>> + { .compatible = "marvell,ac5-sdhci", .data = (void *)XENON_AC5}, >>> {} >>> }; >>> MODULE_DEVICE_TABLE(of, sdhci_xenon_dt_ids); >>> diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h >>> index 3e9c6c908a79..0460d97aad26 100644 >>> --- a/drivers/mmc/host/sdhci-xenon.h >>> +++ b/drivers/mmc/host/sdhci-xenon.h >>> @@ -57,7 +57,8 @@ enum xenon_variant { >>> XENON_A3700, >>> XENON_AP806, >>> XENON_AP807, >>> - XENON_CP110 >>> + XENON_CP110, >>> + XENON_AC5 >>> }; >>> >>> struct xenon_priv { >> > > Regards,