Received: by 10.213.65.68 with SMTP id h4csp1985898imn; Thu, 5 Apr 2018 07:10:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/o2hDyDekr83gBnyDyqg6Rq8udc5AYVNB3LRdK7Kxhg2c3hBIVnGBv9kFm5kAghuJvlBSE X-Received: by 10.99.109.75 with SMTP id i72mr14877061pgc.403.1522937416325; Thu, 05 Apr 2018 07:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522937416; cv=none; d=google.com; s=arc-20160816; b=J83qpUahDJj3yRTKv8zN0My+JqRLyVhJWlOjuYh1CJBju3wCdlhS5i1jVbfUx5qJIs oz4ckVL8M43ofUXrCYQOMqdyHjfUgQ1dTGtjUwDupsk1vleFSp89iOVU+WxJnMlUAdQf i8AVe6UgEb/94ce/s6mYe3FGkV1N4EXlf6H//89PcoQy1XSN3tM4kPlU6qPGfMNl1b90 DbRZOIJZjOVsZStvTuGzGOYVYZ+6sVk6eFHWCfZAIvHuhGe0x7H3cjMUDUA8G6oqQaSO c/vapmaWHbQ5N3DgRkF06XkO8uwskOsdnAw594sc/ALjCl48DekYawtzNHjimIEJLYQ3 QnHA== 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:references:cc:to:from:subject:arc-authentication-results; bh=ZAcE0F/ZNITxM2KlqJRbTOcPT5FDaLs/En+L+kg0YrY=; b=zWTQV0Fvi57QQ7R7QuHYGPsePxsaOCAXgjXLm1GNKkt1fFm6Arg2LAw7sc+jJHOYfc VOEXjhhXnYo35jef/vIpzquQ+Xpctmjd0VkWglk2hsftuDqN4b4j9NaJ1gmK5FvoDpML yJmSPzXIEqvrL38hxupr6D5D1UtSosklKcbPfbMakwFU6DDp/yMdNj2MwoKnmF9CAkop uLODCzCD5E6NZSYpat93Jn9Q+w6nc3Yj+epxxikxOa30+5dXOfODlI3zn92JRiX1hf/C wT2fJeutRFREdn/GKJ/lzb6QoKWVq1KovEkvik0NEx85hh2X5qj9aQoby4YNXRWqdiX0 2wPA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si5986525plk.702.2018.04.05.07.10.01; Thu, 05 Apr 2018 07:10:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbeDEOI3 (ORCPT + 99 others); Thu, 5 Apr 2018 10:08:29 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54794 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeDEOI1 (ORCPT ); Thu, 5 Apr 2018 10:08:27 -0400 Received: by mail-wm0-f67.google.com with SMTP id r191so6037266wmg.4 for ; Thu, 05 Apr 2018 07:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZAcE0F/ZNITxM2KlqJRbTOcPT5FDaLs/En+L+kg0YrY=; b=TeQqsq64T2EtAVfJnWR/EaqIP2PEEURnbHBWjKbURhEnJAnvTVY5Nep5SlSCLwHGVr zZ1IKhz6XjIXEtzAQBF6X4bf6Fuwz1jbTK8G8Yj3GlpWqrOV2L3bmjAYt7feSBy+FNes voAdwzdGwg1Pgh7dbFmWvNMOVeWsAHU56UqsaZgTGsKODOdTlo1zTnDAKAisZljZGQZ2 TI6wCj8IbM+PoJgK3sHNDuJ/udaKzufioXCNiniQm2Vn9XfTuyGRTSJiHMffqjoDfT9u ivY1PIRnPtVfDRCVSFnrDHwFhIiR2pxB7ja5lkm/SU5Iy6p/T3Bv/XjH1sseTg7ZsTax miMw== X-Gm-Message-State: ALQs6tCUogOeQ+U0Mv+tPk0dtNMGsTrAEmqoR3rrgaa9OI9qeR0HX/U8 4RBSjHSKM1NtcT+Jlge4z8//JQ== X-Received: by 10.80.241.154 with SMTP id x26mr3122140edl.59.1522937306115; Thu, 05 Apr 2018 07:08:26 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id o3sm4800761edi.24.2018.04.05.07.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 07:08:25 -0700 (PDT) Subject: Re: [PATCH] ata: ahci-platform: add reset control support From: Hans de Goede To: Thierry Reding Cc: Patrice CHOTARD , Kunihiko Hayashi , 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" References: <1521768653-11824-1-git-send-email-hayashi.kunihiko@socionext.com> <20180405095429.GA7506@ulmo> <1f7d0738-1963-21c5-c293-e46fb0214ecf@redhat.com> <20180405135435.GA10860@ulmo> <6ce60a0b-0409-016a-d29c-91b8b9e2ad07@redhat.com> Message-ID: Date: Thu, 5 Apr 2018 16:08:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <6ce60a0b-0409-016a-d29c-91b8b9e2ad07@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Hans