@@ -775,20 +775,19 @@ void drm_event_cancel_free(struct drm_device *dev,
775775EXPORT_SYMBOL (drm_event_cancel_free );
776776
777777/**
778- * drm_send_event_locked - send DRM event to file descriptor
778+ * drm_send_event_helper - send DRM event to file descriptor
779779 * @dev: DRM device
780780 * @e: DRM event to deliver
781+ * @timestamp: timestamp to set for the fence event in kernel's CLOCK_MONOTONIC
782+ * time domain
781783 *
782- * This function sends the event @e, initialized with drm_event_reserve_init(),
783- * to its associated userspace DRM file. Callers must already hold
784- * &drm_device.event_lock, see drm_send_event() for the unlocked version.
785- *
786- * Note that the core will take care of unlinking and disarming events when the
787- * corresponding DRM file is closed. Drivers need not worry about whether the
788- * DRM file for this event still exists and can call this function upon
789- * completion of the asynchronous work unconditionally.
784+ * This helper function sends the event @e, initialized with
785+ * drm_event_reserve_init(), to its associated userspace DRM file.
786+ * The timestamp variant of dma_fence_signal is used when the caller
787+ * sends a valid timestamp.
790788 */
791- void drm_send_event_locked (struct drm_device * dev , struct drm_pending_event * e )
789+ void drm_send_event_helper (struct drm_device * dev ,
790+ struct drm_pending_event * e , ktime_t timestamp )
792791{
793792 assert_spin_locked (& dev -> event_lock );
794793
@@ -799,7 +798,10 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
799798 }
800799
801800 if (e -> fence ) {
802- dma_fence_signal (e -> fence );
801+ if (timestamp )
802+ dma_fence_signal_timestamp (e -> fence , timestamp );
803+ else
804+ dma_fence_signal (e -> fence );
803805 dma_fence_put (e -> fence );
804806 }
805807
@@ -814,6 +816,48 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
814816 wake_up_interruptible_poll (& e -> file_priv -> event_wait ,
815817 EPOLLIN | EPOLLRDNORM );
816818}
819+
820+ /**
821+ * drm_send_event_timestamp_locked - send DRM event to file descriptor
822+ * @dev: DRM device
823+ * @e: DRM event to deliver
824+ * @timestamp: timestamp to set for the fence event in kernel's CLOCK_MONOTONIC
825+ * time domain
826+ *
827+ * This function sends the event @e, initialized with drm_event_reserve_init(),
828+ * to its associated userspace DRM file. Callers must already hold
829+ * &drm_device.event_lock.
830+ *
831+ * Note that the core will take care of unlinking and disarming events when the
832+ * corresponding DRM file is closed. Drivers need not worry about whether the
833+ * DRM file for this event still exists and can call this function upon
834+ * completion of the asynchronous work unconditionally.
835+ */
836+ void drm_send_event_timestamp_locked (struct drm_device * dev ,
837+ struct drm_pending_event * e , ktime_t timestamp )
838+ {
839+ drm_send_event_helper (dev , e , timestamp );
840+ }
841+ EXPORT_SYMBOL (drm_send_event_timestamp_locked );
842+
843+ /**
844+ * drm_send_event_locked - send DRM event to file descriptor
845+ * @dev: DRM device
846+ * @e: DRM event to deliver
847+ *
848+ * This function sends the event @e, initialized with drm_event_reserve_init(),
849+ * to its associated userspace DRM file. Callers must already hold
850+ * &drm_device.event_lock, see drm_send_event() for the unlocked version.
851+ *
852+ * Note that the core will take care of unlinking and disarming events when the
853+ * corresponding DRM file is closed. Drivers need not worry about whether the
854+ * DRM file for this event still exists and can call this function upon
855+ * completion of the asynchronous work unconditionally.
856+ */
857+ void drm_send_event_locked (struct drm_device * dev , struct drm_pending_event * e )
858+ {
859+ drm_send_event_helper (dev , e , 0 );
860+ }
817861EXPORT_SYMBOL (drm_send_event_locked );
818862
819863/**
@@ -836,7 +880,7 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
836880 unsigned long irqflags ;
837881
838882 spin_lock_irqsave (& dev -> event_lock , irqflags );
839- drm_send_event_locked (dev , e );
883+ drm_send_event_helper (dev , e , 0 );
840884 spin_unlock_irqrestore (& dev -> event_lock , irqflags );
841885}
842886EXPORT_SYMBOL (drm_send_event );
0 commit comments