linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Patrik Jakobsson" <patrik.r.jakobsson@gmail.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Dave Hansen" <dave.hansen@intel.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Dan Williams" <dan.j.williams@intel.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Eric Biggers" <ebiggers@kernel.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"David Howells" <dhowells@redhat.com>, "Chris Mason" <clm@fb.com>,
	"Josef Bacik" <josef@toxicpanda.com>,
	"David Sterba" <dsterba@suse.com>,
	"Steve French" <sfrench@samba.org>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"Chao Yu" <yuchao0@huawei.com>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Brian King" <brking@us.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 03/17] drivers/gpu: Convert to mem*_page()
Date: Fri, 4 Dec 2020 08:05:04 -0800	[thread overview]
Message-ID: <20201204160504.GH1563847@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <160648211578.10416.3269409785516897908@jlahtine-mobl.ger.corp.intel.com>

On Fri, Nov 27, 2020 at 03:01:56PM +0200, Joonas Lahtinen wrote:
> + intel-gfx mailing list
> 
> Quoting ira.weiny@intel.com (2020-11-24 08:07:41)
> > From: Ira Weiny <ira.weiny@intel.com>
> > 
> > The pattern of kmap/mem*/kunmap is repeated.  Use the new mem*_page()
> > calls instead.
> > 
> > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> > ---
> >  drivers/gpu/drm/gma500/gma_display.c      | 7 +++----
> >  drivers/gpu/drm/gma500/mmu.c              | 4 ++--
> >  drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++----
> >  drivers/gpu/drm/i915/gt/intel_gtt.c       | 9 ++-------
> >  drivers/gpu/drm/i915/gt/shmem_utils.c     | 8 +++-----
> 
> Are you looking to merge all these from the same tree, or first merge
> the first patch and then trickle the rest through their own trees?

I was thinking that they would go through Andrew's tree in bulk.  But as I go
through all the 'variants' including adding any kmap_atomic() variants it is
getting to be a pretty big change.  I'm trying to use Coccinelle but I'm not
100% confident in it working, more precisely in my skill to make it work.

So I think I'm going to submit the base patch to Andrew today (with some
cleanups per the comments in this thread).

