From: Guenter Roeck <linux@roeck-us.net>
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH 2/3] hwmon: axi-fan-control: handle irqs in natural order
Date: Wed, 11 Aug 2021 21:38:41 -0700 [thread overview]
Message-ID: <20210812043841.GA1115561@roeck-us.net> (raw)
In-Reply-To: <20210811114853.159298-3-nuno.sa@analog.com>
On Wed, Aug 11, 2021 at 01:48:52PM +0200, Nuno Sá wrote:
> The core will now start out of reset at boot as soon as clocking is
> available. Hence, by the time we unmask the interrupts we already might
> have some of them set. Thus, it's important to handle them in the
> natural order the core generates them. Otherwise, we could process
> 'ADI_IRQ_SRC_PWM_CHANGED' before 'ADI_IRQ_SRC_TEMP_INCREASE' and
> erroneously set 'update_tacho_params' to true.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/axi-fan-control.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c
> index 901d1588234d..c898ad121dc7 100644
> --- a/drivers/hwmon/axi-fan-control.c
> +++ b/drivers/hwmon/axi-fan-control.c
> @@ -283,18 +283,9 @@ static irqreturn_t axi_fan_control_irq_handler(int irq, void *data)
> u32 irq_pending = axi_ioread(ADI_REG_IRQ_PENDING, ctl);
> u32 clear_mask;
>
> - if (irq_pending & ADI_IRQ_SRC_NEW_MEASUR) {
> - if (ctl->update_tacho_params) {
> - u32 new_tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl);
> -
> - /* get 25% tolerance */
> - u32 tach_tol = DIV_ROUND_CLOSEST(new_tach * 25, 100);
> - /* set new tacho parameters */
> - axi_iowrite(new_tach, ADI_REG_TACH_PERIOD, ctl);
> - axi_iowrite(tach_tol, ADI_REG_TACH_TOLERANCE, ctl);
> - ctl->update_tacho_params = false;
> - }
> - }
> + if (irq_pending & ADI_IRQ_SRC_TEMP_INCREASE)
> + /* hardware requested a new pwm */
> + ctl->hw_pwm_req = true;
>
> if (irq_pending & ADI_IRQ_SRC_PWM_CHANGED) {
> /*
> @@ -310,9 +301,18 @@ static irqreturn_t axi_fan_control_irq_handler(int irq, void *data)
> }
> }
>
> - if (irq_pending & ADI_IRQ_SRC_TEMP_INCREASE)
> - /* hardware requested a new pwm */
> - ctl->hw_pwm_req = true;
> + if (irq_pending & ADI_IRQ_SRC_NEW_MEASUR) {
> + if (ctl->update_tacho_params) {
> + u32 new_tach = axi_ioread(ADI_REG_TACH_MEASUR, ctl);
> + /* get 25% tolerance */
> + u32 tach_tol = DIV_ROUND_CLOSEST(new_tach * 25, 100);
> +
> + /* set new tacho parameters */
> + axi_iowrite(new_tach, ADI_REG_TACH_PERIOD, ctl);
> + axi_iowrite(tach_tol, ADI_REG_TACH_TOLERANCE, ctl);
> + ctl->update_tacho_params = false;
> + }
> + }
>
> if (irq_pending & ADI_IRQ_SRC_TACH_ERR)
> ctl->fan_fault = 1;
next prev parent reply other threads:[~2021-08-12 4:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 11:48 [PATCH 0/3] AXI FAN new features and improvements Nuno Sá
2021-08-11 11:48 ` [PATCH 1/3] hwmon: axi-fan-control: make sure the clock is enabled Nuno Sá
2021-08-12 4:37 ` Guenter Roeck
2021-08-11 11:48 ` [PATCH 2/3] hwmon: axi-fan-control: handle irqs in natural order Nuno Sá
2021-08-12 4:38 ` Guenter Roeck [this message]
2021-08-11 11:48 ` [PATCH 3/3] hwmon: axi-fan-control: support temperature vs pwm points Nuno Sá
2021-08-12 4:39 ` Guenter Roeck
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=20210812043841.GA1115561@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=nuno.sa@analog.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 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).