Re: atomic test and set

2017-10-17 Thread Anish Kumar


> On Oct 17, 2017, at 5:40 PM, Tobin C. Harding  wrote:
> 
> Hi,
> 
> Do we have an atomic test and set function in the kernel. I have tried

Yes and it is used very much inside the kernel.
> 
> const int KEY_FLAG_BIT = 1;
> 
> ...
> 
>static siphash_key_t ptr_secret __read_mostly;
>static unsigned long have_key = 0;
> 
>if (test_and_set_bit(KEY_FLAG_BIT, _key))
>get_random_bytes(_secret, sizeof(ptr_secret));
> 
> 
> But that doesn't work.

What doesn't work? What you expected and how is the result different?
> 
> I looked in include/linux/atomic.h and thought about using
> 
>static atomic_t have_key = ATOMIC_INIT(0);
> 
>if (atomic_xchg(_key, 1) == 0)
>get_random_bytes(_secret, sizeof(ptr_secret));
> 
> 
> This works. My question is; does this code LOAD the value at have_key and 
> STORE the argument on
> every call? Or does it LOAD the value, check if it is the same as the 
> argument, and STORE _only_ if
> it is different? 

Did you read this https://www.mjmwired.net/kernel/Documentation/atomic_ops.txt ?
> (Is this whole discussion just premature optimization?)

This has nothing to do with optimization but rather the requirement. In kernel 
atomic variables are used to avoid race conditions generally.
> 
> I cannot grok the macros in atomic.h, they seem circular. Here is the macro 
> definitions in call
> chain order starting with atomic_xchg()

Implementation would differ based on the architecture. In some architectures it 
would be a single instruction and in others it may not be the case.
> 
> 
> #define  atomic_xchg(...)\
>__atomic_op_fence(atomic_xchg, __VA_ARGS__)
> 
> #define __atomic_op_fence(op, args...)\
> ({\
>typeof(op##_relaxed(args)) __ret;\
>smp_mb__before_atomic();\
>__ret = op##_relaxed(args);\
>smp_mb__after_atomic();\
>__ret;\
> })
> 
> #define  atomic_xchg_release(...)\
>__atomic_op_release(atomic_xchg, __VA_ARGS__)
> 
> #define __atomic_op_release(op, args...)\
> ({\
>smp_mb__before_atomic();\
>op##_relaxed(args);\
> })
> 
> #define  atomic_xchg_relaxedatomic_xchg
> 
> thanks,
> Tobin.
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Help on modelling gpio interrupt source when interrupt is shared

2017-01-24 Thread Anish Kumar


> On Jan 23, 2017, at 10:56 PM, Rajasekhar Pulluru 
>  wrote:
> 
> Hi Anish,
> 
> My intention is just to detect interrupt in the user space and read the 
> device id without using udev.
> 
> I don't want to create a new driver in kernel (assume I can't modify linux 
> kernel sources), which is the first reason to go for uio generic platform 
> driver.
> 
> If I register a gpio interrupt (level triggered) using a kernel module, I can 
> get the interrupt detected

Which means you are able to do insmod, so you can very well write a kernel 
module and send some event to user space.
> when device is inserted/removed. But I would like to detect device presence 
> completely from user space without modifying linux kernel.
> 
> Thanks & Regards,
> Rajasekhar
> 
>> On Tue, Jan 24, 2017 at 11:56 AM, anish singh  
>> wrote:
>> 
>> 
>>> On Mon, Jan 23, 2017 at 7:46 AM, Rajasekhar Pulluru 
>>>  wrote:
>>> Hi,
>>> 
>>> I have a query on device tree pertaining to modelling a gpio pin as an 
>>> interrupt source. 
>>> I have searched mailing list archives and kernel documentation before 
>>> posting this and couldn't get any direct solution.
>>> (My understanding is limited and hence posting the query below:)
>>> 
>>> My SOC has a gpio controller and uart both sharing same interrupt line as 
>>> specified below. 
>>> 
>>> interrupt-parent = <>;
>>> 
>>> mygpio: gpio@0x19008000 {
>>> compatible = "mysoc,mygpio-controller,gc";
>>> #address-cells = <1>;
>>> #size-cells = <1>;
>>> #gpio-cells = <2>;
>>> reg = gpio: <0x19008000 0x50>;
>>> ngpios = <12>;
>>> pin-offset = <4>;
>>> pin-base = <4>;
>>> irq-base = <256>; /* sw irq base for irq handlers */
>>> gpio-controller;
>>> interrupt-controller;
>>> interrupts = ;
>>> };
>>> 
>>> uart0: serial@0x19000300 {
>>> compatible = "snps,dw-apb-uart";
>>> reg = <0x19000300 0x100>;
>>> interrupts = ;
>>> clock-frequency = <6250>;
>>> };
>>> 
>>> gpio pin 0 of mygpio is used as an interrupt source for detecting the 
>>> presence of external pluggable device (that is not driven by kernel). 
>>> And I intend to detect the presence of the pluggable device from user space 
>>> by means of generic uio platform driver using below device
>> 
>> What do you intend to achieve by detecting device in userspace?
>> You can directly get notification using udev notification.
>> 
>> However, you need to send udev notification from a kernel driver.
>>  
>>> tree configuration. (following 
>>> https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/)
>>> 
>>> user_io@0 {
>>> compatible = "mydevice,generic-uio,ui_pdrv";
>>> status = "okay";
>>> interrupt-parent = <>;
>>> interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
>>> };
>>> 
>>> Running modprobe uio_pdrv_genirq of_id="mydevice,generic-uio,ui_pdrv" and 
>>> creating /dev/uio0 using mknod (major number from cat /proc/devices | grep 
>>> uio),
>>> I couldn't see an irq entry bind to uio driver under /proc/interrupts.
>>> Am I doing anything wrong here?
>>> 
>>> Other method I have tried to get notified of the gpio pin0 interrupt in 
>>> user space is to poll on /sys/class/gpio/gpio0/value. But merely exporting 
>>> gpio0 
>>> wasn't sufficient as kernel should make a call to request_irq on the gpio0 
>>> interrupt line. Is there a generic driver framework (like pinctrl) that can 
>>> export
>>> a device node to register the gpio pin0 as an interrupt source that allows 
>>> me to poll on its sysfs entry?
>> 
>> All sysfs nodes can be polled as it is supported in kernel. 
>> You can simply create a dummy driver and register the
>> irq and in your irq handler send udev notifications using
>> kobj.
>> 
>> Or
>> just update a sysfs node which can be polled from userspace.
>> 
>> If this answer is not sufficient then please explain in detail
>> what you are planning to achieve rather than what you are
>> doing to achieve that. 
>>> 
>>> Thanks,
>>> Rajasekhar
>>> 
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>> 
>> 
> 
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: adding 32 bit compatibility layer in custom kernel module

2017-01-03 Thread Anish Kumar


> On Jan 3, 2017, at 10:03 PM, Pradeepa Kumar <cdprade...@gmail.com> wrote:
> 
> Please see inline below
> 
>> On Wed, Jan 4, 2017 at 11:07 AM, Anish Kumar <anish198519851...@gmail.com> 
>> wrote:
>> 
>> 
>>> On Jan 3, 2017, at 8:04 PM, Pradeepa Kumar <cdprade...@gmail.com> wrote:
>>> 
>>> Hi experts
>>> 
>>> down vote
>>> favorite
>>> in my 64 bit kernel, I have a custom kernel module providing new protocol 
>>> and providing socket system calls.
>>> 
>>> it works fine when 64 bit app runs.
>>> 
>>> i am seeing issues when 32 bit app runs (for exp recvmsg() call does not 
>>> work if msg has cmsghdrs as struct size of cmsghdr is different in 32 bit 
>>> and 64 bit).
>>> 
>>> This is because my custom kernel module does not have 32 bit compatibility 
>>> layer ( but linux kernel has this in compat.c etc).
>>> 
>>> is it simple to add compatibility layer to my custom kernel module
>>> 
>>> All you have to do is add compat_ioctl call to your driver.
> my kernel module provides recvmsg() but i dont see any 'compat_recvmsg' in 
> struct proto_ops.

Try to wrap your text in 80 characters.

Your application is crashing? Right?
Have you figured where it is crashing exactly?

I understood that your application is crashing as 
It not able to function with 64 bit kernel.

This happens because of the data being passed
to kernel is not in the right format. You need to
look at what you are passing to the driver and
if needed write the compat_ioctl callback in your
driver fops.
> had there been  'compat_recvmsg' it would have been possible for me to define 
> recvmsg() for 32 bit apps.
> please let me know if i am missing anything
> 
>>> how do i do this (any links ?)
>>> 
>>> You can see many drivers supports compat call.
>>> Thanks
>>> 
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: adding 32 bit compatibility layer in custom kernel module

2017-01-03 Thread Anish Kumar


> On Jan 3, 2017, at 8:04 PM, Pradeepa Kumar  wrote:
> 
> Hi experts
> 
> down vote
> favorite
> in my 64 bit kernel, I have a custom kernel module providing new protocol and 
> providing socket system calls.
> 
> it works fine when 64 bit app runs.
> 
> i am seeing issues when 32 bit app runs (for exp recvmsg() call does not work 
> if msg has cmsghdrs as struct size of cmsghdr is different in 32 bit and 64 
> bit).
> 
> This is because my custom kernel module does not have 32 bit compatibility 
> layer ( but linux kernel has this in compat.c etc).
> 
> is it simple to add compatibility layer to my custom kernel module
> 
> All you have to do is add compat_ioctl call to your driver.
> how do i do this (any links ?)
> 
> You can see many drivers supports compat call.
> Thanks
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Options for adding I2C devices and how-to

2016-09-30 Thread Anish Kumar


> On Sep 30, 2016, at 6:23 PM, vibnwis  wrote:
> 
> Hi there,
> 
> My questions are about the options available for adding I2C devices onto 
> existing single board computers, such as Panda Board or Raspberry Pi. Later 
> then I would ask how to get it done. 
> 
> By far, I have found out the following options. Correct me if I am wrong as 
> my understanding s still hazy.
> 
> 1. BitBanging method. That is by connecting it to existing unused GPIOs.  
> Need to create a Bitbanging client driver for the device with the two GPIOs 
> for SDA, SCLK respectively

Right
> 
> 2. Use existing allocated I2C Pins. Assuming the kernel driver for the device 
> is already available, then simply run make menuconfig to configure to use the 
> right I2c device. However, if the driver is not available. One needs to 
> create a new client driver. if up to now I am still not wrong, then I have a 
> few questions.
>a) what address is it and how to specify one for the new device? would 
> like wise to use the existing allocated addresses which are not being used 
> due to non-existence of those I2C devices on the system?

You need to find out the device address of your device. 
find out which device is not connected and connect your device on that bus and 
change the device tree to replace the device address.
> b) if somehow, the new I2C device has somewhat similar architecture 
> with the existing supporter I2C devices, would it wise to use it instead of 
> developing a new client driver? I am trying to say that would it wise to 
> trial and error some of the existing supporting driver if they are 
> compatible. Only after testing then decide if new driver development is 
> needed. Is it the right thing to do?

You mean if the regmap is similar? I don't think that would be the case unless 
both devices are from the same company with minor revision change.
> 
> 3. Writing/using user mode I2c driver.

You can certainly use i2c_detect and i2c_get user space tools to work with your 
device. However is there is a existing kernel space i2c device on that bus then 
it will certain lead to bus hogging problems.
> 
> Feel free to add any comments or suggestions.
Please add information about your device and kernel version which you are 
trying to use. May be there is already a driver for it in open source.
Best of luck!!
> 
> Thank you in advance.
> 
> Best regards,
> Lim
> 
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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


Re: gpio-led driver

2016-07-20 Thread Anish Kumar


> On Jul 20, 2016, at 4:15 AM, Raul Piper  wrote:
> 
> Hi,
> I wanted to know the part number

What is part number?

> for the leds-gpio.c in the driver/leds folder and the device tree bindings 
> for this driver .Can some one point out to me where in Linux kernel it is?
> 
> Also why below line has been used.Is it mandatory?
> ...
> .of_match_table = of_gpio_leds_match,

This is needed when you are using device tree for getting the board settings 
but you can also do the same without this as well. Read up on device tree in 
kernel Documentation folder.
> },
> 
> thanks in advance ,
> Rp
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: I have a large patch in the 2000 lines. What to do?

2015-10-09 Thread Anish Kumar


> On Oct 9, 2015, at 11:45 AM, Ivan Safonov  wrote:
> 
> Hi!
> 
> I have a large patch in the 2000 lines, which replaces the macro BITn to 
> BIT(n) in multiple files.

I will recommend sending RFC patch first and 
Get the community comments.

If they like your patch then divide the patch based on logic rather than lines 
of codes.
> Is it worth to split this patch into several parts?
> Is it sufficient to place the changes in each file in a separate part of 
> patchset?
> 
> 
> 
> ___
> 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: bitops for handling 32 bits

2015-07-28 Thread Anish Kumar




 On Jul 28, 2015, at 10:46 PM, Kevin Wilson wkev...@gmail.com wrote:
 
 Hi all,
 Is there a kernel API for handling 32 bits ?
 I see a macro like BIT(nr)
 http://lxr.free-electrons.com/source/include/linux/bitops.h#L6
 
 #define BIT(nr) (1UL  (nr))
 
 and also
 #define BIT_ULL(nr) (1ULL  (nr))
 
 However, these macros are using 64 bit semantics, so if I will use
 them with 32 bits values
 the results will  be wrong.

Did you try using it? The code is generic.
 
 Any ideas ?
 
 Regards,
 Kevin
 
 ___
 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: why use while(0) to write set_current_state

2015-06-16 Thread Anish Kumar




 On Jun 16, 2015, at 10:01 PM, 慕冬亮 mudonglianga...@gmail.com wrote:
 
 I see the macro in the include/linux/sched.h
 #define __set_current_state(state_value)  \
   do { current-state = (state_value); } while (0)
 
 Why define it like this? What's the meaning of while?

Read this and you will know why.
http://kernelnewbies.org/FAQ/DoWhile0

 mudongliang 
 ___
 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: To use wake_up_interruptible in ISR

2015-05-26 Thread Anish Kumar




 On May 25, 2015, at 10:02 PM, 김찬 c...@etri.re.kr wrote:
 
 Hello,
 
 I see in the source (linux ver 3.3) that wake_up_interruptible function 
 doesn't sleep so I used in it an ISR but I'm getting 'BUG:scheduling while 
 atomic' message. (I'm not sure it's coming from this)

Remove it and check if the problem goes away.
 I'm looking for the exact cause but Is there any caveat when using 
 wake_up_interruptible() in an ISR?  (I found some drivers use it in ISR, some 
 use it in work_struct)
 

I think there should be no problem using this api in isr context.
 I also read in 
 http://www.slideshare.net/rampalliraj/tasklet-vs-work-queues?from_action=save 
  that tasklet is not allowed to sleep but work is. (because  tasklet is not 
 in process context, but in bottom-half)
 I don't know if I have to move the wake_up_interruptible function to tasklet 
 or work(queue) or even it matters to the current problem.
 
 Any help would be greatly appreciated. 

What are you trying to achieve.
 Regards,
 
 Chan
 
 ___
 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: getting interrupt number

2015-03-08 Thread Anish Kumar




 On Mar 8, 2015, at 7:25 PM, Ronit Halder ronit.li...@gmail.com wrote:
 
 How to get the interrupt number of a device.I know it's device id and
 the bus number.
 The device is a usb mouse.

Interrupt number is not a constant value.
Depending on the board it changes.
For which are you asking ?
 
 ___
 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: Get local CPU id

2015-03-08 Thread Anish Kumar
You can use ftrace and such.



 On Mar 8, 2015, at 12:06 PM, Matwey V. Kornilov matwey.korni...@gmail.com 
 wrote:
 
 Hi,
 
 I would like to somehow obtain local CPU core ID in the interrupt
 handler function. I want to see how my interruptions are distributed
 among different CPU cores under different conditions.
 
 How should I do that?
 
 
 ___
 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: workqueues - how to use them correctly

2015-02-10 Thread Anish Kumar




 On Feb 10, 2015, at 12:50 AM, Roshan A roshan@gmail.com wrote:
 
 hi all,
 
 My question is regarding the correct use of workqueues. I have a
 driver which queues a work item in the interrupt handler. The bottom
 half function ( the workitem -function ) does have proper locking (
 mutex ) in place for atomicity.

Post the code snippet and why are you using
Mutex? If you want to synchronize between 
Interrupt handler and workqueue then you should
use spinlocks.
 
 With this setup, since the interrupts are enabled, it's possible to
 have a scenario where, when one workitem is being executed, another
 can be queued up, which results in the workitems being executed in
 parallel, however since there is a mutex, one thread will sleep.

And precisely the reason not to use mutex locks.
 
 is this particular scenario considered bad or discouraged ?

Now what do you think?
 
 Thank you,
 -Roshan
 
 ___
 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: container_of

2015-01-17 Thread Anish Kumar




 On Jan 17, 2015, at 8:32 AM, Simon Brand simon.br...@postadigitale.de wrote:
 
 Good evening,
 
 i read the article about the container_of function:
 http://www.kroah.com/log/linux/container_of.html
 
 I understand what it does and how it works.
 
 I thought, it could be simplified by replacing it through this:
 
 #define container_of(ptr, type, member) ({ \
(type *)( (char *)ptr - offsetof(type,member) );})
 
 Original:
 #define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)-member ) *__mptr = (ptr); 
(type *)( (char *)__mptr - offsetof(type,member) );})
 
 
 ptr has the type of a pointer to the member, which should be the same
 as __mptr? The value should although be the same.
 
 First I tried it in a self written script, then replaced it in
 include/linux/kernel.h and compiled it as usermode linux - working
 well.
 
 Then I compiled it and run it in a VM, but it is not working.
What do you mean by that? What is not working?
 
 Can you please explain to me, why the original version is always working
 and mine is not? 
 
 Thank you for your time!
 
 Regards,
 Simon
 
 ___
 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: test jiffies on ARM SMP board

2013-02-20 Thread anish kumar
On Wed, 2013-02-20 at 17:30 +, Russell King - ARM Linux wrote:
 On Wed, Feb 20, 2013 at 10:54:41PM +0530, anish kumar wrote:
  On Thu, 2013-02-21 at 00:39 +0800, buyitian wrote:
   i am confused about my test. in one device driver, 
   i put below code:
   
   printk(start to test test jiffies\n);
   
   local_irq_save(flags);
   
   jf1 = jiffies; // read jiffies first time
   
   // hold cpu for about 2 seconds(do some calculation)
   
   jf2 = jiffies; // read jiffies after 2 seconds
   
   local_irq_restore(flags);
   
   printk(jf1:%lu, jf2:%lu\n, jf1, jf2);
   
   and the output is as below:
   
   4[  108.551124]start to test test jiffies
   4[  110.367604]jf1:4294948151, jf2:4294948151
   
   the jf1 and jf2 are the same value, although they are
   read between 2 seconds interval, i think this is because
   i disabled local interrupt.
   but the printk timestamp is from 108.551124 to 110.367604,
   which is about 2 seconds. and on my platform, printk timestamp
   is got from the function read_sched_clock:
  static u32 __read_mostly (*read_sched_clock)(void) = 
   jiffy_sched_clock_read;
   
   and function jiffy_sched_clock_read() is to read from jiffies.
   
   it seems that the jiffies is frozen when local irq is disabled,
   but after local_irq_restore(), the jiffies not only start
   to run, but also recover the lost 2 seconds.
   
   is the jiffies updated from another cpu when irq is disabled on
   local cpu? 
   
   is there some internel processor interrupt between cpu1 and cpu0
   after local irq is re-enabled so that jiffies recover the lost 2 seconds? 
 
  I think it is because of the fact that some RTC registers keep the
 
 The RTC has nothing to do with this.
 
 As soon as the IRQs are allowed again (immediately after the
 local_irq_restore()) the pending interrupt - including the timer
 interrupt will be processed.
 
 At this point, because we read the clocksource, we can see that two
 seconds have passed, and so we advance jiffies by the elapsed time.
So I understand there is some register which stores the elapsed time and
in my understanding it was RTC register which is wrong as suggested by
you.I suppose some timer register is used for this information on the
SOC.
 
 This means printk() sees that the two seconds have passed.  But because
 you're reading from jiffies within the interrupt disabled region, that
 code can't see the missed ticks.



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


Re: process 0 (swapper)

2013-02-16 Thread anish kumar
On Sat, 2013-02-16 at 18:48 +0200, Kevin Wilson wrote:
 Hi,
 
  we see this code in proc_pid_lookup:
 
  tgid = name_to_int(dentry);
  if (tgid == ~0U)
  goto out;
It is the error case when name can't be converted to integer i.e.
name is wrong.
 
  In other words, if you ask for pid 0, it bails and doesn't return anything.
 
 Are you sure that this is what it cjecks?
 
  ~0U is not 0 but -1;
right
 
 for example, try:
   printf(%d\n,~0U );
   printf(%x\n,~0U );
   printf(%x\n,-1 );
 and you get:
 -1
 
 
 rgs
 Kevin
 
 ___
 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: Kernel code interrupted by Timer

2013-02-09 Thread anish kumar
Thanks Frederic.
On Sat, 2013-02-09 at 08:44 +0100, Frederic Weisbecker wrote:
 2013/2/8 Gaurav Jain gjainroor...@gmail.com:
  What happens if the kernel executing in some process context (let's say
  executing a time-consuming syscall) gets interrupted by the Timer - which is
  apparently allowed in 2.6 onwards kernels.
 
  My understanding is that once the interrupt handler is done executing, we
  should switch back to where the kernel code was executing.
 
 Exactly. At the end of the interrupt, the state of the processor
 (register values) as it was before being interrupted is restored.
 
  Specifically, the
  interrupt handler for the Timer interrupt should not schedule some other
  task since that might leave kernel data in an inconsistent state - kernel
  didn't finish doing whatever it was doing when interrupted.
 
  So, does the Timer interrupt handler include such a policy for the above
  case?
 
 In the case you have CONFIG_PREEMPT and it's the turn for some other
 task to be scheduled, the function preempt_schedule_irq() is called
 right before the irq return to the interrupted code. If the irq
 interrupted preemptible code (code that was not under a
 preempt_disable() section) then the scheduler may well schedule
 another task.
However if the code is under preempt_disable() when irq happened then it
won't choose any other task and will come back immediately to the task
which was preempted by the irq handler.

I think what you are referring is below code:

__irq_svc:
svc_entry
irq_handler

#ifdef CONFIG_PREEMPT
get_thread_info tsk
ldr r8, [tsk, #TI_PREEMPT]  @ get preempt count
ldr r0, [tsk, #TI_FLAGS]@ get flags
teq r8, #0  @ if preempt count != 0
movne   r0, #0  @ force flags to 0
tst r0, #_TIF_NEED_RESCHED
blnesvc_preempt
#endif

#ifdef CONFIG_PREEMPT 
svc_preempt:
mov r8, lr
1:  bl  preempt_schedule_irq@ irq en/disable is done
inside
ldr r0, [tsk, #TI_FLAGS]@ get new tasks TI_FLAGS
tst r0, #_TIF_NEED_RESCHED
moveq   pc, r8  @ go again
b   1b
#endif


/*
 * this is the entry point to schedule() from kernel preemption
 * off of irq context.
 * Note, that this is called and return with irqs disabled. This will
 * protect us against recursive calling from irq.
 */
asmlinkage void __sched preempt_schedule_irq(void)
{
struct thread_info *ti = current_thread_info();

/* Catch callers which need to be fixed */
BUG_ON(ti-preempt_count || !irqs_disabled());

user_exit();
do {
add_preempt_count(PREEMPT_ACTIVE);
local_irq_enable();
__schedule();
local_irq_disable();
sub_preempt_count(PREEMPT_ACTIVE);

/*
 * Check again in case we missed a preemption
opportunity
 * between schedule and now.
 */
barrier();
} while (need_resched());
}

 
 It may indeed sound suprising that we schedule from an interrupt but
It is really *surprising* that we do scheduling from interrupt context.
Doesn't Do's and Don't of scheduling from interrupt context apply here?

So how does the regular call to schedule() occur when task(process) time
slice is over?
 it's actually fine. Later on, the scheduler restores the previous task
 to the middle of preempt_schedule_irq() and the irq completes its
Sorry didn't understand this sentence i.e. scheduler restores the
previous task to the middle of preempt_schedule_irq().
 return to what it interrupted. The state of the processor prior to the
 interrupt is stored on the task stack. So we can restore that anytime.
 Note if the irq interrupted userspace, it can do about the same thing,
 except it calls schedule() directly instead of preempt_schedule_irq().
 
 ___
 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: Kernel code interrupted by Timer

2013-02-09 Thread anish kumar

On Sun, 2013-02-10 at 00:47 +0800, Peter Teoh wrote:
 
 
 On Sun, Feb 10, 2013 at 12:22 AM, Frederic Weisbecker
 fweis...@gmail.com wrote:
 2013/2/9 Peter Teoh htmldevelo...@gmail.com:
  A search in the entire subtree of arch/x86/ and including
 all its
  subdirectories, (for 3.2.0 kernel) return only TWO result
 where
  preempt_schedule_irq is called:   kernel/entry_64.S and
 kernel/entry_32.S.
  And the called is in fact resume_kernel(),   ie, it is NOT
 called from timer
  interrupt, but from wakeup context of the CPU, and is only
 executed ONCE
  upon waking up from hibernation.
 
  for example, calling from here:
 
  https://lkml.org/lkml/2012/5/2/298
 
  so definitely this preempt_schedule_irq() calling from irq
 mode is rare - at
  least for x86.
 
 
 The name resume_kernel can indeed sound like something that
 is
 called on hibernation resume. It's actually not related at
 all. It's a
 piece of code that is called at the end of every irq and
 exception
 when the interrupted code was running in the kernel. If the
 interrupted code was running in userspace, we jump to
 resume_userspace.
 
 well, i guessed u must be the expert here, i have yet to really digest
 all these...:-).   thanks for the explanation.
In the kernel folder do this:
git log --author=Frederic Weisbecker
 
 
 -- 
 Regards,
 Peter Teoh



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


Re: Kernel code interrupted by Timer

2013-02-08 Thread anish kumar
On Sat, 2013-02-09 at 14:57 +0800, Peter Teoh wrote:
 
 
 On Sat, Feb 9, 2013 at 1:47 PM, anish kumar 
 .
 Timer interrupts is supposed to cause scheduling and scheduler
 may or
 may not pick up your last process(we always use the term
 task in
 kernel space) after handling timer interrupt.
 
 
 
 
 Sorry if I may disagree, correct me if wrong.   Timer interrupt and
 scheduler is two different thing.   I just counted in the drivers
 subdirectory, there are at least more than 200 places where
 setup_timer() is called, and these have nothing to do with
 scheduling.   For eg, heartbeat operation etc.  Not sure I
 misunderstood something?
Have a look at kernel/timer.c and kernel/hrtimer.c.
There are many sched() calls in these files.This will invoke scheduler.
 
 
 -- 
 Regards,
 Peter Teoh



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


Re: pr_info not printing message in /var/log/messages

2013-02-07 Thread anish kumar
On Tue, 2013-02-05 at 16:18 -0500, valdis.kletni...@vt.edu wrote:
 On Wed, 06 Feb 2013 04:43:20 +0800, Jimmy Pan said:
 
  in fact, i've been always wondering what is the relationship between dmesg
  and /var/log/message. they diverse a lot...
dmesg is provided by kernel using cat /proc/kmsg.

/proc/kmsg is like any other linux file which supports below file
operations:

from /kernel/printk.c
const struct file_operations kmsg_fops = {
.open = devkmsg_open,
.read = devkmsg_read,
.aio_write = devkmsg_writev,
.llseek = devkmsg_llseek,
.poll = devkmsg_poll,
.release = devkmsg_release,
};

printk dumps it's output in the ring buffer whose size is set using
defconfig CONFIG_LOG_BUF_SHIFT(if 16 = then ring buffer size is 64KB,
and for 17 = 128KB).

This ring buffer is the source for syslog and klogd daemon logs.How it
extracts the buffer depends on the configuration of these deamons.

Call stack:

printk
vprintk_emit
log_store
write to log_buf
log_from_idx used by /proc/kmsg to read the buffer
sylog uses ioctl to work on ring buffers:
case SYSLOG_ACTION_CLOSE:   /* Close log */
case SYSLOG_ACTION_OPEN:/* Open log */
case SYSLOG_ACTION_READ:/* Read from log */
case SYSLOG_ACTION_READ_CLEAR:
case SYSLOG_ACTION_READ_ALL:
case SYSLOG_ACTION_CLEAR:
case SYSLOG_ACTION_CONSOLE_OFF:
case SYSLOG_ACTION_CONSOLE_ON:
case SYSLOG_ACTION_CONSOLE_LEVEL:
case SYSLOG_ACTION_SIZE_UNREAD:
case SYSLOG_ACTION_SIZE_BUFFER:


Quoting from
http://askubuntu.com/questions/26237/difference-between-var-log-messages-var-log-syslog-and-var-log-kern-log

Syslog is a standard logging facility. It collects messages of various
programs and services including the kernel, and stores them, depending
on setup, in a bunch of log files typically under /var/log. There are
also possibilities to send the messages to another host over network, to
a serial console, to a database table, etc.

According to my /etc/syslog.conf, default /var/log/kern.log captures
only the kernel's messages of any loglevel; i.e. the output of dmesg.

/var/log/messages instead aims at storing valuable, non-debug and
non-critical messages. This log should be considered the general system
activity log.

/var/log/syslog in turn logs everything, except auth related messages.

Other insteresting standard logs managed by syslog
are /var/log/auth.log, /var/log/mail.log.

Regarding your question: if you need solely kernel messages log, use the
kern.log or call dmesg.
 
 What ends up in /var/log/message is some subset (possibly 100%, possibly 0%)
 of what's in dmesg.  Where your syslog daemon routes stuff is a local config
 issue - if your syslogd supports it, there's no reason not to dump the 
 iptables
 messages in to /var/log/firewall and the rest of it in /var/log/kernel, or
 any other policy that makes sense for the sysadmin
 ___
 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: locking spinlocks during copy_to_user, copy_from_user

2013-01-25 Thread anish kumar
On Fri, 2013-01-25 at 10:00 -0300, Pablo Pessolani wrote:
 Hi:
It is well know that is not recomended to keep a spinlock locked
 during operations that can be preempted. Some of these operations are
 copy_to_user, copy_from_user.
 Below is the code of the write_lock() as a sample.
  
 340 static inline void __write_lock(rwlock_t *lock)
  341{
  342preempt_disable();  THE ISSUE IS HERE 
  343rwlock_acquire(lock-dep_map, 0, 0, _RET_IP_);
  344LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
  345}
 
 On write_unlock() the preemtion is enable.
  
 My question is: Is there any know consequence if I enable preemption
 before copy_to_user/copy_from user (keeping the spinlock locked) and
why do you want to do this?
  then disable preemption again after the copy?
 i.e.:
 write_lock(lock);
 ...
  preempt_enable(); 
  copy_to_user(...);
   preempt_disable(); 
  ...
 write_unlock(lock);
 
 Thanks in advance.
 PAP
  
  
  
  
  
 
 
 ___
 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: what is the function of do_softirq() ?

2013-01-16 Thread anish kumar
On Wed, 2013-01-16 at 10:25 +, Anuz Pratap Singh Tomar wrote:
 
 
 On Tue, Jan 15, 2013 at 6:31 AM, horseriver horseriv...@gmail.com
 wrote:
 hi:
 
what is the function of do_softirq()?
Softirq is basically same as bottom half except it is run in irq
context.So the question which comes to mind is why softirq?Softirqs can
run concurrently on several CPUs and that is why it used in networking.
There are other advantages also but it is mostly use case dependent.
 
It is called by ksoftirqd() ,which is setup by :
 kernel_thread(ksoftirqd, hcpu, CLONE_KERNEL) ; 
ksoftirq is a saviour thread which takes up the execution of softirq if
it finds out that softirq are executing one by one and thereby userspace
is not being scheduled or none of other task is getting executed.As
threads have low priority it lets other tasks run.
 
 Please read Understanding the Linux Kernel Chapter on Interrupts and
 Section on Softirqs and tasklets.  Page number 171(might be different
 in other editions) onwards.
 
 
 
 thanks!
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
 
 
 -- 
 Thank you 
 Warm Regards
 Anuz
 ___
 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: Block device driver: how to terminate the block device if media disappears?

2013-01-12 Thread anish kumar
On Sat, 2013-01-12 at 14:39 -0300, Ezequiel Garcia wrote:
 On Mon, Jan 7, 2013 at 7:49 AM, John Beard jo...@codexdigital.com wrote:
  On 21/12/12 18:23, Ezequiel Garcia wrote:
 
  On Thu, Dec 13, 2012 at 12:31 PM, John Beard jo...@codexdigital.com 
  wrote:
 
  What is the right way to terminate requests and delete the gendisk in
  the case of physically vanished PCI devices (or even devices in general)?
 
 
  There are several block driver examples in drivers/block.
  Or you might want to take a loot at mtdblock.c, or perhaps
  this simple ubiblock implementation:
 
  http://lwn.net/Articles/525957/
 
  Thanks, Ezequiel - sorry for the delay, I haven't had a chance to touch
  my development computer over the break. The workqueue-based approach
  from ubiblock.c seems to have solved the problem and the device can now
  shut down happily once the request queue is emptied in the submit_req
  call following device removal.
 
 
 Great! It's nice to hear the hint helped you.
 
 FYI, a workqueue should always be preferred over a separate kernel thread,
 unless there is a good reason for the kernel thread.
I was led to believe that the workqueue implementation is based on
kernel thread.
I wonder in which cases kernel thread should be preferred over
workqueue?
 



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


Re: Regarding module init function

2013-01-08 Thread anish kumar
On Tue, 2013-01-08 at 14:51 +0100, Tobias Boege wrote:
 On Tue, 08 Jan 2013, Rahul Bedarkar wrote:
  Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each
  of init functions from __early_initcall_end to __initcall_end. But I don't
  know from where these values gets initialized.
  
 
 Take a look at include/linux/init.h. There you can find the macros for
 declaring various init functions. They all go into special sections. The
 rest is linker magic (e.g. arch/x86/kernel/vmlinux.lds{,.S}).
 
  I want to know when one of auxdriver (selected in from menuconfig) is built
  as built-in module. When and Who calls it's init function ?
 
 It's, too, in the init.h. There are two definitions of module_init()
 depending on whether MODULE is declared or not. The first definition is
How does the individual driver define this MODULE?I think some macro
magic works here.
 accompanied by a useful comment about where the init function is called in
 either case.
 
 Regards,
 Tobi
 
 
 ___
 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: How kernel handle interrupts[AX88796B network controller]

2013-01-07 Thread anish kumar
On Mon, 2012-12-24 at 22:10 +0800, Woody Wu wrote:
 On Fri, Dec 21, 2012 at 01:33:03PM -0800, anish kumar wrote:
  On Fri, 2012-12-21 at 23:34 +0800, Woody Wu wrote:
   On Thu, Dec 20, 2012 at 10:05:05AM -0800, anish singh wrote:
On Dec 20, 2012 6:30 AM, Woody Wu narkewo...@gmail.com wrote:

 Hi, List

 Where is the Kernel code that handles external interrupts? I want to
 have a look at it but haven't found out where it is.

 Actually, I have some basic questions about interrupt handling in 
 Linux.
 1. After Kernel's ISR received an interrupt, I believe it will invoke 
 a
handler defined in a device driver if any. But it should be the
device driver's responsibility or kernel ISR's responsibility to
clear (or acknowledge) the interrupt?
If the interrupt in question is currently being handled then in
the case of edge triggered interrupt we just mask the interrupt,set it
pending and bail out.Once the interrupt handler completes then we check 
for
pending interrupt and handle it.In level triggered we don't do that.
Kerenel ISR -this is mixture of core kernel interrupt handling code + 
your
device driver interrupt handler(if this is chip driver which is 
supposed to
get one interrupt and is reponsible for calling other interrupt handlers
based on the chip register status then you do explicit masking unmasking
yourself).
If you device driver is a interrupt controller driver then you register
your driver with kernel interrupt handling code and need to write some
callbacks such as .mask,.unmask and so on.This callbacks are called at
appropiate places whenever the interrupt is raised.This interrupt is 
then
passed to drivers who has requested for this interrupt by calling
request_irq.

 2. My device, an AX88796B network controller, asserting the interrupt
line in a level-triggered manner. Now I met problem with the device
that
might caused by the CPU interrupt mode is not set as 
 level-triggered by
edge trigger.  My CPU is Samsung S3C2410, an ARM920T powered one.  
 Does
anyone know usually where and how should I do this kind of setting?
Just pass the parameter level triggered in request_irq in your device
driver.
   
   Hi Sign,
   
   I searched the interrupt.h for the all the defined flags that I can pass
   to the request_irq, but there is no a flag looks like level triggered.
   Would you tell me what you mean the parameter level triggered?
  irq_set_irq_type(info-irq, IRQ_TYPE_LEVEL_LOW)
  
  include/linux/irq.h
  IRQ_TYPE_LEVEL_HIGH  - high level triggered
  IRQ_TYPE_LEVEL_LOW   - low level triggered
 
 Thanks. You saved my ass.
 
 Be curious, I found the api changes from 2.6 to 3.7.  In 2.6, there are
 pair of funtions, set_irq_type and set_irq_handle (there is no
 irq_set_irq_type in 2.6).  Problem is, I cannot find something like
 irq_set_irq_handle in 3.7.  Does that mean, in 3.7, when
 irq_set_irq_type is changed, the associated flow handler is also
 changed?  In my case, the interrupt was originally assgined with a edge
 flow handler and set type as edge irq. After I, by invoking
 irq_set_irq_type, change it to level irq, I think the flow handler
 should also be changed to a level handle.  Is that happened
 automatically behind?  I search through the code, but did not find where
 is it.
Why not try calling irq_set_irq_type and check what happens?
 
 
   
   Thanks.
   


 Thanks in advance.

 --
 woody
 I can't go back to yesterday - because I was a different person then.

 ___
 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: How kernel handle interrupts[AX88796B network controller]

2013-01-07 Thread anish kumar
On Sat, 2012-12-22 at 23:11 +0800, Woody Wu wrote:
 On Fri, Dec 21, 2012 at 01:33:03PM -0800, anish kumar wrote:
  On Fri, 2012-12-21 at 23:34 +0800, Woody Wu wrote:
   On Thu, Dec 20, 2012 at 10:05:05AM -0800, anish singh wrote:
On Dec 20, 2012 6:30 AM, Woody Wu narkewo...@gmail.com wrote:

 Hi, List

 Where is the Kernel code that handles external interrupts? I want to
 have a look at it but haven't found out where it is.

 Actually, I have some basic questions about interrupt handling in 
 Linux.
 1. After Kernel's ISR received an interrupt, I believe it will invoke 
 a
handler defined in a device driver if any. But it should be the
device driver's responsibility or kernel ISR's responsibility to
clear (or acknowledge) the interrupt?
If the interrupt in question is currently being handled then in
the case of edge triggered interrupt we just mask the interrupt,set it
pending and bail out.Once the interrupt handler completes then we check 
for
pending interrupt and handle it.In level triggered we don't do that.
Kerenel ISR -this is mixture of core kernel interrupt handling code + 
your
device driver interrupt handler(if this is chip driver which is 
supposed to
get one interrupt and is reponsible for calling other interrupt handlers
based on the chip register status then you do explicit masking unmasking
yourself).
If you device driver is a interrupt controller driver then you register
your driver with kernel interrupt handling code and need to write some
callbacks such as .mask,.unmask and so on.This callbacks are called at
appropiate places whenever the interrupt is raised.This interrupt is 
then
passed to drivers who has requested for this interrupt by calling
request_irq.

 2. My device, an AX88796B network controller, asserting the interrupt
line in a level-triggered manner. Now I met problem with the device
that
might caused by the CPU interrupt mode is not set as 
 level-triggered by
edge trigger.  My CPU is Samsung S3C2410, an ARM920T powered one.  
 Does
anyone know usually where and how should I do this kind of setting?
Just pass the parameter level triggered in request_irq in your device
driver.
   
   Hi Sign,
   
   I searched the interrupt.h for the all the defined flags that I can pass
   to the request_irq, but there is no a flag looks like level triggered.
   Would you tell me what you mean the parameter level triggered?
  irq_set_irq_type(info-irq, IRQ_TYPE_LEVEL_LOW)
  
  include/linux/irq.h
  IRQ_TYPE_LEVEL_HIGH  - high level triggered
  IRQ_TYPE_LEVEL_LOW   - low level triggered
 
 Thanks. Now I find the function.
 
 I searched some code about irq in ARM architecure.  Some other
 people talked about do_IRQ() probabaly is wrong for ARM. There is simply
 no that function in ARM. Maybe the do_IRQ in x86 is replaced by
 handle_IRQ.
arch/arm/kernel/entry-armv.S
__irq_svc is called by the arm processor which in turn calls irq_handler
macro.I think this is the lowest level handler after which linux
interrupt handling takes over.
 
 For the irq_set_irq_type(), do you think what's the correct place to
 call it? Inside my device driver or outside the device driver (probably
 in the board definition file)? If that should be called inside a device
 driver, should it be the driver probe function or in the open function?
 After or before the invocation of request_irq()?
irq_set_irq_type() should be called by device driver code not by the
board file.It should be called in the probe function AFAIK.
 
 Sorry for asking too many question.  I found the kernel + device driver
 irq handling part still not clear to me.
You are welcome to ask as many question as you want.
 
 
   
   Thanks.
   


 Thanks in advance.

 --
 woody
 I can't go back to yesterday - because I was a different person then.

 ___
 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: What does ISA/PCI really mean to ARM architecture?

2012-12-27 Thread anish kumar
On Thu, 2012-12-27 at 10:51 +0100, Geert Uytterhoeven wrote:
 On Thu, Dec 27, 2012 at 9:27 AM, Woody Wu narkewo...@gmail.com wrote:
  Can a peripheral chip that claims to be ISA or PCI device be used in a
  ARM based embedded system?  For these kind of chips, I only concern
  about the planar kind of devices, means they are not on a dedicated
  expansion card.
 
  From hardware point of view, to attach a ISA or PCI planar chip, is
  there any requirement need to fulfill on a ARM bard?
arm AFAIK is only used in embedded system but ISA/PCI buses are
generally part of 'big systems' and most of the times it refers to x86
PC.
 
  From Linux driver point of view, what are needed to support an ISA or
  PCI driver in ARM architecture?  More important, is ISA or PCI device a
  platform device?  If not, how to add these kind of devices in my board
  definition?
AFAIK, Platform device is just a way to add a particular driver whose
probe can't be called at runtime.Mostly platform device is part of
system on chip.
PCI devices probe function will be called by the PCI bus as and when it
detects any activity on the bus.So you don't need PCI device to be  a
platform device.
 
 An ISA device is typically a platform device. For ARM, which uses device 
 trees,
Don't know much about ISA device to comment on this but people familiar
with this can enlighten us as to the reason why it is platform device in
detail.
 this means you define it in the device tree.
 
 A PCI device is not a platform device, as devices on a PCI bus can be
 probed automatically. The PCI host bridge is typically a platform device,
 though, so it it should be in your device tree.
 
 Gr{oetje,eeting}s,
 
 Geert
 
 --
 Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
 ge...@linux-m68k.org
 
 In personal conversations with technical people, I call myself a hacker. But
 when I'm talking to journalists I just say programmer or something like 
 that.
 -- Linus Torvalds
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



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


Re: What does ISA/PCI really mean to ARM architecture?

2012-12-27 Thread anish kumar
On Thu, 2012-12-27 at 11:22 -0500, jonsm...@gmail.com wrote:
 On Thu, Dec 27, 2012 at 3:27 AM, Woody Wu narkewo...@gmail.com wrote:
  Hi, list
 
  I know this might be a very basic question.  But I really don't clear at
  it.
 
  Can a peripheral chip that claims to be ISA or PCI device be used in a
  ARM based embedded system?  For these kind of chips, I only concern
  about the planar kind of devices, means they are not on a dedicated
  expansion card.
 
  From hardware point of view, to attach a ISA or PCI planar chip, is
  there any requirement need to fulfill on a ARM board?
 
 See if your ARM CPU has an interface for SRAM (in addition to DRAM).
 You can use a SRAM chip select to access ISA type devices. But you may
Would you mind explaining this in detail?
 need additional buffers/latches to do this.
 
 Another solution is to attach you peripherals using USB. Almost all
Connect using USB what does this mean?
 embedded wifi chips are attached this way. The USB connectors aren't
 required, you can route USB around on your PCB. USB hub chips are
 $0.35 if you need more ports.  USB Ethernet chips are available.
 
 Other options include SPI/I2C. It is worthwhile to investigate these
Only chips which support SPI/I2C can be used but ISA/PCI is completely
orthogonal to this AFAIK.
 serial solutions before doing a parallel solution. Parallel buses eat
 up a lot of PCB space.
 
 
 
  From Linux driver point of view, what are needed to support an ISA or
  PCI driver in ARM architecture?  More important, is ISA or PCI device a
  platform device?  If not, how to add these kind of devices in my board
  definition?
 
  I know my question might not be reasonable enough, if I messed concepts,
  please sort me out.
 
 
  Thanks in advance.
 
 
  --
  woody
  I can't go back to yesterday - because I was a different person then.
  --
  To unsubscribe from this list: send the line unsubscribe linux-kernel in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 
 
 
 --
 Jon Smirl
 jonsm...@gmail.com
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



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


Re: How kernel handle interrupts

2012-12-21 Thread anish kumar
On Fri, 2012-12-21 at 17:34 +0800, Woody Wu wrote:
 
 在 2012-12-21 AM2:05,anish singh anish198519851...@gmail.com写
 道:
 
 
  On Dec 20, 2012 6:30 AM, Woody Wu narkewo...@gmail.com wrote:
  
   Hi, List
  
   Where is the Kernel code that handles external interrupts? I want
 to
   have a look at it but haven't found out where it is.
  
   Actually, I have some basic questions about interrupt handling in
 Linux.
   1. After Kernel's ISR received an interrupt, I believe it will
 invoke a
  handler defined in a device driver if any. But it should be the
  device driver's responsibility or kernel ISR's responsibility
 to
  clear (or acknowledge) the interrupt?
  If the interrupt in question is currently being handled then in
  the case of edge triggered interrupt we just mask the interrupt,set
 it pending and bail out.Once the interrupt handler completes then we
 check for pending interrupt and handle it.In level triggered we don't
 do that.
  Kerenel ISR -this is mixture of core kernel interrupt handling code
 + your device driver interrupt handler(if this is chip driver which is
 supposed to get one interrupt and is reponsible for calling other
 interrupt handlers based on the chip register status then you do
 explicit masking unmasking yourself).
  If you device driver is a interrupt controller driver then you
 register your driver with kernel interrupt handling code and need to
 write some callbacks such as .mask,.unmask and so on.This callbacks
 are called at appropiate places whenever the interrupt is raised.This
 interrupt is then passed to drivers who has requested for this
 interrupt by calling request_irq.
 
 Sorry not fully understand . My device is an interrupt line is back to
 inactive.Ethernet controller. It needs to response TX and RX
 interrupts triggered by the device itself. In this case , my driver is
 a chip driver or interrupt controller driver in your terms?
Your device is neither of these.
 
 If my driver needs to do the mask and unmask job, what's the kernel
 API I should call?
You don't need to worry about mask and unmask job AFAIK.
 
 And , I don't understand why there exists differences between level
 and edge triggered interrupts in terms of kernel handling.
Level type interrupts are active as long as the hardware line has the
active level. This may require to mask the interrupt and unmask it after
the associated handler has acknowledged the device, so the interrupt
line is back to inactive.
Edge interrupt occurs on the falling and/or rising edge of a hardware
signal.The occurrence is latched into the irq controller hardware
and must be acked in order to be re-enabled.
Read the code /kerel/irq/chip.c(handle_edge_irq  handle_level_irq)
 
 I know my questions might be basic , so would please tell me what's
If it was not basic then this question wouldn't be in kernelnewbies
right :)?
  the kernel code for ARM architecture doing these complex jobs as you
 explained?
You don't need to worry about it but if you want to know further then I
suggest tracing the call flow from asm interrupt handler(I believe
do_irq but not sure) in arm to handle_edge_irq call flow by adding some
logs or just browsing the code.
 
 Thanks in advance !
 
 
  
   2. My device, an AX88796B network controller, asserting the
 interrupt
  line in a level-triggered manner. Now I met problem with the
 device that
  might caused by the CPU interrupt mode is not set as
 level-triggered by
  edge trigger.  My CPU is Samsung S3C2410, an ARM920T powered
 one.  Does
  anyone know usually where and how should I do this kind of
 setting?
  Just pass the parameter level triggered in request_irq in your
 device driver.
 
  
  
   Thanks in advance.
  
   --
   woody
   I can't go back to yesterday - because I was a different person
 then.
  
   ___
   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: How kernel handle interrupts[AX88796B network controller]

2012-12-21 Thread anish kumar
On Fri, 2012-12-21 at 23:34 +0800, Woody Wu wrote:
 On Thu, Dec 20, 2012 at 10:05:05AM -0800, anish singh wrote:
  On Dec 20, 2012 6:30 AM, Woody Wu narkewo...@gmail.com wrote:
  
   Hi, List
  
   Where is the Kernel code that handles external interrupts? I want to
   have a look at it but haven't found out where it is.
  
   Actually, I have some basic questions about interrupt handling in Linux.
   1. After Kernel's ISR received an interrupt, I believe it will invoke a
  handler defined in a device driver if any. But it should be the
  device driver's responsibility or kernel ISR's responsibility to
  clear (or acknowledge) the interrupt?
  If the interrupt in question is currently being handled then in
  the case of edge triggered interrupt we just mask the interrupt,set it
  pending and bail out.Once the interrupt handler completes then we check for
  pending interrupt and handle it.In level triggered we don't do that.
  Kerenel ISR -this is mixture of core kernel interrupt handling code + your
  device driver interrupt handler(if this is chip driver which is supposed to
  get one interrupt and is reponsible for calling other interrupt handlers
  based on the chip register status then you do explicit masking unmasking
  yourself).
  If you device driver is a interrupt controller driver then you register
  your driver with kernel interrupt handling code and need to write some
  callbacks such as .mask,.unmask and so on.This callbacks are called at
  appropiate places whenever the interrupt is raised.This interrupt is then
  passed to drivers who has requested for this interrupt by calling
  request_irq.
  
   2. My device, an AX88796B network controller, asserting the interrupt
  line in a level-triggered manner. Now I met problem with the device
  that
  might caused by the CPU interrupt mode is not set as level-triggered by
  edge trigger.  My CPU is Samsung S3C2410, an ARM920T powered one.  Does
  anyone know usually where and how should I do this kind of setting?
  Just pass the parameter level triggered in request_irq in your device
  driver.
 
 Hi Sign,
 
 I searched the interrupt.h for the all the defined flags that I can pass
 to the request_irq, but there is no a flag looks like level triggered.
 Would you tell me what you mean the parameter level triggered?
irq_set_irq_type(info-irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH  - high level triggered
IRQ_TYPE_LEVEL_LOW   - low level triggered
 
 Thanks.
 
  
  
   Thanks in advance.
  
   --
   woody
   I can't go back to yesterday - because I was a different person then.
  
   ___
   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: Callback function from kernel module

2012-11-07 Thread anish kumar
On Sat, 2012-11-03 at 21:56 +0530, jeshkumar...@gmail.com wrote:
 hello Mulyadi,
 
 As per my design, a userspace application shall call some function in
 the application  for each interrupt occur in  particular kernel
 module. So what mechanism shall go ? As subramaniam referred kobject,
 I am going on with it. ( understanding kobject)
Why userspace is bothered about interrupts in the kernel.Something is
inherently wrong in your understanding.
A detailed problem description would help you.
 
 Sent from my HTC
 Excuse for typo.
 
 - Reply message -
 From: Mulyadi Santosa mulyadi.sant...@gmail.com
 Date: Sat, Nov 3, 2012 9:42 pm
 Subject: Callback function from kernel module
 To: Jeshwanth Kumar N K Jeshu jeshkumar...@gmail.com
 Cc: kernelnewbies Kernelnewbies@kernelnewbies.org
 
 
 Hi..
 
 On Sat, Nov 3, 2012 at 8:44 PM, Jeshwanth Kumar N K Jeshu
 jeshkumar...@gmail.com wrote:
  Hello All,
 
  Can I call userspace function from kernel module ? Actually I need
 to
  process some data in user space for every event occured in kernel
 module.
 
 user space function or user space program? for later, IIRC you can use
 usermode_helper...
 
 
 -- 
 regards,
 
 Mulyadi Santosa
 Freelance Linux trainer and consultant
 
 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com
 
 
 ___
 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: Finding the interrupt vector of a given IRQ

2012-10-19 Thread anish kumar
On Fri, 2012-10-19 at 10:34 +0530, Arun KS wrote:
 Hi Anish,
 
 On Mon, May 28, 2012 at 9:16 AM, anish singh
 anish198519851...@gmail.com wrote:
 On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
 richard.weinber...@gmail.com wrote:
  On Sun, May 27, 2012 at 2:02 AM, Mark Farnell
 mark.farn...@gmail.com wrote:
  In the kernel, how can I find out the interrupt vector
 number of a
  given IRQ (for example, IRQ7)?
 
  Within the kernel module, I would like to manually set the
 IRQ using
  the assembly code:
 
  asm(int $irq vector);
 
  and let the IRQ handler installed by a different module
 catch that interrupt.
 
  Is this possible?
 
  No really because not all IRQ have an interrupt line to the
 CPU.
  Linux can multiplex and emulate them. Think of GPIO drivers
 with
  interrupt support.
 
 Can you please describe this in detail?It would really help a
 lot of
 people like me.Does multiplex mean that all numbers starting
 from
 0,1,2,3,.. TOTAL-interrupt will have interrupt lines
 associated with it
 eventhough all interrupt numbers are not linear?
 
 GPIOs are grouped as banks. Let’s say 32 gpios are in a bank.
 There will be only single interrupt line to interrupt controller for a
 bank.
 
 
 Consider that you have configured gpio1 and gpio16 as interrupts.
 Even if interrupt happens on gpio 1 or gpio 16, the same interrupt
 line will be triggered to 
   
 Interrupt controller.
 
 
 Now the gpio driver has to figure out reading the Interrupt status 
 
 Register of GPIO to find which interrupt (gpio1 or gpio16) has really
 fired.
And this is done by this way:
Suppose we have a chip(mfd-multi-funcion-driver) driver which is
connected to processor using a gpio - this gpio line acts as interrupt
line from the processor

  ++
+ Processor+  + Chip   +USB  interrupt handler
+  +gpio-+ MFD+dock interrupt handler
  ++UART interrupt handler
  ++Factory cable interrupt handler

So the code will be as follows:

handler_function()
{   
/* find out which interrupt is triggered */
/* it can be usb,dock,uart or factory cable */
ret_irq = read_mfd_register();
/*
* ok we found out the interrupt line, get a corresponding
* software linux irq number by calling
* irq_domain_add_linear 
* irq_create_mapping 
* you would have made this calls in the probe probably
*/ 
handle_nested_irq(ret_irq); 
}

handle_nested_irq inturn will call all the irq_handlers in the system
for your UART,usb and dock driver.

mfd_driver()
{   
request_irq(gpio_to_irq(gpio), handler_function);
}

Hope I have not missed anything.
 
 So in this case a single interrupt line is multiplex for 32 gpio
 interrupts.
 
 
 HTH.
 
 Thanks,
 Arun
  
  Anyway, why to you think you need to trigger the raw IRQ
 manually?
  This sounds really odd...
 
 
  --
  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: Mult core cpus - SMP

2012-09-13 Thread anish kumar
On Thu, 2012-09-13 at 15:33 +0400, Denis Kirjanov wrote:
Hello Denis,

Don't top post!!
 Yes, for example IBM 970MP CPU:
 
 • Dual processors on a single chip
 – Each processor has its own dedicated storage subsystem, including a
 1 MB L2 cache per core.
 – Each processor has its own dedicated resets, external interrupt,
 thermal diode, and voltage plane
 (common logic is powered on).
 – Common logic provides arbitration for bus access between the two cores.
 – A single external interface allows a companion chip with a single
 interface to support two processors.
 
 On 9/13/12, Kshemendra KP kshemen...@suphalaam.com wrote:
  Hi,
 
  Does  multi core CPU act like SMP system.
Preemption will effectively turn a UniProcessor system into an effective
SMP system.
 
  Regards
 
  Kshemendra
 
 
 



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


Re: Writing I2C chip driver in combination with other structure

2012-09-04 Thread anish kumar
On Fri, 2012-07-20 at 16:24 +0530, aurum spark wrote:
 Hi All,
 
 I have written and seen lot of code of i2c drivers for input subsystem
 devices and much familiar with that. Now I have started writing driver
 for one chip that is not exactly type of input device. So, little bit
 confused about how should be the driver architecture so that it will
 be a clean code yet simple.  Following text and diagram explains short
 functional description of chip.
 
 
 Chip Interface :-
 ==
 
 
 ==   ===
 | ||   I2C |
 | | - I2C ---  |  Device|
 |ARM  | - Bus --  |  With rw|  Input Connect
 | ||   regs   |
 | | ---| |
 == INTR   ===
 
 So above picture depicts how chip is interfaced to ARM CPU. This chip
 has some registers which are rw and can be used to read certain
 information from chip or to program it. This chip is capable of giving
 intterupt to CPU. This chip has one input which it like some cable
 connection. It detects when this cable is connected and raises the
 interrupt.
 
 Functionality Expected in Driver:-
 ===
 
 1. Driver should communicate with chip over I2C.
 2. Driver should report event to user space upon receiving interrupt
 from I2C device.
 3. Driver should be capable of programming I2C chip @ the time of
 initialization as well should be capable of changing registers as and
 when Linux User Space application wants to.
 
 What I have thought of:-
 ==
 
 #1 definitely makes this as i2c client driver(chip driver)
 
 #2 Here I have few options
 
  a) Shall I use input subsystem mechanism to report interrupt as an
 event to user space ? In this case it's combination of I2C + input
 subsystem. Then application can read something over i2c and decide
 next flow,
 
  OR
 
  b) Shall I use some sysfs based interface on which application can do
 select sys call and can receive event ? for this nothing extra
 required.
 
 #3 Since approach in #2 is not fixed here also there are multiple options
 a) This  can be written as I2C client + char driver so that it can
 have ioctls to send commands to i2c chip based on applications demand.
