Skip to content

trace: convert trace time stamp to ticks - #1358

Merged
lgirdwood merged 1 commit into
thesofproject:masterfrom
bardliao:trace_timer
May 31, 2019
Merged

lgirdwood merged 1 commit into
thesofproject:masterfrom
bardliao:trace_timer

Conversation

@bardliao

@bardliao bardliao commented May 3, 2019

Copy link
Copy Markdown
Collaborator

The unit of trace header timestamp is ticks but it is nanosecond
in trace params. So we have to convert it to ticks.

Signed-off-by: Bard Liao yung-chuan.liao@linux.intel.com

@lgirdwood lgirdwood left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao Can you rename the ipc structure time delta variable to include a _ns suffix and comment for nanosecs, that way it's obvious. This wont be an ABI change.

@xiulipan xiulipan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The clock usage seems not like other user. Please take reference and made some modification.

Comment thread src/lib/clk.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bardliao
Maybe this way?

Suggested change
return clk_pdata->clk[clock].ticks_per_msec / 1000 * ns / 1000;
return clk_pdata->clk[clock].ticks_per_msec * ns / 1000000;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@xiulipan It is a trade-off between overflow and accuracy. It may overflow when clk_pdata->clk[clock].ticks_per_msec * ns

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then maybe add a comment here to explain the overflow risk.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao would it be easier to use the clock here in this calculation since it will be in MHz (multiplied by 1000 it will be same timebase as host ns) ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood Sorry I didn't get you. I think the clock here is an index, right? Did you mean something like double clock; in logger? I didn't find a similar variable here.

Comment thread src/include/sof/timer.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why made this to a global variable?
You can take reference to other clock user like: sch->clock or just use PLATFORM_DEFAULT_CLOCK

Comment thread src/ipc/handler.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This here is too complex, you can reference clock_ms_to_ticks user to simplify here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@xiulipan Updated. But I don't know if using PLATFORM_DEFAULT_CLOCK is always right. for example, On baytrail, the .clk is PLATFORM_WORKQ_CLOCK, but the PLATFORM_DEFAULT_CLOCK is CLK_SSP

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bardliao
Then maybe you can take reference of sch->clock to pre define it for different platform.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@xiulipan updated.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Existing clock_ms_to_ticks() is used with the PLATFORM_DEFAULT_CLOCK in many places assuming this is correct define.
Wrt to BYT see this define:

/* platform WorkQ clock */
#define PLATFORM_WORKQ_CLOCK	PLATFORM_DEFAULT_CLOCK

@xiulipan

xiulipan commented May 4, 2019

Copy link
Copy Markdown
Contributor

@bardliao
BTW, where is the linux part. Or no need for driver change?

@bardliao
bardliao requested a review from akloniex as a code owner May 5, 2019 05:35
@bardliao

bardliao commented May 5, 2019

Copy link
Copy Markdown
Collaborator Author

@bardliao
BTW, where is the linux part. Or no need for driver change?

@xiulipan The linux part is on thesofproject/linux#756

@bardliao

bardliao commented May 5, 2019

Copy link
Copy Markdown
Collaborator Author

@bardliao Can you rename the ipc structure time delta variable to include a _ns suffix and comment for nanosecs, that way it's obvious. This wont be an ABI change.

@lgirdwood Yes, done.

@bardliao
bardliao requested a review from RanderWang as a code owner May 6, 2019 06:00
@xiulipan
xiulipan requested a review from bkokoszx May 6, 2019 07:30
@xiulipan

xiulipan commented May 6, 2019

Copy link
Copy Markdown
Contributor

@bkokoszx
There are some timer related changes. Please have a look to see if the implementation is the right way.

@RanderWang RanderWang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment thread src/ipc/handler.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assign ticks to nanosecond?

@bkokoszx bkokoszx May 6, 2019 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've also think that _ns is bit misleading here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao external host IPC uses nanosecs, internal uses local time domain (which will be different for each platform)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bardliao
I think the _ns is already with timestamp_ns. No need for delta.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, thanks everyone. The _ns here is a mistake. I will fix it then

Comment thread src/ipc/handler.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao external host IPC uses nanosecs, internal uses local time domain (which will be different for each platform)

Comment thread src/lib/clk.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao would it be easier to use the clock here in this calculation since it will be in MHz (multiplied by 1000 it will be same timebase as host ns) ?

Comment thread src/library/include/platform/platform.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this extern structure ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood I need to know the clk id of platform_timer (eg. CLK_SSP) which is platform dependency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bardliao ok, can you rebase

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood Yes, done.

mmaka1
mmaka1 previously requested changes May 10, 2019
Comment thread src/ipc/handler.c Resolved
The unit of trace header timestamp is ticks but it is nanosecond
in trace params. So we have to convert it to ticks.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao

Copy link
Copy Markdown
Collaborator Author

@mmaka1 Thanks for the comments. The PR has updated. thanks.

@lgirdwood

Copy link
Copy Markdown
Member

@bardliao is the kernel part ready for merging yet ?

@bardliao

Copy link
Copy Markdown
Collaborator Author

@bardliao is the kernel part ready for merging yet ?

@lgirdwood I think basically @plbossart agree with that PR, but we need to deal with the missing ABI minor 6 issue. Please see thesofproject/linux#756 (comment)

@lgirdwood

Copy link
Copy Markdown
Member

@zrombel @bardliao can you check the build failure.

@tlauda
tlauda requested review from lgirdwood, mmaka1 and xiulipan May 30, 2019 09:39
@tlauda

tlauda commented May 30, 2019

Copy link
Copy Markdown
Contributor

@bardliao I guess the kernel change is already merged? Is this one good to go?

@xiulipan xiulipan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code LGTM
I will try to run some test later.

@bardliao

Copy link
Copy Markdown
Collaborator Author

@bardliao I guess the kernel change is already merged? Is this one good to go?

@tlauda Yes, the kernel change is already merged. thesofproject/linux#756

@lgirdwood
lgirdwood dismissed mmaka1’s stale review May 31, 2019 15:46

Now outdated, changes made to simplify further.

@lgirdwood
lgirdwood merged commit 7bfbe43 into thesofproject:master May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants