drm/i915: Drive request submission through fence callbacks
[cascardo/linux.git] / drivers / gpu / drm / i915 / i915_gem_request.h
1 /*
2  * Copyright © 2008-2015 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24
25 #ifndef I915_GEM_REQUEST_H
26 #define I915_GEM_REQUEST_H
27
28 #include <linux/fence.h>
29
30 #include "i915_gem.h"
31 #include "i915_sw_fence.h"
32
33 struct intel_wait {
34         struct rb_node node;
35         struct task_struct *tsk;
36         u32 seqno;
37 };
38
39 struct intel_signal_node {
40         struct rb_node node;
41         struct intel_wait wait;
42 };
43
44 /**
45  * Request queue structure.
46  *
47  * The request queue allows us to note sequence numbers that have been emitted
48  * and may be associated with active buffers to be retired.
49  *
50  * By keeping this list, we can avoid having to do questionable sequence
51  * number comparisons on buffer last_read|write_seqno. It also allows an
52  * emission time to be associated with the request for tracking how far ahead
53  * of the GPU the submission is.
54  *
55  * When modifying this structure be very aware that we perform a lockless
56  * RCU lookup of it that may race against reallocation of the struct
57  * from the slab freelist. We intentionally do not zero the structure on
58  * allocation so that the lookup can use the dangling pointers (and is
59  * cogniscent that those pointers may be wrong). Instead, everything that
60  * needs to be initialised must be done so explicitly.
61  *
62  * The requests are reference counted.
63  */
64 struct drm_i915_gem_request {
65         struct fence fence;
66         spinlock_t lock;
67
68         /** On Which ring this request was generated */
69         struct drm_i915_private *i915;
70
71         /**
72          * Context and ring buffer related to this request
73          * Contexts are refcounted, so when this request is associated with a
74          * context, we must increment the context's refcount, to guarantee that
75          * it persists while any request is linked to it. Requests themselves
76          * are also refcounted, so the request will only be freed when the last
77          * reference to it is dismissed, and the code in
78          * i915_gem_request_free() will then decrement the refcount on the
79          * context.
80          */
81         struct i915_gem_context *ctx;
82         struct intel_engine_cs *engine;
83         struct intel_ring *ring;
84         struct intel_signal_node signaling;
85
86         struct i915_sw_fence submit;
87
88         /** GEM sequence number associated with the previous request,
89          * when the HWS breadcrumb is equal to this the GPU is processing
90          * this request.
91          */
92         u32 previous_seqno;
93
94         /** Position in the ring of the start of the request */
95         u32 head;
96
97         /**
98          * Position in the ring of the start of the postfix.
99          * This is required to calculate the maximum available ring space
100          * without overwriting the postfix.
101          */
102         u32 postfix;
103
104         /** Position in the ring of the end of the whole request */
105         u32 tail;
106
107         /** Position in the ring of the end of any workarounds after the tail */
108         u32 wa_tail;
109
110         /** Preallocate space in the ring for the emitting the request */
111         u32 reserved_space;
112
113         /**
114          * Context related to the previous request.
115          * As the contexts are accessed by the hardware until the switch is
116          * completed to a new context, the hardware may still be writing
117          * to the context object after the breadcrumb is visible. We must
118          * not unpin/unbind/prune that object whilst still active and so
119          * we keep the previous context pinned until the following (this)
120          * request is retired.
121          */
122         struct i915_gem_context *previous_context;
123
124         /** Batch buffer related to this request if any (used for
125          * error state dump only).
126          */
127         struct i915_vma *batch;
128         struct list_head active_list;
129
130         /** Time at which this request was emitted, in jiffies. */
131         unsigned long emitted_jiffies;
132
133         /** engine->request_list entry for this request */
134         struct list_head link;
135
136         /** ring->request_list entry for this request */
137         struct list_head ring_link;
138
139         struct drm_i915_file_private *file_priv;
140         /** file_priv list entry for this request */
141         struct list_head client_list;
142
143         /** Link in the execlist submission queue, guarded by execlist_lock. */
144         struct list_head execlist_link;
145 };
146
147 extern const struct fence_ops i915_fence_ops;
148
149 static inline bool fence_is_i915(struct fence *fence)
150 {
151         return fence->ops == &i915_fence_ops;
152 }
153
154 struct drm_i915_gem_request * __must_check
155 i915_gem_request_alloc(struct intel_engine_cs *engine,
156                        struct i915_gem_context *ctx);
157 int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
158                                    struct drm_file *file);
159 void i915_gem_request_retire_upto(struct drm_i915_gem_request *req);
160
161 static inline u32
162 i915_gem_request_get_seqno(struct drm_i915_gem_request *req)
163 {
164         return req ? req->fence.seqno : 0;
165 }
166
167 static inline struct intel_engine_cs *
168 i915_gem_request_get_engine(struct drm_i915_gem_request *req)
169 {
170         return req ? req->engine : NULL;
171 }
172
173 static inline struct drm_i915_gem_request *
174 to_request(struct fence *fence)
175 {
176         /* We assume that NULL fence/request are interoperable */
177         BUILD_BUG_ON(offsetof(struct drm_i915_gem_request, fence) != 0);
178         GEM_BUG_ON(fence && !fence_is_i915(fence));
179         return container_of(fence, struct drm_i915_gem_request, fence);
180 }
181
182 static inline struct drm_i915_gem_request *
183 i915_gem_request_get(struct drm_i915_gem_request *req)
184 {
185         return to_request(fence_get(&req->fence));
186 }
187
188 static inline struct drm_i915_gem_request *
189 i915_gem_request_get_rcu(struct drm_i915_gem_request *req)
190 {
191         return to_request(fence_get_rcu(&req->fence));
192 }
193
194 static inline void
195 i915_gem_request_put(struct drm_i915_gem_request *req)
196 {
197         fence_put(&req->fence);
198 }
199
200 static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,
201                                            struct drm_i915_gem_request *src)
202 {
203         if (src)
204                 i915_gem_request_get(src);
205
206         if (*pdst)
207                 i915_gem_request_put(*pdst);
208
209         *pdst = src;
210 }
211
212 void __i915_add_request(struct drm_i915_gem_request *req, bool flush_caches);
213 #define i915_add_request(req) \
214         __i915_add_request(req, true)
215 #define i915_add_request_no_flush(req) \
216         __i915_add_request(req, false)
217
218 struct intel_rps_client;
219 #define NO_WAITBOOST ERR_PTR(-1)
220 #define IS_RPS_CLIENT(p) (!IS_ERR(p))
221 #define IS_RPS_USER(p) (!IS_ERR_OR_NULL(p))
222
223 int i915_wait_request(struct drm_i915_gem_request *req,
224                       unsigned int flags,
225                       s64 *timeout,
226                       struct intel_rps_client *rps)
227         __attribute__((nonnull(1)));
228 #define I915_WAIT_INTERRUPTIBLE BIT(0)
229 #define I915_WAIT_LOCKED        BIT(1) /* struct_mutex held, handle GPU reset */
230
231 static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine);
232
233 /**
234  * Returns true if seq1 is later than seq2.
235  */
236 static inline bool i915_seqno_passed(u32 seq1, u32 seq2)
237 {
238         return (s32)(seq1 - seq2) >= 0;
239 }
240
241 static inline bool
242 i915_gem_request_started(const struct drm_i915_gem_request *req)
243 {
244         return i915_seqno_passed(intel_engine_get_seqno(req->engine),
245                                  req->previous_seqno);
246 }
247
248 static inline bool
249 i915_gem_request_completed(const struct drm_i915_gem_request *req)
250 {
251         return i915_seqno_passed(intel_engine_get_seqno(req->engine),
252                                  req->fence.seqno);
253 }
254
255 bool __i915_spin_request(const struct drm_i915_gem_request *request,
256                          int state, unsigned long timeout_us);
257 static inline bool i915_spin_request(const struct drm_i915_gem_request *request,
258                                      int state, unsigned long timeout_us)
259 {
260         return (i915_gem_request_started(request) &&
261                 __i915_spin_request(request, state, timeout_us));
262 }
263
264 /* We treat requests as fences. This is not be to confused with our
265  * "fence registers" but pipeline synchronisation objects ala GL_ARB_sync.
266  * We use the fences to synchronize access from the CPU with activity on the
267  * GPU, for example, we should not rewrite an object's PTE whilst the GPU
268  * is reading them. We also track fences at a higher level to provide
269  * implicit synchronisation around GEM objects, e.g. set-domain will wait
270  * for outstanding GPU rendering before marking the object ready for CPU
271  * access, or a pageflip will wait until the GPU is complete before showing
272  * the frame on the scanout.
273  *
274  * In order to use a fence, the object must track the fence it needs to
275  * serialise with. For example, GEM objects want to track both read and
276  * write access so that we can perform concurrent read operations between
277  * the CPU and GPU engines, as well as waiting for all rendering to
278  * complete, or waiting for the last GPU user of a "fence register". The
279  * object then embeds a #i915_gem_active to track the most recent (in
280  * retirement order) request relevant for the desired mode of access.
281  * The #i915_gem_active is updated with i915_gem_active_set() to track the
282  * most recent fence request, typically this is done as part of
283  * i915_vma_move_to_active().
284  *
285  * When the #i915_gem_active completes (is retired), it will
286  * signal its completion to the owner through a callback as well as mark
287  * itself as idle (i915_gem_active.request == NULL). The owner
288  * can then perform any action, such as delayed freeing of an active
289  * resource including itself.
290  */
291 struct i915_gem_active;
292
293 typedef void (*i915_gem_retire_fn)(struct i915_gem_active *,
294                                    struct drm_i915_gem_request *);
295
296 struct i915_gem_active {
297         struct drm_i915_gem_request __rcu *request;
298         struct list_head link;
299         i915_gem_retire_fn retire;
300 };
301
302 void i915_gem_retire_noop(struct i915_gem_active *,
303                           struct drm_i915_gem_request *request);
304
305 /**
306  * init_request_active - prepares the activity tracker for use
307  * @active - the active tracker
308  * @func - a callback when then the tracker is retired (becomes idle),
309  *         can be NULL
310  *
311  * init_request_active() prepares the embedded @active struct for use as
312  * an activity tracker, that is for tracking the last known active request
313  * associated with it. When the last request becomes idle, when it is retired
314  * after completion, the optional callback @func is invoked.
315  */
316 static inline void
317 init_request_active(struct i915_gem_active *active,
318                     i915_gem_retire_fn retire)
319 {
320         INIT_LIST_HEAD(&active->link);
321         active->retire = retire ?: i915_gem_retire_noop;
322 }
323
324 /**
325  * i915_gem_active_set - updates the tracker to watch the current request
326  * @active - the active tracker
327  * @request - the request to watch
328  *
329  * i915_gem_active_set() watches the given @request for completion. Whilst
330  * that @request is busy, the @active reports busy. When that @request is
331  * retired, the @active tracker is updated to report idle.
332  */
333 static inline void
334 i915_gem_active_set(struct i915_gem_active *active,
335                     struct drm_i915_gem_request *request)
336 {
337         list_move(&active->link, &request->active_list);
338         rcu_assign_pointer(active->request, request);
339 }
340
341 static inline struct drm_i915_gem_request *
342 __i915_gem_active_peek(const struct i915_gem_active *active)
343 {
344         /* Inside the error capture (running with the driver in an unknown
345          * state), we want to bend the rules slightly (a lot).
346          *
347          * Work is in progress to make it safer, in the meantime this keeps
348          * the known issue from spamming the logs.
349          */
350         return rcu_dereference_protected(active->request, 1);
351 }
352
353 /**
354  * i915_gem_active_raw - return the active request
355  * @active - the active tracker
356  *
357  * i915_gem_active_raw() returns the current request being tracked, or NULL.
358  * It does not obtain a reference on the request for the caller, so the caller
359  * must hold struct_mutex.
360  */
361 static inline struct drm_i915_gem_request *
362 i915_gem_active_raw(const struct i915_gem_active *active, struct mutex *mutex)
363 {
364         return rcu_dereference_protected(active->request,
365                                          lockdep_is_held(mutex));
366 }
367
368 /**
369  * i915_gem_active_peek - report the active request being monitored
370  * @active - the active tracker
371  *
372  * i915_gem_active_peek() returns the current request being tracked if
373  * still active, or NULL. It does not obtain a reference on the request
374  * for the caller, so the caller must hold struct_mutex.
375  */
376 static inline struct drm_i915_gem_request *
377 i915_gem_active_peek(const struct i915_gem_active *active, struct mutex *mutex)
378 {
379         struct drm_i915_gem_request *request;
380
381         request = i915_gem_active_raw(active, mutex);
382         if (!request || i915_gem_request_completed(request))
383                 return NULL;
384
385         return request;
386 }
387
388 /**
389  * i915_gem_active_get - return a reference to the active request
390  * @active - the active tracker
391  *
392  * i915_gem_active_get() returns a reference to the active request, or NULL
393  * if the active tracker is idle. The caller must hold struct_mutex.
394  */
395 static inline struct drm_i915_gem_request *
396 i915_gem_active_get(const struct i915_gem_active *active, struct mutex *mutex)
397 {
398         return i915_gem_request_get(i915_gem_active_peek(active, mutex));
399 }
400
401 /**
402  * __i915_gem_active_get_rcu - return a reference to the active request
403  * @active - the active tracker
404  *
405  * __i915_gem_active_get() returns a reference to the active request, or NULL
406  * if the active tracker is idle. The caller must hold the RCU read lock, but
407  * the returned pointer is safe to use outside of RCU.
408  */
409 static inline struct drm_i915_gem_request *
410 __i915_gem_active_get_rcu(const struct i915_gem_active *active)
411 {
412         /* Performing a lockless retrieval of the active request is super
413          * tricky. SLAB_DESTROY_BY_RCU merely guarantees that the backing
414          * slab of request objects will not be freed whilst we hold the
415          * RCU read lock. It does not guarantee that the request itself
416          * will not be freed and then *reused*. Viz,
417          *
418          * Thread A                     Thread B
419          *
420          * req = active.request
421          *                              retire(req) -> free(req);
422          *                              (req is now first on the slab freelist)
423          *                              active.request = NULL
424          *
425          *                              req = new submission on a new object
426          * ref(req)
427          *
428          * To prevent the request from being reused whilst the caller
429          * uses it, we take a reference like normal. Whilst acquiring
430          * the reference we check that it is not in a destroyed state
431          * (refcnt == 0). That prevents the request being reallocated
432          * whilst the caller holds on to it. To check that the request
433          * was not reallocated as we acquired the reference we have to
434          * check that our request remains the active request across
435          * the lookup, in the same manner as a seqlock. The visibility
436          * of the pointer versus the reference counting is controlled
437          * by using RCU barriers (rcu_dereference and rcu_assign_pointer).
438          *
439          * In the middle of all that, we inspect whether the request is
440          * complete. Retiring is lazy so the request may be completed long
441          * before the active tracker is updated. Querying whether the
442          * request is complete is far cheaper (as it involves no locked
443          * instructions setting cachelines to exclusive) than acquiring
444          * the reference, so we do it first. The RCU read lock ensures the
445          * pointer dereference is valid, but does not ensure that the
446          * seqno nor HWS is the right one! However, if the request was
447          * reallocated, that means the active tracker's request was complete.
448          * If the new request is also complete, then both are and we can
449          * just report the active tracker is idle. If the new request is
450          * incomplete, then we acquire a reference on it and check that
451          * it remained the active request.
452          *
453          * It is then imperative that we do not zero the request on
454          * reallocation, so that we can chase the dangling pointers!
455          * See i915_gem_request_alloc().
456          */
457         do {
458                 struct drm_i915_gem_request *request;
459
460                 request = rcu_dereference(active->request);
461                 if (!request || i915_gem_request_completed(request))
462                         return NULL;
463
464                 /* An especially silly compiler could decide to recompute the
465                  * result of i915_gem_request_completed, more specifically
466                  * re-emit the load for request->fence.seqno. A race would catch
467                  * a later seqno value, which could flip the result from true to
468                  * false. Which means part of the instructions below might not
469                  * be executed, while later on instructions are executed. Due to
470                  * barriers within the refcounting the inconsistency can't reach
471                  * past the call to i915_gem_request_get_rcu, but not executing
472                  * that while still executing i915_gem_request_put() creates
473                  * havoc enough.  Prevent this with a compiler barrier.
474                  */
475                 barrier();
476
477                 request = i915_gem_request_get_rcu(request);
478
479                 /* What stops the following rcu_access_pointer() from occurring
480                  * before the above i915_gem_request_get_rcu()? If we were
481                  * to read the value before pausing to get the reference to
482                  * the request, we may not notice a change in the active
483                  * tracker.
484                  *
485                  * The rcu_access_pointer() is a mere compiler barrier, which
486                  * means both the CPU and compiler are free to perform the
487                  * memory read without constraint. The compiler only has to
488                  * ensure that any operations after the rcu_access_pointer()
489                  * occur afterwards in program order. This means the read may
490                  * be performed earlier by an out-of-order CPU, or adventurous
491                  * compiler.
492                  *
493                  * The atomic operation at the heart of
494                  * i915_gem_request_get_rcu(), see fence_get_rcu(), is
495                  * atomic_inc_not_zero() which is only a full memory barrier
496                  * when successful. That is, if i915_gem_request_get_rcu()
497                  * returns the request (and so with the reference counted
498                  * incremented) then the following read for rcu_access_pointer()
499                  * must occur after the atomic operation and so confirm
500                  * that this request is the one currently being tracked.
501                  *
502                  * The corresponding write barrier is part of
503                  * rcu_assign_pointer().
504                  */
505                 if (!request || request == rcu_access_pointer(active->request))
506                         return rcu_pointer_handoff(request);
507
508                 i915_gem_request_put(request);
509         } while (1);
510 }
511
512 /**
513  * i915_gem_active_get_unlocked - return a reference to the active request
514  * @active - the active tracker
515  *
516  * i915_gem_active_get_unlocked() returns a reference to the active request,
517  * or NULL if the active tracker is idle. The reference is obtained under RCU,
518  * so no locking is required by the caller.
519  *
520  * The reference should be freed with i915_gem_request_put().
521  */
522 static inline struct drm_i915_gem_request *
523 i915_gem_active_get_unlocked(const struct i915_gem_active *active)
524 {
525         struct drm_i915_gem_request *request;
526
527         rcu_read_lock();
528         request = __i915_gem_active_get_rcu(active);
529         rcu_read_unlock();
530
531         return request;
532 }
533
534 /**
535  * i915_gem_active_isset - report whether the active tracker is assigned
536  * @active - the active tracker
537  *
538  * i915_gem_active_isset() returns true if the active tracker is currently
539  * assigned to a request. Due to the lazy retiring, that request may be idle
540  * and this may report stale information.
541  */
542 static inline bool
543 i915_gem_active_isset(const struct i915_gem_active *active)
544 {
545         return rcu_access_pointer(active->request);
546 }
547
548 /**
549  * i915_gem_active_is_idle - report whether the active tracker is idle
550  * @active - the active tracker
551  *
552  * i915_gem_active_is_idle() returns true if the active tracker is currently
553  * unassigned or if the request is complete (but not yet retired). Requires
554  * the caller to hold struct_mutex (but that can be relaxed if desired).
555  */
556 static inline bool
557 i915_gem_active_is_idle(const struct i915_gem_active *active,
558                         struct mutex *mutex)
559 {
560         return !i915_gem_active_peek(active, mutex);
561 }
562
563 /**
564  * i915_gem_active_wait - waits until the request is completed
565  * @active - the active request on which to wait
566  *
567  * i915_gem_active_wait() waits until the request is completed before
568  * returning. Note that it does not guarantee that the request is
569  * retired first, see i915_gem_active_retire().
570  *
571  * i915_gem_active_wait() returns immediately if the active
572  * request is already complete.
573  */
574 static inline int __must_check
575 i915_gem_active_wait(const struct i915_gem_active *active, struct mutex *mutex)
576 {
577         struct drm_i915_gem_request *request;
578
579         request = i915_gem_active_peek(active, mutex);
580         if (!request)
581                 return 0;
582
583         return i915_wait_request(request,
584                                  I915_WAIT_INTERRUPTIBLE | I915_WAIT_LOCKED,
585                                  NULL, NULL);
586 }
587
588 /**
589  * i915_gem_active_wait_unlocked - waits until the request is completed
590  * @active - the active request on which to wait
591  * @flags - how to wait
592  * @timeout - how long to wait at most
593  * @rps - userspace client to charge for a waitboost
594  *
595  * i915_gem_active_wait_unlocked() waits until the request is completed before
596  * returning, without requiring any locks to be held. Note that it does not
597  * retire any requests before returning.
598  *
599  * This function relies on RCU in order to acquire the reference to the active
600  * request without holding any locks. See __i915_gem_active_get_rcu() for the
601  * glory details on how that is managed. Once the reference is acquired, we
602  * can then wait upon the request, and afterwards release our reference,
603  * free of any locking.
604  *
605  * This function wraps i915_wait_request(), see it for the full details on
606  * the arguments.
607  *
608  * Returns 0 if successful, or a negative error code.
609  */
610 static inline int
611 i915_gem_active_wait_unlocked(const struct i915_gem_active *active,
612                               unsigned int flags,
613                               s64 *timeout,
614                               struct intel_rps_client *rps)
615 {
616         struct drm_i915_gem_request *request;
617         int ret = 0;
618
619         request = i915_gem_active_get_unlocked(active);
620         if (request) {
621                 ret = i915_wait_request(request, flags, timeout, rps);
622                 i915_gem_request_put(request);
623         }
624
625         return ret;
626 }
627
628 /**
629  * i915_gem_active_retire - waits until the request is retired
630  * @active - the active request on which to wait
631  *
632  * i915_gem_active_retire() waits until the request is completed,
633  * and then ensures that at least the retirement handler for this
634  * @active tracker is called before returning. If the @active
635  * tracker is idle, the function returns immediately.
636  */
637 static inline int __must_check
638 i915_gem_active_retire(struct i915_gem_active *active,
639                        struct mutex *mutex)
640 {
641         struct drm_i915_gem_request *request;
642         int ret;
643
644         request = i915_gem_active_raw(active, mutex);
645         if (!request)
646                 return 0;
647
648         ret = i915_wait_request(request,
649                                 I915_WAIT_INTERRUPTIBLE | I915_WAIT_LOCKED,
650                                 NULL, NULL);
651         if (ret)
652                 return ret;
653
654         list_del_init(&active->link);
655         RCU_INIT_POINTER(active->request, NULL);
656
657         active->retire(active, request);
658
659         return 0;
660 }
661
662 /* Convenience functions for peeking at state inside active's request whilst
663  * guarded by the struct_mutex.
664  */
665
666 static inline uint32_t
667 i915_gem_active_get_seqno(const struct i915_gem_active *active,
668                           struct mutex *mutex)
669 {
670         return i915_gem_request_get_seqno(i915_gem_active_peek(active, mutex));
671 }
672
673 static inline struct intel_engine_cs *
674 i915_gem_active_get_engine(const struct i915_gem_active *active,
675                            struct mutex *mutex)
676 {
677         return i915_gem_request_get_engine(i915_gem_active_peek(active, mutex));
678 }
679
680 #define for_each_active(mask, idx) \
681         for (; mask ? idx = ffs(mask) - 1, 1 : 0; mask &= ~BIT(idx))
682
683 #endif /* I915_GEM_REQUEST_H */