Re: Handling interrupts in spidev

2014-02-13 Thread Nilesh Bacchewar
you can use Asynchronous notification  , FASYNC .

http://www.makelinux.net/ldd3/chp-6-sect-4

Regards,
Nilesh


On Tue, Jan 28, 2014 at 9:47 PM, Vishwanath Govind <
vishwanath.gov...@gmail.com> wrote:

> You can implement irq handler in spi driver itself. SPI specific platform
> data can pass it from board file.
> Regards
> Vishwa
>
>
> On Tue, Jan 28, 2014 at 9:24 PM, Richard Weinberger wrote:
>
>> Am 28.01.2014 15:12, schrieb Amit Mahadik:
>> > Thanks Richard. One more question. If I register an SPI irq  struct
>> spi_board_info spi_board_info[] structure in machine board.c file; then the
>> request irq api and irq handler
>> > should be written in board.c file or in the spidev driver.
>>
>> Never do any programming in the board file.
>> The purpose if the board file it describing the hardware.
>> Please note, board files go away, device tree is the way to go.
>>
>> Thanks,
>> //richard
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Firmware Loading every boot?

2014-02-13 Thread Peter Teoh
FYI, the "firmware" are loaded from flash:

http://en.wikipedia.org/wiki/Flash_memory

which means microcontroller (or microprocessor) + DMA/DDR memory + flash
are the usual makeup of an embedded system.   flash are non-volatile, but
normally it is slower and cannot be executed as CPU or microncontroller
instruction.   which is why you will need to load it into memory to be
executed:

http://lwn.net/Articles/135472/

cheers.


On Mon, Feb 10, 2014 at 9:29 PM, Jeshwanth  wrote:

> Hello List,
>
> I came to know that, linux loads firmware for my dma everytime it boots.
> But I don't understand, why it is required to load everytime it boots,
> don't dma holds which is loaded previously.
> AFAIK, firmware is a program which runs in devices.
>
> Please correct me if I am wrong.
>
> Thanks :)
>
> Regards,
> Jeshwanth
>
> Sent from my HTC
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


-- 
Regards,
Peter Teoh
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Connecting a Device with configFS

2014-02-13 Thread Sergej Roytman
Hi!  I’m not sure this is general enough for the kernel newbie list.  However, 
it is certainly a newbie question, and I’m not sure it belongs on target-devel, 
being more of the “I don’t know how to do something simple” variety.  Anyway, 
if this question belongs somewhere other than kernelnewbies, and you can direct 
me to that place, I will be grateful for that pointer as well.

I am trying to patch this thing:

http://www.spinics.net/lists/target-devel/msg05630.html

It is a new user space storage backend for LIO.  There’s a couple of patch 
files in other messages from the thread, which actually make up the 
implementation.  I confirmed with the target-devel list at kernel.org that this 
is in fact the planned user space backend to LIO, which is scheduled for the 
3.15 kernel.  I am trying to get a jump on using this thing, by installing the 
pre-release version and becoming familiar with using it, in time for the 
official release later this year.

So.  I patched the 3.13 source and built the resulting kernel, with no 
problems.  insmod-ed the resulting .ko.  The program in the message which I 
linked, basically, sets up structures in /sys/config, and then puts the new 
backend through its paces.  To do these things by hand would make a script 
something like the following.  And I note that when I mkdir certain 
pseudo-directories in configFS and examine them, additional structure is 
getting added, as it should be, indicating that the kernel module is installed 
and active, and calling its callback functions.

  # #!/bin/sh
  #

  #DEV_FILE=/dev/sdc
  DEV_FILE=$HOME/test_backend/test.img

  # For iSCSI, the iqn name seems to correspond to the NAA name.
  NAA_STR=iqn.2003-01.org.linux-iscsi.target.x8664:sn.5e47974d8c71
  VPD_STR=b9802841-1d9a-4e08-a8a0-d4161221

  mkdir -p /sys/kernel/config/target/core/tcmu_0/test

  # This contains an address from a running program---that's fine, since it's 
the
  # directory structure in /config I'm interested in.  If I got the user space 
target
  # as far as tripping over the bad pointer, I'd be pretty happy right now.
  #
  echo -n mailbox_addr=139752828575744,mailbox_size=18948096,dev_size=43275 >\
  
/sys/kernel/config/target/core/tcmu_0/test/control

  echo $DEV_FILE >/sys/kernel/config/target/core/tcmu_0/test/udev_path

  echo 1 >/sys/kernel/config/target/core/tcmu_0/test/enable

  echo $VPD_STR >/sys/kernel/config/target/core/tcmu_0/test/wwn/vpd_unit_serial

  ln -s /sys/kernel/config/target/core/tcmu_0/test \
  
/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.target.x8664:sn.5e47974d8c71\
  /tpgt_1/lun/lun_0/aa

  echo return value from ln: $?

As I understand it, from reading the source of the targetcli tool which sets 
these things up, this script would be the way to do this by hand.  Set up the 
structure under /sys/kernel/config/target/iscsi (this is done automatically on 
my VM, after I set it up in targetcli and did a saveconfig); set up the 
structure in /sys/kernel/config/target/core (the new user space target, which I 
confirmed to be active by noting that the pseudo-directories I make are getting 
populated); set up soft links between the two pseudo-directories to indicate 
that the one connects to the other.  However, the $? from the ln returns an 
error, and the new link under lun_0 is not being made.  That I’m connecting the 
backend to a file, rather than a raw device as I’d like, isn’t even the issue 
yet, as I’m not making even that connection.

Ultimately, I would like to connect to the user space backend through iSCSI, 
using a raw block device as a backing store, and run some benchmarking through 
it, varying any parameter I can think of to see which will and will not make a 
difference.  Then I could compare with benchmarking on SCST user space and LIO 
talking to a raw device, which I’ve already done, and see how this thing 
compares.  Suggestions?

