From nobody@FreeBSD.org  Mon Nov 15 04:28:22 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 58D20106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Nov 2010 04:28:22 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2BFC38FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Nov 2010 04:28:22 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oAF4SLaZ037363
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Nov 2010 04:28:21 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id oAF4SL06037362;
	Mon, 15 Nov 2010 04:28:21 GMT
	(envelope-from nobody)
Message-Id: <201011150428.oAF4SL06037362@www.freebsd.org>
Date: Mon, 15 Nov 2010 04:28:21 GMT
From: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Support ioctl() on TTY control devices
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         152254
>Category:       kern
>Synopsis:       [patch] Support ioctl() on TTY control devices
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ed
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 15 04:30:09 UTC 2010
>Closed-Date:    Sat Jul 02 13:54:50 UTC 2011
>Last-Modified:  Sat Jul 02 13:54:50 UTC 2011
>Originator:     Peter Jeremy
>Release:        FreeBSD-8.1
>Organization:
Alcatel-Lucent Australia
>Environment:
FreeBSD pjdesk.au.alcatel-lucent.com 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #19: Wed Jul 14 07:24:18 EST 2010     root@pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk  amd64

>Description:
The TTY MPSAFE adaption removed support for issuing driver-specific ioctl(2) calls on the TTY control device.  This patch re-adds it since this support is required for digi(4).
>How-To-Repeat:
Code inspection
>Fix:


Patch attached with submission follows:

Index: sys/ttydevsw.h
===================================================================
RCS file: /usr/ncvs/src/sys/sys/ttydevsw.h,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 ttydevsw.h
--- sys/ttydevsw.h	3 Aug 2009 08:13:06 -0000	1.4.2.1
+++ sys/ttydevsw.h	15 Nov 2010 03:11:44 -0000
@@ -52,6 +52,8 @@
     vm_paddr_t * paddr, int nprot);
 typedef void tsw_pktnotify_t(struct tty *tp, char event);
 typedef void tsw_free_t(void *softc);
+typedef int tsw_cioctl_t(struct tty *tp, u_long cmd, caddr_t data,
+    struct thread *td);
 
 struct ttydevsw {
 	unsigned int	tsw_flags;	/* Default TTY flags. */
@@ -70,6 +72,8 @@
 	tsw_pktnotify_t	*tsw_pktnotify;	/* TIOCPKT events. */
 
 	tsw_free_t	*tsw_free;	/* Destructor. */
+
+	tsw_cioctl_t	*tsw_cioctl;	/* Ioctl on control devices */
 };
 
 static __inline int
@@ -166,4 +170,13 @@
 	tp->t_devsw->tsw_free(tty_softc(tp));
 }
 
+static __inline int
+ttydevsw_cioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
+{
+	tty_lock_assert(tp, MA_OWNED);
+	MPASS(!tty_gone(tp));
+
+	return tp->t_devsw->tsw_cioctl(tp, cmd, data, td);
+}
+
 #endif /* !_SYS_TTYDEVSW_H_ */
Index: kern/tty.c
===================================================================
RCS file: /usr/ncvs/src/sys/kern/tty.c,v
retrieving revision 1.328.2.4
diff -u -r1.328.2.4 tty.c
--- kern/tty.c	18 Jan 2010 09:04:53 -0000	1.328.2.4
+++ kern/tty.c	15 Nov 2010 03:21:46 -0000
@@ -781,7 +781,7 @@
 		bzero(data, sizeof(struct winsize));
 		break;
 	default:
-		error = ENOTTY;
+		error = ttydevsw_ioctl(tp, cmd, data, td);
 	}
 
 done:	tty_unlock(tp);
@@ -905,6 +905,13 @@
 	panic("Terminal device freed without a free-handler");
 }
 
