Skip to content

Kinetis update to fix tickless #11412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 9, 2019

Conversation

mmahadevan108
Copy link
Contributor

Description

This should fix issue #11401 (comment)

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@mmahadevan108
Copy link
Contributor Author

cc @0xc0170 @jamesbeyond @kjbracey-arm @maciejbocianski

@ciarmcom
Copy link
Member

ciarmcom commented Sep 4, 2019

@mmahadevan108, thank you for your changes.
@maclobdell @ARMmbed/mbed-os-maintainers please review.

@0xc0170 0xc0170 requested a review from kjbracey September 4, 2019 19:36
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Looks basically good to me, except for the apparently unbalanced PRE/POST calls - please check that.

Other stuff is basically style bike-shedding you can take with a pinch of salt.

int clock_enabled = 0;
switch (uart_index) {
case 0:
clock_enabled = (SIM->SCGC4 & SIM_SCGC4_UART0_MASK) >> SIM_SCGC4_UART0_SHIFT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, I'd be inclined to pare this down to more like:

static bool serial_is_enabled(uint32_t uart_index)
{
    switch (uart_index) {
        case 0:
            return SIM->SCGC4 & SIM_SCGC4_UART0_MASK;
        default:
            return false;
    }
}

Let bool take the strain. But this is fine.


/* Check if data is waiting to be written out of transmit buffer */
if (!(kUART_TransmissionCompleteFlag & UART_GetStatusFlags((UART_Type *)base))) {
uart_tx_ongoing = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I'd just return true. But maybe doesn't fit the style in this unit.

serial_wait_tx_complete(STDIO_UART);
/* Check if any of the UART's is transmitting data */
if (serial_check_tx_ongoing()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Aha! This is actually an approach I hadn't considered, and it is actually much better than waiting or going into shallow sleep. Thank you.

Returning is best here. This gives waking interrupts a chance to operate, rather than sitting there looping with interrupts disabled inside the HAL - possibly bad for performance. The core code will re-enable interrupts briefly, giving them a chance to execute, and then come back here again if it still wants to sleep. The loop will happen at a higher level, with proper "I've changed my mind about sleeping" checks.

Except it looks unbalanced with respect to the vPortPRE_SLEEP_PROCESSING above. Should this check be done before that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha! This is actually an approach I hadn't considered, and it is actually much better than waiting or going into shallow sleep. Thank you.

Returning is best here. This gives waking interrupts a chance to operate, rather than sitting there looping with interrupts disabled inside the HAL - possibly bad for performance. The core code will re-enable interrupts briefly, giving them a chance to execute, and then come back here again if it still wants to sleep. The loop will happen at a higher level, with proper "I've changed my mind about sleeping" checks.

Except it looks unbalanced with respect to the vPortPRE_SLEEP_PROCESSING above. Should this check be done before that?

I have addressed the unbalannce PRE/POST by moving the serial check earlier.

@@ -19,8 +19,7 @@

extern void vPortPRE_SLEEP_PROCESSING(clock_mode_t powermode);
extern void vPortPOST_SLEEP_PROCESSING(clock_mode_t powermode);
extern void serial_wait_tx_complete(uint32_t uart_index);

extern int serial_check_tx_ongoing();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should really be bool. I think only reason there's not much bool in the existing code is because it predates C99 being enabled in Mbed OS. Oh, and (void). This isn't C++ - still need (void) in declarations, or else you're leaving parameters unspecified.

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 have changed this to bool.

@0xc0170 0xc0170 self-requested a review September 5, 2019 08:56
The code checks if any of the UART's is still transmitting.
If so then prevent from entering deepsleep

Signed-off-by: Mahesh Mahadevan <[email protected]>
We should not block in case the UART is busy transmitting. The
API has been updated to check the status of all UART's and return
1 in case any of them is busy transmitting.

Signed-off-by: Mahesh Mahadevan <[email protected]>
@mmahadevan108 mmahadevan108 force-pushed the Kinetis_Update_To_Fix_Tickless branch from a47f5eb to 5c48e4e Compare September 5, 2019 19:13
The code checks if any of the UART's is still transmitting.
If so then prevent from entering deepsleep

Signed-off-by: Mahesh Mahadevan <[email protected]>
We should not block in case the UART is busy transmitting. The
API has been updated to check the status of all UART's and return
1 in case any of them is busy transmitting.

Signed-off-by: Mahesh Mahadevan <[email protected]>
@mmahadevan108 mmahadevan108 force-pushed the Kinetis_Update_To_Fix_Tickless branch from 5c48e4e to 31da8ff Compare September 5, 2019 19:16
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 6, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Sep 6, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@mmahadevan108
Copy link
Contributor Author

Build failures do not seem related to this PR

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 6, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Sep 6, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@jamesbeyond
Copy link
Contributor

jamesbeyond commented Sep 6, 2019

Hi @0xc0170, this issue, has bigger impacts, and fails one of mbed-os example, I suggest get it into mbed-os-5.14-rc2

@0xc0170 0xc0170 merged commit f35e16e into ARMmbed:master Sep 9, 2019
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 9, 2019

Release version updated as requested, cc @adbridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants