提交 bd5970a0 编写于 作者: D Dave Jiang 提交者: Vinod Koul

dmaengine: idxd: create locked version of idxd_quiesce() call

Add a locked version of idxd_quiesce() call so that the quiesce can be
called with a lock in situations where the lock is not held by the caller.

In the driver probe/remove path, the lock is already held, so the raw
version can be called w/o locking.
Reviewed-by: NKevin Tian <kevin.tian@intel.com>
Signed-off-by: NDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/163528418980.3925689.5841907054957931211.stgit@djiang5-desk3.ch.intel.comSigned-off-by: NVinod Koul <vkoul@kernel.org>
上级 46c6df1c
...@@ -411,12 +411,20 @@ int idxd_wq_init_percpu_ref(struct idxd_wq *wq) ...@@ -411,12 +411,20 @@ int idxd_wq_init_percpu_ref(struct idxd_wq *wq)
return 0; return 0;
} }
void idxd_wq_quiesce(struct idxd_wq *wq) void __idxd_wq_quiesce(struct idxd_wq *wq)
{ {
lockdep_assert_held(&wq->wq_lock);
percpu_ref_kill(&wq->wq_active); percpu_ref_kill(&wq->wq_active);
wait_for_completion(&wq->wq_dead); wait_for_completion(&wq->wq_dead);
} }
void idxd_wq_quiesce(struct idxd_wq *wq)
{
mutex_lock(&wq->wq_lock);
__idxd_wq_quiesce(wq);
mutex_unlock(&wq->wq_lock);
}
/* Device control bits */ /* Device control bits */
static inline bool idxd_is_enabled(struct idxd_device *idxd) static inline bool idxd_is_enabled(struct idxd_device *idxd)
{ {
......
...@@ -316,7 +316,7 @@ static int idxd_dmaengine_drv_probe(struct idxd_dev *idxd_dev) ...@@ -316,7 +316,7 @@ static int idxd_dmaengine_drv_probe(struct idxd_dev *idxd_dev)
return 0; return 0;
err_dma: err_dma:
idxd_wq_quiesce(wq); __idxd_wq_quiesce(wq);
percpu_ref_exit(&wq->wq_active); percpu_ref_exit(&wq->wq_active);
err_ref: err_ref:
idxd_wq_free_resources(wq); idxd_wq_free_resources(wq);
...@@ -333,7 +333,7 @@ static void idxd_dmaengine_drv_remove(struct idxd_dev *idxd_dev) ...@@ -333,7 +333,7 @@ static void idxd_dmaengine_drv_remove(struct idxd_dev *idxd_dev)
struct idxd_wq *wq = idxd_dev_to_wq(idxd_dev); struct idxd_wq *wq = idxd_dev_to_wq(idxd_dev);
mutex_lock(&wq->wq_lock); mutex_lock(&wq->wq_lock);
idxd_wq_quiesce(wq); __idxd_wq_quiesce(wq);
idxd_unregister_dma_channel(wq); idxd_unregister_dma_channel(wq);
idxd_wq_free_resources(wq); idxd_wq_free_resources(wq);
__drv_disable_wq(wq); __drv_disable_wq(wq);
......
...@@ -570,6 +570,7 @@ int idxd_wq_map_portal(struct idxd_wq *wq); ...@@ -570,6 +570,7 @@ int idxd_wq_map_portal(struct idxd_wq *wq);
void idxd_wq_unmap_portal(struct idxd_wq *wq); void idxd_wq_unmap_portal(struct idxd_wq *wq);
int idxd_wq_set_pasid(struct idxd_wq *wq, int pasid); int idxd_wq_set_pasid(struct idxd_wq *wq, int pasid);
int idxd_wq_disable_pasid(struct idxd_wq *wq); int idxd_wq_disable_pasid(struct idxd_wq *wq);
void __idxd_wq_quiesce(struct idxd_wq *wq);
void idxd_wq_quiesce(struct idxd_wq *wq); void idxd_wq_quiesce(struct idxd_wq *wq);
int idxd_wq_init_percpu_ref(struct idxd_wq *wq); int idxd_wq_init_percpu_ref(struct idxd_wq *wq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册