+static int
+ttydevsw_defcioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
+{
+
+	return (ENOTTY);
+}
+
 /*
  * TTY allocation and deallocation. TTY devices can be deallocated when
  * the driver doesn't use it anymore, when the TTY isn't a session's
@@ -938,6 +945,7 @@
 	PATCH_FUNC(mmap);
 	PATCH_FUNC(pktnotify);
 	PATCH_FUNC(free);
+	PATCH_FUNC(cioctl);
 #undef PATCH_FUNC
 
 	tp = malloc(sizeof(struct tty), M_TTY, M_WAITOK|M_ZERO);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ed 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Mon Nov 15 12:22:35 UTC 2010 
Responsible-Changed-Why:  
Ed, is this your department? If not please assign back into the pool. ;) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152254 

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, peter.jeremy@alcatel-lucent.com
Cc:  
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Mon, 15 Nov 2010 15:15:59 +0100

 --TB36FDmn/VVEgNH/
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Peter,
 
 The patch looks okay, but it doesn't make any changes to digi(4).
 Wouldn't it be better to do it all in one commit?
 
 Greetings,
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --TB36FDmn/VVEgNH/
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.16 (FreeBSD)
 
 iEYEARECAAYFAkzhQJ8ACgkQ52SDGA2eCwXUtACdHoEBvmGxf2kfN0IK5TF1T9GZ
 WcYAnjpsEzHxdjC1EzRxJ1ZcNNHzrVUJ
 =9nmf
 -----END PGP SIGNATURE-----
 
 --TB36FDmn/VVEgNH/--

From: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
To: Ed Schouten <ed@80386.nl>
Cc: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Tue, 16 Nov 2010 07:51:03 +1100

 --8teuZUM8bA5gqecl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On 2010-Nov-15 22:15:59 +0800, Ed Schouten <ed@80386.nl> wrote:
 >The patch looks okay, but it doesn't make any changes to digi(4).
 
 Agreed.  This just restores core TTY functionality that was lost in
 the TTYng changes.  It looks like it was only ever used by digi(4) but
 could potentially have been used by other drivers.
 
 >Wouldn't it be better to do it all in one commit?
 
 It depends whether you want one large commit that does lots of not
 well related things or a number of small commits that perform
 well-defined (and hopefully easier to verify) changes.  In the past,
 I've submitted large, multi-functional changes and been requested to
 split them up - this is generally much harder to do after the fact
 than combining lots of small patches if a single commit is desired.
 
 --=20
 Peter Jeremy
 
 --8teuZUM8bA5gqecl
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.16 (FreeBSD)
 
 iEYEARECAAYFAkzhnTcACgkQ/opHv/APuIdWsQCgw+u7GkHCeRSl6cBaRIPz8DpI
 BqoAnRpPiaAl4h4owJMQolsxoVA658J6
 =QRAM
 -----END PGP SIGNATURE-----
 
 --8teuZUM8bA5gqecl--

From: Ed Schouten <ed@80386.nl>
To: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
Cc: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Mon, 15 Nov 2010 23:41:20 +0100

 --yH1ZJFh+qWm+VodA
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hello Peter,
 
 * Peter Jeremy <peter.jeremy@alcatel-lucent.com>, 20101115 21:51:
 > >Wouldn't it be better to do it all in one commit?
 >=20
 > It depends whether you want one large commit that does lots of not
 > well related things or a number of small commits that perform
 > well-defined (and hopefully easier to verify) changes.  In the past,
 > I've submitted large, multi-functional changes and been requested to
 > split them up - this is generally much harder to do after the fact
 > than combining lots of small patches if a single commit is desired.
 
 Well, I'd vote on doing something in between -- committing both patches
 at the same time, but in two separate commits. I don't feel like adding
 functionality to the TTY layer that is never used by any of its drivers.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --yH1ZJFh+qWm+VodA
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.16 (FreeBSD)
 
 iEYEARECAAYFAkzhtxAACgkQ52SDGA2eCwWKeQCePnd3HHqzns/gRmUvOL34T9K6
 tYwAmQGXtDRtI8UB3ATCEY2pSZOUZlpO
 =0SX5
 -----END PGP SIGNATURE-----
 
 --yH1ZJFh+qWm+VodA--

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, peter.jeremy@alcatel-lucent.com
Cc:  
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Sun, 21 Nov 2010 15:35:37 +0100

 If you want this to be MFCed, I think additional work is needed so that
 using an old driver module with a new kernel does not invoke a garbage
 ioctl function pointer.
 
 -- 
 Jilles Tjoelker

From: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
To: Jilles Tjoelker <jilles@stack.nl>
Cc: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Mon, 22 Nov 2010 07:37:17 +1100

 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On 2010-Nov-21 22:35:37 +0800, Jilles Tjoelker <jilles@stack.nl> wrote:
 >If you want this to be MFCed, I think additional work is needed so that
 >using an old driver module with a new kernel does not invoke a garbage
 >ioctl function pointer.
 
 I was aware of the KBI issue but hadn't really thought of a way around
 it.  I guess one option would be to add a new TF_xxx flag to specify
 that the tsw_cioctl field exists but that doesn't really scale to
 potential further extensions.
 
 What would be your recommendation for expanding struct ttydevsw in a
 backwards compatible manner?
 
 BTW, there is a typo in the patch I initially posted, and having
 actually tried to use it, I've identified a a shortcoming which has
 necessitated a change to the function prototype.  I will submit a
 new patch once I'm happy with my patches to digi(4).
 
 --=20
 Peter Jeremy
 
 --qDbXVdCdHGoSgWSk
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.16 (FreeBSD)
 
 iEYEARECAAYFAkzpgvwACgkQ/opHv/APuIcFRgCgqOJghXM05tBxug7bZMXJtzT6
 pZYAoLVSwO5w5ZRrGydquF5Q0gEvuk73
 =8S0R
 -----END PGP SIGNATURE-----
 
 --qDbXVdCdHGoSgWSk--

From: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
To: "FreeBSD-gnats-submit@FreeBSD.org" <FreeBSD-gnats-submit@FreeBSD.org>,
        "freebsd-bugs@FreeBSD.org" <freebsd-bugs@FreeBSD.org>
Cc:  
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Tue, 21 Jun 2011 14:53:11 +1000

 --0eh6TmSyL6TZE2Uz
 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7"
 Content-Disposition: inline
 
 
 --fdj2RfSjLxBAspz7
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 I notice that FreeBSD is entering the 9.0 release cycle.  As Jilles
 Tjoelker has noted, my patch changes the KBI.  As a result, I would
 like to request that this change be made before the 9.0 freeze.  If
 you do not want to commit the change, could you please add some
 padding fields to struct ttydevsw to simplify applying the change in
 future.
 
 My apologies for the late request but re@ are being very secretive
 with dates and I only just found out about the code slush.
 
 An updated version of the patch is attached.  This has undergone
 limited testing in both 8-stable and -current annd testing is
 continuing.
 
 Note that this PR is a prerequisite for kern/158086
 
 --=20
 Peter Jeremy
 
 --fdj2RfSjLxBAspz7
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="152254.patch"
 Content-Transfer-Encoding: quoted-printable
 
 Index: sys/kern/tty.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /usr/ncvs/src/sys/kern/tty.c,v
 retrieving revision 1.341
 diff -u -r1.341 tty.c
 --- sys/kern/tty.c	4 Jan 2011 10:59:38 -0000	1.341
 +++ sys/kern/tty.c	20 Jun 2011 22:45:20 -0000
 @@ -91,7 +91,7 @@
  			HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\
  			CDSR_OFLOW|CCAR_OFLOW)
 =20
 -#define	TTY_CALLOUT(tp,d) ((d) !=3D (tp)->t_dev && (d) !=3D dev_console)
 +#define	TTY_CALLOUT(tp,d) (dev2unit(d) & TTYUNIT_CALLOUT)
 =20
  /*
   * Set TTY buffer sizes.
 @@ -791,7 +791,7 @@
  		bzero(data, sizeof(struct winsize));
  		break;
  	default:
 -		error =3D ENOTTY;
 +		error =3D ttydevsw_cioctl(tp, dev2unit(dev), cmd, data, td);
  	}
 =20
  done:	tty_unlock(tp);
 @@ -927,6 +927,13 @@
  	panic("Terminal device freed without a free-handler");
  }
 =20
 +static int
 +ttydevsw_defcioctl(struct tty *tp, int unit, u_long cmd, caddr_t data, str=
 uct thread *td)
 +{
 +
 +	return (ENOTTY);
 +}
 +
  /*
   * TTY allocation and deallocation. TTY devices can be deallocated when
   * the driver doesn't use it anymore, when the TTY isn't a session's
 @@ -960,6 +967,7 @@
  	PATCH_FUNC(mmap);
  	PATCH_FUNC(pktnotify);
  	PATCH_FUNC(free);
 +	PATCH_FUNC(cioctl);
  #undef PATCH_FUNC
 =20
  	tp =3D malloc(sizeof(struct tty), M_TTY, M_WAITOK|M_ZERO);
 @@ -1190,13 +1198,13 @@
 =20
  	/* Slave call-in devices. */
  	if (tp->t_flags & TF_INITLOCK) {
 -		dev =3D make_dev_cred(&ttyil_cdevsw, 0, cred,
 +		dev =3D make_dev_cred(&ttyil_cdevsw, TTYUNIT_INIT, cred,
  		    uid, gid, mode, "%s%s.init", prefix, name);
  		dev_depends(tp->t_dev, dev);
  		dev->si_drv1 =3D tp;
  		dev->si_drv2 =3D &tp->t_termios_init_in;
 =20
 -		dev =3D make_dev_cred(&ttyil_cdevsw, 0, cred,
 +		dev =3D make_dev_cred(&ttyil_cdevsw, TTYUNIT_LOCK, cred,
  		    uid, gid, mode, "%s%s.lock", prefix, name);
  		dev_depends(tp->t_dev, dev);
  		dev->si_drv1 =3D tp;
 @@ -1205,20 +1213,22 @@
 =20
  	/* Call-out devices. */
  	if (tp->t_flags & TF_CALLOUT) {
 -		dev =3D make_dev_cred(&ttydev_cdevsw, 0, cred,
 +		dev =3D make_dev_cred(&ttydev_cdevsw, TTYUNIT_CALLOUT, cred,
  		    UID_UUCP, GID_DIALER, 0660, "cua%s", name);
  		dev_depends(tp->t_dev, dev);
  		dev->si_drv1 =3D tp;
 =20
  		/* Slave call-out devices. */
  		if (tp->t_flags & TF_INITLOCK) {
 -			dev =3D make_dev_cred(&ttyil_cdevsw, 0, cred,
 +			dev =3D make_dev_cred(&ttyil_cdevsw,=20
 +			    TTYUNIT_CALLOUT | TTYUNIT_INIT, cred,
  			    UID_UUCP, GID_DIALER, 0660, "cua%s.init", name);
  			dev_depends(tp->t_dev, dev);
  			dev->si_drv1 =3D tp;
  			dev->si_drv2 =3D &tp->t_termios_init_out;
 =20
 -			dev =3D make_dev_cred(&ttyil_cdevsw, 0, cred,
 +			dev =3D make_dev_cred(&ttyil_cdevsw,
 +			    TTYUNIT_CALLOUT | TTYUNIT_LOCK, cred,
  			    UID_UUCP, GID_DIALER, 0660, "cua%s.lock", name);
  			dev_depends(tp->t_dev, dev);
  			dev->si_drv1 =3D tp;
 Index: sys/sys/tty.h
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /usr/ncvs/src/sys/sys/tty.h,v
 retrieving revision 1.118
 diff -u -r1.118 tty.h
 --- sys/sys/tty.h	4 Jan 2010 20:59:52 -0000	1.118
 +++ sys/sys/tty.h	20 Jun 2011 22:47:15 -0000
 @@ -150,6 +150,11 @@
  	dev_t	xt_dev;		/* Userland device. */
  };
 =20
 +/* Used to distinguish between normal, callout, lock and init devices */
 +#define	TTYUNIT_INIT	0x1
 +#define	TTYUNIT_LOCK	0x2
 +#define	TTYUNIT_CALLOUT	0x4
 +
  #ifdef _KERNEL
 =20
  /* Allocation and deallocation. */
 Index: sys/sys/ttydevsw.h
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /usr/ncvs/src/sys/sys/ttydevsw.h,v
 retrieving revision 1.5
 diff -u -r1.5 ttydevsw.h
 --- sys/sys/ttydevsw.h	29 Dec 2009 21:51:28 -0000	1.5
 +++ sys/sys/ttydevsw.h	20 Jun 2011 22:47:15 -0000
 @@ -52,6 +52,8 @@
      vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr);
  typedef void tsw_pktnotify_t(struct tty *tp, char event);
  typedef void tsw_free_t(void *softc);
 +typedef int tsw_cioctl_t(struct tty *tp, int unit, u_long cmd, caddr_t dat=
 a,
 +    struct thread *td);
 =20
  struct ttydevsw {
  	unsigned int	tsw_flags;	/* Default TTY flags. */
 @@ -70,6 +72,8 @@
  	tsw_pktnotify_t	*tsw_pktnotify;	/* TIOCPKT events. */
 =20
  	tsw_free_t	*tsw_free;	/* Destructor. */
 +
 +	tsw_cioctl_t	*tsw_cioctl;	/* Ioctl on control devices */
  };
 =20
  static __inline int
 @@ -167,4 +171,13 @@
  	tp->t_devsw->tsw_free(tty_softc(tp));
  }
 =20
 +static __inline int
 +ttydevsw_cioctl(struct tty *tp, int unit, u_long cmd, caddr_t data, struct=
  thread *td)
 +{
 +	tty_lock_assert(tp, MA_OWNED);
 +	MPASS(!tty_gone(tp));
 +
 +	return tp->t_devsw->tsw_cioctl(tp, unit, cmd, data, td);
 +}
 +
  #endif /* !_SYS_TTYDEVSW_H_ */
 
 --fdj2RfSjLxBAspz7--
 
 --0eh6TmSyL6TZE2Uz
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iEYEARECAAYFAk4AI7cACgkQ/opHv/APuIeaRwCdHxcIwrFDi+CpGg1y4V12+4zT
 BmIAoIF4i0s5kW/xKaDiaR6aQtNwc7k1
 =I3R4
 -----END PGP SIGNATURE-----
 
 --0eh6TmSyL6TZE2Uz--

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, peter.jeremy@alcatel-lucent.com
Cc:  
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Thu, 30 Jun 2011 18:55:42 +0200

 --RwxaKO075aXzzOz0
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi Peter,
 
 Even though I thought the first version of your patch was okay, I don't
 agree with the second version you propose. A nice thing about the
 current TTY layer is that it gets rid of device minor numbers entirely.
 This patch seems to reintroduce them.
 
 Isn't there a way for us to make tsw_cioctl() work without them? Is the
 distinction between lock/init/callin/callout really needed by digi(4)?
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --RwxaKO075aXzzOz0
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iQIcBAEBAgAGBQJODKqNAAoJEG5e2P40kaK7mYwQAIUDWuZ88isVQVaDAkeW6qnb
 mcnoxoaLgBZB2wWw6OPbOssvPbW1Iu6GCoZgggwXQo4FepDB6VYciWQu8KPqzym5
 rNOr17TWa6nFlaQ4/dspZI9EIkIipLFDjiuB61AB5MxaKg4l7QWEyJAyRw5BAf7p
 /dAusqavvxtrITukLWOgqkIAzoTJ4vOWirCCjNZhN1Uu5GCLGCGJEcOdvaCSPTg7
 WB39inEP7LUugb6J2+YTfUxZgDZiiojKW0602+M3dtZS4bAtP0y3zTmd0YP5EBrX
 xqava1/9byqHNhbXvR5O2ztU55EbzqEpZzKTM/8Nf7t2NXAjFKWWgTzMHcN7+yxK
 3e9Olt28kKESXLI406bC6yi27Vh5BWHKWV87wPqCO178rH7t9+cZCcBqBNRHOqwA
 bnmgT2Rm5tXIVDY51U8v/E9RyT3HifpNOVuzcWDq+Zwy4/Xe9pNl77Bu2B9u76V8
 9MkrlT4c4Dc2aR2zBw2ej9KpXQwMsKS8b3oACxfcK7KqoULnkFzjkCbXv+HujHW7
 YEe6cev4h1t02l+jpiR6xxoy8XS5Oc2IWQhwnbY9OfRiEQJcRObpUOng39svLKzJ
 Oy7RS4bPl0H2iZxgPe7rC3niekKVcw1dElmjzjlzNhdLsaAWqZSPfNoxWupUz5w5
 6awAn6H+EnWSPXRmbOnF
 =ONiV
 -----END PGP SIGNATURE-----
 
 --RwxaKO075aXzzOz0--

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, peter.jeremy@alcatel-lucent.com
Cc:  
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Thu, 30 Jun 2011 21:05:33 +0200

 --bgLLobvf7eP6VP5c
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi Peter,
 
 * Ed Schouten <ed@80386.nl>, 20110630 18:55:
 > Even though I thought the first version of your patch was okay, I don't
 > agree with the second version you propose. A nice thing about the
 > current TTY layer is that it gets rid of device minor numbers entirely.
 > This patch seems to reintroduce them.
 >=20
 > Isn't there a way for us to make tsw_cioctl() work without them? Is the
 > distinction between lock/init/callin/callout really needed by digi(4)?
 
 Hmmm... I've taken a second look and I think your solution does make
 sense, though. I would still advise a small change. Would you mind if I
 moved the call to ttydevsw_cioctl() to the top and make it return
 ENOIOCTL, just like we do for ttydevsw_ioctl()? I'd like to keep
 ttydevsw_cioctl() as similar to ttydevsw_ioctl() as possible.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --bgLLobvf7eP6VP5c
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iQIcBAEBAgAGBQJODMj9AAoJEG5e2P40kaK7AuQQAJuJwAmkEBJ32kR9Juqkp+Fa
 AUjJnVUcePef3a/TU8rKvhzKNHARmR+MXeDeaZrCSZE0vtkSTV8xECOwEBA03juS
 BmS+3T5i0wfs4gOL//Y/ewo9p5Z0QK3DGX4yqeIv9AeNqVByIRZSOti4V64qnDrJ
 6CtMXodlKoVbP9Ogjx59UG6K/Ul6525+1yxQo5AOhmFaErvXuYesP411/KreItP9
 3H0wMjNk7phYmi48Mbpq+IepbDpZ5YI2g0bzoNQAENiqPptJHRfzSgXoTsDQB/FJ
 C/odn2774gwiS2h7kVA8XEy1GvRENlMgQkBXSyZkWKa6jKa6fxDWnMmz53lhf3az
 bSu0/HKfe+T6Eo/P6q+LHAd7waViI9cCuaDGO7YA4xT2YVSbyPmCUwAySpkj8uy/
 FclWjbGg9M/mTha+KCYw26Xja2zqv7tDvkOpYpCBzHKBcgb/gKg0FFTTwTJ4603x
 VzTAgjH7pVR8w2wGOy/Dr34WMIxdd/BiSrD6T7dmemkPP3Y+XXRymjinTmRLgS+H
 eX3Up2Q4WkgfcNLAPOZ6gkUcP2mpX5/uuwHUXnB6Bzd9wBudYWORpj1Bs9rbILF3
 OG3a7UWtivr8nULsugBlenesgzvP5VWL0et7by59bSEvec4C0D5/XiN+sIsigsqq
 iCyhVFBQjvAxu7wxNQ0I
 =krNX
 -----END PGP SIGNATURE-----
 
 --bgLLobvf7eP6VP5c--

From: Peter Jeremy <peter.jeremy@alcatel-lucent.com>
To: Ed Schouten <ed@80386.nl>
Cc: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>
Subject: Re: kern/152254: [patch] Support ioctl() on TTY control devices
Date: Fri, 1 Jul 2011 11:56:26 +1000

 --jkO+KyKz7TfD21mV
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi Ed,
 
 On 2011-Jul-01 03:05:33 +0800, Ed Schouten <ed@80386.nl> wrote:
 >* Ed Schouten <ed@80386.nl>, 20110630 18:55:
 >> Even though I thought the first version of your patch was okay, I don't
 >> agree with the second version you propose. A nice thing about the
 >> current TTY layer is that it gets rid of device minor numbers entirely.
 >> This patch seems to reintroduce them.
 
 The current TTY layer no longer has a device minor number as a
 distinct entity but each physical port still has six devices
 associated with it - a pair of callin/callout devices (handled via
 ttydev_cdevsw) and a pair of init/lock "slave" devices for each
 (handled via ttyil_cdevsw).  With the existing code, there's no way
 for the driver to identify which specific device node interface is
 being used - which leads to contortions like the TTY_CALLOUT() macro
 in kern/tty.c.
 
 >> Isn't there a way for us to make tsw_cioctl() work without them? Is the
 >> distinction between lock/init/callin/callout really needed by digi(4)?
 
 Not really and yes.  The Digi AccelePort variant uses 10P10C modular
 sockets (see http://en.wikipedia.org/wiki/Modular_connector#10P10C )
 with RI and DCD on pins 1 and 10, respectively.  In order to make DCD
 available when using cheaper and more available 8P8C (RJ-45) plugs,
 there's an option to swap the DCD and DSR pins (accessed via the
 DIGIIO_{S,G}ETALTPIN ioctl).  This is per-port state that needs to be
 managed in the same way as (eg) termios data.  I can't see any way to
 support this other than by passing init/lock ioctl() calls onto the
 device driver and making the device type accessible to it.
 
 The callin/callout isn't needed by digi(4) but is orthogonal to the
 lock/init state and carifies the TTY_CALLOUT() macro.
 
 >Hmmm... I've taken a second look and I think your solution does make
 >sense, though. I would still advise a small change. Would you mind if I
 >moved the call to ttydevsw_cioctl() to the top and make it return
 >ENOIOCTL, just like we do for ttydevsw_ioctl()? I'd like to keep
 >ttydevsw_cioctl() as similar to ttydevsw_ioctl() as possible.
 
 I presume you mean make ttyil_ioctl() similar to tty_ioctl() - the
 driver ioctl (ttydevsw_cioctl() or ttydevsw_ioctl()) is always invoked
 and the generic code (current ttyil_ioctl() or tty_generic_ioctl()) is
 only invoked if the driver doesn't handle it (ie returns ENOIOCTL).  I
 just based my patch on the old TTY code.  If you feel that it would be
 better aligned with the tty_ioctl() handling, feel free to change it.
 
 --=20
 Peter Jeremy
 
 --jkO+KyKz7TfD21mV
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iEYEARECAAYFAk4NKUoACgkQ/opHv/APuId13wCfe0jHWvrZNCMBmk7klSRj03/S
 xMMAniPoOoyUZJosS2jBxewt3vRndrPm
 =L4L7
 -----END PGP SIGNATURE-----
 
 --jkO+KyKz7TfD21mV--
State-Changed-From-To: open->closed 
State-Changed-By: ed 
State-Changed-When: Sat Jul 2 13:54:49 UTC 2011 
State-Changed-Why:  
Committed, with minor changes. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152254 
>Unformatted:
