From patchwork Wed May 22 23:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 798184 Delivered-To: patch@linaro.org Received: by 2002:ab3:6414:0:b0:267:d849:ee76 with SMTP id j20csp917501lte; Wed, 22 May 2024 16:32:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/QSTMLmZ9evCgRRyeEHSlWuekw0TDVaIhiFjtk0SMYBp1Du87dK6SZMxTtKltDurZ1JxjEQ/Mm8IMP50bJ10t X-Google-Smtp-Source: AGHT+IEx8OpPl8ASdKpUcrK7TxYFl4ykFAulb4tHj0we6zPGg8pBEO7VlGOuX7dYS7J5ilcDucOv X-Received: by 2002:a2e:a444:0:b0:2e5:2c7e:257 with SMTP id 38308e7fff4ca-2e94949dfa2mr20932521fa.30.1716420764382; Wed, 22 May 2024 16:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716420764; cv=none; d=google.com; s=arc-20160816; b=q+6vKrdA3JJ8QCAOOwZJPaM45eWSpAplzWS6K9LOcIRQsH/18H6KmpOvMbgnNG9bb3 DIELkVwZG7iVqtQ3VBmlU4S5erj1FFLgIWlK3eoks2SaS+Qas6S0eP4NptVkpQxHNd4i opKh1a7RknhGorOlM8h+7YeFhYhTr+wBwhN7q0NnyWdby0LLRf92f/nh5xnnH9EtGnMf xf73fhUBX1cDY7ySnr5JACTaxSq/S30MgEWG2uANdsQbG3jayjkqKRMmgXIrlqzgeJ7u w37z8dQdC8clbjxG5MGPVXpkqMKEls5VKZaxcGJQ/hAeaSGbDJm9KEcVVZ6cCvP/IZBE EpqA== 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=t3gboz91R7dbgrRePpjOmuoLxx9XyCXEGmIzVeG6Gic=; fh=qvfujmusX+st0fqR3cPijP3UMQnaKZE3Wmsnb/Zd33o=; b=nXlBHPk/ubgIsvUiyIL3MYBqu0XLsBEXV/LMj1EsPKcTSeArCONJJHZLDFSywVoQxe PPfAaxTaKZjZ+3zX+r/IbxBwQA9+Udgophdb99e3pNL0knYP7j/vZYB+VosYtuv9DCga ZQ9bKEg+WW7IdjGpmlUsm2ENMCHwPZ0hnoztzhWO15BI6dkQzrv/NMPbghX4pZYVCwD4 0vxs5z/PgBhTu2iVwHWXYIj5uJe0XTTZ3CdztSXIFqZbF9WBBm4U9Xh1NWcNNxttivDt C1G/+851o/xNlgLm9q4/XQAz05ENNAd/uQPUV52o9Hs6pF+9EAr8/BrAkLyB2nfRQcsc fG7Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yFcJC6Q+; 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 Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d4e7csi15493484a12.322.2024.05.22.16.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:32:44 -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=yFcJC6Q+; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ACDEC88517; Thu, 23 May 2024 01:31:46 +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="yFcJC6Q+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D40C884EE; Thu, 23 May 2024 01:31:42 +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-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) (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 64B69884DC for ; Thu, 23 May 2024 01:31:40 +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-xc35.google.com with SMTP id 006d021491bc7-5b2dec569e3so3098521eaf.2 for ; Wed, 22 May 2024 16:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716420699; x=1717025499; 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=t3gboz91R7dbgrRePpjOmuoLxx9XyCXEGmIzVeG6Gic=; b=yFcJC6Q+wZ32RKaTDyZTRYpi011+HHBOv3Qy7/Qw2js+jRjaLPqOEwLUhEQ8aXdEFV 88yntpFMFBFmjdsbUqTtKxe4snAdiLhkTcYRb8r28o5NKg2Jer8geHztLt0RcluJpPGM cTvrBHY/WbdE7DSSUvWwgjOcYdARTMzQ3KIE0cKrUDDO52diHylRYhaNh80ii3r9dMFn PCZhE85Wn01pAdmVJwJYKqVsq78xKjk4KCYqPMyeMjhBRMSqjY3FUM9oqc5G6gDd7FW+ nY5+noh3g1IRyGbU7rlO01xypGcXGIce3k2ooaMT8NZY1SUW2i6OhXKGz4bhWL25enGs eI1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716420699; x=1717025499; 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=t3gboz91R7dbgrRePpjOmuoLxx9XyCXEGmIzVeG6Gic=; b=Rhe+fOKermRSXGcBdjZKnaeJwfBhyGiR9oXnfzUrMYizkAixiLr5PHlPhCHuNV8t5G E1032IaO75v4npFfmx/BimWznfZKAx22UEIValk8etUgd3JPCU3cpFCeaSnzSPq9IADy KrDnqMJXH9mll7HwIO+/miSEMubFswlFiqsbNtv+QDEHgqPUl7Y3OkMc1xJKHPkmW7hh G0m3PzCPbnmKl76YPD5LhftAHTtwNAHNc/H9rXbDmyQdMzRu+TIku2oueCIrxFleqKqH zwZBppn0nX2JK8Pkx4DAQkqnBbS1E57rwd9BpM05M8CfjO6XvvWJpO9fyj8BFvmymAoL 0b2g== X-Forwarded-Encrypted: i=1; AJvYcCXHX4aKDJXhp6TZrP3CUi8rxrbVQOKAJ1K7pEoFLn++t96HvZQArxknihaXFkyB9PMYbtAyIuEETDpqF5OO5L7ksoLVIg== X-Gm-Message-State: AOJu0YyTD+8ztDWa7bV1s8yRyn5gwO6PMs7RjTVb4ucadoaoAteeJAqa HeT0l0tFuXsvlVP8YRK+BYc9I1guwXp7ZHcoh7ocZqaYEC3W8BfYHuQZdjcGkBs= X-Received: by 2002:a05:6820:618:b0:5b2:ff69:9814 with SMTP id 006d021491bc7-5b6a0c10983mr3503553eaf.2.1716420699073; Wed, 22 May 2024 16:31:39 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5b539ff2464sm1334312eaf.8.2024.05.22.16.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:31:38 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: 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 04/42] mmc: dw_mmc: Extract waiting for data busy into a separate routine Date: Wed, 22 May 2024 18:30:57 -0500 Message-Id: <20240522233135.26835-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522233135.26835-1-semen.protsenko@linaro.org> References: <20240522233135.26835-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 --- 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) {