From patchwork Tue Apr 14 16:13:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185406 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1601545ilf; Tue, 14 Apr 2020 09:14:25 -0700 (PDT) X-Received: by 2002:a19:f518:: with SMTP id j24mr330685lfb.205.1586880864893; Tue, 14 Apr 2020 09:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586880864; cv=none; d=google.com; s=arc-20160816; b=jubBdIV4MOu5UxHCAJt4YYeSpO5xQCnnhj6xFlFOL1Rq2TYa8jt7AkPM1ntCMpoHEg z1EyZDnKMoGO9R/in/d4VJd6CWP5JXPr0FL1SqeqQYvju6c7ZMntSUQm0zW5DDOE0Nnv ZlWNWbVrtrniChrAcSKgxyRHc1KDe910tTsjXcKuhU63wulV89wxUF0U8KnIaY5NA0EN P0GT+NDfKHb6eZxligfe7OBGuXleemUFfA2ML+AeI+nloAKA8bQD1/sQ6kwvHBQ0e2iQ aVCpi8bOZoFyB+iPNXlVq2jYa+S6ZSu4BXMxnFcKobL3IksSCp7fiXFCYv1v51W/i0w1 1t+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=AYdnh8axE7O5nxAM7j16STUfeW8l+S8DGrk3gV3Ki2w=; b=SzgbOwk3RUhV738ielKKmzkGJTLHGlI2iHsPin/aj8tBybzpT6EPlObNOQ4OO9eNsU MQikka/rDTixgrSEAL1ehZ72C/kG7oM5a/pfUxV9C+Bz8JVmdF/uUSTUpR98rxiSqLbk Dim7d5voYROYKhiDBFbTzdl92XjfKhM9mmAwZpqq9bS9DeWtJDo3Gm8cQGnqI+P5k8TT PsT9en+zUgfpTCksNozbGiIQvQl/qyE1vC4GQeroblTdb0gCLILYJ3UuAaAt6CKSO43I KbgfJfwbUg/wcFx6LiaFmRvaq9YNS7Po99NMWwAj4eIcH0ll098zdxcIbzPnfbuktwIx T//w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FYSixSDX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q9sor7989629ljb.17.2020.04.14.09.14.24 for (Google Transport Security); Tue, 14 Apr 2020 09:14:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FYSixSDX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AYdnh8axE7O5nxAM7j16STUfeW8l+S8DGrk3gV3Ki2w=; b=FYSixSDXj+uVpRBQsmoBKTzaDrieN3wjrMbhC5q+4fYMmL0/CTBKEqebCgrrDsU3OU zPl2xwzZRdr1opCFuBqL1MOVlL7r6jndWmP4bsQNDAGy/fk3hiry8bXZgwoSp+IITSMv HrzYz57d4D+qfvswMF5sA8ZyFDwUAHUJr74vY03RvVP7h/BQ71dIZcauFmMSnmXUrbCz Fxs36SiY3EZO+qP6sAM8I6TPdZDYXk1/AM7DIhDRJwrwJuobTNOnKS+qN9LPsfrQGwUw iGqIKy7zqrtF1U13H/iS9Mi/nAfzrpcKbCSWyqrdKdgnTWpg75F6OxyzPpOoiQy9qNYl q7SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AYdnh8axE7O5nxAM7j16STUfeW8l+S8DGrk3gV3Ki2w=; b=qqx292PKV/coJGdvhkp7wGQ5dKTyfOTLO3XVzXWc3+BfiZjr8w4gQOo47okrpz3HJN 5zoNg/rELVt/z15VDYVDI6D8YTKsCLBRZwpxpv3W86Mu8nfnnsGww1QjbzuFKPw1IHYr AaDSQYgKvMkdNKDV6b8Xk+dLTAEyg3CPdOiebTO7m2oxOGdvMan+lNTI4Dz27PJEYQjQ PtgAzLKHyG+2n7zMrlqkdS4ZE/9IEG+BgSayz+vbvxCLxp0+1QdNEbiTMoIsLZKs/y4d nxX0DlMdw2fl5ysAjHXYYtTo3kOZUjJsbS9vHhcEL91XEyGWfUD03gdmP7qavfN5YJJK qi4A== X-Gm-Message-State: AGi0PuadpV9vPPwj/UJHpq2+qlPuUyGrwky2H27R3whsoJ2uS9WskKMI AakLJJN8yH8GDFR7w86BgtCNGMIR X-Google-Smtp-Source: APiQypL8YkNs8e6IfWiesvrfd+ebEKIwH++gg0sGm7nmkBjls88mayVolw3CRNdAwNLZSh7TJrLLoA== X-Received: by 2002:a2e:a303:: with SMTP id l3mr569214lje.166.1586880864266; Tue, 14 Apr 2020 09:14:24 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-131.NA.cust.bahnhof.se. [98.128.181.131]) by smtp.gmail.com with ESMTPSA id a26sm9330669ljn.22.2020.04.14.09.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 09:14:23 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Linus Walleij , Rui Miguel Silva , Johan Hovold , Alex Elder , Greg Kroah-Hartman , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Bruce Chang , Harald Welte , Alex Dubov , Sascha Sommer , Manivannan Sadhasivam , mirq-linux@rere.qmqm.pl, Jesper Nilsson , Lars Persson , Paul Cercueil , Ludovic Desroches , Nicolas Ferre Subject: [PATCH 04/19] mmc: jz4740: Inform the mmc core about the maximum busy timeout Date: Tue, 14 Apr 2020 18:13:58 +0200 Message-Id: <20200414161413.3036-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414161413.3036-1-ulf.hansson@linaro.org> References: <20200414161413.3036-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Some commands uses R1B responses, which means the card may assert the DAT0 line to signal busy for a period of time, after it has received the command. The mmc core normally specifies the busy period for the command in the cmd->busy_timeout. Ideally the driver should respect it, but that requires quite some update of the code, so let's defer that to someone with the HW at hand. Instead, let's inform the mmc core about the maximum supported busy timeout in ->max_busy_timeout during ->probe(). This value corresponds to the fixed 5s timeout used by jz4740. In this way, we let the mmc core validate the needed timeout, which may lead to that it converts from a R1B into a R1 response and then use CMD13 to poll for busy completion. In other words, this change enables support for commands with longer busy periods than 5s, like erase (CMD38) for example. Cc: Paul Cercueil Signed-off-by: Ulf Hansson --- drivers/mmc/host/jz4740_mmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index fbae87d1f017..cba7a6fcd178 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -108,6 +108,7 @@ #define JZ_MMC_LPM_LOW_POWER_MODE_EN BIT(0) #define JZ_MMC_CLK_RATE 24000000 +#define JZ_MMC_REQ_TIMEOUT_MS 5000 enum jz4740_mmc_version { JZ_MMC_JZ4740, @@ -440,7 +441,8 @@ static unsigned int jz4740_mmc_poll_irq(struct jz4740_mmc_host *host, if (timeout == 0) { set_bit(0, &host->waiting); - mod_timer(&host->timeout_timer, jiffies + 5*HZ); + mod_timer(&host->timeout_timer, + jiffies + msecs_to_jiffies(JZ_MMC_REQ_TIMEOUT_MS)); jz4740_mmc_set_irq_enabled(host, irq, true); return true; } @@ -893,7 +895,8 @@ static void jz4740_mmc_request(struct mmc_host *mmc, struct mmc_request *req) host->state = JZ4740_MMC_STATE_READ_RESPONSE; set_bit(0, &host->waiting); - mod_timer(&host->timeout_timer, jiffies + 5*HZ); + mod_timer(&host->timeout_timer, + jiffies + msecs_to_jiffies(JZ_MMC_REQ_TIMEOUT_MS)); jz4740_mmc_send_command(host, req->cmd); } @@ -1023,6 +1026,12 @@ static int jz4740_mmc_probe(struct platform_device* pdev) mmc->f_min = mmc->f_max / 128; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; + /* + * We use a fixed timeout of 5s, hence inform the core about it. A + * future improvement should instead respect the cmd->busy_timeout. + */ + mmc->max_busy_timeout = JZ_MMC_REQ_TIMEOUT_MS; + mmc->max_blk_size = (1 << 10) - 1; mmc->max_blk_count = (1 << 15) - 1; mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;