Many thanks in advance!
This message contains confidential information. If you are not the intended 
recipient you are hereby notified that disclosing,copying, distributing or 
taking any action in reliance on the contents of this information is strictly 
prohibited. Please notify the sender immediately and delete this e-mail from 
your system.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to invalidate cache in kernel driver?

2014-02-13 Thread anish singh
On Feb 13, 2014 10:29 AM, "m silverstri" 
wrote:
>
> I have an output buffer in my kernel driver. And that share with my
> hardware, which uses it for output.
>
> When I got an interrupt, the kernel driver will copy the data from the
> output buffer to user space buffer.
>
> How can I invalidate cache after my kernel driver copy the output buffer
And why you have to do that? Do you
see any inconsistency in the current
value of that variable?
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


How to invalidate cache in kernel driver?

2014-02-13 Thread m silverstri
I have an output buffer in my kernel driver. And that share with my
hardware, which uses it for output.

When I got an interrupt, the kernel driver will copy the data from the
output buffer to user space buffer.

How can I invalidate cache after my kernel driver copy the output buffer?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [Help] How to Replace File Operations in File System?

2014-02-13 Thread freeman
Hi Rishi,

Thanks for your reply!

I'm sorry that the description of the problem was not clear.

I am writing a module(not a filesystem) to replace some operation
pointers of Ext4.
Just now, I try to print the dentry->name as you said. It seems
that I'm modifying the right files.

I'm wonderring if my idea is bad:
I changed operations of a file both in ->create and ->lookup in
inode operations of direcotry. And test the module like this:

echo hello > hello  (for dir_inode->create and f->write)
cat hello   (for f->read)


Will the file operations be changed back?
Or what I modified is some copies of real objects because of the
complex caching mechanism?

Regards

Freeman Zhang



___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [Help] How to Replace File Operations in File System?

2014-02-13 Thread freeman
Hi Abhijit and Saket,

Thank you very much for your reply!

I did some study on eCryptfs before. I think eCrytfs is a "
big ideas for small business".
Implementation of a totally new filesystem is quite complex
for me to imitate and study. So with the elicitation from
eCryptfs, I have this idea to design a simplified module(not
another filesystem) to do transparent en/decrypting, by
replacing some main function pointers.

Thanks to you, now I know there is WRAPFS, which I think is
perfectly suitable for my project--short, easy, and highly
extendable. If I still cannot fix this problem, I would like
to turn to WRAPFS!

Much thanks!

Freeman Zhang



___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [Help] How to Replace File Operations in File System?

2014-02-13 Thread Rishi Agrawal
Hi,


On Thu, Feb 13, 2014 at 12:14 PM, Abhijit Chandrakant Pawar <
abhi.c.pa...@gmail.com> wrote:

> Hi,
>
> On Thursday 13 February 2014 07:40 AM, freeman wrote:
> > Hi list,
> >
> > I am a newbie in linux kernel programming. Recently I got stuck in a
> > problem when doing
> > practice in file system programming. I hope this list is the right place
> > I can turn to.
> >
> > I want to replace some file operations of files in a certain
> > directory,so that data can be
> > decrypted/encrypted through read/write system call. So I:
> >
> > #1: Find the directory inode, save its original inode operation
> > table,then replace
> > the table:
> >
> > kern_path(pathname, LOOKUP_FOLLOW, &target_dir_path);
> > lower_iops = target_dir_path.dentry->d_inode->i_op;
> > target_dir_path.dentry->d_inode->i_op = &my_iops;
> >
> I assume that you are writing your own stackable filesystem.
> Take a look at WRAPFS[1] and ecryptfs[2]. As a matter of fact, ecryptfs
> does what you are expecting.
>
> To do this, you need to set your superblock operations for the lower
> directory inode so the VFS use your filesystem instead of the original
> filesystem.
> Important steps to look are:
> 1. get lower superblock from the lower directory inode
> 2. assign this superblock as an overlay for your own superblock.
> 3. Set your own superblock operations for the new superblock
> 4. get a root inode for your superblock using the lower directory inode
> 5. While you are getting the inode, you can set the file operations on
> this inode which will help you achieve your case.
>
> The point to note that you need to interpose the inodes with VFS so that
> everything would be routed to your filesystem.
>
> --
> Abhijit.
> [1]http://wrapfs.filesystems.org/
> [2]http://ecryptfs.org/
>
>
> > #2: In my_iops, I mainly changed ".lookup" function like this to achive
> > my goal --
> > replace the file operation table of all files in the directory.
> >
> > static struct dentry *my_inode_lookup(struct inode *dir, struct dentry
> > *dentry,
> > struct nameidata *nd)
> > {
> > struct dentry *ret_dentry;
> >
> > ret_dentry = lower_iops->lookup(dir,dentry,nd);
> > if (!ret_dentry)
> > goto out;
> > ret_dentry->d_inode->i_fop = &my_fops;
> > out:
> > return ret_dentry;
> > }
> >
> > Things turns out that replacement of inode operation table of directory
> > is successful
> > but the changes in file operations are not functional: system works as
> > it used to,
> > totally ignore my_fops!
> >
> > I have no idea how to fix it. Can anybody help?
> > Thanks for your attention!
> > Regards
> >
> > Freeman Zhang
> >
> >
> > ___
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


Freeman - What you are doing seems to be correct - you may have missed some
pointer some where.

Which file system are you using, are you writing a layer on an existing
file system or changing the code of a file system

Try adding some debug messages whenever you change the operations which
prints the dentry->name of the file, you will get an idea that the correct
file's operations are getting modified.


-- 
Regards,
Rishi Agrawal
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies