Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2189097iof; Tue, 7 Jun 2022 22:38:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0GciVTzX3LZelNJ3EY+IhCP+satXVyQ7xA/M9gzMpGTUy0LSkokuV0ehNrNWypJ6aZNsJ X-Received: by 2002:a17:90b:3b83:b0:1e8:77b9:f78c with SMTP id pc3-20020a17090b3b8300b001e877b9f78cmr17163741pjb.61.1654666683427; Tue, 07 Jun 2022 22:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666683; cv=none; d=google.com; s=arc-20160816; b=PANLe7+yqvkFPAuBCUmSB66ODNOng0Pg57G9ptru3z7hiDDT8hCh8GK0MKgifMWG7V llWbt9DLIgxv9IEOcmFcrROi8GCjosfuYNy5tlU8OkP1GZvKGK95JuS8hn3KqxhCH4i6 SzB2YuZwUyAFWNFSVw5Fgr0+Tl+gYRgzkc9uf1huL/ADN6CCWQf/3KyD2OsfAn2N/Ie/ vs+RzIiSEc924/rwyKdPOVWUJCE7EsPMPXr1uT65z+m6qtZT2LfjW0ruuBNN21WebuHW DwwzayFBIqgKKNrPp0ZD6JSX9rj475xWB0sis8UWg2tKzzVdeDe4ewPG/aNL34tWtIA7 9/DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=aO/lSvFaLajkL7Ac/IqTCOTSOPQr+6oNuobROU/TF8k=; b=CUYzPshxYSTEsYorrTl6o0X0wksbZeSgbn3a4wRZc5AZTT00CvbEccGFrEGFj95QUC pJ8hGseoANoepfPmYY0xBXS9D4/rHFlcRDvaueGxWCletk1XRHwPN/+HL6O3ygh7mudq SFoChXJC9a4BJLtXHV4tdLdw29eFopLW+7G32FD5s8V6YRc7uE1cin7M+eJ4Jzb97HrC RhXQavvQ0a9Fl92t1ft0SWtYHBbpp90Kx8bFFV1OsfjFVwajiNjRJzICNLhe6dhtcw8H ZWWbF76g9vWv1yOFSXLNW8N+Bdx4KZBVgmwfUml8LYyS7F9fbNvugGxVzbpG2tefSGvi onUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=plZ0JtxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j12-20020a170903028c00b00161ed8630e1si25872860plr.158.2022.06.07.22.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:38:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=plZ0JtxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1326345E707; Tue, 7 Jun 2022 22:04:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242526AbiFGLI0 (ORCPT + 99 others); Tue, 7 Jun 2022 07:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242504AbiFGLID (ORCPT ); Tue, 7 Jun 2022 07:08:03 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6807C104CA6 for ; Tue, 7 Jun 2022 04:04:09 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id y32so27727567lfa.6 for ; Tue, 07 Jun 2022 04:04:09 -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:content-transfer-encoding; bh=aO/lSvFaLajkL7Ac/IqTCOTSOPQr+6oNuobROU/TF8k=; b=plZ0JtxWk2Nc24B6pQU1IdzZ7fMFVakDlxjXm1dhZfOhbMC11ALQejl6bnQ4uXxFQq CiRvRizUUB6Q6XOYtz7/pBHYG3DyAdJKKaej8Ki2oFk96Vg4LC8B5NRrQbwIGp50BvQq PCPkamJ/f1O0MGhS4o5loFLInz8co4ctI11OggzRThUimjtNATTeEVur3srhTyvR5aNE UkIncS+2ZcyEDZIzLq6wIxUJfD2flK51qsJ0r3PzGh7yV5Z8nN7KJJePQsOOybCwmYLW GsUb+yluSCn1dtqSGUZvDycBaNNTBCK3iNAg6a5K1Vnz4JR2nK3FrJo1qP6RE2P0bOpK w+Sw== 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:content-transfer-encoding; bh=aO/lSvFaLajkL7Ac/IqTCOTSOPQr+6oNuobROU/TF8k=; b=C+O8PFVGSX/dfg6U1XyTp7XyIl3Om9MErcFwYr4EuTgq4f0Xix6m+62M7Le2zgc51f 8yksi/M9DvehHPD9deMDbGxGXtlJuoW/Z32rz8g4YO27mmeMSr+wmFOvBogqX52Z1/jl S5b8+I4XCsahuQPw1C8X0UoezoThFynDFbsrwJSQSF2nYRqnwfY6MIHufpWLgbtePyL7 5G2Ct8N0dulIMS8qWp3mBCEadmfcPSkeBNUuKVhyzOm/zMHI88MH1l6ssj3CeER3p+T7 zRiNel40sJEIFmie79SxjyDcDCGJ3QqSXUOHnQVtuxe4YIu7CCv1eyD3d8lCt7wMv2Jq SxuQ== X-Gm-Message-State: AOAM5309LH+0/9Gm+Yi1WNnMk1h4c+w9zxixAjhVB2qtLWKaiNNRlh7L w5EdOwizN3qZdlIfVlCFRdanT0H5pKk1Dnqr4h8rqg== X-Received: by 2002:a19:ac42:0:b0:478:593c:e6fe with SMTP id r2-20020a19ac42000000b00478593ce6femr17856420lfc.254.1654599847422; Tue, 07 Jun 2022 04:04:07 -0700 (PDT) MIME-Version: 1.0 References: <55A0788B-03E8-457E-B093-40FD93F1B9F3@goldelico.com> In-Reply-To: From: Ulf Hansson Date: Tue, 7 Jun 2022 13:03:30 +0200 Message-ID: Subject: Re: BUG in mmc: core: Disable card detect during shutdown To: "H. Nikolaus Schaller" Cc: Discussions about the Letux Kernel , kernel@pyra-handheld.com, aTc , Tony Lindgren , linux-omap , linux Kernel Mailing List , linux-mmc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 4 Jun 2022 at 12:16, H. Nikolaus Schaller wrote= : > > Hi, > > > Am 03.06.2022 um 12:46 schrieb Ulf Hansson : > > > > On Mon, 30 May 2022 at 18:55, H. Nikolaus Schaller = wrote: > >> > >> Hi Ulf, > >> users did report a strange issue that the OMAP5 based Pyra does not > >> shutdown if a kernel 5.10.116 is used. > >> > > ... > > >> mmc_stop_host() is not called but __mmc_stop_host() is called 4 times. > >> There are 4 active MMC interfaces in the Pyra - 3 for (=C2=B5)SD slots > >> and one for an SDIO WLAN module. > >> > >> Now it looks as if 3 of them are properly teared down (two of them > >> seem to have host->slot.cd_irq >=3D 0) but on the fourth call > >> cancel_delayed_work_sync(&host->detect); does not return. This is > >> likely the location of the stall why we don't see a "reboot: Power dow= n" > >> > >> Any ideas? > > > > I guess the call to cancel_delayed_work_sync() in __mmc_stop_host() > > hangs for one of the mmc hosts. This shouldn't happen - and indicates > > that there is something else being wrong. > > Yes, you were right... > > > > > See more suggestions below. > > > >> > >> BR and thanks, > >> Nikolaus > >> > >> printk hack: > >> > >> void __mmc_stop_host(struct mmc_host *host) > >> { > >> printk("%s 1\n", __func__); > >> if (host->slot.cd_irq >=3D 0) { > >> printk("%s 2\n", __func__); > >> mmc_gpio_set_cd_wake(host, false); > >> printk("%s 3\n", __func__); > >> disable_irq(host->slot.cd_irq); > >> printk("%s 4\n", __func__); > >> } > >> > >> host->rescan_disable =3D 1; > >> printk("%s 5\n", __func__); > > > > My guess is that it's the same mmc host that causes the hang. I > > suggest you print the name of the host too, to verify that. Something > > along the lines of the below. > > > > printk("%s: %s 5\n", mmc_hostname(host), __func__); > > To my surprise, this did report an mmc6 host port where the OMAP5 only ha= s 4... > > Yes, we have a special driver for the txs02612 sdio switch and voltage tr= anslator > chip to make two ports out of the single mmc2 port of the OMAP5 SoC. > > This driver was begun ca. 7 years ago but never finished... > > The idea is to make a mmc port have several subports. For the Pyra handhe= ld hardware > we needed 5 mmc/sdio interfaces but the omap5 only has 4 of them availabl= e to us. > > So the txs02612 drivers is sitting between the omap5 mmc2 host pins and s= witches > between an =C2=B5SD slot and an eMMC. > > Therefore, the driver is a mmc client driver (like e.g. the driver of som= e WiFi chip > connected to some SDIO port) and provides multiple mmc host interfaces. > > It should intercept data transfer requests to its multiple mmc hosts, syn= chronize > (or enqueue) them, control the switch gpio and forward requests to the pr= ocessor's > mmc host port so that they are processed (after switching). > > We never continued to make this work... Well, I can imagine that it's just very difficult to make this work properl= y. Moreover, the mmc core and its block layer code isn't designed to support this type of configuration. For example, the I/O scheduling can't work with this setup. > > What remained is simple code to manually throw the switch through some /s= ysfs > control file after doing an eject and before a fresh partprobe. > > Still, the probe function of the txs02612 driver does two calls to mmc_ad= d_host(). > These seem to make > > > > >> cancel_delayed_work_sync(&host->detect); > > get stuck. Most likely because the initialization is not complete for han= dling > card detection. > > >> > >> --- here should be another __mmc_stop_host 6 > >> --- and reboot: Power down > > > > When/if you figured out that it's the same host that hangs, you could > > try to disable that host through the DTS files (add status =3D > > "disabled" in the device node, for example) - and see if that works. > > When not calling mmc_add_host() in our txs02612 driver fragment we can > properly shut down the OMAP5. That is the solution with the least efforts= . > The other would be to make the txs02612 properly work... > > So in summary there is no bug upstream. It is in our tree. Thanks for sharing the details. > > If you are interested in how our code fragment for the txs02612 looks lik= e: > > https://git.goldelico.com/?p=3Dletux-kernel.git;a=3Dshortlog;h=3Drefs/hea= ds/letux/txs02612 > > Maybe you have some suggestions to make it work? Sorry, but I have lots of things to do at this point, maybe some other time= . Kind regards Uffe