From: Nishanth Menon on
Felipe Balbi had written, on 04/06/2010 11:32 AM, the following:
> On Tue, Apr 06, 2010 at 06:16:01PM +0200, ext Madhusudhan wrote:
>>
>>> -----Original Message-----
>>> From: Felipe Balbi [mailto:me(a)felipebalbi.com]
>>> Sent: Tuesday, April 06, 2010 12:01 AM
>>> To: Madhusudhan
>>> Cc: me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal Singh';
>>> tony(a)atomide.com; svenkatr(a)ti.com; linux-omap(a)vger.kernel.org; linux-
>>> kernel(a)vger.kernel.org; jarkko.lavinen(a)nokia.com
>>> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD card's
>>> peformance.
>>>
>>> Hi,
>>>
>>> On Mon, Apr 05, 2010 at 12:19:29PM -0500, Madhusudhan wrote:
>>>> Since the first if command already checks for the 8-bit the second check
>>>> like >= 4 is definitely not readable in my opinion.
>>> how come ???
>>>
>>>> Functionally do you see anything wrong with this patch??
>>> functionally no, but (hypothetical situation) and if on
>>> omap4/5/6/whatever, omap controller supports a bigger bus width then
>>> you'll have to add a line like:
>>>
>>> + if (mmc_slot(host).wires == 16)
>>> + mmc->caps |= (MMC_CAP_16_BIT_DATA | MMC_CAP_8_BIT_DATA |
>>> + MMC_CAP_4_BIT_DATA);
>>> - if (mmc_slot(host).wires == 8)
>>> + else if (mmc_slot(host).wires == 8)
>>>
>>> do you see the problem ?? In my opinion it doesn't scale well.
>>>
>> The point we should note here is that MMC spec supports a max bus width of
>> 8-bit. So anything beyond 8-bit is not in the picture as of today.
>
> in that case, the code could be:
>
> WARN_ON(mmc_slot(host).wires > 8);
>
> if (mmc_slot(host).wires == 8)
> mmc->caps |= MMC_CAP_8_BIT_DATA;
> if (mmc_slot(host).wires >= 4)
> mmc->caps |= MMC_CAP_4_BIT_DATA;
>
some reasons why i love switch statements ;) since I dont expect other
than precisely 4 and 8 (do we expect 5,6,7 - i might be wrong).. but if
it is so, wont the following be better?

switch (mmc_slot(host).wires)
{
case 8:
mmc->caps |= MMC_CAP_8_BIT_DATA;
/* fall thru*/
case 4:
mmc->caps |= MMC_CAP_4_BIT_DATA;
break;
default:
WARN("bad width");
}
--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Madhusudhan on


> -----Original Message-----
> From: Felipe Balbi [mailto:felipe.balbi(a)nokia.com]
> Sent: Tuesday, April 06, 2010 11:57 AM
> To: ext Nishanth Menon
> Cc: Balbi Felipe (Nokia-D/Helsinki); Chikkature Rajashekar, Madhusudhan;
> me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal Singh'; tony(a)atomide.com;
> S, Venkatraman; linux-omap(a)vger.kernel.org; linux-kernel(a)vger.kernel.org;
> Lavinen Jarkko (Nokia-D/Helsinki)
> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD card's
> peformance.
>
> On Tue, Apr 06, 2010 at 06:55:03PM +0200, ext Nishanth Menon wrote:
> >some reasons why i love switch statements ;) since I dont expect other
> >than precisely 4 and 8 (do we expect 5,6,7 - i might be wrong).. but if
> >it is so, wont the following be better?
> >
> >switch (mmc_slot(host).wires)
> >{
> >case 8:
> > mmc->caps |= MMC_CAP_8_BIT_DATA;
> > /* fall thru*/
> >case 4:
> > mmc->caps |= MMC_CAP_4_BIT_DATA;
> > break;
> >default:
> > WARN("bad width");
> >}
>
> I like that, but I remember Madhu (or someone else) saying he thinks
> it's less readable this way. Go figure...
>
Well, I did not comment on the usage of switch here. Note we only need to
handle 8-bit and 4-bit.The board files need not setup 8-bit or 4-bit if the
configuration of that board is 1-bit. The driver will still work in 1-bit
mode which would mean there is nothing to do in default case and should not
err out.

Regards,
Madhu

> --
> balbi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Nishanth Menon on
Chikkature Rajashekar, Madhusudhan had written, on 04/06/2010 06:23 PM,
the following:
>
>> -----Original Message-----
>> From: Felipe Balbi [mailto:felipe.balbi(a)nokia.com]
>> Sent: Tuesday, April 06, 2010 11:57 AM
>> To: ext Nishanth Menon
>> Cc: Balbi Felipe (Nokia-D/Helsinki); Chikkature Rajashekar, Madhusudhan;
>> me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal Singh'; tony(a)atomide.com;
>> S, Venkatraman; linux-omap(a)vger.kernel.org; linux-kernel(a)vger.kernel.org;
>> Lavinen Jarkko (Nokia-D/Helsinki)
>> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD card's
>> peformance.
>>
>> On Tue, Apr 06, 2010 at 06:55:03PM +0200, ext Nishanth Menon wrote:
>>> some reasons why i love switch statements ;) since I dont expect other
>>> than precisely 4 and 8 (do we expect 5,6,7 - i might be wrong).. but if
>>> it is so, wont the following be better?
>>>
>>> switch (mmc_slot(host).wires)
>>> {
>>> case 8:
>>> mmc->caps |= MMC_CAP_8_BIT_DATA;
>>> /* fall thru*/
>>> case 4:
>>> mmc->caps |= MMC_CAP_4_BIT_DATA;
>>> break;
>>> default:
>>> WARN("bad width");
>>> }
>> I like that, but I remember Madhu (or someone else) saying he thinks
>> it's less readable this way. Go figure...
>>
> Well, I did not comment on the usage of switch here. Note we only need to
> handle 8-bit and 4-bit.The board files need not setup 8-bit or 4-bit if the
> configuration of that board is 1-bit. The driver will still work in 1-bit
> mode which would mean there is nothing to do in default case and should not
> err out.
check the attachment out.. hope that takes care of it.. just as a
reference alone ofcourse..
--
Regards,
Nishanth Menon
From: Madhusudhan on


> -----Original Message-----
> From: Nishanth Menon [mailto:nm(a)ti.com]
> Sent: Tuesday, April 06, 2010 6:39 PM
> To: Chikkature Rajashekar, Madhusudhan
> Cc: felipe.balbi(a)nokia.com; me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal
> Singh'; tony(a)atomide.com; S, Venkatraman; linux-omap(a)vger.kernel.org;
> linux-kernel(a)vger.kernel.org; 'Lavinen Jarkko (Nokia-D/Helsinki)'
> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD card's
> peformance.
>
> Chikkature Rajashekar, Madhusudhan had written, on 04/06/2010 06:23 PM,
> the following:
> >
> >> -----Original Message-----
> >> From: Felipe Balbi [mailto:felipe.balbi(a)nokia.com]
> >> Sent: Tuesday, April 06, 2010 11:57 AM
> >> To: ext Nishanth Menon
> >> Cc: Balbi Felipe (Nokia-D/Helsinki); Chikkature Rajashekar,
> Madhusudhan;
> >> me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal Singh';
> tony(a)atomide.com;
> >> S, Venkatraman; linux-omap(a)vger.kernel.org; linux-
> kernel(a)vger.kernel.org;
> >> Lavinen Jarkko (Nokia-D/Helsinki)
> >> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD
> card's
> >> peformance.
> >>
> >> On Tue, Apr 06, 2010 at 06:55:03PM +0200, ext Nishanth Menon wrote:
> >>> some reasons why i love switch statements ;) since I dont expect other
> >>> than precisely 4 and 8 (do we expect 5,6,7 - i might be wrong).. but
> if
> >>> it is so, wont the following be better?
> >>>
> >>> switch (mmc_slot(host).wires)
> >>> {
> >>> case 8:
> >>> mmc->caps |= MMC_CAP_8_BIT_DATA;
> >>> /* fall thru*/
> >>> case 4:
> >>> mmc->caps |= MMC_CAP_4_BIT_DATA;
> >>> break;
> >>> default:
> >>> WARN("bad width");
> >>> }
> >> I like that, but I remember Madhu (or someone else) saying he thinks
> >> it's less readable this way. Go figure...
> >>
> > Well, I did not comment on the usage of switch here. Note we only need
> to
> > handle 8-bit and 4-bit.The board files need not setup 8-bit or 4-bit if
> the
> > configuration of that board is 1-bit. The driver will still work in 1-
> bit
> > mode which would mean there is nothing to do in default case and should
> not
> > err out.
> check the attachment out.. hope that takes care of it.. just as a
> reference alone ofcourse..

Nope. The default case is wrong. The assumption followed by controller
drivers is that if the board file says 4-bit or 8-bit set the capabilities
otherwise don't do any thing. The host will continue to work in 1-bit mode
which is a must. Your patch violates that (can not design a board without
connecting one data line at least :))

