All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <robert.hancock@calian.com>
To: "jic23@kernel.org" <jic23@kernel.org>
Cc: "michal.simek@amd.com" <michal.simek@amd.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds
Date: Thu, 14 Sep 2023 23:45:02 +0000	[thread overview]
Message-ID: <aaf5b4e3e5a87e8beee5218cd73ed018135f28a3.camel@calian.com> (raw)
In-Reply-To: <20230914212432.2842010-2-robert.hancock@calian.com>

On Thu, 2023-09-14 at 15:24 -0600, Robert Hancock wrote:
> In the probe function, the driver was reading out the thresholds
> already
> set in the core, which can be configured by the user in the Vivado
> tools
> when the FPGA image is built. However, it later clobbered those
> values
> with zero or maximum values. In particular, the overtemperature
> shutdown
> threshold register was overwritten with the max value, which
> effectively
> prevents the FPGA from shutting down when the desired threshold was
> eached, potentially risking hardware damage in that case.
> 
> Remove this code to leave the preconfigured default threshold values
> intact.

Apparently this change is necessary but not sufficient, as the driver
is also disabling all the alarm bits which are needed for the
overtemperature shutdown to actually function. Will follow up with a
new version shortly.

> 
> Fixes: bdc8cda1d010 ("iio:adc: Add Xilinx XADC driver")
> Signed-off-by: Robert Hancock <robert.hancock@calian.com>
> ---
>  drivers/iio/adc/xilinx-xadc-core.c | 16 ----------------
>  1 file changed, 16 deletions(-)
> 
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c
> b/drivers/iio/adc/xilinx-xadc-core.c
> index dba73300f894..88d523ac7881 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1429,22 +1429,6 @@ static int xadc_probe(struct platform_device
> *pdev)
>         if (ret)
>                 return ret;
>  
> -       /* Set thresholds to min/max */
> -       for (i = 0; i < 16; i++) {
> -               /*
> -                * Set max voltage threshold and both temperature
> thresholds to
> -                * 0xffff, min voltage threshold to 0.
> -                */
> -               if (i % 8 < 4 || i == 7)
> -                       xadc->threshold[i] = 0xffff;
> -               else
> -                       xadc->threshold[i] = 0;
> -               ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i),
> -                       xadc->threshold[i]);
> -               if (ret)
> -                       return ret;
> -       }
> -
>         /* Go to non-buffered mode */
>         xadc_postdisable(indio_dev);
>  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Robert Hancock <robert.hancock@calian.com>
To: "jic23@kernel.org" <jic23@kernel.org>
Cc: "michal.simek@amd.com" <michal.simek@amd.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds
Date: Thu, 14 Sep 2023 23:45:02 +0000	[thread overview]
Message-ID: <aaf5b4e3e5a87e8beee5218cd73ed018135f28a3.camel@calian.com> (raw)
In-Reply-To: <20230914212432.2842010-2-robert.hancock@calian.com>

On Thu, 2023-09-14 at 15:24 -0600, Robert Hancock wrote:
> In the probe function, the driver was reading out the thresholds
> already
> set in the core, which can be configured by the user in the Vivado
> tools
> when the FPGA image is built. However, it later clobbered those
> values
> with zero or maximum values. In particular, the overtemperature
> shutdown
> threshold register was overwritten with the max value, which
> effectively
> prevents the FPGA from shutting down when the desired threshold was
> eached, potentially risking hardware damage in that case.
> 
> Remove this code to leave the preconfigured default threshold values
> intact.

Apparently this change is necessary but not sufficient, as the driver
is also disabling all the alarm bits which are needed for the
overtemperature shutdown to actually function. Will follow up with a
new version shortly.

> 
> Fixes: bdc8cda1d010 ("iio:adc: Add Xilinx XADC driver")
> Signed-off-by: Robert Hancock <robert.hancock@calian.com>
> ---
>  drivers/iio/adc/xilinx-xadc-core.c | 16 ----------------
>  1 file changed, 16 deletions(-)
> 
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c
> b/drivers/iio/adc/xilinx-xadc-core.c
> index dba73300f894..88d523ac7881 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1429,22 +1429,6 @@ static int xadc_probe(struct platform_device
> *pdev)
>         if (ret)
>                 return ret;
>  
> -       /* Set thresholds to min/max */
> -       for (i = 0; i < 16; i++) {
> -               /*
> -                * Set max voltage threshold and both temperature
> thresholds to
> -                * 0xffff, min voltage threshold to 0.
> -                */
> -               if (i % 8 < 4 || i == 7)
> -                       xadc->threshold[i] = 0xffff;
> -               else
> -                       xadc->threshold[i] = 0;
> -               ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i),
> -                       xadc->threshold[i]);
> -               if (ret)
> -                       return ret;
> -       }
> -
>         /* Go to non-buffered mode */
>         xadc_postdisable(indio_dev);
>  


  reply	other threads:[~2023-09-14 23:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 21:24 [PATCH 0/2] Xilinx XADC fixes Robert Hancock
2023-09-14 21:24 ` Robert Hancock
2023-09-14 21:24 ` [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds Robert Hancock
2023-09-14 21:24   ` Robert Hancock
2023-09-14 23:45   ` Robert Hancock [this message]
2023-09-14 23:45     ` Robert Hancock
2023-09-14 21:24 ` [PATCH 2/2] iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale Robert Hancock
2023-09-14 21:24   ` Robert Hancock

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=aaf5b4e3e5a87e8beee5218cd73ed018135f28a3.camel@calian.com \
    --to=robert.hancock@calian.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=michal.simek@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.