If Andrew could land that then I will can submit separate patches to each
subsystem which would get full testing...  :-(

That is best.

Thanks for making me think on this,
Ira

> Our last -next PR was already sent for i915, so I would queue this
> only for 5.12.
> 
> In any case, if you could split the i915 changes to a separate patch
> (we have multiple sub-trees in drm), those are:
> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> The gma500 changes also appear correct, so feel free to apply the
> R-b for those, too.
> 
> Regards, Joonas
> 
> >  5 files changed, 12 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> > index 3df6d6e850f5..f81114594211 100644
> > --- a/drivers/gpu/drm/gma500/gma_display.c
> > +++ b/drivers/gpu/drm/gma500/gma_display.c
> > @@ -9,6 +9,7 @@
> >  
> >  #include <linux/delay.h>
> >  #include <linux/highmem.h>
> > +#include <linux/pagemap.h>
> >  
> >  #include <drm/drm_crtc.h>
> >  #include <drm/drm_fourcc.h>
> > @@ -334,7 +335,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
> >         struct gtt_range *gt;
> >         struct gtt_range *cursor_gt = gma_crtc->cursor_gt;
> >         struct drm_gem_object *obj;
> > -       void *tmp_dst, *tmp_src;
> > +       void *tmp_dst;
> >         int ret = 0, i, cursor_pages;
> >  
> >         /* If we didn't get a handle then turn the cursor off */
> > @@ -400,9 +401,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
> >                 /* Copy the cursor to cursor mem */
> >                 tmp_dst = dev_priv->vram_addr + cursor_gt->offset;
> >                 for (i = 0; i < cursor_pages; i++) {
> > -                       tmp_src = kmap(gt->pages[i]);
> > -                       memcpy(tmp_dst, tmp_src, PAGE_SIZE);
> > -                       kunmap(gt->pages[i]);
> > +                       memcpy_from_page(tmp_dst, gt->pages[i], 0, PAGE_SIZE);
> >                         tmp_dst += PAGE_SIZE;
> >                 }
> >  
> > diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
> > index 505044c9a673..8a0856c7f439 100644
> > --- a/drivers/gpu/drm/gma500/mmu.c
> > +++ b/drivers/gpu/drm/gma500/mmu.c
> > @@ -5,6 +5,7 @@
> >   **************************************************************************/
> >  
> >  #include <linux/highmem.h>
> > +#include <linux/pagemap.h>
> >  
> >  #include "mmu.h"
> >  #include "psb_drv.h"
> > @@ -204,8 +205,7 @@ struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
> >  
> >         kunmap(pd->p);
> >  
> > -       clear_page(kmap(pd->dummy_page));
> > -       kunmap(pd->dummy_page);
> > +       memzero_page(pd->dummy_page, 0, PAGE_SIZE);
> >  
> >         pd->tables = vmalloc_user(sizeof(struct psb_mmu_pt *) * 1024);
> >         if (!pd->tables)
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > index 75e8b71c18b9..8a25e08edd18 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > @@ -558,7 +558,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv,
> >         do {
> >                 unsigned int len = min_t(typeof(size), size, PAGE_SIZE);
> >                 struct page *page;
> > -               void *pgdata, *vaddr;
> > +               void *pgdata;
> >  
> >                 err = pagecache_write_begin(file, file->f_mapping,
> >                                             offset, len, 0,
> > @@ -566,9 +566,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv,
> >                 if (err < 0)
> >                         goto fail;
> >  
> > -               vaddr = kmap(page);
> > -               memcpy(vaddr, data, len);
> > -               kunmap(page);
> > +               memcpy_to_page(page, 0, data, len);
> >  
> >                 err = pagecache_write_end(file, file->f_mapping,
> >                                           offset, len, len,
> > diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.c b/drivers/gpu/drm/i915/gt/intel_gtt.c
> > index 3f1114b58b01..f3d7c601d362 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_gtt.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_gtt.c
> > @@ -153,13 +153,8 @@ static void poison_scratch_page(struct drm_i915_gem_object *scratch)
> >         if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
> >                 val = POISON_FREE;
> >  
> > -       for_each_sgt_page(page, sgt, scratch->mm.pages) {
> > -               void *vaddr;
> > -
> > -               vaddr = kmap(page);
> > -               memset(vaddr, val, PAGE_SIZE);
> > -               kunmap(page);
> > -       }
> > +       for_each_sgt_page(page, sgt, scratch->mm.pages)
> > +               memset_page(page, val, 0, PAGE_SIZE);
> >  }
> >  
> >  int setup_scratch_page(struct i915_address_space *vm)
> > diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
> > index f011ea42487e..2d5f1f2e803d 100644
> > --- a/drivers/gpu/drm/i915/gt/shmem_utils.c
> > +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
> > @@ -95,19 +95,17 @@ static int __shmem_rw(struct file *file, loff_t off,
> >                 unsigned int this =
> >                         min_t(size_t, PAGE_SIZE - offset_in_page(off), len);
> >                 struct page *page;
> > -               void *vaddr;
> >  
> >                 page = shmem_read_mapping_page_gfp(file->f_mapping, pfn,
> >                                                    GFP_KERNEL);
> >                 if (IS_ERR(page))
> >                         return PTR_ERR(page);
> >  
> > -               vaddr = kmap(page);
> >                 if (write)
> > -                       memcpy(vaddr + offset_in_page(off), ptr, this);
> > +                       memcpy_to_page(page, offset_in_page(off), ptr, this);
> >                 else
> > -                       memcpy(ptr, vaddr + offset_in_page(off), this);
> > -               kunmap(page);
> > +                       memcpy_from_page(ptr, page, offset_in_page(off), this);
> > +
> >                 put_page(page);
> >  
> >                 len -= this;
> > -- 
> > 2.28.0.rc0.12.gb6a658bd00c9
> > 

  parent reply	other threads:[~2020-12-04 16:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24  6:07 [PATCH 00/17] kmap: Create mem*_page interfaces ira.weiny
2020-11-24  6:07 ` [PATCH 01/17] mm/highmem: Lift memcpy_[to|from]_page and memset_page to core ira.weiny
2020-11-24 14:19   ` Matthew Wilcox
2020-11-24 19:21     ` Ira Weiny
2020-11-24 20:20       ` Matthew Wilcox
     [not found]   ` <160648238432.10416.12405581766428273347@jlahtine-mobl.ger.corp.intel.com>
2020-11-27 13:20     ` Matthew Wilcox
     [not found]       ` <160672815223.3453.2374529656870007787@jlahtine-mobl.ger.corp.intel.com>
2020-12-03 18:25         ` Ira Weiny
2020-11-24  6:07 ` [PATCH 02/17] drivers/firmware_loader: Use new memcpy_[to|from]_page() ira.weiny
2020-11-24  6:07 ` [PATCH 03/17] drivers/gpu: Convert to mem*_page() ira.weiny
     [not found]   ` <160648211578.10416.3269409785516897908@jlahtine-mobl.ger.corp.intel.com>
2020-12-04 16:05     ` Ira Weiny [this message]
2020-12-04 22:33       ` Thomas Gleixner
2020-12-07  6:46         ` Ira Weiny
2020-12-07 16:19           ` Thomas Gleixner
2020-11-24  6:07 ` [PATCH 04/17] fs/afs: Convert to memzero_page() ira.weiny
2020-11-24  6:07 ` [PATCH 05/17] fs/btrfs: " ira.weiny
2020-11-24 14:12   ` David Sterba
2020-11-24 19:25     ` Ira Weiny
2020-11-24  6:07 ` [PATCH 06/17] fs/hfs: Convert to mem*_page() interface ira.weiny
2020-11-24  6:07 ` [PATCH 07/17] fs/cifs: Convert to memcpy_page() ira.weiny
2020-11-24  6:07 ` [PATCH 08/17] fs/hfsplus: Convert to mem*_page() ira.weiny
2020-11-24  6:07 ` [PATCH 09/17] fs/f2fs: Remove f2fs_copy_page() ira.weiny
2020-11-25  3:27   ` Chao Yu
2020-11-24  6:07 ` [PATCH 10/17] fs/freevxfs: Use memcpy_to_page() ira.weiny
2020-11-24  6:07 ` [PATCH 11/17] fs/reiserfs: Use memcpy_from_page() ira.weiny
2020-11-24  6:07 ` [PATCH 12/17] fs/cramfs: " ira.weiny
2020-11-24 15:20   ` Nicolas Pitre
2020-11-24  6:07 ` [PATCH 13/17] drivers/target: Convert to mem*_page() ira.weiny
2020-11-24  6:07 ` [PATCH 14/17] drivers/scsi: Use memcpy_to_page() ira.weiny
2020-11-24  6:07 ` [PATCH 15/17] drivers/staging: Use memcpy_to/from_page() ira.weiny
2020-11-24  6:07 ` [PATCH 16/17] lib: Use mempcy_to/from_page() ira.weiny
2020-11-24  6:07 ` [PATCH 17/17] samples: Use memcpy_to/from_page() ira.weiny
2020-12-04 10:18 ` [PATCH 04/17] fs/afs: Convert to memzero_page() David Howells

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=20201204160504.GH1563847@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=brking@us.ibm.com \
    --cc=clm@fb.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@intel.com \
    --cc=dhowells@redhat.com \
    --cc=dsterba@suse.com \
    --cc=ebiggers@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jaegeuk@kernel.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jglisse@redhat.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=josef@toxicpanda.com \
    --cc=kwankhede@nvidia.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mcgrof@kernel.org \
    --cc=nico@fluxnic.net \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sfrench@samba.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yuchao0@huawei.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).