facing a problem with request _irq qnd enable_irq

2009-09-30 Thread Harinderjit Singh Sandhu
---
int ret;
printk("initializing module\n");
//free_irq(7,NULL);
i = register_chrdev (SKELETON_MAJOR, SKELETON_NAME, &skeleton_fops);
if (i != 0) return - EIO;
//disable_irq(7);
ret = request_irq (7, interrupt_handler,0,SKELETON_NAME ,NULL);
printk("ret=%d\n",ret);
//enable_irq(7);
if(ret>=0){
enable_irq(7);
//outb_p(0x10, BASEPORT + 2);
}
else
{
printk("Not Working \n");
}
//printk("Generating interrupt \n");

outb(0, BASEPORT);
outb(255, BASEPORT);
outb(0, BASEPORT);
printk("Interrupt generated. You should see the handler-message\n");

-
when i insmod the module of which this is apart.


i get the following output

[ 1291.259646] initializing module
[ 1291.259672] ret=0
[ 1291.259679] [ cut here ]
[ 1291.259682] WARNING: at
/build/buildd/linux-2.6.28/kernel/irq/manage.c:225 __enable_irq+0x30/0x70()
[ 1291.259685] Unbalanced enable for IRQ 7
[ 1291.259687] Modules linked in: skeleton(+) hid_bright usbhid rfkill_input
i915 drm binfmt_misc ppdev bridge stp bnep lp parport arc4 ecb snd_hda_intel
snd_pcm_oss snd_mixer_oss snd_pcm pcmcia snd_seq_dummy b43 snd_seq_oss
snd_seq_midi snd_rawmidi mac80211 snd_seq_midi_event cfg80211 iTCO_wdt
iTCO_vendor_support snd_seq snd_timer snd_seq_device yenta_socket
rsrc_nonstatic ricoh_mmc sdhci_pci sdhci snd pcmcia_core led_class intel_agp
agpgart soundcore snd_page_alloc pcspkr input_polldev serio_raw uvcvideo
compat_ioctl32 videodev v4l1_compat video output ohci1394 ieee1394 8139too
8139cp mii ssb fbcon tileblit font bitblit softcursor
[ 1291.259751] Pid: 4400, comm: insmod Not tainted 2.6.28-11-generic
#42-Ubuntu
[ 1291.259754] Call Trace:
[ 1291.259760]  [] warn_slowpath+0x60/0x80
[ 1291.259765]  [] ? register_handler_proc+0x119/0x130
[ 1291.259773]  [] ? vsnprintf+0x378/0x5c0
[ 1291.259778]  [] ? release_console_sem+0x1c9/0x200
[ 1291.259782]  [] __enable_irq+0x30/0x70
[ 1291.259786]  [] enable_irq+0x3c/0x60
[ 1291.259790]  [] ? skeleton_init_module+0x0/0x96 [skeleton]
[ 1291.259795]  [] skeleton_init_module+0x78/0x96 [skeleton]
[ 1291.259802]  [] _stext+0x2e/0x170
[ 1291.259807]  [] ? sysfs_addrm_finish+0x15/0xf0
[ 1291.259811]  [] ? sysfs_add_one+0x13/0x50
[ 1291.259814]  [] ? sysfs_addrm_start+0x3f/0xa0
[ 1291.259820]  [] ? __vunmap+0x9c/0xe0
[ 1291.259823]  [] ? __vunmap+0x9c/0xe0
[ 1291.259832]  [] ? vfree+0x21/0x30
[ 1291.259837]  [] ? load_module+0x103a/0x1040
[ 1291.259848]  [] sys_init_module+0x88/0x1b0
[ 1291.259853]  [] ? sys_close+0x7a/0xc0
[ 1291.259857]  [] sysenter_do_call+0x12/0x2f
[ 1291.259865]  [] ? relay_hotcpu_callback+0x6d/0xbd
[ 1291.259868] ---[ end trace cddcbfa519faa2fe ]---
[ 1291.259870] Interrupt generated. You should see the handler-message

and the message in the handler doesnt appear.
i am unable to get what is the problem and how can this be solved.

please help me out


-- 
-
Harinderjit Singh


Re: development/hacking environment reg.

2009-09-30 Thread vinit dhatrak
On Wed, Sep 30, 2009 at 8:57 PM, Anand Arumugam  wrote:
> Thanks a bunch for your detailed reply. It really gave me some idea. Even if
> its not something related to the nuts and bolts of the target hardware, how
> does one go about test the fix in other architectures say
> SPARC/MIPS/ARM/SH*??? Can that be achieved using QEMU or can this be done
> using VirtualBox itself?
>
> Cheers,
> -Anand.

Yes, its very much possible to emulate these archs with QEMU, I use it
for arm processor related work. Or another very nice option is
Marvell's SheevaPlug. It already comes with development kit with it.
Explore it here, http://en.wikipedia.org/wiki/SheevaPlug

-Vinit


> On Wed, Sep 30, 2009 at 1:15 AM, Michal Ludvig  wrote:
>>
>> Anand Arumugam wrote:
>>
>> > what is the
>> > normal environment that is used by most of the kernel hackers and
>> > developers? do they have a dedicated pc for this work and have a
>> > separate pc for other uses? or just create a partition in the hard drive
>> > and use this partition for kernel related development?
>>
>> I guess it really depends on what sort of kernel development you do. If
>> it's something that doesn't need access to the hardware, for instance a
>> new filesystem, you can get away with a virtual machine in VirtualBox or
>> KVM or Xen. On the other hand if you need access to the metal, when
>> writing device drivers for example, you're better off having a dedicated
>> machine since you are likely to experience frequent reboots.
>>
>> To give an example - I work, edit code, browse documentation, etc on my
>> workstation. That one hardly ever gets rebooted. The code I write for a
>> given project is in a NFS-exported dir and that dir is mounted on a one
>> of my test systems where I compile and test it. If it works - good, if
>> it breaks - never mind. All I need is to reboot or powercycle the test
>> machine and in the mean time, on my workstation, fix the problem and get
>> ready for another test. That means that my work environment (open files
>> in editor, open documentation PDFs, etc) is not disturbed if the test
>> system crashes. And it also means that all my code is in one place, not
>> scattered among many different systems.
>>
>> I don't need a keyboard and screen for each system - all of them are
>> networked and most of the time I ssh to them from the comfort of my
>> workstation (using a dedicated password-less ssh key to make it even
>> simpler). Actually some of my embedded boards only have a serial console
>> and no network, but that's a whole different story.
>>
>> My test systems are often low-spec machines that you can buy 2nd hand
>> for a few bucks from ebay or similar sites. Not a big investment for the
>> comfort you gain from having a dedicated test system.
>>
>> I'm sure other developers prefer different setups. This is merely a way
>> that works for me.
>>
>> HTH,
>>
>> Michal
>>
>>
>>
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Threaded Network Device Interrupts

2009-09-30 Thread Peter Teoh
Look at this:

http://linuxplumbersconf.org/2009/schedule/

and in particular the following - Steven Rostedt is talking about
replacing softirq with threaded interrupt.   Amazing innovations!!!

http://linuxplumbersconf.org/ocw/proposals/53

Threaded Network Device Interrupts
*
Networking
Talk
lpc2009-0053
Scheduled: Wednesday, September 23, 2009 from 11:30am – 12:15pm in Salon E
Excerpt

Increasing networking performance by using threaded interrupts for the
network devices.
Description

Several in the networking community are skeptical on using interrupt
threads for the network devices. I will argue that not only does it
make the solution more simplex, but also increases network throughput.
With the introduction of the threaded interrupt infrastructure into
2.6.30, the path has been paved to allow networking devices to take
advantage of this. The threaded interrupt may then do all the work
needed to hand off the packet to the thread code without all the
complexities needed in locking while using the softirqs.

I will present my ideas and even a working proof of concept, to
convince those that still have doubts that the future of the network
and Linux in general, is a kernel free from softirqs.



-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



after a couple weeks off, new kernel newbie column!

2009-09-30 Thread Robert P. J. Day

  initrd and initramfs:  http://cli.gs/18nDd7

written in great haste, so feel free to leave comments and ask
questions.

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Dear friend!

2009-09-30 Thread Ray Kinsella
Hi,
I bought a TV last week from a website:www.hkeles.com.  I have
received the product. The quality is very good. They also sell
phones,motor,psp and so on. Because of the financial crisis, their
products are very cheap. by the way, they only sell new and original
products .If you need these products, you can have a look . I think
you will get many benefits.
Greetings!

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Char device. poll() function question.

2009-09-30 Thread Usman S. Ansari
> I want to use poll() functionality (to properly handle select()
> and poll() syscalls) in my char-device driver. The code for my 
> kernel-side poll() function is (a little bit simplified):
> 
> unsigned int my_poll(struct file *filp, struct poll_table_struct 
> *wait)
> {
>        unsigned int mask=0;
>        unsigned long flags;
>
>        poll_wait(filp, my_wait_queue, wait);
>
>        if ( any_data_available > 0)
>                mask |= POLLIN | POLLRDNORM;
>
>        return mask;
>}

You have to make sure your process is sleeping on my_wait_queue. Linux kernel 
will wake up processes sleeping on my_wait_queue.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: max throughput achievable with outb()

2009-09-30 Thread Peter Teoh
On Wed, Sep 30, 2009 at 6:01 AM, Michal Ludvig  wrote:
> Peter Teoh wrote:
>> On Wed, Sep 30, 2009 at 11:47 AM, Michal Ludvig  wrote:
>>> Hi all,
>>>
>>> I've got a digital IO card hanging off an ISA bus in PC/104 system. I'm
>>> pushing data packets to it, usually 16-32 bytes per transfer, 100x per
>>> second.
>>>
>>> Apparently ISA bus clock is supposed to run at 8MHz and I expected to
>>> achieve somewhat close-to-that performance with my driver. To test the
>>> throughput I've got a simple loop in my kernel driver:
>>>
>>>    uint8_t data = 0;
>>>    while(loops--) {
>>>        outb(data, iobase);
>>>        data = ~data;
>>>    }
>>>
>>> A frequency probe reveals that the port status is changing at roughly
>>> 250kHz (and other timing checks confirm it), which is far less than the
>>> expected 8MHz.
>>>
>>> I've got two questions:
>>> 1) Can I speed it up somehow?
>>
>> generally, port i/o programming is always slower than mmio, why don't
>> u consider that option?
>
> Good idea. However ... does mmio need support on the isa-card side?
>
> How do I map ioports 0x300-0x30B to some address accessible by readb() /
> writeb()?
>
> I can't work out the relation between isa address space (0xA to
> 0x10) and io ports (eg mine 0x300 to 0x30B range). What do I pass to
> ioremap() [?] to get the ports accessible by readb/writeb?


this knowledge is from datasheet.   but this is beyond my level of
understandingeg for ICH7 manual:

5.15

   ) . 179
5.16 IDE Controller (D31:F1)
...
183
 5.16.1 PIO Transfers
...
183
5.16.1.1 PIO IDE Timing Modes
. 184
5.16.1.2 IORDY
Masking...
184
5.16.1.3 PIO 32-Bit IDE Data Port Accesses
 184
5.16.1.4 PIO IDE Data Port Prefetching and Posting
. 185

There is some info on PIO, and then throughout many other MMIO stuff:


00
5.19 USB UHCI Host Controllers (D29:F0, F1, F2, and F3)
 200
 5.19.1 Data Structures in Main Memory
. 200
 5.19.2 Data Transfers to/from Main Memory
... 200
 5.19.3 Data Encoding and Bit Stuffing
... 200
 5.19.4 Bus
Protocol.
200
5.19.4.1 Bit
Ordering
200
5.19.4.2 SYNC Field
.
201
5.19.4.3 Packet Field
Formats
201
5.19.4.4 Address
Fields.
201
5.19.4.5 Frame Number Field
 201
5.19.4.6 Data Field
..
201
5.19.4.7 Cyclic Redundancy Check (CRC)
 201
 5.19.5 Packet
Formats.
201
 5.19.6 USB Interrupts
.
201
5.19.6.1 Transaction-Based Interrupts
 202
5.19.6.2 Non-Transaction Based Interrupts
.. 203
 5.19.7 USB Power Management

204
 5.19.8 USB Legacy Keyboard Operation
. 204
 USB EHCI Host Controller
(D29:F7)
207
 5.20.1 EHC Initialization
..
207
5.20.1.1 BIOS Initialization
...
207
5.20.1.2 Driver Initialization
.. 207
5.20.1.3 EHC
Resets.
208
 5.20.2 Data Structures in Main Memory
. 208
 5.20.3 USB 2.0 Enhanced Host Con

Re: max throughput achievable with outb()

2009-09-30 Thread Peter Teoh
n Wed, Sep 30, 2009 at 3:26 AM, Thomas Petazzoni
 wrote:
> Le Wed, 30 Sep 2009 16:47:33 +1300,
> Michal Ludvig  a écrit :
>
>> I've got two questions:
>> 1) Can I speed it up somehow?
>> 2) Apparently it's quite a lot of time between calling outb() and its
>> return. Can the kernel do something else in the meantime, like
>> scheduling another process or handling interrupts, or is it blocked
>> waiting for the outb() return? I'm on a uniprocessor x86 system.
>
> You can read the implementation of outb() for x86
> in /home/thomas/local/linuxdev/arch/x86/include/asm/io_32.h. Unless you
> use outb_p() (which introduces a pause after the write), outb() is only
> a static inline function that does the "outb" CPU instruction. No more,
> no less.
>
> If you want to be 100%, for testing purposes, you can hand-code the
> outb() using an asm("") statement. But I don't think it'll make any
> difference.
>
> You can also make an accurate measurement of the instruction duration
> using the TSC, to get the number of cycles spent during the execution
> of the instruction.
>
> Finally, my hardware knowledge is a bit limited, but I'm not sure that
> a 8 Mhz bus necessarly means that you can do 8 millions outb() per
> second through this bus. One outb() probably requires several (if not
> many) clock ticks.

