Linux IOMMU Development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Dan Carpenter <error27@gmail.com>
Cc: iommu@lists.linux.dev
Subject: Re: [bug report] iommufd: Add a selftest
Date: Tue, 15 Nov 2022 09:25:07 -0400	[thread overview]
Message-ID: <Y3OTMwnYKWs7z8lj@ziepe.ca> (raw)
In-Reply-To: <Y3OK6DeM6X4q5JWO@kili>

On Tue, Nov 15, 2022 at 03:49:44PM +0300, Dan Carpenter wrote:
> Hello Jason Gunthorpe,
> 
> The patch 147393321d65: "iommufd: Add a selftest" from Nov 19, 2021,
> leads to the following Smatch static checker warning:
> 
> 	drivers/iommu/iommufd/selftest.c:160 mock_domain_map_pages()
> 	warn: use 'gfp' here instead of GFP_XXX?
> 
> drivers/iommu/iommufd/selftest.c
>    133  static int mock_domain_map_pages(struct iommu_domain *domain,
>    134                                   unsigned long iova, phys_addr_t paddr,
>    135                                   size_t pgsize, size_t pgcount, int prot,
>    136                                   gfp_t gfp, size_t *mapped)
>    137  {
>    138          struct mock_iommu_domain *mock =
>    139                  container_of(domain, struct mock_iommu_domain, domain);
>    140          unsigned long flags = MOCK_PFN_START_IOVA;
>    141          unsigned long start_iova = iova;
>    142  
>    143          /*
>    144           * xarray does not reliably work with fault injection because it does a
>    145           * retry allocation, so put our own failure point.
>    146           */
>    147          if (iommufd_should_fail())
>    148                  return -ENOENT;
>    149  
>    150          WARN_ON(iova % MOCK_IO_PAGE_SIZE);
>    151          WARN_ON(pgsize % MOCK_IO_PAGE_SIZE);
>    152          for (; pgcount; pgcount--) {
>    153                  size_t cur;
>    154  
>    155                  for (cur = 0; cur != pgsize; cur += MOCK_IO_PAGE_SIZE) {
>    156                          void *old;
>    157  
>    158                          if (pgcount == 1 && cur + MOCK_IO_PAGE_SIZE == pgsize)
>    159                                  flags = MOCK_PFN_LAST_IOVA;
>    160                          old = xa_store(&mock->pfns, iova / MOCK_IO_PAGE_SIZE,
>    161                                         xa_mk_value((paddr / MOCK_IO_PAGE_SIZE) |
>    162                                                     flags),
>    163                                         GFP_KERNEL);
>                                                ^^^^^^^^^^
> "gfp" isn't used anywhere so maybe it was intended here?

It is always GFP_KERNEL, but yes it can use that. I fixed it

Jason

      reply	other threads:[~2022-11-15 13:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 12:49 [bug report] iommufd: Add a selftest Dan Carpenter
2022-11-15 13:25 ` Jason Gunthorpe [this message]

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=Y3OTMwnYKWs7z8lj@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=error27@gmail.com \
    --cc=iommu@lists.linux.dev \
    /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