Also you can not say 1-bit is non-optimal because the board file dictates
the configuration based on what it is capable of. Why through a warning?
It is subjective.

Regards,
Madhu

> --
> Regards,
> Nishanth Menon

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Nishanth Menon on
Chikkature Rajashekar, Madhusudhan had written, on 04/06/2010 07:16 PM,
the following:
>
>> -----Original Message-----
>> From: Nishanth Menon [mailto:nm(a)ti.com]
>> Sent: Tuesday, April 06, 2010 6:39 PM
>> To: Chikkature Rajashekar, Madhusudhan
>> Cc: felipe.balbi(a)nokia.com; me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal
>> Singh'; tony(a)atomide.com; S, Venkatraman; linux-omap(a)vger.kernel.org;
>> linux-kernel(a)vger.kernel.org; 'Lavinen Jarkko (Nokia-D/Helsinki)'
>> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD card's
>> peformance.
>>
>> Chikkature Rajashekar, Madhusudhan had written, on 04/06/2010 06:23 PM,
>> the following:
>>>> -----Original Message-----
>>>> From: Felipe Balbi [mailto:felipe.balbi(a)nokia.com]
>>>> Sent: Tuesday, April 06, 2010 11:57 AM
>>>> To: ext Nishanth Menon
>>>> Cc: Balbi Felipe (Nokia-D/Helsinki); Chikkature Rajashekar,
>> Madhusudhan;
>>>> me(a)felipebalbi.com; 'kishore kadiyala'; 'Vimal Singh';
>> tony(a)atomide.com;
>>>> S, Venkatraman; linux-omap(a)vger.kernel.org; linux-
>> kernel(a)vger.kernel.org;
>>>> Lavinen Jarkko (Nokia-D/Helsinki)
>>>> Subject: Re: [PATCH v3] OMAP: Fix for bus width which improves SD
>> card's
>>>> peformance.
>>>>
>>>> On Tue, Apr 06, 2010 at 06:55:03PM +0200, ext Nishanth Menon wrote:
>>>>> some reasons why i love switch statements ;) since I dont expect other
>>>>> than precisely 4 and 8 (do we expect 5,6,7 - i might be wrong).. but
>> if
>>>>> it is so, wont the following be better?
>>>>>
>>>>> switch (mmc_slot(host).wires)
>>>>> {
>>>>> case 8:
>>>>> mmc->caps |= MMC_CAP_8_BIT_DATA;
>>>>> /* fall thru*/
>>>>> case 4:
>>>>> mmc->caps |= MMC_CAP_4_BIT_DATA;
>>>>> break;
>>>>> default:
>>>>> WARN("bad width");
>>>>> }
>>>> I like that, but I remember Madhu (or someone else) saying he thinks
>>>> it's less readable this way. Go figure...
>>>>
>>> Well, I did not comment on the usage of switch here. Note we only need
>> to
>>> handle 8-bit and 4-bit.The board files need not setup 8-bit or 4-bit if
>> the
>>> configuration of that board is 1-bit. The driver will still work in 1-
>> bit
>>> mode which would mean there is nothing to do in default case and should
>> not
>>> err out.
>> check the attachment out.. hope that takes care of it.. just as a
>> reference alone ofcourse..
>
> Nope. The default case is wrong. The assumption followed by controller
> drivers is that if the board file says 4-bit or 8-bit set the capabilities
> otherwise don't do any thing. The host will continue to work in 1-bit mode
> which is a must. Your patch violates that (can not design a board without
> connecting one data line at least :))
>
> Also you can not say 1-bit is non-optimal because the board file dictates
> the configuration based on what it is capable of. Why through a warning?
> It is subjective.
Point noted. try n++:
switch(mmc_slot(host).wires) {
case 8:
mmc->caps |= MMC_CAP_8_BIT_DATA;
/* Fall through */
case 4:
mmc->caps |= MMC_CAP_4_BIT_DATA;
break;
case 0:
/* assuming nothing was given by board, use 1 */
case 1:
/* nothing to crib here */
break;
default:
/* Completely unexpected.. try 1 bit instead */
dev_crit(mmc_dev(host->mmc), "Invalid width %d"
" used! using 1 instead\n",
mmc_slot(host).wires);
}

note: we should crib if the board file made a mistake here.. say it gave
10 wire or so.. I agree that we can recover by stepping back to 1 bit
mode.. but we gotta tell the log that something aint right..

--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/