Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1218646
| Path | csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod |
|---|---|
| From | Xunlei Pang <pang.xunlei@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] cpuidle/coupled: Add sanity check for safe_state_index |
| Date | Fri, 04 Sep 2015 04:20:01 +0200 |
| Message-ID | <q4OLD-5eV-5@gated-at.bofh.it> (permalink) |
| References | <q3o6S-47f-11@gated-at.bofh.it> <q4rcm-58S-31@gated-at.bofh.it> |
| X-Original-To | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=I/aII1NhBzno/wUSdPd0fR/n3lhmABEZCJ0E7TbFK/M=; b=EqsUy5O/O0uxf5ddVd1AuvZv18FIxfEQqgRnfirWXh8dx0YQEWV/UU+l5JFMy3riAP YVLubo0GgjhtJagZJEjAbytgs7wm9UCa4BCJ5nwAQJetoQrE64zRJQSHMkPYDqOu/x/O 3ZB+X9m39wpuwinV5K3fO88XbcX19uL1XwQ3YR3V6gyhPJ+iQzVuKBWLQ3RQg70laRLp RXvuq2qwEjZF+YEcjVSSLlxgSBTJ74RbAljLSfHkKxs79hih2HGP2G56heWXDyzSsQz9 Wsr2BTwr2STfJNbbAoxkZhwNye/pZuSGPueJCoVbnt9+Pg5p1Y7RFAWOnHaBOoKGY3gT Yrwg== |
| X-Gm-Message-State | ALoCoQmdKrFr6A0f6Yby+M26kU0zeyeSYYDh1nmFfAhpOmBVX9AeHd2QYyOphETtVtPNQ7kiJvFm |
| MIME-Version | 1.0 |
| X-Received | by 10.129.148.197 with SMTP id l188mr1400936ywg.118.1441332941659; Thu, 03 Sep 2015 19:15:41 -0700 (PDT) |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 114 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | lkml <linux-kernel@vger.kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, linux-pm@vger.kernel.org |
| X-Original-Date | Fri, 4 Sep 2015 10:15:41 +0800 |
| X-Original-Message-ID | <CADcy93VYaL9VxkLj8P7ScgJqrPNf+bq7WTaH1qWS7pLXr=z7JQ@mail.gmail.com> |
| X-Original-References | <1440992045-17464-1-git-send-email-xlpang@126.com> <2730874.lxGIcz4Q5K@vostro.rjw.lan> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1218646 |
Show key headers only | View raw
Hi Rafael,
On 3 September 2015 at 09:35, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Monday, August 31, 2015 11:34:05 AM Xunlei Pang wrote:
>> From: Xunlei Pang <pang.xunlei@linaro.org>
>>
>> Since we are using cpuidle_driver::safe_state_index directly as the
>> target state index, it is better to add the sanity check at the point
>> of registering the driver.
>>
>> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
>
> I'm queuing this one up for the next PM pull request, thanks!
Thanks!
Regards,
Xunlei
>
>
>> ---
>> v2->v3:
>> Move the code to a new cpuidle_coupled_state_verify() depending on
>> CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED, to avoid using #ifdef in function
>> bodies. Thanks Rafael's comments on this.
>>
>> drivers/cpuidle/coupled.c | 22 ++++++++++++++++++++++
>> drivers/cpuidle/cpuidle.h | 6 ++++++
>> drivers/cpuidle/driver.c | 4 ++++
>> 3 files changed, 32 insertions(+)
>>
>> diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c
>> index 1523e2d..344058f 100644
>> --- a/drivers/cpuidle/coupled.c
>> +++ b/drivers/cpuidle/coupled.c
>> @@ -187,6 +187,28 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
>> }
>>
>> /**
>> + * cpuidle_coupled_state_verify - check if the coupled states are correctly set.
>> + * @drv: struct cpuidle_driver for the platform
>> + *
>> + * Returns 0 for valid state values, a negative error code otherwise:
>> + * * -EINVAL if any coupled state(safe_state_index) is wrongly set.
>> + */
>> +int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
>> +{
>> + int i;
>> +
>> + for (i = drv->state_count - 1; i >= 0; i--) {
>> + if (cpuidle_state_is_coupled(drv, i) &&
>> + (drv->safe_state_index == i ||
>> + drv->safe_state_index < 0 ||
>> + drv->safe_state_index >= drv->state_count))
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +/**
>> * cpuidle_coupled_set_ready - mark a cpu as ready
>> * @coupled: the struct coupled that contains the current cpu
>> */
>> diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
>> index 178c5ad..f87f399 100644
>> --- a/drivers/cpuidle/cpuidle.h
>> +++ b/drivers/cpuidle/cpuidle.h
>> @@ -35,6 +35,7 @@ extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
>>
>> #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
>> bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
>> +int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
>> int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
>> struct cpuidle_driver *drv, int next_state);
>> int cpuidle_coupled_register_device(struct cpuidle_device *dev);
>> @@ -46,6 +47,11 @@ bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
>> return false;
>> }
>>
>> +static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
>> +{
>> + return 0;
>> +}
>> +
>> static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
>> struct cpuidle_driver *drv, int next_state)
>> {
>> diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
>> index 5db1478..389ade4 100644
>> --- a/drivers/cpuidle/driver.c
>> +++ b/drivers/cpuidle/driver.c
>> @@ -227,6 +227,10 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
>> if (!drv || !drv->state_count)
>> return -EINVAL;
>>
>> + ret = cpuidle_coupled_state_verify(drv);
>> + if (ret)
>> + return ret;
>> +
>> if (cpuidle_disabled())
>> return -ENODEV;
>>
>>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v3] cpuidle/coupled: Add sanity check for safe_state_index Xunlei Pang <xlpang@126.com> - 2015-08-31 05:40 +0200
Re: [PATCH v3] cpuidle/coupled: Add sanity check for safe_state_index "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-09-03 03:10 +0200
Re: [PATCH v3] cpuidle/coupled: Add sanity check for safe_state_index Xunlei Pang <pang.xunlei@linaro.org> - 2015-09-04 04:20 +0200
csiph-web