From: Scott Wood <scottwood@freescale.com>
To: Rivera Jose-B46482 <German.Rivera@freescale.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
Yoder Stuart-B08248 <stuart.yoder@freescale.com>,
Hamciuc Bogdan-BHAMCIU1 <bhamciu1@freescale.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"Sharma Bhupesh-B45370" <bhupesh.sharma@freescale.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"agraf@suse.de" <agraf@suse.de>,
"Erez Nir-RM30794" <nir.erez@freescale.com>,
katz Itai-RM05202 <itai.katz@freescale.com>,
Marginean Alexandru-R89243 <R89243@freescale.com>,
Schmitt Richard-B43082 <richard.schmitt@freescale.com>
Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
Date: Tue, 5 May 2015 15:40:13 -0500 [thread overview]
Message-ID: <1430858413.16357.252.camel@freescale.com> (raw)
In-Reply-To: <DM2PR0301MB13095252BF220671E3BF42AEFED10@DM2PR0301MB1309.namprd03.prod.outlook.com>
On Tue, 2015-05-05 at 15:22 -0500, Rivera Jose-B46482 wrote:
>
>
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Tuesday, May 05, 2015 2:57 PM
> > To: Dan Carpenter
> > Cc: Rivera Jose-B46482; devel@driverdev.osuosl.org; Yoder Stuart-B08248;
> > Hamciuc Bogdan-BHAMCIU1; arnd@arndb.de; Sharma Bhupesh-B45370;
> > gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; agraf@suse.de;
> > Erez Nir-RM30794; katz Itai-RM05202; Marginean Alexandru-R89243; Schmitt
> > Richard-B43082
> > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
> >
> > On Tue, 2015-05-05 at 19:40 +0300, Dan Carpenter wrote:
> > > On Tue, May 05, 2015 at 04:08:49PM +0000, Jose Rivera wrote:
> > > > > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
> > > > >
> > > > > On Mon, May 04, 2015 at 10:09:08PM +0000, Jose Rivera wrote:
> > > > > > > > + WARN_ON((int16_t)irq_count < 0);
> > > > > > >
> > > > > > > This code is doing "WARN_ON(test_bit(15, (unsigned long
> > > > > *)&irq_count));".
> > > > > > > That seems like nonsense. Anyway, just delete the WARN_ON().
> > > > > > >
> > > > > > I disagree. This WARN_ON is checking that irq_count is in the
> > > > > > expected range (it fits in int16_t as a positive number). The
> > > > > > dprc_scan_objects() function expects irq_count to be of type
> > > > > > "unsigned int" (which is 32-bit unsigned)
> > > > > >
> > > > >
> > > > > You're not allowed to disagree because it's a testable thing and
> > > > > not an opinion about style or something. :P What you want is:
> > > > >
> > > > > WARN_ON(irq_count > SHRT_MAX);
> > > > >
> > > > I see your point now. The check "(int16_t)irq_count < 0)" will not
> > > > be able to catch 0x10000 > 0x7fff, but "irq_count > SHRT_MAX) will.
> > > > So I'll make the suggested change, but I would prefer to use S16_MAX
> > > > rather than SHRT_MAX.
> > > >
> > >
> > > Huh? I didn't even know about the S16_MAX definition. There are
> > > literally no users of it in the kernel. It's not very fair because
> > > there are few users of SHRT_MAX. But there are literally no users of
> > > S32_MAX in the kernel and 358 users of INT_MAX.
> > >
> > > Don't insist that you must be special and different from everyone else.
> >
> > There are some users of U16_MAX, U32_MAX, and U64_MAX. Why use a limit
> > for a different type than is being used? Why have s16/s32 at all if
> > you're going to conflate it with short/int elsewhere?
> >
> > That said, I don't see where this code is actually using s16 (or
> > int16_t) for irq_count except in these weird error checks. German, why
> > do you need to check against 0x7fff (whatever you call it) at all?
> > Won't comparing to a promoted-to-unsigned-int .max_count (as you do
> > immediately after the WARN_ON) suffice?
> >
> mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count is of type int16_t
> (and is so, because its value comes from an MC API that returns
> an int16_t). The reason for checking irq_count against 0x7ffff is to
> catch the case in which irq_count is out of range (irq_count originates
> from values coming from the MC device, so we should do some validation
> before using it)
Comparing irq_count with max_count will catch any condition that
comparing irq_count with 0x7fff will catch.
-Scott
next prev parent reply other threads:[~2015-05-05 20:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 17:39 [PATCH 0/7] staging: fsl-mc: New functionality to the MC bus driver J. German Rivera
2015-04-28 17:39 ` [PATCH 1/7] staging: fsl-mc: MC bus IRQ support J. German Rivera
2015-04-30 11:49 ` Dan Carpenter
2015-05-04 22:09 ` Jose Rivera
2015-05-05 8:48 ` Dan Carpenter
2015-05-05 16:08 ` Jose Rivera
2015-05-05 16:40 ` Dan Carpenter
2015-05-05 19:56 ` Scott Wood
2015-05-05 20:22 ` Jose Rivera
2015-05-05 20:40 ` Scott Wood [this message]
2015-05-06 6:42 ` Dan Carpenter
2015-05-05 19:42 ` Scott Wood
2015-05-05 20:26 ` Jose Rivera
2015-04-28 17:39 ` [PATCH 2/7] staging: fsl_-mc: add device binding path 'driver_override' J. German Rivera
2015-04-28 17:39 ` [PATCH 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children J. German Rivera
2015-04-28 17:39 ` [PATCH 4/7] staging: fsl-mc: Upgraded MC bus driver to match MC fw 7.0.0 J. German Rivera
2015-04-30 12:12 ` Dan Carpenter
2015-05-04 23:58 ` Jose Rivera
2015-05-05 8:51 ` Dan Carpenter
2015-04-28 17:39 ` [PATCH 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support J. German Rivera
2015-04-28 17:39 ` [PATCH 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls J. German Rivera
2015-04-30 12:59 ` Dan Carpenter
2015-05-05 16:20 ` Jose Rivera
2015-04-28 17:39 ` [PATCH 7/7] staging: fsl-mc: Use DPMCP IRQ and completion var to wait for MC J. German Rivera
2015-04-30 13:01 ` Dan Carpenter
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=1430858413.16357.252.camel@freescale.com \
--to=scottwood@freescale.com \
--cc=German.Rivera@freescale.com \
--cc=R89243@freescale.com \
--cc=agraf@suse.de \
--cc=arnd@arndb.de \
--cc=bhamciu1@freescale.com \
--cc=bhupesh.sharma@freescale.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=itai.katz@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nir.erez@freescale.com \
--cc=richard.schmitt@freescale.com \
--cc=stuart.yoder@freescale.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.