dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] dmaengine: idxd: reset states after device disable or reset
@ 2020-07-21 18:57 Dave Jiang
  2020-07-27  9:17 ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Jiang @ 2020-07-21 18:57 UTC (permalink / raw)
  To: vkoul; +Cc: Mona Hossain, dmaengine

The state for WQs should be reset to disabled when a device is reset or
disabled.

Fixes: da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after disabling")
Reported-by: Mona Hossain <mona.hossain@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/dma/idxd/device.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
index 14b45853aa5f..d0290072d558 100644
--- a/drivers/dma/idxd/device.c
+++ b/drivers/dma/idxd/device.c
@@ -414,6 +414,7 @@ int idxd_device_disable(struct idxd_device *idxd)
 {
 	struct device *dev = &idxd->pdev->dev;
 	u32 status;
+	int i;
 
 	if (!idxd_is_enabled(idxd)) {
 		dev_dbg(dev, "Device is not enabled\n");
@@ -429,13 +430,33 @@ int idxd_device_disable(struct idxd_device *idxd)
 		return -ENXIO;
 	}
 
+	for (i = 0; i < idxd->max_wqs; i++) {
+		struct idxd_wq *wq = &idxd->wqs[i];
+
+		if (wq->state == IDXD_WQ_ENABLED) {
+			idxd_wq_disable_cleanup(wq);
+			wq->state = IDXD_WQ_DISABLED;
+		}
+	}
 	idxd->state = IDXD_DEV_CONF_READY;
 	return 0;
 }
 
 void idxd_device_reset(struct idxd_device *idxd)
 {
+	int i;
+
 	idxd_cmd_exec(idxd, IDXD_CMD_RESET_DEVICE, 0, NULL);
+
+	for (i = 0; i < idxd->max_wqs; i++) {
+		struct idxd_wq *wq = &idxd->wqs[i];
+
+		if (wq->state == IDXD_WQ_ENABLED) {
+			idxd_wq_disable_cleanup(wq);
+			wq->state = IDXD_WQ_DISABLED;
+		}
+	}
+	idxd->state = IDXD_DEV_CONF_READY;
 }
 
 /* Device configuration bits */


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

* Re: [PATCH] dmaengine: idxd: reset states after device disable or reset
  2020-07-21 18:57 [PATCH] dmaengine: idxd: reset states after device disable or reset Dave Jiang
@ 2020-07-27  9:17 ` Vinod Koul
  2020-07-27 14:47   ` Dave Jiang
  0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2020-07-27  9:17 UTC (permalink / raw)
  To: Dave Jiang; +Cc: Mona Hossain, dmaengine

On 21-07-20, 11:57, Dave Jiang wrote:
> The state for WQs should be reset to disabled when a device is reset or
> disabled.
> 
> Fixes: da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after disabling")
> Reported-by: Mona Hossain <mona.hossain@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/dma/idxd/device.c |   21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
> index 14b45853aa5f..d0290072d558 100644
> --- a/drivers/dma/idxd/device.c
> +++ b/drivers/dma/idxd/device.c
> @@ -414,6 +414,7 @@ int idxd_device_disable(struct idxd_device *idxd)
>  {
>  	struct device *dev = &idxd->pdev->dev;
>  	u32 status;
> +	int i;
>  
>  	if (!idxd_is_enabled(idxd)) {
>  		dev_dbg(dev, "Device is not enabled\n");
> @@ -429,13 +430,33 @@ int idxd_device_disable(struct idxd_device *idxd)
>  		return -ENXIO;
>  	}
>  
> +	for (i = 0; i < idxd->max_wqs; i++) {
> +		struct idxd_wq *wq = &idxd->wqs[i];
> +
> +		if (wq->state == IDXD_WQ_ENABLED) {
> +			idxd_wq_disable_cleanup(wq);
> +			wq->state = IDXD_WQ_DISABLED;
> +		}
> +	}
>  	idxd->state = IDXD_DEV_CONF_READY;
>  	return 0;
>  }
>  
>  void idxd_device_reset(struct idxd_device *idxd)
>  {
> +	int i;
> +
>  	idxd_cmd_exec(idxd, IDXD_CMD_RESET_DEVICE, 0, NULL);
> +
> +	for (i = 0; i < idxd->max_wqs; i++) {
> +		struct idxd_wq *wq = &idxd->wqs[i];
> +
> +		if (wq->state == IDXD_WQ_ENABLED) {
> +			idxd_wq_disable_cleanup(wq);
> +			wq->state = IDXD_WQ_DISABLED;
> +		}
> +	}

Repeated, how about a helper for this?

> +	idxd->state = IDXD_DEV_CONF_READY;
>  }
>  
>  /* Device configuration bits */

-- 
~Vinod

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

* Re: [PATCH] dmaengine: idxd: reset states after device disable or reset
  2020-07-27  9:17 ` Vinod Koul
@ 2020-07-27 14:47   ` Dave Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2020-07-27 14:47 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Mona Hossain, dmaengine



On 7/27/2020 2:17 AM, Vinod Koul wrote:
> On 21-07-20, 11:57, Dave Jiang wrote:
>> The state for WQs should be reset to disabled when a device is reset or
>> disabled.
>>
>> Fixes: da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after disabling")
>> Reported-by: Mona Hossain <mona.hossain@intel.com>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> ---
>>   drivers/dma/idxd/device.c |   21 +++++++++++++++++++++
>>   1 file changed, 21 insertions(+)
>>
>> diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
>> index 14b45853aa5f..d0290072d558 100644
>> --- a/drivers/dma/idxd/device.c
>> +++ b/drivers/dma/idxd/device.c
>> @@ -414,6 +414,7 @@ int idxd_device_disable(struct idxd_device *idxd)
>>   {
>>   	struct device *dev = &idxd->pdev->dev;
>>   	u32 status;
>> +	int i;
>>   
>>   	if (!idxd_is_enabled(idxd)) {
>>   		dev_dbg(dev, "Device is not enabled\n");
>> @@ -429,13 +430,33 @@ int idxd_device_disable(struct idxd_device *idxd)
>>   		return -ENXIO;
>>   	}
>>   
>> +	for (i = 0; i < idxd->max_wqs; i++) {
>> +		struct idxd_wq *wq = &idxd->wqs[i];
>> +
>> +		if (wq->state == IDXD_WQ_ENABLED) {
>> +			idxd_wq_disable_cleanup(wq);
>> +			wq->state = IDXD_WQ_DISABLED;
>> +		}
>> +	}
>>   	idxd->state = IDXD_DEV_CONF_READY;
>>   	return 0;
>>   }
>>   
>>   void idxd_device_reset(struct idxd_device *idxd)
>>   {
>> +	int i;
>> +
>>   	idxd_cmd_exec(idxd, IDXD_CMD_RESET_DEVICE, 0, NULL);
>> +
>> +	for (i = 0; i < idxd->max_wqs; i++) {
>> +		struct idxd_wq *wq = &idxd->wqs[i];
>> +
>> +		if (wq->state == IDXD_WQ_ENABLED) {
>> +			idxd_wq_disable_cleanup(wq);
>> +			wq->state = IDXD_WQ_DISABLED;
>> +		}
>> +	}
> 
> Repeated, how about a helper for this?

Ok will fix.

> 
>> +	idxd->state = IDXD_DEV_CONF_READY;
>>   }
>>   
>>   /* Device configuration bits */
> 

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 18:57 [PATCH] dmaengine: idxd: reset states after device disable or reset Dave Jiang
2020-07-27  9:17 ` Vinod Koul
2020-07-27 14:47   ` Dave Jiang

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git