Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4552334ybz; Tue, 21 Apr 2020 02:41:03 -0700 (PDT) X-Google-Smtp-Source: APiQypK5n8JD1bWs6lAT+r5Dl1tlIKqdL2dxjREUjZuuRDvpvv8Bjcw//IlnkGLsRNbfgi0CI+iL X-Received: by 2002:aa7:c3cb:: with SMTP id l11mr17314043edr.129.1587462063359; Tue, 21 Apr 2020 02:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587462063; cv=none; d=google.com; s=arc-20160816; b=MD9qGWMQ9+Tha7DUEbxU7Qz89ZnQA89JnRU1h5QAYhcMI3zCsCQrIBSVFq9gM61Npe TeP6CT1zbH/yrKownohbdncfu3PTGuBo24akXyU7UysHQ8PtFSAmny9jLGBtdtZfFlJv bUvGy+oWEeuxlheK8qDPNxo/ANYTWJ0e3TTpSSWUUkqf337l9MY0EIcFSGtCQxZgHnJk 929/N7Uzx2kl0KOGFet+uui3YweCboCpH3EV74Ghws7opZsSH8PdMCVr2sKdpxRBXdRT l3n7GVTV9zzT4wJLqixESR7XmC7yKCOGc4yKNmENgxlhGWSazzuMI7BplOWu/CqAvcYa pi7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J6xX4UX3gD4CgRlcECeL2t8r4Bb9qOAjl08Y9GivdCk=; b=QzwgQkSd8cbk7fOKxUqo83B83MTboOZBC1mxDONR8y0PPuqxcDBSEcJGXlga0DpY9T Sw1L4UmH4N9+mDF+nz0WywRhpo0Ongsbceq9g9cSGvlhA+A4o8RezLHmSHArC7TZUX2U ECn6xoUgRo0EddBe6NbOWbd6G2oyKOVll/LzspnS93GVW5uVyqGpkF7ANDMjrL0HYxVJ qtuxQYZmcsMsrZUJYmsmAdlS6rZMxar4cEXergqZO5RkKuRSOD/txBIM0DDslun6eqRe zbzh/QZG/zUzRXYSmiEv+nymF5ONQkH8L8FZbwoJtULG1IgoVK4ILpWOHQ1j6EfmQCK/ spJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wNADBHYf; 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 d1si1184947edr.360.2020.04.21.02.40.40; Tue, 21 Apr 2020 02:41:03 -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=wNADBHYf; 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 S1728285AbgDUJj0 (ORCPT + 99 others); Tue, 21 Apr 2020 05:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726403AbgDUJjZ (ORCPT ); Tue, 21 Apr 2020 05:39:25 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 036F1C061A41 for ; Tue, 21 Apr 2020 02:39:24 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id h200so3433702vke.3 for ; Tue, 21 Apr 2020 02:39:23 -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=J6xX4UX3gD4CgRlcECeL2t8r4Bb9qOAjl08Y9GivdCk=; b=wNADBHYfBqrmYLagYMXhvkFyUT8BxHFDmwzkIw/FRVt1EftHXgipIT5yJYjq9ocehu GrZB6OVK67pjdwBAL3ZpBnNYXCYFWesoXkeoHo0e+Ys2ree61WWYf4q1s6aM2pRu8zzE AejCt13Zo1guyVsMD5GmA9rvmocxaeUAi4sNkPEfOLyZk1Y2qbJjkD6tKDgzsKIF5CWZ bLLAKSp0UWZJvyvTPaV6DLqfwXjGE7lCNhM1KyduORgSrcceVXJfhY1vVq4+4BSaq4zN YVaXK4yTyH5sWOKbHxJKYqWhedO0PsZU5jTNO2D9GxGo88EZ/BqFQXR4VHF3pC6Bn3an zNPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J6xX4UX3gD4CgRlcECeL2t8r4Bb9qOAjl08Y9GivdCk=; b=nIIGd6oMf9H95fIrX1AWDOVqjiP5DLKOtVApJTRrXIjcwPNPxjyNnXxY7fEyHWLzQv hBVuMYDAGLbGUE6SaEIIC388ungmTvhe2sMJfMCk1P6uezM37qixRTrWajj5AydXiiwm p8YQbRDEmJPXLfjlHNKNZ/90fINbve78NsZF88bD2+LQQExHP/TGg0GVvmZPsA8W95nQ xlRnQcyRWG9juSpcLKUJg7a6XxmYDsIOUHKmTEbMcuBIShv3X866tOvCILpNkUGgFnq0 wjTdceHPxsqb3UmZE7XF28vsrDUKl/d879VXJtByFYoc//lw55pzCYjhNu48gnfnxfjw pIjg== X-Gm-Message-State: AGi0PubKgk3I4SlbmTSY3/3urnRZuol0qRrN0ZjnYlUoEs4YqO/w9jEQ ZEjbmIAyaEkwEUAdk3stSkt54QGhR75RW/keTpiqTcxfI84= X-Received: by 2002:a1f:31cf:: with SMTP id x198mr4295427vkx.101.1587461963161; Tue, 21 Apr 2020 02:39:23 -0700 (PDT) MIME-Version: 1.0 References: <20200420161831.5043-1-ludovic.barre@st.com> In-Reply-To: From: Ulf Hansson Date: Tue, 21 Apr 2020 11:38:47 +0200 Message-ID: Subject: Re: [PATCH] mmc: mmci_sdmmc: fix power on issue due to pwr_reg initialization To: Ludovic Barre Cc: Rob Herring , Srini Kandagatla , Maxime Coquelin , Alexandre Torgue , Linux ARM , Linux Kernel Mailing List , DTML , "linux-mmc@vger.kernel.org" , linux-stm32@st-md-mailman.stormreply.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Apr 2020 at 11:25, Ulf Hansson wrote: > > On Mon, 20 Apr 2020 at 18:18, Ludovic Barre wrote: > > > > This patch fix a power-on issue, and avoid to retry the power sequence. > > > > In power off sequence: sdmmc must set pwr_reg in "power-cycle" state > > (value 0x2), to prevent the card from being supplied through the signal > > lines (all the lines are driven low). > > > > In power on sequence: when the power is stable, sdmmc must set pwr_reg > > in "power-off" state (value 0x0) to drive all signal to high before to > > set "power-on". > > Just a question to gain further understanding. > > Let's assume that the controller is a power-on state, because it's > been initialized by the boot loader. When the mmc core then starts the > power-on sequence (not doing a power-off first), would $subject patch > then cause the > MMCIPOWER to remain as is, or is it going to be overwritten? > > I am a little worried that we may start to rely on boot loader > conditions, which isn't really what we want either... > > > > > To avoid writing the same value to the power register several times, this > > register is cached by the pwr_reg variable. At probe pwr_reg is initialized > > to 0 by kzalloc of mmc_alloc_host. > > > > Like pwr_reg value is 0 at probing, the power on sequence fail because > > the "power-off" state is not writes (value 0x0) and the lines > > remain drive to low. > > > > This patch initializes "pwr_reg" variable with power register value. > > This it done in sdmmc variant init to not disturb default mmci behavior. > > > > Signed-off-by: Ludovic Barre > > Besides the comment, the code and the approach seems reasonable to me. Another related question. I just realized why you probably haven't set .pwrreg_nopower for the variant_stm32_sdmmc and variant_stm32_sdmmcv2. I guess it's because you need a slightly different way to restore the context of MMCIPOWER register at ->runtime_resume(), rather than just re-writing it with the saved register values. Is this something that you are looking into as well? [...] Kind regards Uffe