Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1880901pxb; Tue, 26 Oct 2021 18:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwegaOgig+TIfj82LJwRJPrnC9aJCpIEyM4haN5V45JlGKBdMMd54pYEdjOaOSDNzd5IuZw X-Received: by 2002:a62:e51a:0:b0:44d:67bd:53ab with SMTP id n26-20020a62e51a000000b0044d67bd53abmr29650161pff.86.1635298430867; Tue, 26 Oct 2021 18:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635298430; cv=none; d=google.com; s=arc-20160816; b=Jb4fxxi3j/8Vodw+CYklwAeDY2z3CPqs/HnCIqZ7WD7ZWqKzxTC+C3wXnGwmDHoPbs 69zcX+97TbVt05qkICL+Z4h5wiaEEsNknU0ZjVQHmgF0c9RMUYBMELV2dMpqT3pNwxtO Tig/rB0i8kRP/SA89aB5ZTW8u3NQSsv6+gjeYAaUDybTmZwL0x91eW3fPO/erNYQBJ4B Bx4Z+HAMwEJ93ZAhBk8SURo/iJJIfWo5LBPWF0jMpQ7+gTeIWWPyj1xFrpmEHs840T/U xFciJbh8ERwhxqexrQRvO4wfcHtUKk2KD21JbVQ5pQbj9jnCZlfy4OL1bFYzpYlcn2P3 MNUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LP40nYkEbLTRumSDbIOq85aSQOkINlJU3Lvgje0t1Ow=; b=x871Sd3wMXvUInQuNdmj3oaIeQH7r4O88IICHwbNTPeP/CDysaHswyEpujeX0u4pF/ ITKrIxghiIDADmDo7k3OV/Ja/laalclgMDsQgZUBwu/5eFZIADLxBKQ8ger1Yqq/xkVN CnQLnFE22gX4h72X59UR1StNYo118LARARenes2HEO8qj2SAkCtiIPqYWi4XuobcrCR9 kGl1sKnGplY4GC4fbyIqToM5rxHMEbm13WVr9ux4WoaHlAEhaMN2tbgbC6GtivosQGdA nWLyiKX4AwScW7DNPM28hgL4vqHFcSOH9rBZJ0FwzK2SSvpF5nayVNZRwmVg7Ii8Dbxu 0qYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CIA7RDXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si34110880plh.134.2021.10.26.18.33.23; Tue, 26 Oct 2021 18:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CIA7RDXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237607AbhJZQ6H (ORCPT + 99 others); Tue, 26 Oct 2021 12:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237329AbhJZQ6E (ORCPT ); Tue, 26 Oct 2021 12:58:04 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31486C061767 for ; Tue, 26 Oct 2021 09:55:40 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id p16so224726lfa.2 for ; Tue, 26 Oct 2021 09:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LP40nYkEbLTRumSDbIOq85aSQOkINlJU3Lvgje0t1Ow=; b=CIA7RDXGOVfr6w+wIEX0zTARG/3oUw7hS1nDA65m5j4EqzU2S3uppECIgYtrZ3onB7 tCjEyCUOL3u34a4MtlqnZjoebRIXxZzeNy4QZeA4EjF0MDXWf04W/2qvfFMhIhU8+cbW KWQCsAPRF+u7Khu7QFp6i/hLT5Y62m7+S+ObY9YqB7ZhKy8+sU6lV1YC59dGSzI/Vl3d xAH/HOOC8w4PiOk3EnRbI6q5j9u1B4nrRX8Q0Z9Mv/WZ3hpA99jBaNFIbAlF9q9bnP9B NOrM63SZQbLdbF/mMpywcsgxhDZAOGkhJuh9GwufQ4gblB0rfFmHY6EAF9o1us5W4vM5 CVSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LP40nYkEbLTRumSDbIOq85aSQOkINlJU3Lvgje0t1Ow=; b=QLtV/Ae44ILda7jpn0mBfACSFLkVQa7f/uXtfyEVMySbic4yk5C9CBolM7Rdy4LoPz fGX8oZreWLIv/C3QeNjhTVmz23/fvOCRczXPXE1Doj6hZGYTcl1aYiZk+XYwnceEE7EX 1tuSj16oltCGg4/hVIS+sPd1rgWwu368QBfutQqK4Ro1m7JlImTZa8Vi3bltyzd4p6g7 yib5SirRW8989Mz/GbnwOuOlRgbh8kNCnhkUAefFTYt/xFnB03bKVwa9/lgpmgOCaDz8 vlGl8kxNxRhi/QcpNMG9sFcj01XCeFSxEdrCrzNVXiK8+JttGA9LoWYZTfoQimvID850 uFWQ== X-Gm-Message-State: AOAM530GjftvjDADZfeyWdURVnHJGtVYjoarNBDjENhZqNNDR0dIzzqX qR9537eYOsFJUtYiqxnS/w9IVeo7jgAfkNEj2VZjuyEgObzvwg== X-Received: by 2002:a05:6512:1515:: with SMTP id bq21mr24435501lfb.71.1635267338322; Tue, 26 Oct 2021 09:55:38 -0700 (PDT) MIME-Version: 1.0 References: <20211022063920.2145-1-huijin.park@samsung.com> In-Reply-To: <20211022063920.2145-1-huijin.park@samsung.com> From: Ulf Hansson Date: Tue, 26 Oct 2021 18:55:01 +0200 Message-ID: Subject: Re: [PATCH 1/2] mmc: core: adjust polling interval for CMD1 To: Huijin Park Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Huijin Park Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Oct 2021 at 08:39, Huijin Park wrote: > > In mmc_send_op_cond(), loops are continuously performed at the same > interval of 10 ms. However the behaviour is not good for some eMMC > which can be out from a busy state earlier than 10 ms if normal. > > Therefore, this patch adjusts the waiting interval time. The interval > time starts at 1 ms, but doubles until the range reaches 10 ms for > each loop. > > The reason for adjusting the interval time is that it is important > to reduce the eMMC initialization time, especially in devices that > use eMMC as rootfs. > > Test log(eMMC:KLM8G1GETF-B041): > > before: 12 ms (0.439407 - 0.427186) > [0.419407] mmc0: starting CMD0 arg 00000000 flags 000000c0 > [0.422652] mmc0: starting CMD1 arg 00000000 flags 000000e1 > [0.424270] mmc0: starting CMD0 arg 00000000 flags 000000c0 > [0.427186] mmc0: starting CMD1 arg 40000080 flags 000000e1<-start > [0.439407] mmc0: starting CMD1 arg 40000080 flags 000000e1<-finish > [0.439721] mmc0: starting CMD2 arg 00000000 flags 00000007 > > after: 4 ms (0.431725 - 0.427352) > [0.419575] mmc0: starting CMD0 arg 00000000 flags 000000c0 > [0.422819] mmc0: starting CMD1 arg 00000000 flags 000000e1 > [0.424435] mmc0: starting CMD0 arg 00000000 flags 000000c0 > [0.427352] mmc0: starting CMD1 arg 40000080 flags 000000e1<-start > [0.428913] mmc0: starting CMD1 arg 40000080 flags 000000e1 > [0.431725] mmc0: starting CMD1 arg 40000080 flags 000000e1<-finish > [0.432038] mmc0: starting CMD2 arg 00000000 flags 00000007 > > Signed-off-by: Huijin Park > > diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c > index 0c54858e89c0..61b4ffdc89ce 100644 > --- a/drivers/mmc/core/mmc_ops.c > +++ b/drivers/mmc/core/mmc_ops.c > @@ -177,6 +177,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) > { > struct mmc_command cmd = {}; > int i, err = 0; > + int interval = 1, interval_max = 10; > > cmd.opcode = MMC_SEND_OP_COND; > cmd.arg = mmc_host_is_spi(host) ? 0 : ocr; > @@ -198,7 +199,9 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) > > err = -ETIMEDOUT; > > - mmc_delay(10); > + mmc_delay(interval); > + if (interval < interval_max) > + interval = min(interval * 2, interval_max); It looks like we should be able to replace the above polling loop with __mmc_poll_for_busy(). We would need a callback function and a callback data, specific for CMD1, but that looks far better to me, if we can get that to work. Would you mind having a look? > > /* > * According to eMMC specification v5.1 section 6.4.3, we Kind regards Uffe