What does this chip do and why does it need to do I2C transaction based
on application demand?
 b) We can provide sysfs interface to user space to send commands to
 i2c device as and when required at runtime.
 
 
 As per my thoughts I am not sure shall I make this as input device
 just to report one event upon getting interrupt from device. Also will
 it be ok to have this as char driver in combination with i2c chip
 driver ?
 Please guide me and take me to correct source or documentation or to
 source code of some driver for this kind of device. Does i2c support
 ops like fbops ?
 
 
 Regards,
  ~/Aurum
 
 ___
 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: How to allocate hugepage in kernel module?

2012-08-09 Thread anish kumar
On Fri, 2012-08-10 at 09:00 +0900, J.Hwan Kim wrote:
 I set the __GFP_COMP flag to __get_free_pages(),
 but the result was same.

Does this help?
sourd/core/memalloc.c +170

 2012년 08월 09일 17:59, Denis Kirjanov 쓴 글:
  Forgot to CC kernelnewbies:
 
  Did you pass the __GFP_COMP flag to __get_free_pages?
 
 
  On 8/9/12, J.Hwan Kimfrog1...@gmail.com  wrote:
  Hi, everyone
 
  How can I allocate physically contiguous huge page in kernel module ?
  The routine of _get_fee_pages() fails whenever there are much free
  memory in system.
 
  I found the procedures for set hugepages with sysctl or
  /proc/sys/vm/nr_hugepages
  but I've not found the api for allocate the huge page in kernel.
 
  Thanks in advnace.
 
  Best Regards,
  J.Hwan Kim
 
 
 
  ___
  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: Why can not processes switch in atomic context?

