Received: by 10.213.65.68 with SMTP id h4csp374354imn; Fri, 6 Apr 2018 01:31:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx484pHkIa20A7yeBVKxckadcbGsJ3adBkiMo9ObnqHPCu4kHs4ZA2CBc/jC60r2b7Q8bkwk1 X-Received: by 10.98.210.7 with SMTP id c7mr19566635pfg.92.1523003470822; Fri, 06 Apr 2018 01:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523003470; cv=none; d=google.com; s=arc-20160816; b=kMrJL8VbD0ponmD24jDSIy36qrSy8BClfRg9JVokDvUZ1NSxPgn9XJGM2pkdFt+fTN cXYy/cGiLJuE+EwBuJfaEM8QT65+my2m1KigAEpv9150aFD+MVdr4MqulIoaHV76ZGdW r9ki425ssl5ITvuxNxz86Vc/TsuVu04Sp5a0q8Q3rZi+fm4jh3wjW4gkSIJgSr+kipRP vQa0l5HD4dSih8O7onhykwAmWm0TX5s1YOEWHEvnr74Gl2Xui7yYQ0kXSxD54d6SfP9w dbT178z/gEEsuOHPb9NaEVsXMjLR+r7QzUOynlFpnnYA/J91w8ZSgDJdXA9NOQE+Whwq AsCw== 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:from:references:cc:to:subject:arc-authentication-results; bh=iwCd/A0vFRIAumNJicQVa8LRGprK6YavTdhPZYuIG/E=; b=rHHUm07lHHLg7IVgbylebTMkqKAJBiciJbl2c48NCVtQcUecOc21RqBD4SVq3GBwkd gHz9cKygPxrUA2S+X/CagQSmO21xdvue3flybZcOp9HrMj3qnXilJc9b9V+Zz09WKJ6U iMg0RsvA8A9jWQqRtsaa/LIPdxGN5hufs2gkvrDG7+D9f8kHPdqpV+wtCq0uZ+BVV0GN GGKDx8TpxFxv1LSbqzLgfi+caGjQuLv/jL97JGiJvZn8EkaGq8X7hMr/wu+QsByYmZIU SePIH6GwvbH0KC533tJC/nDoZLiTYrdXMYjIOOPp9eQ1yxqfPj2U7KkLKBs7g6neo/uZ eAog== 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 o19si4450751pgn.197.2018.04.06.01.30.55; Fri, 06 Apr 2018 01:31:10 -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 S1751573AbeDFI3o (ORCPT + 99 others); Fri, 6 Apr 2018 04:29:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52366 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751442AbeDFI3k (ORCPT ); Fri, 6 Apr 2018 04:29:40 -0400 Received: by mail-wm0-f68.google.com with SMTP id g8so1530438wmd.2 for ; Fri, 06 Apr 2018 01:29:39 -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:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iwCd/A0vFRIAumNJicQVa8LRGprK6YavTdhPZYuIG/E=; b=hqI7UTFyOhIRkE0nvgJRR+ORhUBhgSO4MgavM0pKpa1zJQgl5tlh7UzZIj6soqCUYi V+7FJpSLh01Uf2667QtFvRzJa/jSkUWS5fw1MiSR3mZvcjlMBxa6Ve404YO6pfdaTG90 HKZKrztLGyG6WKZaO11uy7iUD4SgL1mzxvnELLNbEoxvGuvuKiJsL4L+Vy5cqvU/h9ZS JKpqauRbv3XEHg3O4udy3PlUV+1kh2zg+/QIwsdyiCAp0OAy7Eq5rMKSfr22tfKYi2Ro Dd0DmD+d4/tWJ/VFiLQp2k+cSMyS6Sojc8GUyfPv7FyXo50Rq9Y1K20vbSYfM/1DiuSg jmQw== X-Gm-Message-State: ALQs6tBVnPDh/lRiuzXmN6GhABjdct1+t4DZppCoK4euDahSKQntLCfo JAANF0jRJb4fKAPmfvrY6DUldg== X-Received: by 10.80.135.233 with SMTP id 38mr6070208edz.8.1523003378869; Fri, 06 Apr 2018 01:29:38 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id b8sm5565418edi.14.2018.04.06.01.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 01:29:38 -0700 (PDT) Subject: Re: [PATCH] ata: ahci-platform: add reset control support To: Kunihiko Hayashi 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" References: <6ce60a0b-0409-016a-d29c-91b8b9e2ad07@redhat.com> <20180406134838.2ADC.4A936039@socionext.com> From: Hans de Goede Message-ID: <22a2bcd7-eff5-c20f-e056-f5946e579d5e@redhat.com> Date: Fri, 6 Apr 2018 10:29:37 +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: <20180406134838.2ADC.4A936039@socionext.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 06-04-18 06:48, Kunihiko Hayashi wrote: > 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? Yes, that is right, but instead of adding a "bool use_reset" please add an "unsigned int flags" parameter instead and a: #define AHCI_PLATFORM_GET_RESETS 0x01 And update all callers of ahci_platform_get_resources to pass 0 for flags except for drivers/ata/ahci_platform.c. This way we only need to modify all callers once, and if we want to add another optional resource in the future we can add a: #define AHCI_PLATFORM_GET_FOO 0x02 Without needing to change all callers again. Regards, Hans