ASoC/SoundWire: add BTP/BRA prerequisites#4735
Merged
plbossart merged 9 commits intothesofproject:topic/sof-devfrom Dec 18, 2023
Merged
ASoC/SoundWire: add BTP/BRA prerequisites#4735plbossart merged 9 commits intothesofproject:topic/sof-devfrom
plbossart merged 9 commits intothesofproject:topic/sof-devfrom
Conversation
Likely a copy-paste error, wrong CONFIG used. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Export this helper so that we can report the DPIB position if the BPT DMA do not complete - this is very useful to see if the DMA started or gets stuck somehow with invalid bandwidth configurations. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
For some reason, we add an offset to the PDI, presumably to skip the PDI0 and PDI1 which are reserved for BPT. This code is however completely wrong and leads to an out-of-bounds access. We were just lucky so far since we used only a couple of PDIs and remained within the PDI array bounds. A Fixes: tag is not provided since there are no known platforms where the out-of-bounds would be accessed, and the initial code had problems as well. A follow-up patch completely removes this useless offset. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This offset is set to exactly zero and serves no purpose. Remove. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This is redundant with sdw_bus_params, and was never used. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The definitions for DP0 are missing a set of fields that are required to reuse the same configuration code as DPn. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The existing code sets the maximum address at 0x80000000, which is not completely accurate. The last 2 Gbytes are indeed reserved, but so are the 896 Mbytes just before. The maximum address which can be used with paging or BRA is 0x47FFFFFF per Table 131 of the SoundWire 1.2.1 specification. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
We have an existing debugfs files to read standard registers (DP0/SCP/DPn). This patch provides a more generic interface to ANY set of read/write contiguous registers in a peripheral device. In follow-up patches, this interface will be extended to use BRA transfers. The sequence is to use the following files added under the existing debugsfs directory for each peripheral device: command (write 0, read 1) num_bytes start_address firmware_file (only for writes) read_buffer (only for reads) Example for a read command - this checks the 6 bytes used for enumeration. cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/ echo 1 > command echo 6 > num_bytes echo 0x50 > start_address echo 1 > go cat read_buffer address 0x50 val 0x30 address 0x51 val 0x02 address 0x52 val 0x5d address 0x53 val 0x07 address 0x54 val 0x11 address 0x55 val 0x01 Example with a 2-byte firmware file written in DP0 address 0x22 od -x /lib/firmware/test_firmware 0000000 0a37 0000002 cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/ echo 0 > command echo 2 > num_bytes echo 0x22 > start_address echo "test_firmware" > firmware_file echo 1 > go cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/ echo 1 > command echo 2 > num_bytes echo 0x22 > start_address echo 1 > go cat read_buffer address 0x22 val 0x37 address 0x23 val 0x0a Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
bardliao
approved these changes
Dec 8, 2023
RanderWang
reviewed
Dec 8, 2023
| u32 bank_switch_timeout; | ||
| bool multi_link; | ||
| int hw_sync_min_links; | ||
| int stream_refcount; |
There was a problem hiding this comment.
refcount is native supported by Linux kernel. How about to use it ? It can help to decrease multi-thread risk
refcount_inc, refcount_set, refcount_dec_and_test.
Member
Author
There was a problem hiding this comment.
It's a good point @RanderWang, I initially planned to use the refcount helpers, but there's a protection:
sdw_master_rt_alloc() and sdw_master_rt_free() need to be called with bus_lock held, it's clearly written in the documentation and it's used this way.
I didn't see the need for additional protection.
Member
Author
There was a problem hiding this comment.
I will add a comment in the commit message to make this clear.
The notion of stream is by construction based on a multi-bus capability, to allow for aggregation of Peripheral devices or functions located on different segments. We currently count how many master_rt contexts are used by a stream, but we don't have the dual refcount of how many streams are allocated on a given bus. This refcount will be useful to check if BTP/BRA streams can be allocated. Note that the stream_refcount is modified in sdw_master_rt_alloc() and sdw_master_rt_free() which are both called with the bus_lock mutex held, so there's no need for refcount_ primitives for additional protection. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
0b2fd12 to
54b0b97
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR includes non-controversial patches that should be merged and sent upstream in this kernel cycle. The full set of BTP/BRA patches is still in PR #4679 and will have to wait for an RFC and further comments.
@bardliao @ujfalusi @ranj063 @RanderWang thanks for your comments.