All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Anton Ivanov <anton.ivanov@kot-begemot.co.uk>,
	linux-um@lists.infradead.org
Subject: Re: [PATCH 7/7] um: simplify IRQ handling code
Date: Mon, 30 Nov 2020 13:00:57 +0100	[thread overview]
Message-ID: <0eb098cf6a82e6656e2179a0f43cc014d437e271.camel@sipsolutions.net> (raw)
In-Reply-To: <41545b47-bf98-f520-c832-4cbe4145b745@kot-begemot.co.uk>

Sorry, looks like I forgot to reply to this earlier.

On Tue, 2020-11-24 at 22:36 +0000, Anton Ivanov wrote:

> > > > @@ -151,73 +171,33 @@ static int activate_fd(int irq, int fd, enum um_irq_type type, void *dev_id)
> > > >    		goto out;
> > > >    
> > > >    	spin_lock_irqsave(&irq_lock, flags);
> > > > -
> > > > -	/* Check if we have an entry for this fd */
> > > > -
> > > > -	err = -EBUSY;
> > > > -	for (irq_entry = active_fds;
> > > > -		irq_entry != NULL; irq_entry = irq_entry->next) {
> > > > -		if (irq_entry->fd == fd)
> > > > -			break;
> > > > -	}
> > > > -
> > > > -	if (irq_entry == NULL) {
> > > > -		/* This needs to be atomic as it may be called from an
> > > > -		 * IRQ context.
> > > > -		 */
> > > > -		irq_entry = kmalloc(sizeof(struct irq_entry), GFP_ATOMIC);
> > > > -		if (irq_entry == NULL) {
> > > > -			printk(KERN_ERR
> > > > -				"Failed to allocate new IRQ entry\n");
> > > > +	irq_entry = get_irq_entry_by_fd(fd);
> > > > +	if (irq_entry) {
> > > 
> > > This is not right.
> > > 
> > > You can re-register the same IRQ/fd, but with a different mask - f.e.
> > > turn on/off write or read on the same fd. F.E. - you have registered a
> > > read IRQ, you after that register same IRQ for write and you can alter
> > > the mask.
> > 
> > Hmm. You snipped some code, and it continued like this:
> > 
> >          irq_entry = get_irq_entry_by_fd(fd);
> >          if (irq_entry) {
> >                  /* cannot register the same FD twice with the same type */
> >                  if (WARN_ON(irq_entry->reg[type].events)) {
> >                          // basically return -EALREADY
> > 
> > 
> > I'm not sure I see this is different from what it was before? If the
> 
> The original intention was to be able to do it :)

To do _what_ exactly? You said to re-register the same FD, but you could
do that before by unregistering?

And read/write are completely separate entries anyway. You cannot do
both at the same time (they're not bitmasks, just enum values.)

In fact, you *can* still use the same FD for both, with and without this
patch. We find the irq_entry here (by FD), and then check if this type
of event is already used. That means you cannot register for READ for
the same FD twice, but using the other event (WRITE) is still fine.

johannes


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


  reply	other threads:[~2020-11-30 12:01 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 19:56 [PATCH 0/7 um: IRQ handling cleanups Johannes Berg
2020-11-23 19:56 ` [PATCH 1/7] um: support dynamic IRQ allocation Johannes Berg
2020-11-30 11:26   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 2/7] um: virtio: use " Johannes Berg
2020-11-30 13:45   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 3/7] um: clean up alarm IRQ chip name Johannes Berg
2020-11-30 13:54   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 4/7] um: irq: clean up and rename struct irq_fd Johannes Berg
2020-11-30 14:01   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 5/7] um: irq: reduce irq_reg allocation Johannes Berg
2020-11-23 19:56 ` [PATCH 6/7] um: remove IRQ_NONE type Johannes Berg
2020-11-30 14:31   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 7/7] um: simplify IRQ handling code Johannes Berg
2020-11-24 21:50   ` Anton Ivanov
2020-11-24 21:58     ` Johannes Berg
2020-11-24 22:36       ` Anton Ivanov
2020-11-30 12:00         ` Johannes Berg [this message]
2020-11-30 13:40           ` Anton Ivanov
2020-11-30 16:30   ` Anton Ivanov
2020-12-01 20:15     ` Johannes Berg
2020-12-02  9:03       ` Anton Ivanov
2020-12-02 11:29         ` Johannes Berg
2020-12-02 11:31           ` Anton Ivanov
2020-12-02 11:32             ` Johannes Berg
2020-12-02 11:56               ` Anton Ivanov
2020-12-02 11:58                 ` Johannes Berg
2020-12-02 11:43           ` Johannes Berg
2020-12-02 11:49     ` Johannes Berg
2020-12-02 11:54   ` Johannes Berg
2020-12-02 11:58     ` Anton Ivanov
2020-11-24  8:14 ` [PATCH 0/7 um: IRQ handling cleanups Anton Ivanov
2020-11-24  8:55   ` Johannes Berg
2020-11-24  8:58     ` Johannes Berg
2020-11-24  9:06       ` Anton Ivanov
2020-11-24 16:34         ` Anton Ivanov
2020-11-24 16:39           ` Johannes Berg
2020-11-24 16:42             ` Anton Ivanov
2020-11-24 16:45             ` Anton Ivanov
2020-11-24 16:46               ` Johannes Berg
2020-11-24 17:07                 ` Anton Ivanov
2020-11-24 18:32                   ` Johannes Berg
2020-11-24 21:11 ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0eb098cf6a82e6656e2179a0f43cc014d437e271.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=anton.ivanov@kot-begemot.co.uk \
    --cc=linux-um@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.