we seem to have a new 0-day report with randconfig related to the page/sgbuffer management. Not sure why it wasn't seen before, I've already fixed quite a few exotic configurations for non-Intel targets.
sound/soc/sof/core.c: In function 'snd_sof_create_page_table': sound/soc/sof/core.c:201:10: error: implicit declaration of function 'snd_sgbuf_aligned_pages' [-Werror=implicit-function-declaration] pages = snd_sgbuf_aligned_pages(size); ^ Looking at the code:
+static inline unsigned int sof_get_pages(size_t size) +{
- return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+}
this inline doesn't seem to be used but duplicates the code from
static inline unsigned int snd_sgbuf_aligned_pages(size_t size) { return (size + PAGE_SIZE - 1) >> PAGE_SHIFT; }
which is used below
+int snd_sof_create_page_table(struct snd_sof_dev *sdev,
struct snd_dma_buffer *dmab,
unsigned char *page_table, size_t size)
+{
- int i, pages;
- pages = snd_sgbuf_aligned_pages(size);
this code doesn't compile unless CONFIG_SND_DMA_SGBUF is defined (it is set for the intel-specific code but not for the SOF core). We can fix this in different ways 0. require SND_CMD_SGBUF for the core - likely not desirable 1. use sof_get_pages() 2. change include/sound/memalloc.h to make sure this snd_sgbuf_aligned_pages() inline is available whether CONFIG_SND_DMA_SGBUF is defined or not - maybe making sure while we are at it that the malloc and free functions are empty static inlines?
Thoughts? Thanks -Pierre
- dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
dmab->area, size, pages);
- for (i = 0; i < pages; i++) {
u32 idx = (((i << 2) + i)) >> 1;
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
u32 *pg_table;
dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
pg_table = (u32 *)(page_table + idx);
if (i & 1)
*pg_table |= (pfn << 4);
else
*pg_table |= pfn;
- }
- return pages;
+}