linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mount PCI-express RAM memory as block device
@ 2005-01-07 18:36 Shakthi Kannan
  2005-01-07 18:53 ` linux-os
  2005-01-07 19:00 ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Shakthi Kannan @ 2005-01-07 18:36 UTC (permalink / raw)
  To: linux-kernel

Greetings!

I would like to know as to how we can mount a
filesystem for RAM memory on a PCI-express card.
System for development is x86 with 2.4.22 kernel.

I, initially wrote a ramdisk driver to read/write data
between buffer and RAM. Here, I have used:
device->data = vmalloc (device->size);
where:
- device is the device driver structure variable
- data = unsigned char *
- size = unsigned int

I am able to load the above block driver and mount a
filesystem using:
dd if=/dev/zero of=/dev/sbull bs=1k count=64
mkdir /mnt/mysbull
mke2fs -vm0 /dev/sbull 64
mount /dev/sbull /mnt/mysbull

For PCI device driver, I have modifed the above to
directly ioremap device->data as follows:
device->data = ioremap_nocache (BASE_ADDRESS,
BASE_SIZE);
Have successfully done:
dd if=/dev/zero of=/dev/sbull bs=1k count=64
mkdir /mnt/mysbull
mke2fs -vm0 /dev/sbull 64

But, when I proceed to mount a filesystem, it fails. 
mount /dev/sbull /mnt/mysbull

mount:error while guessing filesystem type
mount: you must specify the filesystem type

Also, if I give "fsck -v /dev/sbull", it returns with
improper filesystem super block. Even if I specify "-t
ext2" for mount, it fails. I even tried a
loopback device mount, but it fails too:
mount -o loop /dev/sbull /mnt/mysbull

FAT: bogus logical sector size 0
VFS: Can't find a valid FAT filesystem on dev FA:00

How can I map the RAM memory on the PCI card, even
though I don't allocate any memory (during ioremap)
and display that to the end user as a mounted
filesystem so that he/she can read/write files to it?

Any help/pointers to links is appreciated.

Thanks,

K Shakthi


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

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

* Re: mount PCI-express RAM memory as block device
  2005-01-07 18:36 mount PCI-express RAM memory as block device Shakthi Kannan
@ 2005-01-07 18:53 ` linux-os
  2005-01-07 20:17   ` Shakthi Kannan
  2005-01-07 19:00 ` Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: linux-os @ 2005-01-07 18:53 UTC (permalink / raw)
  To: Shakthi Kannan; +Cc: linux-kernel

On Fri, 7 Jan 2005, Shakthi Kannan wrote:

> Greetings!
>
> I would like to know as to how we can mount a
> filesystem for RAM memory on a PCI-express card.
> System for development is x86 with 2.4.22 kernel.
>
> I, initially wrote a ramdisk driver to read/write data
> between buffer and RAM. Here, I have used:
> device->data = vmalloc (device->size);
> where:
> - device is the device driver structure variable
> - data = unsigned char *
> - size = unsigned int
>
> I am able to load the above block driver and mount a
> filesystem using:
> dd if=/dev/zero of=/dev/sbull bs=1k count=64
> mkdir /mnt/mysbull
> mke2fs -vm0 /dev/sbull 64
> mount /dev/sbull /mnt/mysbull
>
> For PCI device driver, I have modifed the above to
> directly ioremap device->data as follows:
> device->data = ioremap_nocache (BASE_ADDRESS,
> BASE_SIZE);
> Have successfully done:
> dd if=/dev/zero of=/dev/sbull bs=1k count=64
> mkdir /mnt/mysbull
> mke2fs -vm0 /dev/sbull 64
>
> But, when I proceed to mount a filesystem, it fails.
> mount /dev/sbull /mnt/mysbull
>
> mount:error while guessing filesystem type
> mount: you must specify the filesystem type
>
> Also, if I give "fsck -v /dev/sbull", it returns with
> improper filesystem super block. Even if I specify "-t
> ext2" for mount, it fails. I even tried a
> loopback device mount, but it fails too:
> mount -o loop /dev/sbull /mnt/mysbull
>
> FAT: bogus logical sector size 0
> VFS: Can't find a valid FAT filesystem on dev FA:00
>
> How can I map the RAM memory on the PCI card, even
> though I don't allocate any memory (during ioremap)
> and display that to the end user as a mounted
> filesystem so that he/she can read/write files to it?
>
> Any help/pointers to links is appreciated.
>
> Thanks,
>
> K Shakthi
>

When you ioremap() in the kernel, you get a cookie that you
can use (in the kernel) to copy data to and from the device.

This doesn't allow a user to copy data directly. Instead,
in your read() and write() routines, you use the appropriate
copy_to/from_user() routines. If the device is not a
block device, then you will have to mount it through the
loop device. If it is a block device, you can mount it
directly after initialization.

