Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp108935ybg; Mon, 8 Jun 2020 17:51:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL3z4HD8HIIIOHWtMr7TJsP80hFLdMMRMQTwvTYgjqNc46Xc8nIqiaELuJ3BKQbZBVybKe X-Received: by 2002:a50:f387:: with SMTP id g7mr25134246edm.185.1591663860392; Mon, 08 Jun 2020 17:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663860; cv=none; d=google.com; s=arc-20160816; b=sJxvQMoB96ux+emV2Hzo0UKT2CKPJHLA6ovLUqokmZED242wSMY3dcISij2fWDCo/S Gf9V3AO3Hjc4vOl0CtkPRyxLTdxATm9+u7pbl5SL0uG/68i78FIY7MmYVU9bYqXoUuEp gTvgWPPgDeqzoPO9V8pACiA+g4gc/3IVR/6B4//KWZez4Hgcr8dnTUehu8lL/QPkrSYw BCQ5apeMEenMnDWxpzVVqyWLkUMWB6jeL6AUgrOXgF261s63yftB8HzqGasdhndgtv3m et0KvarcRTCk/lWABnJKRGPWZIe4XT0dwX9Hx7jt7vVBelCTrN9bznPKMQgG5jMfmrRD k00Q== 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:dkim-signature; bh=J15eJufKdDHorGHaYKdBz4fOpJXaofZH0gLXbZy+af4=; b=QrapuWyMkieHHZCYS1NbNsuAEM3O3T630/lvKs28Um62i3P9DRoktgzFAvMhD72Gak gBZiTwc4Zlc1jYLjD+9+w8FZ705cNtWiVJHpxULCG6mE3z6Gc7jysY4lYL3bWF7Swz4I MzZITlb5yUvc6OLVP7O4djx+NZ8CXKhv1F/ML0t3X6Qn1LJnSneOQTWG3Ty5120YBz6W BKtPVPrnPuR5FHrjowTAG0y9jBb/FrdQ7uw2ykcObXOiLwjTpRO081rpnMXTSTJDMYQ7 txC3xP9Ee780efCEwrthz3079n2itTX52mPIWggrL1Qkj3HwEHrBmwMTkr0Wu/TC7g7G d0Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="sNLV/DmZ"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si9403730edx.269.2020.06.08.17.50.37; Mon, 08 Jun 2020 17:51:00 -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=@ti.com header.s=ti-com-17Q1 header.b="sNLV/DmZ"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732166AbgFIAs2 (ORCPT + 99 others); Mon, 8 Jun 2020 20:48:28 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:48224 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbgFHXKy (ORCPT ); Mon, 8 Jun 2020 19:10:54 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 058NAi4F060849; Mon, 8 Jun 2020 18:10:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1591657844; bh=J15eJufKdDHorGHaYKdBz4fOpJXaofZH0gLXbZy+af4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=sNLV/DmZnULJuDOJYu9WDMgnzhgTBpfc+gZVE24GmrdNpm/BaeTxTkn7RXro2QdHh f+PtS5/zox1sRzGEr73qdNqenszENbRmHt2OtNIP2siu7SyDNa4wSzYNSlgEiphQyJ NIJzoTuStuqacbcd38bWFfZ64HcfmKAholGBF0HM= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 058NAiBX072956 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jun 2020 18:10:44 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 8 Jun 2020 18:10:44 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 8 Jun 2020 18:10:44 -0500 Received: from [10.250.48.148] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 058NAiXa040586; Mon, 8 Jun 2020 18:10:44 -0500 Subject: Re: [PATCH v7 3/5] remoteproc: Add support for runtime PM To: Paul Cercueil CC: Bjorn Andersson , Ohad Ben-Cohen , Arnaud Pouliquen , , , , , Tero Kristo References: <20200515104340.10473-1-paul@crapouillou.net> <20200515104340.10473-3-paul@crapouillou.net> <035bf8ad-3ef0-8314-ae5c-a94a24c230c8@ti.com> <9XPMBQ.UM94FDID8MZW@crapouillou.net> From: Suman Anna Message-ID: <107dc1d3-05c6-61be-b82c-197f0c43cdba@ti.com> Date: Mon, 8 Jun 2020 18:10:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <9XPMBQ.UM94FDID8MZW@crapouillou.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On 6/8/20 5:46 PM, Paul Cercueil wrote: > Hi Suman, > >>>> On 5/15/20 5:43 AM, Paul Cercueil wrote: >>>>> Call pm_runtime_get_sync() before the firmware is loaded, and >>>>> pm_runtime_put() after the remote processor has been stopped. >>>>> >>>>> Even though the remoteproc device has no PM callbacks, this allows the >>>>> parent device's PM callbacks to be properly called. >>>> >>>> I see this patch staged now for 5.8, and the latest -next branch >>>> has broken the pm-runtime autosuspend feature we have in the >>>> OMAP remoteproc driver. See commit 5f31b232c674 ("remoteproc/omap: >>>> Add support for runtime auto-suspend/resume"). >>>> >>>> What was the original purpose of this patch, because there can be >>>> differing backends across different SoCs. >>> >>> Did you try pm_suspend_ignore_children()? It looks like it was made >>> for your use-case. >> >> Sorry for the delay in getting back. So, using >> pm_suspend_ignore_children() does fix my current issue. >> >> But I still fail to see the original purpose of this patch in the >> remoteproc core especially given that the core itself does not have >> any callbacks. If the sole intention was to call the parent pdev's >> callbacks, then I feel that state-machine is better managed within >> that particular platform driver itself, as the sequencing/device >> management can vary with different platform drivers. > > The problem is that with Ingenic SoCs some clocks must be enabled in > order to load the firmware, and the core doesn't give you an option to > register a callback to be called before loading it. Yep, I have similar usage in one of my remoteproc drivers (see keystone_remoteproc.c), and I think this all stems from the need to use/support loading into a processor's internal memories. My driver does leverage the pm-clks backend plugged into pm_runtime, so you won't see explicit calls on the clocks. I guess the question is what exact PM features you are looking for with the Ingenic SoC. I do see you are using pm_runtime autosuspend, and your callbacks are managing the clocks, but reset is managed only in start/stop. > The first version of > my patchset added .prepare/.unprepare callbacks to the struct rproc_ops, > but the feedback from the maintainers was that I should do it via > runtime PM. However, it was not possible to keep it contained in the > driver, since again the core doesn't provide a "prepare" callback, so no > place to call pm_runtime_get_sync(). FWIW, the .prepare/.unprepare callbacks is actually now part of the rproc core. Looks like multiple developers had a need for this, and this functionality went in at the same time as your driver :). Not sure if you looked up the prior patches, I leveraged the patch that Loic had submitted a long-time ago, and a revised version of it is now part of 5.8-rc1. So we settled with having runtime > PM in the core without callbacks, which will trigger the runtime PM > callbacks of the driver at the right moment. Looks like we can do some cleanup on the Ingenic SoC driver depending on the features you want. regards Suman > > Sorry if that caused you trouble. > > Cheers, > -Paul >>>> > >>>> >>>>> >>>>> Signed-off-by: Paul Cercueil >>>>> --- >>>>> >>>>> Notes: >>>>>      v2-v4: No change >>>>>      v5: Move calls to prepare/unprepare to >>>>> rproc_fw_boot/rproc_shutdown >>>>>      v6: Instead of prepare/unprepare callbacks, use PM runtime >>>>> callbacks >>>>>      v7: Check return value of pm_runtime_get_sync() >>>>> >>>>>   drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++- >>>>>   1 file changed, 16 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/remoteproc/remoteproc_core.c >>>>> b/drivers/remoteproc/remoteproc_core.c >>>>> index a7f96bc98406..e33d1ef27981 100644 >>>>> --- a/drivers/remoteproc/remoteproc_core.c >>>>> +++ b/drivers/remoteproc/remoteproc_core.c >>>>> @@ -29,6 +29,7 @@ >>>>>   #include >>>>>   #include >>>>>   #include >>>>> +#include >>>>>   #include >>>>>   #include >>>>>   #include >>>>> @@ -1382,6 +1383,12 @@ static int rproc_fw_boot(struct rproc >>>>> *rproc, const struct firmware *fw) >>>>>       if (ret) >>>>>           return ret; >>>>>   +    ret = pm_runtime_get_sync(dev); >>>>> +    if (ret < 0) { >>>>> +        dev_err(dev, "pm_runtime_get_sync failed: %d\n", ret); >>>>> +        return ret; >>>>> +    } >>>>> + >>>>>       dev_info(dev, "Booting fw image %s, size %zd\n", name, >>>>> fw->size); >>>>>         /* >>>>> @@ -1391,7 +1398,7 @@ static int rproc_fw_boot(struct rproc >>>>> *rproc, const struct firmware *fw) >>>>>       ret = rproc_enable_iommu(rproc); >>>>>       if (ret) { >>>>>           dev_err(dev, "can't enable iommu: %d\n", ret); >>>>> -        return ret; >>>>> +        goto put_pm_runtime; >>>>>       } >>>>>         rproc->bootaddr = rproc_get_boot_addr(rproc, fw); >>>>> @@ -1435,6 +1442,8 @@ static int rproc_fw_boot(struct rproc >>>>> *rproc, const struct firmware *fw) >>>>>       rproc->table_ptr = NULL; >>>>>   disable_iommu: >>>>>       rproc_disable_iommu(rproc); >>>>> +put_pm_runtime: >>>>> +    pm_runtime_put(dev); >>>>>       return ret; >>>>>   } >>>>>   @@ -1840,6 +1849,8 @@ void rproc_shutdown(struct rproc *rproc) >>>>>         rproc_disable_iommu(rproc); >>>>>   +    pm_runtime_put(dev); >>>>> + >>>>>       /* Free the copy of the resource table */ >>>>>       kfree(rproc->cached_table); >>>>>       rproc->cached_table = NULL; >>>>> @@ -2118,6 +2129,9 @@ struct rproc *rproc_alloc(struct device >>>>> *dev, const char *name, >>>>>         rproc->state = RPROC_OFFLINE; >>>>>   +    pm_runtime_no_callbacks(&rproc->dev); >>>>> +    pm_runtime_enable(&rproc->dev); >>>>> + >>>>>       return rproc; >>>>>   } >>>>>   EXPORT_SYMBOL(rproc_alloc); >>>>> @@ -2133,6 +2147,7 @@ EXPORT_SYMBOL(rproc_alloc); >>>>>    */ >>>>>   void rproc_free(struct rproc *rproc) >>>>>   { >>>>> +    pm_runtime_disable(&rproc->dev); >>>>>       put_device(&rproc->dev); >>>>>   } >>>>>   EXPORT_SYMBOL(rproc_free); >>>>> >>>> > >