Tue Mar 6 02:36:47 2012 UTC ()
pull down from usbmp branch:

- remove SPLUSBCHECK.  it has been broken and disabled for ages.


(mrg)
diff -r1.183 -r1.184 src/sys/dev/usb/ehci.c
diff -r1.218 -r1.219 src/sys/dev/usb/ohci.c
diff -r1.242 -r1.243 src/sys/dev/usb/uhci.c
diff -r1.134 -r1.135 src/sys/dev/usb/usbdi.c
diff -r1.93 -r1.94 src/sys/dev/usb/usbdivar.h

cvs diff -r1.183 -r1.184 src/sys/dev/usb/ehci.c (expand / switch to unified diff)

--- src/sys/dev/usb/ehci.c 2011/12/23 00:51:43 1.183
+++ src/sys/dev/usb/ehci.c 2012/03/06 02:36:45 1.184
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehci.c,v 1.183 2011/12/23 00:51:43 jakllsch Exp $ */ 1/* $NetBSD: ehci.c,v 1.184 2012/03/06 02:36:45 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004-2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004-2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum and 8 * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum and
9 * Jeremy Morse (jeremy.morse@gmail.com). 9 * Jeremy Morse (jeremy.morse@gmail.com).
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -42,27 +42,27 @@ @@ -42,27 +42,27 @@
42 42
43/* 43/*
44 * TODO: 44 * TODO:
45 * 1) hold off explorations by companion controllers until ehci has started. 45 * 1) hold off explorations by companion controllers until ehci has started.
46 * 46 *
47 * 2) The hub driver needs to handle and schedule the transaction translator, 47 * 2) The hub driver needs to handle and schedule the transaction translator,
48 * to assign place in frame where different devices get to go. See chapter 48 * to assign place in frame where different devices get to go. See chapter
49 * on hubs in USB 2.0 for details. 49 * on hubs in USB 2.0 for details.
50 * 50 *
51 * 3) Command failures are not recovered correctly. 51 * 3) Command failures are not recovered correctly.
52 */ 52 */
53 53
54#include <sys/cdefs.h> 54#include <sys/cdefs.h>
55__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.183 2011/12/23 00:51:43 jakllsch Exp $"); 55__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.184 2012/03/06 02:36:45 mrg Exp $");
56 56
57#include "ohci.h" 57#include "ohci.h"
58#include "uhci.h" 58#include "uhci.h"
59#include "opt_usb.h" 59#include "opt_usb.h"
60 60
61#include <sys/param.h> 61#include <sys/param.h>
62#include <sys/systm.h> 62#include <sys/systm.h>
63#include <sys/kernel.h> 63#include <sys/kernel.h>
64#include <sys/malloc.h> 64#include <sys/malloc.h>
65#include <sys/device.h> 65#include <sys/device.h>
66#include <sys/select.h> 66#include <sys/select.h>
67#include <sys/proc.h> 67#include <sys/proc.h>
68#include <sys/queue.h> 68#include <sys/queue.h>
@@ -1720,27 +1720,26 @@ ehci_open(usbd_pipe_handle pipe) @@ -1720,27 +1720,26 @@ ehci_open(usbd_pipe_handle pipe)
1720 1720
1721 bad: 1721 bad:
1722 if (sqh != NULL) 1722 if (sqh != NULL)
1723 ehci_free_sqh(sc, sqh); 1723 ehci_free_sqh(sc, sqh);
1724 return (err); 1724 return (err);
1725} 1725}
1726 1726
1727/* 1727/*
1728 * Add an ED to the schedule. Called at splusb(). 1728 * Add an ED to the schedule. Called at splusb().
1729 */ 1729 */
1730Static void 1730Static void
1731ehci_add_qh(ehci_soft_qh_t *sqh, ehci_soft_qh_t *head) 1731ehci_add_qh(ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
1732{ 1732{
1733 SPLUSBCHECK; 
1734 1733
1735 usb_syncmem(&head->dma, head->offs + offsetof(ehci_qh_t, qh_link), 1734 usb_syncmem(&head->dma, head->offs + offsetof(ehci_qh_t, qh_link),
1736 sizeof(head->qh.qh_link), BUS_DMASYNC_POSTWRITE); 1735 sizeof(head->qh.qh_link), BUS_DMASYNC_POSTWRITE);
1737 sqh->next = head->next; 1736 sqh->next = head->next;
1738 sqh->qh.qh_link = head->qh.qh_link; 1737 sqh->qh.qh_link = head->qh.qh_link;
1739 usb_syncmem(&sqh->dma, sqh->offs + offsetof(ehci_qh_t, qh_link), 1738 usb_syncmem(&sqh->dma, sqh->offs + offsetof(ehci_qh_t, qh_link),
1740 sizeof(sqh->qh.qh_link), BUS_DMASYNC_PREWRITE); 1739 sizeof(sqh->qh.qh_link), BUS_DMASYNC_PREWRITE);
1741 head->next = sqh; 1740 head->next = sqh;
1742 head->qh.qh_link = htole32(sqh->physaddr | EHCI_LINK_QH); 1741 head->qh.qh_link = htole32(sqh->physaddr | EHCI_LINK_QH);
1743 usb_syncmem(&head->dma, head->offs + offsetof(ehci_qh_t, qh_link), 1742 usb_syncmem(&head->dma, head->offs + offsetof(ehci_qh_t, qh_link),
1744 sizeof(head->qh.qh_link), BUS_DMASYNC_PREWRITE); 1743 sizeof(head->qh.qh_link), BUS_DMASYNC_PREWRITE);
1745 1744
1746#ifdef EHCI_DEBUG 1745#ifdef EHCI_DEBUG
@@ -1749,27 +1748,26 @@ ehci_add_qh(ehci_soft_qh_t *sqh, ehci_so @@ -1749,27 +1748,26 @@ ehci_add_qh(ehci_soft_qh_t *sqh, ehci_so
1749 ehci_dump_sqh(sqh); 1748 ehci_dump_sqh(sqh);
1750 } 1749 }
1751#endif 1750#endif
1752} 1751}
1753 1752
1754/* 1753/*
1755 * Remove an ED from the schedule. Called at splusb(). 1754 * Remove an ED from the schedule. Called at splusb().
1756 */ 1755 */
1757Static void 1756Static void
1758ehci_rem_qh(ehci_softc_t *sc, ehci_soft_qh_t *sqh, ehci_soft_qh_t *head) 1757ehci_rem_qh(ehci_softc_t *sc, ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
1759{ 1758{
1760 ehci_soft_qh_t *p; 1759 ehci_soft_qh_t *p;
1761 1760
1762 SPLUSBCHECK; 
1763 /* XXX */ 1761 /* XXX */
1764 for (p = head; p != NULL && p->next != sqh; p = p->next) 1762 for (p = head; p != NULL && p->next != sqh; p = p->next)
1765 ; 1763 ;
1766 if (p == NULL) 1764 if (p == NULL)
1767 panic("ehci_rem_qh: ED not found"); 1765 panic("ehci_rem_qh: ED not found");
1768 usb_syncmem(&sqh->dma, sqh->offs + offsetof(ehci_qh_t, qh_link), 1766 usb_syncmem(&sqh->dma, sqh->offs + offsetof(ehci_qh_t, qh_link),
1769 sizeof(sqh->qh.qh_link), BUS_DMASYNC_POSTWRITE); 1767 sizeof(sqh->qh.qh_link), BUS_DMASYNC_POSTWRITE);
1770 p->next = sqh->next; 1768 p->next = sqh->next;
1771 p->qh.qh_link = sqh->qh.qh_link; 1769 p->qh.qh_link = sqh->qh.qh_link;
1772 usb_syncmem(&p->dma, p->offs + offsetof(ehci_qh_t, qh_link), 1770 usb_syncmem(&p->dma, p->offs + offsetof(ehci_qh_t, qh_link),
1773 sizeof(p->qh.qh_link), BUS_DMASYNC_PREWRITE); 1771 sizeof(p->qh.qh_link), BUS_DMASYNC_PREWRITE);
1774 1772
1775 ehci_sync_hc(sc); 1773 ehci_sync_hc(sc);

cvs diff -r1.218 -r1.219 src/sys/dev/usb/ohci.c (expand / switch to unified diff)

--- src/sys/dev/usb/ohci.c 2011/08/07 13:45:46 1.218
+++ src/sys/dev/usb/ohci.c 2012/03/06 02:36:46 1.219
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ohci.c,v 1.218 2011/08/07 13:45:46 jmcneill Exp $ */ 1/* $NetBSD: ohci.c,v 1.219 2012/03/06 02:36:46 mrg Exp $ */
2/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998, 2004, 2005 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998, 2004, 2005 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * This code is derived from software contributed to The NetBSD Foundation 11 * This code is derived from software contributed to The NetBSD Foundation
12 * by Charles M. Hannum. 12 * by Charles M. Hannum.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE. 33 * POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36/* 36/*
37 * USB Open Host Controller driver. 37 * USB Open Host Controller driver.
38 * 38 *
39 * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html 39 * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html
40 * USB spec: http://www.usb.org/developers/docs/ 40 * USB spec: http://www.usb.org/developers/docs/
41 */ 41 */
42 42
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218 2011/08/07 13:45:46 jmcneill Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.219 2012/03/06 02:36:46 mrg Exp $");
45 45
46#include "opt_usb.h" 46#include "opt_usb.h"
47 47
48#include <sys/param.h> 48#include <sys/param.h>
49#include <sys/systm.h> 49#include <sys/systm.h>
50#include <sys/malloc.h> 50#include <sys/malloc.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/device.h> 52#include <sys/device.h>
53#include <sys/select.h> 53#include <sys/select.h>
54#include <sys/proc.h> 54#include <sys/proc.h>
55#include <sys/queue.h> 55#include <sys/queue.h>
56 56
57#include <sys/bus.h> 57#include <sys/bus.h>
@@ -1802,52 +1802,49 @@ ohci_device_request(usbd_xfer_handle xfe @@ -1802,52 +1802,49 @@ ohci_device_request(usbd_xfer_handle xfe
1802 ohci_free_std(sc, stat); 1802 ohci_free_std(sc, stat);
1803 bad1: 1803 bad1:
1804 return (err); 1804 return (err);
1805} 1805}
1806 1806
1807/* 1807/*
1808 * Add an ED to the schedule. Called at splusb(). 1808 * Add an ED to the schedule. Called at splusb().
1809 */ 1809 */
1810void 1810void
1811ohci_add_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head) 1811ohci_add_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
1812{ 1812{
1813 DPRINTFN(8,("ohci_add_ed: sed=%p head=%p\n", sed, head)); 1813 DPRINTFN(8,("ohci_add_ed: sed=%p head=%p\n", sed, head));
1814 1814
1815 SPLUSBCHECK; 
1816 usb_syncmem(&head->dma, head->offs + offsetof(ohci_ed_t, ed_nexted), 1815 usb_syncmem(&head->dma, head->offs + offsetof(ohci_ed_t, ed_nexted),
1817 sizeof(head->ed.ed_nexted), 1816 sizeof(head->ed.ed_nexted),
1818 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); 1817 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
1819 sed->next = head->next; 1818 sed->next = head->next;
1820 sed->ed.ed_nexted = head->ed.ed_nexted; 1819 sed->ed.ed_nexted = head->ed.ed_nexted;
1821 usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted), 1820 usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted),
1822 sizeof(sed->ed.ed_nexted), 1821 sizeof(sed->ed.ed_nexted),
1823 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1822 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
1824 head->next = sed; 1823 head->next = sed;
1825 head->ed.ed_nexted = HTOO32(sed->physaddr); 1824 head->ed.ed_nexted = HTOO32(sed->physaddr);
1826 usb_syncmem(&head->dma, head->offs + offsetof(ohci_ed_t, ed_nexted), 1825 usb_syncmem(&head->dma, head->offs + offsetof(ohci_ed_t, ed_nexted),
1827 sizeof(head->ed.ed_nexted), 1826 sizeof(head->ed.ed_nexted),
1828 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1827 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
1829} 1828}
1830 1829
1831/* 1830/*
1832 * Remove an ED from the schedule. Called at splusb(). 1831 * Remove an ED from the schedule. Called at splusb().
1833 */ 1832 */
1834void 1833void
1835ohci_rem_ed(ohci_soft_ed_t *sed, ohci_soft_ed_t *head) 1834ohci_rem_ed(ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
1836{ 1835{
1837 ohci_soft_ed_t *p; 1836 ohci_soft_ed_t *p;
1838 1837
1839 SPLUSBCHECK; 
1840 
1841 /* XXX */ 1838 /* XXX */
1842 for (p = head; p != NULL && p->next != sed; p = p->next) 1839 for (p = head; p != NULL && p->next != sed; p = p->next)
1843 ; 1840 ;
1844 if (p == NULL) 1841 if (p == NULL)
1845 panic("ohci_rem_ed: ED not found"); 1842 panic("ohci_rem_ed: ED not found");
1846 usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted), 1843 usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted),
1847 sizeof(sed->ed.ed_nexted), 1844 sizeof(sed->ed.ed_nexted),
1848 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); 1845 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
1849 p->next = sed->next; 1846 p->next = sed->next;
1850 p->ed.ed_nexted = sed->ed.ed_nexted; 1847 p->ed.ed_nexted = sed->ed.ed_nexted;
1851 usb_syncmem(&p->dma, p->offs + offsetof(ohci_ed_t, ed_nexted), 1848 usb_syncmem(&p->dma, p->offs + offsetof(ohci_ed_t, ed_nexted),
1852 sizeof(p->ed.ed_nexted), 1849 sizeof(p->ed.ed_nexted),
1853 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1850 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
@@ -1860,73 +1857,67 @@ ohci_rem_ed(ohci_soft_ed_t *sed, ohci_so @@ -1860,73 +1857,67 @@ ohci_rem_ed(ohci_soft_ed_t *sed, ohci_so
1860 * and we have no simple way to translate this back to a kernel address. 1857 * and we have no simple way to translate this back to a kernel address.
1861 * To make the translation possible (and fast) we use a hash table of 1858 * To make the translation possible (and fast) we use a hash table of
1862 * TDs currently in the schedule. The physical address is used as the 1859 * TDs currently in the schedule. The physical address is used as the
1863 * hash value. 1860 * hash value.
1864 */ 1861 */
1865 1862
1866#define HASH(a) (((a) >> 4) % OHCI_HASH_SIZE) 1863#define HASH(a) (((a) >> 4) % OHCI_HASH_SIZE)
1867/* Called at splusb() */ 1864/* Called at splusb() */
1868void 1865void
1869ohci_hash_add_td(ohci_softc_t *sc, ohci_soft_td_t *std) 1866ohci_hash_add_td(ohci_softc_t *sc, ohci_soft_td_t *std)
1870{ 1867{
1871 int h = HASH(std->physaddr); 1868 int h = HASH(std->physaddr);
1872 1869
1873 SPLUSBCHECK; 
1874 
1875 LIST_INSERT_HEAD(&sc->sc_hash_tds[h], std, hnext); 1870 LIST_INSERT_HEAD(&sc->sc_hash_tds[h], std, hnext);
1876} 1871}
1877 1872
1878/* Called at splusb() */ 1873/* Called at splusb() */
1879void 1874void
1880ohci_hash_rem_td(ohci_softc_t *sc, ohci_soft_td_t *std) 1875ohci_hash_rem_td(ohci_softc_t *sc, ohci_soft_td_t *std)
1881{ 1876{
1882 SPLUSBCHECK; 
1883 1877
1884 LIST_REMOVE(std, hnext); 1878 LIST_REMOVE(std, hnext);
1885} 1879}
1886 1880
1887ohci_soft_td_t * 1881ohci_soft_td_t *
1888ohci_hash_find_td(ohci_softc_t *sc, ohci_physaddr_t a) 1882ohci_hash_find_td(ohci_softc_t *sc, ohci_physaddr_t a)
1889{ 1883{
1890 int h = HASH(a); 1884 int h = HASH(a);
1891 ohci_soft_td_t *std; 1885 ohci_soft_td_t *std;
1892 1886
1893 for (std = LIST_FIRST(&sc->sc_hash_tds[h]); 1887 for (std = LIST_FIRST(&sc->sc_hash_tds[h]);
1894 std != NULL; 1888 std != NULL;
1895 std = LIST_NEXT(std, hnext)) 1889 std = LIST_NEXT(std, hnext))
1896 if (std->physaddr == a) 1890 if (std->physaddr == a)
1897 return (std); 1891 return (std);
1898 return (NULL); 1892 return (NULL);
1899} 1893}
1900 1894
1901/* Called at splusb() */ 1895/* Called at splusb() */
1902void 1896void
1903ohci_hash_add_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd) 1897ohci_hash_add_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
1904{ 1898{
1905 int h = HASH(sitd->physaddr); 1899 int h = HASH(sitd->physaddr);
1906 1900
1907 SPLUSBCHECK; 
1908 
1909 DPRINTFN(10,("ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n", 1901 DPRINTFN(10,("ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n",
1910 sitd, (u_long)sitd->physaddr)); 1902 sitd, (u_long)sitd->physaddr));
1911 1903
1912 LIST_INSERT_HEAD(&sc->sc_hash_itds[h], sitd, hnext); 1904 LIST_INSERT_HEAD(&sc->sc_hash_itds[h], sitd, hnext);
1913} 1905}
1914 1906
1915/* Called at splusb() */ 1907/* Called at splusb() */
1916void 1908void
1917ohci_hash_rem_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd) 1909ohci_hash_rem_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
1918{ 1910{
1919 SPLUSBCHECK; 
1920 1911
1921 DPRINTFN(10,("ohci_hash_rem_itd: sitd=%p physaddr=0x%08lx\n", 1912 DPRINTFN(10,("ohci_hash_rem_itd: sitd=%p physaddr=0x%08lx\n",
1922 sitd, (u_long)sitd->physaddr)); 1913 sitd, (u_long)sitd->physaddr));
1923 1914
1924 LIST_REMOVE(sitd, hnext); 1915 LIST_REMOVE(sitd, hnext);
1925} 1916}
1926 1917
1927ohci_soft_itd_t * 1918ohci_soft_itd_t *
1928ohci_hash_find_itd(ohci_softc_t *sc, ohci_physaddr_t a) 1919ohci_hash_find_itd(ohci_softc_t *sc, ohci_physaddr_t a)
1929{ 1920{
1930 int h = HASH(a); 1921 int h = HASH(a);
1931 ohci_soft_itd_t *sitd; 1922 ohci_soft_itd_t *sitd;
1932 1923

cvs diff -r1.242 -r1.243 src/sys/dev/usb/uhci.c (expand / switch to unified diff)

--- src/sys/dev/usb/uhci.c 2011/12/23 00:51:46 1.242
+++ src/sys/dev/usb/uhci.c 2012/03/06 02:36:46 1.243
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uhci.c,v 1.242 2011/12/23 00:51:46 jakllsch Exp $ */ 1/* $NetBSD: uhci.c,v 1.243 2012/03/06 02:36:46 mrg Exp $ */
2/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 */ 32 */
33 33
34/* 34/*
35 * USB Universal Host Controller driver. 35 * USB Universal Host Controller driver.
36 * Handles e.g. PIIX3 and PIIX4. 36 * Handles e.g. PIIX3 and PIIX4.
37 * 37 *
38 * UHCI spec: http://www.intel.com/technology/usb/spec.htm 38 * UHCI spec: http://www.intel.com/technology/usb/spec.htm
39 * USB spec: http://www.usb.org/developers/docs/ 39 * USB spec: http://www.usb.org/developers/docs/
40 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf 40 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf
41 * ftp://download.intel.com/design/intarch/datashts/29056201.pdf 41 * ftp://download.intel.com/design/intarch/datashts/29056201.pdf
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.242 2011/12/23 00:51:46 jakllsch Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.243 2012/03/06 02:36:46 mrg Exp $");
46 46
47#include "opt_usb.h" 47#include "opt_usb.h"
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/malloc.h> 52#include <sys/malloc.h>
53#include <sys/device.h> 53#include <sys/device.h>
54#include <sys/select.h> 54#include <sys/select.h>
55#include <sys/extent.h> 55#include <sys/extent.h>
56#include <sys/proc.h> 56#include <sys/proc.h>
57#include <sys/queue.h> 57#include <sys/queue.h>
58#include <sys/bus.h> 58#include <sys/bus.h>
@@ -1066,55 +1066,51 @@ uhci_rem_loop(uhci_softc_t *sc) { @@ -1066,55 +1066,51 @@ uhci_rem_loop(uhci_softc_t *sc) {
1066 usb_syncmem(&sc->sc_last_qh->dma, 1066 usb_syncmem(&sc->sc_last_qh->dma,
1067 sc->sc_last_qh->offs + offsetof(uhci_qh_t, qh_hlink), 1067 sc->sc_last_qh->offs + offsetof(uhci_qh_t, qh_hlink),
1068 sizeof(sc->sc_last_qh->qh.qh_hlink), 1068 sizeof(sc->sc_last_qh->qh.qh_hlink),
1069 BUS_DMASYNC_PREWRITE); 1069 BUS_DMASYNC_PREWRITE);
1070 } 1070 }
1071} 1071}
1072 1072
1073/* Add high speed control QH, called at splusb(). */ 1073/* Add high speed control QH, called at splusb(). */
1074void 1074void
1075uhci_add_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1075uhci_add_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1076{ 1076{
1077 uhci_soft_qh_t *eqh; 1077 uhci_soft_qh_t *eqh;
1078 1078
1079 SPLUSBCHECK; 
1080 
1081 DPRINTFN(10, ("uhci_add_ctrl: sqh=%p\n", sqh)); 1079 DPRINTFN(10, ("uhci_add_ctrl: sqh=%p\n", sqh));
1082 eqh = sc->sc_hctl_end; 1080 eqh = sc->sc_hctl_end;
1083 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1081 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1084 sizeof(eqh->qh.qh_hlink), 1082 sizeof(eqh->qh.qh_hlink),
1085 BUS_DMASYNC_POSTWRITE); 1083 BUS_DMASYNC_POSTWRITE);
1086 sqh->hlink = eqh->hlink; 1084 sqh->hlink = eqh->hlink;
1087 sqh->qh.qh_hlink = eqh->qh.qh_hlink; 1085 sqh->qh.qh_hlink = eqh->qh.qh_hlink;
1088 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh), 1086 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh),
1089 BUS_DMASYNC_PREWRITE); 1087 BUS_DMASYNC_PREWRITE);
1090 eqh->hlink = sqh; 1088 eqh->hlink = sqh;
1091 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); 1089 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
1092 sc->sc_hctl_end = sqh; 1090 sc->sc_hctl_end = sqh;
1093 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1091 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1094 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE); 1092 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE);
1095#ifdef UHCI_CTL_LOOP 1093#ifdef UHCI_CTL_LOOP
1096 uhci_add_loop(sc); 1094 uhci_add_loop(sc);
1097#endif 1095#endif
1098} 1096}
1099 1097
1100/* Remove high speed control QH, called at splusb(). */ 1098/* Remove high speed control QH, called at splusb(). */
1101void 1099void
1102uhci_remove_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1100uhci_remove_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1103{ 1101{
1104 uhci_soft_qh_t *pqh; 1102 uhci_soft_qh_t *pqh;
1105 1103
1106 SPLUSBCHECK; 
1107 
1108 DPRINTFN(10, ("uhci_remove_hs_ctrl: sqh=%p\n", sqh)); 1104 DPRINTFN(10, ("uhci_remove_hs_ctrl: sqh=%p\n", sqh));
1109#ifdef UHCI_CTL_LOOP 1105#ifdef UHCI_CTL_LOOP
1110 uhci_rem_loop(sc); 1106 uhci_rem_loop(sc);
1111#endif 1107#endif
1112 /* 1108 /*
1113 * The T bit should be set in the elink of the QH so that the HC 1109 * The T bit should be set in the elink of the QH so that the HC
1114 * doesn't follow the pointer. This condition may fail if the 1110 * doesn't follow the pointer. This condition may fail if the
1115 * the transferred packet was short so that the QH still points 1111 * the transferred packet was short so that the QH still points
1116 * at the last used TD. 1112 * at the last used TD.
1117 * In this case we set the T bit and wait a little for the HC 1113 * In this case we set the T bit and wait a little for the HC
1118 * to stop looking at the TD. 1114 * to stop looking at the TD.
1119 * Note that if the TD chain is large enough, the controller 1115 * Note that if the TD chain is large enough, the controller
1120 * may still be looking at the chain at the end of this function. 1116 * may still be looking at the chain at the end of this function.
@@ -1143,51 +1139,47 @@ uhci_remove_hs_ctrl(uhci_softc_t *sc, uh @@ -1143,51 +1139,47 @@ uhci_remove_hs_ctrl(uhci_softc_t *sc, uh
1143 sizeof(pqh->qh.qh_hlink), 1139 sizeof(pqh->qh.qh_hlink),
1144 BUS_DMASYNC_PREWRITE); 1140 BUS_DMASYNC_PREWRITE);
1145 delay(UHCI_QH_REMOVE_DELAY); 1141 delay(UHCI_QH_REMOVE_DELAY);
1146 if (sc->sc_hctl_end == sqh) 1142 if (sc->sc_hctl_end == sqh)
1147 sc->sc_hctl_end = pqh; 1143 sc->sc_hctl_end = pqh;
1148} 1144}
1149 1145
1150/* Add low speed control QH, called at splusb(). */ 1146/* Add low speed control QH, called at splusb(). */
1151void 1147void
1152uhci_add_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1148uhci_add_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1153{ 1149{
1154 uhci_soft_qh_t *eqh; 1150 uhci_soft_qh_t *eqh;
1155 1151
1156 SPLUSBCHECK; 
1157 
1158 DPRINTFN(10, ("uhci_add_ls_ctrl: sqh=%p\n", sqh)); 1152 DPRINTFN(10, ("uhci_add_ls_ctrl: sqh=%p\n", sqh));
1159 eqh = sc->sc_lctl_end; 1153 eqh = sc->sc_lctl_end;
1160 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1154 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1161 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_POSTWRITE); 1155 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_POSTWRITE);
1162 sqh->hlink = eqh->hlink; 1156 sqh->hlink = eqh->hlink;
1163 sqh->qh.qh_hlink = eqh->qh.qh_hlink; 1157 sqh->qh.qh_hlink = eqh->qh.qh_hlink;
1164 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh), 1158 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh),
1165 BUS_DMASYNC_PREWRITE); 1159 BUS_DMASYNC_PREWRITE);
1166 eqh->hlink = sqh; 1160 eqh->hlink = sqh;
1167 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); 1161 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
1168 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1162 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1169 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE); 1163 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE);
1170 sc->sc_lctl_end = sqh; 1164 sc->sc_lctl_end = sqh;
1171} 1165}
1172 1166
1173/* Remove low speed control QH, called at splusb(). */ 1167/* Remove low speed control QH, called at splusb(). */
1174void 1168void
1175uhci_remove_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1169uhci_remove_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1176{ 1170{
1177 uhci_soft_qh_t *pqh; 1171 uhci_soft_qh_t *pqh;
1178 1172
1179 SPLUSBCHECK; 
1180 
1181 DPRINTFN(10, ("uhci_remove_ls_ctrl: sqh=%p\n", sqh)); 1173 DPRINTFN(10, ("uhci_remove_ls_ctrl: sqh=%p\n", sqh));
1182 /* See comment in uhci_remove_hs_ctrl() */ 1174 /* See comment in uhci_remove_hs_ctrl() */
1183 usb_syncmem(&sqh->dma, sqh->offs + offsetof(uhci_qh_t, qh_elink), 1175 usb_syncmem(&sqh->dma, sqh->offs + offsetof(uhci_qh_t, qh_elink),
1184 sizeof(sqh->qh.qh_elink), 1176 sizeof(sqh->qh.qh_elink),
1185 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); 1177 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
1186 if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) { 1178 if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
1187 sqh->qh.qh_elink = htole32(UHCI_PTR_T); 1179 sqh->qh.qh_elink = htole32(UHCI_PTR_T);
1188 usb_syncmem(&sqh->dma, 1180 usb_syncmem(&sqh->dma,
1189 sqh->offs + offsetof(uhci_qh_t, qh_elink), 1181 sqh->offs + offsetof(uhci_qh_t, qh_elink),
1190 sizeof(sqh->qh.qh_elink), 1182 sizeof(sqh->qh.qh_elink),
1191 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1183 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
1192 delay(UHCI_QH_REMOVE_DELAY); 1184 delay(UHCI_QH_REMOVE_DELAY);
1193 } 1185 }
@@ -1200,52 +1192,48 @@ uhci_remove_ls_ctrl(uhci_softc_t *sc, uh @@ -1200,52 +1192,48 @@ uhci_remove_ls_ctrl(uhci_softc_t *sc, uh
1200 sizeof(pqh->qh.qh_hlink), 1192 sizeof(pqh->qh.qh_hlink),
1201 BUS_DMASYNC_PREWRITE); 1193 BUS_DMASYNC_PREWRITE);
1202 delay(UHCI_QH_REMOVE_DELAY); 1194 delay(UHCI_QH_REMOVE_DELAY);
1203 if (sc->sc_lctl_end == sqh) 1195 if (sc->sc_lctl_end == sqh)
1204 sc->sc_lctl_end = pqh; 1196 sc->sc_lctl_end = pqh;
1205} 1197}
1206 1198
1207/* Add bulk QH, called at splusb(). */ 1199/* Add bulk QH, called at splusb(). */
1208void 1200void
1209uhci_add_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1201uhci_add_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1210{ 1202{
1211 uhci_soft_qh_t *eqh; 1203 uhci_soft_qh_t *eqh;
1212 1204
1213 SPLUSBCHECK; 
1214 
1215 DPRINTFN(10, ("uhci_add_bulk: sqh=%p\n", sqh)); 1205 DPRINTFN(10, ("uhci_add_bulk: sqh=%p\n", sqh));
1216 eqh = sc->sc_bulk_end; 1206 eqh = sc->sc_bulk_end;
1217 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1207 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1218 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_POSTWRITE); 1208 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_POSTWRITE);
1219 sqh->hlink = eqh->hlink; 1209 sqh->hlink = eqh->hlink;
1220 sqh->qh.qh_hlink = eqh->qh.qh_hlink; 1210 sqh->qh.qh_hlink = eqh->qh.qh_hlink;
1221 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh), 1211 usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh),
1222 BUS_DMASYNC_PREWRITE); 1212 BUS_DMASYNC_PREWRITE);
1223 eqh->hlink = sqh; 1213 eqh->hlink = sqh;
1224 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); 1214 eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
1225 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink), 1215 usb_syncmem(&eqh->dma, eqh->offs + offsetof(uhci_qh_t, qh_hlink),
1226 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE); 1216 sizeof(eqh->qh.qh_hlink), BUS_DMASYNC_PREWRITE);
1227 sc->sc_bulk_end = sqh; 1217 sc->sc_bulk_end = sqh;
1228 uhci_add_loop(sc); 1218 uhci_add_loop(sc);
1229} 1219}
1230 1220
1231/* Remove bulk QH, called at splusb(). */ 1221/* Remove bulk QH, called at splusb(). */
1232void 1222void
1233uhci_remove_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh) 1223uhci_remove_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
1234{ 1224{
1235 uhci_soft_qh_t *pqh; 1225 uhci_soft_qh_t *pqh;
1236 1226
1237 SPLUSBCHECK; 
1238 
1239 DPRINTFN(10, ("uhci_remove_bulk: sqh=%p\n", sqh)); 1227 DPRINTFN(10, ("uhci_remove_bulk: sqh=%p\n", sqh));
1240 uhci_rem_loop(sc); 1228 uhci_rem_loop(sc);
1241 /* See comment in uhci_remove_hs_ctrl() */ 1229 /* See comment in uhci_remove_hs_ctrl() */
1242 usb_syncmem(&sqh->dma, sqh->offs + offsetof(uhci_qh_t, qh_elink), 1230 usb_syncmem(&sqh->dma, sqh->offs + offsetof(uhci_qh_t, qh_elink),
1243 sizeof(sqh->qh.qh_elink), 1231 sizeof(sqh->qh.qh_elink),
1244 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); 1232 BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
1245 if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) { 1233 if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
1246 sqh->qh.qh_elink = htole32(UHCI_PTR_T); 1234 sqh->qh.qh_elink = htole32(UHCI_PTR_T);
1247 usb_syncmem(&sqh->dma, 1235 usb_syncmem(&sqh->dma,
1248 sqh->offs + offsetof(uhci_qh_t, qh_elink), 1236 sqh->offs + offsetof(uhci_qh_t, qh_elink),
1249 sizeof(sqh->qh.qh_elink), 1237 sizeof(sqh->qh.qh_elink),
1250 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1238 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
1251 delay(UHCI_QH_REMOVE_DELAY); 1239 delay(UHCI_QH_REMOVE_DELAY);

cvs diff -r1.134 -r1.135 src/sys/dev/usb/usbdi.c (expand / switch to unified diff)

--- src/sys/dev/usb/usbdi.c 2011/11/27 03:25:00 1.134
+++ src/sys/dev/usb/usbdi.c 2012/03/06 02:36:46 1.135
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbdi.c,v 1.134 2011/11/27 03:25:00 jmcneill Exp $ */ 1/* $NetBSD: usbdi.c,v 1.135 2012/03/06 02:36:46 mrg Exp $ */
2/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134 2011/11/27 03:25:00 jmcneill Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.135 2012/03/06 02:36:46 mrg Exp $");
36 36
37#include "opt_compat_netbsd.h" 37#include "opt_compat_netbsd.h"
38#include "opt_usb.h" 38#include "opt_usb.h"
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/kernel.h> 42#include <sys/kernel.h>
43#include <sys/device.h> 43#include <sys/device.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46 46
47#include <sys/bus.h> 47#include <sys/bus.h>
48 48
@@ -711,28 +711,26 @@ usbd_get_interface(usbd_interface_handle @@ -711,28 +711,26 @@ usbd_get_interface(usbd_interface_handle
711 USETW(req.wIndex, iface->idesc->bInterfaceNumber); 711 USETW(req.wIndex, iface->idesc->bInterfaceNumber);
712 USETW(req.wLength, 1); 712 USETW(req.wLength, 1);
713 return (usbd_do_request(iface->device, &req, aiface)); 713 return (usbd_do_request(iface->device, &req, aiface));
714} 714}
715 715
716/*** Internal routines ***/ 716/*** Internal routines ***/
717 717
718/* Dequeue all pipe operations, called at splusb(). */ 718/* Dequeue all pipe operations, called at splusb(). */
719Static usbd_status 719Static usbd_status
720usbd_ar_pipe(usbd_pipe_handle pipe) 720usbd_ar_pipe(usbd_pipe_handle pipe)
721{ 721{
722 usbd_xfer_handle xfer; 722 usbd_xfer_handle xfer;
723 723
724 SPLUSBCHECK; 
725 
726 DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe)); 724 DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe));
727#ifdef USB_DEBUG 725#ifdef USB_DEBUG
728 if (usbdebug > 5) 726 if (usbdebug > 5)
729 usbd_dump_queue(pipe); 727 usbd_dump_queue(pipe);
730#endif 728#endif
731 pipe->repeat = 0; 729 pipe->repeat = 0;
732 pipe->aborting = 1; 730 pipe->aborting = 1;
733 while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) { 731 while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) {
734 DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n", 732 DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n",
735 pipe, xfer, pipe->methods)); 733 pipe, xfer, pipe->methods));
736 /* Make the HC abort it (and invoke the callback). */ 734 /* Make the HC abort it (and invoke the callback). */
737 pipe->methods->abort(xfer); 735 pipe->methods->abort(xfer);
738 /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */ 736 /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
@@ -742,28 +740,26 @@ usbd_ar_pipe(usbd_pipe_handle pipe) @@ -742,28 +740,26 @@ usbd_ar_pipe(usbd_pipe_handle pipe)
742} 740}
743 741
744/* Called at splusb() */ 742/* Called at splusb() */
745void 743void
746usb_transfer_complete(usbd_xfer_handle xfer) 744usb_transfer_complete(usbd_xfer_handle xfer)
747{ 745{
748 usbd_pipe_handle pipe = xfer->pipe; 746 usbd_pipe_handle pipe = xfer->pipe;
749 usb_dma_t *dmap = &xfer->dmabuf; 747 usb_dma_t *dmap = &xfer->dmabuf;
750 int sync = xfer->flags & USBD_SYNCHRONOUS; 748 int sync = xfer->flags & USBD_SYNCHRONOUS;
751 int erred = xfer->status == USBD_CANCELLED || 749 int erred = xfer->status == USBD_CANCELLED ||
752 xfer->status == USBD_TIMEOUT; 750 xfer->status == USBD_TIMEOUT;
753 int repeat, polling; 751 int repeat, polling;
754 752
755 SPLUSBCHECK; 
756 
757 DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d " 753 DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
758 "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen)); 754 "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
759 755
760 KASSERT(KERNEL_LOCKED_P()); 756 KASSERT(KERNEL_LOCKED_P());
761 757
762#ifdef DIAGNOSTIC 758#ifdef DIAGNOSTIC
763 if (xfer->busy_free != XFER_ONQU) { 759 if (xfer->busy_free != XFER_ONQU) {
764 printf("usb_transfer_complete: xfer=%p not busy 0x%08x\n", 760 printf("usb_transfer_complete: xfer=%p not busy 0x%08x\n",
765 xfer, xfer->busy_free); 761 xfer, xfer->busy_free);
766 } 762 }
767#endif 763#endif
768 764
769#ifdef DIAGNOSTIC 765#ifdef DIAGNOSTIC
@@ -875,28 +871,26 @@ usb_insert_transfer(usbd_xfer_handle xfe @@ -875,28 +871,26 @@ usb_insert_transfer(usbd_xfer_handle xfe
875 err = USBD_NORMAL_COMPLETION; 871 err = USBD_NORMAL_COMPLETION;
876 } 872 }
877 splx(s); 873 splx(s);
878 return (err); 874 return (err);
879} 875}
880 876
881/* Called at splusb() */ 877/* Called at splusb() */
882void 878void
883usbd_start_next(usbd_pipe_handle pipe) 879usbd_start_next(usbd_pipe_handle pipe)
884{ 880{
885 usbd_xfer_handle xfer; 881 usbd_xfer_handle xfer;
886 usbd_status err; 882 usbd_status err;
887 883
888 SPLUSBCHECK; 
889 
890#ifdef DIAGNOSTIC 884#ifdef DIAGNOSTIC
891 if (pipe == NULL) { 885 if (pipe == NULL) {
892 printf("usbd_start_next: pipe == NULL\n"); 886 printf("usbd_start_next: pipe == NULL\n");
893 return; 887 return;
894 } 888 }
895 if (pipe->methods == NULL || pipe->methods->start == NULL) { 889 if (pipe->methods == NULL || pipe->methods->start == NULL) {
896 printf("usbd_start_next: pipe=%p no start method\n", pipe); 890 printf("usbd_start_next: pipe=%p no start method\n", pipe);
897 return; 891 return;
898 } 892 }
899#endif 893#endif
900 894
901 /* Get next request in queue. */ 895 /* Get next request in queue. */
902 xfer = SIMPLEQ_FIRST(&pipe->queue); 896 xfer = SIMPLEQ_FIRST(&pipe->queue);

cvs diff -r1.93 -r1.94 src/sys/dev/usb/usbdivar.h (expand / switch to unified diff)

--- src/sys/dev/usb/usbdivar.h 2011/05/27 17:19:18 1.93
+++ src/sys/dev/usb/usbdivar.h 2012/03/06 02:36:46 1.94
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbdivar.h,v 1.93 2011/05/27 17:19:18 drochner Exp $ */ 1/* $NetBSD: usbdivar.h,v 1.94 2012/03/06 02:36:46 mrg Exp $ */
2/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at 9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology. 10 * Carlstedt Research & Technology.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -248,27 +248,13 @@ usbd_status usbd_reattach_device(device_ @@ -248,27 +248,13 @@ usbd_status usbd_reattach_device(device_
248void usbd_remove_device(usbd_device_handle, struct usbd_port *); 248void usbd_remove_device(usbd_device_handle, struct usbd_port *);
249int usbd_printBCD(char *, size_t, int); 249int usbd_printBCD(char *, size_t, int);
250usbd_status usbd_fill_iface_data(usbd_device_handle, int, int); 250usbd_status usbd_fill_iface_data(usbd_device_handle, int, int);
251void usb_free_device(usbd_device_handle); 251void usb_free_device(usbd_device_handle);
252 252
253usbd_status usb_insert_transfer(usbd_xfer_handle); 253usbd_status usb_insert_transfer(usbd_xfer_handle);
254void usb_transfer_complete(usbd_xfer_handle); 254void usb_transfer_complete(usbd_xfer_handle);
255int usb_disconnect_port(struct usbd_port *, device_t, int); 255int usb_disconnect_port(struct usbd_port *, device_t, int);
256 256
257/* Routines from usb.c */ 257/* Routines from usb.c */
258void usb_needs_explore(usbd_device_handle); 258void usb_needs_explore(usbd_device_handle);
259void usb_needs_reattach(usbd_device_handle); 259void usb_needs_reattach(usbd_device_handle);
260void usb_schedsoftintr(struct usbd_bus *); 260void usb_schedsoftintr(struct usbd_bus *);
261 
262/* 
263 * XXX This check is extremely bogus. Bad Bad Bad. 
264 */ 
265#if defined(DIAGNOSTIC) && 0 
266#define SPLUSBCHECK \ 
267 do { int _s = splusb(), _su = splusb(); \ 
268 if (!cold && _s != _su) printf("SPLUSBCHECK failed 0x%x!=0x%x, %s:%d\n", \ 
269 _s, _su, __FILE__, __LINE__); \ 
270 splx(_s); \ 
271 } while (0) 
272#else 
273#define SPLUSBCHECK 
274#endif