Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp456987rdh; Wed, 7 Feb 2024 09:27:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdVkyypxYA2FPLNeZTafwfEvJxuxyRvf7S++1xRknOseQ5pyoARxvdkncwvmNgXOf/9jVD X-Received: by 2002:a17:90a:cb0a:b0:295:aaaa:74fe with SMTP id z10-20020a17090acb0a00b00295aaaa74femr238437pjt.14.1707326866932; Wed, 07 Feb 2024 09:27:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707326866; cv=pass; d=google.com; s=arc-20160816; b=Hduh6q4oCoPAzcK20purVsU4ffUnR6DtIZvVWs0P7fugGnNTVOr9PFsE94I+kaiQnH L50g2oOEdh7NziX0KIr+WOCYMPwbDK36NcVMiDeqQ76wsYk4EnO5DIDxIoMXK9St3Cs8 fMuJ002J4ypPcN7wEAISxmRtQntrdZtLhg6YONQuO0eyRcnTJQuJmLRGmwkWV8fIRQ03 oMc43OTIDcAxu81Q+s3pTOvDHRjZWMkd7miL7uDIkmp3RQYhWAtXQ18CHG5qL5QN43o7 BSQtp5uVpx9u4QOaRcNEN2grDOg/9I4j+D/nQjX70BXaFlBtngwE6L1GcYau7FKXRLeJ 0nZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=9GbhGJFen+rZb/8GL5jjUcVb+EgOwgfWs6I0/DZPcxw=; fh=PipO9ZD07mbFk5EvGQjrmaaK4DySS5KOJbTJQKNbKts=; b=DkmQ+R6ZyDYILZy6+SzZrDpMk7dpxxFTgVdjCn83eXm/Rt+c0ovNiGYJao8fnthfOf SrF0wdXsx+zGaE/PfNGQRK4qmCxqAQFDokxsDyt+AKKDNObOKeK4Ziz5yyVZch7d+DpF pPkBhq2JW0qHBOsbemQg459XAE1ID98sgoxFok8ZO+3St38cwmHMzowl7/pQIO+lWGcP dwF0ijAPpcIU+Kzap250ZCxQ/bUW3ggATY0aGWj0D3tC4lPHYKlfJ2q35Ujn5xdj6zw3 KfrFmPiKlzh/BH53WjtES2wHtY7clcY/CaJ+ePuf8IfwYeXTSk+N2K/zmlysXLU/N9IE uWXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pT0o7Pcm; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-56825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCX/gh2Fw/aMVJV/1TOt6PLve9lKSKVLeiBkWs46X+dQav5AuALhbCPlXFKHKXJgpad5xZUSJXkSh6eWMiXCG0NqhbZAXZvvjP+fYzVMxA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g2-20020a17090a300200b00296256908d3si1983055pjb.154.2024.02.07.09.27.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 09:27:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pT0o7Pcm; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-56825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4568F28E177 for ; Wed, 7 Feb 2024 17:25:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B7C582877; Wed, 7 Feb 2024 17:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pT0o7Pcm" Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C923282868 for ; Wed, 7 Feb 2024 17:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707326742; cv=none; b=NU/3427kslGIoMQw0FcKwBP4s6PomgIfiGggz+VL3nwYn3PPrJU3ZXZPvY/nVNYKebE5SA/Twb/DF1ibCKhcWyQZExn2G45oECAvJOm2LxYAZT3JrZJHKABFVzxyhqlJ7wEh6EIUN0AZz1lZMsVkCFG7CYdA6OVoNBhzKMp/eL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707326742; c=relaxed/simple; bh=BXebPHotLM8qKwCQMvIN7v+edJrZgKOrhmuTMg/ZIew=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HPdwuLzJU8aEJIhlfGLtrIds4GLKjuq5ezs1bAdqaeMAAlZPg4ILI8gv/vWvm8w54han0j7CroogMmOh3asUClGMzwAbcznGIzLA3/0iP7YqZnOxIuL/P4tRFHCxht7clq/QKWEIQ5Ip/n5i+SQ+jiSKwKehfi5TumAmNAWDLbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pT0o7Pcm; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6043d9726adso505537b3.0 for ; Wed, 07 Feb 2024 09:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707326740; x=1707931540; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9GbhGJFen+rZb/8GL5jjUcVb+EgOwgfWs6I0/DZPcxw=; b=pT0o7PcmiEDqRffzmzjIB7PwAfYwJNQcmdAefCNQPIFuawcGE+kAE0BsEmhj82v9tH iFif3BCEriIKITdmaLyxRdhxUOsJn/MD5lih5pdX7kx6UlZpPJYMXUsqjuxg8Ao2EZZL ltQC+Cs1hRrYvbu/yJG9Bed9Uem9oOMHZUKyu9cTxLnL9pgISZ+Eq1h0Ox6M6YqrcuDx rPAl8sB5h79UDVq84MMoWjA5CRPtCQiLzx/ASy0BzLY563yvWDIDlYl0qIONktQSZkQp 2iRAs4pOZyKsRzlUG7aN/JqWQVSGeN15eaOJ1GM35N0zM2q8+5qRL+vnxd1Hjg2PBFSK HrnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707326740; x=1707931540; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9GbhGJFen+rZb/8GL5jjUcVb+EgOwgfWs6I0/DZPcxw=; b=vuSPzbYxQ21WeQj/Te5ttYXOzM06SRl++paZyz8E1JWuejR+2Ey8NzzU113Zy9s8Fs rv99F7Gptb2sXShwHT76/aQzFYKkwRt67N3BrDyGtl+tj3iMaAtu8OTI1k33GtEDOv9n Ni0Abk2te0Evc2gA3WF6qnGfs3zN/DilIgk5DGZ/BNb13USi87G2LBpIgGpmoYIcF7c7 8uav8arj6okNozugJ9h51tQ6LYjQZAfy97G0aNzKrXw+qzXFzBrAgrE3ivwSI0Z/EZ/p 6J0eiOvZL+yJzuQQ1oyypWyY7chzOafmSOulU+5lC4sq2Me2+Zmlupji8Bznen1tegx1 3qJw== X-Gm-Message-State: AOJu0YwG0ilopPdX03PiOvuJmZpkZoLlwqeDPfiY9cRtZLYl2KHREvAJ 5GN3XWdrL/6Q3XogRg5o90alsGw+B3kKvQ/07naLWzhdW7pB2nDO5Hyee2fOteNdhr82DQSGlM2 mkcNVd3TbyaMPKJKWhZ1nJozPJ/D7kDBJiH7t/A== X-Received: by 2002:a0d:e813:0:b0:604:9ce9:5132 with SMTP id r19-20020a0de813000000b006049ce95132mr119472ywe.7.1707326739690; Wed, 07 Feb 2024 09:25:39 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240207170425.478558-1-enachman@marvell.com> <20240207170425.478558-3-enachman@marvell.com> In-Reply-To: <20240207170425.478558-3-enachman@marvell.com> From: Ulf Hansson Date: Wed, 7 Feb 2024 18:25:03 +0100 Message-ID: Subject: Re: [PATCH 2/2] mmc: xenon: add timeout for PHY init complete To: Elad Nachman Cc: huziji@marvell.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Wed, 7 Feb 2024 at 18:04, Elad Nachman wrote: > > From: Elad Nachman > > AC5X spec says PHY init complete bit must be polled until zero. > We see cases in which timeout can take longer than the standard > calculation on AC5X, which is expected following the spec comment above. > According to the spec, we must wait as long as it takes for that bit to > toggle on AC5X. > Cap that with 100 delay loops so we won't get stuck forever. > > Signed-off-by: Elad Nachman > --- > drivers/mmc/host/sdhci-xenon-phy.c | 31 ++++++++++++++++++++++++------ > 1 file changed, 25 insertions(+), 6 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c > index 4e99197b62c3..f551a9e31772 100644 > --- a/drivers/mmc/host/sdhci-xenon-phy.c > +++ b/drivers/mmc/host/sdhci-xenon-phy.c > @@ -109,6 +109,8 @@ > #define XENON_EMMC_PHY_LOGIC_TIMING_ADJUST (XENON_EMMC_PHY_REG_BASE + 0x18) > #define XENON_LOGIC_TIMING_VALUE 0x00AA8977 > > +#define XENON_MAX_PHY_TIMEOUT_LOOPS 100 > + > /* > * List offset of PHY registers and some special register values > * in eMMC PHY 5.0 or eMMC PHY 5.1 > @@ -244,7 +246,7 @@ static int xenon_check_stability_internal_clk(struct sdhci_host *host) > */ > static int xenon_emmc_phy_init(struct sdhci_host *host) > { > - u32 reg; > + u32 reg, retry; > u32 wait, clock; > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); > @@ -282,14 +284,31 @@ static int xenon_emmc_phy_init(struct sdhci_host *host) > /* get the wait time */ > wait /= clock; > wait++; > - /* wait for host eMMC PHY init completes */ > - udelay(wait); > > - reg = sdhci_readl(host, phy_regs->timing_adj); > - reg &= XENON_PHY_INITIALIZAION; > + /* > + * AC5X spec says bit must be polled until zero. > + * We see cases in which timeout can take longer > + * than the standard calculation on AC5X, which is > + * expected following the spec comment above. > + * According to the spec, we must wait as long as > + * it takes for that bit to toggle on AC5X. > + * Cap that with 100 delay loops so we won't get > + * stuck here forever: > + */ > + > + retry = XENON_MAX_PHY_TIMEOUT_LOOPS; > + > + do { > + /* wait for host eMMC PHY init completes */ > + udelay(wait); > + > + reg = sdhci_readl(host, phy_regs->timing_adj); > + reg &= XENON_PHY_INITIALIZAION; > + } while (reg && retry--); > + > if (reg) { > dev_err(mmc_dev(host->mmc), "eMMC PHY init cannot complete after %d us\n", > - wait); > + wait * XENON_MAX_PHY_TIMEOUT_LOOPS); > return -ETIMEDOUT; > } Similar comment as for patch1, please convert to readx_poll_timeout() or similar. Kind regards Uffe