linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.
@ 2020-02-05  5:43 Dan Carpenter
  2020-02-05  7:21 ` Wei Hu
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-02-05  5:43 UTC (permalink / raw)
  To: weh; +Cc: linux-hyperv

Hello Wei Hu,

The patch 3a6fb6c4255c: "video: hyperv: hyperv_fb: Use physical
memory for fb on HyperV Gen 1 VMs." from Dec 9, 2019, leads to the
following static checker warning:

	drivers/video/fbdev/hyperv_fb.c:991 hvfb_get_phymem()
	error: 'vmem' came from dma_alloc_coherent() so we can't do virt_to_phys()

drivers/video/fbdev/hyperv_fb.c
   960  static phys_addr_t hvfb_get_phymem(struct hv_device *hdev,
   961                                     unsigned int request_size)
   962  {
   963          struct page *page = NULL;
   964          dma_addr_t dma_handle;
   965          void *vmem;
   966          phys_addr_t paddr = 0;
   967          unsigned int order = get_order(request_size);
   968  
   969          if (request_size == 0)
   970                  return -1;
   971  
   972          if (order < MAX_ORDER) {
   973                  /* Call alloc_pages if the size is less than 2^MAX_ORDER */
   974                  page = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
   975                  if (!page)
   976                          return -1;
   977  
   978                  paddr = (page_to_pfn(page) << PAGE_SHIFT);
   979          } else {
   980                  /* Allocate from CMA */
   981                  hdev->device.coherent_dma_mask = DMA_BIT_MASK(64);
   982  
   983                  vmem = dma_alloc_coherent(&hdev->device,
   984                                            round_up(request_size, PAGE_SIZE),
   985                                            &dma_handle,
   986                                            GFP_KERNEL | __GFP_NOWARN);
   987  
   988                  if (!vmem)
   989                          return -1;
   990  
   991                  paddr = virt_to_phys(vmem);

Pretty straight forward that the static checker is right but I can't
give you any hints how to fix it.

   992          }
   993  
   994          return paddr;
   995  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-05 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05  5:43 [bug report] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs Dan Carpenter
2020-02-05  7:21 ` Wei Hu
2020-02-05  8:07   ` Dan Carpenter
2020-02-05 11:33     ` Wei Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).