linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] habanalabs: Handle HW_IP_INFO if device disabled or in reset
@ 2019-08-08 12:30 Tomer Tayar
  2019-08-08 14:11 ` Oded Gabbay
  0 siblings, 1 reply; 2+ messages in thread
From: Tomer Tayar @ 2019-08-08 12:30 UTC (permalink / raw)
  To: oded.gabbay; +Cc: linux-kernel

The HW IP information is relevant even if the device is disabled or in
reset, so always handle the corresponding INFO IOCTL opcode.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
---
 drivers/misc/habanalabs/habanalabs_ioctl.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/habanalabs/habanalabs_ioctl.c b/drivers/misc/habanalabs/habanalabs_ioctl.c
index 3ce65459b01c..589324ac19d0 100644
--- a/drivers/misc/habanalabs/habanalabs_ioctl.c
+++ b/drivers/misc/habanalabs/habanalabs_ioctl.c
@@ -204,10 +204,21 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
 	struct hl_device *hdev = hpriv->hdev;
 	int rc;
 
-	/* We want to return device status even if it disabled or in reset */
-	if (args->op == HL_INFO_DEVICE_STATUS)
+	/*
+	 * Information is returned for the following opcodes even if the device
+	 * is disabled or in reset.
+	 */
+	switch (args->op) {
+	case HL_INFO_HW_IP_INFO:
+		return hw_ip_info(hdev, args);
+
+	case HL_INFO_DEVICE_STATUS:
 		return device_status_info(hdev, args);
 
+	default:
+		break;
+	}
+
 	if (hl_device_disabled_or_in_reset(hdev)) {
 		dev_warn_ratelimited(dev,
 			"Device is %s. Can't execute INFO IOCTL\n",
@@ -216,10 +227,6 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
 	}
 
 	switch (args->op) {
-	case HL_INFO_HW_IP_INFO:
-		rc = hw_ip_info(hdev, args);
-		break;
-
 	case HL_INFO_HW_EVENTS:
 		rc = hw_events_info(hdev, args);
 		break;
-- 
2.17.1


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

* Re: [PATCH] habanalabs: Handle HW_IP_INFO if device disabled or in reset
  2019-08-08 12:30 [PATCH] habanalabs: Handle HW_IP_INFO if device disabled or in reset Tomer Tayar
@ 2019-08-08 14:11 ` Oded Gabbay
  0 siblings, 0 replies; 2+ messages in thread
From: Oded Gabbay @ 2019-08-08 14:11 UTC (permalink / raw)
  To: Tomer Tayar; +Cc: linux-kernel

On Thu, Aug 8, 2019 at 3:30 PM Tomer Tayar <ttayar@habana.ai> wrote:
>
> The HW IP information is relevant even if the device is disabled or in
> reset, so always handle the corresponding INFO IOCTL opcode.
>
> Signed-off-by: Tomer Tayar <ttayar@habana.ai>
> ---
>  drivers/misc/habanalabs/habanalabs_ioctl.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/misc/habanalabs/habanalabs_ioctl.c b/drivers/misc/habanalabs/habanalabs_ioctl.c
> index 3ce65459b01c..589324ac19d0 100644
> --- a/drivers/misc/habanalabs/habanalabs_ioctl.c
> +++ b/drivers/misc/habanalabs/habanalabs_ioctl.c
> @@ -204,10 +204,21 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
>         struct hl_device *hdev = hpriv->hdev;
>         int rc;
>
> -       /* We want to return device status even if it disabled or in reset */
> -       if (args->op == HL_INFO_DEVICE_STATUS)
> +       /*
> +        * Information is returned for the following opcodes even if the device
> +        * is disabled or in reset.
> +        */
> +       switch (args->op) {
> +       case HL_INFO_HW_IP_INFO:
> +               return hw_ip_info(hdev, args);
> +
> +       case HL_INFO_DEVICE_STATUS:
>                 return device_status_info(hdev, args);
>
> +       default:
> +               break;
> +       }
> +
>         if (hl_device_disabled_or_in_reset(hdev)) {
>                 dev_warn_ratelimited(dev,
>                         "Device is %s. Can't execute INFO IOCTL\n",
> @@ -216,10 +227,6 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
>         }
>
>         switch (args->op) {
> -       case HL_INFO_HW_IP_INFO:
> -               rc = hw_ip_info(hdev, args);
> -               break;
> -
>         case HL_INFO_HW_EVENTS:
>                 rc = hw_events_info(hdev, args);
>                 break;
> --
> 2.17.1
>

This patch is:
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>

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

end of thread, other threads:[~2019-08-08 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 12:30 [PATCH] habanalabs: Handle HW_IP_INFO if device disabled or in reset Tomer Tayar
2019-08-08 14:11 ` Oded Gabbay

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