Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1328704 > unrolled thread

linux-next: manual merge of the tty tree with the tty.current tree

Started byStephen Rothwell <sfr@canb.auug.org.au>
First post2016-02-08 03:20 +0100
Last post2016-02-08 04:00 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  linux-next: manual merge of the tty tree with the tty.current tree Stephen Rothwell <sfr@canb.auug.org.au> - 2016-02-08 03:20 +0100
    Re: linux-next: manual merge of the tty tree with the tty.current  tree Greg KH <greg@kroah.com> - 2016-02-08 03:30 +0100
      Re: linux-next: manual merge of the tty tree with the tty.current  tree Peter Hurley <peter@hurleysoftware.com> - 2016-02-08 04:00 +0100

#1328704 — linux-next: manual merge of the tty tree with the tty.current tree

FromStephen Rothwell <sfr@canb.auug.org.au>
Date2016-02-08 03:20 +0100
Subjectlinux-next: manual merge of the tty tree with the tty.current tree
Message-ID<qZJAK-6SN-15@gated-at.bofh.it>
Hi Greg,

Today's linux-next merge of the tty tree got a conflict in:

  drivers/tty/tty_io.c

between commit:

  e9036d066236 ("tty: Drop krefs for interrupted tty lock")

from the tty.current tree and commit:

  d6203d0c7b73 ("tty: Refactor tty_open()")

from the tty tree.

