From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933460AbcDER3P (ORCPT ); Tue, 5 Apr 2016 13:29:15 -0400 Received: from dougal.metanate.com ([90.155.101.14]:16640 "EHLO metanate.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759011AbcDER3N (ORCPT ); Tue, 5 Apr 2016 13:29:13 -0400 Date: Tue, 5 Apr 2016 18:28:58 +0100 From: John Keeping To: Heiko Stuebner Cc: Joerg Roedel , 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 Message-ID: <20160405182858.382ea465.john@metanate.com> In-Reply-To: <5389576.zuTxjFsmO4@phil> References: <1459865146-25308-1-git-send-email-john@metanate.com> <5389576.zuTxjFsmO4@phil> Organization: Metanate Ltd X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 05 Apr 2016 10:21:27 -0700, Heiko Stuebner wrote: > 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 > > Nice catch, thanks. > > Reviewed-by: Heiko Stuebner > > John, out of curiosity, how did you find that problem? Excess stall error > messages or something else? I was testing the drm iommu patches I posted today [1] and noticed an "Enable stall request timed out" error when unbinding the display-subsystem, but the RK_MMU_STATUS value printed in the error message indicated that stall active was set. [1] http://article.gmane.org/gmane.comp.video.dri.devel/150721 > > --- > > 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; > > } >