2012-07-03 Thread anish kumar
On Tue, 2012-07-03 at 22:24 +0800, Parmenides wrote:
 Hi,
 
 It is said that kernel can not be preempted in interrupt context
 and when it is in a critical section protected by a spin lock
 
 1. For the spinlock case, it is easy to get if preemption is allowed
 in critical section, the purpose of protection provided by spinlock
 can not be achieved readily.
I don't know what you mean here.Please clarify.
 
 2. For the interrupt context case, I think when processing interrupt,
 kernel can be preempted in principle. But, this really increases the
 interrupt processing time which further cause longer response time and
 data missing in device. Except that, is there any other reasons?
data missing in device.Can you elaborate that?
Stack space is pretty limited in ISR context.Does that give you a clue?
 
 3. Kernel is responsible for prohibiiting passive process switches,
 namely preemption, in the above cases. But, It seems that it does not
 take care of active process swtiches, namely yield. For example, some
 code in a critical section protected by a spinlock can invoke
 schedule() to switch process passively. Is this the case?
I don't understand this question but we don't switch when we are holding
spinlock as that will jeopardize the integrity of the system i.e.
suppose you slept while holding spinlock.What would happen?
 
 ___
 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: Missing Key-codes from input.h file.

2012-06-26 Thread anish kumar
On Mon, 2012-06-25 at 23:24 +0530, Dharam Kumar wrote:
 On Mon, Jun 25, 2012 at 10:47 PM, anish kumar
 anish198519851...@gmail.com wrote:
  On Mon, 2012-06-25 at 18:52 +0530, Dharam Kumar wrote:
  Hi,
  I'm working on a module which is an input device and hence it needs to
  report certain key events.
 
  While browsing through the linux/input.h, I did find most of the
  key-codes(which I need to use)already defined but not all.
 
 
  Few of the KEY_xxx which i could not find are:
 
 
  a.) A Key for going to the previous channel.
  b.) Keys for Moving upper-right, lower-right, upper-left and
  lower-left direction(probably a GUI(grid of icons),where you move
  diagonally)
  d.) A key for Subpicture (this 'subpicture' key is deeined in
  CEA-931C).
  I think you are interested in the user space implementation of
  the keys reported by the input subsystem of kernel.
  Keys reported by the driver-input subsystem-reported to user space.
 
  I am not sure about linux way of reporting keys but in android the key
  is reported at a particular sysfs file and this sysfs file is read by
  eventhub.cpp.This file in turn is responsible for sending the events
  to particular application and it is the responsibility of the
  application how they interpret this keys.It can interpret events by
  moving diagonally a pointer/touch or going left/right.
 
 Thanks Anish ! To be clear, i just want to know the key-code
 which will be used by the Input Subsytem of the Kernel.
 
 For example, in linux/input.h file you will find a lot of #defines
 like the below,mapping different kind of key events to some key-code
 or value :
 #define KEY_UP 0xXYZ
 #define KEY_DOWN 0xABC and so on...
 
 Now, I'm looking for key events like:
 #define KEY_PREVIOUSCHANNEL   ???
 #define KEY_RIGHTUP ???
 #define kEY_RIGHTLEFT ???
 #define kEY_SUBPICTURE ??? and so on...
 
 You are probably right , that Userspace reads the key-events/key-codes
 from certain sysfs entries exported by Android Linux Kernel and these
 key-codes/events will be handled accordingly by the respective
 Framework/Application. But  I'm really not interested in how and what
 Userspace gets from Kernel.
 I'm interested in what values the Kernel or input subsystem will
 provide to such keys..
