Received: by 10.213.65.68 with SMTP id h4csp450786imn; Fri, 6 Apr 2018 03:13:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx49T51IK9qbPB7NKdEl3xJQTj2iKMcRHBB71urGnurTGZ4cHIUkUkSyu5tc0PkNQ3o6fMeLn X-Received: by 2002:a17:902:b095:: with SMTP id p21-v6mr26358948plr.31.1523009622556; Fri, 06 Apr 2018 03:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523009622; cv=none; d=google.com; s=arc-20160816; b=ZNHsQ/7YGW+lvlbiHpHgegNDTbeyGYQ46+peYcGNFTYRe+v2yORaXL4+toNglucbqc 2c1o2B58mDNaP4dC+249C2fpXJRCq9nS5hKR9RwI1h3hX+oFWGpXUV+kPSOIJGWkADZ9 kuT7YaU/CJm1ezsKCHSlL5Gd6ed6Qsg2hDlJ59urS6nNT/S01LuTUz1jeno1OOMNNwo2 itWU/n8RiRJ0s1iycfU+EU+sOgw+QHeLRjI8iOJSVN4QMD7YJXx4dGhnkENh+BCnpaGQ 96AnsPhpDGQLPwuwLjJUy+mXpn5W9tFnJiO7MDe5TGMu2jGkljKHJQOlTcdYkJTE+uci /YFQ== 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=gD9YpsJEyH3gmEKIKXkuBhCijhgn+qmdymaXD61Bftg=; b=x/9wNnuAZkg/bGFnj5yBqHIVRlgP9L4RJvtfkCod0hwkwtlQ0oG6PoSOIMzHqLMIW4 sYH6wLTFGVlka8B+Qf7fy3iS/NA2lCEnH1CbtlHSSq8rr8hgyMLDedgqh7JqWrZZPy5J svl+SoiJaIbmbMV3rsv6s8ISKp8OpDdtIsrMTsg/m3u1fxiYhtrov0BRW2CA0zaedW/C s6LSDA9EG++TuQB28O/7i3F+VorfUQf/LFRkNg7pyOC8zCILHM/s2TQXz4nfOV3qlOBf K6eM0FqgIQ64sfp8O+NmkOjOCZlxbMePPnpaw7fd1FDeKg2RIn4hK5Vu30mqgtEyoWrn 07RA== 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 b9si4339232pgw.657.2018.04.06.03.13.28; Fri, 06 Apr 2018 03:13:42 -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 S1752129AbeDFKMR (ORCPT + 99 others); Fri, 6 Apr 2018 06:12:17 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52973 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034AbeDFKMO (ORCPT ); Fri, 6 Apr 2018 06:12:14 -0400 Received: by mail-wm0-f67.google.com with SMTP id g8so2314471wmd.2 for ; Fri, 06 Apr 2018 03:12:13 -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=gD9YpsJEyH3gmEKIKXkuBhCijhgn+qmdymaXD61Bftg=; b=JAn25TN/4nVUKlobHhJhJwSByQV8K47o9GlnqWAVrFUzhpC8kwuOmufpL4HsqUrY/4 RvoZdXAwdwMYt+LlFu/hL0FRcW7FwF6XLFVevW/+okpPQZFd5ZbvRn53xU1YUrFuvWfj 8ZRECVPwh+Czke4otdFwLQQ8iXCokpYjbHqu6EqS1+WdC1xab3EP23QDhLBwRmJiFgNr mHOL6+YMAvn4T/VdeI+jB+d5tAXfaRtYpsnedJDsCZfSeljmE3kMEj+8qIqYdZ83gbed rcslbzbSvHZODO1bzSvzLhZrQ3JpuDEmgiulzGW9hNKSiPR3tlCXiRb9PTj4mQuQ15oA 0+1g== X-Gm-Message-State: ALQs6tCOZehpNWzS6/44SLErA8SvDuUWq8cONn6VeEVybqmPHD2Ug2+h duDkD+5o10DRgCYG4TMEyJBq6A== X-Received: by 10.80.177.44 with SMTP id k41mr6341164edd.217.1523009532934; Fri, 06 Apr 2018 03:12:12 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id v15sm2602278eda.90.2018.04.06.03.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 03:12:12 -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: <20180406134838.2ADC.4A936039@socionext.com> <22a2bcd7-eff5-c20f-e056-f5946e579d5e@redhat.com> <20180406183623.CA38.4A936039@socionext.com> From: Hans de Goede Message-ID: <68d50624-d31b-09cf-210e-9fb7c73b5df0@redhat.com> Date: Fri, 6 Apr 2018 12:12:11 +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: <20180406183623.CA38.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 11:36, Kunihiko Hayashi wrote: > Hi Hans, > > On Fri, 6 Apr 2018 10:29:37 +0200 > Hans de Goede wrote: > >> 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. > > Indeed. This is more flexible to add another resources. > > Although I'm about to prepare the candidate patch to fix this issue, > I think we need to revert the previous patch first if some SoCs have > issues because of it. Ack. It is probably best if you do a "git revert f0f56716fc3e5d547fd7811eb218a30ed0695605" on a tree with that commit and then send a patch to Tejun for this. Regards, Hans