From: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
To: John Keeping <john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org>
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] iommu/rockchip: Fix "is stall active" check
Date: Tue, 05 Apr 2016 10:21:27 -0700 [thread overview]
Message-ID: <5389576.zuTxjFsmO4@phil> (raw)
In-Reply-To: <1459865146-25308-1-git-send-email-john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org>
Am Dienstag, 5. April 2016, 15:05:46 schrieb John Keeping:
> Since commit cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") rk_iommu_is_stall_active() always returns false because the
> bitwise AND operates on the boolean flag promoted to an integer and a
> value that is either zero or BIT(2).
>
> Explicitly convert the right-hand value to a boolean so that both sides
> are guaranteed to be either zero or one.
>
> rk_iommu_is_paging_enabled() does not suffer from the same problem since
> RK_MMU_STATUS_PAGING_ENABLED is BIT(0), but let's apply the same change
> for consistency and to make it clear that it's correct without needing
> to lookup the value.
>
> Fixes: cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") Signed-off-by: John Keeping <john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org>
Nice catch, thanks.
Reviewed-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
John, out of curiosity, how did you find that problem? Excess stall error
messages or something else?
Thanks
Heiko
> ---
> drivers/iommu/rockchip-iommu.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/rockchip-iommu.c
> b/drivers/iommu/rockchip-iommu.c index a6f593a0a29e..5710a06c3049 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -315,8 +315,8 @@ static bool rk_iommu_is_stall_active(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - active &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_STALL_ACTIVE;
> + active &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_STALL_ACTIVE);
>
> return active;
> }
> @@ -327,8 +327,8 @@ static bool rk_iommu_is_paging_enabled(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - enable &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_PAGING_ENABLED;
> + enable &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_PAGING_ENABLED);
>
> return enable;
> }
WARNING: multiple messages have this Message-ID (diff)
From: heiko@sntech.de (Heiko Stuebner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/rockchip: Fix "is stall active" check
Date: Tue, 05 Apr 2016 10:21:27 -0700 [thread overview]
Message-ID: <5389576.zuTxjFsmO4@phil> (raw)
In-Reply-To: <1459865146-25308-1-git-send-email-john@metanate.com>
Am Dienstag, 5. April 2016, 15:05:46 schrieb John Keeping:
> Since commit cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") rk_iommu_is_stall_active() always returns false because the
> bitwise AND operates on the boolean flag promoted to an integer and a
> value that is either zero or BIT(2).
>
> Explicitly convert the right-hand value to a boolean so that both sides
> are guaranteed to be either zero or one.
>
> rk_iommu_is_paging_enabled() does not suffer from the same problem since
> RK_MMU_STATUS_PAGING_ENABLED is BIT(0), but let's apply the same change
> for consistency and to make it clear that it's correct without needing
> to lookup the value.
>
> Fixes: cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") Signed-off-by: John Keeping <john@metanate.com>
Nice catch, thanks.
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
John, out of curiosity, how did you find that problem? Excess stall error
messages or something else?
Thanks
Heiko
> ---
> drivers/iommu/rockchip-iommu.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/rockchip-iommu.c
> b/drivers/iommu/rockchip-iommu.c index a6f593a0a29e..5710a06c3049 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -315,8 +315,8 @@ static bool rk_iommu_is_stall_active(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - active &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_STALL_ACTIVE;
> + active &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_STALL_ACTIVE);
>
> return active;
> }
> @@ -327,8 +327,8 @@ static bool rk_iommu_is_paging_enabled(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - enable &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_PAGING_ENABLED;
> + enable &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_PAGING_ENABLED);
>
> return enable;
> }
WARNING: multiple messages have this Message-ID (diff)
From: Heiko Stuebner <heiko@sntech.de>
To: John Keeping <john@metanate.com>
Cc: Joerg Roedel <joro@8bytes.org>,
iommu@lists.linux-foundation.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/rockchip: Fix "is stall active" check
Date: Tue, 05 Apr 2016 10:21:27 -0700 [thread overview]
Message-ID: <5389576.zuTxjFsmO4@phil> (raw)
In-Reply-To: <1459865146-25308-1-git-send-email-john@metanate.com>
Am Dienstag, 5. April 2016, 15:05:46 schrieb John Keeping:
> Since commit cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") rk_iommu_is_stall_active() always returns false because the
> bitwise AND operates on the boolean flag promoted to an integer and a
> value that is either zero or BIT(2).
>
> Explicitly convert the right-hand value to a boolean so that both sides
> are guaranteed to be either zero or one.
>
> rk_iommu_is_paging_enabled() does not suffer from the same problem since
> RK_MMU_STATUS_PAGING_ENABLED is BIT(0), but let's apply the same change
> for consistency and to make it clear that it's correct without needing
> to lookup the value.
>
> Fixes: cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
> slaves") Signed-off-by: John Keeping <john@metanate.com>
Nice catch, thanks.
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
John, out of curiosity, how did you find that problem? Excess stall error
messages or something else?
Thanks
Heiko
> ---
> drivers/iommu/rockchip-iommu.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/rockchip-iommu.c
> b/drivers/iommu/rockchip-iommu.c index a6f593a0a29e..5710a06c3049 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -315,8 +315,8 @@ static bool rk_iommu_is_stall_active(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - active &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_STALL_ACTIVE;
> + active &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_STALL_ACTIVE);
>
> return active;
> }
> @@ -327,8 +327,8 @@ static bool rk_iommu_is_paging_enabled(struct rk_iommu
> *iommu) int i;
>
> for (i = 0; i < iommu->num_mmu; i++)
> - enable &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> - RK_MMU_STATUS_PAGING_ENABLED;
> + enable &= !!(rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
> + RK_MMU_STATUS_PAGING_ENABLED);
>
> return enable;
> }
next prev parent reply other threads:[~2016-04-05 17:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 14:05 [PATCH] iommu/rockchip: Fix "is stall active" check John Keeping
2016-04-05 14:05 ` John Keeping
2016-04-05 14:05 ` John Keeping
[not found] ` <1459865146-25308-1-git-send-email-john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org>
2016-04-05 17:21 ` Heiko Stuebner [this message]
2016-04-05 17:21 ` Heiko Stuebner
2016-04-05 17:21 ` Heiko Stuebner
2016-04-05 17:28 ` John Keeping
2016-04-05 17:28 ` John Keeping
2016-04-05 17:28 ` John Keeping
[not found] ` <20160405182858.382ea465.john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org>
2016-04-05 19:10 ` Heiko Stuebner
2016-04-05 19:10 ` Heiko Stuebner
2016-04-05 19:10 ` Heiko Stuebner
2016-04-06 7:45 ` Tomeu Vizoso
2016-04-06 7:45 ` Tomeu Vizoso
2016-04-06 7:45 ` Tomeu Vizoso
2016-04-07 12:50 ` Joerg Roedel
2016-04-07 12:50 ` Joerg Roedel
2016-04-07 12:50 ` Joerg Roedel
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=5389576.zuTxjFsmO4@phil \
--to=heiko-4mtyjxux2i+zqb+pc5nmwq@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=john-HooS5bfzL4hWk0Htik3J/w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
/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.