You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/29 03:47:44 UTC
[GitHub] [incubator-nuttx] zhuyanlinzyl opened a new pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
zhuyanlinzyl opened a new pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901
## Summary
## Impact
## Testing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901#discussion_r837562565
##########
File path: drivers/power/pm_lock.c
##########
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * drivers/power/pm_lock.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/irq.h>
+#include <nuttx/power/pm.h>
+#include <sched.h>
+#include "pm.h"
+
+#if defined(CONFIG_PM)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pm_lock
+ *
+ * Description:
+ * Lock the power management operation.
+ *
+ ****************************************************************************/
+
+irqstate_t pm_lock(void)
+{
+ irqstate_t flags = 0;
+
+ if (up_interrupt_context() || sched_idletask())
+ {
+ flags = enter_critical_section();
+ }
+ else
+ {
+ nxsem_wait(&g_pmglobals.regsem);
Review comment:
to support sync between the normal thread and idle thread/interrupt context, it's better:
1. If not in idle thread and interrupt context, hold the semaphore
2. And then always hold the critical section
##########
File path: drivers/power/pm_register.c
##########
@@ -56,20 +56,24 @@
int pm_register(FAR struct pm_callback_s *callbacks)
{
- int ret;
-
DEBUGASSERT(callbacks);
/* Add the new entry to the end of the list of registered callbacks */
- ret = pm_lock();
- if (ret == OK)
+ if (OSINIT_OS_READY())
Review comment:
@zhuyanlinzyl bring back the wrong code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] zhuyanlinzyl commented on pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
zhuyanlinzyl commented on pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901#issuecomment-1085897754
Yes, I have update the patch, please review again @xiaoxiang781216 @pkarashchenko
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901#discussion_r840528348
##########
File path: drivers/power/pm_lock.c
##########
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * drivers/power/pm_lock.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/irq.h>
+#include <nuttx/power/pm.h>
+#include <sched.h>
+#include "pm.h"
+
+#if defined(CONFIG_PM)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pm_lock
+ *
+ * Description:
+ * Lock the power management operation.
+ *
+ ****************************************************************************/
+
+irqstate_t pm_lock(void)
+{
+ irqstate_t flags = 0;
+
+ if (up_interrupt_context() || sched_idletask())
+ {
+ flags = enter_critical_section();
+ }
+ else
+ {
+ nxsem_wait(&g_pmglobals.regsem);
Review comment:
yes, but the current implementation does not take into account interruption by a signal. Maybe we should use uninterrupted version or have `int pm_lock(irqstate_t *state);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901#discussion_r840536482
##########
File path: drivers/power/pm_lock.c
##########
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * drivers/power/pm_lock.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/irq.h>
+#include <nuttx/power/pm.h>
+#include <sched.h>
+#include "pm.h"
+
+#if defined(CONFIG_PM)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pm_lock
+ *
+ * Description:
+ * Lock the power management operation.
+ *
+ ****************************************************************************/
+
+irqstate_t pm_lock(void)
+{
+ irqstate_t flags = 0;
+
+ if (up_interrupt_context() || sched_idletask())
+ {
+ flags = enter_critical_section();
+ }
+ else
+ {
+ nxsem_wait(&g_pmglobals.regsem);
Review comment:
I think so, @zhuyanlinzyl
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901#discussion_r837480266
##########
File path: drivers/power/pm_register.c
##########
@@ -56,20 +56,24 @@
int pm_register(FAR struct pm_callback_s *callbacks)
{
- int ret;
-
DEBUGASSERT(callbacks);
/* Add the new entry to the end of the list of registered callbacks */
- ret = pm_lock();
- if (ret == OK)
+ if (OSINIT_OS_READY())
Review comment:
I think this completely contradicts to https://github.com/apache/incubator-nuttx/pull/5849
@GUIDINGLI could you please review this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5901: power: unify lock sates and move pm_auto_update to outer dir
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5901:
URL: https://github.com/apache/incubator-nuttx/pull/5901
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org