From: Christoph Hellwig <hch@lst.de>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Intel Linux Wireless <linuxwifi@intel.com>,
linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT),
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
linux-rdma@vger.kernel.org, linux-media@vger.kernel.org,
netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
linux-s390@vger.kernel.org, devel@driverdev.osuosl.org,
linux-mm@kvack.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 03/16] drm/i915: stop using drm_pci_alloc
Date: Fri, 14 Jun 2019 15:47:13 +0200 [thread overview]
Message-ID: <20190614134726.3827-4-hch@lst.de> (raw)
In-Reply-To: <20190614134726.3827-1-hch@lst.de>
Remove usage of the legacy drm PCI DMA wrappers, and with that the
incorrect usage cocktail of __GFP_COMP, virt_to_page on DMA allocation
and SetPageReserved.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/drm/i915/i915_gem.c | 30 +++++++++++++-------------
drivers/gpu/drm/i915/i915_gem_object.h | 3 ++-
drivers/gpu/drm/i915/intel_display.c | 2 +-
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ad01c92aaf74..8f2053c91aff 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -228,7 +228,6 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
static int i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
{
struct address_space *mapping = obj->base.filp->f_mapping;
- drm_dma_handle_t *phys;
struct sg_table *st;
struct scatterlist *sg;
char *vaddr;
@@ -242,13 +241,13 @@ static int i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
* to handle all possible callers, and given typical object sizes,
* the alignment of the buddy allocation will naturally match.
*/
- phys = drm_pci_alloc(obj->base.dev,
- roundup_pow_of_two(obj->base.size),
- roundup_pow_of_two(obj->base.size));
- if (!phys)
+ obj->phys_vaddr = dma_alloc_coherent(&obj->base.dev->pdev->dev,
+ roundup_pow_of_two(obj->base.size),
+ &obj->phys_handle, GFP_KERNEL);
+ if (!obj->phys_vaddr)
return -ENOMEM;
- vaddr = phys->vaddr;
+ vaddr = obj->phys_vaddr;
for (i = 0; i < obj->base.size / PAGE_SIZE; i++) {
struct page *page;
char *src;
@@ -286,18 +285,17 @@ static int i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
sg->offset = 0;
sg->length = obj->base.size;
- sg_dma_address(sg) = phys->busaddr;
+ sg_dma_address(sg) = obj->phys_handle;
sg_dma_len(sg) = obj->base.size;
- obj->phys_handle = phys;
-
__i915_gem_object_set_pages(obj, st, sg->length);
return 0;
err_phys:
- drm_pci_free(obj->base.dev, phys);
-
+ dma_free_coherent(&obj->base.dev->pdev->dev,
+ roundup_pow_of_two(obj->base.size), obj->phys_vaddr,
+ obj->phys_handle);
return err;
}
@@ -335,7 +333,7 @@ i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
if (obj->mm.dirty) {
struct address_space *mapping = obj->base.filp->f_mapping;
- char *vaddr = obj->phys_handle->vaddr;
+ char *vaddr = obj->phys_vaddr;
int i;
for (i = 0; i < obj->base.size / PAGE_SIZE; i++) {
@@ -363,7 +361,9 @@ i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
sg_free_table(pages);
kfree(pages);
- drm_pci_free(obj->base.dev, obj->phys_handle);
+ dma_free_coherent(&obj->base.dev->pdev->dev,
+ roundup_pow_of_two(obj->base.size), obj->phys_vaddr,
+ obj->phys_handle);
}
static void
@@ -603,7 +603,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
struct drm_i915_gem_pwrite *args,
struct drm_file *file)
{
- void *vaddr = obj->phys_handle->vaddr + args->offset;
+ void *vaddr = obj->phys_vaddr + args->offset;
char __user *user_data = u64_to_user_ptr(args->data_ptr);
/* We manually control the domain here and pretend that it
@@ -1431,7 +1431,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
ret = i915_gem_gtt_pwrite_fast(obj, args);
if (ret == -EFAULT || ret == -ENOSPC) {
- if (obj->phys_handle)
+ if (obj->phys_vaddr)
ret = i915_gem_phys_pwrite(obj, args, file);
else
ret = i915_gem_shmem_pwrite(obj, args);
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index ca93a40c0c87..14bd2d61d0f6 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -290,7 +290,8 @@ struct drm_i915_gem_object {
};
/** for phys allocated objects */
- struct drm_dma_handle *phys_handle;
+ dma_addr_t phys_handle;
+ void *phys_vaddr;
struct reservation_object __builtin_resv;
};
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5098228f1302..4f8b368ac4e2 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -10066,7 +10066,7 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state)
u32 base;
if (INTEL_INFO(dev_priv)->display.cursor_needs_physical)
- base = obj->phys_handle->busaddr;
+ base = obj->phys_handle;
else
base = intel_plane_ggtt_offset(plane_state);
--
2.20.1
next prev parent reply other threads:[~2019-06-14 13:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 13:47 use exact allocation for dma coherent memory Christoph Hellwig
2019-06-14 13:47 ` [PATCH 01/16] media: videobuf-dma-contig: use dma_mmap_coherent Christoph Hellwig
2019-06-14 13:47 ` [PATCH 02/16] drm/ati_pcigart: stop using drm_pci_alloc Christoph Hellwig
2019-06-14 13:47 ` Christoph Hellwig [this message]
2019-06-14 16:45 ` [Intel-gfx] [PATCH 03/16] drm/i915: " Ville Syrjälä
2019-06-14 13:47 ` [PATCH 04/16] drm: move drm_pci_{alloc,free} to drm_legacy Christoph Hellwig
2019-06-14 13:47 ` [PATCH 05/16] drm: don't mark pages returned from drm_pci_alloc reserved Christoph Hellwig
2019-06-14 13:47 ` [PATCH 06/16] drm: don't pass __GFP_COMP to dma_alloc_coherent in drm_pci_alloc Christoph Hellwig
2019-06-14 13:47 ` [PATCH 07/16] IB/hfi1: stop passing bogus gfp flags arguments to dma_alloc_coherent Christoph Hellwig
2019-06-14 13:47 ` [PATCH 08/16] IB/qib: " Christoph Hellwig
2019-06-14 13:47 ` [PATCH 09/16] cnic: " Christoph Hellwig
2019-06-14 13:47 ` [PATCH 10/16] iwlwifi: " Christoph Hellwig
2019-06-14 13:47 ` [PATCH 11/16] s390/ism: " Christoph Hellwig
2019-06-14 13:47 ` [PATCH 12/16] staging/comedi: mark as broken Christoph Hellwig
2019-06-14 14:02 ` Greg KH
2019-06-14 14:48 ` Christoph Hellwig
2019-06-14 15:30 ` Greg KH
2019-06-14 15:34 ` Christoph Hellwig
2019-06-17 13:15 ` Ian Abbott
2019-06-14 13:47 ` [PATCH 13/16] mm: rename alloc_pages_exact_nid to alloc_pages_exact_node Christoph Hellwig
2019-06-14 13:47 ` [PATCH 14/16] mm: use alloc_pages_exact_node to implement alloc_pages_exact Christoph Hellwig
2019-06-14 13:47 ` [PATCH 15/16] dma-mapping: clear __GFP_COMP in dma_alloc_attrs Christoph Hellwig
2019-06-14 13:47 ` [PATCH 16/16] dma-mapping: use exact allocation in dma_alloc_contiguous Christoph Hellwig
2019-06-14 14:15 ` David Laight
2019-06-14 14:50 ` 'Christoph Hellwig'
2019-06-14 15:01 ` David Laight
2019-06-14 15:05 ` 'Christoph Hellwig'
2019-06-14 15:05 ` Robin Murphy
2019-06-14 15:08 ` 'Christoph Hellwig'
2019-06-14 15:16 ` David Laight
2019-06-17 8:21 ` use exact allocation for dma coherent memory Dan Carpenter
2019-06-17 8:33 ` Christoph Hellwig
2019-06-19 16:29 ` Jason Gunthorpe
2019-06-20 10:51 ` Christoph Hellwig
2019-07-01 8:48 ` Christoph Hellwig
2019-07-02 9:48 ` Arend Van Spriel
2019-07-08 18:43 ` Christoph Hellwig
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=20190614134726.3827-4-hch@lst.de \
--to=hch@lst.de \
--cc=abbotti@mev.co.uk \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=devel@driverdev.osuosl.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hsweeten@visionengravers.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linuxwifi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maxime.ripard@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=sean@poorly.run \
/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).