dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: idxd: cleanup workqueue config after disabling
@ 2020-05-15 19:24 Dave Jiang
  2020-06-05 18:59 ` Dave Jiang
  2020-06-24  7:31 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Jiang @ 2020-05-15 19:24 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, yixin.zhang

After disabling a device, we should clean up the internal state for
the wqs and zero out the configuration registers. Without doing so can cause
issues when the user reprogram the wqs.

Reported-by: Yixin Zhang <yixin.zhang@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Tested-by: Yixin Zhang <yixin.zhang@intel.com>
---
 drivers/dma/idxd/device.c |   24 ++++++++++++++++++++++++
 drivers/dma/idxd/idxd.h   |    1 +
 drivers/dma/idxd/sysfs.c  |    5 +++++
 3 files changed, 30 insertions(+)

diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
index 4669986fe018..104bb5b1bad2 100644
--- a/drivers/dma/idxd/device.c
+++ b/drivers/dma/idxd/device.c
@@ -325,6 +325,30 @@ void idxd_wq_unmap_portal(struct idxd_wq *wq)
 	devm_iounmap(dev, wq->dportal);
 }
 
+void idxd_wq_disable_cleanup(struct idxd_wq *wq)
+{
+	struct idxd_device *idxd = wq->idxd;
+	struct device *dev = &idxd->pdev->dev;
+	int i, wq_offset;
+
+	memset(&wq->wqcfg, 0, sizeof(wq->wqcfg));
+	wq->type = IDXD_WQT_NONE;
+	wq->size = 0;
+	wq->group = NULL;
+	wq->threshold = 0;
+	wq->priority = 0;
+	clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
+	memset(wq->name, 0, WQ_NAME_SIZE);
+
+	for (i = 0; i < 8; i++) {
+		wq_offset = idxd->wqcfg_offset + wq->id * 32 + i * sizeof(u32);
+		iowrite32(0, idxd->reg_base + wq_offset);
+		dev_dbg(dev, "WQ[%d][%d][%#x]: %#x\n",
+			wq->id, i, wq_offset,
+			ioread32(idxd->reg_base + wq_offset));
+	}
+}
+
 /* Device control bits */
 static inline bool idxd_is_enabled(struct idxd_device *idxd)
 {
diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
index 9a69738e355d..3dfac462a0df 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -292,6 +292,7 @@ int idxd_wq_disable(struct idxd_wq *wq, unsigned long *irq_flags);
 void idxd_wq_drain(struct idxd_wq *wq, unsigned long *irq_flags);
 int idxd_wq_map_portal(struct idxd_wq *wq);
 void idxd_wq_unmap_portal(struct idxd_wq *wq);
+void idxd_wq_disable_cleanup(struct idxd_wq *wq);
 
 /* submission */
 int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 709a576a25e6..df585b0829db 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -317,6 +317,11 @@ static int idxd_config_bus_remove(struct device *dev)
 		idxd_unregister_dma_device(idxd);
 		spin_lock_irqsave(&idxd->dev_lock, flags);
 		rc = idxd_device_disable(idxd, &flags);
+		for (i = 0; i < idxd->max_wqs; i++) {
+			struct idxd_wq *wq = &idxd->wqs[i];
+
+			idxd_wq_disable_cleanup(wq);
+		}
 		spin_unlock_irqrestore(&idxd->dev_lock, flags);
 		module_put(THIS_MODULE);
 		if (rc < 0)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: idxd: cleanup workqueue config after disabling
  2020-05-15 19:24 [PATCH] dmaengine: idxd: cleanup workqueue config after disabling Dave Jiang
@ 2020-06-05 18:59 ` Dave Jiang
  2020-06-24  7:31 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2020-06-05 18:59 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, yixin.zhang



On 5/15/2020 12:24 PM, Dave Jiang wrote:
> After disabling a device, we should clean up the internal state for
> the wqs and zero out the configuration registers. Without doing so can cause
> issues when the user reprogram the wqs.
> 
> Reported-by: Yixin Zhang <yixin.zhang@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> Tested-by: Yixin Zhang <yixin.zhang@intel.com>

Hi Vinod, ping on this submit.

> ---
>   drivers/dma/idxd/device.c |   24 ++++++++++++++++++++++++
>   drivers/dma/idxd/idxd.h   |    1 +
>   drivers/dma/idxd/sysfs.c  |    5 +++++
>   3 files changed, 30 insertions(+)
> 
> diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
> index 4669986fe018..104bb5b1bad2 100644
> --- a/drivers/dma/idxd/device.c
> +++ b/drivers/dma/idxd/device.c
> @@ -325,6 +325,30 @@ void idxd_wq_unmap_portal(struct idxd_wq *wq)
>   	devm_iounmap(dev, wq->dportal);
>   }
>   
> +void idxd_wq_disable_cleanup(struct idxd_wq *wq)
> +{
> +	struct idxd_device *idxd = wq->idxd;
> +	struct device *dev = &idxd->pdev->dev;
> +	int i, wq_offset;
> +
> +	memset(&wq->wqcfg, 0, sizeof(wq->wqcfg));
> +	wq->type = IDXD_WQT_NONE;
> +	wq->size = 0;
> +	wq->group = NULL;
> +	wq->threshold = 0;
> +	wq->priority = 0;
> +	clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
> +	memset(wq->name, 0, WQ_NAME_SIZE);
> +
> +	for (i = 0; i < 8; i++) {
> +		wq_offset = idxd->wqcfg_offset + wq->id * 32 + i * sizeof(u32);
> +		iowrite32(0, idxd->reg_base + wq_offset);
> +		dev_dbg(dev, "WQ[%d][%d][%#x]: %#x\n",
> +			wq->id, i, wq_offset,
> +			ioread32(idxd->reg_base + wq_offset));
> +	}
> +}
> +
>   /* Device control bits */
>   static inline bool idxd_is_enabled(struct idxd_device *idxd)
>   {
> diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
> index 9a69738e355d..3dfac462a0df 100644
> --- a/drivers/dma/idxd/idxd.h
> +++ b/drivers/dma/idxd/idxd.h
> @@ -292,6 +292,7 @@ int idxd_wq_disable(struct idxd_wq *wq, unsigned long *irq_flags);
>   void idxd_wq_drain(struct idxd_wq *wq, unsigned long *irq_flags);
>   int idxd_wq_map_portal(struct idxd_wq *wq);
>   void idxd_wq_unmap_portal(struct idxd_wq *wq);
> +void idxd_wq_disable_cleanup(struct idxd_wq *wq);
>   
>   /* submission */
>   int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);
> diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
> index 709a576a25e6..df585b0829db 100644
> --- a/drivers/dma/idxd/sysfs.c
> +++ b/drivers/dma/idxd/sysfs.c
> @@ -317,6 +317,11 @@ static int idxd_config_bus_remove(struct device *dev)
>   		idxd_unregister_dma_device(idxd);
>   		spin_lock_irqsave(&idxd->dev_lock, flags);
>   		rc = idxd_device_disable(idxd, &flags);
> +		for (i = 0; i < idxd->max_wqs; i++) {
> +			struct idxd_wq *wq = &idxd->wqs[i];
> +
> +			idxd_wq_disable_cleanup(wq);
> +		}
>   		spin_unlock_irqrestore(&idxd->dev_lock, flags);
>   		module_put(THIS_MODULE);
>   		if (rc < 0)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: idxd: cleanup workqueue config after disabling
  2020-05-15 19:24 [PATCH] dmaengine: idxd: cleanup workqueue config after disabling Dave Jiang
  2020-06-05 18:59 ` Dave Jiang
@ 2020-06-24  7:31 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2020-06-24  7:31 UTC (permalink / raw)
  To: Dave Jiang; +Cc: dmaengine, yixin.zhang

On 15-05-20, 12:24, Dave Jiang wrote:
> After disabling a device, we should clean up the internal state for
> the wqs and zero out the configuration registers. Without doing so can cause
> issues when the user reprogram the wqs.

Doesnt apply, pls rebase and resend

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-24  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 19:24 [PATCH] dmaengine: idxd: cleanup workqueue config after disabling Dave Jiang
2020-06-05 18:59 ` Dave Jiang
2020-06-24  7:31 ` Vinod Koul

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).