I fixed it up (I think - see below) and can carry the fix as necessary
(no action is required).

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/tty/tty_io.c
index a7eacef1bd22,8d26ed79bb4c..000000000000
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@@ -2004,6 -2009,69 +2009,68 @@@ static struct tty_driver *tty_lookup_dr
  }
  
  /**
+  *	tty_open_by_driver	-	open a tty device
+  *	@device: dev_t of device to open
+  *	@inode: inode of device file
+  *	@filp: file pointer to tty
+  *
+  *	Performs the driver lookup, checks for a reopen, or otherwise
+  *	performs the first-time tty initialization.
+  *
+  *	Returns the locked initialized or re-opened &tty_struct
+  *
+  *	Claims the global tty_mutex to serialize:
+  *	  - concurrent first-time tty initialization
+  *	  - concurrent tty driver removal w/ lookup
+  *	  - concurrent tty removal from driver table
+  */
+ static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode,
+ 					     struct file *filp)
+ {
+ 	struct tty_struct *tty;
+ 	struct tty_driver *driver = NULL;
+ 	int index = -1;
+ 	int retval;
+ 
+ 	mutex_lock(&tty_mutex);
+ 	driver = tty_lookup_driver(device, filp, &index);
+ 	if (IS_ERR(driver)) {
+ 		mutex_unlock(&tty_mutex);
+ 		return ERR_CAST(driver);
+ 	}
+ 
+ 	/* check whether we're reopening an existing tty */
+ 	tty = tty_driver_lookup_tty(driver, inode, index);
+ 	if (IS_ERR(tty)) {
+ 		mutex_unlock(&tty_mutex);
+ 		goto out;
+ 	}
+ 
+ 	if (tty) {
+ 		mutex_unlock(&tty_mutex);
+ 		retval = tty_lock_interruptible(tty);
++		tty_kref_put(tty);  /* drop kref from tty_driver_lookup_tty() */
+ 		if (retval) {
+ 			if (retval == -EINTR)
+ 				retval = -ERESTARTSYS;
+ 			tty = ERR_PTR(retval);
+ 			goto out;
+ 		}
 -		/* safe to drop the kref from tty_driver_lookup_tty() */
 -		tty_kref_put(tty);
+ 		retval = tty_reopen(tty);
+ 		if (retval < 0) {
+ 			tty_unlock(tty);
+ 			tty = ERR_PTR(retval);
+ 		}
+ 	} else { /* Returns with the tty_lock held for now */
+ 		tty = tty_init_dev(driver, index);
+ 		mutex_unlock(&tty_mutex);
+ 	}
+ out:
+ 	tty_driver_kref_put(driver);
+ 	return tty;
+ }
+ 
+ /**
   *	tty_open		-	open a tty device
   *	@inode: inode of device file
   *	@filp: file pointer to tty

[toc] | [next] | [standalone]


#1328711 — Re: linux-next: manual merge of the tty tree with the tty.current tree

FromGreg KH <greg@kroah.com>
Date2016-02-08 03:30 +0100
SubjectRe: linux-next: manual merge of the tty tree with the tty.current tree
Message-ID<qZJKq-6We-11@gated-at.bofh.it>
In reply to#1328704
On Mon, Feb 08, 2016 at 01:16:29PM +1100, Stephen Rothwell wrote:
> Hi Greg,
> 
> Today's linux-next merge of the tty tree got a conflict in:
> 
>   drivers/tty/tty_io.c
> 
> between commit:
> 
>   e9036d066236 ("tty: Drop krefs for interrupted tty lock")
> 
> from the tty.current tree and commit:
> 
>   d6203d0c7b73 ("tty: Refactor tty_open()")
> 
> from the tty tree.
> 
> I fixed it up (I think - see below) and can carry the fix as necessary
> (no action is required).
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc drivers/tty/tty_io.c
> index a7eacef1bd22,8d26ed79bb4c..000000000000
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@@ -2004,6 -2009,69 +2009,68 @@@ static struct tty_driver *tty_lookup_dr
>   }
>   
>   /**
> +  *	tty_open_by_driver	-	open a tty device
> +  *	@device: dev_t of device to open
> +  *	@inode: inode of device file
> +  *	@filp: file pointer to tty
> +  *
> +  *	Performs the driver lookup, checks for a reopen, or otherwise
> +  *	performs the first-time tty initialization.
> +  *
> +  *	Returns the locked initialized or re-opened &tty_struct
> +  *
> +  *	Claims the global tty_mutex to serialize:
> +  *	  - concurrent first-time tty initialization
> +  *	  - concurrent tty driver removal w/ lookup
> +  *	  - concurrent tty removal from driver table
> +  */
> + static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode,
> + 					     struct file *filp)
> + {
> + 	struct tty_struct *tty;
> + 	struct tty_driver *driver = NULL;
> + 	int index = -1;
> + 	int retval;
> + 
> + 	mutex_lock(&tty_mutex);
> + 	driver = tty_lookup_driver(device, filp, &index);
> + 	if (IS_ERR(driver)) {
> + 		mutex_unlock(&tty_mutex);
> + 		return ERR_CAST(driver);
> + 	}
> + 
> + 	/* check whether we're reopening an existing tty */
> + 	tty = tty_driver_lookup_tty(driver, inode, index);
> + 	if (IS_ERR(tty)) {
> + 		mutex_unlock(&tty_mutex);
> + 		goto out;
> + 	}
> + 
> + 	if (tty) {
> + 		mutex_unlock(&tty_mutex);
> + 		retval = tty_lock_interruptible(tty);
> ++		tty_kref_put(tty);  /* drop kref from tty_driver_lookup_tty() */
> + 		if (retval) {
> + 			if (retval == -EINTR)
> + 				retval = -ERESTARTSYS;
> + 			tty = ERR_PTR(retval);
> + 			goto out;
> + 		}
>  -		/* safe to drop the kref from tty_driver_lookup_tty() */
>  -		tty_kref_put(tty);
> + 		retval = tty_reopen(tty);
> + 		if (retval < 0) {
> + 			tty_unlock(tty);
> + 			tty = ERR_PTR(retval);
> + 		}
> + 	} else { /* Returns with the tty_lock held for now */
> + 		tty = tty_init_dev(driver, index);
> + 		mutex_unlock(&tty_mutex);
> + 	}
> + out:
> + 	tty_driver_kref_put(driver);
> + 	return tty;
> + }
> + 
> + /**
>    *	tty_open		-	open a tty device
>    *	@inode: inode of device file
>    *	@filp: file pointer to tty

Peter warned me this was going to happen...

Peter, is the merge above correct?

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1328725 — Re: linux-next: manual merge of the tty tree with the tty.current tree

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-02-08 04:00 +0100
SubjectRe: linux-next: manual merge of the tty tree with the tty.current tree
Message-ID<qZKds-77A-3@gated-at.bofh.it>
In reply to#1328711
On 02/07/2016 06:21 PM, Greg KH wrote:
> Peter, is the merge above correct?

Yes, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web