Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp682108pxm; Thu, 3 Mar 2022 02:26:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXsbEJpdaKSKxTUjfnKRDd7NTo7/wkSSZrvUj9pzz9CcUEhydwQq8WwXlvx6dToSeKcYVB X-Received: by 2002:a50:ee90:0:b0:40f:349f:7368 with SMTP id f16-20020a50ee90000000b0040f349f7368mr33519213edr.236.1646303161923; Thu, 03 Mar 2022 02:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646303161; cv=none; d=google.com; s=arc-20160816; b=NKfDdLblk23cxkbcOe/LPwi6bY5frNZHAbRG8SKwisO4udJg3VHAd/xCrFKUom6Iz+ e2Ao1EYHVahCnVEbCxvmXCHYAExsecgAftRPtbiT0tvov/gq8IuLrmhQSFScbASqfTwr pfGG4b8DGUSmzj1SHrNnJLEkTHaWiBdGlx38cTkDYtRmKNdXt/fsSRdASOtQc2we725+ 1m9usPR2jChcH0ZcHGaf7v6Gf+VNZkszPUBtPI70RYBQRuNxOrTTgn7UjEDClNP1cWE/ ev7WmvbzBttMenyoLtUQ3aNABb/Q2tgj5Vcd1UyXoPYmip4vwZprUz9YihV3YP2VoAME wE3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=U2o4D6sY9hcZ2HCOJ98bGEt4shrRBFAlLDCYxMdZwf0=; b=Ms996i/7fDcGHMNvJcEwR+v7CywvAgF9HHCYUG+b1b4RycQS27TbnBCruZArRpedWz pQ7g5j0x5CmYkHvF5X0o6i7v3HQmktVJl5Cx9FzCN9TBwGuVSoTVO5nQ8ghdJu2L72Wk Bn9jUvpFrbEt3epf3pwBilvawjYuK/6La+h84UwC8fil4+AZlTtWdDMHZ/sB8VAoa0jN ebfuMlc9/jBycDGtpeKlhwiohkIcm7jbGZY0LLMF6tdrBv7v/7M+tmJgOCUOYWtkU4Ep W20sk4MkYABEeWpsLFkj3hcQE4k8vPPL9VdkTtJ5LJT4uhXW4rNtQoQSCgNfdujYQM+A nchg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020a1709061c8700b006cfcd366320si977179ejh.888.2022.03.03.02.25.39; Thu, 03 Mar 2022 02:26:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbiCCKDc (ORCPT + 99 others); Thu, 3 Mar 2022 05:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230476AbiCCKDb (ORCPT ); Thu, 3 Mar 2022 05:03:31 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 795511B785; Thu, 3 Mar 2022 02:02:45 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E5AD1424; Thu, 3 Mar 2022 02:02:44 -0800 (PST) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 380833F73D; Thu, 3 Mar 2022 02:02:43 -0800 (PST) Date: Thu, 3 Mar 2022 10:02:40 +0000 From: Sudeep Holla To: Krzysztof Kozlowski Cc: Edwin Chiu =?utf-8?B?6YKx5Z6C5bOw?= , Edwin Chiu , Sudeep Holla , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "rafael@kernel.org" , "daniel.lezcano@linaro.org" , "linux-pm@vger.kernel.org" Subject: Re: [PATCH v5] cpuidle: sunplus: Create cpuidle driver for sunplus sp7021 Message-ID: References: <1628e048220f066204b8ac27f3cedf7f3cc02963.1645427180.git.edwinchiu0505tw@gmail.com> <394261d1-f1df-e80d-3591-10f2d649e731@kernel.org> <748eb0e1-684c-a772-bccd-64b80780192f@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 03, 2022 at 10:34:31AM +0100, Krzysztof Kozlowski wrote: > On 03/03/2022 10:01, Edwin Chiu 邱垂峰 wrote: > > > > > >> -----Original Message----- > >> From: Krzysztof Kozlowski > >> Sent: Tuesday, March 1, 2022 7:34 PM > >> To: Edwin Chiu 邱垂峰 ; Edwin Chiu ; > >> robh+dt@kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; rafael@kernel.org; > >> daniel.lezcano@linaro.org; linux-pm@vger.kernel.org > >> Subject: Re: [PATCH v5] cpuidle: sunplus: Create cpuidle driver for sunplus sp7021 > >> > >> On 01/03/2022 10:30, Edwin Chiu 邱垂峰 wrote: > >>> > >>> > >>>> -----Original Message----- > >>>> From: Krzysztof Kozlowski > >>>> Sent: Tuesday, February 22, 2022 12:48 AM > >>>> To: Edwin Chiu ; Edwin Chiu 邱垂峰 > >>>> ; > >>>> robh+dt@kernel.org; devicetree@vger.kernel.org; > >>>> robh+linux-kernel@vger.kernel.org; rafael@kernel.org; > >>>> daniel.lezcano@linaro.org; linux-pm@vger.kernel.org > >>>> Subject: Re: [PATCH v5] cpuidle: sunplus: Create cpuidle driver for > >>>> sunplus sp7021 > >>>> > >>>> On 21/02/2022 08:26, Edwin Chiu wrote: > >>>>> Create cpuidle driver for sunplus sp7021 chip > >>>>> > >>>>> Signed-off-by: Edwin Chiu > >>>>> --- > >>>>> Changes in v3 > >>>>> - Rearrangement #include sequence > >>>>> - Change remark style to /*~*/ > >>>>> - Align author email address to same as sob > >>>>> - Optimal code > >>>>> Changes in v4 > >>>>> - According Rob Herringrobh's comment > >>>>> There is no need for this binding. > >>>>> Just wanting a different driver is not a reason > >>>>> for a duplicate schema. > >>>>> So remove yaml file and submit driver again. > >>>>> Changes in v5 > >>>>> - According Krzysztof's comment > >>>>> You either use appropriate compatible in DT > >>>>> or add your compatible to cpuidle-arm. > >>>>> Even if this did not work, then the solution is to > >>>>> use common parts, not to duplicate entire driver. > >>>>> According Sudeep's comment > >>>>> In short NACK for any dedicated driver for this platform, > >>>>> use the generic cpuidle-arm driver with appropriate platform hooks > >>>>> Create cpuidle-sunplus.c in arch/arm/mach-sunplus/ > >>>>> for hook generic cpuidle-arm driver > >>>>> > >>>>> MAINTAINERS | 6 ++ > >>>>> arch/arm/mach-sunplus/cpuidle-sunplus.c | 88 +++++++++++++++++ > >>>>> include/linux/platform_data/cpuidle-sunplus.h | 12 ++++ > >>>>> 3 files changed, 106 insertions(+) > >>>>> create mode 100644 arch/arm/mach-sunplus/cpuidle-sunplus.c > >>>>> create mode 100644 include/linux/platform_data/cpuidle-sunplus.h > >>>>> > >>>>> diff --git a/MAINTAINERS b/MAINTAINERS index e0dca8f..5c96428 100644 > >>>>> --- a/MAINTAINERS > >>>>> +++ b/MAINTAINERS > >>>>> @@ -18252,6 +18252,12 @@ L: netdev@vger.kernel.org > >>>>> S: Maintained > >>>>> F: drivers/net/ethernet/dlink/sundance.c > >>>>> > >>>>> +SUNPLUS CPUIDLE DRIVER > >>>>> +M: Edwin Chiu > >>>>> +S: Maintained > >>>>> +F: arch/arm/mach-sunplus/cpuidle-sunplus.c > >>>>> +F: include/linux/platform_data/cpuidle-sunplus.h > >>>>> + > >>>>> SUPERH > >>>>> M: Yoshinori Sato > >>>>> M: Rich Felker > >>>>> diff --git a/arch/arm/mach-sunplus/cpuidle-sunplus.c > >>>>> b/arch/arm/mach-sunplus/cpuidle-sunplus.c > >>>>> new file mode 100644 > >>>>> index 0000000..e9d9738 > >>>>> --- /dev/null > >>>>> +++ b/arch/arm/mach-sunplus/cpuidle-sunplus.c > >>>>> @@ -0,0 +1,88 @@ > >>>>> +// SPDX-License-Identifier: GPL-2.0-only > >>>>> +/* > >>>>> + * SP7021 cpu idle Driver. > >>>>> + * Copyright (C) Sunplus Tech / Tibbo Tech. > >>>>> + */ > >>>>> +#define pr_fmt(fmt) "CPUidle arm: " fmt > >>>>> + > >>>>> +#include > >>>>> +#include > >>>>> +#include > >>>>> + > >>>>> +#include > >>>>> + > >>>>> +typedef int (*idle_fn)(void); > >>>>> + > >>>>> +static DEFINE_PER_CPU(idle_fn*, sp7021_idle_ops); > >>>>> + > >>>>> +static int sp7021_cpuidle_enter(unsigned long index) { > >>>>> + return __this_cpu_read(sp7021_idle_ops)[index](); > >>>>> +} > >>>>> +static int sp7021_cpu_spc(void) > >>>>> +{ > >>>>> + cpu_v7_do_idle(); /* idle to WFI */ > >>>>> + return 0; > >>>>> +} > >>>>> +static const struct of_device_id sp7021_idle_state_match[] = { > >>>>> + { .compatible = "arm,idle-state", .data = sp7021_cpu_spc }, > >>>>> + { }, > >>>>> +}; > >>>> > >>>> This is confusing. You want to have two drivers to bind to the same > >>>> compatible? As I wrote in the previous messages, you should simply use arm,idle-state just like few > >> other architectures. > >>>> > >>>> > >>>> Best regards, > >>>> Krzysztof > >>> > >>> > >>> The patch v5 implemented according your comment. > >>> Used common part of arm,idle-state. > >>> Create new enable-method for cpuidle.ops function. > >>> It only have arm cpuidle driver exist now, no two drivers to bind to the same compatible. > >>> > >>> What do you mean " simply use arm,idle-state just like few other architectures "? > >>> > >> > >> I mean, do it similarly (by using arm,idle-state and other related > >> properties) to for example ti,am4372/ti,am3352. > >> > >> Best regards, > >> Krzysztof > > > > > > The am3352 cpuidle code structure is very similar to ours. > > Used enable-method = "ti,am3352" and compatible = "arm,idle-state" in am33xx.dtsi > > Used CPUIDLE_METHOD_OF_DECLARE(pm33xx_idle, "ti,am3352", &amx3_cpuidle_ops) in pm33xx-core.c > > > > The difference are > > am3352 > > amx3_idle_init(~) assign idle_states[i].wfi_flags = states[i].wfi_flags; > > amx3_idle_enter(~) call idle_fn(idle_state->wfi_flags) > > > > sunplus-sp7021 > > sp7021_cpuidle_init(~) assign fns[i] = idle_fns[i]; > > sp7021_cpuidle_enter(~) call __this_cpu_read(sp7021_idle_ops)[index](); > > > > I don't think am3352 cpuidle code architecture simpler than ours. > > The idle_fn function need more complex method to be assign. > > How do you think? > > You duplicated a driver, entire pieces of code. This is not acceptable. > Therefore it does not really make sense to discuss whether duplicated > solution seems simpler or not... We won't accept duplicated code. > Especially for WFI-only driver. > +1 for above comment. In addition, the reference platform am33xx* doesn't seem to support hotplug (may be I am missing to see but quick grep gave no results) and their idle is definitely not just WFI. So what I asked is that please document the chosen "sunplus,sc-smp" as bot cpu idle and hotplug methods and when you support non WFI states, we can revisit this. Also you must stick to this hotplug method whenever you decided to support it. -- Regards, Sudeep