From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/2] drm/i915: Warn in debug builds of incorrect usages of ptr_pack_bits
Date: Tue, 31 Oct 2017 10:23:26 +0000 [thread overview]
Message-ID: <20171031102326.9738-2-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20171031102326.9738-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
GEM_BUG_ON if the packed bits do not fit into the specified width.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
drivers/gpu/drm/i915/i915_utils.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index af3d7cc53fa1..6a6b497b7dca 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -83,8 +83,10 @@
(typeof(ptr))(__v & -BIT(n)); \
})
-#define ptr_pack_bits(ptr, bits, n) \
- ((typeof(ptr))((unsigned long)(ptr) | (bits)))
+#define ptr_pack_bits(ptr, bits, n) ({ \
+ GEM_BUG_ON((bits) & -BIT(n)); \
+ ((typeof(ptr))((unsigned long)(ptr) | (bits))); \
+})
#define page_mask_bits(ptr) ptr_mask_bits(ptr, PAGE_SHIFT)
#define page_unmask_bits(ptr) ptr_unmask_bits(ptr, PAGE_SHIFT)
--
2.9.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-10-31 10:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 10:23 [PATCH 1/2] drm/i915: Reject unknown syncobj flags Tvrtko Ursulin
2017-10-31 10:23 ` Tvrtko Ursulin [this message]
2017-11-01 14:37 ` [PATCH 2/2] drm/i915: Warn in debug builds of incorrect usages of ptr_pack_bits Chris Wilson
2017-11-02 10:16 ` [PATCH v2 " Tvrtko Ursulin
2017-11-03 9:05 ` [PATCH v3 " Tvrtko Ursulin
2017-11-03 9:50 ` Chris Wilson
2017-10-31 10:52 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Reject unknown syncobj flags Patchwork
2017-10-31 12:04 ` ✓ Fi.CI.IGT: " Patchwork
2017-11-01 14:36 ` [PATCH 1/2] " Chris Wilson
2017-11-02 10:53 ` ✗ Fi.CI.BAT: failure for series starting with [1/2] drm/i915: Reject unknown syncobj flags (rev2) Patchwork
2017-11-02 11:23 ` Patchwork
2017-11-02 12:56 ` ✓ Fi.CI.BAT: success " Patchwork
2017-11-02 14:35 ` ✓ Fi.CI.IGT: " Patchwork
2017-11-03 9:25 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Reject unknown syncobj flags (rev3) Patchwork
2017-11-03 9:30 ` Tvrtko Ursulin
2017-11-03 10:12 ` ✓ Fi.CI.IGT: " Patchwork
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=20171031102326.9738-2-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=Intel-gfx@lists.freedesktop.org \
/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