[PATCH v4 10/10] gna: add open and close operations on GNA device
Kwapulinski, Maciej
maciej.kwapulinski at intel.com
Thu Oct 20 13:35:25 UTC 2022
From: Tomasz Jankowski <tomasz1.jankowski at intel.com>
Signed-off-by: Tomasz Jankowski <tomasz1.jankowski at intel.com>
Tested-by: Mikolaj Grzybowski <mikolajx.grzybowski at intel.com>
Co-developed-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
Signed-off-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
Co-developed-by: Maciej Kwapulinski <maciej.kwapulinski at linux.intel.com>
Signed-off-by: Maciej Kwapulinski <maciej.kwapulinski at linux.intel.com>
---
drivers/gpu/drm/gna/gna_device.c | 46 ++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/gpu/drm/gna/gna_device.c b/drivers/gpu/drm/gna/gna_device.c
index aee409e3b4ea..4ce08bf313c3 100644
--- a/drivers/gpu/drm/gna/gna_device.c
+++ b/drivers/gpu/drm/gna/gna_device.c
@@ -58,6 +58,49 @@ const struct dev_pm_ops __maybe_unused gna_pm = {
SET_RUNTIME_PM_OPS(gna_runtime_suspend, gna_runtime_resume, NULL)
};
+static int gna_open(struct drm_device *dev, struct drm_file *file)
+{
+ struct gna_device *gna_priv;
+
+ gna_priv = to_gna_device(dev);
+
+ file->driver_priv = gna_priv;
+
+ return 0;
+}
+
+static void gna_delete_file_requests(struct drm_file *file, struct gna_device *gna_priv)
+{
+ struct gna_request *req, *temp_req;
+ struct list_head *reqs_list;
+
+ mutex_lock(&gna_priv->reqlist_lock);
+
+ reqs_list = &gna_priv->request_list;
+ if (!list_empty(reqs_list)) {
+ list_for_each_entry_safe(req, temp_req, reqs_list, node) {
+ if (req->drm_f == file) {
+ bool is_pending;
+
+ list_del_init(&req->node);
+ is_pending = cancel_work_sync(&req->work);
+ if (is_pending)
+ atomic_dec(&gna_priv->enqueued_requests);
+ kref_put(&req->refcount, gna_request_release);
+ break;
+ }
+ }
+ }
+
+ mutex_unlock(&gna_priv->reqlist_lock);
+}
+
+static void gna_close(struct drm_device *dev, struct drm_file *file)
+{
+ struct gna_device *gna_priv = (struct gna_device *)file->driver_priv;
+
+ gna_delete_file_requests(file, gna_priv);
+}
static void gna_drm_dev_fini(struct drm_device *dev, void *ptr)
{
@@ -136,6 +179,9 @@ static struct drm_gem_object *gna_create_gem_object(struct drm_device *dev,
static const struct drm_driver gna_drm_driver = {
.driver_features = DRIVER_GEM | DRIVER_RENDER,
+ .open = gna_open,
+ .postclose = gna_close,
+
.gem_create_object = gna_create_gem_object,
.ioctls = gna_drm_ioctls,
--
2.25.1
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
More information about the dri-devel
mailing list