Do you have such keys in your device KEY_RIGHTUP?

  Not sure if this is what you are interested in but would have been
  better if you had described the problem in more detail.
 
 
  Does anybody have any idea about this?
 
 
  -
  Dharam
  ___
  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: Missing Key-codes from input.h file.

2012-06-26 Thread anish kumar
On Tue, 2012-06-26 at 09:43 +0200, Matthias Brugger wrote:
 On 06/26/2012 08:47 AM, Dharam Kumar wrote:
  On Tue, Jun 26, 2012 at 12:02 PM, anish kumar
  anish198519851...@gmail.com wrote:
  On Mon, 2012-06-25 at 23:24 +0530, Dharam Kumar wrote:
  On Mon, Jun 25, 2012 at 10:47 PM, anish kumar
  anish198519851...@gmail.com wrote:
  On Mon, 2012-06-25 at 18:52 +0530, Dharam Kumar wrote:
  Hi,
  I'm working on a module which is an input device and hence it needs to
  report certain key events.
 
  While browsing through the linux/input.h, I did find most of the
  key-codes(which I need to use)already defined but not all.
 
 
  Few of the KEY_xxx which i could not find are:
 
 
  a.) A Key for going to the previous channel.
  b.) Keys for Moving upper-right, lower-right, upper-left and
  lower-left direction(probably a GUI(grid of icons),where you move
  diagonally)
  d.) A key for Subpicture (this 'subpicture' key is deeined in
  CEA-931C).
  I think you are interested in the user space implementation of
  the keys reported by the input subsystem of kernel.
  Keys reported by the driver-input subsystem-reported to user space.
 
  I am not sure about linux way of reporting keys but in android the key
  is reported at a particular sysfs file and this sysfs file is read by
  eventhub.cpp.This file in turn is responsible for sending the events
  to particular application and it is the responsibility of the
  application how they interpret this keys.It can interpret events by
  moving diagonally a pointer/touch or going left/right.
 
  Thanks Anish ! To be clear, i just want to know the key-code
  which will be used by the Input Subsytem of the Kernel.
 
  For example, in linux/input.h file you will find a lot of #defines
  like the below,mapping different kind of key events to some key-code
  or value :
  #define KEY_UP 0xXYZ
  #define KEY_DOWN 0xABC and so on...
 
  Now, I'm looking for key events like:
  #define KEY_PREVIOUSCHANNEL   ???
  #define KEY_RIGHTUP ???
  #define kEY_RIGHTLEFT ???
  #define kEY_SUBPICTURE ??? and so on...
 
  You are probably right , that Userspace reads the key-events/key-codes
  from certain sysfs entries exported by Android Linux Kernel and these
  key-codes/events will be handled accordingly by the respective
  Framework/Application. But  I'm really not interested in how and what
  Userspace gets from Kernel.
  I'm interested in what values the Kernel or input subsystem will
  provide to such keys..
  Do you have such keys in your device KEY_RIGHTUP?
 
  Yes, my device is supposed to support such keys:
  RIGHTUP -- moves cursor upper-right direction.
  RIGHTDOWN --- moves cursor lower-right direction.
  and similar keys for upper-left and lower-left cursor direction.
  Sadly, I could not find any #define in input.h file for such key events.
 
  From your response I interpret that you have some kind of custom 
 key-pad, or anything similar which is not a standard keyboard.
 
 If there are no such defines in the Kernel, it's probably because no one 
 has had the need for them up to now.
 
 I think the implementation should be done as Anish described beforehand. 
 Anyway you can add some defines to your Kernel if this is a requirement 
and probably submit your first patch to the kernel but I am not clear
about the policy regarding adding new keys in the kernel.However sending
the patch would be better than speculating.
 for you.
 
 Regards,
 Matthias
 
  Not sure if this is what you are interested in but would have been
  better if you had described the problem in more detail.
 
 
  Does anybody have any idea about this?
 
 
  -
  Dharam
  ___
  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: Missing Key-codes from input.h file.

2012-06-25 Thread anish kumar
On Mon, 2012-06-25 at 18:52 +0530, Dharam Kumar wrote:
 Hi,
 I'm working on a module which is an input device and hence it needs to
 report certain key events.
 
 While browsing through the linux/input.h, I did find most of the
 key-codes(which I need to use)already defined but not all.
 
 
 Few of the KEY_xxx which i could not find are:
 
 
 a.) A Key for going to the previous channel.
 b.) Keys for Moving upper-right, lower-right, upper-left and
 lower-left direction(probably a GUI(grid of icons),where you move
 diagonally)
 d.) A key for Subpicture (this 'subpicture' key is deeined in
 CEA-931C).
I think you are interested in the user space implementation of 
the keys reported by the input subsystem of kernel.
Keys reported by the driver-input subsystem-reported to user space.

I am not sure about linux way of reporting keys but in android the key
is reported at a particular sysfs file and this sysfs file is read by
eventhub.cpp.This file in turn is responsible for sending the events
to particular application and it is the responsibility of the
application how they interpret this keys.It can interpret events by
moving diagonally a pointer/touch or going left/right.

Not sure if this is what you are interested in but would have been
better if you had described the problem in more detail.
 
 
 Does anybody have any idea about this?
 
 
 -
 Dharam
 ___
 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: Continuous Interrupt Problem

2012-06-16 Thread anish kumar
On Fri, 2012-06-15 at 03:22 -0700, Shaji Yusuf wrote:
 Is the issue resolved?
 
 
 This seems to be more of either a device that's buggy or some
 misunderstanding in understanding the device specs.
I checked with siddharth and understanding in device specs
was the problem.
 
 
 I had a similar issue with one of our devices. When I get an interrupt
 I would do some thing in the device (reading buffers writing some
 registers and stuff) that should reset the Interrupt pin to high state
 again. But the hardware had a bug that would not let the Interrupt pin
 reset, and once I return from the Interrupt it would strike again
 causing the system to freeze. 
 
 
 Thanks 
 
 Shaji Yusuf
 
 
 
 
 
 __
 From: siddharth saxena siddharthsaxena1...@gmail.com
 To: anish singh anish198519851...@gmail.com 
 Cc: Arun KS getaru...@gmail.com; Sarbojit Ganguly
 unixman.linux...@gmail.com; kernelnewbies@kernelnewbies.org 
 Sent: Thursday, June 14, 2012 2:35 PM
 Subject: Re: Continuous Interrupt Problem
 
 
 Initialized in Probe :
 
 if (device-irq) {
 ret = request_irq(device-irq, ts_int_handler,
 IRQF_TRIGGER_LOW, DRIVER_NAME, device);
 if (ret) {
 pr_err(unable to register touch irq.(%s)\r\n,
 device-input_dev-name);
 goto err_request_irq;
 }
 }
 
 
 
 The pin by default has to be initialized to Active Low.
 
 
 
 
 On Thu, Jun 14, 2012 at 2:24 PM, anish singh
 anish198519851...@gmail.com wrote:
 On Thu, Jun 14, 2012 at 2:11 PM, siddharth saxena
 siddharthsaxena1...@gmail.com wrote:
  Hi Arun
 
  I tried changing the flag to IRQF_TRIGGER_HIGH but then
 device is behaving
  abnormally(Hangs and is dead after some time).
  Flooding interrupts still observed. Problem not solved.
 
  I want to know, are we supposed to change interrupt pin
 status or it is done
  automatically when we return IRQ_HANDLED.
 
 why don't you paste the code for your probe routine where you
 are
 calling request_irq.
 Are you using threaded irq?It would be difficult to diagnose
 the
 problem without looking
 at your TSP manual and your code to find out the problem.
 
 
 
 
  On Thu, Jun 14, 2012 at 12:21 PM, Sarbojit Ganguly
  unixman.linux...@gmail.com wrote:
 
  Hi Arun,
 
  While I agree to your pointers but he is facing the problem
 of
  interrupt floods even before he touches.
  IMHO the culprit could be the flag.
 
  On 14 June 2012 12:01, Arun KS getaru...@gmail.com wrote:
   Hello Siddharth,
  
   On Thu, Jun 14, 2012 at 10:34 AM, siddharth saxena
   siddharthsaxena1...@gmail.com wrote:
   Hi all
  
   I need help with an issue.
   I have written a touch driver for a device and used the
 flag
   IRQF_TRIGGER_LOW to request irq.
   Now, when I boot the device, the touch interrupts are
 coming already
   without
   touching the screen.
   Continuous interrupts are occurring without any touch.
  
   Probably the default state of the gpio pin(which you
 configured as
   irq) is low. Check your HW schematic.
  
   TSC should have interrupt polarity(Active High/Low),
 which you have to
   choose depending on your schematic while initiallizing
 the TSC.
   Also different modes like assert interrupt when finger
 moving, when
   finger touch, or assert periodically.
  
   Hope these pointer will help you.
  
   Thanks,
   Arun
  
  
  
  
   --
   Regards
   Siddharth Saxena
  
  
   ___
   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
 
 
 
  --
  Regards,
  Sarbojit
 
 
 
 
  --
  Regards
  Siddharth Saxena
 
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
 
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
 
 
 
 
 -- 
 Regards
 Siddharth Saxena
 
 
 
 

