Skip to content

Conversation

@mbolivar
Copy link
Contributor

Document this behavior. This partially addresses #20708.

@mbolivar mbolivar added bug The issue is a bug, or the PR is fixing a bug area: Documentation area: API Changes to public APIs labels Nov 14, 2019
@mbolivar mbolivar added this to the v2.1.0 milestone Nov 14, 2019
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually wrong. See my comment on your issue.

Common pattern being: functions ending with _async are non blocking, others are.
The documentation was missing at that time, yes. But these were meant to be blocking and should be blocking or then they would be aliases to _async counterpart with a cb set as NULL... so they would be useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for responding. I asked you on slack yesterday what you meant but got no answer :).

OK, so then the situation is that all the clock drivers which aren't blocking are buggy. Would you agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions ending with _async are non blocking, others are.

BTW, I fully agree with this, but nobody who responded so far seemed to, so I am glad we are on the same page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you agree?

I see from your comment on the issue that you do agree. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions ending with _async are non blocking, others are.

BTW, I fully agree with this, but nobody who responded so far seemed to, so I am glad we are on the same page.

I also think this should be true, but see #15703 (comment). "Non-blocking" is subject to conditions, at least for some API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comment seems to indicate that "non-blocking" is not the same as "queued", which makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for responding. I asked you on slack yesterday what you meant but got no answer :).

Sorry I missed the message/notification

OK, so then the situation is that all the clock drivers which aren't blocking are buggy. Would you agree?

Yes, we are on same page.

@mbolivar mbolivar changed the title drivers: clock_control: clock_control_on is nonblocking drivers: clock_control: clock_control_on is blocking Nov 14, 2019
@mbolivar
Copy link
Contributor Author

@tbursztyka I've rewritten this with the opposite sense. Please review and I guess we'll discuss at the next API meeting.

Copy link
Contributor

@nordic-krch nordic-krch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, 2 minor comments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ref clock_control_async_on()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what it is actually. It's probably something that is vendor dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. That's what "opaque data" means, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the clock disable comment to use the same language

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should it behave when called from interrupt context? Do we forbid that or it should be blocking wait (with k_cpu_idle)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that is the 64 thousand dollar question.

We have a few choices which I was planning to discuss at API meeting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it be any different from other blocking functions in this regard?

Copy link
Contributor Author

@mbolivar mbolivar Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we won't get to discuss in the API meeting. Here are some options:

  1. busy-wait in ISR context, sleep in thread context
  2. busy-wait no matter the context
  3. fail in ISR, sleep in thread
  4. ???

I'm not sure if there are other contexts we need to worry about. I don't know how meta IRQs work, for example.

Considering that some clocks take a long time to start up and stabilize, sleeping the thread seems desirable, if a bit more complex.

I'd like to discuss in the meeting to get as much feedback as possible from people who are interested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlescufi points out this is a special case of #6184.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have k_cpu_idle() in ISR and semaphore in thread context.

Personally, I would prefer that function works in both context. I wouldn't like to have _isr, rather function should internally handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated following discussion in the API meeting. The intent has apparently been that unless specifically marked, all driver APIs are only safe to call from threads.

@ioannisg
Copy link
Member

@mbolivar could you address the review by @nordic-krch ?

Copy link
Contributor

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this as a documentation fix for 2.1. As discussed in #20806 and suggested in #20796 (review) we should revisit this API in terms of naming, description of behavior, and functionality.

Document this behavior. This partially addresses zephyrproject-rtos#20708, but we'll
have to deal with driver bugs case by case now that the desired
behavior is clear.

Signed-off-by: Martí Bolívar <[email protected]>
@dleach02 dleach02 modified the milestones: v2.1.0, v2.2.0 Dec 3, 2019
@nashif nashif merged commit 2de12df into zephyrproject-rtos:master Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Clock Control area: Documentation bug The issue is a bug, or the PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.