From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-media@vger.kernel.org
Cc: james.harper@ejbdigital.com.au
Subject: [bug report] [media] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready
Date: Thu, 27 Jun 2019 17:30:38 +0300 [thread overview]
Message-ID: <20190627143038.GA6394@mwanda> (raw)
Hi linux-media devs, this is similar to one of HCH's patches that
hasn't been applied yet.
The patch 7b4eeed174b7: "[media] vmalloc_sg: make sure all pages in
vmalloc area are really DMA-ready" from Jun 12, 2014, leads to the
following static checker warning:
drivers/media/v4l2-core/videobuf-dma-sg.c:236 videobuf_dma_init_kernel()
error: 'addr' came from dma_alloc_coherent() so we can't do virt_to_phys()
drivers/media/v4l2-core/videobuf-dma-sg.c
210 static int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
211 int nr_pages)
212 {
213 int i;
214
215 dprintk(1, "init kernel [%d pages]\n", nr_pages);
216
217 dma->direction = direction;
218 dma->vaddr_pages = kcalloc(nr_pages, sizeof(*dma->vaddr_pages),
219 GFP_KERNEL);
220 if (!dma->vaddr_pages)
221 return -ENOMEM;
222
223 dma->dma_addr = kcalloc(nr_pages, sizeof(*dma->dma_addr), GFP_KERNEL);
224 if (!dma->dma_addr) {
225 kfree(dma->vaddr_pages);
226 return -ENOMEM;
227 }
228 for (i = 0; i < nr_pages; i++) {
229 void *addr;
230
231 addr = dma_alloc_coherent(dma->dev, PAGE_SIZE,
^^^^^^^^^^^^^^^^^^^^^^^^^
232 &(dma->dma_addr[i]), GFP_KERNEL);
233 if (addr == NULL)
234 goto out_free_pages;
235
236 dma->vaddr_pages[i] = virt_to_page(addr);
^^^^^^^^^^^^^^^^^^
Apparently this isn't allowed.
237 }
238 dma->vaddr = vmap(dma->vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP,
239 PAGE_KERNEL);
240 if (NULL == dma->vaddr) {
241 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
242 goto out_free_pages;
243 }
244
245 dprintk(1, "vmalloc is at addr %p, size=%d\n",
246 dma->vaddr, nr_pages << PAGE_SHIFT);
247
248 memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
249 dma->nr_pages = nr_pages;
250
251 return 0;
252 out_free_pages:
253 while (i > 0) {
254 void *addr;
regards,
dan carpenter
reply other threads:[~2019-06-27 14:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190627143038.GA6394@mwanda \
--to=dan.carpenter@oracle.com \
--cc=james.harper@ejbdigital.com.au \
--cc=linux-media@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox