[RFC PATCH v3 2/4] drm/ipvr: drm driver for VED

Cheng, Yao yao.cheng at intel.com
Wed Nov 26 08:50:33 PST 2014


> -----Original Message-----
> From: Cheng, Yao
> Sent: Saturday, November 22, 2014 3:07
> To: intel-gfx at lists.freedesktop.org; dri-devel at lists.freedesktop.org;
> daniel.vetter at ffwll.ch; Kelley, Sean V; Chehab, John
> Cc: Jiang, Fei; dh.herrmann at gmail.com; jani.nikula at linux.intel.com;
> emil.l.velikov at gmail.com; ville.syrjala at linux.intel.com;
> jbarnes at virtuousgeek.org; daniel at fooishbar.org; Cheng, Yao
> Subject: [RFC PATCH v3 2/4] drm/ipvr: drm driver for VED
> 
> +static void
> +ipvr_drm_preclose(struct drm_device *dev, struct drm_file *file_priv)
> +{
> +	/* if user didn't destory ctx explicitly, remove ctx here */
> +	struct drm_ipvr_private *dev_priv;
> +	struct drm_ipvr_file_private *ipvr_fpriv;
> +	struct ved_private *ved_priv;
> +	struct ipvr_context *ipvr_ctx  = NULL;
> +	unsigned long irq_flags;
> +
> +	IPVR_DEBUG_ENTRY("enter\n");
> +	dev_priv = dev->dev_private;
> +	ipvr_fpriv = file_priv->driver_priv;
> +	ved_priv = dev_priv->ved_private;
> +
> +	if (ipvr_fpriv->ctx_id == IPVR_CONTEXT_INVALID_ID)
> +		return;
> +	ipvr_ctx = (struct ipvr_context *)
> +			idr_find(&dev_priv->ipvr_ctx_idr, ipvr_fpriv->ctx_id);

Need protection on ipvr_ctx_idr. Same to the other idr related code.

> +	if (!ipvr_ctx  || (ipvr_ctx->ipvr_fpriv != ipvr_fpriv)) {
> +		IPVR_DEBUG_GENERAL("ctx for id %d has already
> destroyed\n",
> +				ipvr_fpriv->ctx_id);
> +		return;
> +	}
> +
> +	/**
> +	 * fixme: remove this work-around (WA the issue that calling
> +	 * close() with queued cmd might cause state machine issue).
> +	 * we should wait for only the cmds sent from contexts in this file
> +	 * instead of all cmds
> +	 */
> +	ipvr_fence_wait_empty_locked(dev_priv);
> +
> +	IPVR_DEBUG_PM("Video:remove context type 0x%x\n", ipvr_ctx-
> >ctx_type);
> +	mutex_lock(&ved_priv->ved_mutex);
> +	if (ved_priv->ipvr_ctx == ipvr_ctx )
> +		ved_priv->ipvr_ctx = NULL;
> +	mutex_unlock(&ved_priv->ved_mutex);
> +
> +	spin_lock_irqsave(&dev_priv->ipvr_ctx_lock, irq_flags);
> +	list_del(&ipvr_ctx->head);
> +	ipvr_fpriv->ctx_id = IPVR_CONTEXT_INVALID_ID;
> +	spin_unlock_irqrestore(&dev_priv->ipvr_ctx_lock, irq_flags);
> +
> +	idr_remove(&dev_priv->ipvr_ctx_idr, ipvr_ctx->ctx_id);
> +
> +	kfree(ipvr_ctx );
> +	kfree(ipvr_fpriv);
> +}




More information about the dri-devel mailing list