look at the timing diagram, and u can see that one outb() usually have
to spread across many cycles, (1cycle being the smallest clock tick) -
this is to enable data on the bus to be reliably received before the
turning off the signal.

anyway, so many other delays can come in, so just the timing diagram
estimation is likely to be far from accurate.

>

> Sincerly,
>
> Thomas
> --
> Thomas Petazzoni, Free Electrons
> Kernel, drivers and embedded Linux development,
> consulting, training and support.
> http://free-electrons.com
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Char device. poll() function question.

2009-09-30 Thread Denis Borisevich
2009/9/30 Chetan Nanda :
>
>
> On Wed, Sep 30, 2009 at 6:38 PM, Denis Borisevich 
> wrote:
>>
>> Hi!
>> I want to use poll() functionality (to properly handle select() and
>> poll() syscalls) in my char-device driver. The code for my kernel-side
>> poll() function is (a little bit simplified):
>>
>> unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
>> {
>>        unsigned int mask=0;
>>        unsigned long flags;
>>
>>        poll_wait(filp, my_wait_queue, wait);
>>
>>        if ( any_data_available > 0)
>>                mask |= POLLIN | POLLRDNORM;
>>
>>        return mask;
>> }
>>
>> Where "my_wait_queue" is of "wait_queue_head_t" type,
>> "any_data_available" if the flag which tells if any data is available
>> within internal buffer.
>>
> When you are setting 'any_data_available' variable to some positive values
> at the same place you have to wakeup process that is waiting in wait-queue.
> May be this part is missing in your current code and because of that select
> is not retuning before timeout.
Thank you for the answer. I got the point. I used this approach when I
was implementing read() function in this driver. But in that case I've
put the process to sleep manually by wait_event() call. Why do we need
this poll_wait() function if we can use wait_event()? I don't see any
conveniences which it could give. Or do I miss something?
>>
>> When I load this driver and start user-space application wich calls
>> select() with 5 seconds timeout the select() returns after waiting
>> this timeout no matter when the data comes into the port (1,2,3
>> seconds). The return value is positive when the data available and 0
>> when no data comes, as it should be. The question is why select()
>> waits for the timeout even when data is available?
>>
>> --
>> Denis
>>
> Thanks,
> Chetan Nanda

--
Denis

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Char device. poll() function question.

2009-09-30 Thread Daniel Baluta
On Wed, Sep 30, 2009 at 7:24 PM, Chetan Nanda  wrote:
>
>
> On Wed, Sep 30, 2009 at 6:38 PM, Denis Borisevich 
> wrote:
>>
>> Hi!
>> I want to use poll() functionality (to properly handle select() and
>> poll() syscalls) in my char-device driver. The code for my kernel-side
>> poll() function is (a little bit simplified):
>>
>> unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
>> {
>>        unsigned int mask=0;
>>        unsigned long flags;
>>
>>        poll_wait(filp, my_wait_queue, wait);
>>
>>        if ( any_data_available > 0)
>>                mask |= POLLIN | POLLRDNORM;
>>
>>        return mask;
>> }
>>
>> Where "my_wait_queue" is of "wait_queue_head_t" type,
>> "any_data_available" if the flag which tells if any data is available
>> within internal buffer.
>>
> When you are setting 'any_data_available' variable to some positive values
> at the same place you have to wakeup process that is waiting in wait-queue.
> May be this part is missing in your current code and because of that select
> is not retuning before timeout.

This is not true. You only have to set "data_available" in mask and
return it. An upper
layer will take care about waking up the process that is waiting in wait-queue.

>
>
>>
>> When I load this driver and start user-space application wich calls
>> select() with 5 seconds timeout the select() returns after waiting
>> this timeout no matter when the data comes into the port (1,2,3
>> seconds). The return value is positive when the data available and 0
>> when no data comes, as it should be. The question is why select()
>> waits for the timeout even when data is available?
What about select without a timeout? Does the call ever return?

Daniel.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: max throughput achievable with outb()

2009-09-30 Thread Peter Teoh
On Wed, Sep 30, 2009 at 3:18 AM, Thomas Petazzoni
 wrote:
> Le Wed, 30 Sep 2009 13:50:22 +0800,
> Peter Teoh  a écrit :
>
>> generally, port i/o programming is always slower than mmio, why don't
>> u consider that option?
>
> Well, it's rarely an option. Either the device is programmed through
> PIO *or* through MMIO. And I suspect that most ISA devices can only be
> programmed through PIO.
>
> Thomas
> --

