Merge tag 'drm-next-5.5-2019-10-09' of git://people.freedesktop.org/~agd5f/linux...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / amdkfd / kfd_priv.h
index abaed58..060a9e8 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/kref.h>
 #include <linux/sysfs.h>
+#include <linux/device_cgroup.h>
+#include <drm/drm_file.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_device.h>
 #include <kgd_kfd_interface.h>
 
 #include "amd_shared.h"
@@ -226,6 +230,7 @@ struct kfd_dev {
 
        const struct kfd_device_info *device_info;
        struct pci_dev *pdev;
+       struct drm_device *ddev;
 
        unsigned int id;                /* topology stub index */
 
@@ -683,10 +688,7 @@ struct kfd_process {
        /* We want to receive a notification when the mm_struct is destroyed */
        struct mmu_notifier mmu_notifier;
 
-       /* Use for delayed freeing of kfd_process structure */
-       struct rcu_head rcu;
-
-       unsigned int pasid;
+       uint16_t pasid;
        unsigned int doorbell_index;
 
        /*
@@ -1039,6 +1041,21 @@ bool kfd_is_locked(void);
 void kfd_inc_compute_active(struct kfd_dev *dev);
 void kfd_dec_compute_active(struct kfd_dev *dev);
 
+/* Cgroup Support */
+/* Check with device cgroup if @kfd device is accessible */
+static inline int kfd_devcgroup_check_permission(struct kfd_dev *kfd)
+{
+#if defined(CONFIG_CGROUP_DEVICE)
+       struct drm_device *ddev = kfd->ddev;
+
+       return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major,
+                                         ddev->render->index,
+                                         DEVCG_ACC_WRITE | DEVCG_ACC_READ);
+#else
+       return 0;
+#endif
+}
+
 /* Debugfs */
 #if defined(CONFIG_DEBUG_FS)