>From your explanation, it looks like the BASE_ADDRESS is not
the device's on-board memory, but instead, its control
registers, i.e., a simple implementation bug.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

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

* Re: mount PCI-express RAM memory as block device
  2005-01-07 18:36 mount PCI-express RAM memory as block device Shakthi Kannan
  2005-01-07 18:53 ` linux-os
@ 2005-01-07 19:00 ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2005-01-07 19:00 UTC (permalink / raw)
  To: Shakthi Kannan; +Cc: linux-kernel

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

On Freedag 07 Januar 2005 19:36, Shakthi Kannan wrote:
> I would like to know as to how we can mount a
> filesystem for RAM memory on a PCI-express card.
> System for development is x86 with 2.4.22 kernel.
> 
You could use the MTD block driver with on the phram device
by simply specifying the address/size of the memory as a module
parameter.  If you need autodetection, the easiest way to do that
would be including the phram MTD driver in your pci device driver.

If you are completely stuck on 2.4.22, it might be easier to
use the old slram driver instead of phram, but generally you
should try to hack on a modern kernel level like 2.6.10 anyway.

	Arnd <><

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: mount PCI-express RAM memory as block device
  2005-01-07 18:53 ` linux-os
@ 2005-01-07 20:17   ` Shakthi Kannan
  2005-01-11 16:45     ` Shakthi Kannan
  0 siblings, 1 reply; 5+ messages in thread
From: Shakthi Kannan @ 2005-01-07 20:17 UTC (permalink / raw)
  To: linux-kernel

Hi,

Thanks for your replies Dick Johnson and Arnd
Bergmann.

--- linux-os <linux-os@chaos.analogic.com> wrote:
> From your explanation, it looks like the
> BASE_ADDRESS is not
> the device's on-board memory, but instead, its
> control
> registers, i.e., a simple implementation bug.

The BASE_ADDRESS is a physical address (0xfe8f0000)
that points to the RAM memory on the PCI card, which I
tried to remap so that the kernel can address it using
memcpy.

Initially, I wrote a pci driver (character driver
interface) to test memory read/write operations to
this physical address (after ioremap) using
readl/writel. This worked fine.

--- linux-os <linux-os@chaos.analogic.com> wrote:
> When you ioremap() in the kernel, you get a cookie 
> that you can use (in the kernel) to copy data to and
> from the device.
> This doesn't allow a user to copy data directly. 
> Instead, in your read() and write() routines, you
use > the appropriate copy_to/from_user() routines. 

This being a block driver I only define
block_device_operations. How would I declare and use
the file_operations read(), write() routines?

> If the device is not a block device, then you will 
> have to mount it through the loop device. If it is a
> block device, you can mount it directly after 
> initialization.

Which is where it fails. 

--- Arnd Bergmann <arnd@arndb.de> wrote:
> If you are completely stuck on 2.4.22, it might be
> easier to
> use the old slram driver instead of phram, but
> generally you
> should try to hack on a modern kernel level like
> 2.6.10 anyway.

I shall test it with the 2.6.10 kernel.

Thanks again,

K Shakthi


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

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

* Re: mount PCI-express RAM memory as block device
  2005-01-07 20:17   ` Shakthi Kannan
@ 2005-01-11 16:45     ` Shakthi Kannan
  0 siblings, 0 replies; 5+ messages in thread
From: Shakthi Kannan @ 2005-01-11 16:45 UTC (permalink / raw)
  To: linux-kernel

Hi,

--- "Arnd Bergmann" <arnd@arndb.de> wrote:
> You could use the MTD block driver with on the phram

> device by simply specifying the address/size of the 
> memory as a module parameter.  If you need 
> autodetection, the easiest way to do that would be 
> including the phram MTD driver in your pci device 
> driver.

I studied the slram.c and rd.c device drivers. The
ramdisk driver that I had written earlier, similar to
the above, had worked fine. With respect to PCI
express, I had to modify just the memory tranfer
function. The memcpy functions translate to byte
access. But, PCI express is dword access. So, I wrote
my own memory copy to do long read/write using
readl(), writel(). The block device driver works fine.

Thanks,

K Shakthi

=====
-----------------------------------------------------
K Shakthi
Specsoft (Hexaware Technologies), ASIC Design Center
http://www.geocities.com/shakthimaan
-----------------------------------------------------


		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

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

end of thread, other threads:[~2005-01-11 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-07 18:36 mount PCI-express RAM memory as block device Shakthi Kannan
2005-01-07 18:53 ` linux-os
2005-01-07 20:17   ` Shakthi Kannan
2005-01-11 16:45     ` Shakthi Kannan
2005-01-07 19:00 ` Arnd Bergmann

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).