I search all the drivers under ide, char, and several other
directories, and almost all the drivers which used ISA port I/O always
have a corresponding memory mapped I/O.   Perhaps u know of any
drivers that used only port I/O but not memory mapped I/O?

But the authoritative answer comes from Intel manual:

"Implementing Industry Standard Architecture (ISA) with Intel®Express Chipsets"

http://www.intel.com/Assets/PDF/whitepaper/318244.pdf

And within it says:

"The ISA protocol allows for memory-mapped transactions to components placed on
the bus. In order to support these transactions it is, therefore,
necessary to support
memory-mapped transaction on the LPC bus.
The LPC specification specifies that such transactions are supported
on the LPC bus.
Indeed, on all I/O Controller Hubs up to and including ICH5 support these
transactions. From ICH6 onwards, however, support for these
transactions has been
removed. As a result, it is not possible to support ISA memory mapped
transactions
on an Intel® Express chipset."

well.I really cannot fully understand these statement.what is
the difference between LPC DMA and ISA DMA?   (both effectively should
offer MMIO right?)

but in the ICH7 manual (Intel® I/O Controller Hub 7 (ICH7) Family Datasheet):

http://www.intel.com/Assets/PDF/datasheet/313053.pdf

The ICH7 supports LPC DMA (Desktop and Mobile Only), which is similar
to ISA DMA,
through the ICH7’s DMA controller. LPC DMA is handled through the use
of the LDRQ#
lines from peripherals and special encoding on LAD[3:0] from the host. Single,
Demand, Verify, and Increment modes are supported on the LPC
interface. Channels 0–
3 are 8-bit channels. Channels 5–7 are 16-bit channels. Channel 4 is
reserved as a
generic bus master request.

and in another part of document:

Each DMA channel is hardwired to the compatible settings for DMA device size:
channels [3:0] are hardwired to 8-bit, count-by-bytes transfers, and
channels [7:5] are
hardwired to 16-bit, count-by-words (address shifted) transfers.
ICH7 provides 24-bit addressing in compliance with the ISA-Compatible
specification.
Each channel includes a 16-bit ISA-Compatible Current Register which
holds the 16
least-significant bits of the 24-bit address, an ISA-Compatible Page
Register which
contains the eight next most significant bits of address.

So, since ICH7 is a modern chipset (my 1yr computer at least), ISA
compatibility is always provided.  Which means port I/O + MMIO is
always available?

-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Char device. poll() function question.

2009-09-30 Thread Denis Borisevich
2009/9/30 Daniel Baluta :
> On Wed, Sep 30, 2009 at 7:24 PM, Chetan Nanda  wrote:
>>
>>
>> On Wed, Sep 30, 2009 at 6:38 PM, Denis Borisevich 
>> wrote:
>>>
>>> Hi!
>>> I want to use poll() functionality (to properly handle select() and
>>> poll() syscalls) in my char-device driver. The code for my kernel-side
>>> poll() function is (a little bit simplified):
>>>
>>> unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
>>> {
>>>        unsigned int mask=0;
>>>        unsigned long flags;
>>>
>>>        poll_wait(filp, my_wait_queue, wait);
>>>
>>>        if ( any_data_available > 0)
>>>                mask |= POLLIN | POLLRDNORM;
>>>
>>>        return mask;
>>> }
>>>
>>> Where "my_wait_queue" is of "wait_queue_head_t" type,
>>> "any_data_available" if the flag which tells if any data is available
>>> within internal buffer.
>>>
>> When you are setting 'any_data_available' variable to some positive values
>> at the same place you have to wakeup process that is waiting in wait-queue.
>> May be this part is missing in your current code and because of that select
>> is not retuning before timeout.
>
> This is not true. You only have to set "data_available" in mask and
> return it. An upper
> layer will take care about waking up the process that is waiting in 
> wait-queue.
>
>>
>>
>>>
>>> When I load this driver and start user-space application wich calls
>>> select() with 5 seconds timeout the select() returns after waiting
>>> this timeout no matter when the data comes into the port (1,2,3
>>> seconds). The return value is positive when the data available and 0
>>> when no data comes, as it should be. The question is why select()
>>> waits for the timeout even when data is available?
> What about select without a timeout? Does the call ever return?

With timeout set to NULL the call never returns.

> Daniel.
>

--
Denis

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Char device. poll() function question.

2009-09-30 Thread Chetan Nanda
On Wed, Sep 30, 2009 at 6:38 PM, Denis Borisevich wrote:

> Hi!
> I want to use poll() functionality (to properly handle select() and
> poll() syscalls) in my char-device driver. The code for my kernel-side
> poll() function is (a little bit simplified):
>
> unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
> {
>unsigned int mask=0;
>unsigned long flags;
>
>poll_wait(filp, my_wait_queue, wait);
>
>if ( any_data_available > 0)
>mask |= POLLIN | POLLRDNORM;
>
>return mask;
> }
>
> Where "my_wait_queue" is of "wait_queue_head_t" type,
> "any_data_available" if the flag which tells if any data is available
> within internal buffer.
>
> When you are setting 'any_data_available' variable to some positive values
at the same place you have to wakeup process that is waiting in wait-queue.
May be this part is missing in your current code and because of that select
is not retuning before timeout.



> When I load this driver and start user-space application wich calls
> select() with 5 seconds timeout the select() returns after waiting
> this timeout no matter when the data comes into the port (1,2,3
> seconds). The return value is positive when the data available and 0
> when no data comes, as it should be. The question is why select()
> waits for the timeout even when data is available?
>
> --
> Denis
>
> Thanks,
Chetan Nanda

> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>


Re: development/hacking environment reg.

2009-09-30 Thread Anand Arumugam
Thanks a bunch for your detailed reply. It really gave me some idea. Even if
its not something related to the nuts and bolts of the target hardware, how
does one go about test the fix in other architectures say
SPARC/MIPS/ARM/SH*??? Can that be achieved using QEMU or can this be done
using VirtualBox itself?

Cheers,
-Anand.

On Wed, Sep 30, 2009 at 1:15 AM, Michal Ludvig  wrote:

> Anand Arumugam wrote:
>
> > what is the
> > normal environment that is used by most of the kernel hackers and
> > developers? do they have a dedicated pc for this work and have a
> > separate pc for other uses? or just create a partition in the hard drive
> > and use this partition for kernel related development?
>
> I guess it really depends on what sort of kernel development you do. If
> it's something that doesn't need access to the hardware, for instance a
> new filesystem, you can get away with a virtual machine in VirtualBox or
> KVM or Xen. On the other hand if you need access to the metal, when
> writing device drivers for example, you're better off having a dedicated
> machine since you are likely to experience frequent reboots.
>
> To give an example - I work, edit code, browse documentation, etc on my
> workstation. That one hardly ever gets rebooted. The code I write for a
> given project is in a NFS-exported dir and that dir is mounted on a one
> of my test systems where I compile and test it. If it works - good, if
> it breaks - never mind. All I need is to reboot or powercycle the test
> machine and in the mean time, on my workstation, fix the problem and get
> ready for another test. That means that my work environment (open files
> in editor, open documentation PDFs, etc) is not disturbed if the test
> system crashes. And it also means that all my code is in one place, not
> scattered among many different systems.
>
> I don't need a keyboard and screen for each system - all of them are
> networked and most of the time I ssh to them from the comfort of my
> workstation (using a dedicated password-less ssh key to make it even
> simpler). Actually some of my embedded boards only have a serial console
> and no network, but that's a whole different story.
>
> My test systems are often low-spec machines that you can buy 2nd hand
> for a few bucks from ebay or similar sites. Not a big investment for the
> comfort you gain from having a dedicated test system.
>
> I'm sure other developers prefer different setups. This is merely a way
> that works for me.
>
> HTH,
>
> Michal
>
>
>
>


Char device. poll() function question.

2009-09-30 Thread Denis Borisevich
Hi!
I want to use poll() functionality (to properly handle select() and
poll() syscalls) in my char-device driver. The code for my kernel-side
poll() function is (a little bit simplified):

unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
{
unsigned int mask=0;
unsigned long flags;

poll_wait(filp, my_wait_queue, wait);

if ( any_data_available > 0)
mask |= POLLIN | POLLRDNORM;

return mask;
}

Where "my_wait_queue" is of "wait_queue_head_t" type,
"any_data_available" if the flag which tells if any data is available
within internal buffer.

When I load this driver and start user-space application wich calls
select() with 5 seconds timeout the select() returns after waiting
this timeout no matter when the data comes into the port (1,2,3
seconds). The return value is positive when the data available and 0
when no data comes, as it should be. The question is why select()
waits for the timeout even when data is available?

--
Denis

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to build DocBook in Linux kernel?

2009-09-30 Thread chaitanya
2009/9/30 Manish Katiyar 

> On Wed, Sep 30, 2009 at 4:13 PM, NAHieu  wrote:
> > Hi,
> >
> > There are a lot of DocBook files under Documentation/DocBook/. I tried
> > to build them with "make xmldocs", but that only produces .xml file,
> > which cannot be viewed in Firefox.
>
> make pdfdocs 
>
> "make htlmldocs"  if you want it in firefox i guess.
you should get an index.html file


>  >
> > So how to view those resulted .xml file, or if I want to buid those
> > DocBook to .pdf files, what should I do?
> >
> > Thanks,
> > Hieu
> >
> > --
> > To unsubscribe from this list: send an email with
> > "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> > Please read the FAQ at http://kernelnewbies.org/FAQ
> >
> >
>
>
>
> --
> Thanks -
> Manish
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>


-- 
Regards
Chaitanya
+60146458258


CONFIG_ASYNC_XOR not visible through menuconfig/gconfig

2009-09-30 Thread Vikash Kumar
Hello everyone,

I am using linux kernel version 2.6.26.8 and I need to use async_XXX
(async_xor, async_memcpy etc) API. So I need to build the ASYNC_XXX modules
with my kernel. But I can't see the config options related to ASYNC_XOR or
ASYNC_MEMCPY etc through menuconfig or gconfig under Security Options.

In gconfig if I select show all options I can see these config options under
"Security Options" but I can't select them.

I am not sure if this is because of some missing prerequisite CONFIG options
in my config file or something else.
I could directly add these options in the config file manually but I wanted
to be sure it won't have any side effects.

I am posting the Security Options portion of my working .config file here,
as in my last two posts I had attached my .config file (size 33k) but then
my posts were not delivered. After waiting for about a day I decided to try
one more post without attachment. So, this is the third time I am trying to
post the same thing. I apologize if it is recieved multiple times.


#
# Security options
#
# CONFIG_KEYS is not set
# CONFIG_SECURITY is not set
# CONFIG_SECURITY_FILE_CAPABILITIES is not set
CONFIG_CRYPTO=y


Thanking you in advance.


Regards,
Vikash Kumar
http://VikashKumar.com/


Re: How to build DocBook in Linux kernel?

2009-09-30 Thread Manish Katiyar
On Wed, Sep 30, 2009 at 4:13 PM, NAHieu  wrote:
> Hi,
>
> There are a lot of DocBook files under Documentation/DocBook/. I tried
> to build them with "make xmldocs", but that only produces .xml file,
> which cannot be viewed in Firefox.

make pdfdocs 

>
> So how to view those resulted .xml file, or if I want to buid those
> DocBook to .pdf files, what should I do?
>
> Thanks,
> Hieu
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Thanks -
Manish

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



How to build DocBook in Linux kernel?

2009-09-30 Thread NAHieu
Hi,

There are a lot of DocBook files under Documentation/DocBook/. I tried
to build them with "make xmldocs", but that only produces .xml file,
which cannot be viewed in Firefox.

So how to view those resulted .xml file, or if I want to buid those
DocBook to .pdf files, what should I do?

Thanks,
Hieu

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



contributing to linux kernel.

2009-09-30 Thread Pete

Hello list,

I am interested towards contributing towards kernel in the form of
patches bug fixes or small enhancements to start off. I have completed
studying some of the pre-requisite books on kernel programming (RL,
UTLK3, some parts of LDD3 - as suggested on other newbie threads) and
also followed some of the threads which has enabled me to learn a lot
more. 

Although am interested in contributing towards the kernel security or
file systems project related to the kernel, I would take up other things
to start of with. Please suggest what are the possible on going projects
where I could contribute or start looking into.

I was mostly thinking of LSM, SELinux or btrfs, Ext4 ? Can anyone
provide any pointers or tutorials or the project page where I could do
some additional reading to get some hands on ?

Additionally couple of questions which remain unanswered in my mind are
related to the kernel bugs. How do we look actually file bugs into when
someone finds a bug should we notify the community in advance ? Does the
bug get reviewed by the maintainers before its assigned? Does it get
assigned to someone or can we pick up any open bug of our interest and
try start fixing it ? Should we inform the maintainers or the sub-group
as to who would be working on this? 

I apologize of having missed out any reading as I have asked too a many
number of questions.  Appreciate any suggestions from the list members. 

Thanks in advance

 

   


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: max throughput achievable with outb()

2009-09-30 Thread Michal Ludvig
Peter Teoh wrote:
> On Wed, Sep 30, 2009 at 11:47 AM, Michal Ludvig  wrote:
>> Hi all,
>>
>> I've got a digital IO card hanging off an ISA bus in PC/104 system. I'm
>> pushing data packets to it, usually 16-32 bytes per transfer, 100x per
>> second.
>>
>> Apparently ISA bus clock is supposed to run at 8MHz and I expected to
>> achieve somewhat close-to-that performance with my driver. To test the
>> throughput I've got a simple loop in my kernel driver:
>>
>>uint8_t data = 0;
>>while(loops--) {
>>outb(data, iobase);
>>data = ~data;
>>}
>>
>> A frequency probe reveals that the port status is changing at roughly
>> 250kHz (and other timing checks confirm it), which is far less than the
>> expected 8MHz.
>>
>> I've got two questions:
>> 1) Can I speed it up somehow?
> 
> generally, port i/o programming is always slower than mmio, why don't
> u consider that option?

