From patchwork Mon Jul 22 17:57:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 813745 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1985130wro; Mon, 22 Jul 2024 10:58:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3ZtPAYi5CDa+WvddJ5N6uF29STJj/rqfGrt5tp4TrsUDHXUPdi3O3uOPBHjEHas4hypj7BU0ZSAnom63r3Fdw X-Google-Smtp-Source: AGHT+IFGb5tAu3Nm2w61tIV8MVDADU3QeT344mBsvboOqVyuXayTCwZH/6z1fmGpMG0cMVTyWy/P X-Received: by 2002:a17:907:3ea1:b0:a77:e140:a66d with SMTP id a640c23a62f3a-a7a4c584042mr445789366b.67.1721671097152; Mon, 22 Jul 2024 10:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721671097; cv=none; d=google.com; s=arc-20160816; b=Xkz7H44cv05krw3F6+gG8mmYFDoD4LR28Vi0tA0T/w6oiq9IJD1epUE/zsolyYEq6I hWENaLhJEeyny52KKcy4GU55TPD4QCRQoIBSwArkYL92d5raZy2Q5iwlDP02WnyvGgRI X5Yam0VpZ6b5fDkSMhoKq3ZYR92SkrgSFeE3C+NENSyg244o0YJL8hceQ/tUtza5a4vL F5/EYp0HWREo/bZZtKSzmwBwYvRQutyYLBl2TbLVqLwFi3LAAjDXmZ3I5Xu7C1wWk9ud 32bW/r+TQl+cuf9j3Z7/5vI2KCq0Qywm/WWL8cHygA2rboONCSz2gCLggiNr926nukiY gO0g== 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=WrsM4fGIRFJZwpxDjdxpd7RZs/pDRwGsYnn/StKH7jY=; fh=JOrBZ1G1B8MOmqrQBJoCfuhIhJA9QmjNmSCPIT6v1d0=; b=ZCiq4u1hbZomOpTVIij8bhCcc0KrnYqU8fgXxBLSGq0JyesLu1cticQcI7vrbx1GWi cmflk7Rx7H2V4e7g1votH0L7T9vt4KFkrDwsKmKPLF5B0THP5UGAdrqdS5e6nAAMrL6Q /SeEqSQUawFvSJZL7XN3ITvPiP5dV/YiWYEHWhOmeGXu+Sp2rjqmTIMTwY6euh2jpogS cVScGAlvL2uWbV4/acWR3d6y6LlUFQxulpSYY4QwU46uQWhjwYq51eSxFWfMPU2eFG9z ecVQNR3GlgIwf3TtS3hEe7d9bgyLlNfw/cpTW7n9a9IwmJeCGKbFYZFwej9TKHU+BoR5 G+DA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oaZeHI/+"; 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 a640c23a62f3a-a7a3c8c575csi428716566b.283.2024.07.22.10.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:58:17 -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="oaZeHI/+"; 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 797B8884F1; Mon, 22 Jul 2024 19:57:48 +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="oaZeHI/+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17B6A883D9; Mon, 22 Jul 2024 19:57:47 +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-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) (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 B73D5883DE for ; Mon, 22 Jul 2024 19:57:44 +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-oo1-xc29.google.com with SMTP id 006d021491bc7-5d5846f7985so402993eaf.0 for ; Mon, 22 Jul 2024 10:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721671063; x=1722275863; 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=WrsM4fGIRFJZwpxDjdxpd7RZs/pDRwGsYnn/StKH7jY=; b=oaZeHI/+8HxdtzURHq/2zB2gITqIiAwXGGk7Jja0zVrjpjktgUFd4b5Xxf+AN1sw2L 7NG/yRHem9vLR+s3Yj+xKaN3t+mDRUnb3SsxfHWGATAdte1o54G3/eLEmlp9GZBgy0ZB wDx6GPJwCHkEYuaHHBBU4SuC7VUcLBgjaW60bK2PdCeKFJbRjdRdcHaMQUEtopom9FE7 GrGtYjkjClCaHuArkTALCh9SbZ0YiL5ZWwsj1hCUssqIIV8gIAoihiRsyHnhrylhyDs6 eVFI2GpiuxpW6CIyOgsorV5lQWNLqajYzj1Pv0l/297ISLVN4l9yRBbvrAddgT1/9W0m VICA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721671063; x=1722275863; 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=WrsM4fGIRFJZwpxDjdxpd7RZs/pDRwGsYnn/StKH7jY=; b=No66tRbkAhPb7sXpyMZQJXF8mSw9wHMtVuCyM4Gj7XJsB3z64vErsCmWHJtJC8prOT By3RlPGdxKdrjAtdTzRFLrx74MbaeUIEfeDz+KHqxCiSl4CkoIHw+Jy3tTOa525yuqxN QqBoKxY/gDh7eR6XtTGVABRgT9cg9UBq59EQTKo02DTeBIiK20q5nK7/QBUVS72ZEa8q QtLuWq+PgrR/UE/94/01GPL2p1H/JykBB5FosNY2MeEEFuIMvuyczsg7a41tVoKxZtOD UHz03nWCXnNJ722vu+eCGh0Rb5Zca9l4tDH0KD4gEvel67M+05uNHblrAGwn9D3b/DRe 6LxA== X-Forwarded-Encrypted: i=1; AJvYcCXKcTucEIjEG2kRfaA+Al6bGo+jIvlfRcM7Iwpx5xIoE4pqhbWy98+ufiVN9MFXYm/dR15uszAS7VL6QyEL8n0tlwrRMQ== X-Gm-Message-State: AOJu0YwKdukAwx2M+DEKpxTNiBJ+zgupAVgKUPqabv31Y2bwwyqiob+/ 0+Wfom2UnouxPbkU/vtFb+RaWYzptSNe5ai1zr3nd0m66kvUAFApwBcy2OLnRO0= X-Received: by 2002:a05:6820:4c0a:b0:5c4:e036:e383 with SMTP id 006d021491bc7-5d56500366cmr10446736eaf.8.1721671063387; Mon, 22 Jul 2024 10:57:43 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5d55a831b79sm1480335eaf.17.2024.07.22.10.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:57:43 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang Cc: Tom Rini , Peng Fan , Jaehoon Chung , 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 v3 03/38] mmc: dw_mmc: Extract waiting for data busy into a separate routine Date: Mon, 22 Jul 2024 12:57:05 -0500 Message-Id: <20240722175740.6985-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722175740.6985-1-semen.protsenko@linaro.org> References: <20240722175740.6985-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 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 9d668b3d8813..a82f6a96db39 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -246,6 +246,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) @@ -260,19 +275,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) {