From mboxrd@z Thu Jan 1 00:00:00 1970 From: richard.zhao@linaro.org (Richard Zhao) Date: Wed, 11 Jan 2012 20:35:57 +0800 Subject: [PATCH 6/6] dma/imx-sdma: check whether event_id0 < 32 when set event_mask In-Reply-To: References: <1326178910-14044-1-git-send-email-richard.zhao@linaro.org> <1326178910-14044-6-git-send-email-richard.zhao@linaro.org> <20120110142008.GE26599@S2101-09.ap.freescale.net> <20120110142939.GB2019@richard-laptop> <20120110153836.GA27831@S2101-09.ap.freescale.net> <20120111005322.GB2414@b20223-02.ap.freescale.net> <20120111014730.GE2414@b20223-02.ap.freescale.net> Message-ID: <20120111123555.GA1916@richard-laptop> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Jan 11, 2012 at 02:37:08PM +0800, Eric Miao wrote: > On Wed, Jan 11, 2012 at 9:47 AM, Richard Zhao > wrote: > > On Wed, Jan 11, 2012 at 08:53:23AM +0800, Richard Zhao wrote: > >> On Tue, Jan 10, 2012 at 11:38:39PM +0800, Shawn Guo wrote: > >> > On Tue, Jan 10, 2012 at 10:29:42PM +0800, Richard Zhao wrote: > >> > > On Tue, Jan 10, 2012 at 10:20:10PM +0800, Shawn Guo wrote: > >> > > > On Tue, Jan 10, 2012 at 03:01:50PM +0800, Richard Zhao wrote: > >> > > > > Signed-off-by: Richard Zhao > >> > > > > --- > >> > > > > >> > > > I think it deserves a sensible commit message explaining why the patch > >> > > > is needed. > >> > > If event_id0 < 32, 1 << (sdmac->event_id0 - 32) is not zero. > >> This meant to make you clear about the patch. I'll add it in commit > >> message. > > unsigned int t = 31; > > printf("%d %08x\n", t, 1 << (t-32)); > > > > I test above code on both x86 and arm. They shows different results. > > x86: 31 80000000 > > arm: 31 00000000 > > > > I think we still need this patch. we shoud not let it depends on gcc's > > behavior. > > > > Thanks > > Richard > >> > > > >> > My point is you may explain the exact problem you are seeing without > >> > this patch > >> The kernel don't have event_id < 32 case yet. I found the bug when > >> I review the code. > >> > and how the patch helps here. ?In general, doing so would > >> > win a warm feeling from reviewers much more easily than leaving the > >> > commit message empty there. > >> I understand your point that comment as much as possible. > >> > > Shawn, > > I think Richard has made the issue quite clear here, the original > code does seem to have some problems even to me, who do not > understand the very details of the SDMA: > > - sdmac->event_mask0 = 1 << sdmac->event_id0; > - sdmac->event_mask1 = 1 << (sdmac->event_id0 - 32); > > 1. if sdmac->event_id0 >= 32, which will cause event_mask0 to be incorrect > 2. if sdmac->event_id < 32, sdmac->event_mask1 will be incorrect > > An alternate way is to use the standard bit operations: > > struct sdma_channel { > > ... > > unsigned long event_mask[2]; > > ... > }; > > set_bit(sdmac->event_id0, event_mask); > > Which avoids branch instructions and add a bit protection for the operation > to be atomic enough (event_mask0/1 won't be inconsistent). It's a good idea. Thanks Richard From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757425Ab2AKMgQ (ORCPT ); Wed, 11 Jan 2012 07:36:16 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:58826 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752579Ab2AKMgO (ORCPT ); Wed, 11 Jan 2012 07:36:14 -0500 Date: Wed, 11 Jan 2012 20:35:57 +0800 From: Richard Zhao To: Eric Miao Cc: Richard Zhao , Shawn Guo , patches@linaro.org, vinod.koul@intel.com, linux-kernel@vger.kernel.org, kernel@pengutronix.de, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/6] dma/imx-sdma: check whether event_id0 < 32 when set event_mask Message-ID: <20120111123555.GA1916@richard-laptop> References: <1326178910-14044-1-git-send-email-richard.zhao@linaro.org> <1326178910-14044-6-git-send-email-richard.zhao@linaro.org> <20120110142008.GE26599@S2101-09.ap.freescale.net> <20120110142939.GB2019@richard-laptop> <20120110153836.GA27831@S2101-09.ap.freescale.net> <20120111005322.GB2414@b20223-02.ap.freescale.net> <20120111014730.GE2414@b20223-02.ap.freescale.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 11, 2012 at 02:37:08PM +0800, Eric Miao wrote: > On Wed, Jan 11, 2012 at 9:47 AM, Richard Zhao > wrote: > > On Wed, Jan 11, 2012 at 08:53:23AM +0800, Richard Zhao wrote: > >> On Tue, Jan 10, 2012 at 11:38:39PM +0800, Shawn Guo wrote: > >> > On Tue, Jan 10, 2012 at 10:29:42PM +0800, Richard Zhao wrote: > >> > > On Tue, Jan 10, 2012 at 10:20:10PM +0800, Shawn Guo wrote: > >> > > > On Tue, Jan 10, 2012 at 03:01:50PM +0800, Richard Zhao wrote: > >> > > > > Signed-off-by: Richard Zhao > >> > > > > --- > >> > > > > >> > > > I think it deserves a sensible commit message explaining why the patch > >> > > > is needed. > >> > > If event_id0 < 32, 1 << (sdmac->event_id0 - 32) is not zero. > >> This meant to make you clear about the patch. I'll add it in commit > >> message. > > unsigned int t = 31; > > printf("%d %08x\n", t, 1 << (t-32)); > > > > I test above code on both x86 and arm. They shows different results. > > x86: 31 80000000 > > arm: 31 00000000 > > > > I think we still need this patch. we shoud not let it depends on gcc's > > behavior. > > > > Thanks > > Richard > >> > > > >> > My point is you may explain the exact problem you are seeing without > >> > this patch > >> The kernel don't have event_id < 32 case yet. I found the bug when > >> I review the code. > >> > and how the patch helps here.  In general, doing so would > >> > win a warm feeling from reviewers much more easily than leaving the > >> > commit message empty there. > >> I understand your point that comment as much as possible. > >> > > Shawn, > > I think Richard has made the issue quite clear here, the original > code does seem to have some problems even to me, who do not > understand the very details of the SDMA: > > - sdmac->event_mask0 = 1 << sdmac->event_id0; > - sdmac->event_mask1 = 1 << (sdmac->event_id0 - 32); > > 1. if sdmac->event_id0 >= 32, which will cause event_mask0 to be incorrect > 2. if sdmac->event_id < 32, sdmac->event_mask1 will be incorrect > > An alternate way is to use the standard bit operations: > > struct sdma_channel { > > ... > > unsigned long event_mask[2]; > > ... > }; > > set_bit(sdmac->event_id0, event_mask); > > Which avoids branch instructions and add a bit protection for the operation > to be atomic enough (event_mask0/1 won't be inconsistent). It's a good idea. Thanks Richard