Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5609240pxu; Thu, 22 Oct 2020 06:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3ipzmFiGeIpNS+hRswo42WFqkhjeqD8h9xDCaPJ97CKnaXNW0FcQorl4hS/pM1lIyGNqJ X-Received: by 2002:a17:906:a149:: with SMTP id bu9mr2256588ejb.115.1603374786910; Thu, 22 Oct 2020 06:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603374786; cv=none; d=google.com; s=arc-20160816; b=Xo4owAOpEFkS7LEiZc1W7F+YbI+zC61YnWgOr51KPUyI/A1V1WL9NrSSkxmDOC20hl mR4n/lS3UYOppToOkRIzORLqX4qv8pQs5atgTRBnPYYAhg7vBQPWNxWCPJWqNzwMLq8X Czjf9Wd0AGyfru8TPl0c6D9Zd5m3ZkXMenJbXAYAIEpfN1R4E+Rol8gvOr36E2nJpFj8 jwK02nPJi01e2gXcJJWe2p9faRloczw41wCNOtV3hKip8pPGDvuDaOuW9McM7c5fsWU1 rpNkxREyXnUqKJ1BL0cvjlhTdqPEUYc+0pTx4DPXp0leVRYbL5oyrUrZQvTfbuaMMA51 NKIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:cc:to:subject :dkim-signature:dkim-filter; bh=kDAYexLUL1fIzAZL+IINMuwVpdSM8IRXCDveo7dhFUY=; b=pgjm6EsT9HtPwI0/f4m8eqioA//I0WNxL8tH2zv/HacTHVBATqrMH0JJkJlE2CNwci EOHeAZLjdzmOb863jQfA0u4Ylpo5kRC9BXeng1pV0PKIEP8A8vHWFN4eVYHTs7CcPANG zZgNjfivR/mzn+CAmqBd5dCLO+AoZ311RT36z3ZzvWa2sfM3HBqHk8NEI17c/x/Mg6U0 zQdGuKzb7qIuYrriJ4/Zq3+uDqrCR5Qp5Bansjudu5Y+E0T0pNbCw4Fa4CyGR4GbtXSm 1CgmnxeSarxTZjLg7AfenfaToQRJ1TLzqH0xB8JoZ4zER8KJOo3zd7KHL+7WNutEzQl6 d/vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YLw8Bz2H; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si960049edl.450.2020.10.22.06.52.44; Thu, 22 Oct 2020 06:53:06 -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=@samsung.com header.s=mail20170921 header.b=YLw8Bz2H; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895088AbgJVCd3 (ORCPT + 99 others); Wed, 21 Oct 2020 22:33:29 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:28756 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443282AbgJVCd3 (ORCPT ); Wed, 21 Oct 2020 22:33:29 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20201022023326epoutp03a3c25baa7b20677c418b327098693642~AL8jKU4FE0836308363epoutp03f for ; Thu, 22 Oct 2020 02:33:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20201022023326epoutp03a3c25baa7b20677c418b327098693642~AL8jKU4FE0836308363epoutp03f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1603334006; bh=kDAYexLUL1fIzAZL+IINMuwVpdSM8IRXCDveo7dhFUY=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=YLw8Bz2HvkH40y1S0a89QuW37A1ZIQEaapLOAorBuC4C6I4HHI+aaf6wDMUx2qEiq rfapHcpvzjBJaxpTMAou/BjQDLHzxWS8MMZ7fP+yfvxO7kqEtxadxlblvixdM7tRtd 2Pts87mjHtJoBkyMwM70VaArJq0e8lsnghVeShYo= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20201022023326epcas1p3b9bdd8fb412cd443e0c0b9d43fe7561e~AL8ijoQwv0726607266epcas1p3U; Thu, 22 Oct 2020 02:33:26 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.157]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4CGryC4Xc0zMqYm6; Thu, 22 Oct 2020 02:33:23 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id DE.7B.09543.37FE09F5; Thu, 22 Oct 2020 11:33:23 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20201022023323epcas1p4ea552e1162038d835a07738768d00b01~AL8fv2UJ51068810688epcas1p4s; Thu, 22 Oct 2020 02:33:23 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201022023323epsmtrp1dcb1f281dd861d046cab21ccbc6b5235~AL8fu4gmy2300923009epsmtrp1d; Thu, 22 Oct 2020 02:33:23 +0000 (GMT) X-AuditID: b6c32a35-347ff70000002547-b0-5f90ef732b0b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CC.04.08604.27FE09F5; Thu, 22 Oct 2020 11:33:22 +0900 (KST) Received: from [10.113.221.102] (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201022023322epsmtip1bdc086dee72f2aaaec3bd4e62a5ab4b9~AL8fbDqUS2126221262epsmtip1F; Thu, 22 Oct 2020 02:33:22 +0000 (GMT) Subject: Re: [PATCH v4 2/2] PM / devfreq: Add governor attribute flag for specifc sysfs nodes To: Dmitry Osipenko , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Cc: lukasz.luba@arm.com, enric.balletbo@collabora.com, hl@rock-chips.com, thierry.reding@gmail.com, jonathanh@nvidia.com, abel.vesa@nxp.com, k.konieczny@samsung.com, b.zolnierkie@samsung.com, chanwoo@kernel.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com From: Chanwoo Choi Organization: Samsung Electronics Message-ID: <5802dfbd-22d2-0efb-cc98-2dbb1d420367@samsung.com> Date: Thu, 22 Oct 2020 11:47:02 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Thunderbird/59.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGJsWRmVeSWpSXmKPExsWy7bCmgW7x+wnxBs2TZC2WXTrKaLFxxnpW i4k3rrBYrP74mNFize1DjBY/NpxitmiZtYjFYsGnGawWZ5vesFtc3jWHzeJz7xFGi84vs9gs Fja1sFvcblzBZvFz1zwWB36PNfPWMHrsuLuE0WPnrLvsHptWdbJ59Da/Y/PY+G4Hk8ffWftZ PPq2rGL0+LxJLoAzKtsmIzUxJbVIITUvOT8lMy/dVsk7ON453tTMwFDX0NLCXEkhLzE31VbJ xSdA1y0zB+gFJYWyxJxSoFBAYnGxkr6dTVF+aUmqQkZ+cYmtUmp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768d00b01 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20201020025045epcas1p4b26b6f23e2896c2d661b2cfa93505e21 References: <20201020030407.21047-1-cw00.choi@samsung.com> <20201020030407.21047-3-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/22/20 11:30 AM, Dmitry Osipenko wrote: > Hello Chanwoo, > > 20.10.2020 06:04, Chanwoo Choi пишет: >> @@ -1354,55 +1365,71 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, >> struct devfreq *df = to_devfreq(dev); >> int ret; >> char str_governor[DEVFREQ_NAME_LEN + 1]; >> - const struct devfreq_governor *governor, *prev_governor; >> + const struct devfreq_governor *new_governor, *prev_governor; >> >> if (!df->governor) >> return -EINVAL; >> + prev_governor = df->governor; >> >> ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor); >> if (ret != 1) >> return -EINVAL; >> >> mutex_lock(&devfreq_list_lock); >> - governor = try_then_request_governor(str_governor); >> - if (IS_ERR(governor)) { >> - ret = PTR_ERR(governor); >> + new_governor = try_then_request_governor(str_governor); >> + if (IS_ERR(new_governor)) { >> + ret = PTR_ERR(new_governor); >> goto out; >> } >> - if (df->governor == governor) { >> + if (prev_governor == new_governor) { >> ret = 0; >> goto out; >> - } else if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE) >> - || IS_SUPPORTED_FLAG(governor->flags, IMMUTABLE)) { >> + } else if (IS_SUPPORTED_FLAG(prev_governor->flags, IMMUTABLE) >> + || IS_SUPPORTED_FLAG(new_governor->flags, IMMUTABLE)) { >> ret = -EINVAL; >> goto out; >> } >> >> - ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL); >> + /* >> + * Stop the previous governor and remove the specific sysfs files >> + * which depend on previous governor. >> + */ >> + ret = prev_governor->event_handler(df, DEVFREQ_GOV_STOP, NULL); >> if (ret) { >> dev_warn(dev, "%s: Governor %s not stopped(%d)\n", >> - __func__, df->governor->name, ret); >> + __func__, prev_governor->name, ret); >> goto out; >> } >> >> - prev_governor = df->governor; >> - df->governor = governor; >> - strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN); >> - ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); >> + remove_sysfs_files(df, prev_governor); >> + >> + /* >> + * Start the new governor and create the specific sysfs files >> + * which depend on new governor. >> + */ >> + strncpy(df->governor_name, new_governor->name, DEVFREQ_NAME_LEN); >> + ret = new_governor->event_handler(df, DEVFREQ_GOV_START, NULL); > > The "df->governor = new_governor" needs to be set before invocation of > the event_handler(GOV_START) because governors like a > performance-governor need to have the df->governor being set before the > GOV_START callback, otherwise performance governor will use > devfreq->prev_governor->get_target_freq() in devfreq_update_target(), > thus setting a wrong (non-max) freq. You're right. It is my mistake. Thanks for your detailed review. > >> if (ret) { >> dev_warn(dev, "%s: Governor %s not started(%d)\n", >> - __func__, df->governor->name, ret); >> - df->governor = prev_governor; >> + __func__, new_governor->name, ret); >> strncpy(df->governor_name, prev_governor->name, >> DEVFREQ_NAME_LEN); >> - ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); > > Same here. OK. > > -- Best Regards, Chanwoo Choi Samsung Electronics