Received: by 10.213.65.68 with SMTP id h4csp216527imn; Thu, 5 Apr 2018 21:54:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+bvQ5nVdL5CVE5UcNd4cd0J7xUjKIibiWhcydLNGS9cERjyuZnUKW4IBJb7c0SsXrTVk6p X-Received: by 10.98.62.150 with SMTP id y22mr18307755pfj.46.1522990493485; Thu, 05 Apr 2018 21:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522990493; cv=none; d=google.com; s=arc-20160816; b=QFvy8SXTeunD+vwnmK5B2DHqe++Jgw7Wuy43XiuWCBShwBev2jaoJ4AiW2xhTxbsRN b+SQ4pHaBw+mJmxs3ECAR13gd1P+FnsfQ8StvhzXObZzEO2N3+vVaxfSR2C8qdXYeprz muIyW1htUrGQt2tEXgCl2UWLFqwAdpkH6T4T+CJBfZPwcAKigS5fBLcr2TH4e8qXdTZ8 wSqkyGxzUfTvr/qU6EmXyVH5e9mwCfEN4rs84kS6kIisgRORi7ia2hdxgGz8heNva4ZC qL0Rx5syGMAwpXTlZ4cGMRRFM0SqDn+9w6VWHlxC2D6uP9VpuzqJ3xW7Ho3nCx3ol2gZ Zqxw== 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:mime-version :message-id:references:in-reply-to:cc:subject:to:from:date :arc-authentication-results; bh=4DPquR3lTEGrGaDQcd/e8RewVPK25ZYNal7TZDTQGpA=; b=LZVRc5NpGsOlDu36rzJquB9N90QOp00n3Imf3D3zhhB9SjNVBzWsPyJMtqqV3nGu4N uVO56DNZb+hutUGJtf+HUIxE/PUmWvtBlyy/5G1DuZYQggvB/dtnTvK1Hp4WnqAAWxcd xqQIgg/5Phk+Gbb+DWQY5P9TkJASOwzeuFhL0kGUN77N1FjapJZsgqoDrJtZCYfXxUQg KNIVgIGidaC6h5B/JGZbsYK9DboPx7oSQ9t19KiYAU39hZFvGUd9WPZlmRyl9LD3ojW3 cwZ9SR92wUnMtuNakLLSY/KWmi+ep3dNw2FdH1eDpeu7Zdrutv2Cg632Qag0IQRh0fMo Rqqg== 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 p3si6627933pgr.782.2018.04.05.21.54.39; Thu, 05 Apr 2018 21:54:53 -0700 (PDT) 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 S1752664AbeDFEsn (ORCPT + 99 others); Fri, 6 Apr 2018 00:48:43 -0400 Received: from mx.socionext.com ([202.248.49.38]:27012 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751447AbeDFEsl (ORCPT ); Fri, 6 Apr 2018 00:48:41 -0400 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 06 Apr 2018 13:48:40 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 3AAF9180237; Fri, 6 Apr 2018 13:48:40 +0900 (JST) Received: from 172.31.9.53 (172.31.9.53) by m-FILTER with ESMTP; Fri, 6 Apr 2018 13:48:40 +0900 Received: from yuzu.css.socionext.com (yuzu [172.31.8.45]) by iyokan.css.socionext.com (Postfix) with ESMTP id EDFCA403C1; Fri, 6 Apr 2018 13:48:39 +0900 (JST) Received: from [127.0.0.1] (unknown [10.213.134.37]) by yuzu.css.socionext.com (Postfix) with ESMTP id B16621207CC; Fri, 6 Apr 2018 13:48:39 +0900 (JST) Date: Fri, 06 Apr 2018 13:48:39 +0900 From: Kunihiko Hayashi To: Hans de Goede Subject: Re: [PATCH] ata: ahci-platform: add reset control support Cc: Thierry Reding , Patrice CHOTARD , Tejun Heo , Matthias Brugger , Rob Herring , Mark Rutland , "linux-ide@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" In-Reply-To: References: <6ce60a0b-0409-016a-d29c-91b8b9e2ad07@redhat.com> Message-Id: <20180406134838.2ADC.4A936039@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.70 [ja] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hans, On Thu, 5 Apr 2018 16:08:24 +0200 Hans de Goede wrote: > Hi, > > On 05-04-18 16:00, Hans de Goede wrote: > > Hi, > > > On 05-04-18 15:54, Thierry Reding wrote: > >> On Thu, Apr 05, 2018 at 03:27:03PM +0200, Hans de Goede wrote: > >>> Hi, > >>> > >>> On 05-04-18 15:17, Patrice CHOTARD wrote: > >>>> Hi Thierry > >>>> > >>>> On 04/05/2018 11:54 AM, Thierry Reding wrote: > >>>>> On Fri, Mar 23, 2018 at 10:30:53AM +0900, Kunihiko Hayashi wrote: > >>>>>> Add support to get and control a list of resets for the device > >>>>>> as optional and shared. These resets must be kept de-asserted until > >>>>>> the device is enabled. > >>>>>> > >>>>>> This is specified as shared because some SoCs like UniPhier series > >>>>>> have common reset controls with all ahci controller instances. > >>>>>> > >>>>>> Signed-off-by: Kunihiko Hayashi > >>>>>> --- > >>>>>> ??? .../devicetree/bindings/ata/ahci-platform.txt????? |? 1 + > >>>>>> ??? drivers/ata/ahci.h???????????????????????????????? |? 1 + > >>>>>> ??? drivers/ata/libahci_platform.c???????????????????? | 24 +++++++++++++++++++--- > >>>>>> ??? 3 files changed, 23 insertions(+), 3 deletions(-) > >>>>> > >>>>> This causes a regression on Tegra because we explicitly request the > >>>>> resets after the call to ahci_platform_get_resources(). > >>>> > >>>> I confirm, we got exactly the same behavior on STi platform. > >>>> > >>>>> > >>>>> ?? From a quick look, ahci_mtk and ahci_st are in the same boat, adding the > >>>>> corresponding maintainers to Cc. > >>>>> > >>>>> Patrice, Matthias: does SATA still work for you after this patch? This > >>>>> has been in linux-next since next-20180327. > >>>> > >>>> SATA is still working after this patch, but a kernel warning is > >>>> triggered due to the fact that resets are both requested by > >>>> libahci_platform and by ahci_st driver. > >>> > >>> So in your case you might be able to remove the reset handling > >>> from the ahci_st driver and rely on the new libahci_platform > >>> handling instead? If that works that seems like a win to me. > >>> > >>> As said elsewhere in this thread I think it makes sense to keep (or re-add > >>> after a revert) the libahci_platform reset code, but make it conditional > >>> on a flag passed to ahci_platform_get_resources(). This way we get > >>> the shared code for most cases and platforms which need special handling > >>> can opt-out. > >> > >> Agreed, although I prefer such helpers to be opt-in, rather than > >> opt-out. In my experience that tends make the helpers more resilient to > >> this kind of regression. It also simplifies things because instead of > >> drivers saying "I want all the helpers except this one and that one", > >> they can simply say "I want these helpers and that one". In the former > >> case whenever you add some new (opt-out) feature, you have to update all > >> drivers and add the exception. In the latter you only need to extend the > >> drivers that want to make use of the new helper. > > Erm, the idea never was to make this opt-out but rather opt in, so > we add a flags parameter to ahci_platform_get_resources() and all > current users pass in 0 for that to keep the current behavior. > > And only the generic drivers/ata/ahci_platform.c driver will pass > in a the new AHCI_PLATFORM_GET_RESETS flag, which makes > ahci_platform_get_resources() (and the other functions) also deal > with resets. > > >> With that in mind, rather than adding a flag to the > >> ahci_platform_get_resources() function, it might be more flexible to > >> split the helpers into finer-grained functions. That way drivers can > >> pick whatever functionality they want from the helpers. > > > Good point, so lets: > > > 1) Revert the patch for now > > 2) Have a new version of the patch which adds a ahci_platform_get_resets() helper > > 3) Modify the generic drivers/ata/ahci_platform.c driver to call the new > > ?? ahci_platform_get_resets() between its ahci_platform_get_resources() > > ?? and ahci_platform_enable_resources() calls. > > ?? I think that ahci_platform_enable_resources() should still automatically > > ?? do the right thing wrt resets if ahci_platform_get_resets() was called > > ?? (otherwise the resets array will be empty and should be skipped) > > > This should make the generic driver usable for the UniPhier SoCs and > > maybe some other drivers like the ahci_st driver can also switch to the > > new ahci_platform_get_resets() functionality to reduce their code a bit. > > So thinking slightly longer about this, with the opt-in variant > (which is what I intended all along) I do think that a flags parameter > is better, because the whole idea behind lib_ahci_platform is to avoid > having to do err = get_resource_a(), if (err) bail, err = get_resource_b() > if (err) bail, etc. in all the ahci (platform) drivers. And having fine > grained helpers re-introduces that. In case of adding a flag instead of get_resource_a(), for example, we add the flag for use of resets, -struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) +struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, + bool use_reset) and for now all the drivers using this function need to add the argument as false to the caller. - hpriv = ahci_platform_get_resources(pdev); + hpriv = ahci_platform_get_resources(pdev, false); Surely this can avoid adding functions such get_resource_a(). If we apply another feature later, we add its flag as one of the arguments instead. Is it right? Thank you, --- Best Regards, Kunihiko Hayashi