dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Imre Deak <imre.deak@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/3] drm/dp_mst: Fix flushing the delayed port/mstb destroy work
Date: Wed, 10 Jun 2020 11:54:30 -0400	[thread overview]
Message-ID: <b7e474f0e80026565e7c7ad60a967f167e518536.camel@redhat.com> (raw)
In-Reply-To: <20200610134704.25270-1-imre.deak@intel.com>

my crunch time is over so I can review these on time now :)

one small comment below, although it doesn't stop me from giving my R-B here:

Reviewed-by: Lyude Paul <lyude@redhat.com>


On Wed, 2020-06-10 at 16:47 +0300, Imre Deak wrote:
> Atm, a pending delayed destroy work during module removal will be
> canceled, leaving behind MST ports, mstbs. Fix this by using a dedicated
> workqueue which will be drained of requeued items as well when
> destroying it.
> 
> v2:
> - Check if wq is NULL before calling destroy_workqueue().
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 19 ++++++++++++++++---
>  include/drm/drm_dp_mst_helper.h       |  8 ++++++++
>  2 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index eff8d6ac0273..a5f67b9db7fa 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1604,7 +1604,7 @@ static void drm_dp_destroy_mst_branch_device(struct kref
> *kref)
>  	mutex_lock(&mgr->delayed_destroy_lock);
>  	list_add(&mstb->destroy_next, &mgr->destroy_branch_device_list);
>  	mutex_unlock(&mgr->delayed_destroy_lock);
> -	schedule_work(&mgr->delayed_destroy_work);
> +	queue_work(mgr->delayed_destroy_wq, &mgr->delayed_destroy_work);
>  }
>  
>  /**
> @@ -1721,7 +1721,7 @@ static void drm_dp_destroy_port(struct kref *kref)
>  	mutex_lock(&mgr->delayed_destroy_lock);
>  	list_add(&port->next, &mgr->destroy_port_list);
>  	mutex_unlock(&mgr->delayed_destroy_lock);
> -	schedule_work(&mgr->delayed_destroy_work);
> +	queue_work(mgr->delayed_destroy_wq, &mgr->delayed_destroy_work);
>  }
>  
>  /**
> @@ -5182,6 +5182,15 @@ int drm_dp_mst_topology_mgr_init(struct
> drm_dp_mst_topology_mgr *mgr,
>  	INIT_LIST_HEAD(&mgr->destroy_port_list);
>  	INIT_LIST_HEAD(&mgr->destroy_branch_device_list);
>  	INIT_LIST_HEAD(&mgr->up_req_list);
> +
> +	/*
> +	 * delayed_destroy_work will be queued on a dedicated WQ, so that any
> +	 * requeuing will be also flushed when deiniting the topology manager.
> +	 */
> +	mgr->delayed_destroy_wq = alloc_ordered_workqueue("drm_dp_mst_wq", 0);
> +	if (mgr->delayed_destroy_wq == NULL)
> +		return -ENOMEM;
> +
>  	INIT_WORK(&mgr->work, drm_dp_mst_link_probe_work);
>  	INIT_WORK(&mgr->tx_work, drm_dp_tx_work);
>  	INIT_WORK(&mgr->delayed_destroy_work, drm_dp_delayed_destroy_work);
> @@ -5226,7 +5235,11 @@ void drm_dp_mst_topology_mgr_destroy(struct
> drm_dp_mst_topology_mgr *mgr)
>  {
>  	drm_dp_mst_topology_mgr_set_mst(mgr, false);
>  	flush_work(&mgr->work);
> -	cancel_work_sync(&mgr->delayed_destroy_work);
> +	/* The following will also drain any requeued work on the WQ. */
> +	if (mgr->delayed_destroy_wq) {
> +		destroy_workqueue(mgr->delayed_destroy_wq);
> +		mgr->delayed_destroy_wq = NULL;
> +	}

We should definitely cleanup the cleanup in this function, I don't mind
submitting some patches to do it today if you poke me on IRC once you've got
this pushed to drm-misc-next
>  	mutex_lock(&mgr->payload_lock);
>  	kfree(mgr->payloads);
>  	mgr->payloads = NULL;
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index 9e1ffcd7cb68..17b568c6f4f8 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -672,6 +672,14 @@ struct drm_dp_mst_topology_mgr {
>  	 * @destroy_branch_device_list.
>  	 */
>  	struct mutex delayed_destroy_lock;
> +
> +	/**
> +	 * @delayed_destroy_wq: Workqueue used for delayed_destroy_work items.
> +	 * A dedicated WQ makes it possible to drain any requeued work items
> +	 * on it.
> +	 */
> +	struct workqueue_struct *delayed_destroy_wq;
> +
>  	/**
>  	 * @delayed_destroy_work: Work item to destroy MST port and branch
>  	 * devices, needed to avoid locking inversion.

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-06-10 15:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-07 21:25 [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port Imre Deak
2020-06-07 21:25 ` [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration " Imre Deak
2020-06-10  8:03   ` Lisovskiy, Stanislav
2020-06-10 10:09     ` Imre Deak
2020-06-10 10:59       ` Lisovskiy, Stanislav
2020-06-07 21:25 ` [PATCH 3/3] drm/dp_mst: Fix flushing the delayed port/mstb destroy work Imre Deak
2020-06-10  7:29   ` Lisovskiy, Stanislav
2020-06-10 13:47   ` [PATCH v2 " Imre Deak
2020-06-10 15:54     ` Lyude Paul [this message]
2020-06-09 20:45 ` [Intel-gfx] [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port Lisovskiy, Stanislav
     [not found] ` <159186517668.22716.10635471487472572534@emeril.freedesktop.org>
2020-06-11 12:51   ` ✓ Fi.CI.IGT: success for series starting with [1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port (rev2) Imre Deak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7e474f0e80026565e7c7ad60a967f167e518536.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=stanislav.lisovskiy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).