From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:07:04 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37DB7106566B; Sun, 6 Nov 2011 07:07:04 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D3788FC13; Sun, 6 Nov 2011 07:07:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6774e7004464; Sun, 6 Nov 2011 07:07:04 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6772al004461; Sun, 6 Nov 2011 07:07:02 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060707.pA6772al004461@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:07:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227134 - stable/8/games/fortune/datfiles X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:07:04 -0000 Author: dougb Date: Sun Nov 6 07:07:02 2011 New Revision: 227134 URL: http://svn.freebsd.org/changeset/base/227134 Log: MFC r226898: Fix the text and attribution of the poem "Youth" by Samuel Ullman. Our copy was a bastardization of the "older" (probably original?) and shorter version of the poem; and the "newer" version that is better known, and arguably more popular. Standardize on the latter. Cf. http://www.bartleby.com/73/2099.html Modified: stable/8/games/fortune/datfiles/fortunes Directory Properties: stable/8/games/fortune/ (props changed) Modified: stable/8/games/fortune/datfiles/fortunes ============================================================================== --- stable/8/games/fortune/datfiles/fortunes Sun Nov 6 07:02:13 2011 (r227133) +++ stable/8/games/fortune/datfiles/fortunes Sun Nov 6 07:07:02 2011 (r227134) @@ -4942,25 +4942,37 @@ cats on the dinette table, etc. "That stop him?" "No, but it sure slowed him up." % - Youth is not a time of life, it is a state of mind; it is a temper of -the will, a quality of the imagination, a vigor of the emotions, a predominance -of courage over timidity, of the appetite for adventure over love of ease. - Nobody grows old by merely living a number of years; people grow -old only by deserting their ideals. Years wrinkle the skin, but to give up -enthusiasm wrinkles the soul. Worry, doubt, self-distrust, fear, and despair --- these are the long, long years that bow the head and turn the growing spirit -back to dust. - Whether seventy or sixteen, there is in every being's heart the love -of wonder, the sweet amazement at the stars and the starlike things and -thoughts, the undaunted challenge of events, the unfailing childlike appetite -for what next, and the joy and the game of life. - You are as young as your faith, as old as your doubt; as young as your -self-confidence, as old as your fear, as young as your hope, as old as your -despair. - So long as your heart receives messages of beauty, cheer, courage, -grandeur and power from the earth, from man, and from the Infinite, so long -you are young. - -- Samuel Ullman + Youth is not a time of life--it is a state of mind. It is not a +matter of red cheeks, red lips and supple knees. It is a temper of the +will; a quality of the imagination; a vigor of the emotions; it is a +freshness of the deep springs of life. Youth means a tempermental +predominance of courage over timidity, of the appetite for adventure +over a life of ease. This often exists in a man of fifty, more than in +a boy of twenty. Nobody grows old by merely living a number of years; +people grow old by deserting their ideals. + + Years may wrinkle the skin, but to give up enthusiasm wrinkles +the soul. Worry, doubt, self-distrust, fear and despair--these are the +long, long years that bow the head and turn the growing spirit back to +dust. + + Whether seventy or sixteen, there is in every being’s heart a +love of wonder; the sweet amazement at the stars and starlike things and +thoughts; the undaunted challenge of events, the unfailing childlike +appetite for what comes next, and the joy in the game of life. + + You are as young as your faith, as old as your doubt; as young +as your self-confidence, as old as your fear, as young as your hope, as +old as your despair. + + In the central place of your heart there is a wireless station. +So long as it receives messages of beauty, hope, cheer, grandeur, +courage, and power from the earth, from men and from the Infinite--so +long are you young. When the wires are all down and the central places +of your heart are covered with the snows of pessimism and the ice of +cynicism, then are you grown old, indeed! + -- Samuel Ullman, "Youth" (1934), as published in + The Silver Treasury, Prose and Verse for Every Mood % " " -- Charlie Chaplin From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:20:09 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA4EE106566C; Sun, 6 Nov 2011 07:20:09 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AECAB8FC0C; Sun, 6 Nov 2011 07:20:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67K9Rx005075; Sun, 6 Nov 2011 07:20:09 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67K9aZ005073; Sun, 6 Nov 2011 07:20:09 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060720.pA67K9aZ005073@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:20:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227137 - stable/8/usr.bin/calendar/calendars X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:20:10 -0000 Author: dougb Date: Sun Nov 6 07:20:09 2011 New Revision: 227137 URL: http://svn.freebsd.org/changeset/base/227137 Log: MFC r226909: Add a reminder about quarterly status report due dates Modified: stable/8/usr.bin/calendar/calendars/calendar.freebsd Directory Properties: stable/8/usr.bin/calendar/ (props changed) Modified: stable/8/usr.bin/calendar/calendars/calendar.freebsd ============================================================================== --- stable/8/usr.bin/calendar/calendars/calendar.freebsd Sun Nov 6 07:18:19 2011 (r227136) +++ stable/8/usr.bin/calendar/calendars/calendar.freebsd Sun Nov 6 07:20:09 2011 (r227137) @@ -108,6 +108,7 @@ 03/28 Sean C. Farley born in Indianapolis, Indiana, United States, 1970 03/29 Thierry Thomas born in Luxeuil les Bains, France, 1961 03/30 Po-Chuan Hsieh born in Taipei, Taiwan, Republic of China, 1978 +03/31 First quarter status reports are due on 04/15 04/01 Matthew Jacob born in San Francisco, California, United States, 1958 04/01 Bill Fenner born in Bellefonte, Pennsylvania, United States, 1971 04/01 Peter Edwards born in Dublin, Ireland, 1973 @@ -196,6 +197,7 @@ 06/29 Daniel Harris born in Lubbock, Texas, United States, 1985 06/29 Andrew Pantyukhin born in Moscow, Russian Federation, 1985 06/30 Guido van Rooij born in Best, Noord-Brabant, the Netherlands, 1965 +06/30 Second quarter status reports are due on 07/15 07/01 Matthew Dillon born in San Francisco, California, United States, 1966 07/02 Mark Christopher Ovens born in Preston, Lancashire, United Kingdom, 1958 07/02 Vasil Venelinov Dimov born in Shumen, Bulgaria, 1982 @@ -276,6 +278,7 @@ 09/28 Alex Dupre born in Milano, Italy, 1980 09/29 Matthew Hunt born in Johnstown, Pennsylvania, United States, 1976 09/30 Hiten M. Pandya born in Dar-es-Salaam, Tanzania, East Africa, 1986 +09/30 Third quarter status reports are due on 10/15 10/02 Beat Gaetzi born in Zurich, Switzerland, 1980 10/05 Hiroki Sato born in Yamagata, Japan, 1977 10/05 Chris Costello born in Houston, Texas, United States, 1985 @@ -333,5 +336,6 @@ 12/28 Ade Lovett born in London, England, 1969 12/28 Marius Strobl born in Cham, Bavaria, Germany, 1978 12/31 Edwin Groothuis born in Geldrop, the Netherlands, 1970 +12/31 Fourth quarter status reports are due on 01/15 #endif /* !_calendar_freebsd_ */ From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:32:27 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70C75106564A; Sun, 6 Nov 2011 07:32:27 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 458908FC0A; Sun, 6 Nov 2011 07:32:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67WReO005743; Sun, 6 Nov 2011 07:32:27 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67WRdi005741; Sun, 6 Nov 2011 07:32:27 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060732.pA67WRdi005741@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:32:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227140 - stable/8/usr.bin/calendar/calendars X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:32:27 -0000 Author: dougb Date: Sun Nov 6 07:32:26 2011 New Revision: 227140 URL: http://svn.freebsd.org/changeset/base/227140 Log: MFC r226927: Add birth date for Ken Thompson Add birth and death dates for Steve Jobs Update birth and add death date for Dennis Ritchie MFC r226942: Fix typo from r226927 Modified: stable/8/usr.bin/calendar/calendars/calendar.birthday Directory Properties: stable/8/usr.bin/calendar/ (props changed) Modified: stable/8/usr.bin/calendar/calendars/calendar.birthday ============================================================================== --- stable/8/usr.bin/calendar/calendars/calendar.birthday Sun Nov 6 07:29:51 2011 (r227139) +++ stable/8/usr.bin/calendar/calendars/calendar.birthday Sun Nov 6 07:32:26 2011 (r227140) @@ -42,6 +42,7 @@ 01/30 Franklin Delano Roosevelt born in Hyde Park, New York, 1882 01/31 Jackie Robinson born, 1919 02/03 Gertrude Stein born, 1874 +02/04 Ken Thompson, creator of unix, born, 1943 02/05 Alex Harvey (SAHB) is born in Glasgow, Scotland, 1935 02/06 King George VI of UK dies; his daughter becomes Elizabeth II, 1952 02/07 Sinclair Lewis born, 1885 @@ -68,6 +69,7 @@ 02/22 Pierre Jules Cesar Janssen born, 1838, found hydrogen in the sun 02/23 W.E.B. DuBois born, 1868 02/24 Winslow Homer born, 1836 +02/24 Steve Jobs born, 1955 02/25 George Harrison born in Liverpool, England, 1943 02/25 Renoir born, 1841 02/26 Dominique Francois Jean Arago born, 1786; @@ -212,7 +214,7 @@ 09/08 Richard ``the Lionheart'', king of England born in Oxford, 1157 09/08 Peter Sellers born in Southsea, England, 1925 09/09 Chinese Communist Party Chairman Mao Tse-Tung dies at age 82, 1976 -09/09 Dennis Ritchie born, 1941 +09/09 Dennis MacAlistair Ritchie, creator of C, born, 1941 09/12 Jesse Owens born, 1913 09/13 Walter Reed born, 1851 09/15 Agatha Christie born in Torquay, England, 1890 @@ -239,6 +241,8 @@ 10/02 Mohandas K. Gandhi born at Porbandar, Kathiawad, India, 1869 10/04 John V. Atanasoff born, 1903 10/05 Ray Kroc (founder of McDonald's) born, 1902 +10/05 Steve Jobs died at the age of 56, 2011 +10/12 Dennis MacAlistair Ritchie died at the age of 70, 2011 10/13 Lenny Bruce is born in New York City, 1925 10/13 Virgil (Publius Vergilius Maro) born near Mantua, Italy, 70 BC 10/14 Dwight David Eisenhower, 34th President of the United States, born in From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:43:00 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D79D61065672; Sun, 6 Nov 2011 07:43:00 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC3708FC12; Sun, 6 Nov 2011 07:43:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67h0Ro006313; Sun, 6 Nov 2011 07:43:00 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67h0TG006310; Sun, 6 Nov 2011 07:43:00 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060743.pA67h0TG006310@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:43:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227143 - stable/8/usr.sbin/tzsetup X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:43:01 -0000 Author: dougb Date: Sun Nov 6 07:43:00 2011 New Revision: 227143 URL: http://svn.freebsd.org/changeset/base/227143 Log: MFC r222139: - add missing options and arguments to program's usage() and sync it with manpage's SYNOPSIS - generally clean up a manpage's formatting Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 stable/8/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/8/usr.sbin/tzsetup/ (props changed) Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.8 Sun Nov 6 07:35:08 2011 (r227142) +++ stable/8/usr.sbin/tzsetup/tzsetup.8 Sun Nov 6 07:43:00 2011 (r227143) @@ -23,7 +23,8 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd July 4, 2009 +.\" +.Dd October 21, 2009 .Dt TZSETUP 8 .Os .Sh NAME @@ -32,8 +33,8 @@ .Sh SYNOPSIS .Nm .Op Fl nrs -.Op Fl C Ar chroot directory -.Op Ar zoneinfo file | zoneinfo name +.Op Fl C Ar chroot_directory +.Op Ar zoneinfo_file | zoneinfo_name .Sh DESCRIPTION The .Nm @@ -50,24 +51,25 @@ the hardware clock does not keep .Pp The following option is available: .Bl -tag -offset indent -width Fl -.It Fl C Ar chroot directory +.It Fl C Ar chroot_directory Open all files and directories relative to -.Ar chroot directory . +.Ar chroot_directory . .It Fl n Do not create or copy files. .It Fl r -Reinstall the zoneinfo file installed last time. The name is obtained from +Reinstall the zoneinfo file installed last time. +The name is obtained from .Pa /var/db/zoneinfo . -.It Fl s +.It Fl s Skip the initial question about adjusting the clock if not set to .Tn UTC . .El .Pp It is possible to short-circuit the menu system by specifying the location of a -.Ar zoneinfo file +.Ar zoneinfo_file or the name of the -.Ar zoneinfo name +.Ar zoneinfo_name on the command line; this is intended mainly for pre-configured installation scripts or people who know which zoneinfo they want to install. .Sh TIMEZONE DATABASE @@ -101,38 +103,41 @@ The source code to the database contains many additional comments and documentation references for the historically minded. .Sh FILES -.Bl -tag -width /usr/share/zoneinfo/zone.tab -compact +.Bl -tag -width ".Pa /usr/share/zoneinfo/zone.tab" -compact .It Pa /etc/localtime -current time zone file. +current time zone file .It Pa /etc/wall_cmos_clock see -.Xr adjkerntz 8 . +.Xr adjkerntz 8 .It Pa /usr/share/misc/iso3166 mapping of .Tn ISO -3166 territory codes to names. +3166 territory codes to names .It Pa /usr/share/zoneinfo -directory for zoneinfo files. +directory for zoneinfo files .It Pa /usr/share/zoneinfo/zone.tab -mapping of timezone file to country and location. +mapping of timezone file to country and location .It Pa /var/db/zoneinfo -saved name of the timezone file installed last. +saved name of the timezone file installed last .El .Sh EXAMPLES Normal usage, to select the right zoneinfo file via the dialog-based user interface: -.Dl # tzsetup +.Dl tzsetup +.Pp Install the file .Pa /usr/share/zoneinfo/Australia/Sydney : -.Dl # tzsetup /usr/share/zoneinfo/Australia/Sydney +.Dl "tzsetup /usr/share/zoneinfo/Australia/Sydney" +.Pp Install the zoneinfo file for Australia/Sydney, assumed to be located in .Pa /usr/share/zoneinfo : -.Dl # tzsetup Australia/Sydney +.Dl "tzsetup Australia/Sydney" +.Pp After a reinstall of the zoneinfo files, you can reinstall the -latest installed zoneinfo file: (as specified in -.Pa /var/db/zoneinfo ) -.Dl # tzsetup -r +latest installed zoneinfo file (as specified in +.Pa /var/db/zoneinfo ) : +.Dl "tzsetup -r" .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , Modified: stable/8/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.c Sun Nov 6 07:35:08 2011 (r227142) +++ stable/8/usr.sbin/tzsetup/tzsetup.c Sun Nov 6 07:43:00 2011 (r227143) @@ -731,7 +731,8 @@ static void usage(void) { - fprintf(stderr, "usage: tzsetup [-nrs] [zoneinfo file]\n"); + fprintf(stderr, "usage: tzsetup [-nrs] [-C chroot_directory]" + " [zoneinfo_file | zoneinfo_name]\n"); exit(1); } From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:43:57 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6380106566B; Sun, 6 Nov 2011 07:43:57 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D50D98FC12; Sun, 6 Nov 2011 07:43:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67hv17006394; Sun, 6 Nov 2011 07:43:57 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67hvmF006392; Sun, 6 Nov 2011 07:43:57 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060743.pA67hvmF006392@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:43:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227144 - stable/8/usr.sbin/tzsetup X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:43:58 -0000 Author: dougb Date: Sun Nov 6 07:43:57 2011 New Revision: 227144 URL: http://svn.freebsd.org/changeset/base/227144 Log: MFC 227011: If the user is moving from any other time zone to UTC we need to delete any old /var/db/zoneinfo file that may exist so that tzsetup -r does the right thing. Modified: stable/8/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/8/usr.sbin/tzsetup/ (props changed) Modified: stable/8/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.c Sun Nov 6 07:43:00 2011 (r227143) +++ stable/8/usr.sbin/tzsetup/tzsetup.c Sun Nov 6 07:43:57 2011 (r227144) @@ -565,6 +565,18 @@ install_zoneinfo_file(const char *zonein return (DITEM_FAILURE | DITEM_RECREATE); } + if (unlink(path_db) < 0 && errno != ENOENT) { + snprintf(title, sizeof(title), "Error"); + snprintf(prompt, sizeof(prompt), + "Could not delete %s: %s", path_db, + strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); + + return (DITEM_FAILURE | DITEM_RECREATE); + } return (DITEM_LEAVE_MENU); } From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:54:43 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B6D41065672; Sun, 6 Nov 2011 07:54:43 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49F998FC12; Sun, 6 Nov 2011 07:54:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67sh7v006927; Sun, 6 Nov 2011 07:54:43 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67shEK006925; Sun, 6 Nov 2011 07:54:43 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060754.pA67shEK006925@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:54:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227147 - stable/8/usr.sbin/mergemaster X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:54:43 -0000 Author: dougb Date: Sun Nov 6 07:54:42 2011 New Revision: 227147 URL: http://svn.freebsd.org/changeset/base/227147 Log: MFC r213573: mdoc: drop redundant .Pp and .LP calls They have no effect when coming in pairs, or before .Bl/.Bd Modified: stable/8/usr.sbin/mergemaster/mergemaster.8 Directory Properties: stable/8/usr.sbin/mergemaster/ (props changed) Modified: stable/8/usr.sbin/mergemaster/mergemaster.8 ============================================================================== --- stable/8/usr.sbin/mergemaster/mergemaster.8 Sun Nov 6 07:50:25 2011 (r227146) +++ stable/8/usr.sbin/mergemaster/mergemaster.8 Sun Nov 6 07:54:42 2011 (r227147) @@ -330,7 +330,6 @@ overrides .Pa /etc/mergemaster.rc . Here is an example with all values commented out: -.Pp .Bd -literal # These are options for mergemaster, with their default values listed # The following options have command line overrides From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 07:59:34 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4780106564A; Sun, 6 Nov 2011 07:59:34 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9ADC8FC0A; Sun, 6 Nov 2011 07:59:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA67xYj8007143; Sun, 6 Nov 2011 07:59:34 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA67xYRc007140; Sun, 6 Nov 2011 07:59:34 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111060759.pA67xYRc007140@svn.freebsd.org> From: Doug Barton Date: Sun, 6 Nov 2011 07:59:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227148 - stable/8/usr.sbin/mergemaster X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 07:59:35 -0000 Author: dougb Date: Sun Nov 6 07:59:34 2011 New Revision: 227148 URL: http://svn.freebsd.org/changeset/base/227148 Log: MFC r227013: 1. Add a new option, --run-updates, to always or never run the newalises, pwd_mkdb, etc. updates at the end of the comparison. 2. Add an update to the end to handle /etc/localtime, if it exists. If /var/db/zoneinfo exists, automatically update /etc/localtime, which should (hopefully) be safe to do. If not, prompt the user to run tzsetup. 3. Update run_it_now(), the function that handles input for the updates, to make sure that we got a valid answer, and to handle the --run-updates option if supplied. Modified: stable/8/usr.sbin/mergemaster/mergemaster.8 stable/8/usr.sbin/mergemaster/mergemaster.sh Directory Properties: stable/8/usr.sbin/mergemaster/ (props changed) Modified: stable/8/usr.sbin/mergemaster/mergemaster.8 ============================================================================== --- stable/8/usr.sbin/mergemaster/mergemaster.8 Sun Nov 6 07:54:42 2011 (r227147) +++ stable/8/usr.sbin/mergemaster/mergemaster.8 Sun Nov 6 07:59:34 2011 (r227148) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 9, 2011 +.Dd November 1, 2011 .Dt MERGEMASTER 8 .Os .Sh NAME @@ -34,6 +34,7 @@ .Nm .Op Fl scrvhpCP .Op Fl a|iFU +.Op Fl -run-updates=[always|never] .Op Fl m Ar /path/to/sources .Op Fl t Ar /path/to/temp/root .Op Fl d @@ -246,6 +247,11 @@ rc file. Attempt to auto upgrade files that have not been user modified. This option can be dangerous when there are critical changes in the new versions that affect your running system. +.It Fl -run-updates=[always|never] +Specify always or never to run newaliases, pwd_mkdb, etc. +at the end of the comparison run. +If this option is omitted the default is to prompt the user +for each update as necessary. .It Fl m Ar /path/to/sources Specify the path to the directory where you want to do the .Xr make 1 . @@ -365,6 +371,9 @@ with all values commented out: # ***DANGEROUS*** #AUTO_UPGRADE= # +# Either always or never run newaliases, pwd_mkdb at the end (--run-updates) +#RUN_UPDATES= +# # Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf (-C) #COMP_CONFS= # Modified: stable/8/usr.sbin/mergemaster/mergemaster.sh ============================================================================== --- stable/8/usr.sbin/mergemaster/mergemaster.sh Sun Nov 6 07:54:42 2011 (r227147) +++ stable/8/usr.sbin/mergemaster/mergemaster.sh Sun Nov 6 07:59:34 2011 (r227148) @@ -15,7 +15,7 @@ PATH=/bin:/usr/bin:/usr/sbin display_usage () { VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` echo "mergemaster version ${VERSION_NUMBER}" - echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]]' + echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]] [--run-updates=always|never]' echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]' echo "Options:" echo " -s Strict comparison (diff every pair of files)" @@ -31,6 +31,7 @@ display_usage () { echo ' -P Preserve files that are overwritten' echo " -U Attempt to auto upgrade files that have not been user modified" echo ' ***DANGEROUS***' + echo ' --run-updates= Specify always or never to run newalises, pwd_mkdb, etc.' echo '' echo " -m /path/directory Specify location of source to do the make in" echo " -t /path/directory Specify temp root directory" @@ -262,6 +263,20 @@ if [ -r "$HOME/.mergemasterrc" ]; then . "$HOME/.mergemasterrc" fi +for var in "$@" ; do + case "$var" in + --run-updates*) + RUN_UPDATES=`echo ${var#--run-updates=} | tr [:upper:] [:lower:]` + ;; + *) + newopts="$newopts $var" + ;; + esac +done + +set -- $newopts +unset var newopts + # Check the command line options # while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do @@ -1226,34 +1241,43 @@ case "${AUTO_UPGRADED_FILES}" in esac run_it_now () { - case "${AUTO_RUN}" in - '') - unset YES_OR_NO - echo '' - echo -n ' Would you like to run it now? y or n [n] ' - read YES_OR_NO + [ -n "$AUTO_RUN" ] && return + + local answer + + echo '' + while : ; do + if [ "$RUN_UPDATES" = always ]; then + answer=y + elif [ "$RUN_UPDATES" = never ]; then + answer=n + else + echo -n ' Would you like to run it now? y or n [n] ' + read answer + fi - case "${YES_OR_NO}" in + case "$answer" in y) echo " Running ${1}" echo '' eval "${1}" + return ;; ''|n) - echo '' - echo " *** Cancelled" - echo '' + if [ ! "$RUN_UPDATES" = never ]; then + echo '' + echo " *** Cancelled" + echo '' + fi echo " Make sure to run ${1} yourself" + return ;; *) echo '' - echo " *** Sorry, I do not understand your answer (${YES_OR_NO})" + echo " *** Sorry, I do not understand your answer (${answer})" echo '' - echo " Make sure to run ${1} yourself" esac - ;; - *) ;; - esac + done } case "${NEED_NEWALIASES}" in @@ -1312,6 +1336,19 @@ case "${NEED_PWD_MKDB}" in ;; esac +if [ -e "${DESTDIR}/etc/localtime" ]; then # Ignore if TZ == UTC + echo '' + if [ -f "${DESTDIR}/var/db/zoneinfo" ]; then + echo "*** Reinstalling `cat ${DESTDIR}/var/db/zoneinfo` as ${DESTDIR}/etc/localtime" + [ -n "${DESTDIR}" ] && tzs_args="-C ${DESTDIR}" + tzsetup $tzs_args -r + else + echo "*** There is no ${DESTDIR}/var/db/zoneinfo file to update ${DESTDIR}/etc/localtime." + echo ' You should run tzsetup' + run_it_now tzsetup + fi +fi + echo '' if [ -r "${MM_EXIT_SCRIPT}" ]; then From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 09:27:40 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7B4D106564A; Sun, 6 Nov 2011 09:27:40 +0000 (UTC) (envelope-from fjoe@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9715E8FC14; Sun, 6 Nov 2011 09:27:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA69ReaK012431; Sun, 6 Nov 2011 09:27:40 GMT (envelope-from fjoe@svn.freebsd.org) Received: (from fjoe@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA69Re1B012429; Sun, 6 Nov 2011 09:27:40 GMT (envelope-from fjoe@svn.freebsd.org) Message-Id: <201111060927.pA69Re1B012429@svn.freebsd.org> From: Max Khon Date: Sun, 6 Nov 2011 09:27:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227205 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 09:27:40 -0000 Author: fjoe Date: Sun Nov 6 09:27:40 2011 New Revision: 227205 URL: http://svn.freebsd.org/changeset/base/227205 Log: Fix the build with KLD_DEBUG defined. Modified: stable/8/sys/kern/kern_linker.c Modified: stable/8/sys/kern/kern_linker.c ============================================================================== --- stable/8/sys/kern/kern_linker.c Sun Nov 6 09:17:48 2011 (r227204) +++ stable/8/sys/kern/kern_linker.c Sun Nov 6 09:27:40 2011 (r227205) @@ -632,7 +632,7 @@ linker_file_unload(linker_file_t file, i */ if ((error = module_unload(mod)) != 0) { KLD_DPF(FILE, ("linker_file_unload: module %s" - " failed unload\n", mod)); + " failed unload\n", module_getname(mod))); return (error); } MOD_XLOCK; From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 13:02:33 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABD69106564A; Sun, 6 Nov 2011 13:02:33 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B2988FC13; Sun, 6 Nov 2011 13:02:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6D2XM9022355; Sun, 6 Nov 2011 13:02:33 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6D2XN7022353; Sun, 6 Nov 2011 13:02:33 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <201111061302.pA6D2XN7022353@svn.freebsd.org> From: Christian Brueffer Date: Sun, 6 Nov 2011 13:02:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227209 - stable/8/libexec/rshd X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 13:02:33 -0000 Author: brueffer Date: Sun Nov 6 13:02:33 2011 New Revision: 227209 URL: http://svn.freebsd.org/changeset/base/227209 Log: MFC: r226937 Fix a misplaced parenthesis. Modified: stable/8/libexec/rshd/rshd.c Directory Properties: stable/8/libexec/rshd/ (props changed) Modified: stable/8/libexec/rshd/rshd.c ============================================================================== --- stable/8/libexec/rshd/rshd.c Sun Nov 6 12:37:44 2011 (r227208) +++ stable/8/libexec/rshd/rshd.c Sun Nov 6 13:02:33 2011 (r227209) @@ -317,7 +317,7 @@ doit(struct sockaddr *fromp) } if ((pam_err = pam_set_item(pamh, PAM_RUSER, ruser)) != PAM_SUCCESS || - (pam_err = pam_set_item(pamh, PAM_RHOST, rhost) != PAM_SUCCESS)) { + (pam_err = pam_set_item(pamh, PAM_RHOST, rhost)) != PAM_SUCCESS) { syslog(LOG_ERR|LOG_AUTH, "pam_set_item(): %s", pam_strerror(pamh, pam_err)); rshd_errx(1, "Login incorrect."); From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 13:17:37 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A65B106566B; Sun, 6 Nov 2011 13:17:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89FF68FC17; Sun, 6 Nov 2011 13:17:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6DHbCW022988; Sun, 6 Nov 2011 13:17:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6DHb4t022986; Sun, 6 Nov 2011 13:17:37 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201111061317.pA6DHb4t022986@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 6 Nov 2011 13:17:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227212 - stable/8/sys/fs/devfs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 13:17:37 -0000 Author: kib Date: Sun Nov 6 13:17:37 2011 New Revision: 227212 URL: http://svn.freebsd.org/changeset/base/227212 Log: MFC r227062: Fix kernel panic when d_fdopen csw method is called for NULL fp. This may happen when kernel consumer calls VOP_OPEN(). Modified: stable/8/sys/fs/devfs/devfs_vnops.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/8/sys/fs/devfs/devfs_vnops.c Sun Nov 6 13:06:31 2011 (r227211) +++ stable/8/sys/fs/devfs/devfs_vnops.c Sun Nov 6 13:17:37 2011 (r227212) @@ -982,6 +982,10 @@ devfs_open(struct vop_open_args *ap) dsw = dev_refthread(dev, &ref); if (dsw == NULL) return (ENXIO); + if (fp == NULL && dsw->d_fdopen != NULL) { + dev_relthread(dev, ref); + return (ENXIO); + } vlocked = VOP_ISLOCKED(vp); VOP_UNLOCK(vp, 0); From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 15:13:02 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A23B1065672; Sun, 6 Nov 2011 15:13:02 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 695F88FC1F; Sun, 6 Nov 2011 15:13:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6FD2tm027287; Sun, 6 Nov 2011 15:13:02 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6FD25t027285; Sun, 6 Nov 2011 15:13:02 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201111061513.pA6FD25t027285@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 6 Nov 2011 15:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227217 - stable/8/sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 15:13:02 -0000 Author: hselasky Date: Sun Nov 6 15:13:01 2011 New Revision: 227217 URL: http://svn.freebsd.org/changeset/base/227217 Log: MFC r227075: Fix for panic at USB controller attach failure during cold boot. Modified: stable/8/sys/dev/usb/usb_process.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/usb_process.c ============================================================================== --- stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:06:04 2011 (r227216) +++ stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:13:01 2011 (r227217) @@ -67,11 +67,13 @@ static int usb_pcount; #define USB_THREAD_CREATE(f, s, p, ...) \ kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ 0, "usb", __VA_ARGS__) +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() #define USB_THREAD_SUSPEND(p) kthread_suspend(p,0) #define USB_THREAD_EXIT(err) kthread_exit() #else #define USB_THREAD_CREATE(f, s, p, ...) \ kthread_create((f), (s), (p), RFHIGHPID, 0, __VA_ARGS__) +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() #define USB_THREAD_SUSPEND(p) kthread_suspend(p,0) #define USB_THREAD_EXIT(err) kthread_exit(err) #endif @@ -98,6 +100,9 @@ usb_process(void *arg) struct usb_proc_msg *pm; struct thread *td; + /* in case of attach error, check for suspended */ + USB_THREAD_SUSPEND_CHECK(); + /* adjust priority */ td = curthread; thread_lock(td); From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 16:58:17 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF279106564A; Sun, 6 Nov 2011 16:58:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE8FB8FC0C; Sun, 6 Nov 2011 16:58:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6GwH4o031507; Sun, 6 Nov 2011 16:58:17 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6GwHRk031505; Sun, 6 Nov 2011 16:58:17 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201111061658.pA6GwHRk031505@svn.freebsd.org> From: Alexander Motin Date: Sun, 6 Nov 2011 16:58:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227227 - stable/8/sys/geom X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 16:58:18 -0000 Author: mav Date: Sun Nov 6 16:58:17 2011 New Revision: 227227 URL: http://svn.freebsd.org/changeset/base/227227 Log: MFC r226985: Workaround the problem introduced by combination of r162200 and r215687. r162200 delays provider orphanization until all running requests complete, to workaround broken orphan() method implementation in some classes. r215687 removes persistent periodic (10Hz) event thread wake ups. Together these changes can indefinitely delay orphanization until some other event wake up the event thread. One consequence of this is inability of CAM to destroy device disconnected when busy and, as consequence, create new one after reconnection. While the best solution would be to revert r162200, it is not easy, as some classes still broken in that way. Instead conditionally wake up event thread if there are some providers waiting for orphanization. Modified: stable/8/sys/geom/geom_event.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/geom/geom_event.c ============================================================================== --- stable/8/sys/geom/geom_event.c Sun Nov 6 16:54:23 2011 (r227226) +++ stable/8/sys/geom/geom_event.c Sun Nov 6 16:58:17 2011 (r227227) @@ -247,7 +247,7 @@ g_run_events() } else { g_topology_unlock(); msleep(&g_wait_event, &g_eventlock, PRIBIO | PDROP, - "-", 0); + "-", TAILQ_EMPTY(&g_doorstep) ? 0 : hz / 10); } } /* NOTREACHED */ From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 19:47:45 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9A6E106566C; Sun, 6 Nov 2011 19:47:45 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 4F9DF8FC1E; Sun, 6 Nov 2011 19:47:44 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id pA6Jlh4p084174; Sun, 6 Nov 2011 20:47:44 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id pA6JlhGJ084173; Sun, 6 Nov 2011 20:47:43 +0100 (CET) (envelope-from marius) Date: Sun, 6 Nov 2011 20:47:43 +0100 From: Marius Strobl To: Hans Petter Selasky Message-ID: <20111106194743.GD56603@alchemy.franken.de> References: <201111061513.pA6FD25t027285@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201111061513.pA6FD25t027285@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r227217 - stable/8/sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 19:47:45 -0000 On Sun, Nov 06, 2011 at 03:13:02PM +0000, Hans Petter Selasky wrote: > Author: hselasky > Date: Sun Nov 6 15:13:01 2011 > New Revision: 227217 > URL: http://svn.freebsd.org/changeset/base/227217 > > Log: > MFC r227075: > Fix for panic at USB controller attach failure during cold boot. > > Modified: > stable/8/sys/dev/usb/usb_process.c > Directory Properties: > stable/8/sys/ (props changed) > stable/8/sys/amd64/include/xen/ (props changed) > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > stable/8/sys/contrib/dev/acpica/ (props changed) > stable/8/sys/contrib/pf/ (props changed) > > Modified: stable/8/sys/dev/usb/usb_process.c > ============================================================================== > --- stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:06:04 2011 (r227216) > +++ stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:13:01 2011 (r227217) > @@ -67,11 +67,13 @@ static int usb_pcount; > #define USB_THREAD_CREATE(f, s, p, ...) \ > kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ > 0, "usb", __VA_ARGS__) > +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() In stable/8 kthread_suspend_check(9) takes an struct thread * argument. Marius From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 19:57:15 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 013C11065672; Sun, 6 Nov 2011 19:57:15 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E4BCE8FC1D; Sun, 6 Nov 2011 19:57:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6JvEgW039056; Sun, 6 Nov 2011 19:57:14 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6JvEKL039054; Sun, 6 Nov 2011 19:57:14 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201111061957.pA6JvEKL039054@svn.freebsd.org> From: Marius Strobl Date: Sun, 6 Nov 2011 19:57:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227264 - stable/8/sys/dev/mpt X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 19:57:15 -0000 Author: marius Date: Sun Nov 6 19:57:14 2011 New Revision: 227264 URL: http://svn.freebsd.org/changeset/base/227264 Log: MFC: r227001 Increase the IOC port initialization timeouts by ten times to what the corresponding Linux driver uses. This allows mpt(4) to still recognize all good SATA devices in presence of a defective one, which takes about 45 seconds. In the long term we probably should implement the logic used by mpt2sas(4) allowing IOC port initialization to complete at a later time. Submitted by: Andrew Boyer Modified: stable/8/sys/dev/mpt/mpt.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/mpt/mpt.c ============================================================================== --- stable/8/sys/dev/mpt/mpt.c Sun Nov 6 19:05:42 2011 (r227263) +++ stable/8/sys/dev/mpt/mpt.c Sun Nov 6 19:57:14 2011 (r227264) @@ -2084,7 +2084,7 @@ mpt_send_port_enable(struct mpt_softc *m mpt_send_cmd(mpt, req); error = mpt_wait_req(mpt, req, REQ_STATE_DONE, REQ_STATE_DONE, - FALSE, (mpt->is_sas || mpt->is_fc)? 30000 : 3000); + FALSE, (mpt->is_sas || mpt->is_fc)? 300000 : 30000); if (error != 0) { mpt_prt(mpt, "port %d enable timed out\n", port); return (-1); From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 20:38:02 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC468106566C; Sun, 6 Nov 2011 20:38:02 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 29EA48FC12; Sun, 6 Nov 2011 20:38:01 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id pA6Kc0Dl084442; Sun, 6 Nov 2011 21:38:00 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id pA6Kc0t0084441; Sun, 6 Nov 2011 21:38:00 +0100 (CET) (envelope-from marius) Date: Sun, 6 Nov 2011 21:38:00 +0100 From: Marius Strobl To: Hans Petter Selasky Message-ID: <20111106203800.GE56603@alchemy.franken.de> References: <201111061513.pA6FD25t027285@svn.freebsd.org> <20111106194743.GD56603@alchemy.franken.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111106194743.GD56603@alchemy.franken.de> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r227217 - stable/8/sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 20:38:02 -0000 On Sun, Nov 06, 2011 at 08:47:43PM +0100, Marius Strobl wrote: > On Sun, Nov 06, 2011 at 03:13:02PM +0000, Hans Petter Selasky wrote: > > Author: hselasky > > Date: Sun Nov 6 15:13:01 2011 > > New Revision: 227217 > > URL: http://svn.freebsd.org/changeset/base/227217 > > > > Log: > > MFC r227075: > > Fix for panic at USB controller attach failure during cold boot. > > > > Modified: > > stable/8/sys/dev/usb/usb_process.c > > Directory Properties: > > stable/8/sys/ (props changed) > > stable/8/sys/amd64/include/xen/ (props changed) > > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > > stable/8/sys/contrib/dev/acpica/ (props changed) > > stable/8/sys/contrib/pf/ (props changed) > > > > Modified: stable/8/sys/dev/usb/usb_process.c > > ============================================================================== > > --- stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:06:04 2011 (r227216) > > +++ stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:13:01 2011 (r227217) > > @@ -67,11 +67,13 @@ static int usb_pcount; > > #define USB_THREAD_CREATE(f, s, p, ...) \ > > kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ > > 0, "usb", __VA_ARGS__) > > +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() > > In stable/8 kthread_suspend_check(9) takes an struct thread * argument. > Sorry, I didn't look closely enough, it probably should use the same approach as hptmv(4): #if (__FreeBSD_version >= 800002) kproc_suspend_check(curproc); #elif (__FreeBSD_version >= 500043) kthread_suspend_check(curproc); #else kproc_suspend_loop(curproc); #endif In any case, r227217 broke kernel compilation of stable/8. Marius From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 21:09:24 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48B9F106564A; Sun, 6 Nov 2011 21:09:24 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34E7A8FC0C; Sun, 6 Nov 2011 21:09:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6L9O37042073; Sun, 6 Nov 2011 21:09:24 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6L9OLV042060; Sun, 6 Nov 2011 21:09:24 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201111062109.pA6L9OLV042060@svn.freebsd.org> From: Marius Strobl Date: Sun, 6 Nov 2011 21:09:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227278 - in stable/8/sys: arm/conf conf dev/bm dev/dc dev/mii dev/nge dev/sis dev/smc dev/ste dev/stge dev/tl dev/wb dev/xl modules/mii pci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 21:09:24 -0000 Author: marius Date: Sun Nov 6 21:09:23 2011 New Revision: 227278 URL: http://svn.freebsd.org/changeset/base/227278 Log: MFC: r226995, r227042 - Import the common MII bitbang'ing code from NetBSD and convert drivers to take advantage of it instead of duplicating it. This reduces the size of the i386 GENERIC kernel by about 8k. The only potential in-tree users left unconverted are ed(4) and xe(4). Xe(4) generally should be changed to use miibus(4) instead of implementing PHY handling on its own, as otherwise it makes not much sense to add a dependency on miibus(4)/mii_bitbang(4) to it just for the MII bitbang'ing code. Ed(4) has some chip specific things interwinded with the MII bitbang'ing code and it's unclear whether it can be converted to common code, at least not without thorough testing of all the various chips supported by ed(4). The common MII bitbang'ing code also is useful in the embedded space for using GPIO pins to implement MII access. - Based on lessons learnt with dc(4) (see r185750), add bus barriers to the MII bitbang read and write functions of the other drivers converted in order to ensure the intended ordering. Given that register access via an index register as well as register bank/window switching is subject to the same problem, also add bus barriers to the respective functions of smc(4), tl(4) and xl(4). - Sprinkle some const. Thanks to the following testers: Andrew Bliznak (nge(4)), nwhitehorn@ (bm(4)), yongari@ (sis(4) and ste(4)) Thanks to Hans-Joerg Sirtl for supplying hardware to test stge(4). Reviewed by: yongari (subset of drivers) Obtained from: NetBSD (partially) Added: stable/8/sys/dev/mii/mii_bitbang.c - copied unchanged from r226995, head/sys/dev/mii/mii_bitbang.c stable/8/sys/dev/mii/mii_bitbang.h - copied unchanged from r226995, head/sys/dev/mii/mii_bitbang.h Modified: stable/8/sys/arm/conf/GUMSTIX stable/8/sys/conf/NOTES stable/8/sys/conf/files stable/8/sys/dev/bm/if_bm.c stable/8/sys/dev/bm/if_bmreg.h stable/8/sys/dev/bm/if_bmvar.h stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h stable/8/sys/dev/nge/if_nge.c stable/8/sys/dev/nge/if_ngereg.h stable/8/sys/dev/sis/if_sis.c stable/8/sys/dev/sis/if_sisreg.h stable/8/sys/dev/smc/if_smc.c stable/8/sys/dev/ste/if_ste.c stable/8/sys/dev/ste/if_stereg.h stable/8/sys/dev/stge/if_stge.c stable/8/sys/dev/stge/if_stgereg.h stable/8/sys/dev/tl/if_tl.c stable/8/sys/dev/tl/if_tlreg.h stable/8/sys/dev/wb/if_wb.c stable/8/sys/dev/wb/if_wbreg.h stable/8/sys/dev/xl/if_xl.c stable/8/sys/dev/xl/if_xlreg.h stable/8/sys/modules/mii/Makefile stable/8/sys/pci/if_rl.c stable/8/sys/pci/if_rlreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/arm/conf/GUMSTIX ============================================================================== --- stable/8/sys/arm/conf/GUMSTIX Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/arm/conf/GUMSTIX Sun Nov 6 21:09:23 2011 (r227278) @@ -72,6 +72,7 @@ options PREEMPTION device loop device ether device mii +device mii_bitbang device smc device smcphy device uart Modified: stable/8/sys/conf/NOTES ============================================================================== --- stable/8/sys/conf/NOTES Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/conf/NOTES Sun Nov 6 21:09:23 2011 (r227278) @@ -1819,13 +1819,15 @@ device puc # MII bus support is required for many PCI Ethernet NICs, # namely those which use MII-compliant transceivers or implement # transceiver control interfaces that operate like an MII. Adding -# "device miibus" to the kernel config pulls in support for -# the generic miibus API and all of the PHY drivers, including a -# generic one for PHYs that aren't specifically handled by an -# individual driver. Support for specific PHYs may be built by adding -# "device mii" then adding the appropriate PHY driver. -device miibus # MII support including all PHYs +# "device miibus" to the kernel config pulls in support for the generic +# miibus API, the common support for for bit-bang'ing the MII and all +# of the PHY drivers, including a generic one for PHYs that aren't +# specifically handled by an individual driver. Support for specific +# PHYs may be built by adding "device mii", "device mii_bitbang" if +# needed by the NIC driver and then adding the appropriate PHY driver. device mii # Minimal MII support +device mii_bitbang # Common module for bit-bang'ing the MII +device miibus # MII support w/ bit-bang'ing and all PHYs device acphy # Altima Communications AC101 device amphy # AMD AM79c873 / Davicom DM910{1,2} Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/conf/files Sun Nov 6 21:09:23 2011 (r227278) @@ -1309,6 +1309,7 @@ dev/mii/ip1000phy.c optional miibus | i dev/mii/jmphy.c optional miibus | jmphy dev/mii/lxtphy.c optional miibus | lxtphy dev/mii/mii.c optional miibus | mii +dev/mii/mii_bitbang.c optional miibus | mii_bitbang dev/mii/mii_physubr.c optional miibus | mii dev/mii/miibus_if.m optional miibus | mii dev/mii/mlphy.c optional miibus | mlphy Modified: stable/8/sys/dev/bm/if_bm.c ============================================================================== --- stable/8/sys/dev/bm/if_bm.c Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/bm/if_bm.c Sun Nov 6 21:09:23 2011 (r227278) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -105,17 +106,28 @@ static void bm_tick (void *xsc); static int bm_ifmedia_upd (struct ifnet *); static void bm_ifmedia_sts (struct ifnet *, struct ifmediareq *); -static void bm_miicsr_dwrite (struct bm_softc *, u_int16_t); -static void bm_mii_writebit (struct bm_softc *, int); -static int bm_mii_readbit (struct bm_softc *); -static void bm_mii_sync (struct bm_softc *); -static void bm_mii_send (struct bm_softc *, u_int32_t, int); -static int bm_mii_readreg (struct bm_softc *, struct bm_mii_frame *); -static int bm_mii_writereg (struct bm_softc *, struct bm_mii_frame *); static int bm_miibus_readreg (device_t, int, int); static int bm_miibus_writereg (device_t, int, int, int); static void bm_miibus_statchg (device_t); +/* + * MII bit-bang glue + */ +static uint32_t bm_mii_bitbang_read(device_t); +static void bm_mii_bitbang_write(device_t, uint32_t); + +static const struct mii_bitbang_ops bm_mii_bitbang_ops = { + bm_mii_bitbang_read, + bm_mii_bitbang_write, + { + BM_MII_DATAOUT, /* MII_BIT_MDO */ + BM_MII_DATAIN, /* MII_BIT_MDI */ + BM_MII_CLK, /* MII_BIT_MDC */ + BM_MII_OENABLE, /* MII_BIT_DIR_HOST_PHY */ + 0, /* MII_BIT_DIR_PHY_HOST */ + } +}; + static device_method_t bm_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bm_probe), @@ -150,171 +162,36 @@ DRIVER_MODULE(miibus, bm, miibus_driver, */ /* - * Write to the MII csr, introducing a delay to allow valid - * MII clock pulses to be formed - */ -static void -bm_miicsr_dwrite(struct bm_softc *sc, u_int16_t val) -{ - CSR_WRITE_2(sc, BM_MII_CSR, val); - /* - * Assume this is a clock toggle and generate a 1us delay - * to cover both MII's 160ns high/low minimum and 400ns - * cycle miniumum - */ - DELAY(1); -} - -/* - * Write a bit to the MII bus. - */ -static void -bm_mii_writebit(struct bm_softc *sc, int bit) -{ - u_int16_t regval; - - regval = BM_MII_OENABLE; - if (bit) - regval |= BM_MII_DATAOUT; - - bm_miicsr_dwrite(sc, regval); - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); - bm_miicsr_dwrite(sc, regval); -} - -/* - * Read a bit from the MII bus. - */ -static int -bm_mii_readbit(struct bm_softc *sc) -{ - u_int16_t regval, bitin; - - /* ~BM_MII_OENABLE */ - regval = 0; - - bm_miicsr_dwrite(sc, regval); - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); - bm_miicsr_dwrite(sc, regval); - bitin = CSR_READ_2(sc, BM_MII_CSR) & BM_MII_DATAIN; - - return (bitin == BM_MII_DATAIN); -} - -/* - * Sync the PHYs by setting data bit and strobing the clock 32 times. + * Write the MII serial port for the MII bit-bang module. */ static void -bm_mii_sync(struct bm_softc *sc) +bm_mii_bitbang_write(device_t dev, uint32_t val) { - int i; - u_int16_t regval; - - regval = BM_MII_OENABLE | BM_MII_DATAOUT; - - bm_miicsr_dwrite(sc, regval); - for (i = 0; i < 32; i++) { - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); - bm_miicsr_dwrite(sc, regval); - } -} - -/* - * Clock a series of bits through the MII. - */ -static void -bm_mii_send(struct bm_softc *sc, u_int32_t bits, int cnt) -{ - int i; - - for (i = (0x1 << (cnt - 1)); i; i >>= 1) - bm_mii_writebit(sc, bits & i); -} - -/* - * Read a PHY register through the MII. - */ -static int -bm_mii_readreg(struct bm_softc *sc, struct bm_mii_frame *frame) -{ - int i, ack, bit; - - /* - * Set up frame for RX. - */ - frame->mii_stdelim = BM_MII_STARTDELIM; - frame->mii_opcode = BM_MII_READOP; - frame->mii_turnaround = 0; - frame->mii_data = 0; - - /* - * Sync the PHYs - */ - bm_mii_sync(sc); - - /* - * Send command/address info - */ - bm_mii_send(sc, frame->mii_stdelim, 2); - bm_mii_send(sc, frame->mii_opcode, 2); - bm_mii_send(sc, frame->mii_phyaddr, 5); - bm_mii_send(sc, frame->mii_regaddr, 5); - - /* - * Check for ack. - */ - ack = bm_mii_readbit(sc); - - /* - * Now try reading data bits. If the ack failed, we still - * need to clock through 16 cycles to keep the PHY(s) in sync. - */ - for (i = 0x8000; i; i >>= 1) { - bit = bm_mii_readbit(sc); - if (!ack && bit) - frame->mii_data |= i; - } + struct bm_softc *sc; - /* - * Skip through idle bit-times - */ - bm_mii_writebit(sc, 0); - bm_mii_writebit(sc, 0); + sc = device_get_softc(dev); - return ((ack) ? 1 : 0); + CSR_WRITE_2(sc, BM_MII_CSR, val); + CSR_BARRIER(sc, BM_MII_CSR, 2, + BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); } /* - * Write to a PHY register through the MII. + * Read the MII serial port for the MII bit-bang module. */ -static int -bm_mii_writereg(struct bm_softc *sc, struct bm_mii_frame *frame) +static uint32_t +bm_mii_bitbang_read(device_t dev) { - /* - * Set up frame for tx - */ - frame->mii_stdelim = BM_MII_STARTDELIM; - frame->mii_opcode = BM_MII_WRITEOP; - frame->mii_turnaround = BM_MII_TURNAROUND; - - /* - * Sync the phy and start the bitbang write sequence - */ - bm_mii_sync(sc); + struct bm_softc *sc; + uint32_t reg; - bm_mii_send(sc, frame->mii_stdelim, 2); - bm_mii_send(sc, frame->mii_opcode, 2); - bm_mii_send(sc, frame->mii_phyaddr, 5); - bm_mii_send(sc, frame->mii_regaddr, 5); - bm_mii_send(sc, frame->mii_turnaround, 2); - bm_mii_send(sc, frame->mii_data, 16); + sc = device_get_softc(dev); - /* - * Idle bit. - */ - bm_mii_writebit(sc, 0); + reg = CSR_READ_2(sc, BM_MII_CSR); + CSR_BARRIER(sc, BM_MII_CSR, 2, + BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - return (0); + return (reg); } /* @@ -323,34 +200,15 @@ bm_mii_writereg(struct bm_softc *sc, str static int bm_miibus_readreg(device_t dev, int phy, int reg) { - struct bm_softc *sc; - struct bm_mii_frame frame; - - sc = device_get_softc(dev); - bzero(&frame, sizeof(frame)); - - frame.mii_phyaddr = phy; - frame.mii_regaddr = reg; - bm_mii_readreg(sc, &frame); - - return (frame.mii_data); + return (mii_bitbang_readreg(dev, &bm_mii_bitbang_ops, phy, reg)); } static int bm_miibus_writereg(device_t dev, int phy, int reg, int data) { - struct bm_softc *sc; - struct bm_mii_frame frame; - - sc = device_get_softc(dev); - bzero(&frame, sizeof(frame)); - - frame.mii_phyaddr = phy; - frame.mii_regaddr = reg; - frame.mii_data = data; - bm_mii_writereg(sc, &frame); + mii_bitbang_readreg(dev, &bm_mii_bitbang_ops, phy, reg); return (0); } Modified: stable/8/sys/dev/bm/if_bmreg.h ============================================================================== --- stable/8/sys/dev/bm/if_bmreg.h Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/bm/if_bmreg.h Sun Nov 6 21:09:23 2011 (r227278) @@ -129,14 +129,6 @@ #define BM_MII_DATAIN 0x0008 /* MDIO data in */ /* - * MII constants - */ -#define BM_MII_STARTDELIM 0x01 -#define BM_MII_READOP 0x02 -#define BM_MII_WRITEOP 0x01 -#define BM_MII_TURNAROUND 0x02 - -/* * Various flags */ @@ -174,3 +166,5 @@ #define CSR_READ_1(sc, reg) \ bus_read_1(sc->sc_memr, reg) +#define CSR_BARRIER(sc, reg, length, flags) \ + bus_barrier(sc->sc_memr, reg, length, flags) Modified: stable/8/sys/dev/bm/if_bmvar.h ============================================================================== --- stable/8/sys/dev/bm/if_bmvar.h Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/bm/if_bmvar.h Sun Nov 6 21:09:23 2011 (r227278) @@ -46,7 +46,6 @@ /* * software state for transmit job mbufs (may be elements of mbuf chains) */ - struct bm_txsoft { struct mbuf *txs_mbuf; /* head of our mbuf chain */ bus_dmamap_t txs_dmamap; /* our DMA map */ @@ -71,7 +70,6 @@ struct bm_rxsoft { bus_dma_segment_t segment; }; - struct bm_softc { struct ifnet *sc_ifp; struct mtx sc_mtx; @@ -113,13 +111,3 @@ struct bm_softc { dbdma_channel_t *sc_txdma, *sc_rxdma; }; - -struct bm_mii_frame { - u_int8_t mii_stdelim; - u_int8_t mii_opcode; - u_int8_t mii_phyaddr; - u_int8_t mii_regaddr; - u_int8_t mii_turnaround; - u_int16_t mii_data; -}; - Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/dc/if_dc.c Sun Nov 6 21:09:23 2011 (r227278) @@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -149,7 +150,7 @@ MODULE_DEPEND(dc, miibus, 1, 1, 1); /* * Various supported device vendors/types and their names. */ -static const struct dc_type dc_devs[] = { +static const struct dc_type const dc_devs[] = { { DC_DEVID(DC_VENDORID_DEC, DC_DEVICEID_21143), 0, "Intel 21143 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009), 0, @@ -267,12 +268,6 @@ static void dc_eeprom_getword_xircom(str static void dc_eeprom_width(struct dc_softc *); static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); -static void dc_mii_writebit(struct dc_softc *, int); -static int dc_mii_readbit(struct dc_softc *); -static void dc_mii_sync(struct dc_softc *); -static void dc_mii_send(struct dc_softc *, uint32_t, int); -static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); -static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); static int dc_miibus_readreg(device_t, int, int); static int dc_miibus_writereg(device_t, int, int, int); static void dc_miibus_statchg(device_t); @@ -301,6 +296,24 @@ static int dc_decode_leaf_sym(struct dc_ static void dc_apply_fixup(struct dc_softc *, int); static int dc_check_multiport(struct dc_softc *); +/* + * MII bit-bang glue + */ +static uint32_t dc_mii_bitbang_read(device_t); +static void dc_mii_bitbang_write(device_t, uint32_t); + +static const struct mii_bitbang_ops dc_mii_bitbang_ops = { + dc_mii_bitbang_read, + dc_mii_bitbang_write, + { + DC_SIO_MII_DATAOUT, /* MII_BIT_MDO */ + DC_SIO_MII_DATAIN, /* MII_BIT_MDI */ + DC_SIO_MII_CLK, /* MII_BIT_MDC */ + 0, /* MII_BIT_DIR_HOST_PHY */ + DC_SIO_MII_DIR, /* MII_BIT_DIR_PHY_HOST */ + } +}; + #ifdef DC_USEIOSPACE #define DC_RES SYS_RES_IOPORT #define DC_RID DC_PCI_CFBIO @@ -605,185 +618,45 @@ dc_read_eeprom(struct dc_softc *sc, cadd } /* - * The following two routines are taken from the Macronix 98713 - * Application Notes pp.19-21. - */ -/* - * Write a bit to the MII bus. + * Write the MII serial port for the MII bit-bang module. */ static void -dc_mii_writebit(struct dc_softc *sc, int bit) +dc_mii_bitbang_write(device_t dev, uint32_t val) { - uint32_t reg; + struct dc_softc *sc; - reg = DC_SIO_ROMCTL_WRITE | (bit != 0 ? DC_SIO_MII_DATAOUT : 0); - CSR_WRITE_4(sc, DC_SIO, reg); - CSR_BARRIER_4(sc, DC_SIO, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); + sc = device_get_softc(dev); - CSR_WRITE_4(sc, DC_SIO, reg | DC_SIO_MII_CLK); - CSR_BARRIER_4(sc, DC_SIO, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); - CSR_WRITE_4(sc, DC_SIO, reg); + CSR_WRITE_4(sc, DC_SIO, val); CSR_BARRIER_4(sc, DC_SIO, BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); } /* - * Read a bit from the MII bus. + * Read the MII serial port for the MII bit-bang module. */ -static int -dc_mii_readbit(struct dc_softc *sc) +static uint32_t +dc_mii_bitbang_read(device_t dev) { - uint32_t reg; - - reg = DC_SIO_ROMCTL_READ | DC_SIO_MII_DIR; - CSR_WRITE_4(sc, DC_SIO, reg); - CSR_BARRIER_4(sc, DC_SIO, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); - (void)CSR_READ_4(sc, DC_SIO); - CSR_WRITE_4(sc, DC_SIO, reg | DC_SIO_MII_CLK); - CSR_BARRIER_4(sc, DC_SIO, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); - CSR_WRITE_4(sc, DC_SIO, reg); - CSR_BARRIER_4(sc, DC_SIO, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); - if (CSR_READ_4(sc, DC_SIO) & DC_SIO_MII_DATAIN) - return (1); - - return (0); -} + struct dc_softc *sc; + uint32_t val; -/* - * Sync the PHYs by setting data bit and strobing the clock 32 times. - */ -static void -dc_mii_sync(struct dc_softc *sc) -{ - int i; + sc = device_get_softc(dev); - CSR_WRITE_4(sc, DC_SIO, DC_SIO_ROMCTL_WRITE); + val = CSR_READ_4(sc, DC_SIO); CSR_BARRIER_4(sc, DC_SIO, BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - DELAY(1); - - for (i = 0; i < 32; i++) - dc_mii_writebit(sc, 1); -} - -/* - * Clock a series of bits through the MII. - */ -static void -dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) -{ - int i; - - for (i = (0x1 << (cnt - 1)); i; i >>= 1) - dc_mii_writebit(sc, bits & i); -} -/* - * Read an PHY register through the MII. - */ -static int -dc_mii_readreg(struct dc_softc *sc, struct dc_mii_frame *frame) -{ - int i; - - /* - * Set up frame for RX. - */ - frame->mii_stdelim = DC_MII_STARTDELIM; - frame->mii_opcode = DC_MII_READOP; - - /* - * Sync the PHYs. - */ - dc_mii_sync(sc); - - /* - * Send command/address info. - */ - dc_mii_send(sc, frame->mii_stdelim, 2); - dc_mii_send(sc, frame->mii_opcode, 2); - dc_mii_send(sc, frame->mii_phyaddr, 5); - dc_mii_send(sc, frame->mii_regaddr, 5); - - /* - * Now try reading data bits. If the turnaround failed, we still - * need to clock through 16 cycles to keep the PHY(s) in sync. - */ - frame->mii_turnaround = dc_mii_readbit(sc); - if (frame->mii_turnaround != 0) { - for (i = 0; i < 16; i++) - dc_mii_readbit(sc); - goto fail; - } - for (i = 0x8000; i; i >>= 1) { - if (dc_mii_readbit(sc)) - frame->mii_data |= i; - } - -fail: - - /* Clock the idle bits. */ - dc_mii_writebit(sc, 0); - dc_mii_writebit(sc, 0); - - if (frame->mii_turnaround != 0) - return (1); - return (0); -} - -/* - * Write to a PHY register through the MII. - */ -static int -dc_mii_writereg(struct dc_softc *sc, struct dc_mii_frame *frame) -{ - - /* - * Set up frame for TX. - */ - frame->mii_stdelim = DC_MII_STARTDELIM; - frame->mii_opcode = DC_MII_WRITEOP; - frame->mii_turnaround = DC_MII_TURNAROUND; - - /* - * Sync the PHYs. - */ - dc_mii_sync(sc); - - dc_mii_send(sc, frame->mii_stdelim, 2); - dc_mii_send(sc, frame->mii_opcode, 2); - dc_mii_send(sc, frame->mii_phyaddr, 5); - dc_mii_send(sc, frame->mii_regaddr, 5); - dc_mii_send(sc, frame->mii_turnaround, 2); - dc_mii_send(sc, frame->mii_data, 16); - - /* Clock the idle bits. */ - dc_mii_writebit(sc, 0); - dc_mii_writebit(sc, 0); - - return (0); + return (val); } static int dc_miibus_readreg(device_t dev, int phy, int reg) { - struct dc_mii_frame frame; - struct dc_softc *sc; + struct dc_softc *sc; int i, rval, phy_reg = 0; sc = device_get_softc(dev); - bzero(&frame, sizeof(frame)); if (sc->dc_pmode != DC_PMODE_MII) { if (phy == (MII_NPHY - 1)) { @@ -858,34 +731,29 @@ dc_miibus_readreg(device_t dev, int phy, } rval = CSR_READ_4(sc, phy_reg) & 0x0000FFFF; - if (rval == 0xFFFF) return (0); return (rval); } - frame.mii_phyaddr = phy; - frame.mii_regaddr = reg; if (sc->dc_type == DC_TYPE_98713) { phy_reg = CSR_READ_4(sc, DC_NETCFG); CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); } - dc_mii_readreg(sc, &frame); + rval = mii_bitbang_readreg(dev, &dc_mii_bitbang_ops, phy, reg); if (sc->dc_type == DC_TYPE_98713) CSR_WRITE_4(sc, DC_NETCFG, phy_reg); - return (frame.mii_data); + return (rval); } static int dc_miibus_writereg(device_t dev, int phy, int reg, int data) { struct dc_softc *sc; - struct dc_mii_frame frame; int i, phy_reg = 0; sc = device_get_softc(dev); - bzero(&frame, sizeof(frame)); if (DC_IS_PNIC(sc)) { CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE | @@ -931,15 +799,11 @@ dc_miibus_writereg(device_t dev, int phy return (0); } - frame.mii_phyaddr = phy; - frame.mii_regaddr = reg; - frame.mii_data = data; - if (sc->dc_type == DC_TYPE_98713) { phy_reg = CSR_READ_4(sc, DC_NETCFG); CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); } - dc_mii_writereg(sc, &frame); + mii_bitbang_writereg(dev, &dc_mii_bitbang_ops, phy, reg, data); if (sc->dc_type == DC_TYPE_98713) CSR_WRITE_4(sc, DC_NETCFG, phy_reg); Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Nov 6 21:09:23 2011 (r227278) @@ -525,27 +525,9 @@ struct dc_mediainfo { struct dc_type { uint32_t dc_devid; uint8_t dc_minrev; - char *dc_name; + const char *dc_name; }; -struct dc_mii_frame { - uint8_t mii_stdelim; - uint8_t mii_opcode; - uint8_t mii_phyaddr; - uint8_t mii_regaddr; - uint8_t mii_turnaround; - uint16_t mii_data; -}; - -/* - * MII constants - */ -#define DC_MII_STARTDELIM 0x01 -#define DC_MII_READOP 0x02 -#define DC_MII_WRITEOP 0x01 -#define DC_MII_TURNAROUND 0x02 - - /* * Registers specific to clone devices. * This mainly relates to RX filter programming: not all 21x4x clones @@ -804,7 +786,7 @@ struct dc_softc { #define CSR_READ_4(sc, reg) \ bus_space_read_4(sc->dc_btag, sc->dc_bhandle, reg) -#define CSR_BARRIER_4(sc, reg, flags) \ +#define CSR_BARRIER_4(sc, reg, flags) \ bus_space_barrier(sc->dc_btag, sc->dc_bhandle, reg, 4, flags) #define DC_TIMEOUT 1000 Copied: stable/8/sys/dev/mii/mii_bitbang.c (from r226995, head/sys/dev/mii/mii_bitbang.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/dev/mii/mii_bitbang.c Sun Nov 6 21:09:23 2011 (r227278, copy of r226995, head/sys/dev/mii/mii_bitbang.c) @@ -0,0 +1,180 @@ +/* $NetBSD: mii_bitbang.c,v 1.12 2008/05/04 17:06:09 xtraeme Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following didevlaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following didevlaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Common module for bit-bang'ing the MII. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include + +MODULE_VERSION(mii_bitbang, 1); + +static void mii_bitbang_sendbits(device_t dev, mii_bitbang_ops_t ops, + uint32_t data, int nbits); + +#define MWRITE(x) \ +do { \ + ops->mbo_write(dev, (x)); \ + DELAY(1); \ +} while (/* CONSTCOND */ 0) + +#define MREAD ops->mbo_read(dev) + +#define MDO ops->mbo_bits[MII_BIT_MDO] +#define MDI ops->mbo_bits[MII_BIT_MDI] +#define MDC ops->mbo_bits[MII_BIT_MDC] +#define MDIRPHY ops->mbo_bits[MII_BIT_DIR_HOST_PHY] +#define MDIRHOST ops->mbo_bits[MII_BIT_DIR_PHY_HOST] + +/* + * mii_bitbang_sync: + * + * Synchronize the MII. + */ +void +mii_bitbang_sync(device_t dev, mii_bitbang_ops_t ops) +{ + int i; + uint32_t v; + + v = MDIRPHY | MDO; + + MWRITE(v); + for (i = 0; i < 32; i++) { + MWRITE(v | MDC); + MWRITE(v); + } +} + +/* + * mii_bitbang_sendbits: + * + * Send a series of bits to the MII. + */ +static void +mii_bitbang_sendbits(device_t dev, mii_bitbang_ops_t ops, uint32_t data, + int nbits) +{ + int i; + uint32_t v; + + v = MDIRPHY; + MWRITE(v); + + for (i = 1 << (nbits - 1); i != 0; i >>= 1) { + if (data & i) + v |= MDO; + else + v &= ~MDO; + MWRITE(v); + MWRITE(v | MDC); + MWRITE(v); + } +} + +/* + * mii_bitbang_readreg: + * + * Read a PHY register by bit-bang'ing the MII. + */ +int +mii_bitbang_readreg(device_t dev, mii_bitbang_ops_t ops, int phy, int reg) +{ + int i, error, val; + + mii_bitbang_sync(dev, ops); + + mii_bitbang_sendbits(dev, ops, MII_COMMAND_START, 2); + mii_bitbang_sendbits(dev, ops, MII_COMMAND_READ, 2); + mii_bitbang_sendbits(dev, ops, phy, 5); + mii_bitbang_sendbits(dev, ops, reg, 5); + + /* Switch direction to PHY->host, without a clock transition. */ + MWRITE(MDIRHOST); + + /* Turnaround clock. */ + MWRITE(MDIRHOST | MDC); + MWRITE(MDIRHOST); + + /* Check for error. */ + error = MREAD & MDI; + + /* Idle clock. */ + MWRITE(MDIRHOST | MDC); + MWRITE(MDIRHOST); + + val = 0; + for (i = 0; i < 16; i++) { + val <<= 1; + /* Read data prior to clock low-high transition. */ + if (error == 0 && (MREAD & MDI) != 0) + val |= 1; + + MWRITE(MDIRHOST | MDC); + MWRITE(MDIRHOST); + } + + /* Set direction to host->PHY, without a clock transition. */ + MWRITE(MDIRPHY); + + return (error != 0 ? 0 : val); +} + +/* + * mii_bitbang_writereg: + * + * Write a PHY register by bit-bang'ing the MII. + */ +void +mii_bitbang_writereg(device_t dev, mii_bitbang_ops_t ops, int phy, int reg, + int val) +{ + + mii_bitbang_sync(dev, ops); + + mii_bitbang_sendbits(dev, ops, MII_COMMAND_START, 2); + mii_bitbang_sendbits(dev, ops, MII_COMMAND_WRITE, 2); + mii_bitbang_sendbits(dev, ops, phy, 5); + mii_bitbang_sendbits(dev, ops, reg, 5); + mii_bitbang_sendbits(dev, ops, MII_COMMAND_ACK, 2); + mii_bitbang_sendbits(dev, ops, val, 16); + + MWRITE(MDIRPHY); +} Copied: stable/8/sys/dev/mii/mii_bitbang.h (from r226995, head/sys/dev/mii/mii_bitbang.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/dev/mii/mii_bitbang.h Sun Nov 6 21:09:23 2011 (r227278, copy of r226995, head/sys/dev/mii/mii_bitbang.h) @@ -0,0 +1,54 @@ +/* $NetBSD: mii_bitbang.h,v 1.6 2009/05/12 14:31:27 cegger Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#define MII_BIT_MDO 0 /* data out (host->PHY) */ +#define MII_BIT_MDI 1 /* data in (PHY->host) */ +#define MII_BIT_MDC 2 /* clock */ +#define MII_BIT_DIR_HOST_PHY 3 /* set direction: host->PHY */ +#define MII_BIT_DIR_PHY_HOST 4 /* set direction: PHY->host */ +#define MII_NBITS 5 + +struct mii_bitbang_ops { + uint32_t (*mbo_read)(device_t); + void (*mbo_write)(device_t, uint32_t); + uint32_t mbo_bits[MII_NBITS]; +}; + +typedef const struct mii_bitbang_ops *mii_bitbang_ops_t; + +int mii_bitbang_readreg(device_t dev, mii_bitbang_ops_t ops, + int phy, int reg); +void mii_bitbang_sync(device_t dev, mii_bitbang_ops_t ops); +void mii_bitbang_writereg(device_t dev, mii_bitbang_ops_t ops, + int phy, int reg, int val); Modified: stable/8/sys/dev/nge/if_nge.c ============================================================================== --- stable/8/sys/dev/nge/if_nge.c Sun Nov 6 21:09:10 2011 (r227277) +++ stable/8/sys/dev/nge/if_nge.c Sun Nov 6 21:09:23 2011 (r227278) @@ -117,6 +117,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -138,7 +139,7 @@ MODULE_DEPEND(nge, miibus, 1, 1, 1); /* * Various supported device vendors/types and their names. */ -static struct nge_type nge_devs[] = { +static const struct nge_type const nge_devs[] = { { NGE_VENDORID, NGE_DEVICEID, "National Semiconductor Gigabit Ethernet" }, { 0, 0, NULL } @@ -180,11 +181,6 @@ static void nge_eeprom_putbyte(struct ng static void nge_eeprom_getword(struct nge_softc *, int, uint16_t *); static void nge_read_eeprom(struct nge_softc *, caddr_t, int, int); -static void nge_mii_sync(struct nge_softc *); -static void nge_mii_send(struct nge_softc *, uint32_t, int); -static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *); -static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *); - static int nge_miibus_readreg(device_t, int, int); static int nge_miibus_writereg(device_t, int, int, int); static void nge_miibus_statchg(device_t); @@ -200,6 +196,24 @@ static void nge_sysctl_node(struct nge_s static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_nge_int_holdoff(SYSCTL_HANDLER_ARGS); +/* + * MII bit-bang glue + */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 23:26:18 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13946106566B; Sun, 6 Nov 2011 23:26:18 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe02.c2i.net [212.247.154.34]) by mx1.freebsd.org (Postfix) with ESMTP id 111788FC13; Sun, 6 Nov 2011 23:26:16 +0000 (UTC) X-T2-Spam-Status: No, hits=-1.0 required=5.0 tests=ALL_TRUSTED, BAYES_20 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe02.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 201163649; Mon, 07 Nov 2011 00:16:11 +0100 From: Hans Petter Selasky To: Marius Strobl Date: Mon, 7 Nov 2011 00:13:09 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.2-STABLE; KDE/4.4.5; amd64; ; ) References: <20111106194743.GD56603@alchemy.franken.de> <20111106203800.GE56603@alchemy.franken.de> In-Reply-To: <20111106203800.GE56603@alchemy.franken.de> X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq, NwSZ4V"|LR.+tj}g5 %V,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( :AuzV9:.hESm-x4h240C`9=w MIME-Version: 1.0 Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Message-Id: <201111070013.09627.hselasky@c2i.net> Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-8@freebsd.org" Subject: Re: svn commit: r227217 - stable/8/sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 23:26:18 -0000 On Sunday 06 November 2011 21:38:00 Marius Strobl wrote: > On Sun, Nov 06, 2011 at 08:47:43PM +0100, Marius Strobl wrote: > > On Sun, Nov 06, 2011 at 03:13:02PM +0000, Hans Petter Selasky wrote: > > > Author: hselasky > > > Date: Sun Nov 6 15:13:01 2011 > > > New Revision: 227217 > > > URL: http://svn.freebsd.org/changeset/base/227217 > > > > > > Log: > > > MFC r227075: > > > Fix for panic at USB controller attach failure during cold boot. > > > > > > Modified: > > > stable/8/sys/dev/usb/usb_process.c > > > > > > Directory Properties: > > > stable/8/sys/ (props changed) > > > stable/8/sys/amd64/include/xen/ (props changed) > > > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > > > stable/8/sys/contrib/dev/acpica/ (props changed) > > > stable/8/sys/contrib/pf/ (props changed) > > > > > > Modified: stable/8/sys/dev/usb/usb_process.c > > > ======================================================================= > > > ======= --- stable/8/sys/dev/usb/usb_process.c Sun Nov 6 15:06:04 > > > 2011 (r227216) +++ stable/8/sys/dev/usb/usb_process.c Sun Nov 6 > > > 15:13:01 2011 (r227217) @@ -67,11 +67,13 @@ static int usb_pcount; > > > > > > #define USB_THREAD_CREATE(f, s, p, ...) \ > > > > > > kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ > > > > > > 0, "usb", __VA_ARGS__) > > > > > > +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() > > > > In stable/8 kthread_suspend_check(9) takes an struct thread * argument. > > Sorry, I didn't look closely enough, it probably should use the same > approach as hptmv(4): > #if (__FreeBSD_version >= 800002) > kproc_suspend_check(curproc); > #elif (__FreeBSD_version >= 500043) > kthread_suspend_check(curproc); > #else > kproc_suspend_loop(curproc); > #endif > > In any case, r227217 broke kernel compilation of stable/8. Hi, I'll fix this ASAP. Sorry for the inconvenience. --HPS From owner-svn-src-stable-8@FreeBSD.ORG Sun Nov 6 23:34:41 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00BA3106564A; Sun, 6 Nov 2011 23:34:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E47658FC16; Sun, 6 Nov 2011 23:34:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA6NYeig047296; Sun, 6 Nov 2011 23:34:40 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA6NYevj047294; Sun, 6 Nov 2011 23:34:40 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201111062334.pA6NYevj047294@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 6 Nov 2011 23:34:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227287 - stable/8/sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 23:34:41 -0000 Author: hselasky Date: Sun Nov 6 23:34:40 2011 New Revision: 227287 URL: http://svn.freebsd.org/changeset/base/227287 Log: MFC r227286: Fix kernel build breakage of 8-stable. Reported by: Marius Strobl Modified: stable/8/sys/dev/usb/usb_process.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/usb_process.c ============================================================================== --- stable/8/sys/dev/usb/usb_process.c Sun Nov 6 23:26:26 2011 (r227286) +++ stable/8/sys/dev/usb/usb_process.c Sun Nov 6 23:34:40 2011 (r227287) @@ -67,13 +67,17 @@ static int usb_pcount; #define USB_THREAD_CREATE(f, s, p, ...) \ kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ 0, "usb", __VA_ARGS__) +#if (__FreeBSD_version >= 900000) #define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() +#else +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check(curthread) +#endif #define USB_THREAD_SUSPEND(p) kthread_suspend(p,0) #define USB_THREAD_EXIT(err) kthread_exit() #else #define USB_THREAD_CREATE(f, s, p, ...) \ kthread_create((f), (s), (p), RFHIGHPID, 0, __VA_ARGS__) -#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check() +#define USB_THREAD_SUSPEND_CHECK() kthread_suspend_check(curproc) #define USB_THREAD_SUSPEND(p) kthread_suspend(p,0) #define USB_THREAD_EXIT(err) kthread_exit(err) #endif From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 02:32:03 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17892106564A; Mon, 7 Nov 2011 02:32:03 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3468FC08; Mon, 7 Nov 2011 02:32:02 +0000 (UTC) Received: by ggnk3 with SMTP id k3so4412297ggn.13 for ; Sun, 06 Nov 2011 18:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; bh=bvibc8r+h1ipra5A7W3z8ZNrttK3eF0YA6Abia3h/Ns=; b=hzxhpNoU1E7lsOoyUFaWUIt1H3MGVDFuxgZ0Cea/efzbMA14wouLMtAqrYCsgWJV1L IlOFab2FtE4+G4jn6K2x3UYwXJMsyLklzTRwWeixL41OEOtkCDsLgHZne9FJB9Stj+zl JOhJ62AMhsLb7viVlVoU5Vr/uAeAzAaGsXvoQ= Received: by 10.42.151.4 with SMTP id c4mr41370036icw.39.1320631686201; Sun, 06 Nov 2011 18:08:06 -0800 (PST) Received: from DataIX.net (adsl-99-181-144-127.dsl.klmzmi.sbcglobal.net. [99.181.144.127]) by mx.google.com with ESMTPS id eh34sm35899551ibb.5.2011.11.06.18.08.03 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Nov 2011 18:08:04 -0800 (PST) Sender: Jason Hellenthal Received: from DataIX.net (localhost.DataIX.local [127.0.0.1]) by DataIX.net (8.14.5/8.14.5) with ESMTP id pA7280Zn047640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 6 Nov 2011 21:08:00 -0500 (EST) (envelope-from jhell@DataIX.net) Received: (from jhell@localhost) by DataIX.net (8.14.5/8.14.5/Submit) id pA727xeS047639; Sun, 6 Nov 2011 21:07:59 -0500 (EST) (envelope-from jhell@DataIX.net) Date: Sun, 6 Nov 2011 21:07:59 -0500 From: Jason Hellenthal To: Marius Strobl Message-ID: <20111107020759.GA45996@DataIX.net> References: <201111062109.pA6L9OLV042060@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline In-Reply-To: <201111062109.pA6L9OLV042060@svn.freebsd.org> Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r227278 - in stable/8/sys: arm/conf conf dev/bm dev/dc dev/mii dev/nge dev/sis dev/smc dev/ste dev/stge dev/tl dev/wb dev/xl modules/mii pci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 02:32:03 -0000 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The following commmit broke building without device miibus at least on i386. if_dc.o(.text+0x24b4): In function `dc_miibus_writereg': /usr/src/sys/dev/dc/if_dc.c:806: undefined reference to `mii_bitbang_writer= eg' if_dc.o(.text+0x26cc): In function `dc_miibus_readreg': /usr/src/sys/dev/dc/if_dc.c:743: undefined reference to `mii_bitbang_readre= g' If you try to use the modular device mii and the single *phy you will get t= he above error when it comes time to link the kernel. On Sun, Nov 06, 2011 at 09:09:24PM +0000, Marius Strobl wrote: > Author: marius > Date: Sun Nov 6 21:09:23 2011 > New Revision: 227278 > URL: http://svn.freebsd.org/changeset/base/227278 >=20 > Log: > MFC: r226995, r227042 > =20 > - Import the common MII bitbang'ing code from NetBSD and convert driver= s to > take advantage of it instead of duplicating it. This reduces the size= of > the i386 GENERIC kernel by about 8k. The only potential in-tree users= left > unconverted are ed(4) and xe(4). Xe(4) generally should be changed to= use > miibus(4) instead of implementing PHY handling on its own, as otherwi= se it > makes not much sense to add a dependency on miibus(4)/mii_bitbang(4) = to it > just for the MII bitbang'ing code. Ed(4) has some chip specific things > interwinded with the MII bitbang'ing code and it's unclear whether it= can > be converted to common code, at least not without thorough testing of= all > the various chips supported by ed(4). > The common MII bitbang'ing code also is useful in the embedded space = for > using GPIO pins to implement MII access. > - Based on lessons learnt with dc(4) (see r185750), add bus barriers to= the > MII bitbang read and write functions of the other drivers converted in > order to ensure the intended ordering. Given that register access via= an > index register as well as register bank/window switching is subject t= o the > same problem, also add bus barriers to the respective functions of sm= c(4), > tl(4) and xl(4). > - Sprinkle some const. > =20 > Thanks to the following testers: > Andrew Bliznak (nge(4)), nwhitehorn@ (bm(4)), yongari@ (sis(4) and ste(= 4)) > Thanks to Hans-Joerg Sirtl for supplying hardware to test stge(4). > =20 > Reviewed by: yongari (subset of drivers) > Obtained from: NetBSD (partially) >=20 > Added: > stable/8/sys/dev/mii/mii_bitbang.c > - copied unchanged from r226995, head/sys/dev/mii/mii_bitbang.c > stable/8/sys/dev/mii/mii_bitbang.h > - copied unchanged from r226995, head/sys/dev/mii/mii_bitbang.h > Modified: > stable/8/sys/arm/conf/GUMSTIX > stable/8/sys/conf/NOTES > stable/8/sys/conf/files > stable/8/sys/dev/bm/if_bm.c > stable/8/sys/dev/bm/if_bmreg.h > stable/8/sys/dev/bm/if_bmvar.h > stable/8/sys/dev/dc/if_dc.c > stable/8/sys/dev/dc/if_dcreg.h > stable/8/sys/dev/nge/if_nge.c > stable/8/sys/dev/nge/if_ngereg.h > stable/8/sys/dev/sis/if_sis.c > stable/8/sys/dev/sis/if_sisreg.h > stable/8/sys/dev/smc/if_smc.c > stable/8/sys/dev/ste/if_ste.c > stable/8/sys/dev/ste/if_stereg.h > stable/8/sys/dev/stge/if_stge.c > stable/8/sys/dev/stge/if_stgereg.h > stable/8/sys/dev/tl/if_tl.c > stable/8/sys/dev/tl/if_tlreg.h > stable/8/sys/dev/wb/if_wb.c > stable/8/sys/dev/wb/if_wbreg.h > stable/8/sys/dev/xl/if_xl.c > stable/8/sys/dev/xl/if_xlreg.h > stable/8/sys/modules/mii/Makefile > stable/8/sys/pci/if_rl.c > stable/8/sys/pci/if_rlreg.h > Directory Properties: > stable/8/sys/ (props changed) > stable/8/sys/amd64/include/xen/ (props changed) > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > stable/8/sys/contrib/dev/acpica/ (props changed) > stable/8/sys/contrib/pf/ (props changed) >=20 > Modified: stable/8/sys/arm/conf/GUMSTIX > =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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/arm/conf/GUMSTIX Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/arm/conf/GUMSTIX Sun Nov 6 21:09:23 2011 (r227278) > @@ -72,6 +72,7 @@ options PREEMPTION > device loop > device ether > device mii > +device mii_bitbang > device smc > device smcphy > device uart >=20 > Modified: stable/8/sys/conf/NOTES > =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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/conf/NOTES Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/conf/NOTES Sun Nov 6 21:09:23 2011 (r227278) > @@ -1819,13 +1819,15 @@ device puc > # MII bus support is required for many PCI Ethernet NICs, > # namely those which use MII-compliant transceivers or implement > # transceiver control interfaces that operate like an MII. Adding > -# "device miibus" to the kernel config pulls in support for > -# the generic miibus API and all of the PHY drivers, including a > -# generic one for PHYs that aren't specifically handled by an > -# individual driver. Support for specific PHYs may be built by adding > -# "device mii" then adding the appropriate PHY driver. > -device miibus # MII support including all PHYs > +# "device miibus" to the kernel config pulls in support for the generic > +# miibus API, the common support for for bit-bang'ing the MII and all > +# of the PHY drivers, including a generic one for PHYs that aren't > +# specifically handled by an individual driver. Support for specific > +# PHYs may be built by adding "device mii", "device mii_bitbang" if > +# needed by the NIC driver and then adding the appropriate PHY driver. > device mii # Minimal MII support > +device mii_bitbang # Common module for bit-bang'ing the MII > +device miibus # MII support w/ bit-bang'ing and all PHYs > =20 > device acphy # Altima Communications AC101 > device amphy # AMD AM79c873 / Davicom DM910{1,2} >=20 > Modified: stable/8/sys/conf/files > =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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/conf/files Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/conf/files Sun Nov 6 21:09:23 2011 (r227278) > @@ -1309,6 +1309,7 @@ dev/mii/ip1000phy.c optional miibus | i > dev/mii/jmphy.c optional miibus | jmphy > dev/mii/lxtphy.c optional miibus | lxtphy > dev/mii/mii.c optional miibus | mii > +dev/mii/mii_bitbang.c optional miibus | mii_bitbang > dev/mii/mii_physubr.c optional miibus | mii > dev/mii/miibus_if.m optional miibus | mii > dev/mii/mlphy.c optional miibus | mlphy >=20 > Modified: stable/8/sys/dev/bm/if_bm.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/bm/if_bm.c Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/bm/if_bm.c Sun Nov 6 21:09:23 2011 (r227278) > @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); > #include > =20 > #include > +#include > #include > =20 > #include > @@ -105,17 +106,28 @@ static void bm_tick (void *xsc); > static int bm_ifmedia_upd (struct ifnet *); > static void bm_ifmedia_sts (struct ifnet *, struct ifmediareq *); > =20 > -static void bm_miicsr_dwrite (struct bm_softc *, u_int16_t); > -static void bm_mii_writebit (struct bm_softc *, int); > -static int bm_mii_readbit (struct bm_softc *); > -static void bm_mii_sync (struct bm_softc *); > -static void bm_mii_send (struct bm_softc *, u_int32_t, int); > -static int bm_mii_readreg (struct bm_softc *, struct bm_mii_frame *); > -static int bm_mii_writereg (struct bm_softc *, struct bm_mii_frame *); > static int bm_miibus_readreg (device_t, int, int); > static int bm_miibus_writereg (device_t, int, int, int); > static void bm_miibus_statchg (device_t); > =20 > +/* > + * MII bit-bang glue > + */ > +static uint32_t bm_mii_bitbang_read(device_t); > +static void bm_mii_bitbang_write(device_t, uint32_t); > + > +static const struct mii_bitbang_ops bm_mii_bitbang_ops =3D { > + bm_mii_bitbang_read, > + bm_mii_bitbang_write, > + { > + BM_MII_DATAOUT, /* MII_BIT_MDO */ > + BM_MII_DATAIN, /* MII_BIT_MDI */ > + BM_MII_CLK, /* MII_BIT_MDC */ > + BM_MII_OENABLE, /* MII_BIT_DIR_HOST_PHY */ > + 0, /* MII_BIT_DIR_PHY_HOST */ > + } > +}; > + > static device_method_t bm_methods[] =3D { > /* Device interface */ > DEVMETHOD(device_probe, bm_probe), > @@ -150,171 +162,36 @@ DRIVER_MODULE(miibus, bm, miibus_driver, > */ > =20 > /* > - * Write to the MII csr, introducing a delay to allow valid > - * MII clock pulses to be formed > - */ > -static void > -bm_miicsr_dwrite(struct bm_softc *sc, u_int16_t val) > -{ > - CSR_WRITE_2(sc, BM_MII_CSR, val); > - /* > - * Assume this is a clock toggle and generate a 1us delay > - * to cover both MII's 160ns high/low minimum and 400ns > - * cycle miniumum > - */ > - DELAY(1); > -} > - > -/* > - * Write a bit to the MII bus. > - */ > -static void > -bm_mii_writebit(struct bm_softc *sc, int bit) > -{ > - u_int16_t regval; > - > - regval =3D BM_MII_OENABLE; > - if (bit) > - regval |=3D BM_MII_DATAOUT; > - > - bm_miicsr_dwrite(sc, regval); > - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); > - bm_miicsr_dwrite(sc, regval); > -} > - > -/* > - * Read a bit from the MII bus. > - */ > -static int > -bm_mii_readbit(struct bm_softc *sc) > -{ > - u_int16_t regval, bitin; > - > - /* ~BM_MII_OENABLE */ > - regval =3D 0; > - > - bm_miicsr_dwrite(sc, regval); > - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); > - bm_miicsr_dwrite(sc, regval); > - bitin =3D CSR_READ_2(sc, BM_MII_CSR) & BM_MII_DATAIN; > - > - return (bitin =3D=3D BM_MII_DATAIN); > -} > - > -/* > - * Sync the PHYs by setting data bit and strobing the clock 32 times. > + * Write the MII serial port for the MII bit-bang module. > */ > static void > -bm_mii_sync(struct bm_softc *sc) > +bm_mii_bitbang_write(device_t dev, uint32_t val) > { > - int i; > - u_int16_t regval; > - > - regval =3D BM_MII_OENABLE | BM_MII_DATAOUT; > - > - bm_miicsr_dwrite(sc, regval); > - for (i =3D 0; i < 32; i++) { > - bm_miicsr_dwrite(sc, regval | BM_MII_CLK); > - bm_miicsr_dwrite(sc, regval); > - } > -} > - > -/* > - * Clock a series of bits through the MII. > - */ > -static void > -bm_mii_send(struct bm_softc *sc, u_int32_t bits, int cnt) > -{ > - int i; > - > - for (i =3D (0x1 << (cnt - 1)); i; i >>=3D 1) > - bm_mii_writebit(sc, bits & i); > -} > - > -/* > - * Read a PHY register through the MII. > - */ > -static int > -bm_mii_readreg(struct bm_softc *sc, struct bm_mii_frame *frame) > -{ > - int i, ack, bit; > - > - /* > - * Set up frame for RX. > - */ > - frame->mii_stdelim =3D BM_MII_STARTDELIM; > - frame->mii_opcode =3D BM_MII_READOP; > - frame->mii_turnaround =3D 0; > - frame->mii_data =3D 0; > - > - /* > - * Sync the PHYs > - */ > - bm_mii_sync(sc); > - > - /* > - * Send command/address info > - */ > - bm_mii_send(sc, frame->mii_stdelim, 2); > - bm_mii_send(sc, frame->mii_opcode, 2); > - bm_mii_send(sc, frame->mii_phyaddr, 5); > - bm_mii_send(sc, frame->mii_regaddr, 5); > - > - /* > - * Check for ack. > - */ > - ack =3D bm_mii_readbit(sc); > - > - /* > - * Now try reading data bits. If the ack failed, we still > - * need to clock through 16 cycles to keep the PHY(s) in sync. > - */ > - for (i =3D 0x8000; i; i >>=3D 1) { > - bit =3D bm_mii_readbit(sc); > - if (!ack && bit) > - frame->mii_data |=3D i; > - } > + struct bm_softc *sc; > =20 > - /* > - * Skip through idle bit-times > - */ > - bm_mii_writebit(sc, 0); > - bm_mii_writebit(sc, 0); > + sc =3D device_get_softc(dev); > =20 > - return ((ack) ? 1 : 0); > + CSR_WRITE_2(sc, BM_MII_CSR, val); > + CSR_BARRIER(sc, BM_MII_CSR, 2, > + BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > } > =20 > /* > - * Write to a PHY register through the MII. > + * Read the MII serial port for the MII bit-bang module. > */ > -static int > -bm_mii_writereg(struct bm_softc *sc, struct bm_mii_frame *frame) > +static uint32_t > +bm_mii_bitbang_read(device_t dev) > { > - /* > - * Set up frame for tx > - */ > - frame->mii_stdelim =3D BM_MII_STARTDELIM; > - frame->mii_opcode =3D BM_MII_WRITEOP; > - frame->mii_turnaround =3D BM_MII_TURNAROUND; > - > - /* > - * Sync the phy and start the bitbang write sequence > - */ > - bm_mii_sync(sc); > + struct bm_softc *sc; > + uint32_t reg; > =20 > - bm_mii_send(sc, frame->mii_stdelim, 2); > - bm_mii_send(sc, frame->mii_opcode, 2); > - bm_mii_send(sc, frame->mii_phyaddr, 5); > - bm_mii_send(sc, frame->mii_regaddr, 5); > - bm_mii_send(sc, frame->mii_turnaround, 2); > - bm_mii_send(sc, frame->mii_data, 16); > + sc =3D device_get_softc(dev); > =20 > - /* > - * Idle bit. > - */ > - bm_mii_writebit(sc, 0); > + reg =3D CSR_READ_2(sc, BM_MII_CSR); > + CSR_BARRIER(sc, BM_MII_CSR, 2, > + BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > =20 > - return (0); > + return (reg); > } > =20 > /* > @@ -323,34 +200,15 @@ bm_mii_writereg(struct bm_softc *sc, str > static int > bm_miibus_readreg(device_t dev, int phy, int reg) > { > - struct bm_softc *sc; > - struct bm_mii_frame frame; > - > - sc =3D device_get_softc(dev); > - bzero(&frame, sizeof(frame)); > - > - frame.mii_phyaddr =3D phy; > - frame.mii_regaddr =3D reg; > =20 > - bm_mii_readreg(sc, &frame); > - > - return (frame.mii_data); > + return (mii_bitbang_readreg(dev, &bm_mii_bitbang_ops, phy, reg)); > } > =20 > static int > bm_miibus_writereg(device_t dev, int phy, int reg, int data) > { > - struct bm_softc *sc; > - struct bm_mii_frame frame; > - > - sc =3D device_get_softc(dev); > - bzero(&frame, sizeof(frame)); > - > - frame.mii_phyaddr =3D phy; > - frame.mii_regaddr =3D reg; > - frame.mii_data =3D data; > =20 > - bm_mii_writereg(sc, &frame); > + mii_bitbang_readreg(dev, &bm_mii_bitbang_ops, phy, reg); > =20 > return (0); > } >=20 > Modified: stable/8/sys/dev/bm/if_bmreg.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/bm/if_bmreg.h Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/bm/if_bmreg.h Sun Nov 6 21:09:23 2011 (r227278) > @@ -129,14 +129,6 @@ > #define BM_MII_DATAIN 0x0008 /* MDIO data in */ > =20 > /* > - * MII constants > - */ > -#define BM_MII_STARTDELIM 0x01 > -#define BM_MII_READOP 0x02 > -#define BM_MII_WRITEOP 0x01 > -#define BM_MII_TURNAROUND 0x02 > - > -/* > * Various flags > */ > =20 > @@ -174,3 +166,5 @@ > #define CSR_READ_1(sc, reg) \ > bus_read_1(sc->sc_memr, reg) > =20 > +#define CSR_BARRIER(sc, reg, length, flags) \ > + bus_barrier(sc->sc_memr, reg, length, flags) >=20 > Modified: stable/8/sys/dev/bm/if_bmvar.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/bm/if_bmvar.h Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/bm/if_bmvar.h Sun Nov 6 21:09:23 2011 (r227278) > @@ -46,7 +46,6 @@ > /* > * software state for transmit job mbufs (may be elements of mbuf chains) > */ > - > struct bm_txsoft { > struct mbuf *txs_mbuf; /* head of our mbuf chain */ > bus_dmamap_t txs_dmamap; /* our DMA map */ > @@ -71,7 +70,6 @@ struct bm_rxsoft { > bus_dma_segment_t segment; > }; > =20 > - > struct bm_softc { > struct ifnet *sc_ifp; > struct mtx sc_mtx;=09 > @@ -113,13 +111,3 @@ struct bm_softc { > =20 > dbdma_channel_t *sc_txdma, *sc_rxdma; > }; > - > -struct bm_mii_frame { > - u_int8_t mii_stdelim; > - u_int8_t mii_opcode; > - u_int8_t mii_phyaddr; > - u_int8_t mii_regaddr; > - u_int8_t mii_turnaround; > - u_int16_t mii_data; > -}; > - >=20 > Modified: stable/8/sys/dev/dc/if_dc.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/dc/if_dc.c Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/dc/if_dc.c Sun Nov 6 21:09:23 2011 (r227278) > @@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$"); > #include > =20 > #include > +#include > #include > =20 > #include > @@ -149,7 +150,7 @@ MODULE_DEPEND(dc, miibus, 1, 1, 1); > /* > * Various supported device vendors/types and their names. > */ > -static const struct dc_type dc_devs[] =3D { > +static const struct dc_type const dc_devs[] =3D { > { DC_DEVID(DC_VENDORID_DEC, DC_DEVICEID_21143), 0, > "Intel 21143 10/100BaseTX" }, > { DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009), 0, > @@ -267,12 +268,6 @@ static void dc_eeprom_getword_xircom(str > static void dc_eeprom_width(struct dc_softc *); > static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); > =20 > -static void dc_mii_writebit(struct dc_softc *, int); > -static int dc_mii_readbit(struct dc_softc *); > -static void dc_mii_sync(struct dc_softc *); > -static void dc_mii_send(struct dc_softc *, uint32_t, int); > -static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); > -static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); > static int dc_miibus_readreg(device_t, int, int); > static int dc_miibus_writereg(device_t, int, int, int); > static void dc_miibus_statchg(device_t); > @@ -301,6 +296,24 @@ static int dc_decode_leaf_sym(struct dc_ > static void dc_apply_fixup(struct dc_softc *, int); > static int dc_check_multiport(struct dc_softc *); > =20 > +/* > + * MII bit-bang glue > + */ > +static uint32_t dc_mii_bitbang_read(device_t); > +static void dc_mii_bitbang_write(device_t, uint32_t); > + > +static const struct mii_bitbang_ops dc_mii_bitbang_ops =3D { > + dc_mii_bitbang_read, > + dc_mii_bitbang_write, > + { > + DC_SIO_MII_DATAOUT, /* MII_BIT_MDO */ > + DC_SIO_MII_DATAIN, /* MII_BIT_MDI */ > + DC_SIO_MII_CLK, /* MII_BIT_MDC */ > + 0, /* MII_BIT_DIR_HOST_PHY */ > + DC_SIO_MII_DIR, /* MII_BIT_DIR_PHY_HOST */ > + } > +}; > + > #ifdef DC_USEIOSPACE > #define DC_RES SYS_RES_IOPORT > #define DC_RID DC_PCI_CFBIO > @@ -605,185 +618,45 @@ dc_read_eeprom(struct dc_softc *sc, cadd > } > =20 > /* > - * The following two routines are taken from the Macronix 98713 > - * Application Notes pp.19-21. > - */ > -/* > - * Write a bit to the MII bus. > + * Write the MII serial port for the MII bit-bang module. > */ > static void > -dc_mii_writebit(struct dc_softc *sc, int bit) > +dc_mii_bitbang_write(device_t dev, uint32_t val) > { > - uint32_t reg; > + struct dc_softc *sc; > =20 > - reg =3D DC_SIO_ROMCTL_WRITE | (bit !=3D 0 ? DC_SIO_MII_DATAOUT : 0); > - CSR_WRITE_4(sc, DC_SIO, reg); > - CSR_BARRIER_4(sc, DC_SIO, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > + sc =3D device_get_softc(dev); > =20 > - CSR_WRITE_4(sc, DC_SIO, reg | DC_SIO_MII_CLK); > - CSR_BARRIER_4(sc, DC_SIO, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > - CSR_WRITE_4(sc, DC_SIO, reg); > + CSR_WRITE_4(sc, DC_SIO, val); > CSR_BARRIER_4(sc, DC_SIO, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > } > =20 > /* > - * Read a bit from the MII bus. > + * Read the MII serial port for the MII bit-bang module. > */ > -static int > -dc_mii_readbit(struct dc_softc *sc) > +static uint32_t > +dc_mii_bitbang_read(device_t dev) > { > - uint32_t reg; > - > - reg =3D DC_SIO_ROMCTL_READ | DC_SIO_MII_DIR; > - CSR_WRITE_4(sc, DC_SIO, reg); > - CSR_BARRIER_4(sc, DC_SIO, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > - (void)CSR_READ_4(sc, DC_SIO); > - CSR_WRITE_4(sc, DC_SIO, reg | DC_SIO_MII_CLK); > - CSR_BARRIER_4(sc, DC_SIO, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > - CSR_WRITE_4(sc, DC_SIO, reg); > - CSR_BARRIER_4(sc, DC_SIO, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > - if (CSR_READ_4(sc, DC_SIO) & DC_SIO_MII_DATAIN) > - return (1); > - > - return (0); > -} > + struct dc_softc *sc; > + uint32_t val; > =20 > -/* > - * Sync the PHYs by setting data bit and strobing the clock 32 times. > - */ > -static void > -dc_mii_sync(struct dc_softc *sc) > -{ > - int i; > + sc =3D device_get_softc(dev); > =20 > - CSR_WRITE_4(sc, DC_SIO, DC_SIO_ROMCTL_WRITE); > + val =3D CSR_READ_4(sc, DC_SIO); > CSR_BARRIER_4(sc, DC_SIO, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - DELAY(1); > - > - for (i =3D 0; i < 32; i++) > - dc_mii_writebit(sc, 1); > -} > - > -/* > - * Clock a series of bits through the MII. > - */ > -static void > -dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) > -{ > - int i; > - > - for (i =3D (0x1 << (cnt - 1)); i; i >>=3D 1) > - dc_mii_writebit(sc, bits & i); > -} > =20 > -/* > - * Read an PHY register through the MII. > - */ > -static int > -dc_mii_readreg(struct dc_softc *sc, struct dc_mii_frame *frame) > -{ > - int i; > - > - /* > - * Set up frame for RX. > - */ > - frame->mii_stdelim =3D DC_MII_STARTDELIM; > - frame->mii_opcode =3D DC_MII_READOP; > - > - /* > - * Sync the PHYs. > - */ > - dc_mii_sync(sc); > - > - /* > - * Send command/address info. > - */ > - dc_mii_send(sc, frame->mii_stdelim, 2); > - dc_mii_send(sc, frame->mii_opcode, 2); > - dc_mii_send(sc, frame->mii_phyaddr, 5); > - dc_mii_send(sc, frame->mii_regaddr, 5); > - > - /* > - * Now try reading data bits. If the turnaround failed, we still > - * need to clock through 16 cycles to keep the PHY(s) in sync. > - */ > - frame->mii_turnaround =3D dc_mii_readbit(sc); > - if (frame->mii_turnaround !=3D 0) { > - for (i =3D 0; i < 16; i++) > - dc_mii_readbit(sc); > - goto fail; > - } > - for (i =3D 0x8000; i; i >>=3D 1) { > - if (dc_mii_readbit(sc)) > - frame->mii_data |=3D i; > - } > - > -fail: > - > - /* Clock the idle bits. */ > - dc_mii_writebit(sc, 0); > - dc_mii_writebit(sc, 0); > - > - if (frame->mii_turnaround !=3D 0) > - return (1); > - return (0); > -} > - > -/* > - * Write to a PHY register through the MII. > - */ > -static int > -dc_mii_writereg(struct dc_softc *sc, struct dc_mii_frame *frame) > -{ > - > - /* > - * Set up frame for TX. > - */ > - frame->mii_stdelim =3D DC_MII_STARTDELIM; > - frame->mii_opcode =3D DC_MII_WRITEOP; > - frame->mii_turnaround =3D DC_MII_TURNAROUND; > - > - /* > - * Sync the PHYs. > - */ > - dc_mii_sync(sc); > - > - dc_mii_send(sc, frame->mii_stdelim, 2); > - dc_mii_send(sc, frame->mii_opcode, 2); > - dc_mii_send(sc, frame->mii_phyaddr, 5); > - dc_mii_send(sc, frame->mii_regaddr, 5); > - dc_mii_send(sc, frame->mii_turnaround, 2); > - dc_mii_send(sc, frame->mii_data, 16); > - > - /* Clock the idle bits. */ > - dc_mii_writebit(sc, 0); > - dc_mii_writebit(sc, 0); > - > - return (0); > + return (val); > } > =20 > static int > dc_miibus_readreg(device_t dev, int phy, int reg) > { > - struct dc_mii_frame frame; > - struct dc_softc *sc; > + struct dc_softc *sc; > int i, rval, phy_reg =3D 0; > =20 > sc =3D device_get_softc(dev); > - bzero(&frame, sizeof(frame)); > =20 > if (sc->dc_pmode !=3D DC_PMODE_MII) { > if (phy =3D=3D (MII_NPHY - 1)) { > @@ -858,34 +731,29 @@ dc_miibus_readreg(device_t dev, int phy, > } > =20 > rval =3D CSR_READ_4(sc, phy_reg) & 0x0000FFFF; > - > if (rval =3D=3D 0xFFFF) > return (0); > return (rval); > } > =20 > - frame.mii_phyaddr =3D phy; > - frame.mii_regaddr =3D reg; > if (sc->dc_type =3D=3D DC_TYPE_98713) { > phy_reg =3D CSR_READ_4(sc, DC_NETCFG); > CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); > } > - dc_mii_readreg(sc, &frame); > + rval =3D mii_bitbang_readreg(dev, &dc_mii_bitbang_ops, phy, reg); > if (sc->dc_type =3D=3D DC_TYPE_98713) > CSR_WRITE_4(sc, DC_NETCFG, phy_reg); > =20 > - return (frame.mii_data); > + return (rval); > } > =20 > static int > dc_miibus_writereg(device_t dev, int phy, int reg, int data) > { > struct dc_softc *sc; > - struct dc_mii_frame frame; > int i, phy_reg =3D 0; > =20 > sc =3D device_get_softc(dev); > - bzero(&frame, sizeof(frame)); > =20 > if (DC_IS_PNIC(sc)) { > CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE | > @@ -931,15 +799,11 @@ dc_miibus_writereg(device_t dev, int phy > return (0); > } > =20 > - frame.mii_phyaddr =3D phy; > - frame.mii_regaddr =3D reg; > - frame.mii_data =3D data; > - > if (sc->dc_type =3D=3D DC_TYPE_98713) { > phy_reg =3D CSR_READ_4(sc, DC_NETCFG); > CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL); > } > - dc_mii_writereg(sc, &frame); > + mii_bitbang_writereg(dev, &dc_mii_bitbang_ops, phy, reg, data); > if (sc->dc_type =3D=3D DC_TYPE_98713) > CSR_WRITE_4(sc, DC_NETCFG, phy_reg); > =20 >=20 > Modified: stable/8/sys/dev/dc/if_dcreg.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/dc/if_dcreg.h Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/dc/if_dcreg.h Sun Nov 6 21:09:23 2011 (r227278) > @@ -525,27 +525,9 @@ struct dc_mediainfo { > struct dc_type { > uint32_t dc_devid; > uint8_t dc_minrev; > - char *dc_name; > + const char *dc_name; > }; > =20 > -struct dc_mii_frame { > - uint8_t mii_stdelim; > - uint8_t mii_opcode; > - uint8_t mii_phyaddr; > - uint8_t mii_regaddr; > - uint8_t mii_turnaround; > - uint16_t mii_data; > -}; > - > -/* > - * MII constants > - */ > -#define DC_MII_STARTDELIM 0x01 > -#define DC_MII_READOP 0x02 > -#define DC_MII_WRITEOP 0x01 > -#define DC_MII_TURNAROUND 0x02 > - > - > /* > * Registers specific to clone devices. > * This mainly relates to RX filter programming: not all 21x4x clones > @@ -804,7 +786,7 @@ struct dc_softc { > #define CSR_READ_4(sc, reg) \ > bus_space_read_4(sc->dc_btag, sc->dc_bhandle, reg) > =20 > -#define CSR_BARRIER_4(sc, reg, flags) \ > +#define CSR_BARRIER_4(sc, reg, flags) \ > bus_space_barrier(sc->dc_btag, sc->dc_bhandle, reg, 4, flags) > =20 > #define DC_TIMEOUT 1000 >=20 > Copied: stable/8/sys/dev/mii/mii_bitbang.c (from r226995, head/sys/dev/mi= i/mii_bitbang.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ stable/8/sys/dev/mii/mii_bitbang.c Sun Nov 6 21:09:23 2011 (r227278,= copy of r226995, head/sys/dev/mii/mii_bitbang.c) > @@ -0,0 +1,180 @@ > +/* $NetBSD: mii_bitbang.c,v 1.12 2008/05/04 17:06:09 xtraeme Exp $ */ > + > +/*- > + * Copyright (c) 1999 The NetBSD Foundation, Inc. > + * All rights reserved. > + * > + * This code is derived from software contributed to The NetBSD Foundati= on > + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, > + * NASA Ames Research Center. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following didevlaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following didevlaimer in t= he > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBU= TORS > + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L= IMITED > + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTI= CULAR > + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBU= TORS > + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSIN= ESS > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER = IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS= E) > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O= F THE > + * POSSIBILITY OF SUCH DAMAGE. > + */ > + > +/* > + * Common module for bit-bang'ing the MII. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > + > +#include > +#include > + > +MODULE_VERSION(mii_bitbang, 1); > + > +static void mii_bitbang_sendbits(device_t dev, mii_bitbang_ops_t ops, > + uint32_t data, int nbits); > + > +#define MWRITE(x) \ > +do { \ > + ops->mbo_write(dev, (x)); \ > + DELAY(1); \ > +} while (/* CONSTCOND */ 0) > + > +#define MREAD ops->mbo_read(dev) > + > +#define MDO ops->mbo_bits[MII_BIT_MDO] > +#define MDI ops->mbo_bits[MII_BIT_MDI] > +#define MDC ops->mbo_bits[MII_BIT_MDC] > +#define MDIRPHY ops->mbo_bits[MII_BIT_DIR_HOST_PHY] > +#define MDIRHOST ops->mbo_bits[MII_BIT_DIR_PHY_HOST] > + > +/* > + * mii_bitbang_sync: > + * > + * Synchronize the MII. > + */ > +void > +mii_bitbang_sync(device_t dev, mii_bitbang_ops_t ops) > +{ > + int i; > + uint32_t v; > + > + v =3D MDIRPHY | MDO; > + > + MWRITE(v); > + for (i =3D 0; i < 32; i++) { > + MWRITE(v | MDC); > + MWRITE(v); > + } > +} > + > +/* > + * mii_bitbang_sendbits: > + * > + * Send a series of bits to the MII. > + */ > +static void > +mii_bitbang_sendbits(device_t dev, mii_bitbang_ops_t ops, uint32_t data, > + int nbits) > +{ > + int i; > + uint32_t v; > + > + v =3D MDIRPHY; > + MWRITE(v); > + > + for (i =3D 1 << (nbits - 1); i !=3D 0; i >>=3D 1) { > + if (data & i) > + v |=3D MDO; > + else > + v &=3D ~MDO; > + MWRITE(v); > + MWRITE(v | MDC); > + MWRITE(v); > + } > +} > + > +/* > + * mii_bitbang_readreg: > + * > + * Read a PHY register by bit-bang'ing the MII. > + */ > +int > +mii_bitbang_readreg(device_t dev, mii_bitbang_ops_t ops, int phy, int re= g) > +{ > + int i, error, val; > + > + mii_bitbang_sync(dev, ops); > + > + mii_bitbang_sendbits(dev, ops, MII_COMMAND_START, 2); > + mii_bitbang_sendbits(dev, ops, MII_COMMAND_READ, 2); > + mii_bitbang_sendbits(dev, ops, phy, 5); > + mii_bitbang_sendbits(dev, ops, reg, 5); > + > + /* Switch direction to PHY->host, without a clock transition. */ > + MWRITE(MDIRHOST); > + > + /* Turnaround clock. */ > + MWRITE(MDIRHOST | MDC); > + MWRITE(MDIRHOST); > + > + /* Check for error. */ > + error =3D MREAD & MDI; > + > + /* Idle clock. */ > + MWRITE(MDIRHOST | MDC); > + MWRITE(MDIRHOST); > + > + val =3D 0; > + for (i =3D 0; i < 16; i++) { > + val <<=3D 1; > + /* Read data prior to clock low-high transition. */ > + if (error =3D=3D 0 && (MREAD & MDI) !=3D 0) > + val |=3D 1; > + > + MWRITE(MDIRHOST | MDC); > + MWRITE(MDIRHOST); > + } > + > + /* Set direction to host->PHY, without a clock transition. */ > + MWRITE(MDIRPHY); > + > + return (error !=3D 0 ? 0 : val); > +} > + > +/* > + * mii_bitbang_writereg: > + * > + * Write a PHY register by bit-bang'ing the MII. > + */ > +void > +mii_bitbang_writereg(device_t dev, mii_bitbang_ops_t ops, int phy, int r= eg, > + int val) > +{ > + > + mii_bitbang_sync(dev, ops); > + > + mii_bitbang_sendbits(dev, ops, MII_COMMAND_START, 2); > + mii_bitbang_sendbits(dev, ops, MII_COMMAND_WRITE, 2); > + mii_bitbang_sendbits(dev, ops, phy, 5); > + mii_bitbang_sendbits(dev, ops, reg, 5); > + mii_bitbang_sendbits(dev, ops, MII_COMMAND_ACK, 2); > + mii_bitbang_sendbits(dev, ops, val, 16); > + > + MWRITE(MDIRPHY); > +} >=20 > Copied: stable/8/sys/dev/mii/mii_bitbang.h (from r226995, head/sys/dev/mi= i/mii_bitbang.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ stable/8/sys/dev/mii/mii_bitbang.h Sun Nov 6 21:09:23 2011 (r227278,= copy of r226995, head/sys/dev/mii/mii_bitbang.h) > @@ -0,0 +1,54 @@ > +/* $NetBSD: mii_bitbang.h,v 1.6 2009/05/12 14:31:27 cegger Exp $ */ > + > +/*- > + * Copyright (c) 1999 The NetBSD Foundation, Inc. > + * All rights reserved. > + * > + * This code is derived from software contributed to The NetBSD Foundati= on > + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, > + * NASA Ames Research Center. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBU= TORS > + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L= IMITED > + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTI= CULAR > + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBU= TORS > + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSIN= ESS > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER = IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS= E) > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O= F THE > + * POSSIBILITY OF SUCH DAMAGE. > + * > + * $FreeBSD$ > + */ > + > +#define MII_BIT_MDO 0 /* data out (host->PHY) */ > +#define MII_BIT_MDI 1 /* data in (PHY->host) */ > +#define MII_BIT_MDC 2 /* clock */ > +#define MII_BIT_DIR_HOST_PHY 3 /* set direction: host->PHY */ > +#define MII_BIT_DIR_PHY_HOST 4 /* set direction: PHY->host */ > +#define MII_NBITS 5 > + > +struct mii_bitbang_ops { > + uint32_t (*mbo_read)(device_t); > + void (*mbo_write)(device_t, uint32_t); > + uint32_t mbo_bits[MII_NBITS]; > +}; > + > +typedef const struct mii_bitbang_ops *mii_bitbang_ops_t; > + > +int mii_bitbang_readreg(device_t dev, mii_bitbang_ops_t ops, > + int phy, int reg); > +void mii_bitbang_sync(device_t dev, mii_bitbang_ops_t ops); > +void mii_bitbang_writereg(device_t dev, mii_bitbang_ops_t ops, > + int phy, int reg, int val); >=20 > Modified: stable/8/sys/dev/nge/if_nge.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/dev/nge/if_nge.c Sun Nov 6 21:09:10 2011 (r227277) > +++ stable/8/sys/dev/nge/if_nge.c Sun Nov 6 21:09:23 2011 (r227278) > @@ -117,6 +117,7 @@ __FBSDID("$FreeBSD$"); > #include > =20 > #include > +#include > #include > =20 > #include > @@ -138,7 +139,7 @@ MODULE_DEPEND(nge, miibus, 1, 1, 1); > /* > * Various supported device vendors/types and their names. > */ > -static struct nge_type nge_devs[] =3D { > +static const struct nge_type const nge_devs[] =3D { > { NGE_VENDORID, NGE_DEVICEID, > "National Semiconductor Gigabit Ethernet" }, > { 0, 0, NULL } > @@ -180,11 +181,6 @@ static void nge_eeprom_putbyte(struct ng > static void nge_eeprom_getword(struct nge_softc *, int, uint16_t *); > static void nge_read_eeprom(struct nge_softc *, caddr_t, int, int); > =20 > -static void nge_mii_sync(struct nge_softc *); > -static void nge_mii_send(struct nge_softc *, uint32_t, int); > -static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *); > -static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *); > - > static int nge_miibus_readreg(device_t, int, int); > static int nge_miibus_writereg(device_t, int, int, int); > static void nge_miibus_statchg(device_t); > @@ -200,6 +196,24 @@ static void nge_sysctl_node(struct nge_s > static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); > static int sysctl_hw_nge_int_holdoff(SYSCTL_HANDLER_ARGS); > =20 > +/* > + * MII bit-bang glue > + */ >=20 > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > _______________________________________________ > svn-src-stable-8@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-8 > To unsubscribe, send any mail to "svn-src-stable-8-unsubscribe@freebsd.or= g" --qMm9M+Fa2AknHoGS Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) Comment: http://bit.ly/0x89D8547E iQEcBAEBAgAGBQJOtz1/AAoJEJBXh4mJ2FR+evwH/iGnUgNS6VoErPz2CdrpuGb0 iiMS91aXk6jA3Ot+IH0yR1oYABj4F3nMD5PquJyTL6FQUlOrl/YH6+HPD1qRsnhX T27tG6HyyVRWz8XKhAmssrq72jJsiqLPXs46bi1a9Z6hIxZDQ/yPF8eZ2FgNJXnN kFLNWe+j9ViM1xmoEl9N8xXwaN7+PzmxFazziIE3wp8Jj8SV0nU/eR22KhLBIxv3 EMRz5qQcLAleiEmE7bu0qrasHBRTiMFdpxOXa2TcaebOrIeg8Qv4MCaSXLr+/YIP jTzJXqQ9+HehyApfUIHzX7/CJTSNTnL8BMuhlSlBsUb9Bn7/xq/Pw9b5lZvQRxo= =3a+T -----END PGP SIGNATURE----- --qMm9M+Fa2AknHoGS-- From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 11:31:15 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC6EC106564A; Mon, 7 Nov 2011 11:31:14 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB74D8FC0C; Mon, 7 Nov 2011 11:31:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA7BVE9f076999; Mon, 7 Nov 2011 11:31:14 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA7BVE9J076997; Mon, 7 Nov 2011 11:31:14 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201111071131.pA7BVE9J076997@svn.freebsd.org> From: Marius Strobl Date: Mon, 7 Nov 2011 11:31:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227300 - stable/8/sys/conf X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 11:31:15 -0000 Author: marius Date: Mon Nov 7 11:31:14 2011 New Revision: 227300 URL: http://svn.freebsd.org/changeset/base/227300 Log: Automatically compile in mii_bitbang.c if one of the drivers depending on it since r227278 is compiled into the kernel. This restores POLA for people that don't use "options miibus" but "options mii" and individual PHY drivers instead. This is a direct commit to stable/8. Modified: stable/8/sys/conf/files Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Mon Nov 7 09:42:22 2011 (r227299) +++ stable/8/sys/conf/files Mon Nov 7 11:31:14 2011 (r227300) @@ -1309,7 +1309,9 @@ dev/mii/ip1000phy.c optional miibus | i dev/mii/jmphy.c optional miibus | jmphy dev/mii/lxtphy.c optional miibus | lxtphy dev/mii/mii.c optional miibus | mii -dev/mii/mii_bitbang.c optional miibus | mii_bitbang +dev/mii/mii_bitbang.c optional miibus | mii_bitbang | bm | \ + dc | nge | rl | sis | smc | \ + ste | stge | tl | wb | xl dev/mii/mii_physubr.c optional miibus | mii dev/mii/miibus_if.m optional miibus | mii dev/mii/mlphy.c optional miibus | mlphy From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 11:42:59 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5754106564A; Mon, 7 Nov 2011 11:42:59 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 33CFE8FC0A; Mon, 7 Nov 2011 11:42:58 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id pA7BgpVa093811; Mon, 7 Nov 2011 12:42:51 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id pA7Bgp2w093810; Mon, 7 Nov 2011 12:42:51 +0100 (CET) (envelope-from marius) Date: Mon, 7 Nov 2011 12:42:51 +0100 From: Marius Strobl To: Jason Hellenthal Message-ID: <20111107114251.GA93221@alchemy.franken.de> References: <201111062109.pA6L9OLV042060@svn.freebsd.org> <20111107020759.GA45996@DataIX.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111107020759.GA45996@DataIX.net> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r227278 - in stable/8/sys: arm/conf conf dev/bm dev/dc dev/mii dev/nge dev/sis dev/smc dev/ste dev/stge dev/tl dev/wb dev/xl modules/mii pci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 11:42:59 -0000 On Sun, Nov 06, 2011 at 09:07:59PM -0500, Jason Hellenthal wrote: > > > The following commmit broke building without device miibus at least on i386. > > if_dc.o(.text+0x24b4): In function `dc_miibus_writereg': > /usr/src/sys/dev/dc/if_dc.c:806: undefined reference to `mii_bitbang_writereg' > if_dc.o(.text+0x26cc): In function `dc_miibus_readreg': > /usr/src/sys/dev/dc/if_dc.c:743: undefined reference to `mii_bitbang_readreg' > > If you try to use the modular device mii and the single *phy you will get the above error when it comes time to link the kernel. Yes, you now need to additionally put "options mii_bitbang" into your kernel configuration file if you don't use "options miibus" but "options mii" and individual PHY drivers in combination with one of the MAC drivers that where converted to use the common MII bitbang'ing code, see sys/conf/NOTES. Given that this is a rather exotic approach intended for embedded use it didn't occur to me to note it beyond NOTES. However, thinking about it I decided for stable/7 and stable/8 to automatically drag in the common MII bitbang'ing code if one of the MAC drivers depending on it is compiled into the kernel in order to not break POLA. Marius From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 13:17:40 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 870E51065670; Mon, 7 Nov 2011 13:17:40 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 74B468FC0C; Mon, 7 Nov 2011 13:17:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA7DHePk080588; Mon, 7 Nov 2011 13:17:40 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA7DHe8g080582; Mon, 7 Nov 2011 13:17:40 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201111071317.pA7DHe8g080582@svn.freebsd.org> From: Marius Strobl Date: Mon, 7 Nov 2011 13:17:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227303 - in stable/8/sys: dev/esp sparc64/sbus X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 13:17:40 -0000 Author: marius Date: Mon Nov 7 13:17:40 2011 New Revision: 227303 URL: http://svn.freebsd.org/changeset/base/227303 Log: MFC: r226947, r226949, r227284 - Use device_t rather than the NetBSDish struct device. - Move esp_devclass to ncr53c9x.c in order to allow different bus front-ends to use it. - Use KOBJMETHOD_END. - Remove the gl_clear_latched_intr hook as it's not needed for any of the chips nor the front-ends supported in FreeBSD and likely never will be. - Correct the DMA constraints and only limit the tag used for the transfer buffers to 32-bit DMA as that address is written into a 32-bit register. - The ESP200 also only supports up to 64k transfers. - Don't let the DMA and SBus front-end supply a maximum transfer size larger than MAXPHYS as that's the maximum the upper layers use and we otherwise just waste resources unnecessarily. - Initialize the ECB callout and don't zero the handle when returning ECBs to the free list so that ncr53c9x_callout() actually is called with the driver lock held. - On detach the driver lock should be held across cam_sim_free() according to isp(4) and a panic received. - Check the return value of NCRDMA_SETUP(), i.e. bus_dmamap_load(9), and try to handle failures gracefully. - In ncr53c9x_action() replace N calls to xpt_done() in a switch with just one at the end. - On XPT_PATH_INQ report "NCR" rather than "Sun" as the vendor as the former is somewhat more correct as well as the maximum supported transfer size via maxio in order to take advantage of controllers that that can handle more than DFLTPHYS. - Freeze the device queue if a request didn't complete without error and isn't already frozen. - Print the number of MESSAGE (EXTENDED) rejected. - Fix the path encoded in the multiple inclusion protection of ncr53c9xvar.h. - Correct the DMA constraints used in the LSI64854 core to not exceed the maximum supported transfer size and include the boundary so we don't need to check on every setup of a DMA transfer. - Let the bus DMA map callbacks do nothing in case of an error. - Correctly handle > 64k transfers for FAS366 in the LSI64854. A new feature flag NCR_F_LARGEXFER was introduced so we just need to check for this one and not for individual controllers supporting large transfers in several places. - Let the LSI64854 core load transfer buffers using BUS_DMA_NOWAIT as the NCR53C9x core can't handle EINPROGRESS. Due to lack of bounce buffers support, sparc64 doesn't actually use EINPROGRESS and likely never will, as an example for writing additional front-ends for the NCR53C9x core it makes sense to set BUS_DMA_NOWAIT anyway though. - Some minor cleanup. Modified: stable/8/sys/dev/esp/esp_sbus.c stable/8/sys/dev/esp/ncr53c9x.c stable/8/sys/dev/esp/ncr53c9xvar.h stable/8/sys/sparc64/sbus/lsi64854.c stable/8/sys/sparc64/sbus/lsi64854var.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/esp/esp_sbus.c ============================================================================== --- stable/8/sys/dev/esp/esp_sbus.c Mon Nov 7 13:16:51 2011 (r227302) +++ stable/8/sys/dev/esp/esp_sbus.c Mon Nov 7 13:17:40 2011 (r227303) @@ -68,13 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -92,7 +92,7 @@ __FBSDID("$FreeBSD$"); struct esp_softc { struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ - struct device *sc_dev; + device_t sc_dev; struct resource *sc_res; @@ -102,8 +102,6 @@ struct esp_softc { struct lsi64854_softc *sc_dma; /* pointer to my DMA */ }; -static devclass_t esp_devclass; - static int esp_probe(device_t); static int esp_dma_attach(device_t); static int esp_dma_detach(device_t); @@ -118,7 +116,8 @@ static device_method_t esp_dma_methods[] DEVMETHOD(device_detach, esp_dma_detach), DEVMETHOD(device_suspend, esp_suspend), DEVMETHOD(device_resume, esp_resume), - {0, 0} + + KOBJMETHOD_END }; static driver_t esp_dma_driver = { @@ -136,7 +135,8 @@ static device_method_t esp_sbus_methods[ DEVMETHOD(device_detach, esp_sbus_detach), DEVMETHOD(device_suspend, esp_suspend), DEVMETHOD(device_resume, esp_resume), - {0, 0} + + KOBJMETHOD_END }; static driver_t esp_sbus_driver = { @@ -175,7 +175,6 @@ static const struct ncr53c9x_glue const esp_dma_go, esp_dma_stop, esp_dma_isactive, - NULL, /* gl_clear_latched_intr */ }; static int @@ -245,9 +244,9 @@ esp_sbus_attach(device_t dev) BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ - 0, /* nsegments */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ + BUS_SPACE_MAXSIZE, /* maxsize */ + BUS_SPACE_UNRESTRICTED, /* nsegments */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ 0, /* flags */ NULL, NULL, /* no locking */ &lsc->sc_parent_dmat); @@ -292,8 +291,10 @@ esp_sbus_attach(device_t dev) } for (i = 0; i < nchildren; i++) { if (device_is_attached(children[i]) && - sbus_get_slot(children[i]) == sbus_get_slot(dev) && - strcmp(ofw_bus_get_name(children[i]), "dma") == 0) { + sbus_get_slot(children[i]) == + sbus_get_slot(dev) && + strcmp(ofw_bus_get_name(children[i]), + "dma") == 0) { /* XXX hackery */ esc->sc_dma = (struct lsi64854_softc *) device_get_softc(children[i]); @@ -453,13 +454,6 @@ espattach(struct esp_softc *esc, const s NCR_LOCK_INIT(sc); - /* Attach the DMA engine. */ - error = lsi64854_attach(esc->sc_dma); - if (error != 0) { - device_printf(esc->sc_dev, "lsi64854_attach failed\n"); - goto fail_lock; - } - sc->sc_id = OF_getscsinitid(esc->sc_dev); #ifdef ESP_SBUS_DEBUG @@ -516,9 +510,9 @@ espattach(struct esp_softc *esc, const s NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); if ((NCR_READ_REG(sc, NCR_CFG2) & ~NCRCFG2_RSVD) != - (NCRCFG2_SCSI2 | NCRCFG2_RPE)) { + (NCRCFG2_SCSI2 | NCRCFG2_RPE)) sc->sc_rev = NCR_VARIANT_ESP100; - } else { + else { sc->sc_cfg2 = NCRCFG2_SCSI2; NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); sc->sc_cfg3 = 0; @@ -526,9 +520,9 @@ espattach(struct esp_softc *esc, const s sc->sc_cfg3 = (NCRCFG3_CDB | NCRCFG3_FCLK); NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); if (NCR_READ_REG(sc, NCR_CFG3) != - (NCRCFG3_CDB | NCRCFG3_FCLK)) { + (NCRCFG3_CDB | NCRCFG3_FCLK)) sc->sc_rev = NCR_VARIANT_ESP100A; - } else { + else { /* NCRCFG2_FE enables > 64K transfers. */ sc->sc_cfg2 |= NCRCFG2_FE; sc->sc_cfg3 = 0; @@ -543,9 +537,11 @@ espattach(struct esp_softc *esc, const s case 0x02: if ((uid & 0x07) == 0x02) - sc->sc_rev = NCR_VARIANT_FAS216; + sc->sc_rev = + NCR_VARIANT_FAS216; else - sc->sc_rev = NCR_VARIANT_FAS236; + sc->sc_rev = + NCR_VARIANT_FAS236; break; case 0x0a: @@ -560,7 +556,8 @@ espattach(struct esp_softc *esc, const s */ device_printf(esc->sc_dev, "Unknown chip\n"); - goto fail_lsi; + error = ENXIO; + goto fail_lock; } } } @@ -571,12 +568,6 @@ espattach(struct esp_softc *esc, const s #endif /* - * XXX minsync and maxxfer _should_ be set up in MI code, - * XXX but it appears to have some dependency on what sort - * XXX of DMA we're hooked up to, etc. - */ - - /* * This is the value used to start sync negotiations * Note that the NCR register "SYNCTP" is programmed * in "clocks per byte", and has a minimum value of 4. @@ -587,31 +578,27 @@ espattach(struct esp_softc *esc, const s */ sc->sc_minsync = 1000 / sc->sc_freq; + /* + * Except for some variants the maximum transfer size is 64k. + */ + sc->sc_maxxfer = 64 * 1024; sc->sc_maxoffset = 15; sc->sc_extended_geom = 1; /* * Alas, we must now modify the value a bit, because it's - * only valid when can switch on FASTCLK and FASTSCSI bits - * in config register 3... + * only valid when we can switch on FASTCLK and FASTSCSI bits + * in the config register 3... */ switch (sc->sc_rev) { case NCR_VARIANT_ESP100: sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - sc->sc_maxxfer = 64 * 1024; sc->sc_minsync = 0; /* No synch on old chip? */ break; case NCR_VARIANT_ESP100A: - sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - sc->sc_maxxfer = 64 * 1024; - /* Min clocks/byte is 5 */ - sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5); - break; - case NCR_VARIANT_ESP200: sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - sc->sc_maxxfer = 16 * 1024 * 1024; /* Min clocks/byte is 5 */ sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5); break; @@ -642,6 +629,19 @@ espattach(struct esp_softc *esc, const s break; } + /* + * Given that we allocate resources based on sc->sc_maxxfer it doesn't + * make sense to supply a value higher than the maximum actually used. + */ + sc->sc_maxxfer = min(sc->sc_maxxfer, MAXPHYS); + + /* Attach the DMA engine. */ + error = lsi64854_attach(esc->sc_dma); + if (error != 0) { + device_printf(esc->sc_dev, "lsi64854_attach failed\n"); + goto fail_lock; + } + /* Establish interrupt channel. */ i = 0; if ((esc->sc_irqres = bus_alloc_resource_any(esc->sc_dev, SYS_RES_IRQ, Modified: stable/8/sys/dev/esp/ncr53c9x.c ============================================================================== --- stable/8/sys/dev/esp/ncr53c9x.c Mon Nov 7 13:16:51 2011 (r227302) +++ stable/8/sys/dev/esp/ncr53c9x.c Mon Nov 7 13:17:40 2011 (r227303) @@ -123,6 +123,8 @@ __FBSDID("$FreeBSD$"); #include #include +devclass_t esp_devclass; + MODULE_DEPEND(esp, cam, 1, 1, 1); #ifdef NCR53C9X_DEBUG @@ -179,8 +181,7 @@ static inline int ncr53c9x_stp2cpb(struc #define NCR_SET_COUNT(sc, size) do { \ NCR_WRITE_REG((sc), NCR_TCL, (size)); \ NCR_WRITE_REG((sc), NCR_TCM, (size) >> 8); \ - if ((sc->sc_cfg2 & NCRCFG2_FE) || \ - (sc->sc_rev == NCR_VARIANT_FAS366)) \ + if ((sc->sc_features & NCR_F_LARGEXFER) != 0) \ NCR_WRITE_REG((sc), NCR_TCH, (size) >> 16); \ if (sc->sc_rev == NCR_VARIANT_FAS366) \ NCR_WRITE_REG(sc, NCR_RCH, 0); \ @@ -391,6 +392,7 @@ ncr53c9x_attach(struct ncr53c9x_softc *s ecb = &sc->ecb_array[i]; ecb->sc = sc; ecb->tag_id = i; + callout_init_mtx(&ecb->ch, &sc->sc_lock, 0); TAILQ_INSERT_HEAD(&sc->free_list, ecb, free_links); } @@ -449,10 +451,10 @@ ncr53c9x_detach(struct ncr53c9x_softc *s xpt_register_async(0, ncr53c9x_async, sc->sc_sim, sc->sc_path); xpt_free_path(sc->sc_path); xpt_bus_deregister(cam_sim_path(sc->sc_sim)); + cam_sim_free(sc->sc_sim, TRUE); NCR_UNLOCK(sc); - cam_sim_free(sc->sc_sim, TRUE); free(sc->ecb_array, M_DEVBUF); free(sc->sc_tinfo, M_DEVBUF); if (sc->sc_imess_self) @@ -504,6 +506,8 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc /* FALLTHROUGH */ case NCR_VARIANT_ESP100A: sc->sc_features |= NCR_F_SELATN3; + if ((sc->sc_cfg2 & NCRCFG2_FE) != 0) + sc->sc_features |= NCR_F_LARGEXFER; NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); /* FALLTHROUGH */ case NCR_VARIANT_ESP100: @@ -514,8 +518,8 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc break; case NCR_VARIANT_FAS366: - sc->sc_features |= - NCR_F_HASCFG3 | NCR_F_FASTSCSI | NCR_F_SELATN3; + sc->sc_features |= NCR_F_HASCFG3 | NCR_F_FASTSCSI | + NCR_F_SELATN3 | NCR_F_LARGEXFER; sc->sc_cfg3 = NCRFASCFG3_FASTCLK | NCRFASCFG3_OBAUTO; if (sc->sc_id > 7) sc->sc_cfg3 |= NCRFASCFG3_IDBIT3; @@ -711,9 +715,6 @@ ncr53c9x_readregs(struct ncr53c9x_softc sc->sc_espintr = NCR_READ_REG(sc, NCR_INTR); - if (sc->sc_glue->gl_clear_latched_intr != NULL) - (*sc->sc_glue->gl_clear_latched_intr)(sc); - /* * Determine the SCSI bus phase, return either a real SCSI bus phase * or some pseudo phase we use to detect certain exceptions. @@ -806,7 +807,7 @@ ncr53c9x_select(struct ncr53c9x_softc *s struct ncr53c9x_tinfo *ti; uint8_t *cmd; size_t dmasize; - int clen, selatn3, selatns; + int clen, error, selatn3, selatns; int lun = ecb->ccb->ccb_h.target_lun; int target = ecb->ccb->ccb_h.target_id; @@ -887,13 +888,19 @@ ncr53c9x_select(struct ncr53c9x_softc *s dmasize = clen; sc->sc_cmdlen = clen; sc->sc_cmdp = cmd; - NCRDMA_SETUP(sc, &sc->sc_cmdp, &sc->sc_cmdlen, 0, &dmasize); + error = NCRDMA_SETUP(sc, &sc->sc_cmdp, &sc->sc_cmdlen, 0, + &dmasize); + if (error != 0) { + sc->sc_cmdlen = 0; + sc->sc_cmdp = NULL; + goto cmd; + } + /* Program the SCSI counter. */ NCR_SET_COUNT(sc, dmasize); /* Load the count in. */ - /* if (sc->sc_rev != NCR_VARIANT_FAS366) */ - NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); + NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); /* And get the target's attention. */ if (selatn3) { @@ -906,6 +913,7 @@ ncr53c9x_select(struct ncr53c9x_softc *s return; } +cmd: /* * Who am I? This is where we tell the target that we are * happy for it to disconnect etc. @@ -989,13 +997,11 @@ ncr53c9x_action(struct cam_sim *sim, uni case XPT_RESET_BUS: ncr53c9x_init(sc, 1); ccb->ccb_h.status = CAM_REQ_CMP; - xpt_done(ccb); - return; + break; case XPT_CALC_GEOMETRY: cam_calc_geometry(&ccb->ccg, sc->sc_extended_geom); - xpt_done(ccb); - return; + break; case XPT_PATH_INQ: cpi = &ccb->cpi; @@ -1009,19 +1015,19 @@ ncr53c9x_action(struct cam_sim *sim, uni cpi->max_target = sc->sc_ntarg - 1; cpi->max_lun = 7; cpi->initiator_id = sc->sc_id; - cpi->bus_id = 0; - cpi->base_transfer_speed = 3300; strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Sun", HBA_IDLEN); + strncpy(cpi->hba_vid, "NCR", HBA_IDLEN); strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; + cpi->bus_id = 0; + cpi->base_transfer_speed = 3300; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->maxio = sc->sc_maxxfer; ccb->ccb_h.status = CAM_REQ_CMP; - xpt_done(ccb); - return; + break; case XPT_GET_TRAN_SETTINGS: cts = &ccb->cts; @@ -1064,28 +1070,24 @@ ncr53c9x_action(struct cam_sim *sim, uni CTS_SPI_VALID_DISC; scsi->valid = CTS_SCSI_VALID_TQ; ccb->ccb_h.status = CAM_REQ_CMP; - xpt_done(ccb); - return; + break; case XPT_ABORT: device_printf(sc->sc_dev, "XPT_ABORT called\n"); ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; - xpt_done(ccb); - return; + break; case XPT_TERM_IO: device_printf(sc->sc_dev, "XPT_TERM_IO called\n"); ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; - xpt_done(ccb); - return; + break; case XPT_RESET_DEV: case XPT_SCSI_IO: if (ccb->ccb_h.target_id < 0 || ccb->ccb_h.target_id >= sc->sc_ntarg) { ccb->ccb_h.status = CAM_PATH_INVALID; - xpt_done(ccb); - return; + goto done; } /* Get an ECB to use. */ ecb = ncr53c9x_get_ecb(sc); @@ -1097,8 +1099,7 @@ ncr53c9x_action(struct cam_sim *sim, uni xpt_freeze_simq(sim, 1); ccb->ccb_h.status = CAM_REQUEUE_REQ; device_printf(sc->sc_dev, "unable to allocate ecb\n"); - xpt_done(ccb); - return; + goto done; } /* Initialize ecb. */ @@ -1127,7 +1128,7 @@ ncr53c9x_action(struct cam_sim *sim, uni ecb->flags |= ECB_READY; if (sc->sc_state == NCR_IDLE) ncr53c9x_sched(sc); - break; + return; case XPT_SET_TRAN_SETTINGS: cts = &ccb->cts; @@ -1165,16 +1166,16 @@ ncr53c9x_action(struct cam_sim *sim, uni } ccb->ccb_h.status = CAM_REQ_CMP; - xpt_done(ccb); - return; + break; default: device_printf(sc->sc_dev, "Unhandled function code %d\n", ccb->ccb_h.func_code); ccb->ccb_h.status = CAM_PROVIDE_FAIL; - xpt_done(ccb); - return; } + +done: + xpt_done(ccb); } /* @@ -1329,11 +1330,10 @@ ncr53c9x_sched(struct ncr53c9x_softc *sc sc->sc_nexus = ecb; ncr53c9x_select(sc, ecb); break; - } else { + } else NCR_TRACE(("[%s %d:%d busy] \n", __func__, ecb->ccb->ccb_h.target_id, ecb->ccb->ccb_h.target_lun)); - } } } @@ -1412,10 +1412,10 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, */ if (ccb->ccb_h.status == CAM_REQ_CMP) { ccb->csio.scsi_status = ecb->stat; - if ((ecb->flags & ECB_ABORT) != 0) { + if ((ecb->flags & ECB_ABORT) != 0) ccb->ccb_h.status = CAM_CMD_TIMEOUT; - } else if ((ecb->flags & ECB_SENSE) != 0 && - (ecb->stat != SCSI_STATUS_CHECK_COND)) { + else if ((ecb->flags & ECB_SENSE) != 0 && + (ecb->stat != SCSI_STATUS_CHECK_COND)) { ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND; ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; @@ -1439,13 +1439,15 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, } ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; } - } else { + } else ccb->csio.resid = ecb->dleft; - } if (ecb->stat == SCSI_STATUS_QUEUE_FULL) ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; else if (ecb->stat == SCSI_STATUS_BUSY) ccb->ccb_h.status = CAM_SCSI_BUSY; + } else if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) { + ccb->ccb_h.status |= CAM_DEV_QFRZN; + xpt_freeze_devq(ccb->ccb_h.path, 1); } #ifdef NCR53C9X_DEBUG @@ -1473,7 +1475,7 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, } } - if (ccb->ccb_h.status == CAM_SEL_TIMEOUT) { + if ((ccb->ccb_h.status & CAM_SEL_TIMEOUT) != 0) { /* Selection timeout -- discard this LUN if empty. */ if (li->untagged == NULL && li->used == 0) { if (lun < NCR_NLUN) @@ -2030,8 +2032,8 @@ gotit: default: xpt_print_path(ecb->ccb->ccb_h.path); - printf("unrecognized MESSAGE EXTENDED;" - " sending REJECT\n"); + printf("unrecognized MESSAGE EXTENDED 0x%x;" + " sending REJECT\n", sc->sc_imess[2]); goto reject; } break; @@ -2039,7 +2041,8 @@ gotit: default: NCR_MSGS(("ident ")); xpt_print_path(ecb->ccb->ccb_h.path); - printf("unrecognized MESSAGE; sending REJECT\n"); + printf("unrecognized MESSAGE 0x%x; sending REJECT\n", + sc->sc_imess[0]); /* FALLTHROUGH */ reject: ncr53c9x_sched_msgout(SEND_REJECT); @@ -2109,6 +2112,7 @@ ncr53c9x_msgout(struct ncr53c9x_softc *s struct ncr53c9x_tinfo *ti; struct ncr53c9x_ecb *ecb; size_t size; + int error; #ifdef NCR53C9X_DEBUG int i; #endif @@ -2246,17 +2250,14 @@ ncr53c9x_msgout(struct ncr53c9x_softc *s NCR_MSGS(("> ")); } #endif - if (sc->sc_rev == NCR_VARIANT_FAS366) { - /* - * XXX FIFO size - */ - ncr53c9x_flushfifo(sc); - ncr53c9x_wrfifo(sc, sc->sc_omp, sc->sc_omlen); - NCRCMD(sc, NCRCMD_TRANS); - } else { + + if (sc->sc_rev != NCR_VARIANT_FAS366) { /* (Re)send the message. */ size = ulmin(sc->sc_omlen, sc->sc_maxxfer); - NCRDMA_SETUP(sc, &sc->sc_omp, &sc->sc_omlen, 0, &size); + error = NCRDMA_SETUP(sc, &sc->sc_omp, &sc->sc_omlen, 0, &size); + if (error != 0) + goto cmd; + /* Program the SCSI counter. */ NCR_SET_COUNT(sc, size); @@ -2264,7 +2265,16 @@ ncr53c9x_msgout(struct ncr53c9x_softc *s NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); NCRCMD(sc, NCRCMD_TRANS | NCRCMD_DMA); NCRDMA_GO(sc); + return; } + +cmd: + /* + * XXX FIFO size + */ + ncr53c9x_flushfifo(sc); + ncr53c9x_wrfifo(sc, sc->sc_omp, sc->sc_omlen); + NCRCMD(sc, NCRCMD_TRANS); } void @@ -2299,7 +2309,7 @@ ncr53c9x_intr1(struct ncr53c9x_softc *sc struct ncr53c9x_tinfo *ti; struct timeval cur, wait; size_t size; - int i, nfifo; + int error, i, nfifo; uint8_t msg; NCR_LOCK_ASSERT(sc, MA_OWNED); @@ -2974,8 +2984,14 @@ msgin: size = ecb->clen; sc->sc_cmdlen = size; sc->sc_cmdp = (void *)&ecb->cmd.cmd; - NCRDMA_SETUP(sc, &sc->sc_cmdp, &sc->sc_cmdlen, + error = NCRDMA_SETUP(sc, &sc->sc_cmdp, &sc->sc_cmdlen, 0, &size); + if (error != 0) { + sc->sc_cmdlen = 0; + sc->sc_cmdp = NULL; + goto cmd; + } + /* Program the SCSI counter. */ NCR_SET_COUNT(sc, size); @@ -2985,30 +3001,51 @@ msgin: /* Start the command transfer. */ NCRCMD(sc, NCRCMD_TRANS | NCRCMD_DMA); NCRDMA_GO(sc); - } else { - ncr53c9x_wrfifo(sc, (uint8_t *)&ecb->cmd.cmd, - ecb->clen); - NCRCMD(sc, NCRCMD_TRANS); + sc->sc_prevphase = COMMAND_PHASE; + break; } +cmd: + ncr53c9x_wrfifo(sc, (uint8_t *)&ecb->cmd.cmd, ecb->clen); + NCRCMD(sc, NCRCMD_TRANS); sc->sc_prevphase = COMMAND_PHASE; break; case DATA_OUT_PHASE: NCR_PHASE(("DATA_OUT_PHASE [%ld] ", (long)sc->sc_dleft)); + sc->sc_prevphase = DATA_OUT_PHASE; NCRCMD(sc, NCRCMD_FLUSH); size = ulmin(sc->sc_dleft, sc->sc_maxxfer); - NCRDMA_SETUP(sc, &sc->sc_dp, &sc->sc_dleft, 0, &size); - sc->sc_prevphase = DATA_OUT_PHASE; + error = NCRDMA_SETUP(sc, &sc->sc_dp, &sc->sc_dleft, 0, &size); goto setup_xfer; case DATA_IN_PHASE: NCR_PHASE(("DATA_IN_PHASE ")); + sc->sc_prevphase = DATA_IN_PHASE; if (sc->sc_rev == NCR_VARIANT_ESP100) NCRCMD(sc, NCRCMD_FLUSH); size = ulmin(sc->sc_dleft, sc->sc_maxxfer); - NCRDMA_SETUP(sc, &sc->sc_dp, &sc->sc_dleft, 1, &size); - sc->sc_prevphase = DATA_IN_PHASE; - setup_xfer: + error = NCRDMA_SETUP(sc, &sc->sc_dp, &sc->sc_dleft, 1, &size); +setup_xfer: + if (error != 0) { + switch (error) { + case EFBIG: + ecb->ccb->ccb_h.status |= CAM_REQ_TOO_BIG; + break; + case EINPROGRESS: + panic("%s: cannot deal with deferred DMA", + __func__); + case EINVAL: + ecb->ccb->ccb_h.status |= CAM_REQ_INVALID; + break; + case ENOMEM: + ecb->ccb->ccb_h.status |= CAM_REQUEUE_REQ; + break; + default: + ecb->ccb->ccb_h.status |= CAM_REQ_CMP_ERR; + } + goto finish; + } + /* Target returned to data phase: wipe "done" memory */ ecb->flags &= ~ECB_TENTATIVE_DONE; Modified: stable/8/sys/dev/esp/ncr53c9xvar.h ============================================================================== --- stable/8/sys/dev/esp/ncr53c9xvar.h Mon Nov 7 13:16:51 2011 (r227302) +++ stable/8/sys/dev/esp/ncr53c9xvar.h Mon Nov 7 13:17:40 2011 (r227303) @@ -68,8 +68,8 @@ /* $FreeBSD$ */ -#ifndef _DEV_IC_NCR53C9XVAR_H_ -#define _DEV_IC_NCR53C9XVAR_H_ +#ifndef _NCR53C9XVAR_H_ +#define _NCR53C9XVAR_H_ #include @@ -115,7 +115,8 @@ * scsi_status,sense_data}. */ struct ncr53c9x_ecb { - /* These fields are preserved between alloc and free */ + /* These fields are preserved between alloc and free. */ + struct callout ch; struct ncr53c9x_softc *sc; int tag_id; int flags; @@ -130,7 +131,6 @@ struct ncr53c9x_ecb { #define ECB_RESET 0x80 #define ECB_TENTATIVE_DONE 0x100 int timeout; - struct callout ch; struct { uint8_t msg[3]; /* Selection Id msg and tags */ @@ -290,7 +290,7 @@ extern int ncr53c9x_debug; struct ncr53c9x_softc; /* - * Function switch used as glue to MD code. + * Function switch used as glue to MD code */ struct ncr53c9x_glue { /* Mandatory entry points. */ @@ -304,9 +304,6 @@ struct ncr53c9x_glue { void (*gl_dma_go)(struct ncr53c9x_softc *); void (*gl_dma_stop)(struct ncr53c9x_softc *); int (*gl_dma_isactive)(struct ncr53c9x_softc *); - - /* Optional entry points. */ - void (*gl_clear_latched_intr)(struct ncr53c9x_softc *); }; struct ncr53c9x_softc { @@ -330,7 +327,7 @@ struct ncr53c9x_softc { uint8_t sc_ccf; /* Clock Conversion */ uint8_t sc_timeout; - /* register copies, see espreadregs() */ + /* register copies, see ncr53c9x_readregs() */ uint8_t sc_espintr; uint8_t sc_espstat; uint8_t sc_espstep; @@ -415,6 +412,7 @@ struct ncr53c9x_softc { #define NCR_F_FASTSCSI 0x02 /* chip supports Fast mode */ #define NCR_F_DMASELECT 0x04 /* can do dmaselect */ #define NCR_F_SELATN3 0x08 /* chip supports SELATN3 command */ +#define NCR_F_LARGEXFER 0x10 /* chip supports transfers > 64k */ /* values for sc_msgout */ #define SEND_DEV_RESET 0x0001 @@ -499,8 +497,10 @@ struct ncr53c9x_softc { #define ncr53c9x_cpb2stp(sc, cpb) \ ((250 * (cpb)) / (sc)->sc_freq) +extern devclass_t esp_devclass; + int ncr53c9x_attach(struct ncr53c9x_softc *sc); int ncr53c9x_detach(struct ncr53c9x_softc *sc); void ncr53c9x_intr(void *arg); -#endif /* _DEV_IC_NCR53C9XVAR_H_ */ +#endif /* _NCR53C9XVAR_H_ */ Modified: stable/8/sys/sparc64/sbus/lsi64854.c ============================================================================== --- stable/8/sys/sparc64/sbus/lsi64854.c Mon Nov 7 13:16:51 2011 (r227302) +++ stable/8/sys/sparc64/sbus/lsi64854.c Mon Nov 7 13:17:40 2011 (r227303) @@ -94,7 +94,12 @@ int lsi64854debug = 0; #define DPRINTF(a,x) #endif -#define MAX_DMA_SZ (16*1024*1024) +/* + * The rules say we cannot transfer more than the limit of this DMA chip (64k + * for old and 16Mb for new), and we cannot cross a 16Mb boundary. + */ +#define MAX_DMA_SZ (64 * 1024) +#define BOUNDARY (16 * 1024 * 1024) static void lsi64854_reset(struct lsi64854_softc *); static void lsi64854_map_scsi(void *, bus_dma_segment_t *, int, int); @@ -125,6 +130,7 @@ lsi64854_attach(struct lsi64854_softc *s lockfunc = NULL; lockfuncarg = NULL; + sc->sc_maxdmasize = MAX_DMA_SZ; switch (sc->sc_channel) { case L64854_CHANNEL_SCSI: @@ -135,6 +141,7 @@ lsi64854_attach(struct lsi64854_softc *s } lockfunc = busdma_lock_mutex; lockfuncarg = &nsc->sc_lock; + sc->sc_maxdmasize = nsc->sc_maxxfer; sc->intr = lsi64854_scsi_intr; sc->setup = lsi64854_setup; break; @@ -153,13 +160,13 @@ lsi64854_attach(struct lsi64854_softc *s if (sc->setup != NULL) { error = bus_dma_tag_create( sc->sc_parent_dmat, /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + 1, BOUNDARY, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - MAX_DMA_SZ, /* maxsize */ + sc->sc_maxdmasize, /* maxsize */ 1, /* nsegments */ - MAX_DMA_SZ, /* maxsegsize */ + sc->sc_maxdmasize, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ lockfunc, lockfuncarg, /* lockfunc, lockfuncarg */ &sc->sc_buffer_dmat); @@ -250,24 +257,25 @@ lsi64854_detach(struct lsi64854_softc *s * other revs: D_ESC_R_PEND bit reads as 0 \ */ \ DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\ - if (sc->sc_rev != DMAREV_HME) { \ - /* \ - * Select drain bit based on revision \ - * also clears errors and D_TC flag \ - */ \ - csr = L64854_GCSR(sc); \ - if (sc->sc_rev == DMAREV_1 || sc->sc_rev == DMAREV_0) \ - csr |= D_ESC_DRAIN; \ - else \ - csr |= L64854_INVALIDATE; \ + if (sc->sc_rev != DMAREV_HME) { \ + /* \ + * Select drain bit based on revision \ + * also clears errors and D_TC flag \ + */ \ + csr = L64854_GCSR(sc); \ + if (sc->sc_rev == DMAREV_1 || sc->sc_rev == DMAREV_0) \ + csr |= D_ESC_DRAIN; \ + else \ + csr |= L64854_INVALIDATE; \ \ - L64854_SCSR(sc,csr); \ + L64854_SCSR(sc, csr); \ } \ /* \ * Wait for draining to finish \ * rev0 & rev1 call this PACKCNT \ */ \ - DMAWAIT(sc, L64854_GCSR(sc) & L64854_DRAINING, "DRAINING", dontpanic);\ + DMAWAIT(sc, L64854_GCSR(sc) & L64854_DRAINING, "DRAINING", \ + dontpanic); \ } while (/* CONSTCOND */0) #define DMA_FLUSH(sc, dontpanic) do { \ @@ -282,12 +290,14 @@ lsi64854_detach(struct lsi64854_softc *s csr = L64854_GCSR(sc); \ csr &= ~(L64854_WRITE|L64854_EN_DMA); /* no-ops on ENET */ \ csr |= L64854_INVALIDATE; /* XXX FAS ? */ \ - L64854_SCSR(sc,csr); \ + L64854_SCSR(sc, csr); \ } while (/* CONSTCOND */0) static void lsi64854_reset(struct lsi64854_softc *sc) { + bus_dma_tag_t dmat; + bus_dmamap_t dmam; uint32_t csr; DMA_FLUSH(sc, 1); @@ -296,10 +306,11 @@ lsi64854_reset(struct lsi64854_softc *sc DPRINTF(LDB_ANY, ("%s: csr 0x%x\n", __func__, csr)); if (sc->sc_dmasize != 0) { - bus_dmamap_sync(sc->sc_buffer_dmat, sc->sc_dmamap, - (csr & D_WRITE) != 0 ? BUS_DMASYNC_PREREAD : - BUS_DMASYNC_PREWRITE); - bus_dmamap_unload(sc->sc_buffer_dmat, sc->sc_dmamap); + dmat = sc->sc_buffer_dmat; + dmam = sc->sc_dmamap; + bus_dmamap_sync(dmat, dmam, (csr & D_WRITE) != 0 ? + BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); + bus_dmamap_unload(dmat, dmam); } if (sc->sc_rev == DMAREV_HME) @@ -364,15 +375,16 @@ lsi64854_map_scsi(void *arg, bus_dma_seg sc = (struct lsi64854_softc *)arg; + if (error != 0) + return; if (nseg != 1) panic("%s: cannot map %d segments\n", __func__, nseg); bus_dmamap_sync(sc->sc_buffer_dmat, sc->sc_dmamap, - sc->sc_datain ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); + sc->sc_datain != 0 ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); bus_write_4(sc->sc_res, L64854_REG_ADDR, segs[0].ds_addr); } -#define DMAMAX(a) (MAX_DMA_SZ - ((a) & (MAX_DMA_SZ - 1))) /* * setup a DMA transfer */ @@ -381,6 +393,7 @@ lsi64854_setup(struct lsi64854_softc *sc int datain, size_t *dmasize) { long bcnt; + int error; uint32_t csr; DMA_FLUSH(sc, 0); @@ -392,15 +405,12 @@ lsi64854_setup(struct lsi64854_softc *sc sc->sc_dmalen = len; sc->sc_datain = datain; - /* - * The rules say we cannot transfer more than the limit - * of this DMA chip (64k for old and 16Mb for new), - * and we cannot cross a 16Mb boundary. - */ - *dmasize = sc->sc_dmasize = - ulmin(*dmasize, DMAMAX((size_t)*sc->sc_dmaaddr)); + KASSERT(*dmasize <= sc->sc_maxdmasize, + ("%s: transfer size %ld too large", __func__, (long)*dmasize)); - DPRINTF(LDB_ANY, ("%s: dmasize=%ld\n", __func__, (long)sc->sc_dmasize)); + sc->sc_dmasize = *dmasize; + + DPRINTF(LDB_ANY, ("%s: dmasize=%ld\n", __func__, (long)*dmasize)); /* * XXX what length? @@ -412,24 +422,31 @@ lsi64854_setup(struct lsi64854_softc *sc bus_write_4(sc->sc_res, L64854_REG_CNT, *dmasize); } - /* Program the DMA address */ - if (sc->sc_dmasize != 0) - if (bus_dmamap_load(sc->sc_buffer_dmat, sc->sc_dmamap, - *sc->sc_dmaaddr, sc->sc_dmasize, lsi64854_map_scsi, sc, 0)) - panic("%s: cannot allocate DVMA address", __func__); + /* + * Load the transfer buffer and program the DMA address. + * Note that the NCR53C9x core can't handle EINPROGRESS so we set + * BUS_DMA_NOWAIT. + */ + if (*dmasize != 0) { + error = bus_dmamap_load(sc->sc_buffer_dmat, sc->sc_dmamap, + *sc->sc_dmaaddr, *dmasize, lsi64854_map_scsi, sc, + BUS_DMA_NOWAIT); + if (error != 0) + return (error); + } if (sc->sc_rev == DMAREV_ESC) { /* DMA ESC chip bug work-around */ - bcnt = sc->sc_dmasize; + bcnt = *dmasize; if (((bcnt + (long)*sc->sc_dmaaddr) & PAGE_MASK_8K) != 0) bcnt = roundup(bcnt, PAGE_SIZE_8K); bus_write_4(sc->sc_res, L64854_REG_CNT, bcnt); } - /* Setup DMA control register */ + /* Setup the DMA control register. */ csr = L64854_GCSR(sc); - if (datain) + if (datain != 0) csr |= L64854_WRITE; else csr &= ~L64854_WRITE; @@ -445,7 +462,7 @@ lsi64854_setup(struct lsi64854_softc *sc /* * Pseudo (chained) interrupt from the esp driver to kick the - * current running DMA transfer. Called from ncr53c9x_intr() + * current running DMA transfer. Called from ncr53c9x_intr() * for now. * * return 1 if it was a DMA continue. @@ -455,19 +472,23 @@ lsi64854_scsi_intr(void *arg) { struct lsi64854_softc *sc = arg; struct ncr53c9x_softc *nsc = sc->sc_client; - int trans, resid; + bus_dma_tag_t dmat; + bus_dmamap_t dmam; + size_t dmasize; + int lxfer, resid, trans; uint32_t csr; csr = L64854_GCSR(sc); DPRINTF(LDB_SCSI, ("%s: addr 0x%x, csr %b\n", __func__, - bus_read_4(sc->sc_res, L64854_REG_ADDR), csr, DDMACSR_BITS)); + bus_read_4(sc->sc_res, L64854_REG_ADDR), csr, DDMACSR_BITS)); - if (csr & (D_ERR_PEND|D_SLAVE_ERR)) { - device_printf(sc->sc_dev, "error: csr=%b\n", csr, DDMACSR_BITS); - csr &= ~D_EN_DMA; /* Stop DMA */ + if (csr & (D_ERR_PEND | D_SLAVE_ERR)) { + device_printf(sc->sc_dev, "error: csr=%b\n", csr, + DDMACSR_BITS); + csr &= ~D_EN_DMA; /* Stop DMA. */ /* Invalidate the queue; SLAVE_ERR bit is write-to-clear */ - csr |= D_INVALIDATE|D_SLAVE_ERR; + csr |= D_INVALIDATE | D_SLAVE_ERR; L64854_SCSR(sc, csr); return (-1); } @@ -483,10 +504,11 @@ lsi64854_scsi_intr(void *arg) L64854_SCSR(sc, csr); sc->sc_active = 0; - if (sc->sc_dmasize == 0) { - /* A "Transfer Pad" operation completed */ - DPRINTF(LDB_SCSI, ("%s: discarded %d bytes (tcl=%d, tcm=%d)\n", - __func__, NCR_READ_REG(nsc, NCR_TCL) | + dmasize = sc->sc_dmasize; + if (dmasize == 0) { + /* A "Transfer Pad" operation completed. */ + DPRINTF(LDB_SCSI, ("%s: discarded %d bytes (tcl=%d, " + "tcm=%d)\n", __func__, NCR_READ_REG(nsc, NCR_TCL) | (NCR_READ_REG(nsc, NCR_TCM) << 8), NCR_READ_REG(nsc, NCR_TCL), NCR_READ_REG(nsc, NCR_TCM))); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 13:45:19 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00BDF1065670; Mon, 7 Nov 2011 13:45:19 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E04EA8FC17; Mon, 7 Nov 2011 13:45:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA7DjIEj081698; Mon, 7 Nov 2011 13:45:18 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA7DjIVu081689; Mon, 7 Nov 2011 13:45:18 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201111071345.pA7DjIVu081689@svn.freebsd.org> From: Marius Strobl Date: Mon, 7 Nov 2011 13:45:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227306 - in stable/8: . contrib/bsnmp/snmpd contrib/top contrib/xz gnu/usr.bin lib/libusb release/picobsd/floppy.tree/sbin sbin/geom/class/sched share/man/man4 share/misc sys/amd64/con... X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 13:45:19 -0000 Author: marius Date: Mon Nov 7 13:45:18 2011 New Revision: 227306 URL: http://svn.freebsd.org/changeset/base/227306 Log: MFC: r227006, r227281, r227282 Add a PCI front-end to esp(4) allowing it to support AMD Am53C974 and replace amd(4) with the former in the amd64, i386 and pc98 GENERIC kernel configuration files. Besides duplicating functionality, amd(4), which previously also supported the AMD Am53C974, unlike esp(4) is no longer maintained and has accumulated enough bit rot over time to always cause a panic during boot as long as at least one target is attached to it (see PR 124667). PR: 124667 Obtained from: NetBSD (based on) Added: stable/8/sys/dev/esp/am53c974reg.h - copied unchanged from r227006, head/sys/dev/esp/am53c974reg.h stable/8/sys/dev/esp/esp_pci.c - copied unchanged from r227006, head/sys/dev/esp/esp_pci.c Modified: stable/8/UPDATING (contents, props changed) stable/8/share/man/man4/esp.4 stable/8/sys/amd64/conf/GENERIC stable/8/sys/conf/NOTES stable/8/sys/conf/files stable/8/sys/i386/conf/GENERIC stable/8/sys/modules/Makefile stable/8/sys/modules/esp/Makefile stable/8/sys/pc98/conf/GENERIC stable/8/sys/sparc64/conf/GENERIC Directory Properties: stable/8/ (props changed) stable/8/COPYRIGHT (props changed) stable/8/LOCKS (props changed) stable/8/MAINTAINERS (props changed) stable/8/Makefile (props changed) stable/8/Makefile.inc1 (props changed) stable/8/ObsoleteFiles.inc (props changed) stable/8/README (props changed) stable/8/bin/ (props changed) stable/8/bin/chio/ (props changed) stable/8/bin/chmod/ (props changed) stable/8/bin/cp/ (props changed) stable/8/bin/csh/ (props changed) stable/8/bin/date/ (props changed) stable/8/bin/df/ (props changed) stable/8/bin/echo/ (props changed) stable/8/bin/ed/ (props changed) stable/8/bin/expr/ (props changed) stable/8/bin/getfacl/ (props changed) stable/8/bin/kenv/ (props changed) stable/8/bin/kill/ (props changed) stable/8/bin/ln/ (props changed) stable/8/bin/ls/ (props changed) stable/8/bin/mv/ (props changed) stable/8/bin/pax/ (props changed) stable/8/bin/pkill/ (props changed) stable/8/bin/ps/ (props changed) stable/8/bin/pwait/ (props changed) stable/8/bin/setfacl/ (props changed) stable/8/bin/sh/ (props changed) stable/8/bin/sleep/ (props changed) stable/8/bin/stty/ (props changed) stable/8/bin/test/ (props changed) stable/8/cddl/compat/opensolaris/ (props changed) stable/8/cddl/contrib/dtracetoolkit/ (props changed) stable/8/cddl/contrib/opensolaris/ (props changed) stable/8/cddl/lib/ (props changed) stable/8/cddl/lib/libnvpair/ (props changed) stable/8/cddl/lib/libzpool/ (props changed) stable/8/cddl/sbin/ (props changed) stable/8/cddl/usr.bin/ (props changed) stable/8/cddl/usr.sbin/ (props changed) stable/8/contrib/ (props changed) stable/8/contrib/bind9/ (props changed) stable/8/contrib/binutils/ (props changed) stable/8/contrib/bsnmp/ (props changed) stable/8/contrib/bsnmp/snmpd/bsnmpd.1 (props changed) stable/8/contrib/bzip2/ (props changed) stable/8/contrib/com_err/ (props changed) stable/8/contrib/csup/ (props changed) stable/8/contrib/ee/ (props changed) stable/8/contrib/expat/ (props changed) stable/8/contrib/file/ (props changed) stable/8/contrib/gcc/ (props changed) stable/8/contrib/gdb/ (props changed) stable/8/contrib/gdtoa/ (props changed) stable/8/contrib/groff/ (props changed) stable/8/contrib/ipfilter/ (props changed) stable/8/contrib/less/ (props changed) stable/8/contrib/libpcap/ (props changed) stable/8/contrib/libstdc++/ (props changed) stable/8/contrib/lukemftp/ (props changed) stable/8/contrib/ncurses/ (props changed) stable/8/contrib/netcat/ (props changed) stable/8/contrib/ntp/ (props changed) stable/8/contrib/nvi/ (props changed) stable/8/contrib/one-true-awk/ (props changed) stable/8/contrib/openbsm/ (props changed) stable/8/contrib/openpam/ (props changed) stable/8/contrib/pf/ (props changed) stable/8/contrib/sendmail/ (props changed) stable/8/contrib/tcp_wrappers/ (props changed) stable/8/contrib/tcpdump/ (props changed) stable/8/contrib/tcsh/ (props changed) stable/8/contrib/telnet/ (props changed) stable/8/contrib/top/ (props changed) stable/8/contrib/top/install-sh (props changed) stable/8/contrib/traceroute/ (props changed) stable/8/contrib/wpa/ (props changed) stable/8/contrib/xz/ (props changed) stable/8/contrib/xz/AUTHORS (props changed) stable/8/contrib/xz/COPYING (props changed) stable/8/contrib/xz/ChangeLog (props changed) stable/8/contrib/xz/FREEBSD-Xlist (props changed) stable/8/contrib/xz/FREEBSD-upgrade (props changed) stable/8/contrib/xz/README (props changed) stable/8/contrib/xz/THANKS (props changed) stable/8/contrib/xz/TODO (props changed) stable/8/contrib/xz/po/ (props changed) stable/8/contrib/xz/src/ (props changed) stable/8/crypto/heimdal/ (props changed) stable/8/crypto/openssh/ (props changed) stable/8/crypto/openssl/ (props changed) stable/8/etc/ (props changed) stable/8/games/factor/ (props changed) stable/8/games/fortune/ (props changed) stable/8/games/grdc/ (props changed) stable/8/games/pom/ (props changed) stable/8/gnu/lib/csu/ (props changed) stable/8/gnu/lib/libgcc/ (props changed) stable/8/gnu/lib/libstdc++/ (props changed) stable/8/gnu/usr.bin/ (props changed) stable/8/gnu/usr.bin/Makefile (props changed) stable/8/gnu/usr.bin/binutils/ld/ (props changed) stable/8/gnu/usr.bin/cc/cc_tools/ (props changed) stable/8/gnu/usr.bin/cc/include/ (props changed) stable/8/gnu/usr.bin/dialog/ (props changed) stable/8/gnu/usr.bin/gdb/ (props changed) stable/8/gnu/usr.bin/gdb/arch/sparc64/ (props changed) stable/8/gnu/usr.bin/gdb/kgdb/ (props changed) stable/8/gnu/usr.bin/groff/ (props changed) stable/8/gnu/usr.bin/patch/ (props changed) stable/8/include/ (props changed) stable/8/kerberos5/lib/libgssapi_krb5/ (props changed) stable/8/kerberos5/lib/libgssapi_spnego/ (props changed) stable/8/kerberos5/usr.bin/kdestroy/ (props changed) stable/8/kerberos5/usr.bin/kpasswd/ (props changed) stable/8/lib/ (props changed) stable/8/lib/bind/ (props changed) stable/8/lib/csu/ (props changed) stable/8/lib/libarchive/ (props changed) stable/8/lib/libbluetooth/ (props changed) stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc_r/ (props changed) stable/8/lib/libcam/ (props changed) stable/8/lib/libcompat/ (props changed) stable/8/lib/libdevinfo/ (props changed) stable/8/lib/libdevstat/ (props changed) stable/8/lib/libdisk/ (props changed) stable/8/lib/libedit/ (props changed) stable/8/lib/libelf/ (props changed) stable/8/lib/libexpat/ (props changed) stable/8/lib/libfetch/ (props changed) stable/8/lib/libgeom/ (props changed) stable/8/lib/libgpib/ (props changed) stable/8/lib/libgssapi/ (props changed) stable/8/lib/libjail/ (props changed) stable/8/lib/libkse/ (props changed) stable/8/lib/libkvm/ (props changed) stable/8/lib/liblzma/ (props changed) stable/8/lib/libmagic/ (props changed) stable/8/lib/libmemstat/ (props changed) stable/8/lib/libpam/ (props changed) stable/8/lib/libpmc/ (props changed) stable/8/lib/libproc/ (props changed) stable/8/lib/libradius/ (props changed) stable/8/lib/librpcsec_gss/ (props changed) stable/8/lib/librtld_db/ (props changed) stable/8/lib/libsm/ (props changed) stable/8/lib/libstand/ (props changed) stable/8/lib/libtacplus/ (props changed) stable/8/lib/libthr/ (props changed) stable/8/lib/libthread_db/ (props changed) stable/8/lib/libufs/ (props changed) stable/8/lib/libugidfw/ (props changed) stable/8/lib/libusb/ (props changed) stable/8/lib/libusb/usb.h (props changed) stable/8/lib/libusbhid/ (props changed) stable/8/lib/libutil/ (props changed) stable/8/lib/libz/ (props changed) stable/8/lib/libz/contrib/ (props changed) stable/8/lib/msun/ (props changed) stable/8/libexec/ (props changed) stable/8/libexec/comsat/ (props changed) stable/8/libexec/ftpd/ (props changed) stable/8/libexec/rshd/ (props changed) stable/8/libexec/rtld-elf/ (props changed) stable/8/libexec/tftpd/ (props changed) stable/8/release/ (props changed) stable/8/release/doc/en_US.ISO8859-1/hardware/ (props changed) stable/8/release/picobsd/ (props changed) stable/8/release/picobsd/floppy.tree/sbin/ (props changed) stable/8/release/picobsd/floppy.tree/sbin/dhclient-script (props changed) stable/8/release/picobsd/qemu/ (props changed) stable/8/release/picobsd/tinyware/login/ (props changed) stable/8/release/powerpc/ (props changed) stable/8/rescue/ (props changed) stable/8/sbin/ (props changed) stable/8/sbin/atacontrol/ (props changed) stable/8/sbin/bsdlabel/ (props changed) stable/8/sbin/camcontrol/ (props changed) stable/8/sbin/conscontrol/ (props changed) stable/8/sbin/ddb/ (props changed) stable/8/sbin/devd/ (props changed) stable/8/sbin/devfs/ (props changed) stable/8/sbin/dhclient/ (props changed) stable/8/sbin/dump/ (props changed) stable/8/sbin/dumpfs/ (props changed) stable/8/sbin/fdisk/ (props changed) stable/8/sbin/fsck/ (props changed) stable/8/sbin/fsck_ffs/ (props changed) stable/8/sbin/fsck_msdosfs/ (props changed) stable/8/sbin/fsirand/ (props changed) stable/8/sbin/geom/ (props changed) stable/8/sbin/geom/class/multipath/ (props changed) stable/8/sbin/geom/class/part/ (props changed) stable/8/sbin/geom/class/sched/gsched.8 (props changed) stable/8/sbin/geom/class/stripe/ (props changed) stable/8/sbin/ggate/ (props changed) stable/8/sbin/growfs/ (props changed) stable/8/sbin/gvinum/ (props changed) stable/8/sbin/hastctl/ (props changed) stable/8/sbin/hastd/ (props changed) stable/8/sbin/ifconfig/ (props changed) stable/8/sbin/ipfw/ (props changed) stable/8/sbin/iscontrol/ (props changed) stable/8/sbin/kldload/ (props changed) stable/8/sbin/kldstat/ (props changed) stable/8/sbin/mdconfig/ (props changed) stable/8/sbin/mdmfs/ (props changed) stable/8/sbin/mknod/ (props changed) stable/8/sbin/mksnap_ffs/ (props changed) stable/8/sbin/mount/ (props changed) stable/8/sbin/mount_cd9660/ (props changed) stable/8/sbin/mount_msdosfs/ (props changed) stable/8/sbin/mount_nfs/ (props changed) stable/8/sbin/mount_unionfs/ (props changed) stable/8/sbin/natd/ (props changed) stable/8/sbin/newfs/ (props changed) stable/8/sbin/newfs_msdos/ (props changed) stable/8/sbin/ping6/ (props changed) stable/8/sbin/quotacheck/ (props changed) stable/8/sbin/rcorder/ (props changed) stable/8/sbin/reboot/ (props changed) stable/8/sbin/restore/ (props changed) stable/8/sbin/route/ (props changed) stable/8/sbin/routed/ (props changed) stable/8/sbin/setkey/ (props changed) stable/8/sbin/shutdown/ (props changed) stable/8/sbin/spppcontrol/ (props changed) stable/8/sbin/sysctl/ (props changed) stable/8/sbin/tunefs/ (props changed) stable/8/sbin/umount/ (props changed) stable/8/secure/ (props changed) stable/8/secure/lib/libcrypto/ (props changed) stable/8/secure/lib/libssl/ (props changed) stable/8/secure/usr.bin/bdes/ (props changed) stable/8/secure/usr.bin/openssl/ (props changed) stable/8/share/dict/ (props changed) stable/8/share/doc/papers/devfs/ (props changed) stable/8/share/doc/papers/jail/ (props changed) stable/8/share/doc/smm/01.setup/ (props changed) stable/8/share/examples/ (props changed) stable/8/share/examples/cvsup/ (props changed) stable/8/share/man/ (props changed) stable/8/share/man/man1/ (props changed) stable/8/share/man/man3/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man8/ (props changed) stable/8/share/man/man9/ (props changed) stable/8/share/misc/ (props changed) stable/8/share/misc/bsd-family-tree (props changed) stable/8/share/mk/ (props changed) stable/8/share/skel/ (props changed) stable/8/share/syscons/ (props changed) stable/8/share/termcap/ (props changed) stable/8/share/timedef/ (props changed) stable/8/share/zoneinfo/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/tools/ (props changed) stable/8/tools/build/mk/ (props changed) stable/8/tools/build/options/ (props changed) stable/8/tools/debugscripts/ (props changed) stable/8/tools/kerneldoc/subsys/ (props changed) stable/8/tools/regression/acct/ (props changed) stable/8/tools/regression/acltools/ (props changed) stable/8/tools/regression/aio/aiotest/ (props changed) stable/8/tools/regression/bin/ (props changed) stable/8/tools/regression/bin/date/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) stable/8/tools/regression/bin/test/ (props changed) stable/8/tools/regression/doat/ (props changed) stable/8/tools/regression/fifo/ (props changed) stable/8/tools/regression/geom/ (props changed) stable/8/tools/regression/lib/libc/ (props changed) stable/8/tools/regression/lib/msun/test-conj.t (props changed) stable/8/tools/regression/mqueue/mqtest1/ (props changed) stable/8/tools/regression/mqueue/mqtest2/ (props changed) stable/8/tools/regression/mqueue/mqtest3/ (props changed) stable/8/tools/regression/mqueue/mqtest4/ (props changed) stable/8/tools/regression/mqueue/mqtest5/ (props changed) stable/8/tools/regression/netinet/ (props changed) stable/8/tools/regression/poll/ (props changed) stable/8/tools/regression/posixsem/ (props changed) stable/8/tools/regression/priv/ (props changed) stable/8/tools/regression/sockets/unix_gc/ (props changed) stable/8/tools/regression/usr.bin/ (props changed) stable/8/tools/regression/usr.bin/pkill/ (props changed) stable/8/tools/regression/usr.bin/pkill/pgrep-_g.t (props changed) stable/8/tools/regression/usr.bin/pkill/pgrep-_s.t (props changed) stable/8/tools/regression/usr.bin/pkill/pkill-_g.t (props changed) stable/8/tools/regression/usr.bin/sed/ (props changed) stable/8/tools/regression/usr.bin/tr/ (props changed) stable/8/tools/test/ (props changed) stable/8/tools/test/malloc/ (props changed) stable/8/tools/tools/ (props changed) stable/8/tools/tools/aac/ (props changed) stable/8/tools/tools/ath/ (props changed) stable/8/tools/tools/ath/common/dumpregs.h (props changed) stable/8/tools/tools/ath/common/dumpregs_5210.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5211.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5212.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5416.c (props changed) stable/8/tools/tools/cfi/ (props changed) stable/8/tools/tools/ether_reflect/ (props changed) stable/8/tools/tools/iwi/ (props changed) stable/8/tools/tools/mctest/ (props changed) stable/8/tools/tools/nanobsd/ (props changed) stable/8/tools/tools/netrate/ (props changed) stable/8/tools/tools/netrate/netblast/ (props changed) stable/8/tools/tools/netrate/netsend/ (props changed) stable/8/tools/tools/netrate/tcpp/ (props changed) stable/8/tools/tools/termcap/termcap.pl (props changed) stable/8/tools/tools/umastat/ (props changed) stable/8/tools/tools/vimage/ (props changed) stable/8/usr.bin/ (props changed) stable/8/usr.bin/apply/ (props changed) stable/8/usr.bin/ar/ (props changed) stable/8/usr.bin/awk/ (props changed) stable/8/usr.bin/biff/ (props changed) stable/8/usr.bin/c89/ (props changed) stable/8/usr.bin/c99/ (props changed) stable/8/usr.bin/calendar/ (props changed) stable/8/usr.bin/catman/ (props changed) stable/8/usr.bin/checknr/ (props changed) stable/8/usr.bin/chpass/Makefile (props changed) stable/8/usr.bin/column/ (props changed) stable/8/usr.bin/comm/ (props changed) stable/8/usr.bin/cpio/ (props changed) stable/8/usr.bin/cpuset/ (props changed) stable/8/usr.bin/csup/ (props changed) stable/8/usr.bin/du/ (props changed) stable/8/usr.bin/ee/ (props changed) stable/8/usr.bin/enigma/ (props changed) stable/8/usr.bin/fetch/ (props changed) stable/8/usr.bin/find/ (props changed) stable/8/usr.bin/finger/ (props changed) stable/8/usr.bin/fold/ (props changed) stable/8/usr.bin/fstat/ (props changed) stable/8/usr.bin/gcore/ (props changed) stable/8/usr.bin/getopt/ (props changed) stable/8/usr.bin/gzip/ (props changed) stable/8/usr.bin/hexdump/ (props changed) stable/8/usr.bin/indent/ (props changed) stable/8/usr.bin/ipcs/ (props changed) stable/8/usr.bin/jot/ (props changed) stable/8/usr.bin/kdump/ (props changed) stable/8/usr.bin/killall/ (props changed) stable/8/usr.bin/ktrace/ (props changed) stable/8/usr.bin/lastcomm/ (props changed) stable/8/usr.bin/ldd/ (props changed) stable/8/usr.bin/less/ (props changed) stable/8/usr.bin/lex/ (props changed) stable/8/usr.bin/limits/ (props changed) stable/8/usr.bin/locale/ (props changed) stable/8/usr.bin/locate/ (props changed) stable/8/usr.bin/lock/ (props changed) stable/8/usr.bin/lockf/ (props changed) stable/8/usr.bin/logger/ (props changed) stable/8/usr.bin/look/ (props changed) stable/8/usr.bin/m4/ (props changed) stable/8/usr.bin/mail/ (props changed) stable/8/usr.bin/make/ (props changed) stable/8/usr.bin/makewhatis/ (props changed) stable/8/usr.bin/minigzip/ (props changed) stable/8/usr.bin/ncal/ (props changed) stable/8/usr.bin/netstat/ (props changed) stable/8/usr.bin/nfsstat/ (props changed) stable/8/usr.bin/pathchk/ (props changed) stable/8/usr.bin/perror/ (props changed) stable/8/usr.bin/printf/ (props changed) stable/8/usr.bin/procstat/ (props changed) stable/8/usr.bin/rlogin/ (props changed) stable/8/usr.bin/rpcgen/ (props changed) stable/8/usr.bin/rpcinfo/ (props changed) stable/8/usr.bin/rs/ (props changed) stable/8/usr.bin/ruptime/ (props changed) stable/8/usr.bin/script/ (props changed) stable/8/usr.bin/sed/ (props changed) stable/8/usr.bin/showmount/ (props changed) stable/8/usr.bin/sockstat/ (props changed) stable/8/usr.bin/split/ (props changed) stable/8/usr.bin/stat/ (props changed) stable/8/usr.bin/su/ (props changed) stable/8/usr.bin/systat/ (props changed) stable/8/usr.bin/tail/ (props changed) stable/8/usr.bin/tar/ (props changed) stable/8/usr.bin/tftp/ (props changed) stable/8/usr.bin/tip/ (props changed) stable/8/usr.bin/top/ (props changed) stable/8/usr.bin/touch/ (props changed) stable/8/usr.bin/tr/ (props changed) stable/8/usr.bin/truss/ (props changed) stable/8/usr.bin/uname/ (props changed) stable/8/usr.bin/unifdef/ (props changed) stable/8/usr.bin/uniq/ (props changed) stable/8/usr.bin/unzip/ (props changed) stable/8/usr.bin/usbhidaction/ (props changed) stable/8/usr.bin/usbhidctl/ (props changed) stable/8/usr.bin/uudecode/ (props changed) stable/8/usr.bin/vmstat/ (props changed) stable/8/usr.bin/w/ (props changed) stable/8/usr.bin/wall/ (props changed) stable/8/usr.bin/whois/ (props changed) stable/8/usr.bin/xargs/ (props changed) stable/8/usr.bin/xinstall/ (props changed) stable/8/usr.bin/xlint/ (props changed) stable/8/usr.bin/xz/ (props changed) stable/8/usr.bin/yacc/ (props changed) stable/8/usr.sbin/ (props changed) stable/8/usr.sbin/Makefile (props changed) stable/8/usr.sbin/acpi/ (props changed) stable/8/usr.sbin/arp/ (props changed) stable/8/usr.sbin/asf/ (props changed) stable/8/usr.sbin/bluetooth/ (props changed) stable/8/usr.sbin/bluetooth/bthidcontrol/ (props changed) stable/8/usr.sbin/bluetooth/bthidd/ (props changed) stable/8/usr.sbin/bluetooth/l2control/ (props changed) stable/8/usr.sbin/bluetooth/l2ping/ (props changed) stable/8/usr.sbin/boot0cfg/ (props changed) stable/8/usr.sbin/bsnmpd/ (props changed) stable/8/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c (props changed) stable/8/usr.sbin/burncd/ (props changed) stable/8/usr.sbin/cdcontrol/ (props changed) stable/8/usr.sbin/chown/ (props changed) stable/8/usr.sbin/config/ (props changed) stable/8/usr.sbin/config/SMM.doc/ (props changed) stable/8/usr.sbin/cpucontrol/ (props changed) stable/8/usr.sbin/crashinfo/ (props changed) stable/8/usr.sbin/cron/ (props changed) stable/8/usr.sbin/crunch/examples/ (props changed) stable/8/usr.sbin/ctm/ (props changed) stable/8/usr.sbin/cxgbtool/ (props changed) stable/8/usr.sbin/devinfo/ (props changed) stable/8/usr.sbin/diskinfo/ (props changed) stable/8/usr.sbin/dumpcis/cardinfo.h (props changed) stable/8/usr.sbin/dumpcis/cis.h (props changed) stable/8/usr.sbin/faithd/ (props changed) stable/8/usr.sbin/fdcontrol/ (props changed) stable/8/usr.sbin/fdformat/ (props changed) stable/8/usr.sbin/fdread/ (props changed) stable/8/usr.sbin/fdwrite/ (props changed) stable/8/usr.sbin/fifolog/ (props changed) stable/8/usr.sbin/flowctl/ (props changed) stable/8/usr.sbin/freebsd-update/ (props changed) stable/8/usr.sbin/i2c/ (props changed) stable/8/usr.sbin/ifmcstat/ (props changed) stable/8/usr.sbin/inetd/ (props changed) stable/8/usr.sbin/iostat/ (props changed) stable/8/usr.sbin/jail/ (props changed) stable/8/usr.sbin/jls/ (props changed) stable/8/usr.sbin/kbdmap/ (props changed) stable/8/usr.sbin/lpr/ (props changed) stable/8/usr.sbin/mailwrapper/ (props changed) stable/8/usr.sbin/makefs/ (props changed) stable/8/usr.sbin/mergemaster/ (props changed) stable/8/usr.sbin/mfiutil/ (props changed) stable/8/usr.sbin/mountd/ (props changed) stable/8/usr.sbin/moused/ (props changed) stable/8/usr.sbin/mptutil/ (props changed) stable/8/usr.sbin/mtest/ (props changed) stable/8/usr.sbin/mtree/ (props changed) stable/8/usr.sbin/named/ (props changed) stable/8/usr.sbin/ndp/ (props changed) stable/8/usr.sbin/newsyslog/ (props changed) stable/8/usr.sbin/nfsd/ (props changed) stable/8/usr.sbin/nfsdumpstate/ (props changed) stable/8/usr.sbin/nfsuserd/ (props changed) stable/8/usr.sbin/ntp/ (props changed) stable/8/usr.sbin/pciconf/ (props changed) stable/8/usr.sbin/periodic/ (props changed) stable/8/usr.sbin/pkg_install/ (props changed) stable/8/usr.sbin/pmcannotate/ (props changed) stable/8/usr.sbin/pmccontrol/ (props changed) stable/8/usr.sbin/pmcstat/ (props changed) stable/8/usr.sbin/portsnap/ (props changed) stable/8/usr.sbin/powerd/ (props changed) stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/pppctl/ (props changed) stable/8/usr.sbin/pstat/ (props changed) stable/8/usr.sbin/pw/ (props changed) stable/8/usr.sbin/rpc.lockd/ (props changed) stable/8/usr.sbin/rpc.statd/ (props changed) stable/8/usr.sbin/rpc.umntall/ (props changed) stable/8/usr.sbin/rpcbind/ (props changed) stable/8/usr.sbin/rtadvd/ (props changed) stable/8/usr.sbin/rtsold/ (props changed) stable/8/usr.sbin/sade/ (props changed) stable/8/usr.sbin/service/ (props changed) stable/8/usr.sbin/services_mkdb/ (props changed) stable/8/usr.sbin/setfmac/ (props changed) stable/8/usr.sbin/setpmac/ (props changed) stable/8/usr.sbin/smbmsg/ (props changed) stable/8/usr.sbin/sysinstall/ (props changed) stable/8/usr.sbin/syslogd/ (props changed) stable/8/usr.sbin/tcpdrop/ (props changed) stable/8/usr.sbin/traceroute/ (props changed) stable/8/usr.sbin/traceroute6/ (props changed) stable/8/usr.sbin/tzsetup/ (props changed) stable/8/usr.sbin/uathload/ (props changed) stable/8/usr.sbin/ugidfw/ (props changed) stable/8/usr.sbin/uhsoctl/ (props changed) stable/8/usr.sbin/usbconfig/ (props changed) stable/8/usr.sbin/usbdump/ (props changed) stable/8/usr.sbin/vidcontrol/ (props changed) stable/8/usr.sbin/watchdogd/ (props changed) stable/8/usr.sbin/wpa/ (props changed) stable/8/usr.sbin/ypserv/ (props changed) stable/8/usr.sbin/zic/ (props changed) Modified: stable/8/UPDATING ============================================================================== --- stable/8/UPDATING Mon Nov 7 13:40:54 2011 (r227305) +++ stable/8/UPDATING Mon Nov 7 13:45:18 2011 (r227306) @@ -15,6 +15,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. debugging tools present in HEAD were left in place because sun4v support still needs work to become production ready. +20111101: + The broken amd(4) driver has been replaced with esp(4) in the amd64, + i386 and pc98 GENERIC kernel configuration files. + 20110606: A new version of ZFS (version 28) has been merged. This version does not depend on a python library and the Modified: stable/8/share/man/man4/esp.4 ============================================================================== --- stable/8/share/man/man4/esp.4 Mon Nov 7 13:40:54 2011 (r227305) +++ stable/8/share/man/man4/esp.4 Mon Nov 7 13:45:18 2011 (r227306) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2004 Tom Rhodes +.\" Copyright (c) 2011 Marius Strobl .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,158 +25,91 @@ .\" .\" $FreeBSD$ .\" -.Dd September 18, 2005 +.Dd November 1, 2011 .Dt ESP 4 .Os .Sh NAME .Nm esp -.Nd Qlogic FEPS and FAS366 SCSI driver +.Nd Emulex ESP, NCR 53C9x and QLogic FAS families based SCSI controllers .Sh SYNOPSIS -To compile this driver into the kernel, -place the following lines in your +To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device scbus" .Cd "device esp" .Ed -.Sh HARDWARE +.Pp +Alternatively, to load the driver as a module at boot time, place the +following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_esp_load="YES" +.Ed +.Sh DESCRIPTION The .Nm driver provides support for the -.Tn Qlogic -FAS216 and FAS408 +.Tn AMD +Am53C974, the +.Tn Emulex +ESP100, ESP100A, ESP200 and ESP406, the +.Tn NCR +53C90, 53C94 and 53C96 as well as the +.Tn QLogic +FAS100A, FAS216, FAS366 and FAS408 .Tn SCSI controller chips found in a wide variety of systems and peripheral boards. -This includes the -.Tn Qlogic -.Tn SCSI -cards found in most -.Tn Sun -.Tn Ultra 1e -and -.Tn Ultra 2 -machines. -.Pp -For -.Tn Qlogic -.Tn PCI -.Tn SCSI -host adapters, the -.Xr isp 4 -driver should be used in place of the -.Nm -driver. -.Sh IMPLEMENTATION NOTES -During the boot sequence, the +.Sh HARDWARE +Controllers supported by the .Nm -driver -searches the linked list for LUN info by LUN ID. -At this point the driver will attach on that instance, -and then attempt to attach every sub-device. -.Pp -There are at least 4 variations of the -configuration 3 register. -A second config register must be loaded to inquire the chip revision, -otherwise the -.Fn ncr53c9x_reset -function will not set the defaults correctly. -.Pp -The drive attach routine attempts to set the appropriate -bit to put the chip into Fast -.Tn SCSI -mode so that it does not -have to be figured out each time. -This will then be stored in the -.Tn NCR -registers for later use. +driver include: .Pp -The -.Nm -driver makes use of the -.Tn LSI -64854 -.Tn DMA -engine which contains three independent -channels designed to interface with -an NCR539X -.Tn SCSI -controller; -an AM7990 Ethernet controller; -and certain types of parallel port hardware. -As such this driver may eventually replace the -.Xr amd 4 -driver for network hardware. -.Sh DIAGNOSTICS -The following driver specific error messages -may be reported: -.Bl -diag -.It "esp: cannot map %d segments" -The device was unable to map segments while mapping the -.Tn SCSI -devices in -.Tn DMA -mode. -.It "unknown variant %d, devices not attached" -An unknown version of the card was found and devices will -not be attached. -.It "Unhandled function code %d" -The device returned a function code which the driver is -unable to handle, most likely during negotiation. -.It "esp:%d:%d: selection failed %d left in FIFO" -The target left the command phase prematurely. -If a command did not reach the device then it will -be reported as shown above. -.It "invalid state: %d" -The device has reached an invalid state. -.El -.Sh SEE ALSO -.Xr amd 4 , -.Xr isp 4 , -.Xr scbus 4 , -.Xr camcontrol 8 -.Pp -.Bl -item -compact +.Bl -bullet -compact +.It +MELCO IFC-DP (PC-98) +.It +Sun ESP family +.It +Sun FAS family .It -.Pa http://www.qlc.com/ +Tekram DC390 .It -.Pa http://www.sun.com/ +Tekram DC390T .El +.Sh SEE ALSO +.Xr cd 4 , +.Xr ch 4 , +.Xr da 4 , +.Xr intro 4 , +.Xr pci 4 , +.Xr sa 4 , +.Xr sbus 4 , +.Xr scsi 4 , +.Xr camcontrol 8 .Sh HISTORY The .Nm -driver was written for -.Nx -by -.An Eric S. Hvozda . +driver first appeared in +.Nx 1.3 . +The first +.Fx +version to include it was +.Fx 5.3 . +.Sh AUTHORS +.An -nosplit The .Nm -driver was then ported to -.Fx 5.3 +driver was ported to +.Fx by -.An Scott Long Aq scottl@FreeBSD.org . -.Sh AUTHORS -This manual page was written by -.An Tom Rhodes Aq trhodes@FreeBSD.org -instead of porting the original from -.Nx . +.An Scott Long +.Aq scottl@FreeBSD.org +and later on considerably improved by +.An Marius Strobl +.Aq marius@FreeBSD.org . .Sh BUGS The .Nm -driver includes the sbus front-end but lacks the -.Tn PCI -front-end. -Thus it can only support the -.Tn FEPS/FAS366 -.Tn SCSI -found in -.Tn Sun -.Tn Ultra 1e -and -.Tn Ultra 2 -machines at this time. -.Pp -This driver should eventually replace the -.Xr amd 4 -driver, but that requires porting the -.Tn PCI -front-end mentioned above. +driver should read the EEPROM settings of +.Tn Tekram +controllers. Modified: stable/8/sys/amd64/conf/GENERIC ============================================================================== --- stable/8/sys/amd64/conf/GENERIC Mon Nov 7 13:40:54 2011 (r227305) +++ stable/8/sys/amd64/conf/GENERIC Mon Nov 7 13:45:18 2011 (r227306) @@ -108,7 +108,7 @@ options AHC_REG_PRETTY_PRINT # Print re device ahd # AHA39320/29320 and onboard AIC79xx devices options AHD_REG_PRETTY_PRINT # Print register bitfields in debug # output. Adds ~215k to driver. -device amd # AMD 53C974 (Tekram DC-390(T)) +device esp # AMD Am53C974 (Tekram DC-390(T)) device hptiop # Highpoint RocketRaid 3xxx series device isp # Qlogic family #device ispfw # Firmware for QLogic HBAs- normally a module Modified: stable/8/sys/conf/NOTES ============================================================================== --- stable/8/sys/conf/NOTES Mon Nov 7 13:40:54 2011 (r227305) +++ stable/8/sys/conf/NOTES Mon Nov 7 13:45:18 2011 (r227306) @@ -1434,7 +1434,9 @@ options TEKEN_XTERM # xterm-style term # such as the Tekram DC-390(T). # bt: Most Buslogic controllers: including BT-445, BT-54x, BT-64x, BT-74x, # BT-75x, BT-946, BT-948, BT-956, BT-958, SDC3211B, SDC3211F, SDC3222F -# esp: NCR53c9x. Only for SBUS hardware right now. +# esp: Emulex ESP, NCR 53C9x and QLogic FAS families based controllers +# including the AMD Am53C974 (found on devices such as the Tekram +# DC-390(T)) and the Sun ESP and FAS families of controllers # isp: Qlogic ISP 1020, 1040 and 1040B PCI SCSI host adapters, # ISP 1240 Dual Ultra SCSI, ISP 1080 and 1280 (Dual) Ultra2, # ISP 12160 Ultra3 SCSI, Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Mon Nov 7 13:40:54 2011 (r227305) +++ stable/8/sys/conf/files Mon Nov 7 13:45:18 2011 (r227306) @@ -959,6 +959,7 @@ dev/ep/if_ep_eisa.c optional ep eisa dev/ep/if_ep_isa.c optional ep isa dev/ep/if_ep_mca.c optional ep mca dev/ep/if_ep_pccard.c optional ep pccard +dev/esp/esp_pci.c optional esp pci dev/esp/ncr53c9x.c optional esp dev/ex/if_ex.c optional ex dev/ex/if_ex_isa.c optional ex isa Copied: stable/8/sys/dev/esp/am53c974reg.h (from r227006, head/sys/dev/esp/am53c974reg.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/dev/esp/am53c974reg.h Mon Nov 7 13:45:18 2011 (r227306, copy of r227006, head/sys/dev/esp/am53c974reg.h) @@ -0,0 +1,72 @@ +/* $NetBSD: pcscpreg.h,v 1.2 2008/04/28 20:23:55 martin Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Izumi Tsutsui. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* $FreeBSD$ */ + +#ifndef _AM53C974_H_ +#define _AM53C974_H_ + +/* + * Am53c974 DMA engine registers + */ + +#define DMA_CMD 0x40 /* Command */ +#define DMACMD_RSVD 0xFFFFFF28 /* reserved */ +#define DMACMD_DIR 0x00000080 /* Transfer Direction (read:1) */ +#define DMACMD_INTE 0x00000040 /* DMA Interrupt Enable */ +#define DMACMD_MDL 0x00000010 /* Map to Memory Description List */ +#define DMACMD_DIAG 0x00000004 /* Diagnostic */ +#define DMACMD_CMD 0x00000003 /* Command Code Bit */ +#define DMACMD_IDLE 0x00000000 /* Idle */ +#define DMACMD_BLAST 0x00000001 /* Blast */ +#define DMACMD_ABORT 0x00000002 /* Abort */ +#define DMACMD_START 0x00000003 /* Start */ + +#define DMA_STC 0x44 /* Start Transfer Count */ +#define DMA_SPA 0x48 /* Start Physical Address */ +#define DMA_WBC 0x4C /* Working Byte Counter */ +#define DMA_WAC 0x50 /* Working Address Counter */ + +#define DMA_STAT 0x54 /* Status Register */ +#define DMASTAT_RSVD 0xFFFFFF80 /* reserved */ +#define DMASTAT_PABT 0x00000040 /* PCI master/target Abort */ +#define DMASTAT_BCMP 0x00000020 /* BLAST Complete */ +#define DMASTAT_SINT 0x00000010 /* SCSI Interrupt */ +#define DMASTAT_DONE 0x00000008 /* DMA Transfer Terminated */ +#define DMASTAT_ABT 0x00000004 /* DMA Transfer Aborted */ +#define DMASTAT_ERR 0x00000002 /* DMA Transfer Error */ +#define DMASTAT_PWDN 0x00000001 /* Power Down Indicator */ + +#define DMA_SMDLA 0x58 /* Starting Memory Descpritor List Address */ +#define DMA_WMAC 0x5C /* Working MDL Counter */ +#define DMA_SBAC 0x70 /* SCSI Bus and Control */ + +#endif /* _AM53C974_H_ */ Copied: stable/8/sys/dev/esp/esp_pci.c (from r227006, head/sys/dev/esp/esp_pci.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/dev/esp/esp_pci.c Mon Nov 7 13:45:18 2011 (r227306, copy of r227006, head/sys/dev/esp/esp_pci.c) @@ -0,0 +1,654 @@ +/*- + * Copyright (c) 2011 Marius Strobl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $NetBSD: pcscp.c,v 1.45 2010/11/13 13:52:08 uebayasi Exp $ */ + +/*- + * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center; Izumi Tsutsui. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * esp_pci.c: device dependent code for AMD Am53c974 (PCscsi-PCI) + * written by Izumi Tsutsui + * + * Technical manual available at + * http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/19113.pdf + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#define PCI_DEVICE_ID_AMD53C974 0x20201022 + +struct esp_pci_softc { + struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ + struct device *sc_dev; + + struct resource *sc_res[2]; +#define ESP_PCI_RES_INTR 0 +#define ESP_PCI_RES_IO 1 + + bus_dma_tag_t sc_pdmat; + + bus_dma_tag_t sc_xferdmat; /* DMA tag for transfers */ + bus_dmamap_t sc_xferdmam; /* DMA map for transfers */ + + void *sc_ih; /* interrupt handler */ + + size_t sc_dmasize; /* DMA size */ + void **sc_dmaaddr; /* DMA address */ + size_t *sc_dmalen; /* DMA length */ + int sc_active; /* DMA state */ + int sc_datain; /* DMA Data Direction */ +}; + +static struct resource_spec esp_pci_res_spec[] = { + { SYS_RES_IRQ, 0, RF_SHAREABLE | RF_ACTIVE }, /* ESP_PCI_RES_INTR */ + { SYS_RES_IOPORT, PCIR_BAR(0), RF_ACTIVE }, /* ESP_PCI_RES_IO */ + { -1, 0 } +}; + +#define READ_DMAREG(sc, reg) \ + bus_read_4((sc)->sc_res[ESP_PCI_RES_IO], (reg)) +#define WRITE_DMAREG(sc, reg, var) \ + bus_write_4((sc)->sc_res[ESP_PCI_RES_IO], (reg), (var)) + +#define READ_ESPREG(sc, reg) \ + bus_read_1((sc)->sc_res[ESP_PCI_RES_IO], (reg) << 2) +#define WRITE_ESPREG(sc, reg, val) \ + bus_write_1((sc)->sc_res[ESP_PCI_RES_IO], (reg) << 2, (val)) + +static int esp_pci_probe(device_t); +static int esp_pci_attach(device_t); +static int esp_pci_detach(device_t); +static int esp_pci_suspend(device_t); +static int esp_pci_resume(device_t); + +static device_method_t esp_pci_methods[] = { + DEVMETHOD(device_probe, esp_pci_probe), + DEVMETHOD(device_attach, esp_pci_attach), + DEVMETHOD(device_detach, esp_pci_detach), + DEVMETHOD(device_suspend, esp_pci_suspend), + DEVMETHOD(device_resume, esp_pci_resume), + + KOBJMETHOD_END +}; + +static driver_t esp_pci_driver = { + "esp", + esp_pci_methods, + sizeof(struct esp_pci_softc) +}; + +DRIVER_MODULE(esp, pci, esp_pci_driver, esp_devclass, 0, 0); +MODULE_DEPEND(esp, pci, 1, 1, 1); + +/* + * Functions and the switch for the MI code + */ +static void esp_pci_dma_go(struct ncr53c9x_softc *); +static int esp_pci_dma_intr(struct ncr53c9x_softc *); +static int esp_pci_dma_isactive(struct ncr53c9x_softc *); + +static int esp_pci_dma_isintr(struct ncr53c9x_softc *); +static void esp_pci_dma_reset(struct ncr53c9x_softc *); +static int esp_pci_dma_setup(struct ncr53c9x_softc *, void **, size_t *, + int, size_t *); +static void esp_pci_dma_stop(struct ncr53c9x_softc *); +static void esp_pci_write_reg(struct ncr53c9x_softc *, int, uint8_t); +static uint8_t esp_pci_read_reg(struct ncr53c9x_softc *, int); +static void esp_pci_xfermap(void *arg, bus_dma_segment_t *segs, int nseg, + int error); + +static struct ncr53c9x_glue esp_pci_glue = { + esp_pci_read_reg, + esp_pci_write_reg, + esp_pci_dma_isintr, + esp_pci_dma_reset, + esp_pci_dma_intr, + esp_pci_dma_setup, + esp_pci_dma_go, + esp_pci_dma_stop, + esp_pci_dma_isactive, +}; + +static int +esp_pci_probe(device_t dev) +{ + + if (pci_get_devid(dev) == PCI_DEVICE_ID_AMD53C974) { + device_set_desc(dev, "AMD Am53C974 Fast-SCSI"); + return (BUS_PROBE_DEFAULT); + } + + return (ENXIO); +} + +/* + * Attach this instance, and then all the sub-devices + */ +static int +esp_pci_attach(device_t dev) +{ + struct esp_pci_softc *esc; + struct ncr53c9x_softc *sc; + int error; + + esc = device_get_softc(dev); + sc = &esc->sc_ncr53c9x; + + NCR_LOCK_INIT(sc); + + esc->sc_dev = dev; + sc->sc_glue = &esp_pci_glue; + + pci_enable_busmaster(dev); + + error = bus_alloc_resources(dev, esp_pci_res_spec, esc->sc_res); + if (error != 0) { + device_printf(dev, "failed to allocate resources\n"); + bus_release_resources(dev, esp_pci_res_spec, esc->sc_res); + return (error); + } + + error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_UNRESTRICTED, + BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &esc->sc_pdmat); + if (error != 0) { + device_printf(dev, "cannot create parent DMA tag\n"); + goto fail_res; + } + + /* + * XXX More of this should be in ncr53c9x_attach(), but + * XXX should we really poke around the chip that much in + * XXX the MI code? Think about this more... + */ + + /* + * Set up static configuration info. + * + * XXX we should read the configuration from the EEPROM. + */ + sc->sc_id = 7; + sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB; + sc->sc_cfg2 = NCRCFG2_SCSI2 | NCRCFG2_FE; + sc->sc_cfg3 = NCRAMDCFG3_IDM | NCRAMDCFG3_FCLK; + sc->sc_cfg4 = NCRAMDCFG4_GE12NS | NCRAMDCFG4_RADE; + sc->sc_rev = NCR_VARIANT_AM53C974; + sc->sc_features = NCR_F_FASTSCSI | NCR_F_DMASELECT; + sc->sc_cfg3_fscsi = NCRAMDCFG3_FSCSI; + sc->sc_freq = 40; /* MHz */ + + /* + * This is the value used to start sync negotiations + * Note that the NCR register "SYNCTP" is programmed + * in "clocks per byte", and has a minimum value of 4. + * The SCSI period used in negotiation is one-fourth + * of the time (in nanoseconds) needed to transfer one byte. + * Since the chip's clock is given in MHz, we have the following + * formula: 4 * period = (1000 / freq) * 4 + */ + sc->sc_minsync = 1000 / sc->sc_freq; + + sc->sc_maxxfer = DFLTPHYS; /* see below */ + sc->sc_maxoffset = 15; + sc->sc_extended_geom = 1; + +#define MDL_SEG_SIZE 0x1000 /* 4kbyte per segment */ + + /* + * Create the DMA tag and map for the data transfers. + * + * Note: given that bus_dma(9) only adheres to the requested alignment + * for the first segment (and that also only for bus_dmamem_alloc()ed + * DMA maps) we can't use the Memory Descriptor List. However, also + * when not using the MDL, the maximum transfer size apparently is + * limited to 4k so we have to split transfers up, which plain sucks. + */ + error = bus_dma_tag_create(esc->sc_pdmat, PAGE_SIZE, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + MDL_SEG_SIZE, 1, MDL_SEG_SIZE, BUS_DMA_ALLOCNOW, + busdma_lock_mutex, &sc->sc_lock, &esc->sc_xferdmat); + if (error != 0) { + device_printf(dev, "cannot create transfer DMA tag\n"); + goto fail_pdmat; + } + error = bus_dmamap_create(esc->sc_xferdmat, 0, &esc->sc_xferdmam); + if (error != 0) { + device_printf(dev, "cannnot create transfer DMA map\n"); + goto fail_xferdmat; + } + + error = bus_setup_intr(dev, esc->sc_res[ESP_PCI_RES_INTR], + INTR_MPSAFE | INTR_TYPE_CAM, NULL, ncr53c9x_intr, sc, + &esc->sc_ih); + if (error != 0) { + device_printf(dev, "cannot set up interrupt\n"); + goto fail_xferdmam; + } + + /* Do the common parts of attachment. */ + sc->sc_dev = esc->sc_dev; + error = ncr53c9x_attach(sc); + if (error != 0) { + device_printf(esc->sc_dev, "ncr53c9x_attach failed\n"); + goto fail_intr; + } + + return (0); + + fail_intr: + bus_teardown_intr(esc->sc_dev, esc->sc_res[ESP_PCI_RES_INTR], + esc->sc_ih); + fail_xferdmam: + bus_dmamap_destroy(esc->sc_xferdmat, esc->sc_xferdmam); + fail_xferdmat: + bus_dma_tag_destroy(esc->sc_xferdmat); + fail_pdmat: + bus_dma_tag_destroy(esc->sc_pdmat); + fail_res: + bus_release_resources(dev, esp_pci_res_spec, esc->sc_res); + NCR_LOCK_DESTROY(sc); + + return (error); +} + +static int +esp_pci_detach(device_t dev) +{ + struct ncr53c9x_softc *sc; + struct esp_pci_softc *esc; + int error; + + esc = device_get_softc(dev); + sc = &esc->sc_ncr53c9x; + + bus_teardown_intr(esc->sc_dev, esc->sc_res[ESP_PCI_RES_INTR], + esc->sc_ih); + error = ncr53c9x_detach(sc); + if (error != 0) + return (error); + bus_dmamap_destroy(esc->sc_xferdmat, esc->sc_xferdmam); + bus_dma_tag_destroy(esc->sc_xferdmat); + bus_dma_tag_destroy(esc->sc_pdmat); + bus_release_resources(dev, esp_pci_res_spec, esc->sc_res); + NCR_LOCK_DESTROY(sc); + + return (0); +} + +static int +esp_pci_suspend(device_t dev) +{ + + return (ENXIO); +} + +static int +esp_pci_resume(device_t dev) +{ + + return (ENXIO); +} + +static void +esp_pci_xfermap(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)arg; + + if (error != 0) + return; + + KASSERT(nsegs == 1, ("%s: bad transfer segment count %d", __func__, + nsegs)); + KASSERT(segs[0].ds_len <= MDL_SEG_SIZE, + ("%s: bad transfer segment length %ld", __func__, + (long)segs[0].ds_len)); + + /* Program the DMA Starting Physical Address. */ + WRITE_DMAREG(esc, DMA_SPA, segs[0].ds_addr); +} + +/* + * Glue functions + */ + +static uint8_t +esp_pci_read_reg(struct ncr53c9x_softc *sc, int reg) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + + return (READ_ESPREG(esc, reg)); +} + +static void +esp_pci_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + + WRITE_ESPREG(esc, reg, v); +} + +static int +esp_pci_dma_isintr(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + + return (READ_ESPREG(esc, NCR_STAT) & NCRSTAT_INT) != 0; +} + +static void +esp_pci_dma_reset(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + + WRITE_DMAREG(esc, DMA_CMD, DMACMD_IDLE); + + esc->sc_active = 0; +} + +static int +esp_pci_dma_intr(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + bus_dma_tag_t xferdmat; + bus_dmamap_t xferdmam; + size_t dmasize; + int datain, i, resid, trans; + uint32_t dmastat; + char *p = NULL; + + xferdmat = esc->sc_xferdmat; + xferdmam = esc->sc_xferdmam; + datain = esc->sc_datain; + + dmastat = READ_DMAREG(esc, DMA_STAT); + + if ((dmastat & DMASTAT_ERR) != 0) { + /* XXX not tested... */ + WRITE_DMAREG(esc, DMA_CMD, DMACMD_ABORT | (datain != 0 ? + DMACMD_DIR : 0)); + + device_printf(esc->sc_dev, "DMA error detected; Aborting.\n"); + bus_dmamap_sync(xferdmat, xferdmam, datain != 0 ? + BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(xferdmat, xferdmam); + return (-1); + } + + if ((dmastat & DMASTAT_ABT) != 0) { + /* XXX what should be done? */ + device_printf(esc->sc_dev, "DMA aborted.\n"); + WRITE_DMAREG(esc, DMA_CMD, DMACMD_IDLE | (datain != 0 ? + DMACMD_DIR : 0)); + esc->sc_active = 0; + return (0); + } + + KASSERT(esc->sc_active != 0, ("%s: DMA wasn't active", __func__)); + + /* DMA has stopped. */ + + esc->sc_active = 0; + + dmasize = esc->sc_dmasize; + if (dmasize == 0) { + /* A "Transfer Pad" operation completed. */ + NCR_DMA(("%s: discarded %d bytes (tcl=%d, tcm=%d)\n", + __func__, READ_ESPREG(esc, NCR_TCL) | + (READ_ESPREG(esc, NCR_TCM) << 8), + READ_ESPREG(esc, NCR_TCL), READ_ESPREG(esc, NCR_TCM))); + return (0); + } + + resid = 0; + /* + * If a transfer onto the SCSI bus gets interrupted by the device + * (e.g. for a SAVEPOINTER message), the data in the FIFO counts + * as residual since the ESP counter registers get decremented as + * bytes are clocked into the FIFO. + */ + if (datain == 0 && + (resid = (READ_ESPREG(esc, NCR_FFLAG) & NCRFIFO_FF)) != 0) + NCR_DMA(("%s: empty esp FIFO of %d ", __func__, resid)); + + if ((sc->sc_espstat & NCRSTAT_TC) == 0) { + /* + * "Terminal count" is off, so read the residue + * out of the ESP counter registers. + */ + if (datain != 0) { + resid = READ_ESPREG(esc, NCR_FFLAG) & NCRFIFO_FF; + while (resid > 1) + resid = + READ_ESPREG(esc, NCR_FFLAG) & NCRFIFO_FF; + WRITE_DMAREG(esc, DMA_CMD, DMACMD_BLAST | DMACMD_DIR); + + for (i = 0; i < 0x8000; i++) /* XXX 0x8000 ? */ + if ((READ_DMAREG(esc, DMA_STAT) & + DMASTAT_BCMP) != 0) + break; + + /* See the below comments... */ + if (resid != 0) + p = *esc->sc_dmaaddr; + } + + resid += READ_ESPREG(esc, NCR_TCL) | + (READ_ESPREG(esc, NCR_TCM) << 8) | + (READ_ESPREG(esc, NCR_TCH) << 16); + } else + while ((dmastat & DMASTAT_DONE) == 0) + dmastat = READ_DMAREG(esc, DMA_STAT); + + WRITE_DMAREG(esc, DMA_CMD, DMACMD_IDLE | (datain != 0 ? + DMACMD_DIR : 0)); + + /* Sync the transfer buffer. */ + bus_dmamap_sync(xferdmat, xferdmam, datain != 0 ? + BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(xferdmat, xferdmam); + + trans = dmasize - resid; + + /* + * From the technical manual notes: + * + * "In some odd byte conditions, one residual byte will be left + * in the SCSI FIFO, and the FIFO flags will never count to 0. + * When this happens, the residual byte should be retrieved + * via PIO following completion of the BLAST operation." + */ + if (p != NULL) { + p += trans; + *p = READ_ESPREG(esc, NCR_FIFO); + trans++; + } + + if (trans < 0) { /* transferred < 0 ? */ +#if 0 + /* + * This situation can happen in perfectly normal operation + * if the ESP is reselected while using DMA to select + * another target. As such, don't print the warning. + */ + device_printf(dev, "xfer (%d) > req (%d)\n", trans, dmasize); +#endif + trans = dmasize; + } + + NCR_DMA(("%s: tcl=%d, tcm=%d, tch=%d; trans=%d, resid=%d\n", __func__, + READ_ESPREG(esc, NCR_TCL), READ_ESPREG(esc, NCR_TCM), + READ_ESPREG(esc, NCR_TCH), trans, resid)); + + *esc->sc_dmalen -= trans; + *esc->sc_dmaaddr = (char *)*esc->sc_dmaaddr + trans; + + return (0); +} + +static int +esp_pci_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, + int datain, size_t *dmasize) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + int error; + + WRITE_DMAREG(esc, DMA_CMD, DMACMD_IDLE | (datain != 0 ? DMACMD_DIR : + 0)); + + *dmasize = esc->sc_dmasize = ulmin(*dmasize, MDL_SEG_SIZE); + esc->sc_dmaaddr = addr; + esc->sc_dmalen = len; + esc->sc_datain = datain; + + /* + * There's no need to set up DMA for a "Transfer Pad" operation. + */ + if (*dmasize == 0) + return (0); + + /* Set the transfer length. */ + WRITE_DMAREG(esc, DMA_STC, *dmasize); + + /* + * Load the transfer buffer and program the DMA address. + * Note that the NCR53C9x core can't handle EINPROGRESS so we set + * BUS_DMA_NOWAIT. + */ + error = bus_dmamap_load(esc->sc_xferdmat, esc->sc_xferdmam, + *esc->sc_dmaaddr, *dmasize, esp_pci_xfermap, sc, BUS_DMA_NOWAIT); + + return (error); +} + +static void +esp_pci_dma_go(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + int datain; + + datain = esc->sc_datain; + + /* No DMA transfer for a "Transfer Pad" operation */ + if (esc->sc_dmasize == 0) + return; + + /* Sync the transfer buffer. */ + bus_dmamap_sync(esc->sc_xferdmat, esc->sc_xferdmam, datain != 0 ? + BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); + + /* Set the DMA engine to the IDLE state. */ + /* XXX DMA Transfer Interrupt Enable bit is broken? */ + WRITE_DMAREG(esc, DMA_CMD, DMACMD_IDLE | /* DMACMD_INTE | */ + (datain != 0 ? DMACMD_DIR : 0)); + + /* Issue a DMA start command. */ + WRITE_DMAREG(esc, DMA_CMD, DMACMD_START | /* DMACMD_INTE | */ + (datain != 0 ? DMACMD_DIR : 0)); + + esc->sc_active = 1; +} + +static void +esp_pci_dma_stop(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + + /* DMA stop */ + /* XXX what should we do here ? */ + WRITE_DMAREG(esc, DMA_CMD, + DMACMD_ABORT | (esc->sc_datain != 0 ? DMACMD_DIR : 0)); + bus_dmamap_unload(esc->sc_xferdmat, esc->sc_xferdmam); + + esc->sc_active = 0; +} + +static int +esp_pci_dma_isactive(struct ncr53c9x_softc *sc) +{ + struct esp_pci_softc *esc = (struct esp_pci_softc *)sc; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 7 23:09:18 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C836C106564A; Mon, 7 Nov 2011 23:09:18 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7D2D8FC0C; Mon, 7 Nov 2011 23:09:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA7N9Irj000845; Mon, 7 Nov 2011 23:09:18 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA7N9IeU000843; Mon, 7 Nov 2011 23:09:18 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201111072309.pA7N9IeU000843@svn.freebsd.org> From: Peter Holm Date: Mon, 7 Nov 2011 23:09:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227325 - stable/8/sys/ufs/ufs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 23:09:18 -0000 Author: pho Date: Mon Nov 7 23:09:18 2011 New Revision: 227325 URL: http://svn.freebsd.org/changeset/base/227325 Log: MFC r226967, r226971: Added missing cache purge of from argument. Modified: stable/8/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/8/sys/ufs/ufs/ufs_vnops.c Mon Nov 7 22:58:49 2011 (r227324) +++ stable/8/sys/ufs/ufs/ufs_vnops.c Mon Nov 7 23:09:18 2011 (r227325) @@ -1512,6 +1512,15 @@ relock: cache_purge(fdvp); } error = ufs_dirremove(fdvp, fip, fcnp->cn_flags, 0); + /* + * The kern_renameat() looks up the fvp using the DELETE flag, which + * causes the removal of the name cache entry for fvp. + * As the relookup of the fvp is done in two steps: + * ufs_lookup_ino() and then VFS_VGET(), another thread might do a + * normal lookup of the from name just before the VFS_VGET() call, + * causing the cache entry to be re-instantiated. + */ + cache_purge(fvp); unlockout: vput(fdvp); From owner-svn-src-stable-8@FreeBSD.ORG Thu Nov 10 17:04:33 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9AF701065673; Thu, 10 Nov 2011 17:04:33 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89D988FC0A; Thu, 10 Nov 2011 17:04:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAAH4XNe048044; Thu, 10 Nov 2011 17:04:33 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAAH4XdQ048042; Thu, 10 Nov 2011 17:04:33 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201111101704.pAAH4XdQ048042@svn.freebsd.org> From: Alan Cox Date: Thu, 10 Nov 2011 17:04:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227422 - stable/8/sys/vm X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2011 17:04:33 -0000 Author: alc Date: Thu Nov 10 17:04:33 2011 New Revision: 227422 URL: http://svn.freebsd.org/changeset/base/227422 Log: MFC r226740 Speed up vm_page_cache() and vm_page_remove() by checking for a few common cases that can be handled in constant time. Modified: stable/8/sys/vm/vm_page.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/vm/vm_page.c ============================================================================== --- stable/8/sys/vm/vm_page.c Thu Nov 10 17:01:34 2011 (r227421) +++ stable/8/sys/vm/vm_page.c Thu Nov 10 17:04:33 2011 (r227422) @@ -737,7 +737,7 @@ void vm_page_remove(vm_page_t m) { vm_object_t object; - vm_page_t root; + vm_page_t next, prev, root; if ((object = m->object) == NULL) return; @@ -751,15 +751,42 @@ vm_page_remove(vm_page_t m) /* * Now remove from the object's list of backed pages. */ - if (m != object->root) - vm_page_splay(m->pindex, object->root); - if (m->left == NULL) - root = m->right; - else { - root = vm_page_splay(m->pindex, m->left); - root->right = m->right; + if ((next = TAILQ_NEXT(m, listq)) != NULL && next->left == m) { + /* + * Since the page's successor in the list is also its parent + * in the tree, its right subtree must be empty. + */ + next->left = m->left; + KASSERT(m->right == NULL, + ("vm_page_remove: page %p has right child", m)); + } else if ((prev = TAILQ_PREV(m, pglist, listq)) != NULL && + prev->right == m) { + /* + * Since the page's predecessor in the list is also its parent + * in the tree, its left subtree must be empty. + */ + KASSERT(m->left == NULL, + ("vm_page_remove: page %p has left child", m)); + prev->right = m->right; + } else { + if (m != object->root) + vm_page_splay(m->pindex, object->root); + if (m->left == NULL) + root = m->right; + else if (m->right == NULL) + root = m->left; + else { + /* + * Move the page's successor to the root, because + * pages are usually removed in ascending order. + */ + if (m->right != next) + vm_page_splay(m->pindex, m->right); + next->left = m->left; + root = next; + } + object->root = root; } - object->root = root; TAILQ_REMOVE(&object->memq, m, listq); /* @@ -1802,7 +1829,7 @@ void vm_page_cache(vm_page_t m) { vm_object_t object; - vm_page_t root; + vm_page_t next, prev, root; mtx_assert(&vm_page_queue_mtx, MA_OWNED); object = m->object; @@ -1838,15 +1865,42 @@ vm_page_cache(vm_page_t m) * Remove the page from the object's collection of resident * pages. */ - if (m != object->root) - vm_page_splay(m->pindex, object->root); - if (m->left == NULL) - root = m->right; - else { - root = vm_page_splay(m->pindex, m->left); - root->right = m->right; + if ((next = TAILQ_NEXT(m, listq)) != NULL && next->left == m) { + /* + * Since the page's successor in the list is also its parent + * in the tree, its right subtree must be empty. + */ + next->left = m->left; + KASSERT(m->right == NULL, + ("vm_page_cache: page %p has right child", m)); + } else if ((prev = TAILQ_PREV(m, pglist, listq)) != NULL && + prev->right == m) { + /* + * Since the page's predecessor in the list is also its parent + * in the tree, its left subtree must be empty. + */ + KASSERT(m->left == NULL, + ("vm_page_cache: page %p has left child", m)); + prev->right = m->right; + } else { + if (m != object->root) + vm_page_splay(m->pindex, object->root); + if (m->left == NULL) + root = m->right; + else if (m->right == NULL) + root = m->left; + else { + /* + * Move the page's successor to the root, because + * pages are usually removed in ascending order. + */ + if (m->right != next) + vm_page_splay(m->pindex, m->right); + next->left = m->left; + root = next; + } + object->root = root; } - object->root = root; TAILQ_REMOVE(&object->memq, m, listq); object->resident_page_count--; From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 11 01:37:49 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 191071065670; Fri, 11 Nov 2011 01:37:49 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 08A838FC13; Fri, 11 Nov 2011 01:37:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB1bmdj064953; Fri, 11 Nov 2011 01:37:48 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB1bmvi064951; Fri, 11 Nov 2011 01:37:48 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110137.pAB1bmvi064951@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 01:37:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227436 - stable/8/sbin/camcontrol X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 01:37:49 -0000 Author: rstone Date: Fri Nov 11 01:37:48 2011 New Revision: 227436 URL: http://svn.freebsd.org/changeset/base/227436 Log: MFC 215507: When doing a camcontrol rescan all or a camcontrol reset all, use the wildcard path id for enumerating the available busses. Previously camcontrol was implicitly passing 0 as the first path id, which meant that if bus 0 was not present camcontrol would fail with EINVAL instead of rescanning/resetting any busses that were present. Modified: stable/8/sbin/camcontrol/camcontrol.c Directory Properties: stable/8/sbin/camcontrol/ (props changed) Modified: stable/8/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/8/sbin/camcontrol/camcontrol.c Fri Nov 11 01:35:07 2011 (r227435) +++ stable/8/sbin/camcontrol/camcontrol.c Fri Nov 11 01:37:48 2011 (r227436) @@ -1526,6 +1526,7 @@ rescan_or_reset_bus(int bus, int rescan) bzero(&(&matchccb.ccb_h)[1], sizeof(struct ccb_dev_match) - sizeof(struct ccb_hdr)); matchccb.ccb_h.func_code = XPT_DEV_MATCH; + matchccb.ccb_h.path_id = CAM_BUS_WILDCARD; bufsize = sizeof(struct dev_match_result) * 20; matchccb.cdm.match_buf_len = bufsize; matchccb.cdm.matches=(struct dev_match_result *)malloc(bufsize); From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 11 02:02:56 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F1BF106566C; Fri, 11 Nov 2011 02:02:56 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 252E48FC0C; Fri, 11 Nov 2011 02:02:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB22urd065812; Fri, 11 Nov 2011 02:02:56 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB22u04065810; Fri, 11 Nov 2011 02:02:56 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110202.pAB22u04065810@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 02:02:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227437 - stable/8/sys/tools X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 02:02:56 -0000 Author: rstone Date: Fri Nov 11 02:02:55 2011 New Revision: 227437 URL: http://svn.freebsd.org/changeset/base/227437 Log: MFC 220227: GNU awk does not output escaped newlines in multi-line printc statements. This leads to compile errors when trying to compile firmware(9) stubs created with gawk, as multiple #include statements end up on the same line. Replace the multi-line printc statement that outputs all of the #includes with one printc per #include. This allows modules compatible with firmware(9) to be cross-built from a Linux machine without requiring the one true awk to be installed. I've intentionally done the minimal set of changes necessary to make gawk produce valid (but not pretty) C code, to reduce the churn and keep fw_stubs.awk as readable as possible. Modified: stable/8/sys/tools/fw_stub.awk Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/tools/fw_stub.awk ============================================================================== --- stable/8/sys/tools/fw_stub.awk Fri Nov 11 01:37:48 2011 (r227436) +++ stable/8/sys/tools/fw_stub.awk Fri Nov 11 02:02:55 2011 (r227437) @@ -121,13 +121,13 @@ ctmpfilename = cfilename ".tmp"; modname = opt_m; gsub(/[-\.]/, "_", modname); -printc("#include \ -#include \ -#include \ -#include \ -#include \ -#include \ -#include \n"); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include \n"); if (opt_l) { printc("static long " opt_l "_license_ack = 0;"); From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 11 02:10:24 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B802106564A; Fri, 11 Nov 2011 02:10:24 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AFA98FC0A; Fri, 11 Nov 2011 02:10:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB2AOQO066090; Fri, 11 Nov 2011 02:10:24 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB2AOod066088; Fri, 11 Nov 2011 02:10:24 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110210.pAB2AOod066088@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 02:10:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227438 - stable/8/lib/libthr/thread X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 02:10:24 -0000 Author: rstone Date: Fri Nov 11 02:10:24 2011 New Revision: 227438 URL: http://svn.freebsd.org/changeset/base/227438 Log: MFC 220888 r179417 introduced a bug into pthread_once(). Previously pthread_once() used a global pthread_mutex_t for synchronization. r179417 replaced that with an implementation that directly used atomic instructions and thr_* syscalls to synchronize callers to pthread_once. However, calling pthread_mutex_lock on the global mutex implicitly ensured that _thr_check_init() had been called but with r179417 this was no longer guaranteed. This meant that if you were unlucky enough to have your first call into libthr be a call to pthread_once(), you would segfault when trying to access the pointer returned by _get_curthread(). The fix is to explicitly call _thr_check_init() from pthread_once(). Modified: stable/8/lib/libthr/thread/thr_once.c Directory Properties: stable/8/lib/libthr/ (props changed) Modified: stable/8/lib/libthr/thread/thr_once.c ============================================================================== --- stable/8/lib/libthr/thread/thr_once.c Fri Nov 11 02:02:55 2011 (r227437) +++ stable/8/lib/libthr/thread/thr_once.c Fri Nov 11 02:10:24 2011 (r227438) @@ -64,6 +64,8 @@ _pthread_once(pthread_once_t *once_contr struct pthread *curthread; int state; + _thr_check_init(); + for (;;) { state = once_control->state; if (state == ONCE_DONE) From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 11 02:13:35 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F739106564A; Fri, 11 Nov 2011 02:13:35 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 65A6D8FC08; Fri, 11 Nov 2011 02:13:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB2DZux066241; Fri, 11 Nov 2011 02:13:35 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB2DZLY066239; Fri, 11 Nov 2011 02:13:35 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110213.pAB2DZLY066239@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 02:13:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227439 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 02:13:35 -0000 Author: rstone Date: Fri Nov 11 02:13:35 2011 New Revision: 227439 URL: http://svn.freebsd.org/changeset/base/227439 Log: MFC 221081: If the 4BSD scheduler tries to schedule a thread that has been pinned or bound to an AP before SMP has started, the system will panic when we try to touch per-CPU state for that AP because that state has not been initialized yet. Fix this in the same way as ULE: place all threads in the global run queue before SMP has started. Modified: stable/8/sys/kern/sched_4bsd.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/sched_4bsd.c ============================================================================== --- stable/8/sys/kern/sched_4bsd.c Fri Nov 11 02:10:24 2011 (r227438) +++ stable/8/sys/kern/sched_4bsd.c Fri Nov 11 02:13:35 2011 (r227439) @@ -1241,25 +1241,27 @@ sched_add(struct thread *td, int flags) } TD_SET_RUNQ(td); - if (td->td_pinned != 0) { - cpu = td->td_lastcpu; - ts->ts_runq = &runq_pcpu[cpu]; - single_cpu = 1; - CTR3(KTR_RUNQ, - "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td, - cpu); - } else if (td->td_flags & TDF_BOUND) { - /* Find CPU from bound runq. */ - KASSERT(SKE_RUNQ_PCPU(ts), - ("sched_add: bound td_sched not on cpu runq")); - cpu = ts->ts_runq - &runq_pcpu[0]; - single_cpu = 1; - CTR3(KTR_RUNQ, - "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td, - cpu); - } else if (ts->ts_flags & TSF_AFFINITY) { - /* Find a valid CPU for our cpuset */ - cpu = sched_pickcpu(td); + /* + * If SMP is started and the thread is pinned or otherwise limited to + * a specific set of CPUs, queue the thread to a per-CPU run queue. + * Otherwise, queue the thread to the global run queue. + * + * If SMP has not yet been started we must use the global run queue + * as per-CPU state may not be initialized yet and we may crash if we + * try to access the per-CPU run queues. + */ + if (smp_started && (td->td_pinned != 0 || td->td_flags & TDF_BOUND || + ts->ts_flags & TSF_AFFINITY)) { + if (td->td_pinned != 0) + cpu = td->td_lastcpu; + else if (td->td_flags & TDF_BOUND) { + /* Find CPU from bound runq. */ + KASSERT(SKE_RUNQ_PCPU(ts), + ("sched_add: bound td_sched not on cpu runq")); + cpu = ts->ts_runq - &runq_pcpu[0]; + } else + /* Find a valid CPU for our cpuset */ + cpu = sched_pickcpu(td); ts->ts_runq = &runq_pcpu[cpu]; single_cpu = 1; CTR3(KTR_RUNQ, From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 11 02:15:44 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD6F61065676; Fri, 11 Nov 2011 02:15:44 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CDAC8FC16; Fri, 11 Nov 2011 02:15:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB2FiAX066359; Fri, 11 Nov 2011 02:15:44 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB2FilL066357; Fri, 11 Nov 2011 02:15:44 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110215.pAB2FilL066357@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 02:15:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227440 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 02:15:44 -0000 Author: rstone Date: Fri Nov 11 02:15:44 2011 New Revision: 227440 URL: http://svn.freebsd.org/changeset/base/227440 Log: MFC 224156: Fix a LOR between hwpmc and the kernel linker. When a system-wide sampling mode PMC is allocated, hwpmc calls linker_hwpmc_list_objects() while already holding an exclusive lock on pmc-sx lock. list_objects() tries to acquire an exclusive lock on the kld_sx lock. When a KLD module is loaded or unloaded successfully, kern_kld(un)load calls into the pmc hook while already holding an exclusive lock on the kld_sx lock. Calling the pmc hook requires acquiring a shared lock on the pmc-sx lock. Fix this by only acquiring a shared lock on the kld_sx lock in linker_hwpmc_list_objects(), and also downgrading to a shared lock on the kld_sx lock in kern_kld(un)load before calling into the pmc hook. In kern_kldload this required moving some modifications of the linker_file_t to happen before calling into the pmc hook. This fixes the deadlock by ensuring that the hwpmc -> list_objects() case is always able to proceed. Without this patch, I was able to deadlock a multicore system within minutes by constantly loading and unloading an KLD module while I simultaneously started a sampling mode PMC in a loop. Modified: stable/8/sys/kern/kern_linker.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_linker.c ============================================================================== --- stable/8/sys/kern/kern_linker.c Fri Nov 11 02:13:35 2011 (r227439) +++ stable/8/sys/kern/kern_linker.c Fri Nov 11 02:15:44 2011 (r227440) @@ -68,6 +68,9 @@ int kld_debug = 0; #define KLD_LOCK() sx_xlock(&kld_sx) #define KLD_UNLOCK() sx_xunlock(&kld_sx) +#define KLD_DOWNGRADE() sx_downgrade(&kld_sx) +#define KLD_LOCK_READ() sx_slock(&kld_sx) +#define KLD_UNLOCK_READ() sx_sunlock(&kld_sx) #define KLD_LOCKED() sx_xlocked(&kld_sx) #define KLD_LOCK_ASSERT() do { \ if (!cold) \ @@ -1014,18 +1017,24 @@ kern_kldload(struct thread *td, const ch KLD_LOCK(); error = linker_load_module(kldname, modname, NULL, NULL, &lf); - if (error) - goto unlock; + if (error) { + KLD_UNLOCK(); + goto done; + } + lf->userrefs++; + if (fileid != NULL) + *fileid = lf->id; #ifdef HWPMC_HOOKS + KLD_DOWNGRADE(); pkm.pm_file = lf->filename; pkm.pm_address = (uintptr_t) lf->address; PMC_CALL_HOOK(td, PMC_FN_KLD_LOAD, (void *) &pkm); -#endif - lf->userrefs++; - if (fileid != NULL) - *fileid = lf->id; -unlock: + KLD_UNLOCK_READ(); +#else KLD_UNLOCK(); +#endif + +done: CURVNET_RESTORE(); return (error); } @@ -1097,10 +1106,14 @@ kern_kldunload(struct thread *td, int fi error = ENOENT; #ifdef HWPMC_HOOKS - if (error == 0) + if (error == 0) { + KLD_DOWNGRADE(); PMC_CALL_HOOK(td, PMC_FN_KLD_UNLOAD, (void *) &pkm); + KLD_UNLOCK_READ(); + } else +#else + KLD_UNLOCK(); #endif - KLD_UNLOCK(); CURVNET_RESTORE(); return (error); } @@ -1919,7 +1932,7 @@ linker_hwpmc_list_objects(void) int i, nmappings; nmappings = 0; - KLD_LOCK(); + KLD_LOCK_READ(); TAILQ_FOREACH(lf, &linker_files, link) nmappings++; @@ -1934,7 +1947,7 @@ linker_hwpmc_list_objects(void) kobase[i].pm_address = (uintptr_t)lf->address; i++; } - KLD_UNLOCK(); + KLD_UNLOCK_READ(); KASSERT(i > 0, ("linker_hpwmc_list_objects: no kernel objects?"));