Skip to content
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

Bluetooth: Controller: DTM: Fix timer rollover #42866

Closed
wants to merge 4 commits into from

Conversation

piotrParf
Copy link

@piotrParf piotrParf commented Feb 16, 2022

It changes the behaviour of while loop in lll_test.c in isr_tx() . When bug happens and t<s is quite big it can hapen that while loop will take a long time. This leads to setting up start of a radio timer before current timer value. This then leads to invocation of a timer after rollout and this will lead to very large delay in sending packet.

Fixes #42534.

Signed-off-by: Piotr Parfeniuk piotr.parfeniuk@magitech.pl

@carlescufi
Copy link
Member

Thanks @piotrParf, can you please format the commit as per https://docs.zephyrproject.org/latest/contribute/index.html#commit-guidelines?

@carlescufi carlescufi changed the title Fix of issue 42534 in 2.7 LTS Bluetooth: DTM: Fix timer rollover Feb 16, 2022
@cvinayak cvinayak changed the title Bluetooth: DTM: Fix timer rollover Bluetooth: Controller: DTM: Fix timer rollover Feb 17, 2022
Comment on lines 116 to 118
/*Previous calculation in while loop can take too long time and can rollout the timer*/
if (t < s){
t+=((((s - t) / SCAN_INT_UNIT_US) + 1) * SCAN_INT_UNIT_US);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add roll over handling. Feel free to change the implementation for better readability.

Suggested change
/*Previous calculation in while loop can take too long time and can rollout the timer*/
if (t < s){
t+=((((s - t) / SCAN_INT_UNIT_US) + 1) * SCAN_INT_UNIT_US);
if (t < s) {
t += ((((s - t) / SCAN_INT_UNIT_US) + 1) * SCAN_INT_UNIT_US);
} else {
/* Handle rollover case here, timer is configured to 24-bits */
t += ((((BIT(24) - t + s) / SCAN_INT_UNIT_US) + 1) * SCAN_INT_UNIT_US);

Copy link
Author

Choose a reason for hiding this comment

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

Please check my last commit @cvinayak. I made some refactoring of variables naming and also did another type of preventing the timer rollover.

Copy link
Author

Choose a reason for hiding this comment

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

should be done

…ite big it can hapen that while loop will take a long time. This leads to setting up start of a radio timer before current timer value. This then leads to invocation of a timer after rollout and this will lead to very large delay in sending packet. It fixes for me a issue zephyrproject-rtos#42534.

Signed-off-by: Piotr Parfeniuk piotr.parfeniuk@magitech.pl
Piotr Parfeniuk added 2 commits February 17, 2022 12:39
…ted other type of timer rollover prevention.

Signed-off-by: Piotr Parfeniuk piotr.parfeniuk@magitech.pl
Signed-off-by: Piotr Parfeniuk piotr.parfeniuk@magitech.pl
@jhedberg jhedberg assigned cvinayak and unassigned jhedberg Feb 18, 2022
@Thalley Thalley removed their request for review February 25, 2022 11:09
@alwa-nordic alwa-nordic removed their request for review February 28, 2022 16:49
@carlescufi
Copy link
Member

@piotrParf ping, can you take a look at the review comments please?

Signed-off-by: Piotr Parfeniuk piotr.parfeniuk@magitech.pl
@piotrParf
Copy link
Author

Why do i got .github/labeler.yml Error: HttpError ?

@carlescufi
Copy link
Member

Why do i got .github/labeler.yml Error: HttpError ?

You can ignore that

@carlescufi carlescufi requested a review from KAGA164 April 6, 2022 11:16
@carlescufi
Copy link
Member

@KAGA164 could you please comment on this proposed change?

@KAGA164
Copy link
Collaborator

KAGA164 commented Apr 6, 2022

@KAGA164 could you please comment on this proposed change?

@carlescufi I will check timings with Anritsu

@KAGA164
Copy link
Collaborator

KAGA164 commented Apr 6, 2022

@piotrParf Please rebase and align your PR due to changes made by #42300. I included CTE time in the transmit time calculation.

Copy link
Collaborator

@KAGA164 KAGA164 left a comment

Choose a reason for hiding this comment

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

The DTM Tx interval is incorrect with this fix because it doesn't follow the calculation from Core v5.3 Vol 6 Part F 4.1.6 where interval should follow basically pattern n*625us. I did a test on 1Mb PHY with payload length 37 bytes and I measured the 908us interval when it shall be 625us.
DTM_interval

@piotrParf
Copy link
Author

The DTM Tx interval is incorrect with this fix because it doesn't follow the calculation from Core v5.3 Vol 6 Part F 4.1.6 where interval should follow basically pattern n*625us. I did a test on 1Mb PHY with payload length 37 bytes and I measured the 908us interval when it shall be 625us. DTM_interval

As I do not have proper tools for this what is your suggestion ?

@KAGA164
Copy link
Collaborator

KAGA164 commented Apr 11, 2022

@piotrParf I made PR with my proposal how to handle Tx timings in the DTM, Could you test it and give me a feedback ? #44735

@piotrParf
Copy link
Author

@piotrParf I made PR with my proposal how to handle Tx timings in the DTM, Could you test it and give me a feedback ? #44735

For me it is many changes to 2.7.0 but it looks like it works when loaded with this controller to network core.

@cvinayak
Copy link
Contributor

cvinayak commented Jun 1, 2022

@piotrParf I made PR with my proposal how to handle Tx timings in the DTM, Could you test it and give me a feedback ? #44735

For me it is many changes to 2.7.0 but it looks like it works when loaded with this controller to network core.

superceded by #44735, closing based on authors reply.

@cvinayak cvinayak closed this Jun 1, 2022
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.

BLE Testing functions do not work properly
5 participants