[Intel-gfx] [PATCH] drm/i915: Consolidate checks for memcpy-from-wc support

Chris Wilson chris at chris-wilson.co.uk
Wed Dec 7 16:04:37 UTC 2016


In order to silence sparse:

../drivers/gpu/drm/i915/i915_gpu_error.c:200:39: warning: Using plain integer as NULL pointer

add a helper to check whether we have sse4.1 and that the desired
alignment is valid for acceleration.

Reported-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c     | 2 +-
 drivers/gpu/drm/i915/i915_drv.h            | 3 +++
 drivers/gpu/drm/i915/i915_gpu_error.c      | 2 +-
 drivers/gpu/drm/i915/i915_guc_submission.c | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
index ebeb13ba81d7..9f52fef5c76a 100644
--- a/drivers/gpu/drm/i915/i915_cmd_parser.c
+++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
@@ -1076,7 +1076,7 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
 
 	src = ERR_PTR(-ENODEV);
 	if (src_needs_clflush &&
-	    i915_memcpy_from_wc((void *)(uintptr_t)batch_start_offset, NULL, 0)) {
+	    i915_has_memcpy_from_wc((uintptr_t)batch_start_offset)) {
 		src = i915_gem_object_pin_map(src_obj, I915_MAP_WC);
 		if (!IS_ERR(src)) {
 			i915_memcpy_from_wc(dst,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d455e9b22388..0746d5574044 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3913,6 +3913,9 @@ __i915_request_irq_complete(const struct drm_i915_gem_request *req)
 void i915_memcpy_init_early(struct drm_i915_private *dev_priv);
 bool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len);
 
+#define i915_has_memcpy_from_wc(align) \
+	i915_memcpy_from_wc((void *)(align), NULL, 0)
+
 /* i915_mm.c */
 int remap_io_mapping(struct vm_area_struct *vma,
 		     unsigned long addr, unsigned long pfn, unsigned long size,
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index a3f90536c38e..25909bff2790 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -197,7 +197,7 @@ static bool compress_init(struct compress *c)
 	}
 
 	c->tmp = NULL;
-	if (i915_memcpy_from_wc(NULL, 0, 0))
+	if (i915_has_memcpy_from_wc(0))
 		c->tmp = (void *)__get_free_page(GFP_ATOMIC | __GFP_NOWARN);
 
 	return true;
diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index e3bca814aaf9..24c0b0d543cc 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -1224,7 +1224,7 @@ static void guc_log_create(struct intel_guc *guc)
 		 * it should be present on the chipsets supporting GuC based
 		 * submisssions.
 		 */
-		if (WARN_ON(!i915_memcpy_from_wc(NULL, NULL, 0))) {
+		if (WARN_ON(!i915_has_memcpy_from_wc(0))) {
 			/* logging will not be enabled */
 			i915.guc_log_level = -1;
 			return;
-- 
2.11.0



More information about the Intel-gfx mailing list