From patchwork Thu Jul 25 20:44:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 814385 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp566599wrn; Thu, 25 Jul 2024 13:46:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkBzVNgTYAfkG6CM/xm+oFAnwJNKXqH2KGFye+YfJnwoptm0b2NTSZx6foQ3WN3n9lLI7uvlhe0GWZzkkQkOJI X-Google-Smtp-Source: AGHT+IHL9CYyN2/CIQtDPF1xO7+XvjWP5NpKD+kilkFFWExtDisopu8ri1gJLgEASlF6OiNH/FJV X-Received: by 2002:a2e:3c12:0:b0:2f0:25dc:186d with SMTP id 38308e7fff4ca-2f03db6d150mr23446281fa.1.1721940417117; Thu, 25 Jul 2024 13:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721940417; cv=none; d=google.com; s=arc-20160816; b=JhRHfm8OdWdFDUAMJLeLu64spZWZyw4607AfKQvqfLxbctu8CoHCghn088xRBm3Psg MyjttLaNkVr0Js6WOrgPG6qXWtoerH1T/Qm8t/FPWSjQh2Ts3aA7zglFHB6ZNUcaMiUz 9paaZEN8TIkUYwVFagSW0GYyzuuDnRRnw7AucmvJ4I1G1hSel9U1dH2kt80/x9l5bNQD pwCAaQyYpPNItgkXKiTALXrtcgZ+Q4qQIGwSlLTcqqoKKVpHw8Leh4paCaByZIYBVp1W YzUm5KNih79QauakOxQr8Co+HVCe3M77+YtaDjwwLi7nZJ3R+WJNBnW5SBpBx2Un2iv9 FXmw== 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=ruvCrl4J6m5yDHflv99YfWUnqYW+PtjzSr6qfo4u14c=; fh=wSP/B204CIN4t4qPvXVBagltkwe2xcrt2AcQYVqokKo=; b=wWDsg+HLWP8lNUzmz5KUHkopFAQHHW2toxekrX6t8b2ERsnWKNcxPualIyHZhkFkNk xtWVg9WxEuD2zq92gvTP5Nl8VQBqniiCpfqUftojEDDgkwzJo3i5PxA9sPappnJdcluo 8V2abcpvFbPB7DPGMb7/ofuCFKQpNQI8jNgUbDjOdOmktsUdxzvTbAh1tTvpCzj7gcoD 1iqgUcVDjbvr6+/dRNkakGaxPPhCaucsps6b+AMXklBNmU8Hik5w+QGmrCcvyYX/siNH 9o7cBYbpkQ5iuG9SokpkA00z+RClyDja0vAdjE3Di0TlzPJRFCYTyDKuWp9eYDPuvhWQ iDSg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtTPphZG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 38308e7fff4ca-2f03d1834a9si5828131fa.579.2024.07.25.13.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:46:57 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtTPphZG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 E56A1885A8; Thu, 25 Jul 2024 22:45:36 +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="AtTPphZG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD847884E2; Thu, 25 Jul 2024 22:45:30 +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-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 841EA88297 for ; Thu, 25 Jul 2024 22:45:28 +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-oi1-x22f.google.com with SMTP id 5614622812f47-3dab336717fso205640b6e.0 for ; Thu, 25 Jul 2024 13:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721940327; x=1722545127; 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=ruvCrl4J6m5yDHflv99YfWUnqYW+PtjzSr6qfo4u14c=; b=AtTPphZGtn2lM1qftGNgLgEgMb1HO6xQe31rxtM9eEjT7Iv/30IsNfkbO/Feeg9HNF JcVsLGBLZ25aGDrThdcazAr+Dq//Jwy8z2sZuR6t3aGYpKWMcxodXxsfNESQIEtFBpyE sl9Ldney4Whv1W9kl5aR9WRaGyBUfgQX3kE0byNpAYxuyLiqNpuMnfZ1ZXEXw0L2L/iJ Jo6WSwOX8XPqCva7iGFqOQoIXlvfwtxD7+RU7sXmzdf6XvE9vJvbjhH8nCNN8C2X8ORs rd1NeuvAMjFvLgCsWx/0eqvDru5HM7BkqKPWASu3kS2baR5B+T48WgnYgCp7WqjsneRB idNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721940327; x=1722545127; 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=ruvCrl4J6m5yDHflv99YfWUnqYW+PtjzSr6qfo4u14c=; b=lSFNOYPNbWJllLIRte4/xV4kUD2xJmzMZY8Lh8w4Ay8v0H9xwjtfSUrsNXta6Z0qGA LNLKTMc121ZuSKG/oh76l+JesGpmpqXVQuNo/Lw/dhyWfYD365m50v3okUhK/hqdJ9Wj Em5FqehjF+fob3CGnHUJr8XBAzc945te34RaCtxuJD9iTPnHjmu0vO4girXh/pjMY8N/ o+bfzxN8y26XJ5BSl9WbLLUofSKS5BPFW8Y8CqdUcfiLTCZIECmmUX09CEM+UB6s5Y/3 xf0veN9bD+H8gVEzeftrwc1NkOb/JlwRFIKm1OymSk4LH7GACEKlzZUQ4Em6hp+HO8v9 35uQ== X-Forwarded-Encrypted: i=1; AJvYcCXBpV/98miLMFs+3eHUisiY8xL48liZ9RsfK9ecEYiGxhO3F/abbFiv3DsCYBABSXUwb2OC68u6ZggWnO4a5CG5K0Wphw== X-Gm-Message-State: AOJu0YwQ83F3v0LrAoEsTnREYiT/LLEthp/DubX7IQfFju1wN7bfC45b 7nebqEsYoFM27qNBBwc2bNOZwU8XSkTs8d7GfHS5WxC6AZzwbodtUKGMPyYndb4= X-Received: by 2002:a05:6808:171c:b0:3da:a032:24bc with SMTP id 5614622812f47-3db1109b545mr4554198b6e.33.1721940327224; Thu, 25 Jul 2024 13:45:27 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3db135544f3sm422923b6e.51.2024.07.25.13.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:45:26 -0700 (PDT) From: Sam Protsenko To: Jaehoon Chung Cc: Minkyu Kang , Minkyu Kang , Tom Rini , 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 v4 08/38] mmc: dw_mmc: Extract setting the DMA descriptor into a separate routine Date: Thu, 25 Jul 2024 15:44:50 -0500 Message-Id: <20240725204520.18134-9-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240725204520.18134-1-semen.protsenko@linaro.org> References: <20240725204520.18134-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 Make dwmci_prepare_data() function easier to read by extracting the preparation of IDMAC descriptor into a dedicated function. No functional change. Signed-off-by: Sam Protsenko Reviewed-by: Quentin Schulz --- Changes in v4: - Rebased on top of the most recent master Changes in v3: - (none) Changes in v2: - Added R-b tag from Quentin drivers/mmc/dw_mmc.c | 51 +++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 8fc26399034b..d73d58bcf7d7 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -53,46 +53,57 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac, desc->next_addr = (ulong)desc + sizeof(struct dwmci_idmac); } -static void dwmci_prepare_data(struct dwmci_host *host, - struct mmc_data *data, +static void dwmci_prepare_desc(struct mmc_data *data, struct dwmci_idmac *cur_idmac, void *bounce_buffer) { - unsigned long ctrl; - unsigned int i = 0, flags, cnt, blk_cnt; + struct dwmci_idmac *desc = cur_idmac; ulong data_start, data_end; + unsigned int blk_cnt, i; + data_start = (ulong)cur_idmac; blk_cnt = data->blocks; - dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET); - - /* Clear IDMAC interrupt */ - dwmci_writel(host, DWMCI_IDSTS, 0xFFFFFFFF); + for (i = 0;; i++) { + unsigned int flags, cnt; - data_start = (ulong)cur_idmac; - dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); - - do { - flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH ; - flags |= (i == 0) ? DWMCI_IDMAC_FS : 0; + flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH; + if (i == 0) + flags |= DWMCI_IDMAC_FS; if (blk_cnt <= 8) { flags |= DWMCI_IDMAC_LD; cnt = data->blocksize * blk_cnt; } else cnt = data->blocksize * 8; - dwmci_set_idma_desc(cur_idmac, flags, cnt, - (ulong)bounce_buffer + (i * PAGE_SIZE)); + dwmci_set_idma_desc(desc, flags, cnt, + (ulong)bounce_buffer + i * PAGE_SIZE); + desc++; - cur_idmac++; if (blk_cnt <= 8) break; blk_cnt -= 8; - i++; - } while(1); + } - data_end = (ulong)cur_idmac; + data_end = (ulong)desc; 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, + void *bounce_buffer) +{ + unsigned long ctrl; + + dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET); + + /* Clear IDMAC interrupt */ + dwmci_writel(host, DWMCI_IDSTS, 0xFFFFFFFF); + + dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); + + dwmci_prepare_desc(data, cur_idmac, bounce_buffer); ctrl = dwmci_readl(host, DWMCI_CTRL); ctrl |= DWMCI_IDMAC_EN | DWMCI_DMA_EN;