From patchwork Thu Aug 8 03:14:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 817673 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp674945wrt; Wed, 7 Aug 2024 20:16:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMRVjO1IbaLXGOs/CRsQF4ZXws4zV6er3smcBRK2WNPmnJai8lj+yUz7HnaghN3ivgOvgwAuDcr71R8TXvpZpW X-Google-Smtp-Source: AGHT+IFBPZc09tBy6TIIWuzUUepDb5wRQuBJUf7vjEdrmH/62lmnQ5gVuGkrZ4eQoALg13E9e+kY X-Received: by 2002:a05:6402:5204:b0:5a2:a808:a2e0 with SMTP id 4fb4d7f45d1cf-5bbb21f4142mr372766a12.4.1723086992843; Wed, 07 Aug 2024 20:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723086992; cv=none; d=google.com; s=arc-20160816; b=xTylMhtNgPCfsC9/BMSB0JEtqCw1G9bwrxiXeO4x2M9gNM9XkxSaT/9O3FZjzzKZgc pXHwhttkggR+Ri/avYOKlsmWnWqtOSGGGynKt/jyq0IUTcrJ2idDSEF2wo19xFtTQ+ag IxH2H1hEFj8A4k04xy/c6FqzJ0nSwuVhkhKPmMKTwaDit4pJKXwgYrFrtU/GSRGVNKTX 2J29/Kzvqc7atlxHqXK1pi2NFmFoy9wHRtZG2+kM16XLEAt7aQaSHlGbJZmCQdHrsnFQ 3qpTDsSNjk7lCL2WsxlyFnNzyNakNI6v2cqRj917MaZVQDUWZykSetzNkoOs42fZgpa0 SaCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ou+/LKIzS8B7VKc6gIEftWDf7y0ax9FFdW27CIW2CG4=; fh=eqUy7A6Xa8hTD/OwdAcaEJa9XGKgQXgez7K9Nd3WPJg=; b=UX/w0QkdaexuKvjmth07MYveaDjP0L7Heq6qg4cbHKr3fc2nXq5F3AHEKwspWf9INS 0lTZFFCi/VHbJy/NzuC6JR/55u9B/e5i1uA/LHSo3K8mMYNM7EcQwBGpUwn/LrVoE0Kt IK6XdWOgOU+C+KY6oxjUVMMiLYrLQpp7+/Gvw9qCSBbnAqneLSdNnWAx2J5VbV9JThZB 659cOAOx/3oBwkqpRKHltlrGM25MQhg5F63lPhY5I8jyj7wtipuJZ758lWOfiAYUPiYn UeNl+ixpihMJtWaCe4WYh6WZ+3qJ4wCGZ/Q5BYB0xCgYC68AkZNnpOGAthc4ZqwFo0h2 Sz6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tGgZdNHs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bbb2bf99e4si253496a12.75.2024.08.07.20.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:16:32 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tGgZdNHs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C20F88B09; Thu, 8 Aug 2024 05:15:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tGgZdNHs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ADB088873C; Thu, 8 Aug 2024 05:14:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EA9FC88A66 for ; Thu, 8 Aug 2024 05:14:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-704466b19c4so292282a34.0 for ; Wed, 07 Aug 2024 20:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723086892; x=1723691692; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ou+/LKIzS8B7VKc6gIEftWDf7y0ax9FFdW27CIW2CG4=; b=tGgZdNHsHWj/Zw/hCDLBxKv5a7c6qfdPKP9QgH8YE3mWDnKaBL9bs5nUrO8/ZTSBJg I3+at3fCLrCU/x+2v3w26lu/jDN0An2/TQcqOIkF6M98Wvic4zmyROD309C7gA02IglJ xGAwrXRZGFsd59xflUxjJurP86p4iw2HhFChrH8JeQbl1FbFh6LRimH3R0a2ZDsEEOjI 7vO8csrKGxfc7m218I4cD7rTEsXEQgJJx+l7ozGx3griVvgnrjcQB0Z3jW//25LzsTTD lW5yNCyAHImSKrt9QfJkGffgtg2LHy7FmWvRORp7XnSLLjiE+6AcI5+thogemIcXkOiJ HSjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723086892; x=1723691692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ou+/LKIzS8B7VKc6gIEftWDf7y0ax9FFdW27CIW2CG4=; b=rXdetQYGGbVHkeJVGXmMvZY7D26BljpqllKGg6ShJwnZ4/sSCiOnzMiRUdX3jYYSAA c7uD4vfLiYHORAyLylLailvwaawbVfM7zc6xGS8HMnMz9rBkVkFWlcZG1uQsQEGow/pi I/+B0cC7BXfvf2h+jvePpn0xm4CPZXCY55RStabNH7URzzK7vCblJVZ27O3eZVMX06gp FCJSjq/dVTxapFgRh/ZnbHrEfsFWEp+J6mV4h7Y+w5pZeW3o25gaE3TZufQMbNY0kcWq e/Ld8Y9tHPbn/rYTPRxcdsS+/JL82OvjHoZ8waVRFqTDRhI03LAyHS41/Io/apDmSpDD UJmw== X-Forwarded-Encrypted: i=1; AJvYcCWX6I2C/sGBe0At7uPveZVpWxeSxeAik+4dm/d0rKVrW5DQtZXsFwA27Ws8QlVxDYYWxPYz1pkahr2qste+uO0ascaNxg== X-Gm-Message-State: AOJu0Yx8/i+RtafajQlby97ogTPQPlRZ/ofypLlnoo876ihDLcLUxLVx 6CGLaLKczPbJ0s0B8+LM7EiIgJmmbiG6EJR++mSf3aUWHiSYpt62zXAHxSObNOI= X-Received: by 2002:a05:6830:6987:b0:709:3431:94c3 with SMTP id 46e09a7af769-70b4fc95923mr648403a34.23.1723086891753; Wed, 07 Aug 2024 20:14:51 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70b20d2ef80sm4445523a34.40.2024.08.07.20.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:14:51 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang , Jaehoon Chung Cc: Tom Rini , Henrik Grimler , Peng Fan , Simon Glass , Quentin Schulz , Philipp Tomsich , Kever Yang , Eugeniy Paltsev , Peter Robinson , Jonas Karlman , Yang Xiwen , Ferass El Hafidi , Sean Anderson , u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Subject: [PATCH v5 09/38] mmc: dw_mmc: Improve 32-bit IDMAC descriptor namings Date: Wed, 7 Aug 2024 22:14:15 -0500 Message-Id: <20240808031444.9619-10-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240808031444.9619-1-semen.protsenko@linaro.org> References: <20240808031444.9619-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Prepare for adding 64-bit IDMAC descriptors by renaming current 32-bit descriptor and its fields accordingly. While at it, make use of virt_to_phys() to make it more obvious in which places the physical addresses have to be used. No functional change. Signed-off-by: Sam Protsenko --- Changes in v5: - (none) Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - (none) drivers/mmc/dw_mmc.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index d73d58bcf7d7..3e7073f7de1b 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -20,11 +20,12 @@ #define PAGE_SIZE 4096 -struct dwmci_idmac { - u32 flags; - u32 cnt; - u32 addr; - u32 next_addr; +/* Internal DMA Controller (IDMAC) descriptor for 32-bit addressing mode */ +struct dwmci_idmac32 { + u32 des0; /* Control descriptor */ + u32 des1; /* Buffer size */ + u32 des2; /* Buffer physical address */ + u32 des3; /* Next descriptor physical address */ } __aligned(ARCH_DMA_MINALIGN); static int dwmci_wait_reset(struct dwmci_host *host, u32 value) @@ -42,22 +43,23 @@ static int dwmci_wait_reset(struct dwmci_host *host, u32 value) return 0; } -static void dwmci_set_idma_desc(struct dwmci_idmac *idmac, - u32 desc0, u32 desc1, u32 desc2) +static void dwmci_set_idma_desc32(struct dwmci_idmac32 *desc, u32 control, + u32 buf_size, u32 buf_addr) { - struct dwmci_idmac *desc = idmac; + phys_addr_t desc_phys = virt_to_phys(desc); + u32 next_desc_phys = desc_phys + sizeof(struct dwmci_idmac32); - desc->flags = desc0; - desc->cnt = desc1; - desc->addr = desc2; - desc->next_addr = (ulong)desc + sizeof(struct dwmci_idmac); + desc->des0 = control; + desc->des1 = buf_size; + desc->des2 = buf_addr; + desc->des3 = next_desc_phys; } static void dwmci_prepare_desc(struct mmc_data *data, - struct dwmci_idmac *cur_idmac, + struct dwmci_idmac32 *cur_idmac, void *bounce_buffer) { - struct dwmci_idmac *desc = cur_idmac; + struct dwmci_idmac32 *desc32 = cur_idmac; ulong data_start, data_end; unsigned int blk_cnt, i; @@ -65,6 +67,7 @@ static void dwmci_prepare_desc(struct mmc_data *data, blk_cnt = data->blocks; for (i = 0;; i++) { + phys_addr_t buf_phys = virt_to_phys(bounce_buffer); unsigned int flags, cnt; flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH; @@ -76,22 +79,22 @@ static void dwmci_prepare_desc(struct mmc_data *data, } else cnt = data->blocksize * 8; - dwmci_set_idma_desc(desc, flags, cnt, - (ulong)bounce_buffer + i * PAGE_SIZE); - desc++; + dwmci_set_idma_desc32(desc32, flags, cnt, + buf_phys + i * PAGE_SIZE); + desc32++; if (blk_cnt <= 8) break; blk_cnt -= 8; } - data_end = (ulong)desc; + data_end = (ulong)desc32; flush_dcache_range(data_start, roundup(data_end, ARCH_DMA_MINALIGN)); } static void dwmci_prepare_data(struct dwmci_host *host, struct mmc_data *data, - struct dwmci_idmac *cur_idmac, + struct dwmci_idmac32 *cur_idmac, void *bounce_buffer) { unsigned long ctrl; @@ -308,7 +311,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, { #endif struct dwmci_host *host = mmc->priv; - ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, + ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac32, cur_idmac, data ? DIV_ROUND_UP(data->blocks, 8) : 0); int ret = 0, flags = 0, i; u32 retry = 100000;