Good idea. However ... does mmio need support on the isa-card side?

How do I map ioports 0x300-0x30B to some address accessible by readb() /
writeb()?

I can't work out the relation between isa address space (0xA to
0x10) and io ports (eg mine 0x300 to 0x30B range). What do I pass to
ioremap() [?] to get the ports accessible by readb/writeb?

Michal





--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: KHz representation in Linux kernel

2009-09-30 Thread Shankar Ganesh
>
>
>>
> The 32768 Hz is a special value used for Real Time Clocks (RTCs).
> Check it out here:
> http://en.wikipedia.org/wiki/Quartz_clock#Mechanism
>
>
Thanks a lot .

Regards,
Shankar


Re: KHz representation in Linux kernel

2009-09-30 Thread Deven T
On Wed, Sep 30, 2009 at 2:03 PM, Shankar Ganesh wrote:

>
> On Wed, Sep 30, 2009 at 4:06 AM, Pei Lin  wrote:
>
>> i just think you query about why the "stupid computer" only can
>> recognize '0' and '1'. ^_^  :)
>>
>>
> But still 32000 can be represented as 0 & 1 :( . This will have shift while
> executing delay loop  or any calcs.
> 32KHz Timer will have only 32000 ticks per second , not 32768 ticks
>
>
The 32768 Hz is a special value used for Real Time Clocks (RTCs).
Check it out here:
http://en.wikipedia.org/wiki/Quartz_clock#Mechanism

-Deven


Re: KHz representation in Linux kernel

2009-09-30 Thread Shankar Ganesh
On Wed, Sep 30, 2009 at 4:06 AM, Pei Lin  wrote:

> i just think you query about why the "stupid computer" only can
> recognize '0' and '1'. ^_^  :)
>
>
But still 32000 can be represented as 0 & 1 :( . This will have shift while
executing delay loop  or any calcs.
32KHz Timer will have only 32000 ticks per second , not 32768 ticks



> 2009/9/30 Shankar Ganesh :
> > Hi all,
> > In linux kernel, all the places i found ,for ex 32KHz clock is
> > represented as 32768 Hz, not as 32 x 1000 Hz .  Could you please help to
> > understand why  2 ^ x is used instead of 10 ^ y  ?
> >
> >
> > Regards,
> > Shankar
> >
>
>
>
> --
> Best Regards
> Lin
>


Re: KHz representation in Linux kernel

2009-09-30 Thread Pei Lin
i just think you query about why the "stupid computer" only can
recognize '0' and '1'. ^_^  :)

2009/9/30 Shankar Ganesh :
> Hi all,
> In linux kernel, all the places i found ,for ex 32KHz clock is
> represented as 32768 Hz, not as 32 x 1000 Hz .  Could you please help to
> understand why  2 ^ x is used instead of 10 ^ y  ?
>
>
> Regards,
> Shankar
>



-- 
Best Regards
Lin

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: max throughput achievable with outb()

2009-09-30 Thread Thomas Petazzoni
Le Wed, 30 Sep 2009 16:47:33 +1300,
Michal Ludvig  a écrit :

> I've got two questions:
> 1) Can I speed it up somehow?
> 2) Apparently it's quite a lot of time between calling outb() and its
> return. Can the kernel do something else in the meantime, like
> scheduling another process or handling interrupts, or is it blocked
> waiting for the outb() return? I'm on a uniprocessor x86 system.

You can read the implementation of outb() for x86
in /home/thomas/local/linuxdev/arch/x86/include/asm/io_32.h. Unless you
use outb_p() (which introduces a pause after the write), outb() is only
a static inline function that does the "outb" CPU instruction. No more,
no less.

If you want to be 100%, for testing purposes, you can hand-code the
outb() using an asm("") statement. But I don't think it'll make any
difference.

You can also make an accurate measurement of the instruction duration
using the TSC, to get the number of cycles spent during the execution
of the instruction.

Finally, my hardware knowledge is a bit limited, but I'm not sure that
a 8 Mhz bus necessarly means that you can do 8 millions outb() per
second through this bus. One outb() probably requires several (if not
many) clock ticks.

Sincerly,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: max throughput achievable with outb()

2009-09-30 Thread Thomas Petazzoni
Le Wed, 30 Sep 2009 13:50:22 +0800,
Peter Teoh  a écrit :

> generally, port i/o programming is always slower than mmio, why don't
> u consider that option?

Well, it's rarely an option. Either the device is programmed through
PIO *or* through MMIO. And I suspect that most ISA devices can only be
programmed through PIO.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