Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2050710imu; Sun, 18 Nov 2018 14:41:22 -0800 (PST) X-Google-Smtp-Source: AJdET5eLq6nq6VAOy84IojV3jHgrZQM2llYOX8n6ilO3KvtdnNWAG+X/Dv5ZhdzTgNFZHNJ3G94o X-Received: by 2002:a65:5a4c:: with SMTP id z12mr18007010pgs.188.1542580882088; Sun, 18 Nov 2018 14:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542580882; cv=none; d=google.com; s=arc-20160816; b=hICNrGFKGGzpbVZbssodls3hqFNQX609kgXm06xbjQcUisnCsGq/FKV4Lkfh1PmxWs zIZZzUaH6BzWbt5nLNIOJM3oOuGMxcssg9QEjDMN8pnIHsYMLNuKeCTMEwMUcNj+1Sz+ yKd8FzVNbXEpf0oHo1nme8faD7AIFU35g28IT0XtAeNHf6Md8JZ3ALFOwlw+1D4SgNkW OdDoakAkRj5Jld+WyduQZuvdYEFwjjTuY9nYVfPPsqaFv6Bnp8oThmFX3nwTs8EXiymO p76cIjE9X4gRNWU3lTCjidkOGX3TxRQyQlqq4+XeNaJGx3uUuUzlWlAG2fdcPvPA3/UX IVEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=LUHMhtmeSmSQy/oFMBtDOVjheHiD/PN+6FV8R09IlHI=; b=i3uv0Ih59j2HZ/y9EpO1I2WNwKZkc2VUDHeACTlPiPg0PkTtUpkSeFjvisPamvPegf Qhivj1oKUPzzSibx9FC25X6hQj/8Vf6rKqo30nHpVSogIsIoPiKHvT/dNNl2ZS4e821t Ib1ZROLPtlzfJcIgJDKPfqqSRL8uaJHexG9O7JfLj2rC6+8PqS7VK3Kyv4GWvQsTAhsA tv+TiCetzqZOo4xUy9jJZ/qFWZA8MJxQVAbrEqGw8HWwUu96PZR79bfJeQtjNwf/lRgc 64DQKqHaNt42daZ4Q9zu4J5bIpZ9UA8tRWg2PB9uGKasSQlebcPfYe/S9Q0SVEa1D2gc 2BVw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si36405338pga.91.2018.11.18.14.40.58; Sun, 18 Nov 2018 14:41:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727739AbeKSIno (ORCPT + 99 others); Mon, 19 Nov 2018 03:43:44 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:34348 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbeKSIno (ORCPT ); Mon, 19 Nov 2018 03:43:44 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990875AbeKRWUrPUXCL (ORCPT + 2 others); Sun, 18 Nov 2018 23:20:47 +0100 Date: Sun, 18 Nov 2018 23:20:43 +0100 From: Ladislav Michl To: Aaro Koskinen Cc: Ulf Hansson , Tony Lindgren , linux-mmc@vger.kernel.org, Andrzej Zaborowski , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] MMC: OMAP: fix broken MMC on OMAP15XX/OMAP5912/OMAP310 Message-ID: <20181118222043.GA23485@lenoch> References: <20181118201919.14401-1-aaro.koskinen@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181118201919.14401-1-aaro.koskinen@iki.fi> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Aaro, On Sun, Nov 18, 2018 at 10:19:19PM +0200, Aaro Koskinen wrote: > Since v2.6.22 or so there has been reports [1] about OMAP MMC being > broken on OMAP15XX based hardware (OMAP5912 and OMAP310). The breakage > seems to have been caused by commit 46a6730e3ff9 ("mmc-omap: Fix > omap to use MMC_POWER_ON") that changed clock enabling to be done > on MMC_POWER_ON. This can happen multiple times in a row, and on 15XX > the hardware doesn't seem to like it and the MMC just stops responding. > Fix by memorizing the power mode and do the init only when necessary. I'm going to use this patch as an argument against anybody complaining kernel bugs do not get fixed. People just need to teach themselves to be patient. Tested-by: Ladislav Michl > Before the patch (on Palm TE): > > mmc0: new SD card at address b368 > mmcblk0: mmc0:b368 SDC 977 MiB > mmci-omap mmci-omap.0: command timeout (CMD18) > mmci-omap mmci-omap.0: command timeout (CMD13) > mmci-omap mmci-omap.0: command timeout (CMD13) > mmci-omap mmci-omap.0: command timeout (CMD12) [x 6] > mmci-omap mmci-omap.0: command timeout (CMD13) [x 6] > mmcblk0: error -110 requesting status > mmci-omap mmci-omap.0: command timeout (CMD8) > mmci-omap mmci-omap.0: command timeout (CMD18) > mmci-omap mmci-omap.0: command timeout (CMD13) > mmci-omap mmci-omap.0: command timeout (CMD13) > mmci-omap mmci-omap.0: command timeout (CMD12) [x 6] > mmci-omap mmci-omap.0: command timeout (CMD13) [x 6] > mmcblk0: error -110 requesting status > mmcblk0: recovery failed! > print_req_error: I/O error, dev mmcblk0, sector 0 > Buffer I/O error on dev mmcblk0, logical block 0, async page read > mmcblk0: unable to read partition table > > After the patch: > > mmc0: new SD card at address b368 > mmcblk0: mmc0:b368 SDC 977 MiB > mmcblk0: p1 > > The patch is based on a fix and analysis done by Ladislav Michl. > > Tested on OMAP15XX/OMAP310 (Palm TE), OMAP1710 (Nokia 770) > and OMAP2420 (Nokia N810). > > [1] https://marc.info/?t=123175197000003&r=1&w=2 > > Fixes: 46a6730e3ff9 ("mmc-omap: Fix omap to use MMC_POWER_ON") > Reported-by: Ladislav Michl > Reported-by: Andrzej Zaborowski > Signed-off-by: Aaro Koskinen > --- > drivers/mmc/host/omap.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c > index adf32682f27a..c60a7625b1fa 100644 > --- a/drivers/mmc/host/omap.c > +++ b/drivers/mmc/host/omap.c > @@ -104,6 +104,7 @@ struct mmc_omap_slot { > unsigned int vdd; > u16 saved_con; > u16 bus_mode; > + u16 power_mode; > unsigned int fclk_freq; > > struct tasklet_struct cover_tasklet; > @@ -1157,7 +1158,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > struct mmc_omap_slot *slot = mmc_priv(mmc); > struct mmc_omap_host *host = slot->host; > int i, dsor; > - int clk_enabled; > + int clk_enabled, init_stream; > > mmc_omap_select_slot(slot, 0); > > @@ -1167,6 +1168,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > slot->vdd = ios->vdd; > > clk_enabled = 0; > + init_stream = 0; > switch (ios->power_mode) { > case MMC_POWER_OFF: > mmc_omap_set_power(slot, 0, ios->vdd); > @@ -1174,13 +1176,17 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > case MMC_POWER_UP: > /* Cannot touch dsor yet, just power up MMC */ > mmc_omap_set_power(slot, 1, ios->vdd); > + slot->power_mode = ios->power_mode; > goto exit; > case MMC_POWER_ON: > mmc_omap_fclk_enable(host, 1); > clk_enabled = 1; > dsor |= 1 << 11; > + if (slot->power_mode != MMC_POWER_ON) > + init_stream = 1; > break; > } > + slot->power_mode = ios->power_mode; > > if (slot->bus_mode != ios->bus_mode) { > if (slot->pdata->set_bus_mode != NULL) > @@ -1196,7 +1202,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > for (i = 0; i < 2; i++) > OMAP_MMC_WRITE(host, CON, dsor); > slot->saved_con = dsor; > - if (ios->power_mode == MMC_POWER_ON) { > + if (init_stream) { > /* worst case at 400kHz, 80 cycles makes 200 microsecs */ > int usecs = 250; > > @@ -1234,6 +1240,7 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id) > slot->host = host; > slot->mmc = mmc; > slot->id = id; > + slot->power_mode = MMC_POWER_UNDEFINED; > slot->pdata = &host->pdata->slots[id]; > > host->slots[id] = slot; > -- > 2.17.0