[Intel-gfx] [PATCH 24/29] drm/i915: Zero fill the request structure
John.C.Harrison at Intel.com
John.C.Harrison at Intel.com
Thu Oct 30 19:41:16 CET 2014
From: John Harrison <John.C.Harrison at Intel.com>
There is a general theory that kzmalloc is better/safer than kmalloc, especially
for interesting data structures. This change updates the request structure
allocation to be zero filled. That also means it is no longer necessary to
explicitly clear the 'complete' field.
For: VIZ-4377
Signed-off-by: John Harrison <John.C.Harrison at Intel.com>
---
drivers/gpu/drm/i915/intel_lrc.c | 3 +--
drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 2c984a4..02eeff5 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -802,13 +802,12 @@ static int logical_ring_alloc_request(struct intel_engine_cs *ring,
if (ring->outstanding_lazy_request)
return 0;
- request = kmalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
if (request == NULL)
return -ENOMEM;
kref_init(&request->ref);
request->ring = ring;
- request->complete = false;
ret = i915_gem_get_seqno(ring->dev, &request->seqno);
if (ret) {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b5e03d9..04c9572 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2033,13 +2033,12 @@ intel_ring_alloc_request(struct intel_engine_cs *ring)
if (ring->outstanding_lazy_request)
return 0;
- request = kmalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
if (request == NULL)
return -ENOMEM;
kref_init(&request->ref);
request->ring = ring;
- request->complete = false;
ret = i915_gem_get_seqno(ring->dev, &request->seqno);
if (ret) {
--
1.7.9.5
More information about the Intel-gfx
mailing list