From patchwork Thu Aug 8 03:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 817667 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp674653wrt; Wed, 7 Aug 2024 20:15:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRTfc0jOv5fhtD3tA9t4kJ3WW7nDd5xKVF0ijOiwMCcgynig6Qc5f+DuKuchHzjfJJLraRe4KtdALyt83Ab2yZ X-Google-Smtp-Source: AGHT+IG9szO+LOMsKvWK2sTnDFtKAkoxB71i11gjpogMtY1niyquxpJg3HwRFnanDmeQiw3u9yoj X-Received: by 2002:a05:6402:35d5:b0:5a3:d140:1a57 with SMTP id 4fb4d7f45d1cf-5bbb2238e96mr442983a12.1.1723086929876; Wed, 07 Aug 2024 20:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723086929; cv=none; d=google.com; s=arc-20160816; b=1JgnPYp7/hpjuTiGnae3RbB9C9Qv5Ax5dgwRwzosLfbQ1Gb/QaA7cyTyGGEDiE73B4 fh/wxGJpu31ew1Qfg4StWyLTPvl5mBuAO1U8APXexmZKSdKFccUPevIT83v8SCmmhYTW sg4J20fvoNG7CHGLBMaMq7PTyFJW8q1PIJf6IVVoqdsQW2w6LR7gi8trDL4Pq/A6Crsd MYruQrCGkbgczedYjG9Me4Fa+wXes2Kvyti+3y5pagKxaIFGZm6Tb9ZPW3z1d2EgpQcL Q9IxNVt4XTkdb+5A/3dntGku9Xjl13wWZSGcN1409Sk4RQkmBcwnQLObE1KJSwB/Um3i 3Gcw== 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=82+AAIfpblJ/FxfNzNEtfvvh8sailDSat4YEVZKvy/M=; fh=yakYdCC/pfcN34D/CyuTarEMWgp2fUaiiQTTc4OKO1w=; b=i0i5FEh30p1uGh/1BaMuaLeFeZpdxUR4XjStPXa4aHbg4NadXwGz/KGTbC6xDpXQeO jsEnTSmO6UeosW4lEaqu7hN8KlWT1RSEnwlmX3qvFclwmCP6x+kWoSJDS1XAcd+u9i/d X/cszhyab251No0Ih3TAcAWSm2HS8W/auz6dCX2LCzA/qC5+pT6miBmo20/25gKkMl/D U2mBPoORR9rVlq1G3Mjd530z7pdQmPx4myLOsH1/XmC4eM29x8ntATXrG2EBkc9iuSXn EN2PrFZpdJ6XTSUv9pQWagBVzvb9fxGbtlhhzHAHI/jvhbeknZM7shDIgFEyEQwZ0r3b nfLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QGLDI+6n; 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-5bbb2e34be8si247491a12.534.2024.08.07.20.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:15:29 -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=QGLDI+6n; 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 167DC88A6D; Thu, 8 Aug 2024 05:14:57 +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="QGLDI+6n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E00088786; Thu, 8 Aug 2024 05:14:53 +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-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) (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 B1669888CF for ; Thu, 8 Aug 2024 05:14:50 +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-oa1-x2d.google.com with SMTP id 586e51a60fabf-260e1b5576aso381785fac.1 for ; Wed, 07 Aug 2024 20:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723086887; x=1723691687; 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=82+AAIfpblJ/FxfNzNEtfvvh8sailDSat4YEVZKvy/M=; b=QGLDI+6n6cncDjq9tlQCVBi2eFbekSyXNoVlSoiGy6aF1M4N+W6dP+/L7y4nAsiktP Jj94xCGkXjX7kVmi/xebwpMqs9bUdHtTXdo07oqJypDVOme7NthiQo5iPyJfi3FBgQti 2OT3nhM1UEbiRl5TmeVFWbSZQn8qtPfryN7BVu4N3BWoFvWvDS+ac7TZ+sOB0M/djwzG a1QJr9la7nJd/p7np4QyvycKiMSUOJsNfkdcbtr7P4T0hhwxuoyY2lsOSqXyno5JXwty xgfvNRIEAuury0K9Nlqe6a/u8mNfsWiymTJ8mEAQA9Kj6Rak9atiCx6oNWx6aZ4BkSth Mhfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723086887; x=1723691687; 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=82+AAIfpblJ/FxfNzNEtfvvh8sailDSat4YEVZKvy/M=; b=Oo57Kx2r2PzjqzegnvdAMCC74TdtpOoyD5xyxQRgQjACfrA4t5Mibo4MDrSpM23T/Q j2Sc6/PDxUCfzF/lo0SNfrhIEhy+y0C6AaI7aeuNF+nRzQ/lyKFAXGhSszarylZKZMVi 7YuztGuzVDTXdbu7YyR99UA7gTI5Rnlsydq0UYCEg1NO4HpR0caVXkrfcmKPm4pL8Ygg 8J2ifnrAXgk57EWjh8uDrEUYrGOySpGtTBWWv3GdAuDP3oBaUdnPUhcJanT6mlpyUELn DUcHCc6IE0OoPyKhLGilVPkMMoSxsG4Nw8OmFZMLl+ktD33717W1NfoZQm/ktQwsBj7m iRzw== X-Forwarded-Encrypted: i=1; AJvYcCVgtY9ZvT1LDLBNy3F8FYjDKvH6dp7NrYiJOiZVgzDlj3F6XA0N6beuF3yINM5NXIqi7Lv5avQjh4zqbcTBbfJaS5ccCA== X-Gm-Message-State: AOJu0YywHoYn1Fi6Fv0DMt1Va+xFuMD793odArVGh3+BghE6Vu8VTbnv qma7JhBJs1ryoZqnBrEuhSJ96ndEZeR9Vch5Z5nH9BXCoJt765oBmty1nCp4rDQ= X-Received: by 2002:a05:6870:700f:b0:260:e429:2498 with SMTP id 586e51a60fabf-2692b6ad6camr586034fac.26.1723086887504; Wed, 07 Aug 2024 20:14:47 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2689a6824f3sm4380931fac.57.2024.08.07.20.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:14:47 -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 03/38] mmc: dw_mmc: Extract waiting for data busy into a separate routine Date: Wed, 7 Aug 2024 22:14:09 -0500 Message-Id: <20240808031444.9619-4-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 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 v5: - (none) 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) {