Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8204535imu; Tue, 4 Dec 2018 04:50:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/XrZeAvaCBnBZuj8L9WpVMLv9eO471JfOy/Q/m3W/d5vaW9Dc5NDaRjUlvzuK/uG73d7oKI X-Received: by 2002:a62:69c4:: with SMTP id e187mr20083091pfc.50.1543927821360; Tue, 04 Dec 2018 04:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543927821; cv=none; d=google.com; s=arc-20160816; b=htNkaQRilm8AxTYjWKgW9dH1unyz9J+1T7gtUFkk0p+c47HrkHKFK0SgCuvy/rFm/r p+KSOGQKV+Z/WhdmYh+/PnLsTnlcliwc+O6JziRs8jrFxs+YoAV3Wxqb/lWLkX3aU8+q voVE5uRA7GHL2JHeiTHc7+/jnhpWkmX0Csvw0LqwzFi86wLP28lb8D010dw/SI2NAY/G 9nH9Pf9LKyl9bnSxhNzLIf/HCyplR6SSqBdTle7ZUrbBVPJGhlguwGo2/cx5TIcXXNIt KGjdHa2oWc0AnEN0sHL6zBUvteN7QV2UcMJEimHd5PDUIlwooKnS21BpkqpIq23ZZMLv tTtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=7hw8Y79D3Q/8v1FPPuDusCDtJxOHmZnuaCkiNyl24Q8=; b=xL/OMdiC3JIAETp4yMaZPAod5xgxWsx0dyVDfqv60N07AfH9oT8D7mB7w1c1KjzBUM zIWSJTS2A3zK3zyTWGcfqHiyW1FFkjFio2d4EV01HkiQe9cFil1DCwLEjL4qjEGQcGbl jkXB6apg1BY/ehAUIOiinoD8s6DYRKy77pIpcGC0kqjCarz2+UyYBK2UAPxXeI7p4riS kKDNDKjlirxHAqtvHUtgwGERoRUuxxvFxl6RMA4NMpWN2VqCPBpjMlVssMyrtnJ2M9ZF KYbZODR/bsZqVcTMDdn5EbOGnbIoRe6rf8X/ic6SfS6GWgkhmus0CbVOZicUxY6dz8z5 xWlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 26si15260115pgq.402.2018.12.04.04.50.05; Tue, 04 Dec 2018 04:50:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726250AbeLDMt3 (ORCPT + 99 others); Tue, 4 Dec 2018 07:49:29 -0500 Received: from mga06.intel.com ([134.134.136.31]:44654 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbeLDMt3 (ORCPT ); Tue, 4 Dec 2018 07:49:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2018 04:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,314,1539673200"; d="scan'208";a="97928343" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.130]) ([10.237.72.130]) by orsmga006.jf.intel.com with ESMTP; 04 Dec 2018 04:49:27 -0800 Subject: Re: [PATCH] sdhci: fix the fake timeout bug To: "Du, Alek" Cc: linux-mmc@vger.kernel.org, ulf.hansson@linaro.org, linux-kernel@vger.kernel.org References: <20181130150028.732896d8@xdu1-mobl> <81ba3745-8277-d16e-3aad-48324f51dc8a@intel.com> <20181130221300.4ef2956c@xdu1-mobl> <20181201134251.26573207@xdu1-mobl> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Tue, 4 Dec 2018 14:47:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181201134251.26573207@xdu1-mobl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/12/18 7:42 AM, Du, Alek wrote: > On Fri, 30 Nov 2018 16:40:04 +0200 > Adrian Hunter wrote: > >> So you are saying this only happens under virtualization? >> > > Yes, I saw the issue under ACRN virtualization Service OS (4.19 kernel). > But theoretically it can happen in other case when scheduling is not > that good. (due to bad driver or other high priority task) > > >>> >>> Please look at the sdhci_enable_clk() below, there is a window in >>> clock stabilization check. The first check is to check status >>> register, the second check is to check if time passed. That's why I >>> can capture a case that after time passed, the actually clock >>> control register indicated that clock is stable. So the error >>> handling is wrong... >> >> Sure, but "Internal clock never stabilised." is not one of the >> errors you listed. > > Sorry my bad not listing all the error log: > > Case 1. clock stabilization timeout: (the below clock control dump shows clock is good) > [159525.255629] mmc1: Internal clock never stabilised. > [159525.255818] mmc1: sdhci: ============ SDHCI REGISTER DUMP =========== > [159525.256049] mmc1: sdhci: Sys addr: 0x00000000 | Version: 0x00001002 > [159525.256277] mmc1: sdhci: Blk size: 0x00000000 | Blk cnt: 0x00000000 > [159525.256523] mmc1: sdhci: Argument: 0x00000000 | Trn mode: 0x00000000 > [159525.256752] mmc1: sdhci: Present: 0x1fff0000 | Host ctl: 0x00000000 > [159525.256979] mmc1: sdhci: Power: 0x0000000b | Blk gap: 0x00000080 > [159525.257205] mmc1: sdhci: Wake-up: 0x00000000 | Clock: 0x0000fa03 > > Case 2. Reset timeout: (the same check window in sdhci_reset()) > [ 7639.968613] mmc1: Reset 0x4 never completed. > > Case 3. Hardware interrupt timeout > [ 1049.561728] mmc1: Timeout waiting for hardware interrupt. > >> >>> >>> Also the sdhci_send_command commands is not in spin lock There is a >>> windows between mod_timer and real command send... >> >> What code path does not have a spin lock? > Ouch my bad, the sdhci_send_command are called either from spinlock or IRQ handler, > so this part is good ... > > I'll send a new patch to cover case 1 and case 2 if you agree. Please do the mod_timer case also, but please make it a separate patch. Prior to v4.18 it was essentially a 10-second timer, without a preemptible gap afterwards, so extremely unlikely to timeout prematurely, hence: Fixes: fc1fa1b7db275 ("mmc: sdhci: Program a relatively accurate SW timeout value") Cc: stable@vger.kernel.org # v4.18+