Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1474253pxb; Fri, 24 Sep 2021 05:29:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX360j//Cisgl3eah7u5J3k/ED5aX5xgEKrOlbQLB1NO6XzVJJWanXqcQyNqvRqxC/9orp X-Received: by 2002:a05:6e02:1c0d:: with SMTP id l13mr8058028ilh.7.1632486582670; Fri, 24 Sep 2021 05:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632486582; cv=none; d=google.com; s=arc-20160816; b=BUUIpL6tPem8UQy4NlAu7Ntc6AIaujoHBbP9iSDz3uboHtzAuTc0B3H2s95mvjir50 f8Imf5p6ICHhHmDbUfTDRNpc1PpmY3GRU7gINP6YpZyxWD6XNrZ4MqjiqMA2bwHhyTKV ZPlVTc4OtHe55C3ymG/VEh9dOLkZzD5+tNA1K0f9UREwOEACkeEeJuklKU9bYGAo1wZ5 rCbsi5OOHwxQFa26p0kkw8qPF+aoU3lapVFz7mA3FTr1iJfSZ9+cQg7KxjFIaf83VdBP d8PS4LI2rj+oJELddilsDxIIddLPWX/PQz4ndphNQgl51qSF7KCL7+7EtUjDdgiqkDYa TEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject; bh=W6gOgBYYTA2xrWnzjiYB6DoADB+NXnVUCJ1QZcnCNls=; b=V+pEtiDS4CL/SXxfAry5Kn8nK2EE5N9h8QhZLSnm36RASYq/bzpAh26SDh30Kf82nu 4TnnDCEM6gFIeVAqiNX68v6O8RRYzQvH+FJF9oAdCaIkk+Uug8alQGKEIPorGief1mAv R2tv79A87l+3fqq586u4m609WA8fMv5VP+hUqK/P3JeC+7AaUVLOwyofWOweJgItT1mj 9ddKIlo9TmQI0rXGTdoxVpl1YbKruprKLzWz3wcroahPl6pAQjf7cbTGYNfbffnI4L54 k4EZayx2VGjFlDTU/N+CyLJF4BoRiaXJLiNPIE8SFosldDS2x1gxSxABitlrPF1/8Tps 31Pw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si365173iop.49.2021.09.24.05.29.23; Fri, 24 Sep 2021 05:29:42 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245433AbhIXMSt (ORCPT + 99 others); Fri, 24 Sep 2021 08:18:49 -0400 Received: from mga17.intel.com ([192.55.52.151]:39088 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbhIXMSs (ORCPT ); Fri, 24 Sep 2021 08:18:48 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="204217693" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="204217693" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2021 05:17:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="559288776" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.84]) ([10.237.72.84]) by fmsmga002.fm.intel.com with ESMTP; 24 Sep 2021 05:17:05 -0700 Subject: Re: [PATCH v1 2/2] mmc: sdhci: Use the SW timer when the HW timer cannot meet the timeout value required by the device To: Bean Huo , Ulf Hansson Cc: Bean Huo , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210917172727.26834-1-huobean@gmail.com> <20210917172727.26834-3-huobean@gmail.com> <93292ef4-8548-d2ba-d803-d3b40b7e6c1d@intel.com> <40e525300cd656dd17ffc89e1fcbc9a47ea90caf.camel@gmail.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <79056ca7-bfe3-1b25-b6fd-de8a9388b75f@intel.com> Date: Fri, 24 Sep 2021 15:17:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <40e525300cd656dd17ffc89e1fcbc9a47ea90caf.camel@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/09/21 2:45 pm, Bean Huo wrote: > On Fri, 2021-09-24 at 13:07 +0300, Adrian Hunter wrote: >> On 24/09/21 12:17 pm, Bean Huo wrote: >>> On Fri, 2021-09-24 at 08:29 +0300, Adrian Hunter wrote: >>>>> If the data transmission timeout value required by the device >>>>> exceeds >>>>> the maximum timeout value of the host HW timer, we still use >>>>> the HW >>>>> timer with the maximum timeout value of the HW timer. This >>>>> setting >>>>> is >>>>> suitable for most R/W situations. But sometimes, the device >>>>> will >>>>> complete >>>>> the R/W task within its required timeout value (greater than >>>>> the HW >>>>> timer). >>>>> In this case, the HW timer for data transmission will time out. >>>>> Currently, in this condition, we disable the HW timer and use >>>>> the >>>>> SW >>>>> timer only when the SDHCI_QUIRK2_DISABLE_HW_TIMEOUT quirk is >>>>> set by >>>>> the >>>>> host driver. The patch is to remove this if statement >>>>> restriction >>>>> and >>>>> allow data transmission to use the SW timer when the hardware >>>>> timer >>>>> cannot >>>>> meet the required timeout value. >>>> >>>> The reason it is a quirk is because it does not work for all >>>> hardware. >>>> >>>> For some controllers the timeout cannot really be disabled, only >>>> the >>>> >>>> interrupt is disabled, and then the controller never indicates >>>> completion >>>> >>>> if the timeout is exceeded. >>> >>> Hi Adrian, >>> Thanks for your review. >>> >>> Yes, you are right. But this quirk prevents disabling the hardware >>> timeoutIRQ. The purpose of this patch is to disable the hardware >>> timeout IRQ and >>> select the software timeout. >>> >>> void __sdhci_set_timeout(struct sdhci_host *host, struct >>> mmc_command >>> *cmd) >>> { >>> bool too_big = false; >>> u8 count = sdhci_calc_timeout(host, cmd, &too_big); >>> >>> if (too_big) { >>> sdhci_calc_sw_timeout(host, cmd); >>> sdhci_set_data_timeout_irq(host, false); // disable >>> IRQ >>> } else if (!(host->ier & SDHCI_INT_DATA_TIMEOUT)) { >>> sdhci_set_data_timeout_irq(host, true); >>> } >>> >>> sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); >>> } >>> >>> >>> The driver has detected that the hardware timer cannot meet the >>> timeout >>> requirements of the device, but we still use the hardware timer, >>> which will >>> allow potential timeout issuea . Rather than allowing a potential >>> problem to exist, why can’t software timing be used to avoid this >>> problem? >> >> Timeouts aren't that accurate. The maximum is assumed still to work. >> mmc->max_busy_timeout is used to tell the core what the maximum is. > >> > > > > mmc->max_busy_timeout is still a representation of Host HW timer > maximum timeout count, isn't it? Not necessarily. For SDHCI_QUIRK2_DISABLE_HW_TIMEOUT it would be set to zero to indicate no maximum.