linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Wei Hu <weh@microsoft.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: Re: [bug report] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.
Date: Wed, 5 Feb 2020 11:07:33 +0300	[thread overview]
Message-ID: <20200205080733.GU11068@kadam> (raw)
In-Reply-To: <SG2P153MB0380F76124DEE4F3728C056DBB020@SG2P153MB0380.APCP153.PROD.OUTLOOK.COM>


On Wed, Feb 05, 2020 at 07:21:31AM +0000, Wei Hu wrote:
> Hello Dan,
> 
> > -----Original Message-----> 
> > 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.
> > 
> 
> Thanks for reporting this. Would you let me know how I can reproduce this warning or
> Error message? The build on my side runs fine without such message.

Hm...  Sorry, I never publish this Smatch check.  I should do that.
Anyway HCH explains the rules a bit in this email:

https://lkml.org/lkml/2019/6/17/155

regards,
dan carpenter


  reply	other threads:[~2020-02-05  8:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-02-05 11:33     ` Wei Hu

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=20200205080733.GU11068@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=weh@microsoft.com \
    /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;
as well as URLs for NNTP newsgroup(s).