From patchwork Thu Jul 25 20:44:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 814380 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp566355wrn; Thu, 25 Jul 2024 13:46:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXSsubkM6K/veAnxy10tEREmPvDdyK3ljidVgaVQifj9VC7T2lMIqbQ1cS6bJ6gJln96E/QcJXw4cPHHekIyZTm X-Google-Smtp-Source: AGHT+IFhi5ZaCiIoNTEK4VGhyMg4oVuGlr9YYg2CNY48aheiu771Od0iptyZYtpT4MYTudD6q6X3 X-Received: by 2002:ac2:4e09:0:b0:52e:be49:9d32 with SMTP id 2adb3069b0e04-52fd3f78a06mr2823495e87.47.1721940364712; Thu, 25 Jul 2024 13:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721940364; cv=none; d=google.com; s=arc-20160816; b=oi00DzV2NeZDVBGIupbDvpi1oMeSslAL8E2BH/BfaO6Z6vcBdL7ErqCHMIowQm5Kkm 73aj42zEtXciSYlT56eO4wXFKwTp7rz3oeRkjq+BIsYB2HX34hwSLsaw1icoBTm1eUw0 EWPKDQegofGfoCgx1yKghCz8dJ3RC4dAcGTRv3/eFDnKzRCi67Px17DhSYr/Xp4rBapG nx1Va1n6f33EpXVtLKzKgOHfpHMi1KF8Wm/Bh8MS3YLwwHYntEQlzC1W+nt1ugGc4e4f j0wAULZ32cyVUpMGVTU48gjmQ43lzmr1kB9LpFiXmO2kHM/lfJECfy1UiuPtGZVNpqQl sjcg== 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=AEaa0UgmA69sOJlXSnUibgJNWjLQa8i6ZNCcPfHIwDw=; fh=QQhRsY+g6U1du57yqTOg2GHH1d71LnG5bpIp0iOYzr4=; b=d8DgJJQKea2s7Z5rYvXYErD25Qjt1DiYWUNjZglR0A1qN2HmCwG8i/oknbHtgF90rY lfJJ6in5AhzuazfBZo1oxqcjLOy0HtHHLA4NMOQkdz8xtia8f9ZN4vyiHGgexOWHfc9Y JK139BQ7/WaiG0i9Tc3c/omZdnPyPlJbo6/Jp57Y4GMNnhJ0s5KYQpY4btJLdvdFRSKH zG4avpHB63F5N4DjmX1QWD4zeOuCgeP5ra4d3Gd9/Bf6Mb8JJ7Ekgr2mo6mbTuzHwZ9i Sx8iYk92lkjsEMdcE7L4k60GTam9fvGMTdR96Hf6eFGrljLot+sYIAi4HLm586ppncHn IrKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3NLLRQo; 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 2adb3069b0e04-52fd5b9dd89si683377e87.186.2024.07.25.13.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:46:04 -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=R3NLLRQo; 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 55877884AC; Thu, 25 Jul 2024 22:45:30 +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="R3NLLRQo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 077CC88370; Thu, 25 Jul 2024 22:45:27 +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-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) (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 D1D6E88100 for ; Thu, 25 Jul 2024 22:45:24 +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-x336.google.com with SMTP id 46e09a7af769-7093472356dso192395a34.0 for ; Thu, 25 Jul 2024 13:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721940323; x=1722545123; 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=AEaa0UgmA69sOJlXSnUibgJNWjLQa8i6ZNCcPfHIwDw=; b=R3NLLRQo//LXglPTVb03qNy0zQ68bXGDXjYVe3G1y+oJjHIvoM61rGUHXlgUN+UPe5 Pa5HdcGcfdzRJoJyY5rYranNX6qrnlyO/Kd4y1HuvIHcBL5EPVAJwMJdQ50anE+Oj/O2 neKU9F05O/F2HaxJij8ZC5JJGz6/yCP2a60B7NPuO/0u0OR+pkHfUyrYNmuoSbOsIjz+ pZL/7KxKWto4QyLl4gmrpqUWy1jLdeF2OsuAX3PqTcjuYxkKKWPb8qNWAu8O6HwZfurK Si+RxniVuXdaAx6B51nDBOUdTTFCvKDXDA+LFdsZhwG+wx/VcrlMwEGbaI4sQjKVsLtN 8R8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721940323; x=1722545123; 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=AEaa0UgmA69sOJlXSnUibgJNWjLQa8i6ZNCcPfHIwDw=; b=fxIv7Cx4P6ka3rTfvbAm6xcEy78GDIV09CE9u8iAWT92JYrzflBphqfZaJ6j4CKpum ADNNDj9fO//Ch6Pi1EvRgDE8F6UKIkVbMVLhuxIrKmqRk+tm8bDZGHiJBZRjnUiJKw/E e1qSoz9YrjcQkV7vb8ZuusinlwcLPOdfGpQDd+7CWE5WixyIoNLb66TOuWOYRMb7o9DQ +6O0PsXsv1hfy+Xh9YZfq4DKuBPYKVq1IeGLjdpv+q4eVZFm5TK1RXNL03BMGtymyKfP 6u02LPjrFQUrPtAiNTtR1WUWKzZfFh8idXQZZWRIw6/58EyK2KVUdC7D1IY/5yQbBIx1 KZpA== X-Forwarded-Encrypted: i=1; AJvYcCX2EBu511H34Zj9Js+biO5oMfMRUV5Z19r8x4I8n+m6O/qijXVM2Osf7on0JgKzWMlg7uNxq0hG55rYyGC+0o1nLJh6eg== X-Gm-Message-State: AOJu0YyL12PB3Q7ky1NIK3atzZFSA2gZ0vnZOANLU735dzkmBDN0YriU 0S6sGo+k1om/6khSNok2uMKsquelnXpk8YZ/bAbayIIHxot5875QYqyshESyKHk= X-Received: by 2002:a05:6830:6d0b:b0:709:2752:4523 with SMTP id 46e09a7af769-7092e6c7fd5mr6331598a34.8.1721940323589; Thu, 25 Jul 2024 13:45:23 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70930778069sm454759a34.59.2024.07.25.13.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:45:23 -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 03/38] mmc: dw_mmc: Extract waiting for data busy into a separate routine Date: Thu, 25 Jul 2024 15:44:45 -0500 Message-Id: <20240725204520.18134-4-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 Waiting for data busy is a logically separate operation and should be implemented as a separate routine. Follow Linux kernel example and extract it from dwmci_send_cmd(). This way it doesn't clutter dwmci_send_cmd() function, and can be reused later in other cases. No functional change. Signed-off-by: Sam Protsenko Reviewed-by: Quentin Schulz --- Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - Added R-b tag from Quentin drivers/mmc/dw_mmc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 45665e517068..395b699b0a0a 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -245,6 +245,21 @@ static int dwmci_set_transfer_mode(struct dwmci_host *host, return mode; } +static void dwmci_wait_while_busy(struct dwmci_host *host, struct mmc_cmd *cmd) +{ + unsigned int timeout = 500; /* msec */ + ulong start; + + start = get_timer(0); + while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) { + if (get_timer(start) > timeout) { + debug("%s: Timeout on data busy, continue anyway\n", + __func__); + break; + } + } +} + #ifdef CONFIG_DM_MMC static int dwmci_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) @@ -259,19 +274,11 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, data ? DIV_ROUND_UP(data->blocks, 8) : 0); int ret = 0, flags = 0, i; - unsigned int timeout = 500; u32 retry = 100000; u32 mask, ctrl; - ulong start = get_timer(0); struct bounce_buffer bbstate; - while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) { - if (get_timer(start) > timeout) { - debug("%s: Timeout on data busy, continue anyway\n", __func__); - break; - } - } - + dwmci_wait_while_busy(host, cmd); dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL); if (data) {