request_firmware question

2012-02-07 Thread anish kumar
Hi,

Now I have switched to using request_firmware api
and after using firmware, memory is being released.
Does it save kernel memory compare to case when 
I am having a having a local static firmware buffer(very big)
from which I used to get the firmware and write it
to the chip?

As I know request_firmware api has several advantages
but what I want to know is the advantages related
to kernel memory footprint.

Thanks for the help.

ps:I asked the same question in #kernelnewbies IRC


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


Scull -unable to handle kernel paging request

2011-11-19 Thread anish kumar
Hello,

Testing the scullwuid produced attached crash logs.

Combination of read and write using dd and cat
caused this problem.

I don't exactly remember exactly what caused the problem
but combination of read and write did it.

Reproduction would not be possible but just want to know
why this happened as anyone looking into the code would
come to the conclusion that proper locking is in place.

Below is small part of the crash logs:

[21028.412827] BUG: unable to handle kernel paging request at 00300d04
[21028.412832] IP: [c035aef7] _copy_from_user+0x97/0x130
[21028.412839] *pde = 6fa0b067 
[21028.412842] Oops: 0003 [#1] SMP 

[21028.412933] Call Trace:
[21028.412940]  [f9f24d84] ? scull_write+0x193/0x204 [scull]
[21028.412946]  [c0218fc2] ? vfs_write+0xa2/0x190
[21028.412949]  [f9f24bf1] ? scull_write+0x0/0x204 [scull]
[21028.412953]  [c0219882] ? sys_write+0x42/0x70
[21028.412958]  [c05cadd4] ? syscall_call+0x7/0xb
[21028.412963]  [c05c] ? calibrate_delay_direct+0x5a/0xfb

Some of the below code is removed for fitting it into this mail:
ssize_t scull_write(struct file *filp, const char __user *buf, size_t count,
loff_t *f_pos)
{
if (down_interruptible(dev-sem))
return -ERESTARTSYS;
dptr = scull_follow(dev, item);
if (dptr == NULL)
goto out;
if (!dptr-data) {
dptr-data = kmalloc(qset * sizeof(char *), GFP_KERNEL);
if (!dptr-data)
goto out;
memset(dptr-data, 0, qset * sizeof(char *));
}
if (!dptr-data[s_pos]) {
dptr-data[s_pos] = kmalloc(quantum, GFP_KERNEL);
if (!dptr-data[s_pos])
goto out;
/* write only up to the end of this quantum */
if (count  quantum - q_pos) 
count = quantum - q_pos;

if (copy_from_user(dptr-data[s_pos]+q_pos, buf, count)) {
retval = -EFAULT;
goto out;
}


Used: https://github.com/martinezjavier/ldd3 
box:Ubuntu 10.10 |2.6.35-27-generic #48-Ubuntu SMP i686 GNU/Linux

--thanks


[21028.412827] BUG: unable to handle kernel paging request at 00300d04
[21028.412832] IP: [c035aef7] _copy_from_user+0x97/0x130
[21028.412839] *pde = 6fa0b067 
[21028.412842] Oops: 0003 [#1] SMP 
[21028.412845] last sysfs file: 
/sys/devices/pci:00/:00:1c.3/:09:00.0/local_cpus
[21028.412849] Modules linked in: scull rfcomm binfmt_misc sco bnep l2cap 
parport_pc ppdev dm_crypt snd_hda_codec_hdmi snd_hda_codec_idt snd_hda_intel 
snd_hda_codec snd_hwdep snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event 
snd_seq lib80211_crypt_tkip btusb snd_timer snd_seq_device uvcvideo bluetooth 
videodev dell_wmi wl(P) v4l1_compat psmouse serio_raw dell_wmi_aio 
sparse_keymap dell_laptop dcdbas snd lib80211 soundcore snd_page_alloc lp 
parport dm_raid45 xor i915 drm_kms_helper drm usb_storage intel_agp ahci 
agpgart i2c_algo_bit video output libahci r8169 mii
[21028.412890] 
[21028.412894] Pid: 8241, comm: dd Tainted: P2.6.35-27-generic 
#48-Ubuntu 01HXXJ/Inspiron N5050
[21028.412897] EIP: 0060:[c035aef7] EFLAGS: 00010216 CPU: 2
[21028.412900] EIP is at _copy_from_user+0x97/0x130
[21028.412902] EAX: 9f034959 EBX: 0200 ECX: 0200 EDX: 477efb2f
[21028.412905] ESI: 08e01000 EDI: 00300d04 EBP: c8b6bf1c ESP: c8b6bf10
[21028.412907]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[21028.412910] Process dd (pid: 8241, ti=c8b6a000 task=f71d2610 
task.ti=c8b6a000)
[21028.412912] Stack:
[21028.412913]  f9f26d00 0cc0 f9f26d14 c8b6bf64 f9f24d84 f9f2636f 022d 
02e0
[21028.412920] 0 0200 08b74600 0024 02e0 08b4 f247c2d8 
08e01000 0200
[21028.412926] 0 003d0900 0200 e677cc80 0200 08e01000 c8b6bf8c 
c0218fc2 c8b6bf98
[21028.412933] Call Trace:
[21028.412940]  [f9f24d84] ? scull_write+0x193/0x204 [scull]
[21028.412946]  [c0218fc2] ? vfs_write+0xa2/0x190
[21028.412949]  [f9f24bf1] ? scull_write+0x0/0x204 [scull]
[21028.412953]  [c0219882] ? sys_write+0x42/0x70
[21028.412958]  [c05cadd4] ? syscall_call+0x7/0xb
[21028.412963]  [c05c] ? calibrate_delay_direct+0x5a/0xfb
[21028.412965] Code: 8b 1c 24 8b 7c 24 08 89 ec 5d c3 90 89 f0 31 f8 85 05 80 
8e 81 c0 74 be 89 d9 8b 46 20 83 f9 43 76 04 8b 46 40 90 8b 06 8b 56 04 89 07 
89 57 04 8b 46 08 8b 56 0c 89 47 08 89 57 0c 8b 46 10 8b 
[21028.413001] EIP: [c035aef7] _copy_from_user+0x97/0x130 SS:ESP 0068:c8b6bf10
[21028.413005] CR2: 00300d04
[21028.413009] ---[ end trace 3bd8365f04ad063d ]---

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


Re: Getting Information from Multiple nodes

2011-11-16 Thread anish kumar
On Wed, 2011-11-16 at 18:00 +0530, Praveen kumar wrote:
 Hi All,
 I have a I2C chip driver,and there are two identical chips on
 two different i2c bus.
 I have registered the driver and initialized it and created two
 nodes /dev/chip_0 and /dev/chip_1
 
 If I open the node from user how will I make driver identify which
 device to access .ie in the ioctl.

So in your ioctl call you want to get the device structure right?
If yes then have a look at scull/main.c file in scull folder at below
location.
git://github.com/martinezjavier/ldd3.git

Basically you need to set private_data of filp at open time with device
information and get the private_data from filp in ioctl.
If you don't understand then just have a look at the file I mentioned.
 
 Am I clear ???
 
 Praveen
 
 
 ___
 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: Memory leak with dev_add_pack()

2011-01-23 Thread anish kumar
 Hi!

 On 11:40 Sun 23 Jan , Spiro Trikaliotis wrote:
 ...
 * On Sat, Jan 22, 2011 at 08:18:05AM +0100 Michael Blizek wrote:
 ...
  - Which user grows is /proc/slabinfo? (If this file is emply or does 
  not
exist, you may meed to recompile the kernel to use slab instead of
sl[b-z]b)

 Thank you for the pointer, it might help.

 The objects which have changed the most on a mildly loaded network are:

 25000 buffer_head
  5000 dentry
  5000 ext3_inode_cache
  5000 size-64

 The number if the number of more active object after approx. 20h of
 letting it run on the mildly loaded network.

 Note that the ext3_inode_cache might have grown because I was regularly
 writing a new log file from slabinfo (slabinfo --once  slabinfo.`date
 +...`)

 Thus, I would expect I am leaking buffer_head.

 The funny point is that buffer_head belongs to the filesystem subsystem. 
 What
 file systems are you using? Could it be that your code just triggers the
 memory leak, because data is logged to disk, e.g. to /var/log/kern.log ?
I did small experiment with your code.I removed all your logs which were 
getting
logged in kernel buffers(kern.log).With this change i checked the meminfo 
and found that
the memory leaking is almost same as compared to normal case(with no change 
in your code).


 I have tried your program on my virtual machine (2.6.28) and could see any
 leak, but maybe data is leaked very slowly...
i confirm that data is leaking very slowly (below is the output i got on my 
ubuntu machine
with removed logs from your code).

$date
Sun Jan 23 19:13:47 RET 2011

$ head -n5 /proc/meminfo
MemTotal:1018172 kB
MemFree:  373708 kB
Buffers:   32232 kB
Cached:   296004 kB
SwapCached:0 kB

$ date
Sun Jan 23 19:15:03 RET 2011

$ head -n5 /proc/meminfo
MemTotal:1018172 kB
MemFree:  373584 kB
Buffers:   32248 kB
Cached:   296004 kB
SwapCached:0 kB

With logs enabled in your code i can see marginal increase in leaking 
memory.
I can defintely see the memory leaking with your ko and will investigate 
further as to the reason.
Hopefully kmemleak will lead us somewhere.


 -Michi
 -- 
 programing a layer 3+4 network protocol for mesh networks
 see http://michaelblizek.twilightparadox.com


 ___
 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