Skip to content

Conversation

@juimonen
Copy link

No description provided.

@juimonen juimonen force-pushed the ssp_zephyr_stub branch 2 times, most recently from 8c94447 to 6d8c379 Compare April 26, 2022 12:13
Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

I don't understand what the first of the two commits - the merge commit - in this PR is doing, hopefully it's really something that's needed here. The approval is to the actual commit with code

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: ssp-zephyr-shim.c

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, Liam has a better solution: #5727 (review)

Copy link
Author

Choose a reason for hiding this comment

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

hmm ok, let me check if I can do something like that

src/lib/dai.c Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

What if dai_get_zephyr returns NULL? Currently the flow will go through non-zephyr dai creation. I think we rather should return NULL here.

Copy link
Author

Choose a reason for hiding this comment

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

the problem is that in this transient period we have drivers both in zephyr and xtos side. So even if ZEPHYR is defined, we might have only like ssp and alh in zephyr. So the dai_get_zephyr will check the type and not do anything if driver is noton zephyr side.

@juimonen juimonen force-pushed the ssp_zephyr_stub branch 4 times, most recently from dec7307 to 1e4e93e Compare May 4, 2022 05:59
src/audio/dai.c Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

why and what the op postfix means? Would it sound better if they are postfixed instead with sof?
dai_trigger -> sof_dai_trigger

nitpick

Copy link
Collaborator

Choose a reason for hiding this comment

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

...and you already use dai_*_xtos(), so why not use "xtos" everywhere? And I agree with @ujfalusi - a prefix seems both more common and more logical - you usually go from the least to the most specific part. I.e. "xtos" is the least specific part, "dai" is the next level, and the actual operation is the most specific part

Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be a naming challenges we can't win.

I wonder if it'd be cleaner to rename the public "dai.h" to have "sof_" prefix, and then just have different implementations for this in src/lib/dai.c.

Copy link
Author

Choose a reason for hiding this comment

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

yeah totally fine with that, will try and see

src/lib/dai.c Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

For minimized #ifdef __ZEPHYR__ I would have the dai_get(uint32_t type, uint32_t index, uint32_t flags) ifdefed.
Or use the same name for the sub dai_get / dai_put OS dependent implementation, but the naming can get funny...
os_dai_get / dai_get_from_os / ...

@juimonen juimonen force-pushed the ssp_zephyr_stub branch 2 times, most recently from 758d12d to a8d81d7 Compare June 13, 2022 18:29
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

this could be made static inline (if Zephyr) and go away ?

@lgirdwood
Copy link
Member

@juimonen one other thing, it would be good to add inline TODO comments in these files where we have future Zephyr integration to help align everyone.

@XiaoyunWu6666
Copy link
Contributor

SOFCI TEST

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Started the review, but didn't have time to complete. Will resume.

@juimonen juimonen force-pushed the ssp_zephyr_stub branch 2 times, most recently from fd19609 to 3b4319f Compare June 14, 2022 17:29
@juimonen
Copy link
Author

@juimonen one other thing, it would be good to add inline TODO comments in these files where we have future Zephyr integration to help align everyone.

@lgirdwood... I'm not seeing currently obvious TODO in files changed in this PR... for example lib/dma.c should be changed to similar mechanism than here with dai. That might effect some of the struct members in this PR, but can't really say for sure in some TODO.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Looks good. I think further improvements to dai-zephyr.h are better done in follow-up PRs.

src/lib/dai.c Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: I think this could be a good actual usage of an assert to check that strlen of drv_name is sufficient.

Copy link
Author

Choose a reason for hiding this comment

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

oh, something is missing as I changed this to Liams suggerstion.... hold on for awhile

Copy link
Author

Choose a reason for hiding this comment

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

@kv2019i I screwed up yesterday with git reset... now includes the "dai array" changes suggested by Liam for this part of the code... apologies

@juimonen juimonen force-pushed the ssp_zephyr_stub branch 2 times, most recently from 30b2ea1 to d16ad08 Compare June 15, 2022 12:43
This patch adds a mechanism to load and use dai driver from zephyr
instead of xtos driver.

Patch includes following changes:
- dai-zephyr.c calls directly zephyr driver methods
- include/lib/dai.h is divided into dai-legacy.h and dai-zephyr.h
- use zephyr dais by configuring CONFIG_ZEPHYR_NATIVE_DRIVERS=y

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
@juimonen juimonen force-pushed the ssp_zephyr_stub branch 2 times, most recently from 9aeab38 to cd90420 Compare June 15, 2022 15:16
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Some logging could be added later. @abonislawski @marcinszkudlinski @ArsenEloglian any comments ?

group->group_id = 0;
}

#if CONFIG_ZEPHYR_NATIVE_DRIVERS
Copy link
Member

Choose a reason for hiding this comment

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

@juimonen @ArsenEloglian it seems like future steps are to split lib/dai.c into legacy and Zephyr versions. For another PR though...

{"SSP_", {
.type = SOF_DAI_INTEL_SSP,
.dma_dev = DMA_DEV_SSP,
.dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP,
Copy link
Member

Choose a reason for hiding this comment

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

I supose these caps are not needed for Zephyr (as the Zephyr driver will probably know via DT which memory) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is interesting thing. Currently we still need this as our dma_get() API is asking for a DMA instance that matches a given filter and the filter includes "caps". Zephyr DT described HW capabilities, but the lookup code is still on SOF side in src/lib/dma.c and database is filled in src/platform/intel/cavs/lib/dma.c . The latter could be filled directly from Zephyr, but some lookup logic is still needed.

But indeed, @juimonen and @ArsenEloglian , I guess we could leave "dma_caps==0" here when doing dma_get() for native Zephyr drivers. The caps checks will be skipped and DMA is chosen based on dma_dev alone. But this seems good enough. Zephyr drivers don't need this info, this is only to select the DMA instance.


drv = device_get_binding(dai_name);
if (!drv)
return NULL;
Copy link
Member

Choose a reason for hiding this comment

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

shall we tell the user in the logs ?

}

if (!found)
return NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Log the error ?

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Still good to go, but do check the dai_info_table comment. Maybe we can drop the "dma_caps" from the dai query.

{"SSP_", {
.type = SOF_DAI_INTEL_SSP,
.dma_dev = DMA_DEV_SSP,
.dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is interesting thing. Currently we still need this as our dma_get() API is asking for a DMA instance that matches a given filter and the filter includes "caps". Zephyr DT described HW capabilities, but the lookup code is still on SOF side in src/lib/dma.c and database is filled in src/platform/intel/cavs/lib/dma.c . The latter could be filled directly from Zephyr, but some lookup logic is still needed.

But indeed, @juimonen and @ArsenEloglian , I guess we could leave "dma_caps==0" here when doing dma_get() for native Zephyr drivers. The caps checks will be skipped and DMA is chosen based on dma_dev alone. But this seems good enough. Zephyr drivers don't need this info, this is only to select the DMA instance.

@lgirdwood lgirdwood merged commit 015ec63 into thesofproject:main Jun 16, 2022
@marc-hb
Copy link
Collaborator

marc-hb commented Jul 6, 2022

As discovered by @deb-intel, the duplication between dai-legacy.h and dai-zephyr.h broke sof-docs:

@juimonen can you please remove all the doxygen duplication? (The duplication of code is fine, the docs don't care about that)

@marc-hb
Copy link
Collaborator

marc-hb commented Jul 6, 2022

Why no dai-common.h?

@lgirdwood
Copy link
Member

Why no dai-common.h?

This is in plan for @juimonen @ArsenEloglian @abonislawski

marc-hb added a commit to marc-hb/sof that referenced this pull request Jul 6, 2022
From time to time sof-docs regressions are introduced in sof.git. This
introduces a random and sometimes long delay between when the regression
is introduced and when it is found. A recent example is
thesofproject#5731 (comment)
where the doxygen comments were duplicated. Doxygen alone did not mind,
then the sof-docs build failed much later which took multiple people a
lot of time to understand and bisect.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
lgirdwood pushed a commit that referenced this pull request Jul 6, 2022
From time to time sof-docs regressions are introduced in sof.git. This
introduces a random and sometimes long delay between when the regression
is introduced and when it is found. A recent example is
#5731 (comment)
where the doxygen comments were duplicated. Doxygen alone did not mind,
then the sof-docs build failed much later which took multiple people a
lot of time to understand and bisect.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
marc-hb added a commit to marc-hb/sof that referenced this pull request Jul 6, 2022
This fixes the sof-docs build and stops producing a dai-drivers-api.html
garbage that randomly mixed the two .h files.

```
Warning: Duplicate target detected:
    group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910
sof-docs/api/dai-drivers-api.rst:4: WARNING: Duplicate ID:
   "group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910".
sof-docs/api/dai-drivers-api.rst:4: WARNING: Duplicate explicit target name:
   "group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910".

sof/sof-docs/api/dai-drivers-api.rst:6: WARNING:
  Duplicate declaration, const struct device* dai::drv
```

(Temporarily?) fixes commit 015ec63 ("zephyr: add glue code to
use zephyr dai drivers") that introduced a lot of duplication with
dai-zephyr.h. See more details at
thesofproject#5731 (comment)

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb
Copy link
Collaborator

marc-hb commented Jul 6, 2022

Just learned @juimonen is on vacation. 2-lines fix/workaround submitted at:

This simply excludes dai-legacy.h from doxygen instead of randomly mixing both; good enough for now.

lgirdwood pushed a commit that referenced this pull request Jul 7, 2022
This fixes the sof-docs build and stops producing a dai-drivers-api.html
garbage that randomly mixed the two .h files.

```
Warning: Duplicate target detected:
    group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910
sof-docs/api/dai-drivers-api.rst:4: WARNING: Duplicate ID:
   "group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910".
sof-docs/api/dai-drivers-api.rst:4: WARNING: Duplicate explicit target name:
   "group__sof__dai__drivers_1ga8c720c310f408b2f97ce014562d6a910".

sof/sof-docs/api/dai-drivers-api.rst:6: WARNING:
  Duplicate declaration, const struct device* dai::drv
```

(Temporarily?) fixes commit 015ec63 ("zephyr: add glue code to
use zephyr dai drivers") that introduced a lot of duplication with
dai-zephyr.h. See more details at
#5731 (comment)

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
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.

10 participants