From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 BA02A3E0C68 for ; Fri, 24 Apr 2026 15:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043547; cv=none; b=bDowf5Ybx1Pz7g3XxkaZQR1A/hKLOFV+UDjVv32+w8Kesm0h5jPdi6+jgskYWfq6/KiYk1r+Sb2xERtV4WRt3Dj2IvA0VYhyFw8F/lsA4lHXcBl/VTjnJ8CbzoZOkiEMgZLPCGUOZK9M/KuY3U2PMAzTHn2/TDX0Iud8dtAA/Rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043547; c=relaxed/simple; bh=erJdZLIXjpiFj3N8atWnldU0PKLgYpyHE6leKr8+BQc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IZnzzHmG9WprjHlCTiGz5gR+MjFSR+r+6M9qiONSyhNEqSnSH6IB8lPKIX0oCXPEobMSG78KxyX43EfFM6Aivq7XxZ3tzvIeKwXzdBdDwWIzYZ413EeYeYr5Mk4q+ZSN6aHR+AIv4j9MVRD1UrjTCqsOdbo5dblLDAfJp2efw8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JlfGqdFu; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JlfGqdFu" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-688a8e5fe5eso3852003eaf.1 for ; Fri, 24 Apr 2026 08:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777043544; x=1777648344; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Jjw6HWmliluIPaGVVPTQRMT/dS3mcAJIKstHR/uFT7o=; b=JlfGqdFuSpFMXK09AW1vZE22vUQm++p1sXBfB+VRkM6RfwXKE0OgI0+OziulMldc47 meEIBpPOz8h1tAsaGo7gktBbudN/6gmfCViohKGRIJQJM65ULeUkn5LtJ3/wHlMcYJNN xgK31zgplJ3u0FnDF+/SPyqnN/PKN6uc/7SQg0E+cRNbFWrsebACMCVy2y3wvyXnNjWq ETHU/K2aXhiTL+4wkN1gJzlB231caObPIPkQ8bhO8/EVq1dDPdoU28YF9Drx1wJ7jpOj E/iJiHn3u0nV+JXWUSgQhKfMORlKZBR7uGSzsQI770qH3D7Qb86h9ptQgTyeJ1kgFNmG srzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043544; x=1777648344; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jjw6HWmliluIPaGVVPTQRMT/dS3mcAJIKstHR/uFT7o=; b=F77WHx7bEWly9VJyx8s5HxJJXAh9APty1S4wlhvNFJnI4l2eFoBwjKhJ7EXyW+dbdz isTrItuX4ZmLsbNNDEviFctfH4YBs4dmD2Dj4Fm1Z68QmDu5W/kAkR1VfnTGmaWNoFmW Wicx0sG+Rmiw6tFcywbIAiGslfnU/s6PvxvM6BGNlFUAkZYEkUWNK/PIt2ZA6NGlahLB +f2Hlg4QdsojT58T53MUR9Am/WkpFMSEdeCkfpmiGnyfHPS9hVRwp7I2ZccLhFDeCMIR OIwRhMOL8inKQ2fnBHf8IFh1+cqhRR3BTqmPKH/8Y+GRFVkLw2/jRookLbtGpyJp0ePx 8RmA== X-Forwarded-Encrypted: i=1; AFNElJ+Fy+KNDiYUBwDPTmYSEqlHVV1NpoJjVfavYzCvCU/D6qobxkxZuYGc5I/HupjRlP//6G6GGkSHOXmuoE0=@vger.kernel.org X-Gm-Message-State: AOJu0YycZK+e46oDpDwO/4Rna0hE1zFj9vF1K8kNMuYzheGXF3aj1xyG r5KT/dQJusXdy0WG7aRh+pu9ZvzFF7KL1v/RVplguUCen70q31gTLOu65pKpGaZ6 X-Gm-Gg: AeBDieuoCFSF4qo+lvKussG/rgcjzwBJRTbalLxJF/wt6FkyM2/uk7swh3EQzDGp5Gv YB7AU+0an+ZRx22AJkv4A2aoa6Tb0ZuV9bujJEEJGtJjD8mrjl5BMsvKBbUljwWx2IqwANd3nEC IBDZ9+Dtfv68iI6dPkZdy5UVQ2nzlDJ37xTykrcwt3nXX3DV7FL1BgaVl5efu/IIuYQy3xgBMIU DdMPHmvBO7MT4+HysICF84/wg64cWM5SY/RF/qjP2mNqEdiF68MYKGqxMckYpbB0C3gZgjVd973 +T5Dl5ER31b6n9GyIAu9h+S0wUEroJr4Nr5jDWaRvVEbw+izFa0j1Gg5IGU6UXaApPR0V2YGFH4 37+1KjBtzlwOAo3/x1DijxuJ4p0IK/x6nOC2kjqUWFo5ZVH9J89YVkan3lUbus85scFzrUkw9Nh DFXeaJBqVcE/6GCB3YYMI2GOxUOpbEtk86CeluIQRLlIYUkLU5/SgEtZ/0VIoM50VREDBCFlfqc B0ktVf+wO3+ X-Received: by 2002:a05:6820:16ab:b0:694:9b71:3745 with SMTP id 006d021491bc7-6949b713b91mr9212220eaf.57.1777043543632; Fri, 24 Apr 2026 08:12:23 -0700 (PDT) Received: from errol.ini.cmu.edu (pool-108-17-68-229.pitbpa.fios.verizon.net. [108.17.68.229]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50e392c7994sm200838951cf.4.2026.04.24.08.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:23 -0700 (PDT) Date: Fri, 24 Apr 2026 11:12:21 -0400 From: "Gabriel L. Somlo" To: Inochi Amaoto Cc: Ulf Hansson , Karol Gugala , Mateusz Holenko , Joel Stanley , Kamil Rakoczy , Paul Mackerras , Andy Shevchenko , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Yixun Lan , Longbin Li Subject: Re: [PATCH v2] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Message-ID: References: <20260424013615.470325-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260424013615.470325-1-inochiama@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett Hi, Thanks for the patch! On Fri, Apr 24, 2026 at 09:36:14AM +0800, Inochi Amaoto wrote: > The litex_mmc driver assumes the card is already probed in the BIOS > and skip the phy initialization. This will cause the command fail > like the following when the old card is unplugged and then insert > a new card: > > [ 62.923593] litex-mmc f0004000.mmc: Command (cmd 8) error, status -110 > [ 62.949717] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 > [ 62.976606] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 > [ 63.002516] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 > [ 63.028442] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 > > Add required clock settings and initialization for the CMD 0, so it can > probe the new card. > > Fixes: 92e099104729 ("mmc: Add driver for LiteX's LiteSDCard interface") > Signed-off-by: Inochi Amaoto > --- > Change from v1: > - https://lore.kernel.org/linux-mmc/20260421025052.755471-1-inochiama@gmail.com/ > 1. use fsleep to replace udelay > --- > drivers/mmc/host/litex_mmc.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c > index d2f19c2dc673..ac0b47604c02 100644 > --- a/drivers/mmc/host/litex_mmc.c > +++ b/drivers/mmc/host/litex_mmc.c > @@ -68,6 +68,9 @@ > #define SD_SLEEP_US 5 > #define SD_TIMEOUT_US 20000 > > +#define SD_INIT_DELAY_US 1000 > +#define SD_INIT_CLK_HZ 400000 > + > #define SDIRQ_CARD_DETECT 1 > #define SDIRQ_SD_TO_MEM_DONE 2 > #define SDIRQ_MEM_TO_SD_DONE 4 > @@ -99,6 +102,8 @@ struct litex_mmc_host { > bool app_cmd; > }; > > +static void litex_mmc_setclk(struct litex_mmc_host *host, unsigned int freq); > + Instead of the forward reference, can you simply move the entire `litex_mmc_setclk` function definition to this location in the file? (i.e., add a separate, "cosmetic" patch simply cut'n'pasting the function body from one place to another, with a commit blurb stating that it's in preparation for the idle-clock fix, and that it contains only cosmetic, no functional changes)? The idle-clock fix patch can then contain nothing but the "#define SD_INIT_*" lines and the hunk below: > static int litex_mmc_sdcard_wait_done(void __iomem *reg, struct device *dev) > { > u8 evt; > @@ -128,6 +133,12 @@ static int litex_mmc_send_cmd(struct litex_mmc_host *host, > int ret; > u8 evt; > > + if (cmd == MMC_GO_IDLE_STATE) { > + litex_mmc_setclk(host, SD_INIT_CLK_HZ); > + litex_write8(host->sdphy + LITEX_PHY_INITIALIZE, 1); > + fsleep(SD_INIT_DELAY_US); > + } > + > litex_write32(host->sdcore + LITEX_CORE_CMDARG, arg); > litex_write32(host->sdcore + LITEX_CORE_CMDCMD, > cmd << 8 | transfer << 5 | response_len); Thanks much, --Gabriel