9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sheevaplug SD card driver
@ 2012-10-18 12:42 Richard Miller
  2012-10-18 13:46 ` Gorka Guardiola
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Richard Miller @ 2012-10-18 12:42 UTC (permalink / raw)
  To: 9fans

As a side effect of the raspberry pi work, I've produced an SD card
driver for the sheevaplug (and presumably other kirkwood platforms).
It's in two sections: the top layer does the card protocol and is
identical between rpi and kw (could go into /sys/src/9/port?), while
the lower layer does the host sdio interface.  The two layers link via
the usual table of functions, so if we encounter a platform with more
than one sd host interface [anybody seen one?] it won't be hard to
cope with.

Would anyone with a sheevaplug or similar, and a collection of SD
cards, like to try it out before I submit a patch?  Source is in
/n/sources/contrib/miller/9/kw, and if you haven't pulled kernel
sources recently you'll need to update /sys/src/9/port/sd.h as well.
The drive appears as '#S/sdM0', and a FAT-formatted SD card can be
mounted simply by doing "diskparts; dosmnt 1 /n/sd".  You can of
course hot-swap cards without rebooting, but don't forget to unmount
first.

Although the driver is called sdmmc.c, it handles only SD cards and
not the older MMC standard.  I think it's only a matter of slightly
different initialisation, but I haven't got an actual MMC card to
test it with.  If anyone cares enough to send me one, I'll see if
I can make that work too.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-18 12:42 [9fans] sheevaplug SD card driver Richard Miller
@ 2012-10-18 13:46 ` Gorka Guardiola
  2012-10-18 14:24 ` David du Colombier
  2012-10-18 16:05 ` Skip Tavakkolian
  2 siblings, 0 replies; 20+ messages in thread
From: Gorka Guardiola @ 2012-10-18 13:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thu, Oct 18, 2012 at 2:42 PM, Richard Miller <9fans@hamnavoe.com> wrote:
> As a side effect of the raspberry pi work, I've produced an SD card
> driver for the sheevaplug (and presumably other kirkwood platforms).
> It's in two sections: the top layer does the card protocol and is
> identical between rpi and kw (could go into /sys/src/9/port?), while
> the lower layer does the host sdio interface.  The two layers link via
> the usual table of functions, so if we encounter a platform with more
> than one sd host interface [anybody seen one?] it won't be hard to
> cope with.

This is very nice work. Thanks.

>
> Would anyone with a sheevaplug or similar, and a collection of SD
> cards, like to try it out before I submit a patch?  Source is in

I have a sheeva but no SD cards, sorry.

G.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-18 12:42 [9fans] sheevaplug SD card driver Richard Miller
  2012-10-18 13:46 ` Gorka Guardiola
@ 2012-10-18 14:24 ` David du Colombier
  2012-10-19 13:36   ` Richard Miller
  2012-10-18 16:05 ` Skip Tavakkolian
  2 siblings, 1 reply; 20+ messages in thread
From: David du Colombier @ 2012-10-18 14:24 UTC (permalink / raw)
  To: 9fans

> Would anyone with a sheevaplug or similar, and a collection of SD
> cards, like to try it out before I submit a patch?

I just tried with various 2 GB to 16 GB Kingston SD and
microSD (with adapter) cards on my SheevaPlug and it works
like a charm.

Thanks for your very nice work.

--
David du Colombier



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-18 12:42 [9fans] sheevaplug SD card driver Richard Miller
  2012-10-18 13:46 ` Gorka Guardiola
  2012-10-18 14:24 ` David du Colombier
@ 2012-10-18 16:05 ` Skip Tavakkolian
  2 siblings, 0 replies; 20+ messages in thread
From: Skip Tavakkolian @ 2012-10-18 16:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Thanks!!!  I plan to try it out on sheeva and guru later today.

On Thu, Oct 18, 2012 at 5:42 AM, Richard Miller <9fans@hamnavoe.com> wrote:
> As a side effect of the raspberry pi work, I've produced an SD card
> driver for the sheevaplug (and presumably other kirkwood platforms).
> It's in two sections: the top layer does the card protocol and is
> identical between rpi and kw (could go into /sys/src/9/port?), while
> the lower layer does the host sdio interface.  The two layers link via
> the usual table of functions, so if we encounter a platform with more
> than one sd host interface [anybody seen one?] it won't be hard to
> cope with.
>
> Would anyone with a sheevaplug or similar, and a collection of SD
> cards, like to try it out before I submit a patch?  Source is in
> /n/sources/contrib/miller/9/kw, and if you haven't pulled kernel
> sources recently you'll need to update /sys/src/9/port/sd.h as well.
> The drive appears as '#S/sdM0', and a FAT-formatted SD card can be
> mounted simply by doing "diskparts; dosmnt 1 /n/sd".  You can of
> course hot-swap cards without rebooting, but don't forget to unmount
> first.
>
> Although the driver is called sdmmc.c, it handles only SD cards and
> not the older MMC standard.  I think it's only a matter of slightly
> different initialisation, but I haven't got an actual MMC card to
> test it with.  If anyone cares enough to send me one, I'll see if
> I can make that work too.
>
>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-18 14:24 ` David du Colombier
@ 2012-10-19 13:36   ` Richard Miller
  2012-10-19 13:47     ` erik quanstrom
  0 siblings, 1 reply; 20+ messages in thread
From: Richard Miller @ 2012-10-19 13:36 UTC (permalink / raw)
  To: 9fans

> it works
> like a charm.

Thanks.  Patch sdmmc-driver now submitted.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 13:36   ` Richard Miller
@ 2012-10-19 13:47     ` erik quanstrom
  2012-10-19 14:00       ` Richard Miller
  0 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2012-10-19 13:47 UTC (permalink / raw)
  To: 9fans

On Fri Oct 19 09:37:40 EDT 2012, 9fans@hamnavoe.com wrote:
> > it works
> > like a charm.
>
> Thanks.  Patch sdmmc-driver now submitted.

could you explain the ccmalloc trick?

- erik



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 13:47     ` erik quanstrom
@ 2012-10-19 14:00       ` Richard Miller
  2012-10-19 15:30         ` erik quanstrom
  0 siblings, 1 reply; 20+ messages in thread
From: Richard Miller @ 2012-10-19 14:00 UTC (permalink / raw)
  To: 9fans

> could you explain the ccmalloc trick?

"cache coherent malloc" - not really a trick, just a way to
ensure SD buffers are cache-aligned and occupy an integral
number of cache lines, to avoid embarrassment when doing
dma on ARM (which bypasses the cache).  It costs a bit of
space but saves copying.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 14:00       ` Richard Miller
@ 2012-10-19 15:30         ` erik quanstrom
  2012-10-19 15:39           ` Richard Miller
  0 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2012-10-19 15:30 UTC (permalink / raw)
  To: 9fans

On Fri Oct 19 10:01:11 EDT 2012, 9fans@hamnavoe.com wrote:
> > could you explain the ccmalloc trick?
>
> "cache coherent malloc" - not really a trick, just a way to
> ensure SD buffers are cache-aligned and occupy an integral
> number of cache lines, to avoid embarrassment when doing
> dma on ARM (which bypasses the cache).  It costs a bit of
> space but saves copying.

that's what i thought.

we ran into this problem and decided that it was easiest to just
cacheline-align everything in malloc, at the obvious expense of
a tiny bit of memory.  the reason for this was we were using a few
kw devices that could get just about any chunk of malloc'd memory.

ideally we would have written a kw-specific malloc with tracking
segregated from the managed memory.

- erik



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:30         ` erik quanstrom
@ 2012-10-19 15:39           ` Richard Miller
  2012-10-19 15:46             ` erik quanstrom
  0 siblings, 1 reply; 20+ messages in thread
From: Richard Miller @ 2012-10-19 15:39 UTC (permalink / raw)
  To: 9fans

> easiest to just
> cacheline-align everything in malloc

Might be a good idea for ARM.  Until someone produces a
chip with gigantic cache lines?

Another alternative might be to have a separate pool of
uncached memory.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:39           ` Richard Miller
@ 2012-10-19 15:46             ` erik quanstrom
  2012-10-19 16:03               ` Richard Miller
  0 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2012-10-19 15:46 UTC (permalink / raw)
  To: 9fans, 9fans

On Fri Oct 19 11:40:41 EDT 2012, 9fans@hamnavoe.com wrote:
> > easiest to just
> > cacheline-align everything in malloc
> 
> Might be a good idea for ARM.  Until someone produces a
> chip with gigantic cache lines?
> 
> Another alternative might be to have a separate pool of
> uncached memory.

i'm certainly not claiming this is a general solution for all possible
arms, but for kw-style caches (16-byte lines) and kw-style hardware
(very little cache-coherency), i think the idea has a lot of merit.
especially with quickfit with external (that is cache-coherent) tracking.

i really do like your cc malloc, though.  very clean.  though
i had to look twice to verify i understood the pointer orthodontics.
☺.

- erik



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:46             ` erik quanstrom
@ 2012-10-19 16:03               ` Richard Miller
  2012-10-19 21:30                 ` Charles Forsyth
  0 siblings, 1 reply; 20+ messages in thread
From: Richard Miller @ 2012-10-19 16:03 UTC (permalink / raw)
  To: 9fans

> kw-style caches (16-byte lines)

mem.h says it's 32.  But yeah, it's not much.

> i had to look twice to verify i understood the pointer orthodontics.

Correctness proof (or refutation) is left as an exercise for the reader...




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 16:03               ` Richard Miller
@ 2012-10-19 21:30                 ` Charles Forsyth
  2012-10-19 21:49                   ` erik quanstrom
  0 siblings, 1 reply; 20+ messages in thread
From: Charles Forsyth @ 2012-10-19 21:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 122 bytes --]

I think it's better to specify memory that must have special cache
properties, rather than assuming that everything is.

[-- Attachment #2: Type: text/html, Size: 133 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 21:30                 ` Charles Forsyth
@ 2012-10-19 21:49                   ` erik quanstrom
  2012-10-19 21:59                     ` Charles Forsyth
  2012-11-10 12:20                     ` Richard Miller
  0 siblings, 2 replies; 20+ messages in thread
From: erik quanstrom @ 2012-10-19 21:49 UTC (permalink / raw)
  To: charles.forsyth, 9fans

On Fri Oct 19 17:31:50 EDT 2012, charles.forsyth@gmail.com wrote:

> I think it's better to specify memory that must have special cache
> properties, rather than assuming that everything is.

this depends on the ratio of memory that has special cache
properties to the memory that doesn't.  if you have devices
like the kirkwood that can do dma, pci transfers, crcs, etc and
it turns out that you can't predict ahead of time what memory
you'd like to transfer, then, making a small concession in
malloc might make sense.  Block*s (well at least the buffer)
needs to be special because the ethernet on the marvell is not
cache coherent.

- erik



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 21:49                   ` erik quanstrom
@ 2012-10-19 21:59                     ` Charles Forsyth
  2012-11-10 12:20                     ` Richard Miller
  1 sibling, 0 replies; 20+ messages in thread
From: Charles Forsyth @ 2012-10-19 21:59 UTC (permalink / raw)
  To: erik quanstrom; +Cc: 9fans

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

Blocks are intended for IO.

On 19 October 2012 22:49, erik quanstrom <quanstro@quanstro.net> wrote:

> Block*s (well at least the buffer)
> needs to be special because the ethernet on the marvell is not
> cache coherent.
>

[-- Attachment #2: Type: text/html, Size: 496 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 21:49                   ` erik quanstrom
  2012-10-19 21:59                     ` Charles Forsyth
@ 2012-11-10 12:20                     ` Richard Miller
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Miller @ 2012-11-10 12:20 UTC (permalink / raw)
  To: 9fans

quanstro@quanstro.net wrote:
> i really do like your cc malloc, though. very clean.

Actually I've just noticed that my ccmalloc() function just duplicates
what the standard mallocalign() already does.  So I've removed it from
the yet-to-be-applied sdmmc-driver patch.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
@ 2012-11-10 13:24 Erik Quanstrom
  0 siblings, 0 replies; 20+ messages in thread
From: Erik Quanstrom @ 2012-11-10 13:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Interesting.  Speaking of odd bits. Just noticed that devether does qbwrite not pass.  Why? It defeats TCP congestion CTL.

- erik


Richard Miller <9fans@hamnavoe.com> wrote:

>quanstro@quanstro.net wrote:
>> i really do like your cc malloc, though. very clean.
>
>Actually I've just noticed that my ccmalloc() function just duplicates
>what the standard mallocalign() already does.  So I've removed it from
>the yet-to-be-applied sdmmc-driver patch.
>
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:33 ` Richard Miller
@ 2012-10-19 16:01   ` lucio
  0 siblings, 0 replies; 20+ messages in thread
From: lucio @ 2012-10-19 16:01 UTC (permalink / raw)
  To: 9fans

> Or you can look in /n/sources/patch/sdmmc-driver.

Thanks, will do.  Time to dust off the Plug again.  Thank you.

++L




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:21 lucio
  2012-10-19 15:33 ` Richard Miller
@ 2012-10-19 15:39 ` Skip Tavakkolian
  1 sibling, 0 replies; 20+ messages in thread
From: Skip Tavakkolian @ 2012-10-19 15:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

comment it out and uncomment the line above.


On Fri, Oct 19, 2012 at 8:21 AM,  <lucio@proxima.alt.za> wrote:
>> /n/sources/contrib/miller/9/kw
>
> in "plug":
>
> I see you use /usr/miller/bin/arm/usbd, is there something special in
> it?
>
> Also, "paq" reappears, do we want it, or is it just leftover?
>
>         ripple# diff plug /n/sources/contrib/miller/9/kw/plug
>         59a60
>         >       sdmmc           sdio
>         70a72
>         >       paq
>         72d73
>         < #     paq
>         78c79,80
>         <       /arm/bin/usb/usbd
>         ---
>         > #     /arm/bin/usb/usbd
>         >       /usr/miller/bin/arm/usbd
>         80c82,83
>         < #     /arm/bin/paqfs
>         ---
>         >       /arm/bin/paqfs
>         >       nvram
>
> ++L
>
>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
  2012-10-19 15:21 lucio
@ 2012-10-19 15:33 ` Richard Miller
  2012-10-19 16:01   ` lucio
  2012-10-19 15:39 ` Skip Tavakkolian
  1 sibling, 1 reply; 20+ messages in thread
From: Richard Miller @ 2012-10-19 15:33 UTC (permalink / raw)
  To: 9fans

>> /n/sources/contrib/miller/9/kw
>
> in "plug":
>
> I see you use /usr/miller/bin/arm/usbd, is there something special in
> it?
>
> Also, "paq" reappears, do we want it, or is it just leftover?

Sorry, this was leakage from my own experiments.  I've now
replaced that plug config with a standard one.

Or you can look in /n/sources/patch/sdmmc-driver.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [9fans] sheevaplug SD card driver
@ 2012-10-19 15:21 lucio
  2012-10-19 15:33 ` Richard Miller
  2012-10-19 15:39 ` Skip Tavakkolian
  0 siblings, 2 replies; 20+ messages in thread
From: lucio @ 2012-10-19 15:21 UTC (permalink / raw)
  To: 9fans

> /n/sources/contrib/miller/9/kw

in "plug":

I see you use /usr/miller/bin/arm/usbd, is there something special in
it?

Also, "paq" reappears, do we want it, or is it just leftover?

	ripple# diff plug /n/sources/contrib/miller/9/kw/plug
	59a60
	> 	sdmmc		sdio
	70a72
	> 	paq
	72d73
	< #	paq
	78c79,80
	< 	/arm/bin/usb/usbd
	---
	> #	/arm/bin/usb/usbd
	> 	/usr/miller/bin/arm/usbd
	80c82,83
	< #	/arm/bin/paqfs
	---
	> 	/arm/bin/paqfs
	> 	nvram

++L




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-11-10 13:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 12:42 [9fans] sheevaplug SD card driver Richard Miller
2012-10-18 13:46 ` Gorka Guardiola
2012-10-18 14:24 ` David du Colombier
2012-10-19 13:36   ` Richard Miller
2012-10-19 13:47     ` erik quanstrom
2012-10-19 14:00       ` Richard Miller
2012-10-19 15:30         ` erik quanstrom
2012-10-19 15:39           ` Richard Miller
2012-10-19 15:46             ` erik quanstrom
2012-10-19 16:03               ` Richard Miller
2012-10-19 21:30                 ` Charles Forsyth
2012-10-19 21:49                   ` erik quanstrom
2012-10-19 21:59                     ` Charles Forsyth
2012-11-10 12:20                     ` Richard Miller
2012-10-18 16:05 ` Skip Tavakkolian
2012-10-19 15:21 lucio
2012-10-19 15:33 ` Richard Miller
2012-10-19 16:01   ` lucio
2012-10-19 15:39 ` Skip Tavakkolian
2012-11-10 13:24 Erik Quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).