From: Dan Carpenter <dan.carpenter@oracle.com>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [bug report] ALSA: memalloc: Add fallback SG-buffer allocations for x86
Date: Wed, 20 Apr 2022 10:44:58 +0300 [thread overview]
Message-ID: <20220420074458.GA32681@kili> (raw)
Hello Takashi Iwai,
The patch 925ca893b4a6: "ALSA: memalloc: Add fallback SG-buffer
allocations for x86" from Apr 13, 2022, leads to the following Smatch
static checker warning:
sound/core/memalloc.c:732 snd_dma_sg_fallback_alloc()
error: 'p' came from dma_alloc_coherent() so we can't do virt_to_phys()
sound/core/memalloc.c
708 static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size)
709 {
710 struct snd_dma_sg_fallback *sgbuf;
711 struct page **pages;
712 size_t i, count;
713 void *p;
714
715 sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL);
716 if (!sgbuf)
717 return NULL;
718 count = PAGE_ALIGN(size) >> PAGE_SHIFT;
719 pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL);
720 if (!pages)
721 goto error;
722 sgbuf->pages = pages;
723 sgbuf->addrs = kvcalloc(count, sizeof(*sgbuf->addrs), GFP_KERNEL);
724 if (!sgbuf->addrs)
725 goto error;
726
727 for (i = 0; i < count; sgbuf->count++, i++) {
728 p = dma_alloc_coherent(dmab->dev.dev, PAGE_SIZE,
729 &sgbuf->addrs[i], DEFAULT_GFP);
730 if (!p)
731 goto error;
--> 732 sgbuf->pages[i] = virt_to_page(p);
The warning is a bit useless. It's complaining about __phys_addr()
and not virt_to_phys(). I don't really understand the rules here, it
might be legal in certain contexts.
733 }
734
735 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK)
736 set_pages_array_wc(pages, count);
737 p = vmap(pages, count, VM_MAP, PAGE_KERNEL);
738 if (!p)
739 goto error;
740 dmab->private_data = sgbuf;
741 return p;
742
regards,
dan carpenter
next reply other threads:[~2022-04-20 7:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 7:44 Dan Carpenter [this message]
2022-04-20 8:00 ` [bug report] ALSA: memalloc: Add fallback SG-buffer allocations for x86 Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220420074458.GA32681@kili \
--to=dan.carpenter@oracle.com \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.