Re: [PATCH] Move user_intr handling to mach side

2020-08-04 Thread Junling Ma
> On Aug 4, 2020, at 5:24 PM, Samuel Thibault wrote: > > Re, > > Junling Ma, le dim. 02 août 2020 21:07:00 -0700, a ecrit: >> +struct pt_regs; >> +extern int request_irq (unsigned int irq, void (*handler) (int, void *, >> struct pt_regs *), >> + unsigned long flags, const char *devic

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Junling Ma
> On Aug 4, 2020, at 5:30 PM, Samuel Thibault wrote: > > Junling Ma, le mar. 04 août 2020 17:08:03 -0700, a ecrit: static user_intr_t * search_intr (struct irqdev *dev, ipc_port_t dst_port) { user_intr_t *e; - queue_iterate (dev->intr_queue, e, user_intr_t *, chain) >>>

Re: [PATCH v2] irqdev: make deliver_user_intr return void

2020-08-04 Thread Samuel Thibault
Ah, I actually reviewed the all-in-one patch. Put please proceed with the separate patches, that'll be much more testable, and all my comments probably apply just the same. Samuel

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Samuel Thibault
Junling Ma, le mar. 04 août 2020 17:11:06 -0700, a ecrit: > In the next patch, we disallow deliver_user_intr from touching the queue, so > we do not need to lock it. We don't want separate patch to depend on each other. Each patch should by its own just *work* so we can test all of them one after

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Samuel Thibault
Junling Ma, le mar. 04 août 2020 17:08:03 -0700, a ecrit: > >> static user_intr_t * > >> search_intr (struct irqdev *dev, ipc_port_t dst_port) > >> { > >> user_intr_t *e; > >> - queue_iterate (dev->intr_queue, e, user_intr_t *, chain) > >> + simple_lock(&dev->lock); > >> + queue_iterate (&dev-

Re: [PATCH] Move user_intr handling to mach side

2020-08-04 Thread Samuel Thibault
Samuel Thibault, le mer. 05 août 2020 02:24:20 +0200, a ecrit: > > user_intr_t * > > insert_intr_entry (struct irqdev *dev, int id, ipc_port_t dst_port) > > { > [...] > > + /* we do not need to disable irq here, because the irq handler does not > > touch the queue now. */ > ??? How so? Ah, yo

Re: [PATCH] Move user_intr handling to mach side

2020-08-04 Thread Samuel Thibault
Re, Junling Ma, le dim. 02 août 2020 21:07:00 -0700, a ecrit: > +struct pt_regs; > +extern int request_irq (unsigned int irq, void (*handler) (int, void *, > struct pt_regs *), > + unsigned long flags, const char *device, void *dev_id); > +extern void free_irq (unsigned int irq, void *de

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Junling Ma
In the next patch, we disallow deliver_user_intr from touching the queue, so we do not need to lock it. In fact, by doing that, we prevent interrupts from pulling the rug under our feet, so there is no need to do splhigh/splx in irq_acknowledge and intr_thread. Junling > On Aug 4, 2020, at 4:5

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Junling Ma
Hi Samual, > On Aug 4, 2020, at 4:51 PM, Samuel Thibault wrote: > > Junling Ma, le dim. 02 août 2020 21:04:24 -0700, a ecrit: >> -struct irqdev irqtab = { >> - "irq", irq_eoi, &main_intr_queue, 0, >> - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, >> -}; >> +struct irqdev irqtab; >>

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Samuel Thibault
Oh, btw, in queue_intr you also need to take the simple_lock which modifying the entry values. Samuel

Re: [PATCH] user_intr: a lock to protect main_intr_queue

2020-08-04 Thread Samuel Thibault
Junling Ma, le dim. 02 août 2020 21:04:24 -0700, a ecrit: > -struct irqdev irqtab = { > - "irq", irq_eoi, &main_intr_queue, 0, > - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, > -}; > +struct irqdev irqtab; > + > +void irq_init() > +{ > + irqtab.name = "irq"; > + irqtab.irqdev_ack

Re: [PATCH] irqdev: remove tot_num_intr

2020-08-04 Thread Junling Ma
In summary, there is no easy way for device_* interface to know who called. So registering a notification port is a simple and sane way, We only need to move device_intr_register/ack to irq_register/ack into something like irq.defs, so that other devices are freed from having to implement these

Re: [PATCH] irqdev: remove tot_num_intr

2020-08-04 Thread Samuel Thibault
Junling Ma, le mar. 04 août 2020 14:47:09 -0700, a ecrit: > The tot_num_intr field is a count of how many deliverable interrupts across > all lines. When we move > to the scheme of blocking read for request and write for acking, it is > possible that an interrupt > can happen during a small perio

Re: [PATCH] irqdev: remove tot_num_intr

2020-08-04 Thread Junling Ma
Hi Jess, > On Aug 4, 2020, at 3:22 PM, Jessica Clarke wrote: > > On 4 Aug 2020, at 22:47, Junling Ma wrote: >> >> The tot_num_intr field is a count of how many deliverable interrupts across >> all lines. When we move >> to the scheme of blocking read for request and write for acking, it is >

Re: [PATCH] irqdev: search_intr with interrupt line

2020-08-04 Thread Samuel Thibault
Junling Ma, le mar. 04 août 2020 15:16:39 -0700, a ecrit: > In the read/write irq scheme, a program may open multiple irq devices. When > wrting (acking), we > need to find the user_intr_t that both points to the device port and has the > correct interrupt. > Thus the search_intr function need to

Re: [PATCH] irqdev: remove tot_num_intr

2020-08-04 Thread Jessica Clarke
On 4 Aug 2020, at 22:47, Junling Ma wrote: > > The tot_num_intr field is a count of how many deliverable interrupts across > all lines. When we move > to the scheme of blocking read for request and write for acking, it is > possible that an interrupt > can happen during a small period that the

[PATCH] irqdev: search_intr with interrupt line

2020-08-04 Thread Junling Ma
In the read/write irq scheme, a program may open multiple irq devices. When wrting (acking), we need to find the user_intr_t that both points to the device port and has the correct interrupt. Thus the search_intr function need to match the interrupt id. For the device_intr_ack method, the id p

[PATCH] irqdev: remove tot_num_intr

2020-08-04 Thread Junling Ma
The tot_num_intr field is a count of how many deliverable interrupts across all lines. When we move to the scheme of blocking read for request and write for acking, it is possible that an interrupt can happen during a small period that the interrupt is acked, but the read has not happended yet.

[PATCH v2] linux irq: remove suer_intr from linux_action

2020-08-04 Thread Junling Ma
linux irq: remove suer_intr from linux_action --- linux/dev/arch/i386/kernel/irq.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/linux/dev/arch/i386/kernel/irq.c b/linux/dev/arch/i386/kernel/irq.c index aee10462..de7d6c6a 100644 --- a/linux/dev/arch/i386/kernel/irq.c +++ b/linux/

[PATCH v2] irqdev: make deliver_user_intr a linux irq handler

2020-08-04 Thread Junling Ma
irqdev: make deliver_user_intr a linux irq handler --- device/intr.c| 30 ++- device/intr.h| 1 - linux/dev/arch/i386/kernel/irq.c | 51 +--- 3 files changed, 24 insertions(+), 58 deletions(-) diff --git a/devic

[PATCH v2] irqdev: make deliver_user_intr return void

2020-08-04 Thread Junling Ma
This sets up the stage for making deliver_user_intr a linux irq handler, which does not have a return value. So we make deliver_user_intr return void, and move the check for dead notification port into intr_thread. Now deliver_user_intr does not touch main_intr_queue, and only the server thread