Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <linux/firmware.h>
#include <linux/module.h>
#include <asm/unaligned.h>
#include <sound/soc.h>
#include <sound/sof.h>
#include "sof-priv.h"
Expand Down Expand Up @@ -215,16 +216,31 @@ int snd_sof_create_page_table(struct snd_sof_dev *sdev,
*/
u32 idx = (5 * i) >> 1;
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
u32 *pg_table;
u8 *pg_table;

dev_vdbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);

pg_table = (u32 *)(page_table + idx);
pg_table = (u8 *)(page_table + idx);

/*

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.

The commit is super nice! One thing if you can do is: explain why the compression is needed for readers who will try to understand the code later.

* pagetable compression:
* byte 0 byte 1 byte 2 byte 3 byte 4 byte 5
* ___________pfn 0__________ __________pfn 1___________ _pfn 2...
* .... .... .... .... .... .... .... .... .... .... ....
* It is created by:
* 1. set current location to 0, PFN index i to 0
* 2. put pfn[i] at current location in Little Endian byte order
* 3. calculate an intermediate value as
* x = (pfn[i+1] << 4) | (pfn[i] & 0xf)
* 4. put x at offset (current location + 2) in LE byte order
* 5. increment current location by 5 bytes, increment i by 2
* 6. continue to (1)
*/
if (i & 1)
*pg_table |= (pfn << 4);
put_unaligned_le32((pg_table[0] & 0xf) | pfn << 4,
pg_table);
else
*pg_table |= pfn;
put_unaligned_le32(pfn, pg_table);
}

return pages;
Expand Down