From patchwork Wed Jan 3 17:35:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 184808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5160684dyb; Wed, 3 Jan 2024 09:37:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRKQsXGZSLr6kVMXVH5hRUE1LQMihLDgpe0jZ2gE67NulIir9AQu0IluHPRJelRWliWxWu X-Received: by 2002:a05:6808:4449:b0:3bc:24f7:d17b with SMTP id ep9-20020a056808444900b003bc24f7d17bmr1419909oib.32.1704303449058; Wed, 03 Jan 2024 09:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704303449; cv=none; d=google.com; s=arc-20160816; b=XtHGm8gtOROyEDUfStgwYn4WFUegQM6mGhgw0nw7MnRBLCriGaJiVgoRAgBBvOIi10 X8r0Cj4ShBH3eeCIsDBNlZ4cwHPeeSawKmQ/QFwN4waLCPS9IZjhR5gxV2iqoQzZVtGg +7eihnKAvVev1Ey33LUAvn5knn+vqXhJz8hDVXQSqHKNgxn1J1KFMv4D7Anh2169vsp6 +btMC4yeBDdnbY9jZ1EYhI9kOdj7/+1JAFQL7qjsW50LCsdNmlsqOU9uTdut1DOOx9za O0Au2HjI7VkcJs7xpbdWdbhyKIlxwK6QCsTF3v8jT3mX4ZRpMszwVizT5+FXCy4YaTfk IVaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=QtaJSWsEJTNUz9p29xBwXZsSB1Org89UHEZ7k9tdeeE=; fh=dQaW+PkpV6B8DsP7Dkb8SMGnouNee2Ymj5fmrjFCZk0=; b=CwzwbCVfg490r50DEcYWFJVAIJ1Hh9iRzhqtlaJw4BnBRiw49DltB+0yh0h7MJXF+X q0GUIJarlMgKaGlatkHE4sl2omNxmHYPotmPGya9P2pUyrYCYo0bSiFEeUFmoykha99R VY4tn3ETWkdS9bE8PVtSViRi0oi0pyuvNEbqgXGoBM2ewxd6LyaQVZHJ447cSKJec1kN FGq5NfHYTSfW30mIDxJQh3TQP95GMhFsy9bpaQFb1z3G0SbkArEsvGgdFPi5ne283ko8 jZN2z123rO5otuRIHbBeYleEXAXaHwifOWg8cdRHAwy5lTBgceSc9jD+jvwKxFdpyi6I wBrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Eq6XdzTh; spf=pass (google.com: domain of linux-kernel+bounces-15808-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15808-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g27-20020a0caadb000000b0067ef267d46fsi28004396qvb.457.2024.01.03.09.37.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:37:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15808-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Eq6XdzTh; spf=pass (google.com: domain of linux-kernel+bounces-15808-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15808-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D127E1C23A3F for ; Wed, 3 Jan 2024 17:37:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 920131C6B1; Wed, 3 Jan 2024 17:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Eq6XdzTh" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D43131C69D; Wed, 3 Jan 2024 17:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4032THEs005675; Wed, 3 Jan 2024 09:35:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=pfpt0220; bh=QtaJSWsE JTNUz9p29xBwXZsSB1Org89UHEZ7k9tdeeE=; b=Eq6XdzThntSfmd1r1DZoPXTw Mmhk3ExJSXI61uEy2dTmvQvQbpf1Kgmy9QGWKdC6Ei0IUgnqutRNFuP2F75T4B9/ b7zwl0kf0/GtqFFrzw9WHjzrTSLgrH2dMReVMUCNK1hHXDfY7ux+7E4xA96I03em Oen+GNfG1XoJMq1p78A8A3n7DeAdsfeW2UUAt2Nn1Ud4sCeCT28EhRdG71vEM2iJ u4YUazKBpOL/oFRj6rFqo+QV3NKLUVKz8MqVb0GwrWatSFSO509a20dQvgAwRCuL fOlr5K4fiYgcdRMIiH6KDjXnnzBKUYqOfyu9OnndLDKxMSVHjdIKD+RzWjwXZg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3vcxu5unhk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 03 Jan 2024 09:35:47 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 3 Jan 2024 09:35:46 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 3 Jan 2024 09:35:46 -0800 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 94E045B6931; Wed, 3 Jan 2024 09:35:44 -0800 (PST) From: Elad Nachman To: , , , , CC: Subject: [PATCH] mmc: xenon: Add ac5 support via bounce buffer Date: Wed, 3 Jan 2024 19:35:41 +0200 Message-ID: <20240103173541.1835166-1-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: LvIhS-xD5PP_syi32eiOwJvqelREBfVU X-Proofpoint-GUID: LvIhS-xD5PP_syi32eiOwJvqelREBfVU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787091693214085549 X-GMAIL-MSGID: 1787091693214085549 From: Elad Nachman AC5/X/IM SOCs has a variant of the Xenon eMMC controller, in which only 31-bit of addressing pass from the controller on the AXI bus. Since we cannot guarantee that only buffers from the first 2GB of memory will reach the driver, the driver is configured for SDMA mode, without 64-bit mode, overriding the DMA mask to 34-bit to support the DDR memory mapping, which starts at offset 8GB. Signed-off-by: Elad Nachman --- drivers/mmc/host/sdhci-xenon.c | 33 ++++++++++++++++++++++++++++++++- drivers/mmc/host/sdhci-xenon.h | 3 ++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index 25ba7aecc3be..4d6df1815da1 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "sdhci-pltfm.h" #include "sdhci-xenon.h" @@ -422,6 +424,7 @@ static int xenon_probe_params(struct platform_device *pdev) struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); u32 sdhc_id, nr_sdhc; u32 tuning_count; + struct sysinfo si; /* Disable HS200 on Armada AP806 */ if (priv->hw_version == XENON_AP806) @@ -450,6 +453,23 @@ static int xenon_probe_params(struct platform_device *pdev) } priv->tuning_count = tuning_count; + /* + * AC5/X/IM HW has only 31-bits passed in the crossbar switch. + * If we have more than 2GB of memory, this means we might pass + * memory pointers which are above 2GB and which cannot be properly + * represented. In this case, disable ADMA, 64-bit DMA and allow only SDMA. + * This effectively will enable bounce buffer quirk in the + * generic SDHCI driver, which will make sure DMA is only done + * from supported memory regions: + */ + if (priv->hw_version == XENON_AC5) { + si_meminfo(&si); + if (si.totalram * si.mem_unit > SZ_2G) { + host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; + host->quirks2 |= SDHCI_QUIRK2_BROKEN_64_BIT_DMA; + } + } + return xenon_phy_parse_params(dev, host); } @@ -562,7 +582,17 @@ static int xenon_probe(struct platform_device *pdev) goto remove_sdhc; pm_runtime_put_autosuspend(&pdev->dev); - + /* + * If we previously detected AC5 with over 2GB of memory, + * then we disable ADMA and 64-bit DMA. + * This means generic SDHCI driver has set the DMA mask to + * 32-bit. Since DDR starts at 0x2_0000_0000, we must use + * 34-bit DMA mask to access this DDR memory: + */ + if (priv->hw_version == XENON_AC5) { + if (host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA) + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34)); + } return 0; remove_sdhc: @@ -680,6 +710,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 {