aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/pktcdvd.c82
-rw-r--r--drivers/char/agp/Kconfig55
-rw-r--r--drivers/char/agp/amd64-agp.c6
-rw-r--r--drivers/char/agp/sworks-agp.c4
-rw-r--r--drivers/char/drm/i915_irq.c5
-rw-r--r--drivers/char/drm/r300_cmdbuf.c48
-rw-r--r--drivers/char/drm/r300_reg.h3
-rw-r--r--drivers/char/drm/radeon_drv.h3
-rw-r--r--drivers/char/sysrq.c2
-rw-r--r--drivers/crypto/padlock-aes.c8
-rw-r--r--drivers/fc4/fc.c2
-rw-r--r--drivers/ieee1394/sbp2.c126
-rw-r--r--drivers/ieee1394/sbp2.h64
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c14
-rw-r--r--drivers/net/irda/irda-usb.c90
-rw-r--r--drivers/net/irda/irda-usb.h7
-rw-r--r--drivers/net/r8169.c189
-rw-r--r--drivers/net/skge.c75
-rw-r--r--drivers/net/skge.h1
-rw-r--r--drivers/net/sky2.c173
-rw-r--r--drivers/net/sky2.h83
-rw-r--r--drivers/net/wireless/ipw2200.c6
-rw-r--r--drivers/s390/block/Kconfig14
-rw-r--r--drivers/s390/block/Makefile2
-rw-r--r--drivers/s390/block/dasd.c97
-rw-r--r--drivers/s390/block/dasd_3990_erp.c3
-rw-r--r--drivers/s390/block/dasd_eckd.h1
-rw-r--r--drivers/s390/block/dasd_eer.c1090
-rw-r--r--drivers/s390/block/dasd_int.h38
-rw-r--r--drivers/s390/cio/qdio.c13
-rw-r--r--drivers/scsi/esp.c4
-rw-r--r--drivers/scsi/libata-core.c15
-rw-r--r--drivers/scsi/sata_qstor.c2
-rw-r--r--drivers/spi/spi.c5
-rw-r--r--drivers/video/aty/radeon_pm.c19
35 files changed, 730 insertions, 1619 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 93e44d0292ab..bc9b2bcd7dba 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -58,6 +58,7 @@
58#include <linux/suspend.h> 58#include <linux/suspend.h>
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 60#include <scsi/scsi_ioctl.h>
61#include <scsi/scsi.h>
61 62
62#include <asm/uaccess.h> 63#include <asm/uaccess.h>
63 64
@@ -380,6 +381,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
380 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); 381 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE);
381 if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) 382 if (sizeof(rq->cmd) > CDROM_PACKET_SIZE)
382 memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); 383 memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE);
384 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
383 385
384 rq->ref_count++; 386 rq->ref_count++;
385 rq->flags |= REQ_NOMERGE; 387 rq->flags |= REQ_NOMERGE;
@@ -1495,40 +1497,42 @@ static int pkt_set_write_settings(struct pktcdvd_device *pd)
1495} 1497}
1496 1498
1497/* 1499/*
1498 * 0 -- we can write to this track, 1 -- we can't 1500 * 1 -- we can write to this track, 0 -- we can't
1499 */ 1501 */
1500static int pkt_good_track(track_information *ti) 1502static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti)
1501{ 1503{
1502 /* 1504 switch (pd->mmc3_profile) {
1503 * only good for CD-RW at the moment, not DVD-RW 1505 case 0x1a: /* DVD+RW */
1504 */ 1506 case 0x12: /* DVD-RAM */
1507 /* The track is always writable on DVD+RW/DVD-RAM */
1508 return 1;
1509 default:
1510 break;
1511 }
1505 1512
1506 /* 1513 if (!ti->packet || !ti->fp)
1507 * FIXME: only for FP
1508 */
1509 if (ti->fp == 0)
1510 return 0; 1514 return 0;
1511 1515
1512 /* 1516 /*
1513 * "good" settings as per Mt Fuji. 1517 * "good" settings as per Mt Fuji.
1514 */ 1518 */
1515 if (ti->rt == 0 && ti->blank == 0 && ti->packet == 1) 1519 if (ti->rt == 0 && ti->blank == 0)
1516 return 0; 1520 return 1;
1517 1521
1518 if (ti->rt == 0 && ti->blank == 1 && ti->packet == 1) 1522 if (ti->rt == 0 && ti->blank == 1)
1519 return 0; 1523 return 1;
1520 1524
1521 if (ti->rt == 1 && ti->blank == 0 && ti->packet == 1) 1525 if (ti->rt == 1 && ti->blank == 0)
1522 return 0; 1526 return 1;
1523 1527
1524 printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); 1528 printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet);
1525 return 1; 1529 return 0;
1526} 1530}
1527 1531
1528/* 1532/*
1529 * 0 -- we can write to this disc, 1 -- we can't 1533 * 1 -- we can write to this disc, 0 -- we can't
1530 */ 1534 */
1531static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di) 1535static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di)
1532{ 1536{
1533 switch (pd->mmc3_profile) { 1537 switch (pd->mmc3_profile) {
1534 case 0x0a: /* CD-RW */ 1538 case 0x0a: /* CD-RW */
@@ -1537,10 +1541,10 @@ static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
1537 case 0x1a: /* DVD+RW */ 1541 case 0x1a: /* DVD+RW */
1538 case 0x13: /* DVD-RW */ 1542 case 0x13: /* DVD-RW */
1539 case 0x12: /* DVD-RAM */ 1543 case 0x12: /* DVD-RAM */
1540 return 0; 1544 return 1;
1541 default: 1545 default:
1542 VPRINTK("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile); 1546 VPRINTK("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile);
1543 return 1; 1547 return 0;
1544 } 1548 }
1545 1549
1546 /* 1550 /*
@@ -1549,25 +1553,25 @@ static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
1549 */ 1553 */
1550 if (di->disc_type == 0xff) { 1554 if (di->disc_type == 0xff) {
1551 printk("pktcdvd: Unknown disc. No track?\n"); 1555 printk("pktcdvd: Unknown disc. No track?\n");
1552 return 1; 1556 return 0;
1553 } 1557 }
1554 1558
1555 if (di->disc_type != 0x20 && di->disc_type != 0) { 1559 if (di->disc_type != 0x20 && di->disc_type != 0) {
1556 printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type); 1560 printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type);
1557 return 1; 1561 return 0;
1558 } 1562 }
1559 1563
1560 if (di->erasable == 0) { 1564 if (di->erasable == 0) {
1561 printk("pktcdvd: Disc not erasable\n"); 1565 printk("pktcdvd: Disc not erasable\n");
1562 return 1; 1566 return 0;
1563 } 1567 }
1564 1568
1565 if (di->border_status == PACKET_SESSION_RESERVED) { 1569 if (di->border_status == PACKET_SESSION_RESERVED) {
1566 printk("pktcdvd: Can't write to last track (reserved)\n"); 1570 printk("pktcdvd: Can't write to last track (reserved)\n");
1567 return 1; 1571 return 0;
1568 } 1572 }
1569 1573
1570 return 0; 1574 return 1;
1571} 1575}
1572 1576
1573static int pkt_probe_settings(struct pktcdvd_device *pd) 1577static int pkt_probe_settings(struct pktcdvd_device *pd)
@@ -1592,23 +1596,9 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1592 return ret; 1596 return ret;
1593 } 1597 }
1594 1598
1595 if (pkt_good_disc(pd, &di)) 1599 if (!pkt_writable_disc(pd, &di))
1596 return -ENXIO; 1600 return -EROFS;
1597 1601
1598 switch (pd->mmc3_profile) {
1599 case 0x1a: /* DVD+RW */
1600 printk("pktcdvd: inserted media is DVD+RW\n");
1601 break;
1602 case 0x13: /* DVD-RW */
1603 printk("pktcdvd: inserted media is DVD-RW\n");
1604 break;
1605 case 0x12: /* DVD-RAM */
1606 printk("pktcdvd: inserted media is DVD-RAM\n");
1607 break;
1608 default:
1609 printk("pktcdvd: inserted media is CD-R%s\n", di.erasable ? "W" : "");
1610 break;
1611 }
1612 pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR; 1602 pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR;
1613 1603
1614 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ 1604 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */
@@ -1617,9 +1607,9 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1617 return ret; 1607 return ret;
1618 } 1608 }
1619 1609
1620 if (pkt_good_track(&ti)) { 1610 if (!pkt_writable_track(pd, &ti)) {
1621 printk("pktcdvd: can't write to this track\n"); 1611 printk("pktcdvd: can't write to this track\n");
1622 return -ENXIO; 1612 return -EROFS;
1623 } 1613 }
1624 1614
1625 /* 1615 /*
@@ -1633,7 +1623,7 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1633 } 1623 }
1634 if (pd->settings.size > PACKET_MAX_SECTORS) { 1624 if (pd->settings.size > PACKET_MAX_SECTORS) {
1635 printk("pktcdvd: packet size is too big\n"); 1625 printk("pktcdvd: packet size is too big\n");
1636 return -ENXIO; 1626 return -EROFS;
1637 } 1627 }
1638 pd->settings.fp = ti.fp; 1628 pd->settings.fp = ti.fp;
1639 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1); 1629 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
@@ -1675,7 +1665,7 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1675 break; 1665 break;
1676 default: 1666 default:
1677 printk("pktcdvd: unknown data mode\n"); 1667 printk("pktcdvd: unknown data mode\n");
1678 return 1; 1668 return -EROFS;
1679 } 1669 }
1680 return 0; 1670 return 0;
1681} 1671}
@@ -1886,7 +1876,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
1886 1876
1887 if ((ret = pkt_probe_settings(pd))) { 1877 if ((ret = pkt_probe_settings(pd))) {
1888 VPRINTK("pktcdvd: %s failed probe\n", pd->name); 1878 VPRINTK("pktcdvd: %s failed probe\n", pd->name);
1889 return -EROFS; 1879 return ret;
1890 } 1880 }
1891 1881
1892 if ((ret = pkt_set_write_settings(pd))) { 1882 if ((ret = pkt_set_write_settings(pd))) {
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 486ed8a11b59..a4d425d2dce2 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -15,22 +15,23 @@ config AGP
15 due to kernel allocation issues), you could use PCI accesses 15 due to kernel allocation issues), you could use PCI accesses
16 and have up to a couple gigs of texture space. 16 and have up to a couple gigs of texture space.
17 17
18 Note that this is the only means to have XFree4/GLX use 18 Note that this is the only means to have X/GLX use
19 write-combining with MTRR support on the AGP bus. Without it, OpenGL 19 write-combining with MTRR support on the AGP bus. Without it, OpenGL
20 direct rendering will be a lot slower but still faster than PIO. 20 direct rendering will be a lot slower but still faster than PIO.
21 21
22 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
23 use GLX or DRI. If unsure, say N.
24
25 To compile this driver as a module, choose M here: the 22 To compile this driver as a module, choose M here: the
26 module will be called agpgart. 23 module will be called agpgart.
27 24
25 You should say Y here if you want to use GLX or DRI.
26
27 If unsure, say N.
28
28config AGP_ALI 29config AGP_ALI
29 tristate "ALI chipset support" 30 tristate "ALI chipset support"
30 depends on AGP && X86_32 31 depends on AGP && X86_32
31 ---help--- 32 ---help---
32 This option gives you AGP support for the GLX component of 33 This option gives you AGP support for the GLX component of
33 XFree86 4.x on the following ALi chipsets. The supported chipsets 34 X on the following ALi chipsets. The supported chipsets
34 include M1541, M1621, M1631, M1632, M1641,M1647,and M1651. 35 include M1541, M1621, M1631, M1632, M1641,M1647,and M1651.
35 For the ALi-chipset question, ALi suggests you refer to 36 For the ALi-chipset question, ALi suggests you refer to
36 <http://www.ali.com.tw/eng/support/index.shtml>. 37 <http://www.ali.com.tw/eng/support/index.shtml>.
@@ -40,28 +41,19 @@ config AGP_ALI
40 timing issues, this chipset cannot do AGP 2x with the G200. 41 timing issues, this chipset cannot do AGP 2x with the G200.
41 This is a hardware limitation. AGP 1x seems to be fine, though. 42 This is a hardware limitation. AGP 1x seems to be fine, though.
42 43
43 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
44 use GLX or DRI. If unsure, say N.
45
46config AGP_ATI 44config AGP_ATI
47 tristate "ATI chipset support" 45 tristate "ATI chipset support"
48 depends on AGP && X86_32 46 depends on AGP && X86_32
49 ---help--- 47 ---help---
50 This option gives you AGP support for the GLX component of 48 This option gives you AGP support for the GLX component of
51 XFree86 4.x on the ATI RadeonIGP family of chipsets. 49 X on the ATI RadeonIGP family of chipsets.
52
53 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
54 use GLX or DRI. If unsure, say N.
55 50
56config AGP_AMD 51config AGP_AMD
57 tristate "AMD Irongate, 761, and 762 chipset support" 52 tristate "AMD Irongate, 761, and 762 chipset support"
58 depends on AGP && X86_32 53 depends on AGP && X86_32
59 help 54 help
60 This option gives you AGP support for the GLX component of 55 This option gives you AGP support for the GLX component of
61 XFree86 4.x on AMD Irongate, 761, and 762 chipsets. 56 X on AMD Irongate, 761, and 762 chipsets.
62
63 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
64 use GLX or DRI. If unsure, say N.
65 57
66config AGP_AMD64 58config AGP_AMD64
67 tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU 59 tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU
@@ -69,45 +61,38 @@ config AGP_AMD64
69 default y if GART_IOMMU 61 default y if GART_IOMMU
70 help 62 help
71 This option gives you AGP support for the GLX component of 63 This option gives you AGP support for the GLX component of
72 XFree86 4.x using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. 64 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
73 You still need an external AGP bridge like the AMD 8151, VIA 65 You still need an external AGP bridge like the AMD 8151, VIA
74 K8T400M, SiS755. It may also support other AGP bridges when loaded 66 K8T400M, SiS755. It may also support other AGP bridges when loaded
75 with agp_try_unsupported=1. 67 with agp_try_unsupported=1.
76 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
77 use GLX or DRI. If unsure, say Y
78 68
79config AGP_INTEL 69config AGP_INTEL
80 tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support" 70 tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support"
81 depends on AGP && X86 71 depends on AGP && X86
82 help 72 help
83 This option gives you AGP support for the GLX component of XFree86 4.x 73 This option gives you AGP support for the GLX component of X
84 on Intel 440LX/BX/GX, 815, 820, 830, 840, 845, 850, 860, 875, 74 on Intel 440LX/BX/GX, 815, 820, 830, 840, 845, 850, 860, 875,
85 E7205 and E7505 chipsets and full support for the 810, 815, 830M, 845G, 75 E7205 and E7505 chipsets and full support for the 810, 815, 830M,
86 852GM, 855GM, 865G and I915 integrated graphics chipsets. 76 845G, 852GM, 855GM, 865G and I915 integrated graphics chipsets.
77
87 78
88 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
89 use GLX or DRI, or if you have any Intel integrated graphics
90 chipsets. If unsure, say Y.
91 79
92config AGP_NVIDIA 80config AGP_NVIDIA
93 tristate "NVIDIA nForce/nForce2 chipset support" 81 tristate "NVIDIA nForce/nForce2 chipset support"
94 depends on AGP && X86_32 82 depends on AGP && X86_32
95 help 83 help
96 This option gives you AGP support for the GLX component of 84 This option gives you AGP support for the GLX component of
97 XFree86 4.x on the following NVIDIA chipsets. The supported chipsets 85 X on NVIDIA chipsets including nForce and nForce2
98 include nForce and nForce2
99 86
100config AGP_SIS 87config AGP_SIS
101 tristate "SiS chipset support" 88 tristate "SiS chipset support"
102 depends on AGP && X86_32 89 depends on AGP && X86_32
103 help 90 help
104 This option gives you AGP support for the GLX component of 91 This option gives you AGP support for the GLX component of
105 XFree86 4.x on Silicon Integrated Systems [SiS] chipsets. 92 X on Silicon Integrated Systems [SiS] chipsets.
106 93
107 Note that 5591/5592 AGP chipsets are NOT supported. 94 Note that 5591/5592 AGP chipsets are NOT supported.
108 95
109 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
110 use GLX or DRI. If unsure, say N.
111 96
112config AGP_SWORKS 97config AGP_SWORKS
113 tristate "Serverworks LE/HE chipset support" 98 tristate "Serverworks LE/HE chipset support"
@@ -121,10 +106,7 @@ config AGP_VIA
121 depends on AGP && X86_32 106 depends on AGP && X86_32
122 help 107 help
123 This option gives you AGP support for the GLX component of 108 This option gives you AGP support for the GLX component of
124 XFree86 4.x on VIA MVP3/Apollo Pro chipsets. 109 X on VIA MVP3/Apollo Pro chipsets.
125
126 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
127 use GLX or DRI. If unsure, say N.
128 110
129config AGP_I460 111config AGP_I460
130 tristate "Intel 460GX chipset support" 112 tristate "Intel 460GX chipset support"
@@ -159,9 +141,6 @@ config AGP_EFFICEON
159 This option gives you AGP support for the Transmeta Efficeon 141 This option gives you AGP support for the Transmeta Efficeon
160 series processors with integrated northbridges. 142 series processors with integrated northbridges.
161 143
162 You should say Y here if you use XFree86 3.3.6 or 4.x and want to
163 use GLX or DRI. If unsure, say Y.
164
165config AGP_SGI_TIOCA 144config AGP_SGI_TIOCA
166 tristate "SGI TIO chipset AGP support" 145 tristate "SGI TIO chipset AGP support"
167 depends on AGP && (IA64_SGI_SN2 || IA64_GENERIC) 146 depends on AGP && (IA64_SGI_SN2 || IA64_GENERIC)
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 9964c508c111..1251b2515bbe 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -516,8 +516,10 @@ static int __devinit nforce3_agp_init(struct pci_dev *pdev)
516 pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &apbase); 516 pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &apbase);
517 517
518 /* if x86-64 aperture base is beyond 4G, exit here */ 518 /* if x86-64 aperture base is beyond 4G, exit here */
519 if ( (apbase & 0x7fff) >> (32 - 25) ) 519 if ( (apbase & 0x7fff) >> (32 - 25) ) {
520 return -ENODEV; 520 printk(KERN_INFO PFX "aperture base > 4G\n");
521 return -ENODEV;
522 }
521 523
522 apbase = (apbase & 0x7fff) << 25; 524 apbase = (apbase & 0x7fff) << 25;
523 525
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 268f78d926d3..efef9999f1cf 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -468,9 +468,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
468 468
469 switch (pdev->device) { 469 switch (pdev->device) {
470 case 0x0006: 470 case 0x0006:
471 /* ServerWorks CNB20HE 471 printk (KERN_ERR PFX "ServerWorks CNB20HE is unsupported due to lack of documentation.\n");
472 Fail silently.*/
473 printk (KERN_ERR PFX "Detected ServerWorks CNB20HE chipset: No AGP present.\n");
474 return -ENODEV; 472 return -ENODEV;
475 473
476 case PCI_DEVICE_ID_SERVERWORKS_HE: 474 case PCI_DEVICE_ID_SERVERWORKS_HE:
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index a1381c61aa63..d3879ac9970f 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -202,10 +202,15 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
202void i915_driver_irq_uninstall(drm_device_t * dev) 202void i915_driver_irq_uninstall(drm_device_t * dev)
203{ 203{
204 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 204 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
205 u16 temp;
206
205 if (!dev_priv) 207 if (!dev_priv)
206 return; 208 return;
207 209
208 I915_WRITE16(I915REG_HWSTAM, 0xffff); 210 I915_WRITE16(I915REG_HWSTAM, 0xffff);
209 I915_WRITE16(I915REG_INT_MASK_R, 0xffff); 211 I915_WRITE16(I915REG_INT_MASK_R, 0xffff);
210 I915_WRITE16(I915REG_INT_ENABLE_R, 0x0); 212 I915_WRITE16(I915REG_INT_ENABLE_R, 0x0);
213
214 temp = I915_READ16(I915REG_INT_IDENTITY_R);
215 I915_WRITE16(I915REG_INT_IDENTITY_R, temp);
211} 216}
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 291dbf4c8186..c08fa5076f05 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -161,6 +161,7 @@ void r300_init_reg_flags(void)
161 ADD_RANGE(R300_VAP_PVS_CNTL_1, 3); 161 ADD_RANGE(R300_VAP_PVS_CNTL_1, 3);
162 ADD_RANGE(R300_GB_ENABLE, 1); 162 ADD_RANGE(R300_GB_ENABLE, 1);
163 ADD_RANGE(R300_GB_MSPOS0, 5); 163 ADD_RANGE(R300_GB_MSPOS0, 5);
164 ADD_RANGE(R300_TX_CNTL, 1);
164 ADD_RANGE(R300_TX_ENABLE, 1); 165 ADD_RANGE(R300_TX_ENABLE, 1);
165 ADD_RANGE(0x4200, 4); 166 ADD_RANGE(0x4200, 4);
166 ADD_RANGE(0x4214, 1); 167 ADD_RANGE(0x4214, 1);
@@ -489,6 +490,50 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv,
489 490
490 return 0; 491 return 0;
491} 492}
493static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
494 drm_radeon_kcmd_buffer_t *cmdbuf)
495{
496 u32 *cmd = (u32 *) cmdbuf->buf;
497 int count, ret;
498 RING_LOCALS;
499
500 count=(cmd[0]>>16) & 0x3fff;
501
502 if (cmd[0] & 0x8000) {
503 u32 offset;
504
505 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL
506 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
507 offset = cmd[2] << 10;
508 ret = r300_check_offset(dev_priv, offset);
509 if (ret) {
510 DRM_ERROR("Invalid bitblt first offset is %08X\n", offset);
511 return DRM_ERR(EINVAL);
512 }
513 }
514
515 if ((cmd[1] & RADEON_GMC_SRC_PITCH_OFFSET_CNTL) &&
516 (cmd[1] & RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
517 offset = cmd[3] << 10;
518 ret = r300_check_offset(dev_priv, offset);
519 if (ret) {
520 DRM_ERROR("Invalid bitblt second offset is %08X\n", offset);
521 return DRM_ERR(EINVAL);
522 }
523
524 }
525 }
526
527 BEGIN_RING(count+2);
528 OUT_RING(cmd[0]);
529 OUT_RING_TABLE((int *)(cmdbuf->buf + 4), count + 1);
530 ADVANCE_RING();
531
532 cmdbuf->buf += (count+2)*4;
533 cmdbuf->bufsz -= (count+2)*4;
534
535 return 0;
536}
492 537
493static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, 538static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
494 drm_radeon_kcmd_buffer_t *cmdbuf) 539 drm_radeon_kcmd_buffer_t *cmdbuf)
@@ -527,6 +572,9 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
527 case RADEON_3D_LOAD_VBPNTR: /* load vertex array pointers */ 572 case RADEON_3D_LOAD_VBPNTR: /* load vertex array pointers */
528 return r300_emit_3d_load_vbpntr(dev_priv, cmdbuf, header); 573 return r300_emit_3d_load_vbpntr(dev_priv, cmdbuf, header);
529 574
575 case RADEON_CNTL_BITBLT_MULTI:
576 return r300_emit_bitblt_multi(dev_priv, cmdbuf);
577
530 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */ 578 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */
531 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */ 579 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */
532 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */ 580 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */
diff --git a/drivers/char/drm/r300_reg.h b/drivers/char/drm/r300_reg.h
index a0ed20e25221..d1e19954406b 100644
--- a/drivers/char/drm/r300_reg.h
+++ b/drivers/char/drm/r300_reg.h
@@ -451,6 +451,9 @@ I am fairly certain that they are correct unless stated otherwise in comments.
451/* END */ 451/* END */
452 452
453/* gap */ 453/* gap */
454/* Zero to flush caches. */
455#define R300_TX_CNTL 0x4100
456
454/* The upper enable bits are guessed, based on fglrx reported limits. */ 457/* The upper enable bits are guessed, based on fglrx reported limits. */
455#define R300_TX_ENABLE 0x4104 458#define R300_TX_ENABLE 0x4104
456# define R300_TX_ENABLE_0 (1 << 0) 459# define R300_TX_ENABLE_0 (1 << 0)
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 498b19b1d641..1f7d2ab8c4fc 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -90,9 +90,10 @@
90 * 1.19- Add support for gart table in FB memory and PCIE r300 90 * 1.19- Add support for gart table in FB memory and PCIE r300
91 * 1.20- Add support for r300 texrect 91 * 1.20- Add support for r300 texrect
92 * 1.21- Add support for card type getparam 92 * 1.21- Add support for card type getparam
93 * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
93 */ 94 */
94#define DRIVER_MAJOR 1 95#define DRIVER_MAJOR 1
95#define DRIVER_MINOR 21 96#define DRIVER_MINOR 22
96#define DRIVER_PATCHLEVEL 0 97#define DRIVER_PATCHLEVEL 0
97 98
98/* 99/*
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5765f672e853..d58f82318853 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -243,7 +243,7 @@ static struct sysrq_key_op sysrq_term_op = {
243 243
244static void moom_callback(void *ignored) 244static void moom_callback(void *ignored)
245{ 245{
246 out_of_memory(GFP_KERNEL, 0); 246 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], GFP_KERNEL, 0);
247} 247}
248 248
249static DECLARE_WORK(moom_work, moom_callback, NULL); 249static DECLARE_WORK(moom_work, moom_callback, NULL);
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 64819aa7cac4..0c08c58252be 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -348,10 +348,10 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t
348 break; 348 break;
349 349
350 case 32: 350 case 32:
351 E_KEY[4] = le32_to_cpu(in_key[4]); 351 E_KEY[4] = le32_to_cpu(key[4]);
352 E_KEY[5] = le32_to_cpu(in_key[5]); 352 E_KEY[5] = le32_to_cpu(key[5]);
353 E_KEY[6] = le32_to_cpu(in_key[6]); 353 E_KEY[6] = le32_to_cpu(key[6]);
354 t = E_KEY[7] = le32_to_cpu(in_key[7]); 354 t = E_KEY[7] = le32_to_cpu(key[7]);
355 for (i = 0; i < 7; ++i) 355 for (i = 0; i < 7; ++i)
356 loop8 (i); 356 loop8 (i);
357 break; 357 break;
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index 5c8943509cc1..66d03f242d3c 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -1053,7 +1053,7 @@ static int fc_do_els(fc_channel *fc, unsigned int alpa, void *data, int len)
1053 int i; 1053 int i;
1054 1054
1055 fcmd = &_fcmd; 1055 fcmd = &_fcmd;
1056 memset(fcmd, 0, sizeof(fcmd)); 1056 memset(fcmd, 0, sizeof(fcp_cmnd));
1057 FCD(("PLOGI SID %d DID %d\n", fc->sid, alpa)) 1057 FCD(("PLOGI SID %d DID %d\n", fc->sid, alpa))
1058 fch = &fcmd->fch; 1058 fch = &fcmd->fch;
1059 FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, alpa); 1059 FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, alpa);
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 18d7eda38851..eca92eb475a1 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -137,15 +137,15 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)"
137/* 137/*
138 * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on 138 * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on
139 * if your sbp2 device is not properly handling the SCSI inquiry command. 139 * if your sbp2 device is not properly handling the SCSI inquiry command.
140 * This hack makes the inquiry look more like a typical MS Windows 140 * This hack makes the inquiry look more like a typical MS Windows inquiry
141 * inquiry. 141 * by enforcing 36 byte inquiry and avoiding access to mode_sense page 8.
142 * 142 *
143 * If force_inquiry_hack=1 is required for your device to work, 143 * If force_inquiry_hack=1 is required for your device to work,
144 * please submit the logged sbp2_firmware_revision value of this device to 144 * please submit the logged sbp2_firmware_revision value of this device to
145 * the linux1394-devel mailing list. 145 * the linux1394-devel mailing list.
146 */ 146 */
147static int force_inquiry_hack; 147static int force_inquiry_hack;
148module_param(force_inquiry_hack, int, 0444); 148module_param(force_inquiry_hack, int, 0644);
149MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); 149MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)");
150 150
151/* 151/*
@@ -264,18 +264,17 @@ static struct hpsb_protocol_driver sbp2_driver = {
264 }, 264 },
265}; 265};
266 266
267 267/*
268/* List of device firmware's that require a forced 36 byte inquiry. */ 268 * List of device firmwares that require the inquiry hack.
269 * Yields a few false positives but did not break other devices so far.
270 */
269static u32 sbp2_broken_inquiry_list[] = { 271static u32 sbp2_broken_inquiry_list[] = {
270 0x00002800, /* Stefan Richter <richtest@bauwesen.tu-cottbus.de> */ 272 0x00002800, /* Stefan Richter <stefanr@s5r6.in-berlin.de> */
271 /* DViCO Momobay CX-1 */ 273 /* DViCO Momobay CX-1 */
272 0x00000200 /* Andreas Plesch <plesch@fas.harvard.edu> */ 274 0x00000200 /* Andreas Plesch <plesch@fas.harvard.edu> */
273 /* QPS Fire DVDBurner */ 275 /* QPS Fire DVDBurner */
274}; 276};
275 277
276#define NUM_BROKEN_INQUIRY_DEVS \
277 (sizeof(sbp2_broken_inquiry_list)/sizeof(*sbp2_broken_inquiry_list))
278
279/************************************** 278/**************************************
280 * General utility functions 279 * General utility functions
281 **************************************/ 280 **************************************/
@@ -643,9 +642,15 @@ static int sbp2_remove(struct device *dev)
643 if (!scsi_id) 642 if (!scsi_id)
644 return 0; 643 return 0;
645 644
646 /* Trigger shutdown functions in scsi's highlevel. */ 645 if (scsi_id->scsi_host) {
647 if (scsi_id->scsi_host) 646 /* Get rid of enqueued commands if there is no chance to
647 * send them. */
648 if (!sbp2util_node_is_available(scsi_id))
649 sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
650 /* scsi_remove_device() will trigger shutdown functions of SCSI
651 * highlevel drivers which would deadlock if blocked. */
648 scsi_unblock_requests(scsi_id->scsi_host); 652 scsi_unblock_requests(scsi_id->scsi_host);
653 }
649 sdev = scsi_id->sdev; 654 sdev = scsi_id->sdev;
650 if (sdev) { 655 if (sdev) {
651 scsi_id->sdev = NULL; 656 scsi_id->sdev = NULL;
@@ -742,11 +747,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
742 hi->host = ud->ne->host; 747 hi->host = ud->ne->host;
743 INIT_LIST_HEAD(&hi->scsi_ids); 748 INIT_LIST_HEAD(&hi->scsi_ids);
744 749
745 /* Register our sbp2 status address space... */
746 hpsb_register_addrspace(&sbp2_highlevel, ud->ne->host, &sbp2_ops,
747 SBP2_STATUS_FIFO_ADDRESS,
748 SBP2_STATUS_FIFO_ADDRESS +
749 SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(SBP2_MAX_UDS_PER_NODE+1));
750#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 750#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
751 /* Handle data movement if physical dma is not 751 /* Handle data movement if physical dma is not
752 * enabled/supportedon host controller */ 752 * enabled/supportedon host controller */
@@ -759,6 +759,18 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
759 759
760 list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids); 760 list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids);
761 761
762 /* Register the status FIFO address range. We could use the same FIFO
763 * for targets at different nodes. However we need different FIFOs per
764 * target in order to support multi-unit devices. */
765 scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace(
766 &sbp2_highlevel, ud->ne->host, &sbp2_ops,
767 sizeof(struct sbp2_status_block), sizeof(quadlet_t),
768 ~0ULL, ~0ULL);
769 if (!scsi_id->status_fifo_addr) {
770 SBP2_ERR("failed to allocate status FIFO address range");
771 goto failed_alloc;
772 }
773
762 /* Register our host with the SCSI stack. */ 774 /* Register our host with the SCSI stack. */
763 scsi_host = scsi_host_alloc(&scsi_driver_template, 775 scsi_host = scsi_host_alloc(&scsi_driver_template,
764 sizeof(unsigned long)); 776 sizeof(unsigned long));
@@ -997,6 +1009,10 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
997 SBP2_DMA_FREE("single query logins data"); 1009 SBP2_DMA_FREE("single query logins data");
998 } 1010 }
999 1011
1012 if (scsi_id->status_fifo_addr)
1013 hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
1014 scsi_id->status_fifo_addr);
1015
1000 scsi_id->ud->device.driver_data = NULL; 1016 scsi_id->ud->device.driver_data = NULL;
1001 1017
1002 SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id); 1018 SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id);
@@ -1075,11 +1091,10 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1075 ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response)); 1091 ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response));
1076 SBP2_DEBUG("sbp2_query_logins: reserved_resp_length initialized"); 1092 SBP2_DEBUG("sbp2_query_logins: reserved_resp_length initialized");
1077 1093
1078 scsi_id->query_logins_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + 1094 scsi_id->query_logins_orb->status_fifo_hi =
1079 SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); 1095 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1080 scsi_id->query_logins_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | 1096 scsi_id->query_logins_orb->status_fifo_lo =
1081 SBP2_STATUS_FIFO_ADDRESS_HI); 1097 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1082 SBP2_DEBUG("sbp2_query_logins: status FIFO initialized");
1083 1098
1084 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb)); 1099 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb));
1085 1100
@@ -1184,11 +1199,10 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1184 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response)); 1199 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response));
1185 SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized"); 1200 SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized");
1186 1201
1187 scsi_id->login_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + 1202 scsi_id->login_orb->status_fifo_hi =
1188 SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); 1203 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1189 scsi_id->login_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | 1204 scsi_id->login_orb->status_fifo_lo =
1190 SBP2_STATUS_FIFO_ADDRESS_HI); 1205 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1191 SBP2_DEBUG("sbp2_login_device: status FIFO initialized");
1192 1206
1193 /* 1207 /*
1194 * Byte swap ORB if necessary 1208 * Byte swap ORB if necessary
@@ -1301,10 +1315,10 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1301 scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1); 1315 scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
1302 1316
1303 scsi_id->logout_orb->reserved5 = 0x0; 1317 scsi_id->logout_orb->reserved5 = 0x0;
1304 scsi_id->logout_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + 1318 scsi_id->logout_orb->status_fifo_hi =
1305 SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); 1319 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1306 scsi_id->logout_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | 1320 scsi_id->logout_orb->status_fifo_lo =
1307 SBP2_STATUS_FIFO_ADDRESS_HI); 1321 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1308 1322
1309 /* 1323 /*
1310 * Byte swap ORB if necessary 1324 * Byte swap ORB if necessary
@@ -1366,10 +1380,10 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1366 scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1); 1380 scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
1367 1381
1368 scsi_id->reconnect_orb->reserved5 = 0x0; 1382 scsi_id->reconnect_orb->reserved5 = 0x0;
1369 scsi_id->reconnect_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + 1383 scsi_id->reconnect_orb->status_fifo_hi =
1370 SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); 1384 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1371 scsi_id->reconnect_orb->status_FIFO_hi = 1385 scsi_id->reconnect_orb->status_fifo_lo =
1372 (ORB_SET_NODE_ID(hi->host->node_id) | SBP2_STATUS_FIFO_ADDRESS_HI); 1386 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1373 1387
1374 /* 1388 /*
1375 * Byte swap ORB if necessary 1389 * Byte swap ORB if necessary
@@ -1560,7 +1574,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1560 /* Check for a blacklisted set of devices that require us to force 1574 /* Check for a blacklisted set of devices that require us to force
1561 * a 36 byte host inquiry. This can be overriden as a module param 1575 * a 36 byte host inquiry. This can be overriden as a module param
1562 * (to force all hosts). */ 1576 * (to force all hosts). */
1563 for (i = 0; i < NUM_BROKEN_INQUIRY_DEVS; i++) { 1577 for (i = 0; i < ARRAY_SIZE(sbp2_broken_inquiry_list); i++) {
1564 if ((firmware_revision & 0xffff00) == 1578 if ((firmware_revision & 0xffff00) ==
1565 sbp2_broken_inquiry_list[i]) { 1579 sbp2_broken_inquiry_list[i]) {
1566 SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround", 1580 SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround",
@@ -2007,18 +2021,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2007 } 2021 }
2008 2022
2009 /* 2023 /*
2010 * The scsi stack sends down a request_bufflen which does not match the
2011 * length field in the scsi cdb. This causes some sbp2 devices to
2012 * reject this inquiry command. Fix the request_bufflen.
2013 */
2014 if (*cmd == INQUIRY) {
2015 if (force_inquiry_hack || scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK)
2016 request_bufflen = cmd[4] = 0x24;
2017 else
2018 request_bufflen = cmd[4];
2019 }
2020
2021 /*
2022 * Now actually fill in the comamnd orb and sbp2 s/g list 2024 * Now actually fill in the comamnd orb and sbp2 s/g list
2023 */ 2025 */
2024 sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, 2026 sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg,
@@ -2082,9 +2084,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2082 2084
2083 SBP2_DEBUG("sbp2_check_sbp2_response"); 2085 SBP2_DEBUG("sbp2_check_sbp2_response");
2084 2086
2085 switch (SCpnt->cmnd[0]) { 2087 if (SCpnt->cmnd[0] == INQUIRY && (SCpnt->cmnd[1] & 3) == 0) {
2086
2087 case INQUIRY:
2088 /* 2088 /*
2089 * Make sure data length is ok. Minimum length is 36 bytes 2089 * Make sure data length is ok. Minimum length is 36 bytes
2090 */ 2090 */
@@ -2097,13 +2097,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2097 */ 2097 */
2098 scsi_buf[2] |= 2; 2098 scsi_buf[2] |= 2;
2099 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; 2099 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;
2100
2101 break;
2102
2103 default:
2104 break;
2105 } 2100 }
2106 return;
2107} 2101}
2108 2102
2109/* 2103/*
@@ -2114,7 +2108,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2114{ 2108{
2115 struct sbp2scsi_host_info *hi; 2109 struct sbp2scsi_host_info *hi;
2116 struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp; 2110 struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp;
2117 u32 id;
2118 struct scsi_cmnd *SCpnt = NULL; 2111 struct scsi_cmnd *SCpnt = NULL;
2119 u32 scsi_status = SBP2_SCSI_STATUS_GOOD; 2112 u32 scsi_status = SBP2_SCSI_STATUS_GOOD;
2120 struct sbp2_command_info *command; 2113 struct sbp2_command_info *command;
@@ -2137,12 +2130,12 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2137 } 2130 }
2138 2131
2139 /* 2132 /*
2140 * Find our scsi_id structure by looking at the status fifo address written to by 2133 * Find our scsi_id structure by looking at the status fifo address
2141 * the sbp2 device. 2134 * written to by the sbp2 device.
2142 */ 2135 */
2143 id = SBP2_STATUS_FIFO_OFFSET_TO_ENTRY((u32)(addr - SBP2_STATUS_FIFO_ADDRESS));
2144 list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) { 2136 list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) {
2145 if (scsi_id_tmp->ne->nodeid == nodeid && scsi_id_tmp->ud->id == id) { 2137 if (scsi_id_tmp->ne->nodeid == nodeid &&
2138 scsi_id_tmp->status_fifo_addr == addr) {
2146 scsi_id = scsi_id_tmp; 2139 scsi_id = scsi_id_tmp;
2147 break; 2140 break;
2148 } 2141 }
@@ -2483,7 +2476,16 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2483 2476
2484static int sbp2scsi_slave_alloc(struct scsi_device *sdev) 2477static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2485{ 2478{
2486 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; 2479 struct scsi_id_instance_data *scsi_id =
2480 (struct scsi_id_instance_data *)sdev->host->hostdata[0];
2481
2482 scsi_id->sdev = sdev;
2483
2484 if (force_inquiry_hack ||
2485 scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) {
2486 sdev->inquiry_len = 36;
2487 sdev->skip_ms_page_8 = 1;
2488 }
2487 return 0; 2489 return 0;
2488} 2490}
2489 2491
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index 900ea1d25e71..e2d357a9ea3a 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -33,15 +33,17 @@
33#define ORB_DIRECTION_NO_DATA_TRANSFER 0x2 33#define ORB_DIRECTION_NO_DATA_TRANSFER 0x2
34 34
35#define ORB_SET_NULL_PTR(value) ((value & 0x1) << 31) 35#define ORB_SET_NULL_PTR(value) ((value & 0x1) << 31)
36#define ORB_SET_NOTIFY(value) ((value & 0x1) << 31) 36#define ORB_SET_NOTIFY(value) ((value & 0x1) << 31)
37#define ORB_SET_RQ_FMT(value) ((value & 0x3) << 29) /* unused ? */ 37#define ORB_SET_RQ_FMT(value) ((value & 0x3) << 29) /* unused ? */
38#define ORB_SET_NODE_ID(value) ((value & 0xffff) << 16) 38#define ORB_SET_NODE_ID(value) ((value & 0xffff) << 16)
39#define ORB_SET_DATA_SIZE(value) (value & 0xffff) 39#define ORB_SET_STATUS_FIFO_HI(value, id) (value >> 32 | ORB_SET_NODE_ID(id))
40#define ORB_SET_PAGE_SIZE(value) ((value & 0x7) << 16) 40#define ORB_SET_STATUS_FIFO_LO(value) (value & 0xffffffff)
41#define ORB_SET_PAGE_TABLE_PRESENT(value) ((value & 0x1) << 19) 41#define ORB_SET_DATA_SIZE(value) (value & 0xffff)
42#define ORB_SET_MAX_PAYLOAD(value) ((value & 0xf) << 20) 42#define ORB_SET_PAGE_SIZE(value) ((value & 0x7) << 16)
43#define ORB_SET_SPEED(value) ((value & 0x7) << 24) 43#define ORB_SET_PAGE_TABLE_PRESENT(value) ((value & 0x1) << 19)
44#define ORB_SET_DIRECTION(value) ((value & 0x1) << 27) 44#define ORB_SET_MAX_PAYLOAD(value) ((value & 0xf) << 20)
45#define ORB_SET_SPEED(value) ((value & 0x7) << 24)
46#define ORB_SET_DIRECTION(value) ((value & 0x1) << 27)
45 47
46struct sbp2_command_orb { 48struct sbp2_command_orb {
47 volatile u32 next_ORB_hi; 49 volatile u32 next_ORB_hi;
@@ -76,8 +78,8 @@ struct sbp2_login_orb {
76 u32 login_response_lo; 78 u32 login_response_lo;
77 u32 lun_misc; 79 u32 lun_misc;
78 u32 passwd_resp_lengths; 80 u32 passwd_resp_lengths;
79 u32 status_FIFO_hi; 81 u32 status_fifo_hi;
80 u32 status_FIFO_lo; 82 u32 status_fifo_lo;
81}; 83};
82 84
83#define RESPONSE_GET_LOGIN_ID(value) (value & 0xffff) 85#define RESPONSE_GET_LOGIN_ID(value) (value & 0xffff)
@@ -102,8 +104,8 @@ struct sbp2_query_logins_orb {
102 u32 query_response_lo; 104 u32 query_response_lo;
103 u32 lun_misc; 105 u32 lun_misc;
104 u32 reserved_resp_length; 106 u32 reserved_resp_length;
105 u32 status_FIFO_hi; 107 u32 status_fifo_hi;
106 u32 status_FIFO_lo; 108 u32 status_fifo_lo;
107}; 109};
108 110
109#define RESPONSE_GET_MAX_LOGINS(value) (value & 0xffff) 111#define RESPONSE_GET_MAX_LOGINS(value) (value & 0xffff)
@@ -123,8 +125,8 @@ struct sbp2_reconnect_orb {
123 u32 reserved4; 125 u32 reserved4;
124 u32 login_ID_misc; 126 u32 login_ID_misc;
125 u32 reserved5; 127 u32 reserved5;
126 u32 status_FIFO_hi; 128 u32 status_fifo_hi;
127 u32 status_FIFO_lo; 129 u32 status_fifo_lo;
128}; 130};
129 131
130struct sbp2_logout_orb { 132struct sbp2_logout_orb {
@@ -134,8 +136,8 @@ struct sbp2_logout_orb {
134 u32 reserved4; 136 u32 reserved4;
135 u32 login_ID_misc; 137 u32 login_ID_misc;
136 u32 reserved5; 138 u32 reserved5;
137 u32 status_FIFO_hi; 139 u32 status_fifo_hi;
138 u32 status_FIFO_lo; 140 u32 status_fifo_lo;
139}; 141};
140 142
141#define PAGE_TABLE_SET_SEGMENT_BASE_HI(value) (value & 0xffff) 143#define PAGE_TABLE_SET_SEGMENT_BASE_HI(value) (value & 0xffff)
@@ -195,30 +197,6 @@ struct sbp2_status_block {
195 * Miscellaneous SBP2 related config rom defines 197 * Miscellaneous SBP2 related config rom defines
196 */ 198 */
197 199
198/* The status fifo address definition below is used as a base for each
199 * node, which a chunk seperately assigned to each unit directory in the
200 * node. For example, 0xfffe00000000ULL is used for the first sbp2 device
201 * detected on node 0, 0xfffe00000020ULL for the next sbp2 device on node
202 * 0, and so on.
203 *
204 * Note: We could use a single status fifo address for all sbp2 devices,
205 * and figure out which sbp2 device the status belongs to by looking at
206 * the source node id of the status write... but, using separate addresses
207 * for each sbp2 unit directory allows for better code and the ability to
208 * support multiple luns within a single 1394 node.
209 *
210 * Also note that we choose the address range below as it is a region
211 * specified for write posting, where the ohci controller will
212 * automatically send an ack_complete when the status is written by the
213 * sbp2 device... saving a split transaction. =)
214 */
215#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL
216#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe
217#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0
218
219#define SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(entry) ((entry) << 5)
220#define SBP2_STATUS_FIFO_OFFSET_TO_ENTRY(offset) ((offset) >> 5)
221
222#define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1 200#define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1
223#define SBP2_CSR_OFFSET_KEY 0x54 201#define SBP2_CSR_OFFSET_KEY 0x54
224#define SBP2_UNIT_SPEC_ID_KEY 0x12 202#define SBP2_UNIT_SPEC_ID_KEY 0x12
@@ -258,7 +236,6 @@ struct sbp2_status_block {
258 */ 236 */
259 237
260#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 238#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
261#define SBP2_MAX_UDS_PER_NODE 16 /* Maximum scsi devices per node */
262#define SBP2_MAX_SECTORS 255 /* Max sectors supported */ 239#define SBP2_MAX_SECTORS 255 /* Max sectors supported */
263#define SBP2_MAX_CMDS 8 /* This should be safe */ 240#define SBP2_MAX_CMDS 8 /* This should be safe */
264 241
@@ -338,6 +315,11 @@ struct scsi_id_instance_data {
338 u32 sbp2_firmware_revision; 315 u32 sbp2_firmware_revision;
339 316
340 /* 317 /*
318 * Address for the device to write status blocks to
319 */
320 u64 status_fifo_addr;
321
322 /*
341 * Variable used for logins, reconnects, logouts, query logins 323 * Variable used for logins, reconnects, logouts, query logins
342 */ 324 */
343 atomic_t sbp2_login_complete; 325 atomic_t sbp2_login_complete;
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 69c04945591f..ded2c33f5b85 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1019,8 +1019,8 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
1019#define XIP_INVAL_CACHED_RANGE(map, from, size) \ 1019#define XIP_INVAL_CACHED_RANGE(map, from, size) \
1020 INVALIDATE_CACHED_RANGE(map, from, size) 1020 INVALIDATE_CACHED_RANGE(map, from, size)
1021 1021
1022#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \ 1022#define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec) \
1023 UDELAY(map, chip, adr, usec) 1023 UDELAY(map, chip, cmd_adr, usec)
1024 1024
1025/* 1025/*
1026 * Extra notes: 1026 * Extra notes:
@@ -1052,7 +1052,7 @@ do { \
1052 spin_lock(chip->mutex); \ 1052 spin_lock(chip->mutex); \
1053} while (0) 1053} while (0)
1054 1054
1055#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \ 1055#define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec) \
1056do { \ 1056do { \
1057 spin_unlock(chip->mutex); \ 1057 spin_unlock(chip->mutex); \
1058 INVALIDATE_CACHED_RANGE(map, adr, len); \ 1058 INVALIDATE_CACHED_RANGE(map, adr, len); \
@@ -1284,7 +1284,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1284 map_write(map, datum, adr); 1284 map_write(map, datum, adr);
1285 chip->state = mode; 1285 chip->state = mode;
1286 1286
1287 INVALIDATE_CACHE_UDELAY(map, chip, 1287 INVALIDATE_CACHE_UDELAY(map, chip, adr,
1288 adr, map_bankwidth(map), 1288 adr, map_bankwidth(map),
1289 chip->word_write_time); 1289 chip->word_write_time);
1290 1290
@@ -1572,8 +1572,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1572 map_write(map, CMD(0xd0), cmd_adr); 1572 map_write(map, CMD(0xd0), cmd_adr);
1573 chip->state = FL_WRITING; 1573 chip->state = FL_WRITING;
1574 1574
1575 INVALIDATE_CACHE_UDELAY(map, chip, 1575 INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr,
1576 cmd_adr, len, 1576 adr, len,
1577 chip->buffer_write_time); 1577 chip->buffer_write_time);
1578 1578
1579 timeo = jiffies + (HZ/2); 1579 timeo = jiffies + (HZ/2);
@@ -1744,7 +1744,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1744 chip->state = FL_ERASING; 1744 chip->state = FL_ERASING;
1745 chip->erase_suspended = 0; 1745 chip->erase_suspended = 0;
1746 1746
1747 INVALIDATE_CACHE_UDELAY(map, chip, 1747 INVALIDATE_CACHE_UDELAY(map, chip, adr,
1748 adr, len, 1748 adr, len,
1749 chip->erase_time*1000/2); 1749 chip->erase_time*1000/2);
1750 1750
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index fa176ffb4ad5..8936058a3cce 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -108,6 +108,7 @@ static void irda_usb_close(struct irda_usb_cb *self);
108static void speed_bulk_callback(struct urb *urb, struct pt_regs *regs); 108static void speed_bulk_callback(struct urb *urb, struct pt_regs *regs);
109static void write_bulk_callback(struct urb *urb, struct pt_regs *regs); 109static void write_bulk_callback(struct urb *urb, struct pt_regs *regs);
110static void irda_usb_receive(struct urb *urb, struct pt_regs *regs); 110static void irda_usb_receive(struct urb *urb, struct pt_regs *regs);
111static void irda_usb_rx_defer_expired(unsigned long data);
111static int irda_usb_net_open(struct net_device *dev); 112static int irda_usb_net_open(struct net_device *dev);
112static int irda_usb_net_close(struct net_device *dev); 113static int irda_usb_net_close(struct net_device *dev);
113static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 114static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -677,6 +678,12 @@ static void irda_usb_net_timeout(struct net_device *netdev)
677 * on the interrupt pipe and hang the Rx URB only when an interrupt is 678 * on the interrupt pipe and hang the Rx URB only when an interrupt is
678 * received. 679 * received.
679 * Jean II 680 * Jean II
681 *
682 * Note : don't read the above as what we are currently doing, but as
683 * something we could do with KC dongle. Also don't forget that the
684 * interrupt pipe is not part of the original standard, so this would
685 * need to be optional...
686 * Jean II
680 */ 687 */
681 688
682/*------------------------------------------------------------------*/ 689/*------------------------------------------------------------------*/
@@ -704,10 +711,8 @@ static void irda_usb_submit(struct irda_usb_cb *self, struct sk_buff *skb, struc
704 /* Reinitialize URB */ 711 /* Reinitialize URB */
705 usb_fill_bulk_urb(urb, self->usbdev, 712 usb_fill_bulk_urb(urb, self->usbdev,
706 usb_rcvbulkpipe(self->usbdev, self->bulk_in_ep), 713 usb_rcvbulkpipe(self->usbdev, self->bulk_in_ep),
707 skb->data, skb->truesize, 714 skb->data, IRDA_SKB_MAX_MTU,
708 irda_usb_receive, skb); 715 irda_usb_receive, skb);
709 /* Note : unlink *must* be synchronous because of the code in
710 * irda_usb_net_close() -> free the skb - Jean II */
711 urb->status = 0; 716 urb->status = 0;
712 717
713 /* Can be called from irda_usb_receive (irq handler) -> GFP_ATOMIC */ 718 /* Can be called from irda_usb_receive (irq handler) -> GFP_ATOMIC */
@@ -734,6 +739,7 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
734 struct irda_skb_cb *cb; 739 struct irda_skb_cb *cb;
735 struct sk_buff *newskb; 740 struct sk_buff *newskb;
736 struct sk_buff *dataskb; 741 struct sk_buff *dataskb;
742 struct urb *next_urb;
737 int docopy; 743 int docopy;
738 744
739 IRDA_DEBUG(2, "%s(), len=%d\n", __FUNCTION__, urb->actual_length); 745 IRDA_DEBUG(2, "%s(), len=%d\n", __FUNCTION__, urb->actual_length);
@@ -755,20 +761,37 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
755 if (urb->status != 0) { 761 if (urb->status != 0) {
756 switch (urb->status) { 762 switch (urb->status) {
757 case -EILSEQ: 763 case -EILSEQ:
758 self->stats.rx_errors++;
759 self->stats.rx_crc_errors++; 764 self->stats.rx_crc_errors++;
760 break; 765 /* Also precursor to a hot-unplug on UHCI. */
766 /* Fallthrough... */
761 case -ECONNRESET: /* -104 */ 767 case -ECONNRESET: /* -104 */
762 IRDA_DEBUG(0, "%s(), Connection Reset (-104), transfer_flags 0x%04X \n", __FUNCTION__, urb->transfer_flags); 768 /* Random error, if I remember correctly */
763 /* uhci_cleanup_unlink() is going to kill the Rx 769 /* uhci_cleanup_unlink() is going to kill the Rx
764 * URB just after we return. No problem, at this 770 * URB just after we return. No problem, at this
765 * point the URB will be idle ;-) - Jean II */ 771 * point the URB will be idle ;-) - Jean II */
766 break; 772 case -ESHUTDOWN: /* -108 */
773 /* That's usually a hot-unplug. Submit will fail... */
774 case -ETIMEDOUT: /* -110 */
775 /* Usually precursor to a hot-unplug on OHCI. */
767 default: 776 default:
768 IRDA_DEBUG(0, "%s(), RX status %d,transfer_flags 0x%04X \n", __FUNCTION__, urb->status, urb->transfer_flags); 777 self->stats.rx_errors++;
778 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __FUNCTION__, urb->status, urb->transfer_flags);
769 break; 779 break;
770 } 780 }
771 goto done; 781 /* If we received an error, we don't want to resubmit the
782 * Rx URB straight away but to give the USB layer a little
783 * bit of breathing room.
784 * We are in the USB thread context, therefore there is a
785 * danger of recursion (new URB we submit fails, we come
786 * back here).
787 * With recent USB stack (2.6.15+), I'm seeing that on
788 * hot unplug of the dongle...
789 * Lowest effective timer is 10ms...
790 * Jean II */
791 self->rx_defer_timer.function = &irda_usb_rx_defer_expired;
792 self->rx_defer_timer.data = (unsigned long) urb;
793 mod_timer(&self->rx_defer_timer, jiffies + (10 * HZ / 1000));
794 return;
772 } 795 }
773 796
774 /* Check for empty frames */ 797 /* Check for empty frames */
@@ -845,13 +868,45 @@ done:
845 * idle slot.... 868 * idle slot....
846 * Jean II */ 869 * Jean II */
847 /* Note : with this scheme, we could submit the idle URB before 870 /* Note : with this scheme, we could submit the idle URB before
848 * processing the Rx URB. Another time... Jean II */ 871 * processing the Rx URB. I don't think it would buy us anything as
872 * we are running in the USB thread context. Jean II */
873 next_urb = self->idle_rx_urb;
849 874
850 /* Submit the idle URB to replace the URB we've just received */
851 irda_usb_submit(self, skb, self->idle_rx_urb);
852 /* Recycle Rx URB : Now, the idle URB is the present one */ 875 /* Recycle Rx URB : Now, the idle URB is the present one */
853 urb->context = NULL; 876 urb->context = NULL;
854 self->idle_rx_urb = urb; 877 self->idle_rx_urb = urb;
878
879 /* Submit the idle URB to replace the URB we've just received.
880 * Do it last to avoid race conditions... Jean II */
881 irda_usb_submit(self, skb, next_urb);
882}
883
884/*------------------------------------------------------------------*/
885/*
886 * In case of errors, we want the USB layer to have time to recover.
887 * Now, it is time to resubmit ouur Rx URB...
888 */
889static void irda_usb_rx_defer_expired(unsigned long data)
890{
891 struct urb *urb = (struct urb *) data;
892 struct sk_buff *skb = (struct sk_buff *) urb->context;
893 struct irda_usb_cb *self;
894 struct irda_skb_cb *cb;
895 struct urb *next_urb;
896
897 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
898
899 /* Find ourselves */
900 cb = (struct irda_skb_cb *) skb->cb;
901 IRDA_ASSERT(cb != NULL, return;);
902 self = (struct irda_usb_cb *) cb->context;
903 IRDA_ASSERT(self != NULL, return;);
904
905 /* Same stuff as when Rx is done, see above... */
906 next_urb = self->idle_rx_urb;
907 urb->context = NULL;
908 self->idle_rx_urb = urb;
909 irda_usb_submit(self, skb, next_urb);
855} 910}
856 911
857/*------------------------------------------------------------------*/ 912/*------------------------------------------------------------------*/
@@ -990,6 +1045,9 @@ static int irda_usb_net_close(struct net_device *netdev)
990 /* Stop network Tx queue */ 1045 /* Stop network Tx queue */
991 netif_stop_queue(netdev); 1046 netif_stop_queue(netdev);
992 1047
1048 /* Kill defered Rx URB */
1049 del_timer(&self->rx_defer_timer);
1050
993 /* Deallocate all the Rx path buffers (URBs and skb) */ 1051 /* Deallocate all the Rx path buffers (URBs and skb) */
994 for (i = 0; i < IU_MAX_RX_URBS; i++) { 1052 for (i = 0; i < IU_MAX_RX_URBS; i++) {
995 struct urb *urb = self->rx_urb[i]; 1053 struct urb *urb = self->rx_urb[i];
@@ -1365,6 +1423,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1365 self = net->priv; 1423 self = net->priv;
1366 self->netdev = net; 1424 self->netdev = net;
1367 spin_lock_init(&self->lock); 1425 spin_lock_init(&self->lock);
1426 init_timer(&self->rx_defer_timer);
1368 1427
1369 /* Create all of the needed urbs */ 1428 /* Create all of the needed urbs */
1370 for (i = 0; i < IU_MAX_RX_URBS; i++) { 1429 for (i = 0; i < IU_MAX_RX_URBS; i++) {
@@ -1498,6 +1557,9 @@ static void irda_usb_disconnect(struct usb_interface *intf)
1498 * This will stop/desactivate the Tx path. - Jean II */ 1557 * This will stop/desactivate the Tx path. - Jean II */
1499 self->present = 0; 1558 self->present = 0;
1500 1559
1560 /* Kill defered Rx URB */
1561 del_timer(&self->rx_defer_timer);
1562
1501 /* We need to have irq enabled to unlink the URBs. That's OK, 1563 /* We need to have irq enabled to unlink the URBs. That's OK,
1502 * at this point the Tx path is gone - Jean II */ 1564 * at this point the Tx path is gone - Jean II */
1503 spin_unlock_irqrestore(&self->lock, flags); 1565 spin_unlock_irqrestore(&self->lock, flags);
@@ -1507,11 +1569,11 @@ static void irda_usb_disconnect(struct usb_interface *intf)
1507 /* Accept no more transmissions */ 1569 /* Accept no more transmissions */
1508 /*netif_device_detach(self->netdev);*/ 1570 /*netif_device_detach(self->netdev);*/
1509 netif_stop_queue(self->netdev); 1571 netif_stop_queue(self->netdev);
1510 /* Stop all the receive URBs */ 1572 /* Stop all the receive URBs. Must be synchronous. */
1511 for (i = 0; i < IU_MAX_RX_URBS; i++) 1573 for (i = 0; i < IU_MAX_RX_URBS; i++)
1512 usb_kill_urb(self->rx_urb[i]); 1574 usb_kill_urb(self->rx_urb[i]);
1513 /* Cancel Tx and speed URB. 1575 /* Cancel Tx and speed URB.
1514 * Toggle flags to make sure it's synchronous. */ 1576 * Make sure it's synchronous to avoid races. */
1515 usb_kill_urb(self->tx_urb); 1577 usb_kill_urb(self->tx_urb);
1516 usb_kill_urb(self->speed_urb); 1578 usb_kill_urb(self->speed_urb);
1517 } 1579 }
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h
index bd8f66542322..4026af42dd47 100644
--- a/drivers/net/irda/irda-usb.h
+++ b/drivers/net/irda/irda-usb.h
@@ -136,8 +136,6 @@ struct irda_usb_cb {
136 __u16 bulk_out_mtu; /* Max Tx packet size in bytes */ 136 __u16 bulk_out_mtu; /* Max Tx packet size in bytes */
137 __u8 bulk_int_ep; /* Interrupt Endpoint assignments */ 137 __u8 bulk_int_ep; /* Interrupt Endpoint assignments */
138 138
139 wait_queue_head_t wait_q; /* for timeouts */
140
141 struct urb *rx_urb[IU_MAX_RX_URBS]; /* URBs used to receive data frames */ 139 struct urb *rx_urb[IU_MAX_RX_URBS]; /* URBs used to receive data frames */
142 struct urb *idle_rx_urb; /* Pointer to idle URB in Rx path */ 140 struct urb *idle_rx_urb; /* Pointer to idle URB in Rx path */
143 struct urb *tx_urb; /* URB used to send data frames */ 141 struct urb *tx_urb; /* URB used to send data frames */
@@ -147,17 +145,18 @@ struct irda_usb_cb {
147 struct net_device_stats stats; 145 struct net_device_stats stats;
148 struct irlap_cb *irlap; /* The link layer we are binded to */ 146 struct irlap_cb *irlap; /* The link layer we are binded to */
149 struct qos_info qos; 147 struct qos_info qos;
150 hashbin_t *tx_list; /* Queued transmit skb's */
151 char *speed_buff; /* Buffer for speed changes */ 148 char *speed_buff; /* Buffer for speed changes */
152 149
153 struct timeval stamp; 150 struct timeval stamp;
154 struct timeval now; 151 struct timeval now;
155 152
156 spinlock_t lock; /* For serializing operations */ 153 spinlock_t lock; /* For serializing Tx operations */
157 154
158 __u16 xbofs; /* Current xbofs setting */ 155 __u16 xbofs; /* Current xbofs setting */
159 __s16 new_xbofs; /* xbofs we need to set */ 156 __s16 new_xbofs; /* xbofs we need to set */
160 __u32 speed; /* Current speed */ 157 __u32 speed; /* Current speed */
161 __s32 new_speed; /* speed we need to set */ 158 __s32 new_speed; /* speed we need to set */
159
160 struct timer_list rx_defer_timer; /* Wait for Rx error to clear */
162}; 161};
163 162
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 6e1018448eea..8cc0d0bbdf50 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -287,6 +287,20 @@ enum RTL8169_register_content {
287 TxInterFrameGapShift = 24, 287 TxInterFrameGapShift = 24,
288 TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */ 288 TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */
289 289
290 /* Config1 register p.24 */
291 PMEnable = (1 << 0), /* Power Management Enable */
292
293 /* Config3 register p.25 */
294 MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */
295 LinkUp = (1 << 4), /* Wake up when the cable connection is re-established */
296
297 /* Config5 register p.27 */
298 BWF = (1 << 6), /* Accept Broadcast wakeup frame */
299 MWF = (1 << 5), /* Accept Multicast wakeup frame */
300 UWF = (1 << 4), /* Accept Unicast wakeup frame */
301 LanWake = (1 << 1), /* LanWake enable/disable */
302 PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */
303
290 /* TBICSR p.28 */ 304 /* TBICSR p.28 */
291 TBIReset = 0x80000000, 305 TBIReset = 0x80000000,
292 TBILoopback = 0x40000000, 306 TBILoopback = 0x40000000,
@@ -433,6 +447,7 @@ struct rtl8169_private {
433 unsigned int (*phy_reset_pending)(void __iomem *); 447 unsigned int (*phy_reset_pending)(void __iomem *);
434 unsigned int (*link_ok)(void __iomem *); 448 unsigned int (*link_ok)(void __iomem *);
435 struct work_struct task; 449 struct work_struct task;
450 unsigned wol_enabled : 1;
436}; 451};
437 452
438MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); 453MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
@@ -607,6 +622,80 @@ static void rtl8169_link_option(int idx, u8 *autoneg, u16 *speed, u8 *duplex)
607 *duplex = p->duplex; 622 *duplex = p->duplex;
608} 623}
609 624
625static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
626{
627 struct rtl8169_private *tp = netdev_priv(dev);
628 void __iomem *ioaddr = tp->mmio_addr;
629 u8 options;
630
631 wol->wolopts = 0;
632
633#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
634 wol->supported = WAKE_ANY;
635
636 spin_lock_irq(&tp->lock);
637
638 options = RTL_R8(Config1);
639 if (!(options & PMEnable))
640 goto out_unlock;
641
642 options = RTL_R8(Config3);
643 if (options & LinkUp)
644 wol->wolopts |= WAKE_PHY;
645 if (options & MagicPacket)
646 wol->wolopts |= WAKE_MAGIC;
647
648 options = RTL_R8(Config5);
649 if (options & UWF)
650 wol->wolopts |= WAKE_UCAST;
651 if (options & BWF)
652 wol->wolopts |= WAKE_BCAST;
653 if (options & MWF)
654 wol->wolopts |= WAKE_MCAST;
655
656out_unlock:
657 spin_unlock_irq(&tp->lock);
658}
659
660static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
661{
662 struct rtl8169_private *tp = netdev_priv(dev);
663 void __iomem *ioaddr = tp->mmio_addr;
664 int i;
665 static struct {
666 u32 opt;
667 u16 reg;
668 u8 mask;
669 } cfg[] = {
670 { WAKE_ANY, Config1, PMEnable },
671 { WAKE_PHY, Config3, LinkUp },
672 { WAKE_MAGIC, Config3, MagicPacket },
673 { WAKE_UCAST, Config5, UWF },
674 { WAKE_BCAST, Config5, BWF },
675 { WAKE_MCAST, Config5, MWF },
676 { WAKE_ANY, Config5, LanWake }
677 };
678
679 spin_lock_irq(&tp->lock);
680
681 RTL_W8(Cfg9346, Cfg9346_Unlock);
682
683 for (i = 0; i < ARRAY_SIZE(cfg); i++) {
684 u8 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask;
685 if (wol->wolopts & cfg[i].opt)
686 options |= cfg[i].mask;
687 RTL_W8(cfg[i].reg, options);
688 }
689
690 RTL_W8(Cfg9346, Cfg9346_Lock);
691
692 tp->wol_enabled = (wol->wolopts) ? 1 : 0;
693
694 spin_unlock_irq(&tp->lock);
695
696 return 0;
697}
698
610static void rtl8169_get_drvinfo(struct net_device *dev, 699static void rtl8169_get_drvinfo(struct net_device *dev,
611 struct ethtool_drvinfo *info) 700 struct ethtool_drvinfo *info)
612{ 701{
@@ -1025,6 +1114,8 @@ static struct ethtool_ops rtl8169_ethtool_ops = {
1025 .get_tso = ethtool_op_get_tso, 1114 .get_tso = ethtool_op_get_tso,
1026 .set_tso = ethtool_op_set_tso, 1115 .set_tso = ethtool_op_set_tso,
1027 .get_regs = rtl8169_get_regs, 1116 .get_regs = rtl8169_get_regs,
1117 .get_wol = rtl8169_get_wol,
1118 .set_wol = rtl8169_set_wol,
1028 .get_strings = rtl8169_get_strings, 1119 .get_strings = rtl8169_get_strings,
1029 .get_stats_count = rtl8169_get_stats_count, 1120 .get_stats_count = rtl8169_get_stats_count,
1030 .get_ethtool_stats = rtl8169_get_ethtool_stats, 1121 .get_ethtool_stats = rtl8169_get_ethtool_stats,
@@ -1442,6 +1533,11 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1442 } 1533 }
1443 tp->chipset = i; 1534 tp->chipset = i;
1444 1535
1536 RTL_W8(Cfg9346, Cfg9346_Unlock);
1537 RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
1538 RTL_W8(Config5, RTL_R8(Config5) & PMEStatus);
1539 RTL_W8(Cfg9346, Cfg9346_Lock);
1540
1445 *ioaddr_out = ioaddr; 1541 *ioaddr_out = ioaddr;
1446 *dev_out = dev; 1542 *dev_out = dev;
1447out: 1543out:
@@ -1612,49 +1708,6 @@ rtl8169_remove_one(struct pci_dev *pdev)
1612 pci_set_drvdata(pdev, NULL); 1708 pci_set_drvdata(pdev, NULL);
1613} 1709}
1614 1710
1615#ifdef CONFIG_PM
1616
1617static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
1618{
1619 struct net_device *dev = pci_get_drvdata(pdev);
1620 struct rtl8169_private *tp = netdev_priv(dev);
1621 void __iomem *ioaddr = tp->mmio_addr;
1622 unsigned long flags;
1623
1624 if (!netif_running(dev))
1625 return 0;
1626
1627 netif_device_detach(dev);
1628 netif_stop_queue(dev);
1629 spin_lock_irqsave(&tp->lock, flags);
1630
1631 /* Disable interrupts, stop Rx and Tx */
1632 RTL_W16(IntrMask, 0);
1633 RTL_W8(ChipCmd, 0);
1634
1635 /* Update the error counts. */
1636 tp->stats.rx_missed_errors += RTL_R32(RxMissed);
1637 RTL_W32(RxMissed, 0);
1638 spin_unlock_irqrestore(&tp->lock, flags);
1639
1640 return 0;
1641}
1642
1643static int rtl8169_resume(struct pci_dev *pdev)
1644{
1645 struct net_device *dev = pci_get_drvdata(pdev);
1646
1647 if (!netif_running(dev))
1648 return 0;
1649
1650 netif_device_attach(dev);
1651 rtl8169_hw_start(dev);
1652
1653 return 0;
1654}
1655
1656#endif /* CONFIG_PM */
1657
1658static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, 1711static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
1659 struct net_device *dev) 1712 struct net_device *dev)
1660{ 1713{
@@ -2700,6 +2753,56 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev)
2700 return &tp->stats; 2753 return &tp->stats;
2701} 2754}
2702 2755
2756#ifdef CONFIG_PM
2757
2758static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
2759{
2760 struct net_device *dev = pci_get_drvdata(pdev);
2761 struct rtl8169_private *tp = netdev_priv(dev);
2762 void __iomem *ioaddr = tp->mmio_addr;
2763
2764 if (!netif_running(dev))
2765 goto out;
2766
2767 netif_device_detach(dev);
2768 netif_stop_queue(dev);
2769
2770 spin_lock_irq(&tp->lock);
2771
2772 rtl8169_asic_down(ioaddr);
2773
2774 tp->stats.rx_missed_errors += RTL_R32(RxMissed);
2775 RTL_W32(RxMissed, 0);
2776
2777 spin_unlock_irq(&tp->lock);
2778
2779 pci_save_state(pdev);
2780 pci_enable_wake(pdev, pci_choose_state(pdev, state), tp->wol_enabled);
2781 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2782out:
2783 return 0;
2784}
2785
2786static int rtl8169_resume(struct pci_dev *pdev)
2787{
2788 struct net_device *dev = pci_get_drvdata(pdev);
2789
2790 if (!netif_running(dev))
2791 goto out;
2792
2793 netif_device_attach(dev);
2794
2795 pci_set_power_state(pdev, PCI_D0);
2796 pci_restore_state(pdev);
2797 pci_enable_wake(pdev, PCI_D0, 0);
2798
2799 rtl8169_schedule_work(dev, rtl8169_reset_task);
2800out:
2801 return 0;
2802}
2803
2804#endif /* CONFIG_PM */
2805
2703static struct pci_driver rtl8169_pci_driver = { 2806static struct pci_driver rtl8169_pci_driver = {
2704 .name = MODULENAME, 2807 .name = MODULENAME,
2705 .id_table = rtl8169_pci_tbl, 2808 .id_table = rtl8169_pci_tbl,
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 67fb19b8fde9..25e028b7ce48 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -879,13 +879,12 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
879 int i; 879 int i;
880 880
881 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); 881 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
882 xm_read16(hw, port, XM_PHY_DATA); 882 *val = xm_read16(hw, port, XM_PHY_DATA);
883 883
884 /* Need to wait for external PHY */
885 for (i = 0; i < PHY_RETRIES; i++) { 884 for (i = 0; i < PHY_RETRIES; i++) {
886 udelay(1);
887 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY) 885 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY)
888 goto ready; 886 goto ready;
887 udelay(1);
889 } 888 }
890 889
891 return -ETIMEDOUT; 890 return -ETIMEDOUT;
@@ -918,7 +917,12 @@ static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val)
918 917
919 ready: 918 ready:
920 xm_write16(hw, port, XM_PHY_DATA, val); 919 xm_write16(hw, port, XM_PHY_DATA, val);
921 return 0; 920 for (i = 0; i < PHY_RETRIES; i++) {
921 if (!(xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY))
922 return 0;
923 udelay(1);
924 }
925 return -ETIMEDOUT;
922} 926}
923 927
924static void genesis_init(struct skge_hw *hw) 928static void genesis_init(struct skge_hw *hw)
@@ -1168,13 +1172,17 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1168 u32 r; 1172 u32 r;
1169 const u8 zero[6] = { 0 }; 1173 const u8 zero[6] = { 0 };
1170 1174
1171 /* Clear MIB counters */ 1175 for (i = 0; i < 10; i++) {
1172 xm_write16(hw, port, XM_STAT_CMD, 1176 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1),
1173 XM_SC_CLR_RXC | XM_SC_CLR_TXC); 1177 MFF_SET_MAC_RST);
1174 /* Clear two times according to Errata #3 */ 1178 if (skge_read16(hw, SK_REG(port, TX_MFF_CTRL1)) & MFF_SET_MAC_RST)
1175 xm_write16(hw, port, XM_STAT_CMD, 1179 goto reset_ok;
1176 XM_SC_CLR_RXC | XM_SC_CLR_TXC); 1180 udelay(1);
1181 }
1182
1183 printk(KERN_WARNING PFX "%s: genesis reset failed\n", dev->name);
1177 1184
1185 reset_ok:
1178 /* Unreset the XMAC. */ 1186 /* Unreset the XMAC. */
1179 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST); 1187 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
1180 1188
@@ -1191,7 +1199,7 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1191 r |= GP_DIR_2|GP_IO_2; 1199 r |= GP_DIR_2|GP_IO_2;
1192 1200
1193 skge_write32(hw, B2_GP_IO, r); 1201 skge_write32(hw, B2_GP_IO, r);
1194 skge_read32(hw, B2_GP_IO); 1202
1195 1203
1196 /* Enable GMII interface */ 1204 /* Enable GMII interface */
1197 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD); 1205 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
@@ -1205,6 +1213,13 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1205 for (i = 1; i < 16; i++) 1213 for (i = 1; i < 16; i++)
1206 xm_outaddr(hw, port, XM_EXM(i), zero); 1214 xm_outaddr(hw, port, XM_EXM(i), zero);
1207 1215
1216 /* Clear MIB counters */
1217 xm_write16(hw, port, XM_STAT_CMD,
1218 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1219 /* Clear two times according to Errata #3 */
1220 xm_write16(hw, port, XM_STAT_CMD,
1221 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1222
1208 /* configure Rx High Water Mark (XM_RX_HI_WM) */ 1223 /* configure Rx High Water Mark (XM_RX_HI_WM) */
1209 xm_write16(hw, port, XM_RX_HI_WM, 1450); 1224 xm_write16(hw, port, XM_RX_HI_WM, 1450);
1210 1225
@@ -2170,8 +2185,10 @@ static int skge_up(struct net_device *dev)
2170 skge->tx_avail = skge->tx_ring.count - 1; 2185 skge->tx_avail = skge->tx_ring.count - 1;
2171 2186
2172 /* Enable IRQ from port */ 2187 /* Enable IRQ from port */
2188 spin_lock_irq(&hw->hw_lock);
2173 hw->intr_mask |= portirqmask[port]; 2189 hw->intr_mask |= portirqmask[port];
2174 skge_write32(hw, B0_IMSK, hw->intr_mask); 2190 skge_write32(hw, B0_IMSK, hw->intr_mask);
2191 spin_unlock_irq(&hw->hw_lock);
2175 2192
2176 /* Initialize MAC */ 2193 /* Initialize MAC */
2177 spin_lock_bh(&hw->phy_lock); 2194 spin_lock_bh(&hw->phy_lock);
@@ -2229,8 +2246,10 @@ static int skge_down(struct net_device *dev)
2229 else 2246 else
2230 yukon_stop(skge); 2247 yukon_stop(skge);
2231 2248
2249 spin_lock_irq(&hw->hw_lock);
2232 hw->intr_mask &= ~portirqmask[skge->port]; 2250 hw->intr_mask &= ~portirqmask[skge->port];
2233 skge_write32(hw, B0_IMSK, hw->intr_mask); 2251 skge_write32(hw, B0_IMSK, hw->intr_mask);
2252 spin_unlock_irq(&hw->hw_lock);
2234 2253
2235 /* Stop transmitter */ 2254 /* Stop transmitter */
2236 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP); 2255 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP);
@@ -2678,8 +2697,7 @@ static int skge_poll(struct net_device *dev, int *budget)
2678 2697
2679 /* restart receiver */ 2698 /* restart receiver */
2680 wmb(); 2699 wmb();
2681 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), 2700 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
2682 CSR_START | CSR_IRQ_CL_F);
2683 2701
2684 *budget -= work_done; 2702 *budget -= work_done;
2685 dev->quota -= work_done; 2703 dev->quota -= work_done;
@@ -2687,10 +2705,11 @@ static int skge_poll(struct net_device *dev, int *budget)
2687 if (work_done >= to_do) 2705 if (work_done >= to_do)
2688 return 1; /* not done */ 2706 return 1; /* not done */
2689 2707
2690 netif_rx_complete(dev); 2708 spin_lock_irq(&hw->hw_lock);
2691 hw->intr_mask |= portirqmask[skge->port]; 2709 __netif_rx_complete(dev);
2692 skge_write32(hw, B0_IMSK, hw->intr_mask); 2710 hw->intr_mask |= portirqmask[skge->port];
2693 skge_read32(hw, B0_IMSK); 2711 skge_write32(hw, B0_IMSK, hw->intr_mask);
2712 spin_unlock_irq(&hw->hw_lock);
2694 2713
2695 return 0; 2714 return 0;
2696} 2715}
@@ -2850,18 +2869,10 @@ static void skge_extirq(unsigned long data)
2850 } 2869 }
2851 spin_unlock(&hw->phy_lock); 2870 spin_unlock(&hw->phy_lock);
2852 2871
2853 local_irq_disable(); 2872 spin_lock_irq(&hw->hw_lock);
2854 hw->intr_mask |= IS_EXT_REG; 2873 hw->intr_mask |= IS_EXT_REG;
2855 skge_write32(hw, B0_IMSK, hw->intr_mask); 2874 skge_write32(hw, B0_IMSK, hw->intr_mask);
2856 local_irq_enable(); 2875 spin_unlock_irq(&hw->hw_lock);
2857}
2858
2859static inline void skge_wakeup(struct net_device *dev)
2860{
2861 struct skge_port *skge = netdev_priv(dev);
2862
2863 prefetch(skge->rx_ring.to_clean);
2864 netif_rx_schedule(dev);
2865} 2876}
2866 2877
2867static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs) 2878static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
@@ -2872,15 +2883,17 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2872 if (status == 0 || status == ~0) /* hotplug or shared irq */ 2883 if (status == 0 || status == ~0) /* hotplug or shared irq */
2873 return IRQ_NONE; 2884 return IRQ_NONE;
2874 2885
2875 status &= hw->intr_mask; 2886 spin_lock(&hw->hw_lock);
2876 if (status & IS_R1_F) { 2887 if (status & IS_R1_F) {
2888 skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
2877 hw->intr_mask &= ~IS_R1_F; 2889 hw->intr_mask &= ~IS_R1_F;
2878 skge_wakeup(hw->dev[0]); 2890 netif_rx_schedule(hw->dev[0]);
2879 } 2891 }
2880 2892
2881 if (status & IS_R2_F) { 2893 if (status & IS_R2_F) {
2894 skge_write8(hw, Q_ADDR(Q_R2, Q_CSR), CSR_IRQ_CL_F);
2882 hw->intr_mask &= ~IS_R2_F; 2895 hw->intr_mask &= ~IS_R2_F;
2883 skge_wakeup(hw->dev[1]); 2896 netif_rx_schedule(hw->dev[1]);
2884 } 2897 }
2885 2898
2886 if (status & IS_XA1_F) 2899 if (status & IS_XA1_F)
@@ -2922,6 +2935,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2922 } 2935 }
2923 2936
2924 skge_write32(hw, B0_IMSK, hw->intr_mask); 2937 skge_write32(hw, B0_IMSK, hw->intr_mask);
2938 spin_unlock(&hw->hw_lock);
2925 2939
2926 return IRQ_HANDLED; 2940 return IRQ_HANDLED;
2927} 2941}
@@ -3290,6 +3304,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3290 3304
3291 hw->pdev = pdev; 3305 hw->pdev = pdev;
3292 spin_lock_init(&hw->phy_lock); 3306 spin_lock_init(&hw->phy_lock);
3307 spin_lock_init(&hw->hw_lock);
3293 tasklet_init(&hw->ext_tasklet, skge_extirq, (unsigned long) hw); 3308 tasklet_init(&hw->ext_tasklet, skge_extirq, (unsigned long) hw);
3294 3309
3295 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); 3310 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 2efdacc290e5..941f12a333b6 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2402,6 +2402,7 @@ struct skge_hw {
2402 2402
2403 struct tasklet_struct ext_tasklet; 2403 struct tasklet_struct ext_tasklet;
2404 spinlock_t phy_lock; 2404 spinlock_t phy_lock;
2405 spinlock_t hw_lock;
2405}; 2406};
2406 2407
2407enum { 2408enum {
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index bfeba5b9cd7a..ca8160d68229 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -195,11 +195,11 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
195 pr_debug("sky2_set_power_state %d\n", state); 195 pr_debug("sky2_set_power_state %d\n", state);
196 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 196 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
197 197
198 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control); 198 power_control = sky2_pci_read16(hw, hw->pm_cap + PCI_PM_PMC);
199 vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) && 199 vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
200 (power_control & PCI_PM_CAP_PME_D3cold); 200 (power_control & PCI_PM_CAP_PME_D3cold);
201 201
202 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control); 202 power_control = sky2_pci_read16(hw, hw->pm_cap + PCI_PM_CTRL);
203 203
204 power_control |= PCI_PM_CTRL_PME_STATUS; 204 power_control |= PCI_PM_CTRL_PME_STATUS;
205 power_control &= ~(PCI_PM_CTRL_STATE_MASK); 205 power_control &= ~(PCI_PM_CTRL_STATE_MASK);
@@ -223,7 +223,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
223 sky2_write8(hw, B2_Y2_CLK_GATE, 0); 223 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
224 224
225 /* Turn off phy power saving */ 225 /* Turn off phy power saving */
226 pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1); 226 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
227 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); 227 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
228 228
229 /* looks like this XL is back asswards .. */ 229 /* looks like this XL is back asswards .. */
@@ -232,18 +232,28 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
232 if (hw->ports > 1) 232 if (hw->ports > 1)
233 reg1 |= PCI_Y2_PHY2_COMA; 233 reg1 |= PCI_Y2_PHY2_COMA;
234 } 234 }
235 pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1); 235
236 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
237 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
238 reg1 = sky2_pci_read32(hw, PCI_DEV_REG4);
239 reg1 &= P_ASPM_CONTROL_MSK;
240 sky2_pci_write32(hw, PCI_DEV_REG4, reg1);
241 sky2_pci_write32(hw, PCI_DEV_REG5, 0);
242 }
243
244 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
245
236 break; 246 break;
237 247
238 case PCI_D3hot: 248 case PCI_D3hot:
239 case PCI_D3cold: 249 case PCI_D3cold:
240 /* Turn on phy power saving */ 250 /* Turn on phy power saving */
241 pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1); 251 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
242 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 252 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
243 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); 253 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
244 else 254 else
245 reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); 255 reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
246 pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1); 256 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
247 257
248 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 258 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
249 sky2_write8(hw, B2_Y2_CLK_GATE, 0); 259 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
@@ -265,7 +275,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
265 ret = -1; 275 ret = -1;
266 } 276 }
267 277
268 pci_write_config_byte(hw->pdev, hw->pm_cap + PCI_PM_CTRL, power_control); 278 sky2_pci_write16(hw, hw->pm_cap + PCI_PM_CTRL, power_control);
269 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 279 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
270 return ret; 280 return ret;
271} 281}
@@ -463,16 +473,31 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
463 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); 473 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
464 } 474 }
465 475
466 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); 476 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) {
477 /* apply fixes in PHY AFE */
478 gm_phy_write(hw, port, 22, 255);
479 /* increase differential signal amplitude in 10BASE-T */
480 gm_phy_write(hw, port, 24, 0xaa99);
481 gm_phy_write(hw, port, 23, 0x2011);
467 482
468 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { 483 /* fix for IEEE A/B Symmetry failure in 1000BASE-T */
469 /* turn on 100 Mbps LED (LED_LINK100) */ 484 gm_phy_write(hw, port, 24, 0xa204);
470 ledover |= PHY_M_LED_MO_100(MO_LED_ON); 485 gm_phy_write(hw, port, 23, 0x2002);
471 }
472 486
473 if (ledover) 487 /* set page register to 0 */
474 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); 488 gm_phy_write(hw, port, 22, 0);
489 } else {
490 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
475 491
492 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
493 /* turn on 100 Mbps LED (LED_LINK100) */
494 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
495 }
496
497 if (ledover)
498 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
499
500 }
476 /* Enable phy interrupt on auto-negotiation complete (or link up) */ 501 /* Enable phy interrupt on auto-negotiation complete (or link up) */
477 if (sky2->autoneg == AUTONEG_ENABLE) 502 if (sky2->autoneg == AUTONEG_ENABLE)
478 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL); 503 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL);
@@ -953,6 +978,12 @@ static int sky2_rx_start(struct sky2_port *sky2)
953 978
954 sky2->rx_put = sky2->rx_next = 0; 979 sky2->rx_put = sky2->rx_next = 0;
955 sky2_qset(hw, rxq); 980 sky2_qset(hw, rxq);
981
982 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) {
983 /* MAC Rx RAM Read is controlled by hardware */
984 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
985 }
986
956 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); 987 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
957 988
958 rx_set_checksum(sky2); 989 rx_set_checksum(sky2);
@@ -1035,9 +1066,10 @@ static int sky2_up(struct net_device *dev)
1035 RB_RST_SET); 1066 RB_RST_SET);
1036 1067
1037 sky2_qset(hw, txqaddr[port]); 1068 sky2_qset(hw, txqaddr[port]);
1038 if (hw->chip_id == CHIP_ID_YUKON_EC_U)
1039 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
1040 1069
1070 /* Set almost empty threshold */
1071 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == 1)
1072 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
1041 1073
1042 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, 1074 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
1043 TX_RING_SIZE - 1); 1075 TX_RING_SIZE - 1);
@@ -1047,8 +1079,10 @@ static int sky2_up(struct net_device *dev)
1047 goto err_out; 1079 goto err_out;
1048 1080
1049 /* Enable interrupts from phy/mac for port */ 1081 /* Enable interrupts from phy/mac for port */
1082 spin_lock_irq(&hw->hw_lock);
1050 hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; 1083 hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2;
1051 sky2_write32(hw, B0_IMSK, hw->intr_mask); 1084 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1085 spin_unlock_irq(&hw->hw_lock);
1052 return 0; 1086 return 0;
1053 1087
1054err_out: 1088err_out:
@@ -1348,10 +1382,10 @@ static int sky2_down(struct net_device *dev)
1348 netif_stop_queue(dev); 1382 netif_stop_queue(dev);
1349 1383
1350 /* Disable port IRQ */ 1384 /* Disable port IRQ */
1351 local_irq_disable(); 1385 spin_lock_irq(&hw->hw_lock);
1352 hw->intr_mask &= ~((sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2); 1386 hw->intr_mask &= ~((sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
1353 sky2_write32(hw, B0_IMSK, hw->intr_mask); 1387 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1354 local_irq_enable(); 1388 spin_unlock_irq(&hw->hw_lock);
1355 1389
1356 flush_scheduled_work(); 1390 flush_scheduled_work();
1357 1391
@@ -1633,10 +1667,10 @@ static void sky2_phy_task(void *arg)
1633out: 1667out:
1634 up(&sky2->phy_sema); 1668 up(&sky2->phy_sema);
1635 1669
1636 local_irq_disable(); 1670 spin_lock_irq(&hw->hw_lock);
1637 hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; 1671 hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2;
1638 sky2_write32(hw, B0_IMSK, hw->intr_mask); 1672 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1639 local_irq_enable(); 1673 spin_unlock_irq(&hw->hw_lock);
1640} 1674}
1641 1675
1642 1676
@@ -1863,6 +1897,17 @@ static int sky2_poll(struct net_device *dev0, int *budget)
1863 1897
1864 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); 1898 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1865 1899
1900 /*
1901 * Kick the STAT_LEV_TIMER_CTRL timer.
1902 * This fixes my hangs on Yukon-EC (0xb6) rev 1.
1903 * The if clause is there to start the timer only if it has been
1904 * configured correctly and not been disabled via ethtool.
1905 */
1906 if (sky2_read8(hw, STAT_LEV_TIMER_CTRL) == TIM_START) {
1907 sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_STOP);
1908 sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START);
1909 }
1910
1866 hwidx = sky2_read16(hw, STAT_PUT_IDX); 1911 hwidx = sky2_read16(hw, STAT_PUT_IDX);
1867 BUG_ON(hwidx >= STATUS_RING_SIZE); 1912 BUG_ON(hwidx >= STATUS_RING_SIZE);
1868 rmb(); 1913 rmb();
@@ -1945,16 +1990,19 @@ exit_loop:
1945 sky2_tx_check(hw, 0, tx_done[0]); 1990 sky2_tx_check(hw, 0, tx_done[0]);
1946 sky2_tx_check(hw, 1, tx_done[1]); 1991 sky2_tx_check(hw, 1, tx_done[1]);
1947 1992
1993 if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
1994 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
1995 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
1996 }
1997
1948 if (likely(work_done < to_do)) { 1998 if (likely(work_done < to_do)) {
1949 /* need to restart TX timer */ 1999 spin_lock_irq(&hw->hw_lock);
1950 if (is_ec_a1(hw)) { 2000 __netif_rx_complete(dev0);
1951 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
1952 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
1953 }
1954 2001
1955 netif_rx_complete(dev0);
1956 hw->intr_mask |= Y2_IS_STAT_BMU; 2002 hw->intr_mask |= Y2_IS_STAT_BMU;
1957 sky2_write32(hw, B0_IMSK, hw->intr_mask); 2003 sky2_write32(hw, B0_IMSK, hw->intr_mask);
2004 spin_unlock_irq(&hw->hw_lock);
2005
1958 return 0; 2006 return 0;
1959 } else { 2007 } else {
1960 *budget -= work_done; 2008 *budget -= work_done;
@@ -2017,13 +2065,13 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2017 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { 2065 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
2018 u16 pci_err; 2066 u16 pci_err;
2019 2067
2020 pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err); 2068 pci_err = sky2_pci_read16(hw, PCI_STATUS);
2021 if (net_ratelimit()) 2069 if (net_ratelimit())
2022 printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", 2070 printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n",
2023 pci_name(hw->pdev), pci_err); 2071 pci_name(hw->pdev), pci_err);
2024 2072
2025 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2073 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2026 pci_write_config_word(hw->pdev, PCI_STATUS, 2074 sky2_pci_write16(hw, PCI_STATUS,
2027 pci_err | PCI_STATUS_ERROR_BITS); 2075 pci_err | PCI_STATUS_ERROR_BITS);
2028 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 2076 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2029 } 2077 }
@@ -2032,7 +2080,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2032 /* PCI-Express uncorrectable Error occurred */ 2080 /* PCI-Express uncorrectable Error occurred */
2033 u32 pex_err; 2081 u32 pex_err;
2034 2082
2035 pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err); 2083 pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
2036 2084
2037 if (net_ratelimit()) 2085 if (net_ratelimit())
2038 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", 2086 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n",
@@ -2040,7 +2088,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2040 2088
2041 /* clear the interrupt */ 2089 /* clear the interrupt */
2042 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2090 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2043 pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, 2091 sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
2044 0xffffffffUL); 2092 0xffffffffUL);
2045 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 2093 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2046 2094
@@ -2086,6 +2134,7 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
2086 2134
2087 hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2); 2135 hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
2088 sky2_write32(hw, B0_IMSK, hw->intr_mask); 2136 sky2_write32(hw, B0_IMSK, hw->intr_mask);
2137
2089 schedule_work(&sky2->phy_task); 2138 schedule_work(&sky2->phy_task);
2090} 2139}
2091 2140
@@ -2099,6 +2148,7 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
2099 if (status == 0 || status == ~0) 2148 if (status == 0 || status == ~0)
2100 return IRQ_NONE; 2149 return IRQ_NONE;
2101 2150
2151 spin_lock(&hw->hw_lock);
2102 if (status & Y2_IS_HW_ERR) 2152 if (status & Y2_IS_HW_ERR)
2103 sky2_hw_intr(hw); 2153 sky2_hw_intr(hw);
2104 2154
@@ -2127,7 +2177,7 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
2127 2177
2128 sky2_write32(hw, B0_Y2_SP_ICR, 2); 2178 sky2_write32(hw, B0_Y2_SP_ICR, 2);
2129 2179
2130 sky2_read32(hw, B0_IMSK); 2180 spin_unlock(&hw->hw_lock);
2131 2181
2132 return IRQ_HANDLED; 2182 return IRQ_HANDLED;
2133} 2183}
@@ -2170,7 +2220,7 @@ static int sky2_reset(struct sky2_hw *hw)
2170{ 2220{
2171 u16 status; 2221 u16 status;
2172 u8 t8, pmd_type; 2222 u8 t8, pmd_type;
2173 int i, err; 2223 int i;
2174 2224
2175 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2225 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2176 2226
@@ -2192,25 +2242,18 @@ static int sky2_reset(struct sky2_hw *hw)
2192 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2242 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2193 2243
2194 /* clear PCI errors, if any */ 2244 /* clear PCI errors, if any */
2195 err = pci_read_config_word(hw->pdev, PCI_STATUS, &status); 2245 status = sky2_pci_read16(hw, PCI_STATUS);
2196 if (err)
2197 goto pci_err;
2198 2246
2199 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2247 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2200 err = pci_write_config_word(hw->pdev, PCI_STATUS, 2248 sky2_pci_write16(hw, PCI_STATUS, status | PCI_STATUS_ERROR_BITS);
2201 status | PCI_STATUS_ERROR_BITS); 2249
2202 if (err)
2203 goto pci_err;
2204 2250
2205 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2251 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2206 2252
2207 /* clear any PEX errors */ 2253 /* clear any PEX errors */
2208 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) { 2254 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
2209 err = pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, 2255 sky2_pci_write32(hw, PEX_UNC_ERR_STAT, 0xffffffffUL);
2210 0xffffffffUL); 2256
2211 if (err)
2212 goto pci_err;
2213 }
2214 2257
2215 pmd_type = sky2_read8(hw, B2_PMD_TYP); 2258 pmd_type = sky2_read8(hw, B2_PMD_TYP);
2216 hw->copper = !(pmd_type == 'L' || pmd_type == 'S'); 2259 hw->copper = !(pmd_type == 'L' || pmd_type == 'S');
@@ -2309,8 +2352,7 @@ static int sky2_reset(struct sky2_hw *hw)
2309 sky2_write8(hw, STAT_FIFO_ISR_WM, 16); 2352 sky2_write8(hw, STAT_FIFO_ISR_WM, 16);
2310 2353
2311 sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000)); 2354 sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000));
2312 sky2_write32(hw, STAT_LEV_TIMER_INI, sky2_us2clk(hw, 100)); 2355 sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 7));
2313 sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 20));
2314 } 2356 }
2315 2357
2316 /* enable status unit */ 2358 /* enable status unit */
@@ -2321,14 +2363,6 @@ static int sky2_reset(struct sky2_hw *hw)
2321 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); 2363 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2322 2364
2323 return 0; 2365 return 0;
2324
2325pci_err:
2326 /* This is to catch a BIOS bug workaround where
2327 * mmconfig table doesn't have other buses.
2328 */
2329 printk(KERN_ERR PFX "%s: can't access PCI config space\n",
2330 pci_name(hw->pdev));
2331 return err;
2332} 2366}
2333 2367
2334static u32 sky2_supported_modes(const struct sky2_hw *hw) 2368static u32 sky2_supported_modes(const struct sky2_hw *hw)
@@ -2852,11 +2886,11 @@ static int sky2_set_coalesce(struct net_device *dev,
2852 (ecmd->rx_coalesce_usecs_irq < tmin || ecmd->rx_coalesce_usecs_irq > tmax)) 2886 (ecmd->rx_coalesce_usecs_irq < tmin || ecmd->rx_coalesce_usecs_irq > tmax))
2853 return -EINVAL; 2887 return -EINVAL;
2854 2888
2855 if (ecmd->tx_max_coalesced_frames > 0xffff) 2889 if (ecmd->tx_max_coalesced_frames >= TX_RING_SIZE-1)
2856 return -EINVAL; 2890 return -EINVAL;
2857 if (ecmd->rx_max_coalesced_frames > 0xff) 2891 if (ecmd->rx_max_coalesced_frames > RX_MAX_PENDING)
2858 return -EINVAL; 2892 return -EINVAL;
2859 if (ecmd->rx_max_coalesced_frames_irq > 0xff) 2893 if (ecmd->rx_max_coalesced_frames_irq >RX_MAX_PENDING)
2860 return -EINVAL; 2894 return -EINVAL;
2861 2895
2862 if (ecmd->tx_coalesce_usecs == 0) 2896 if (ecmd->tx_coalesce_usecs == 0)
@@ -3198,17 +3232,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3198 } 3232 }
3199 } 3233 }
3200 3234
3201#ifdef __BIG_ENDIAN
3202 /* byte swap descriptors in hardware */
3203 {
3204 u32 reg;
3205
3206 pci_read_config_dword(pdev, PCI_DEV_REG2, &reg);
3207 reg |= PCI_REV_DESC;
3208 pci_write_config_dword(pdev, PCI_DEV_REG2, reg);
3209 }
3210#endif
3211
3212 err = -ENOMEM; 3235 err = -ENOMEM;
3213 hw = kzalloc(sizeof(*hw), GFP_KERNEL); 3236 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
3214 if (!hw) { 3237 if (!hw) {
@@ -3226,6 +3249,18 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3226 goto err_out_free_hw; 3249 goto err_out_free_hw;
3227 } 3250 }
3228 hw->pm_cap = pm_cap; 3251 hw->pm_cap = pm_cap;
3252 spin_lock_init(&hw->hw_lock);
3253
3254#ifdef __BIG_ENDIAN
3255 /* byte swap descriptors in hardware */
3256 {
3257 u32 reg;
3258
3259 reg = sky2_pci_read32(hw, PCI_DEV_REG2);
3260 reg |= PCI_REV_DESC;
3261 sky2_pci_write32(hw, PCI_DEV_REG2, reg);
3262 }
3263#endif
3229 3264
3230 /* ring for status responses */ 3265 /* ring for status responses */
3231 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES, 3266 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index fd12c289a238..3edb98075e0a 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -5,14 +5,22 @@
5#define _SKY2_H 5#define _SKY2_H
6 6
7/* PCI config registers */ 7/* PCI config registers */
8#define PCI_DEV_REG1 0x40 8enum {
9#define PCI_DEV_REG2 0x44 9 PCI_DEV_REG1 = 0x40,
10#define PCI_DEV_STATUS 0x7c 10 PCI_DEV_REG2 = 0x44,
11#define PCI_OS_PCI_X (1<<26) 11 PCI_DEV_STATUS = 0x7c,
12 PCI_DEV_REG3 = 0x80,
13 PCI_DEV_REG4 = 0x84,
14 PCI_DEV_REG5 = 0x88,
15};
12 16
13#define PEX_LNK_STAT 0xf2 17enum {
14#define PEX_UNC_ERR_STAT 0x104 18 PEX_DEV_CAP = 0xe4,
15#define PEX_DEV_CTRL 0xe8 19 PEX_DEV_CTRL = 0xe8,
20 PEX_DEV_STA = 0xea,
21 PEX_LNK_STAT = 0xf2,
22 PEX_UNC_ERR_STAT= 0x104,
23};
16 24
17/* Yukon-2 */ 25/* Yukon-2 */
18enum pci_dev_reg_1 { 26enum pci_dev_reg_1 {
@@ -37,6 +45,25 @@ enum pci_dev_reg_2 {
37 PCI_USEDATA64 = 1<<0, /* Use 64Bit Data bus ext */ 45 PCI_USEDATA64 = 1<<0, /* Use 64Bit Data bus ext */
38}; 46};
39 47
48/* PCI_OUR_REG_4 32 bit Our Register 4 (Yukon-ECU only) */
49enum pci_dev_reg_4 {
50 /* (Link Training & Status State Machine) */
51 P_TIMER_VALUE_MSK = 0xffL<<16, /* Bit 23..16: Timer Value Mask */
52 /* (Active State Power Management) */
53 P_FORCE_ASPM_REQUEST = 1<<15, /* Force ASPM Request (A1 only) */
54 P_ASPM_GPHY_LINK_DOWN = 1<<14, /* GPHY Link Down (A1 only) */
55 P_ASPM_INT_FIFO_EMPTY = 1<<13, /* Internal FIFO Empty (A1 only) */
56 P_ASPM_CLKRUN_REQUEST = 1<<12, /* CLKRUN Request (A1 only) */
57
58 P_ASPM_FORCE_CLKREQ_ENA = 1<<4, /* Force CLKREQ Enable (A1b only) */
59 P_ASPM_CLKREQ_PAD_CTL = 1<<3, /* CLKREQ PAD Control (A1 only) */
60 P_ASPM_A1_MODE_SELECT = 1<<2, /* A1 Mode Select (A1 only) */
61 P_CLK_GATE_PEX_UNIT_ENA = 1<<1, /* Enable Gate PEX Unit Clock */
62 P_CLK_GATE_ROOT_COR_ENA = 1<<0, /* Enable Gate Root Core Clock */
63 P_ASPM_CONTROL_MSK = P_FORCE_ASPM_REQUEST | P_ASPM_GPHY_LINK_DOWN
64 | P_ASPM_CLKRUN_REQUEST | P_ASPM_INT_FIFO_EMPTY,
65};
66
40 67
41#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \ 68#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
42 PCI_STATUS_SIG_SYSTEM_ERROR | \ 69 PCI_STATUS_SIG_SYSTEM_ERROR | \
@@ -507,6 +534,16 @@ enum {
507}; 534};
508#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs)) 535#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs))
509 536
537/* Q_F 32 bit Flag Register */
538enum {
539 F_ALM_FULL = 1<<27, /* Rx FIFO: almost full */
540 F_EMPTY = 1<<27, /* Tx FIFO: empty flag */
541 F_FIFO_EOF = 1<<26, /* Tag (EOF Flag) bit in FIFO */
542 F_WM_REACHED = 1<<25, /* Watermark reached */
543 F_M_RX_RAM_DIS = 1<<24, /* MAC Rx RAM Read Port disable */
544 F_FIFO_LEVEL = 0x1fL<<16, /* Bit 23..16: # of Qwords in FIFO */
545 F_WATER_MARK = 0x0007ffL, /* Bit 10.. 0: Watermark */
546};
510 547
511/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/ 548/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/
512enum { 549enum {
@@ -909,10 +946,12 @@ enum {
909 PHY_BCOM_ID1_C0 = 0x6044, 946 PHY_BCOM_ID1_C0 = 0x6044,
910 PHY_BCOM_ID1_C5 = 0x6047, 947 PHY_BCOM_ID1_C5 = 0x6047,
911 948
912 PHY_MARV_ID1_B0 = 0x0C23, /* Yukon (PHY 88E1011) */ 949 PHY_MARV_ID1_B0 = 0x0C23, /* Yukon (PHY 88E1011) */
913 PHY_MARV_ID1_B2 = 0x0C25, /* Yukon-Plus (PHY 88E1011) */ 950 PHY_MARV_ID1_B2 = 0x0C25, /* Yukon-Plus (PHY 88E1011) */
914 PHY_MARV_ID1_C2 = 0x0CC2, /* Yukon-EC (PHY 88E1111) */ 951 PHY_MARV_ID1_C2 = 0x0CC2, /* Yukon-EC (PHY 88E1111) */
915 PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */ 952 PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */
953 PHY_MARV_ID1_FE = 0x0C83, /* Yukon-FE (PHY 88E3082 Rev.A1) */
954 PHY_MARV_ID1_ECU= 0x0CB0, /* Yukon-ECU (PHY 88E1149 Rev.B2?) */
916}; 955};
917 956
918/* Advertisement register bits */ 957/* Advertisement register bits */
@@ -1837,8 +1876,9 @@ struct sky2_port {
1837struct sky2_hw { 1876struct sky2_hw {
1838 void __iomem *regs; 1877 void __iomem *regs;
1839 struct pci_dev *pdev; 1878 struct pci_dev *pdev;
1840 u32 intr_mask;
1841 struct net_device *dev[2]; 1879 struct net_device *dev[2];
1880 spinlock_t hw_lock;
1881 u32 intr_mask;
1842 1882
1843 int pm_cap; 1883 int pm_cap;
1844 int msi; 1884 int msi;
@@ -1912,4 +1952,25 @@ static inline void gma_set_addr(struct sky2_hw *hw, unsigned port, unsigned reg,
1912 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8)); 1952 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8));
1913 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8)); 1953 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8));
1914} 1954}
1955
1956/* PCI config space access */
1957static inline u32 sky2_pci_read32(const struct sky2_hw *hw, unsigned reg)
1958{
1959 return sky2_read32(hw, Y2_CFG_SPC + reg);
1960}
1961
1962static inline u16 sky2_pci_read16(const struct sky2_hw *hw, unsigned reg)
1963{
1964 return sky2_read16(hw, Y2_CFG_SPC + reg);
1965}
1966
1967static inline void sky2_pci_write32(struct sky2_hw *hw, unsigned reg, u32 val)
1968{
1969 sky2_write32(hw, Y2_CFG_SPC + reg, val);
1970}
1971
1972static inline void sky2_pci_write16(struct sky2_hw *hw, unsigned reg, u16 val)
1973{
1974 sky2_write16(hw, Y2_CFG_SPC + reg, val);
1975}
1915#endif 1976#endif
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 0702f0eeb784..44024c76d187 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4636,9 +4636,9 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4636 } 4636 }
4637 4637
4638 default: 4638 default:
4639 IPW_ERROR("Unknown notification: " 4639 IPW_DEBUG_NOTIF("Unknown notification: "
4640 "subtype=%d,flags=0x%2x,size=%d\n", 4640 "subtype=%d,flags=0x%2x,size=%d\n",
4641 notif->subtype, notif->flags, notif->size); 4641 notif->subtype, notif->flags, notif->size);
4642 } 4642 }
4643} 4643}
4644 4644
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6912399d0937..6f50cc9323d9 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -55,21 +55,13 @@ config DASD_DIAG
55 Disks under VM. If you are not running under VM or unsure what it is, 55 Disks under VM. If you are not running under VM or unsure what it is,
56 say "N". 56 say "N".
57 57
58config DASD_EER
59 tristate "Extended error reporting (EER)"
60 depends on DASD
61 help
62 This driver provides a character device interface to the
63 DASD extended error reporting. This is only needed if you want to
64 use applications written for the EER facility.
65
66config DASD_CMB 58config DASD_CMB
67 tristate "Compatibility interface for DASD channel measurement blocks" 59 tristate "Compatibility interface for DASD channel measurement blocks"
68 depends on DASD 60 depends on DASD
69 help 61 help
70 This driver provides an additional interface to the channel 62 This driver provides an additional interface to the channel measurement
71 measurement facility, which is normally accessed though sysfs, with 63 facility, which is normally accessed though sysfs, with a set of
72 a set of ioctl functions specific to the dasd driver. 64 ioctl functions specific to the dasd driver.
73 This is only needed if you want to use applications written for 65 This is only needed if you want to use applications written for
74 linux-2.4 dasd channel measurement facility interface. 66 linux-2.4 dasd channel measurement facility interface.
75 67
diff --git a/drivers/s390/block/Makefile b/drivers/s390/block/Makefile
index 0c0d871e8f51..58c6780134f7 100644
--- a/drivers/s390/block/Makefile
+++ b/drivers/s390/block/Makefile
@@ -5,7 +5,6 @@
5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o 5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o
6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o 6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o
7dasd_diag_mod-objs := dasd_diag.o 7dasd_diag_mod-objs := dasd_diag.o
8dasd_eer_mod-objs := dasd_eer.o
9dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \ 8dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \
10 dasd_genhd.o dasd_erp.o 9 dasd_genhd.o dasd_erp.o
11 10
@@ -14,6 +13,5 @@ obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o
14obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o 13obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o
15obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o 14obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o
16obj-$(CONFIG_DASD_CMB) += dasd_cmb.o 15obj-$(CONFIG_DASD_CMB) += dasd_cmb.o
17obj-$(CONFIG_DASD_EER) += dasd_eer.o
18obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o 16obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o
19obj-$(CONFIG_DCSSBLK) += dcssblk.o 17obj-$(CONFIG_DCSSBLK) += dcssblk.o
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 08c88fcd8963..af1d5b404cee 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -18,7 +18,6 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
20#include <linux/hdreg.h> 20#include <linux/hdreg.h>
21#include <linux/notifier.h>
22 21
23#include <asm/ccwdev.h> 22#include <asm/ccwdev.h>
24#include <asm/ebcdic.h> 23#include <asm/ebcdic.h>
@@ -58,7 +57,6 @@ static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
58static void dasd_flush_ccw_queue(struct dasd_device *, int); 57static void dasd_flush_ccw_queue(struct dasd_device *, int);
59static void dasd_tasklet(struct dasd_device *); 58static void dasd_tasklet(struct dasd_device *);
60static void do_kick_device(void *data); 59static void do_kick_device(void *data);
61static void dasd_disable_eer(struct dasd_device *device);
62 60
63/* 61/*
64 * SECTION: Operations on the device structure. 62 * SECTION: Operations on the device structure.
@@ -153,10 +151,13 @@ dasd_state_new_to_known(struct dasd_device *device)
153static inline void 151static inline void
154dasd_state_known_to_new(struct dasd_device * device) 152dasd_state_known_to_new(struct dasd_device * device)
155{ 153{
156 /* disable extended error reporting for this device */
157 dasd_disable_eer(device);
158 /* Forget the discipline information. */ 154 /* Forget the discipline information. */
155 if (device->discipline)
156 module_put(device->discipline->owner);
159 device->discipline = NULL; 157 device->discipline = NULL;
158 if (device->base_discipline)
159 module_put(device->base_discipline->owner);
160 device->base_discipline = NULL;
160 device->state = DASD_STATE_NEW; 161 device->state = DASD_STATE_NEW;
161 162
162 dasd_free_queue(device); 163 dasd_free_queue(device);
@@ -871,9 +872,6 @@ dasd_handle_state_change_pending(struct dasd_device *device)
871 struct dasd_ccw_req *cqr; 872 struct dasd_ccw_req *cqr;
872 struct list_head *l, *n; 873 struct list_head *l, *n;
873 874
874 /* first of all call extended error reporting */
875 dasd_write_eer_trigger(DASD_EER_STATECHANGE, device, NULL);
876
877 device->stopped &= ~DASD_STOPPED_PENDING; 875 device->stopped &= ~DASD_STOPPED_PENDING;
878 876
879 /* restart all 'running' IO on queue */ 877 /* restart all 'running' IO on queue */
@@ -1093,19 +1091,6 @@ restart:
1093 } 1091 }
1094 goto restart; 1092 goto restart;
1095 } 1093 }
1096
1097 /* first of all call extended error reporting */
1098 if (device->eer && cqr->status == DASD_CQR_FAILED) {
1099 dasd_write_eer_trigger(DASD_EER_FATALERROR,
1100 device, cqr);
1101
1102 /* restart request */
1103 cqr->status = DASD_CQR_QUEUED;
1104 cqr->retries = 255;
1105 device->stopped |= DASD_STOPPED_QUIESCE;
1106 goto restart;
1107 }
1108
1109 /* Process finished ERP request. */ 1094 /* Process finished ERP request. */
1110 if (cqr->refers) { 1095 if (cqr->refers) {
1111 __dasd_process_erp(device, cqr); 1096 __dasd_process_erp(device, cqr);
@@ -1243,8 +1228,7 @@ __dasd_start_head(struct dasd_device * device)
1243 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1228 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1244 /* check FAILFAST */ 1229 /* check FAILFAST */
1245 if (device->stopped & ~DASD_STOPPED_PENDING && 1230 if (device->stopped & ~DASD_STOPPED_PENDING &&
1246 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && 1231 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) {
1247 (!device->eer)) {
1248 cqr->status = DASD_CQR_FAILED; 1232 cqr->status = DASD_CQR_FAILED;
1249 dasd_schedule_bh(device); 1233 dasd_schedule_bh(device);
1250 } 1234 }
@@ -1880,9 +1864,10 @@ dasd_generic_remove (struct ccw_device *cdev)
1880 */ 1864 */
1881int 1865int
1882dasd_generic_set_online (struct ccw_device *cdev, 1866dasd_generic_set_online (struct ccw_device *cdev,
1883 struct dasd_discipline *discipline) 1867 struct dasd_discipline *base_discipline)
1884 1868
1885{ 1869{
1870 struct dasd_discipline *discipline;
1886 struct dasd_device *device; 1871 struct dasd_device *device;
1887 int rc; 1872 int rc;
1888 1873
@@ -1890,6 +1875,7 @@ dasd_generic_set_online (struct ccw_device *cdev,
1890 if (IS_ERR(device)) 1875 if (IS_ERR(device))
1891 return PTR_ERR(device); 1876 return PTR_ERR(device);
1892 1877
1878 discipline = base_discipline;
1893 if (device->features & DASD_FEATURE_USEDIAG) { 1879 if (device->features & DASD_FEATURE_USEDIAG) {
1894 if (!dasd_diag_discipline_pointer) { 1880 if (!dasd_diag_discipline_pointer) {
1895 printk (KERN_WARNING 1881 printk (KERN_WARNING
@@ -1901,6 +1887,16 @@ dasd_generic_set_online (struct ccw_device *cdev,
1901 } 1887 }
1902 discipline = dasd_diag_discipline_pointer; 1888 discipline = dasd_diag_discipline_pointer;
1903 } 1889 }
1890 if (!try_module_get(base_discipline->owner)) {
1891 dasd_delete_device(device);
1892 return -EINVAL;
1893 }
1894 if (!try_module_get(discipline->owner)) {
1895 module_put(base_discipline->owner);
1896 dasd_delete_device(device);
1897 return -EINVAL;
1898 }
1899 device->base_discipline = base_discipline;
1904 device->discipline = discipline; 1900 device->discipline = discipline;
1905 1901
1906 rc = discipline->check_device(device); 1902 rc = discipline->check_device(device);
@@ -1909,6 +1905,8 @@ dasd_generic_set_online (struct ccw_device *cdev,
1909 "dasd_generic couldn't online device %s " 1905 "dasd_generic couldn't online device %s "
1910 "with discipline %s rc=%i\n", 1906 "with discipline %s rc=%i\n",
1911 cdev->dev.bus_id, discipline->name, rc); 1907 cdev->dev.bus_id, discipline->name, rc);
1908 module_put(discipline->owner);
1909 module_put(base_discipline->owner);
1912 dasd_delete_device(device); 1910 dasd_delete_device(device);
1913 return rc; 1911 return rc;
1914 } 1912 }
@@ -1986,9 +1984,6 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
1986 switch (event) { 1984 switch (event) {
1987 case CIO_GONE: 1985 case CIO_GONE:
1988 case CIO_NO_PATH: 1986 case CIO_NO_PATH:
1989 /* first of all call extended error reporting */
1990 dasd_write_eer_trigger(DASD_EER_NOPATH, device, NULL);
1991
1992 if (device->state < DASD_STATE_BASIC) 1987 if (device->state < DASD_STATE_BASIC)
1993 break; 1988 break;
1994 /* Device is active. We want to keep it. */ 1989 /* Device is active. We want to keep it. */
@@ -2046,51 +2041,6 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
2046 put_driver(drv); 2041 put_driver(drv);
2047} 2042}
2048 2043
2049/*
2050 * notifications for extended error reports
2051 */
2052static struct notifier_block *dasd_eer_chain;
2053
2054int
2055dasd_register_eer_notifier(struct notifier_block *nb)
2056{
2057 return notifier_chain_register(&dasd_eer_chain, nb);
2058}
2059
2060int
2061dasd_unregister_eer_notifier(struct notifier_block *nb)
2062{
2063 return notifier_chain_unregister(&dasd_eer_chain, nb);
2064}
2065
2066/*
2067 * Notify the registered error reporting module of a problem
2068 */
2069void
2070dasd_write_eer_trigger(unsigned int id, struct dasd_device *device,
2071 struct dasd_ccw_req *cqr)
2072{
2073 if (device->eer) {
2074 struct dasd_eer_trigger temp;
2075 temp.id = id;
2076 temp.device = device;
2077 temp.cqr = cqr;
2078 notifier_call_chain(&dasd_eer_chain, DASD_EER_TRIGGER,
2079 (void *)&temp);
2080 }
2081}
2082
2083/*
2084 * Tell the registered error reporting module to disable error reporting for
2085 * a given device and to cleanup any private data structures on that device.
2086 */
2087static void
2088dasd_disable_eer(struct dasd_device *device)
2089{
2090 notifier_call_chain(&dasd_eer_chain, DASD_EER_DISABLE, (void *)device);
2091}
2092
2093
2094static int __init 2044static int __init
2095dasd_init(void) 2045dasd_init(void)
2096{ 2046{
@@ -2172,11 +2122,6 @@ EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2172EXPORT_SYMBOL_GPL(dasd_generic_set_offline); 2122EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2173EXPORT_SYMBOL_GPL(dasd_generic_auto_online); 2123EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
2174 2124
2175EXPORT_SYMBOL(dasd_register_eer_notifier);
2176EXPORT_SYMBOL(dasd_unregister_eer_notifier);
2177EXPORT_SYMBOL(dasd_write_eer_trigger);
2178
2179
2180/* 2125/*
2181 * Overrides for Emacs so that we follow Linus's tabbing style. 2126 * Overrides for Emacs so that we follow Linus's tabbing style.
2182 * Emacs will notice this stuff at the end of the file and automatically 2127 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index c811380b9079..4ee0f934e325 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -1108,9 +1108,6 @@ dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
1108 case 0x0B: 1108 case 0x0B:
1109 DEV_MESSAGE(KERN_WARNING, device, "%s", 1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1110 "FORMAT F - Volume is suspended duplex"); 1110 "FORMAT F - Volume is suspended duplex");
1111 /* call extended error reporting (EER) */
1112 dasd_write_eer_trigger(DASD_EER_PPRCSUSPEND, device,
1113 erp->refers);
1114 break; 1111 break;
1115 case 0x0C: 1112 case 0x0C:
1116 DEV_MESSAGE(KERN_WARNING, device, "%s", 1113 DEV_MESSAGE(KERN_WARNING, device, "%s",
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index e15dd7978050..bc3823d35223 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -29,7 +29,6 @@
29#define DASD_ECKD_CCW_PSF 0x27 29#define DASD_ECKD_CCW_PSF 0x27
30#define DASD_ECKD_CCW_RSSD 0x3e 30#define DASD_ECKD_CCW_RSSD 0x3e
31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47 31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
32#define DASD_ECKD_CCW_SNSS 0x54
33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63 32#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63
34#define DASD_ECKD_CCW_WRITE_MT 0x85 33#define DASD_ECKD_CCW_WRITE_MT 0x85
35#define DASD_ECKD_CCW_READ_MT 0x86 34#define DASD_ECKD_CCW_READ_MT 0x86
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
deleted file mode 100644
index f70cd7716b24..000000000000
--- a/drivers/s390/block/dasd_eer.c
+++ /dev/null
@@ -1,1090 +0,0 @@
1/*
2 * character device driver for extended error reporting
3 *
4 *
5 * Copyright (C) 2005 IBM Corporation
6 * extended error reporting for DASD ECKD devices
7 * Author(s): Stefan Weinhuber <wein@de.ibm.com>
8 *
9 */
10
11#include <linux/init.h>
12#include <linux/fs.h>
13#include <linux/kernel.h>
14#include <linux/miscdevice.h>
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/device.h>
18#include <linux/workqueue.h>
19#include <linux/poll.h>
20#include <linux/notifier.h>
21
22#include <asm/uaccess.h>
23#include <asm/semaphore.h>
24#include <asm/atomic.h>
25#include <asm/ebcdic.h>
26
27#include "dasd_int.h"
28#include "dasd_eckd.h"
29
30
31MODULE_LICENSE("GPL");
32
33MODULE_AUTHOR("Stefan Weinhuber <wein@de.ibm.com>");
34MODULE_DESCRIPTION("DASD extended error reporting module");
35
36
37#ifdef PRINTK_HEADER
38#undef PRINTK_HEADER
39#endif /* PRINTK_HEADER */
40#define PRINTK_HEADER "dasd(eer):"
41
42
43
44
45
46/*****************************************************************************/
47/* the internal buffer */
48/*****************************************************************************/
49
50/*
51 * The internal buffer is meant to store obaque blobs of data, so it doesn't
52 * know of higher level concepts like triggers.
53 * It consists of a number of pages that are used as a ringbuffer. Each data
54 * blob is stored in a simple record that consists of an integer, which
55 * contains the size of the following data, and the data bytes themselfes.
56 *
57 * To allow for multiple independent readers we create one internal buffer
58 * each time the device is opened and destroy the buffer when the file is
59 * closed again.
60 *
61 * One record can be written to a buffer by using the functions
62 * - dasd_eer_start_record (one time per record to write the size to the buffer
63 * and reserve the space for the data)
64 * - dasd_eer_write_buffer (one or more times per record to write the data)
65 * The data can be written in several steps but you will have to compute
66 * the total size up front for the invocation of dasd_eer_start_record.
67 * If the ringbuffer is full, dasd_eer_start_record will remove the required
68 * number of old records.
69 *
70 * A record is typically read in two steps, first read the integer that
71 * specifies the size of the following data, then read the data.
72 * Both can be done by
73 * - dasd_eer_read_buffer
74 *
75 * For all mentioned functions you need to get the bufferlock first and keep it
76 * until a complete record is written or read.
77 */
78
79
80/*
81 * Alle information necessary to keep track of an internal buffer is kept in
82 * a struct eerbuffer. The buffer specific to a file pointer is strored in
83 * the private_data field of that file. To be able to write data to all
84 * existing buffers, each buffer is also added to the bufferlist.
85 * If the user doesn't want to read a complete record in one go, we have to
86 * keep track of the rest of the record. residual stores the number of bytes
87 * that are still to deliver. If the rest of the record is invalidated between
88 * two reads then residual will be set to -1 so that the next read will fail.
89 * All entries in the eerbuffer structure are protected with the bufferlock.
90 * To avoid races between writing to a buffer on the one side and creating
91 * and destroying buffers on the other side, the bufferlock must also be used
92 * to protect the bufferlist.
93 */
94
95struct eerbuffer {
96 struct list_head list;
97 char **buffer;
98 int buffersize;
99 int buffer_page_count;
100 int head;
101 int tail;
102 int residual;
103};
104
105LIST_HEAD(bufferlist);
106
107static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED;
108
109DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
110
111/*
112 * How many free bytes are available on the buffer.
113 * needs to be called with bufferlock held
114 */
115static int
116dasd_eer_get_free_bytes(struct eerbuffer *eerb)
117{
118 if (eerb->head < eerb->tail) {
119 return eerb->tail - eerb->head - 1;
120 } else
121 return eerb->buffersize - eerb->head + eerb->tail -1;
122}
123
124/*
125 * How many bytes of buffer space are used.
126 * needs to be called with bufferlock held
127 */
128static int
129dasd_eer_get_filled_bytes(struct eerbuffer *eerb)
130{
131
132 if (eerb->head >= eerb->tail) {
133 return eerb->head - eerb->tail;
134 } else
135 return eerb->buffersize - eerb->tail + eerb->head;
136}
137
138/*
139 * The dasd_eer_write_buffer function just copies count bytes of data
140 * to the buffer. Make sure to call dasd_eer_start_record first, to
141 * make sure that enough free space is available.
142 * needs to be called with bufferlock held
143 */
144static void
145dasd_eer_write_buffer(struct eerbuffer *eerb, int count, char *data)
146{
147
148 unsigned long headindex,localhead;
149 unsigned long rest, len;
150 char *nextdata;
151
152 nextdata = data;
153 rest = count;
154 while (rest > 0) {
155 headindex = eerb->head / PAGE_SIZE;
156 localhead = eerb->head % PAGE_SIZE;
157 len = min(rest, (PAGE_SIZE - localhead));
158 memcpy(eerb->buffer[headindex]+localhead, nextdata, len);
159 nextdata += len;
160 rest -= len;
161 eerb->head += len;
162 if ( eerb->head == eerb->buffersize )
163 eerb->head = 0; /* wrap around */
164 if (eerb->head > eerb->buffersize) {
165 MESSAGE(KERN_ERR, "%s", "runaway buffer head.");
166 BUG();
167 }
168 }
169}
170
171/*
172 * needs to be called with bufferlock held
173 */
174static int
175dasd_eer_read_buffer(struct eerbuffer *eerb, int count, char *data)
176{
177
178 unsigned long tailindex,localtail;
179 unsigned long rest, len, finalcount;
180 char *nextdata;
181
182 finalcount = min(count, dasd_eer_get_filled_bytes(eerb));
183 nextdata = data;
184 rest = finalcount;
185 while (rest > 0) {
186 tailindex = eerb->tail / PAGE_SIZE;
187 localtail = eerb->tail % PAGE_SIZE;
188 len = min(rest, (PAGE_SIZE - localtail));
189 memcpy(nextdata, eerb->buffer[tailindex]+localtail, len);
190 nextdata += len;
191 rest -= len;
192 eerb->tail += len;
193 if ( eerb->tail == eerb->buffersize )
194 eerb->tail = 0; /* wrap around */
195 if (eerb->tail > eerb->buffersize) {
196 MESSAGE(KERN_ERR, "%s", "runaway buffer tail.");
197 BUG();
198 }
199 }
200 return finalcount;
201}
202
203/*
204 * Whenever you want to write a blob of data to the internal buffer you
205 * have to start by using this function first. It will write the number
206 * of bytes that will be written to the buffer. If necessary it will remove
207 * old records to make room for the new one.
208 * needs to be called with bufferlock held
209 */
210static int
211dasd_eer_start_record(struct eerbuffer *eerb, int count)
212{
213 int tailcount;
214 if (count + sizeof(count) > eerb->buffersize)
215 return -ENOMEM;
216 while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
217 if (eerb->residual > 0) {
218 eerb->tail += eerb->residual;
219 if (eerb->tail >= eerb->buffersize)
220 eerb->tail -= eerb->buffersize;
221 eerb->residual = -1;
222 }
223 dasd_eer_read_buffer(eerb, sizeof(tailcount),
224 (char*)(&tailcount));
225 eerb->tail += tailcount;
226 if (eerb->tail >= eerb->buffersize)
227 eerb->tail -= eerb->buffersize;
228 }
229 dasd_eer_write_buffer(eerb, sizeof(count), (char*)(&count));
230
231 return 0;
232};
233
234/*
235 * release pages that are not used anymore
236 */
237static void
238dasd_eer_free_buffer_pages(char **buf, int no_pages)
239{
240 int i;
241
242 for (i = 0; i < no_pages; ++i) {
243 free_page((unsigned long)buf[i]);
244 }
245}
246
247/*
248 * allocate a new set of memory pages
249 */
250static int
251dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
252{
253 int i;
254
255 for (i = 0; i < no_pages; ++i) {
256 buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
257 if (!buf[i]) {
258 dasd_eer_free_buffer_pages(buf, i);
259 return -ENOMEM;
260 }
261 }
262 return 0;
263}
264
265/*
266 * empty the buffer by resetting head and tail
267 * In case there is a half read data blob in the buffer, we set residual
268 * to -1 to indicate that the remainder of the blob is lost.
269 */
270static void
271dasd_eer_purge_buffer(struct eerbuffer *eerb)
272{
273 unsigned long flags;
274
275 spin_lock_irqsave(&bufferlock, flags);
276 if (eerb->residual > 0)
277 eerb->residual = -1;
278 eerb->tail=0;
279 eerb->head=0;
280 spin_unlock_irqrestore(&bufferlock, flags);
281}
282
283/*
284 * set the size of the buffer, newsize is the new number of pages to be used
285 * we don't try to copy any data back an forth, so any resize will also purge
286 * the buffer
287 */
288static int
289dasd_eer_resize_buffer(struct eerbuffer *eerb, int newsize)
290{
291 int i, oldcount, reuse;
292 char **new;
293 char **old;
294 unsigned long flags;
295
296 if (newsize < 1)
297 return -EINVAL;
298 if (eerb->buffer_page_count == newsize) {
299 /* documented behaviour is that any successfull invocation
300 * will purge all records */
301 dasd_eer_purge_buffer(eerb);
302 return 0;
303 }
304 new = kmalloc(newsize*sizeof(char*), GFP_KERNEL);
305 if (!new)
306 return -ENOMEM;
307
308 reuse=min(eerb->buffer_page_count, newsize);
309 for (i = 0; i < reuse; ++i) {
310 new[i] = eerb->buffer[i];
311 }
312 if (eerb->buffer_page_count < newsize) {
313 if (dasd_eer_allocate_buffer_pages(
314 &new[eerb->buffer_page_count],
315 newsize - eerb->buffer_page_count)) {
316 kfree(new);
317 return -ENOMEM;
318 }
319 }
320
321 spin_lock_irqsave(&bufferlock, flags);
322 old = eerb->buffer;
323 eerb->buffer = new;
324 if (eerb->residual > 0)
325 eerb->residual = -1;
326 eerb->tail = 0;
327 eerb->head = 0;
328 oldcount = eerb->buffer_page_count;
329 eerb->buffer_page_count = newsize;
330 spin_unlock_irqrestore(&bufferlock, flags);
331
332 if (oldcount > newsize) {
333 for (i = newsize; i < oldcount; ++i) {
334 free_page((unsigned long)old[i]);
335 }
336 }
337 kfree(old);
338
339 return 0;
340}
341
342
343/*****************************************************************************/
344/* The extended error reporting functionality */
345/*****************************************************************************/
346
347/*
348 * When a DASD device driver wants to report an error, it calls the
349 * function dasd_eer_write_trigger (via a notifier mechanism) and gives the
350 * respective trigger ID as parameter.
351 * Currently there are four kinds of triggers:
352 *
353 * DASD_EER_FATALERROR: all kinds of unrecoverable I/O problems
354 * DASD_EER_PPRCSUSPEND: PPRC was suspended
355 * DASD_EER_NOPATH: There is no path to the device left.
356 * DASD_EER_STATECHANGE: The state of the device has changed.
357 *
358 * For the first three triggers all required information can be supplied by
359 * the caller. For these triggers a record is written by the function
360 * dasd_eer_write_standard_trigger.
361 *
362 * When dasd_eer_write_trigger is called to write a DASD_EER_STATECHANGE
363 * trigger, we have to gather the necessary sense data first. We cannot queue
364 * the necessary SNSS (sense subsystem status) request immediatly, since we
365 * are likely to run in a deadlock situation. Instead, we schedule a
366 * work_struct that calls the function dasd_eer_sense_subsystem_status to
367 * create and start an SNSS request asynchronously.
368 *
369 * To avoid memory allocations at runtime, the necessary memory is allocated
370 * when the extended error reporting is enabled for a device (by
371 * dasd_eer_probe). There is one private eer data structure for each eer
372 * enabled DASD device. It contains memory for the work_struct, one SNSS cqr
373 * and a flags field that is used to coordinate the use of the cqr. The call
374 * to write a state change trigger can come in at any time, so we have one flag
375 * CQR_IN_USE that protects the cqr itself. When this flag indicates that the
376 * cqr is currently in use, dasd_eer_sense_subsystem_status cannot start a
377 * second request but sets the SNSS_REQUESTED flag instead.
378 *
379 * When the request is finished, the callback function dasd_eer_SNSS_cb
380 * is called. This function will invoke the function
381 * dasd_eer_write_SNSS_trigger to finally write the trigger. It will also
382 * check the SNSS_REQUESTED flag and if it is set it will call
383 * dasd_eer_sense_subsystem_status again.
384 *
385 * To avoid race conditions during the handling of the lock, the flags must
386 * be protected by the snsslock.
387 */
388
389struct dasd_eer_private {
390 struct dasd_ccw_req *cqr;
391 unsigned long flags;
392 struct work_struct worker;
393};
394
395static void dasd_eer_destroy(struct dasd_device *device,
396 struct dasd_eer_private *eer);
397static int
398dasd_eer_write_trigger(struct dasd_eer_trigger *trigger);
399static void dasd_eer_sense_subsystem_status(void *data);
400static int dasd_eer_notify(struct notifier_block *self,
401 unsigned long action, void *data);
402
403struct workqueue_struct *dasd_eer_workqueue;
404
405#define SNSS_DATA_SIZE 44
406static spinlock_t snsslock = SPIN_LOCK_UNLOCKED;
407
408#define DASD_EER_BUSID_SIZE 10
409struct dasd_eer_header {
410 __u32 total_size;
411 __u32 trigger;
412 __u64 tv_sec;
413 __u64 tv_usec;
414 char busid[DASD_EER_BUSID_SIZE];
415} __attribute__ ((packed));
416
417static struct notifier_block dasd_eer_nb = {
418 .notifier_call = dasd_eer_notify,
419};
420
421/*
422 * flags for use with dasd_eer_private
423 */
424#define CQR_IN_USE 0
425#define SNSS_REQUESTED 1
426
427/*
428 * This function checks if extended error reporting is available for a given
429 * dasd_device. If yes, then it creates and returns a struct dasd_eer,
430 * otherwise it returns an -EPERM error pointer.
431 */
432struct dasd_eer_private *
433dasd_eer_probe(struct dasd_device *device)
434{
435 struct dasd_eer_private *private;
436
437 if (!(device && device->discipline
438 && !strcmp(device->discipline->name, "ECKD"))) {
439 return ERR_PTR(-EPERM);
440 }
441 /* allocate the private data structure */
442 private = (struct dasd_eer_private *)kmalloc(
443 sizeof(struct dasd_eer_private), GFP_KERNEL);
444 if (!private) {
445 return ERR_PTR(-ENOMEM);
446 }
447 INIT_WORK(&private->worker, dasd_eer_sense_subsystem_status,
448 (void *)device);
449 private->cqr = dasd_kmalloc_request("ECKD",
450 1 /* SNSS */ ,
451 SNSS_DATA_SIZE ,
452 device);
453 if (!private->cqr) {
454 kfree(private);
455 return ERR_PTR(-ENOMEM);
456 }
457 private->flags = 0;
458 return private;
459};
460
461/*
462 * If our private SNSS request is queued, remove it from the
463 * dasd ccw queue so we can free the requests memory.
464 */
465static void
466dasd_eer_dequeue_SNSS_request(struct dasd_device *device,
467 struct dasd_eer_private *eer)
468{
469 struct list_head *lst, *nxt;
470 struct dasd_ccw_req *cqr, *erpcqr;
471 dasd_erp_fn_t erp_fn;
472
473 spin_lock_irq(get_ccwdev_lock(device->cdev));
474 list_for_each_safe(lst, nxt, &device->ccw_queue) {
475 cqr = list_entry(lst, struct dasd_ccw_req, list);
476 /* we are looking for two kinds or requests */
477 /* first kind: our SNSS request: */
478 if (cqr == eer->cqr) {
479 if (cqr->status == DASD_CQR_IN_IO)
480 device->discipline->term_IO(cqr);
481 list_del(&cqr->list);
482 break;
483 }
484 /* second kind: ERP requests for our SNSS request */
485 if (cqr->refers) {
486 /* If this erp request chain ends in our cqr, then */
487 /* cal the erp_postaction to clean it up */
488 erpcqr = cqr;
489 while (erpcqr->refers) {
490 erpcqr = erpcqr->refers;
491 }
492 if (erpcqr == eer->cqr) {
493 erp_fn = device->discipline->erp_postaction(
494 cqr);
495 erp_fn(cqr);
496 }
497 continue;
498 }
499 }
500 spin_unlock_irq(get_ccwdev_lock(device->cdev));
501}
502
503/*
504 * This function dismantles a struct dasd_eer that was created by
505 * dasd_eer_probe. Since we want to free our private data structure,
506 * we must make sure that the memory is not in use anymore.
507 * We have to flush the work queue and remove a possible SNSS request
508 * from the dasd queue.
509 */
510static void
511dasd_eer_destroy(struct dasd_device *device, struct dasd_eer_private *eer)
512{
513 flush_workqueue(dasd_eer_workqueue);
514 dasd_eer_dequeue_SNSS_request(device, eer);
515 dasd_kfree_request(eer->cqr, device);
516 kfree(eer);
517};
518
519/*
520 * enable the extended error reporting for a particular device
521 */
522static int
523dasd_eer_enable_on_device(struct dasd_device *device)
524{
525 void *eer;
526 if (!device)
527 return -ENODEV;
528 if (device->eer)
529 return 0;
530 if (!try_module_get(THIS_MODULE)) {
531 return -EINVAL;
532 }
533 eer = (void *)dasd_eer_probe(device);
534 if (IS_ERR(eer)) {
535 module_put(THIS_MODULE);
536 return PTR_ERR(eer);
537 }
538 device->eer = eer;
539 return 0;
540}
541
542/*
543 * enable the extended error reporting for a particular device
544 */
545static int
546dasd_eer_disable_on_device(struct dasd_device *device)
547{
548 struct dasd_eer_private *eer = device->eer;
549
550 if (!device)
551 return -ENODEV;
552 if (!device->eer)
553 return 0;
554 device->eer = NULL;
555 dasd_eer_destroy(device,eer);
556 module_put(THIS_MODULE);
557
558 return 0;
559}
560
561/*
562 * Set extended error reporting (eer)
563 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
564 */
565static int
566dasd_ioctl_set_eer(struct block_device *bdev, int no, long args)
567{
568 struct dasd_device *device;
569 int intval;
570
571 if (!capable(CAP_SYS_ADMIN))
572 return -EACCES;
573 if (bdev != bdev->bd_contains)
574 /* Error-reporting is not allowed for partitions */
575 return -EINVAL;
576 if (get_user(intval, (int __user *) args))
577 return -EFAULT;
578 device = bdev->bd_disk->private_data;
579 if (device == NULL)
580 return -ENODEV;
581
582 intval = (intval != 0);
583 DEV_MESSAGE (KERN_DEBUG, device,
584 "set eer on device to %d", intval);
585 if (intval)
586 return dasd_eer_enable_on_device(device);
587 else
588 return dasd_eer_disable_on_device(device);
589}
590
591/*
592 * Get value of extended error reporting.
593 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
594 */
595static int
596dasd_ioctl_get_eer(struct block_device *bdev, int no, long args)
597{
598 struct dasd_device *device;
599
600 device = bdev->bd_disk->private_data;
601 if (device == NULL)
602 return -ENODEV;
603 return put_user((device->eer != NULL), (int __user *) args);
604}
605
606/*
607 * The following function can be used for those triggers that have
608 * all necessary data available when the function is called.
609 * If the parameter cqr is not NULL, the chain of requests will be searched
610 * for valid sense data, and all valid sense data sets will be added to
611 * the triggers data.
612 */
613static int
614dasd_eer_write_standard_trigger(int trigger, struct dasd_device *device,
615 struct dasd_ccw_req *cqr)
616{
617 struct dasd_ccw_req *temp_cqr;
618 int data_size;
619 struct timeval tv;
620 struct dasd_eer_header header;
621 unsigned long flags;
622 struct eerbuffer *eerb;
623
624 /* go through cqr chain and count the valid sense data sets */
625 temp_cqr = cqr;
626 data_size = 0;
627 while (temp_cqr) {
628 if (temp_cqr->irb.esw.esw0.erw.cons)
629 data_size += 32;
630 temp_cqr = temp_cqr->refers;
631 }
632
633 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
634 header.trigger = trigger;
635 do_gettimeofday(&tv);
636 header.tv_sec = tv.tv_sec;
637 header.tv_usec = tv.tv_usec;
638 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
639
640 spin_lock_irqsave(&bufferlock, flags);
641 list_for_each_entry(eerb, &bufferlist, list) {
642 dasd_eer_start_record(eerb, header.total_size);
643 dasd_eer_write_buffer(eerb, sizeof(header), (char*)(&header));
644 temp_cqr = cqr;
645 while (temp_cqr) {
646 if (temp_cqr->irb.esw.esw0.erw.cons)
647 dasd_eer_write_buffer(eerb, 32, cqr->irb.ecw);
648 temp_cqr = temp_cqr->refers;
649 }
650 dasd_eer_write_buffer(eerb, 4,"EOR");
651 }
652 spin_unlock_irqrestore(&bufferlock, flags);
653
654 wake_up_interruptible(&dasd_eer_read_wait_queue);
655
656 return 0;
657}
658
659/*
660 * This function writes a DASD_EER_STATECHANGE trigger.
661 */
662static void
663dasd_eer_write_SNSS_trigger(struct dasd_device *device,
664 struct dasd_ccw_req *cqr)
665{
666 int data_size;
667 int snss_rc;
668 struct timeval tv;
669 struct dasd_eer_header header;
670 unsigned long flags;
671 struct eerbuffer *eerb;
672
673 snss_rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
674 if (snss_rc)
675 data_size = 0;
676 else
677 data_size = SNSS_DATA_SIZE;
678
679 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
680 header.trigger = DASD_EER_STATECHANGE;
681 do_gettimeofday(&tv);
682 header.tv_sec = tv.tv_sec;
683 header.tv_usec = tv.tv_usec;
684 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
685
686 spin_lock_irqsave(&bufferlock, flags);
687 list_for_each_entry(eerb, &bufferlist, list) {
688 dasd_eer_start_record(eerb, header.total_size);
689 dasd_eer_write_buffer(eerb, sizeof(header),(char*)(&header));
690 if (!snss_rc)
691 dasd_eer_write_buffer(eerb, SNSS_DATA_SIZE, cqr->data);
692 dasd_eer_write_buffer(eerb, 4,"EOR");
693 }
694 spin_unlock_irqrestore(&bufferlock, flags);
695
696 wake_up_interruptible(&dasd_eer_read_wait_queue);
697}
698
699/*
700 * callback function for use with SNSS request
701 */
702static void
703dasd_eer_SNSS_cb(struct dasd_ccw_req *cqr, void *data)
704{
705 struct dasd_device *device;
706 struct dasd_eer_private *private;
707 unsigned long irqflags;
708
709 device = (struct dasd_device *)data;
710 private = (struct dasd_eer_private *)device->eer;
711 dasd_eer_write_SNSS_trigger(device, cqr);
712 spin_lock_irqsave(&snsslock, irqflags);
713 if(!test_and_clear_bit(SNSS_REQUESTED, &private->flags)) {
714 clear_bit(CQR_IN_USE, &private->flags);
715 spin_unlock_irqrestore(&snsslock, irqflags);
716 return;
717 };
718 clear_bit(CQR_IN_USE, &private->flags);
719 spin_unlock_irqrestore(&snsslock, irqflags);
720 dasd_eer_sense_subsystem_status(device);
721 return;
722}
723
724/*
725 * clean a used cqr before using it again
726 */
727static void
728dasd_eer_clean_SNSS_request(struct dasd_ccw_req *cqr)
729{
730 struct ccw1 *cpaddr = cqr->cpaddr;
731 void *data = cqr->data;
732
733 memset(cqr, 0, sizeof(struct dasd_ccw_req));
734 memset(cpaddr, 0, sizeof(struct ccw1));
735 memset(data, 0, SNSS_DATA_SIZE);
736 cqr->cpaddr = cpaddr;
737 cqr->data = data;
738 strncpy((char *) &cqr->magic, "ECKD", 4);
739 ASCEBC((char *) &cqr->magic, 4);
740 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
741}
742
743/*
744 * build and start an SNSS request
745 * This function is called from a work queue so we have to
746 * pass the dasd_device pointer as a void pointer.
747 */
748static void
749dasd_eer_sense_subsystem_status(void *data)
750{
751 struct dasd_device *device;
752 struct dasd_eer_private *private;
753 struct dasd_ccw_req *cqr;
754 struct ccw1 *ccw;
755 unsigned long irqflags;
756
757 device = (struct dasd_device *)data;
758 private = (struct dasd_eer_private *)device->eer;
759 if (!private) /* device not eer enabled any more */
760 return;
761 cqr = private->cqr;
762 spin_lock_irqsave(&snsslock, irqflags);
763 if(test_and_set_bit(CQR_IN_USE, &private->flags)) {
764 set_bit(SNSS_REQUESTED, &private->flags);
765 spin_unlock_irqrestore(&snsslock, irqflags);
766 return;
767 };
768 spin_unlock_irqrestore(&snsslock, irqflags);
769 dasd_eer_clean_SNSS_request(cqr);
770 cqr->device = device;
771 cqr->retries = 255;
772 cqr->expires = 10 * HZ;
773
774 ccw = cqr->cpaddr;
775 ccw->cmd_code = DASD_ECKD_CCW_SNSS;
776 ccw->count = SNSS_DATA_SIZE;
777 ccw->flags = 0;
778 ccw->cda = (__u32)(addr_t)cqr->data;
779
780 cqr->buildclk = get_clock();
781 cqr->status = DASD_CQR_FILLED;
782 cqr->callback = dasd_eer_SNSS_cb;
783 cqr->callback_data = (void *)device;
784 dasd_add_request_head(cqr);
785
786 return;
787}
788
789/*
790 * This function is called for all triggers. It calls the appropriate
791 * function that writes the actual trigger records.
792 */
793static int
794dasd_eer_write_trigger(struct dasd_eer_trigger *trigger)
795{
796 int rc;
797 struct dasd_eer_private *private = trigger->device->eer;
798
799 switch (trigger->id) {
800 case DASD_EER_FATALERROR:
801 case DASD_EER_PPRCSUSPEND:
802 rc = dasd_eer_write_standard_trigger(
803 trigger->id, trigger->device, trigger->cqr);
804 break;
805 case DASD_EER_NOPATH:
806 rc = dasd_eer_write_standard_trigger(
807 trigger->id, trigger->device, NULL);
808 break;
809 case DASD_EER_STATECHANGE:
810 if (queue_work(dasd_eer_workqueue, &private->worker)) {
811 rc=0;
812 } else {
813 /* If the work_struct was already queued, it can't
814 * be queued again. But this is OK since we don't
815 * need to have it queued twice.
816 */
817 rc = -EBUSY;
818 }
819 break;
820 default: /* unknown trigger, so we write it without any sense data */
821 rc = dasd_eer_write_standard_trigger(
822 trigger->id, trigger->device, NULL);
823 break;
824 }
825 return rc;
826}
827
828/*
829 * This function is registered with the dasd device driver and gets called
830 * for all dasd eer notifications.
831 */
832static int dasd_eer_notify(struct notifier_block *self,
833 unsigned long action, void *data)
834{
835 switch (action) {
836 case DASD_EER_DISABLE:
837 dasd_eer_disable_on_device((struct dasd_device *)data);
838 break;
839 case DASD_EER_TRIGGER:
840 dasd_eer_write_trigger((struct dasd_eer_trigger *)data);
841 break;
842 }
843 return NOTIFY_OK;
844}
845
846
847/*****************************************************************************/
848/* the device operations */
849/*****************************************************************************/
850
851/*
852 * On the one side we need a lock to access our internal buffer, on the
853 * other side a copy_to_user can sleep. So we need to copy the data we have
854 * to transfer in a readbuffer, which is protected by the readbuffer_mutex.
855 */
856static char readbuffer[PAGE_SIZE];
857DECLARE_MUTEX(readbuffer_mutex);
858
859
860static int
861dasd_eer_open(struct inode *inp, struct file *filp)
862{
863 struct eerbuffer *eerb;
864 unsigned long flags;
865
866 eerb = kmalloc(sizeof(struct eerbuffer), GFP_KERNEL);
867 eerb->head = 0;
868 eerb->tail = 0;
869 eerb->residual = 0;
870 eerb->buffer_page_count = 1;
871 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
872 eerb->buffer = kmalloc(eerb->buffer_page_count*sizeof(char*),
873 GFP_KERNEL);
874 if (!eerb->buffer)
875 return -ENOMEM;
876 if (dasd_eer_allocate_buffer_pages(eerb->buffer,
877 eerb->buffer_page_count)) {
878 kfree(eerb->buffer);
879 return -ENOMEM;
880 }
881 filp->private_data = eerb;
882 spin_lock_irqsave(&bufferlock, flags);
883 list_add(&eerb->list, &bufferlist);
884 spin_unlock_irqrestore(&bufferlock, flags);
885
886 return nonseekable_open(inp,filp);
887}
888
889static int
890dasd_eer_close(struct inode *inp, struct file *filp)
891{
892 struct eerbuffer *eerb;
893 unsigned long flags;
894
895 eerb = (struct eerbuffer *)filp->private_data;
896 spin_lock_irqsave(&bufferlock, flags);
897 list_del(&eerb->list);
898 spin_unlock_irqrestore(&bufferlock, flags);
899 dasd_eer_free_buffer_pages(eerb->buffer, eerb->buffer_page_count);
900 kfree(eerb->buffer);
901 kfree(eerb);
902
903 return 0;
904}
905
906static long
907dasd_eer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
908{
909 int intval;
910 struct eerbuffer *eerb;
911
912 eerb = (struct eerbuffer *)filp->private_data;
913 switch (cmd) {
914 case DASD_EER_PURGE:
915 dasd_eer_purge_buffer(eerb);
916 return 0;
917 case DASD_EER_SETBUFSIZE:
918 if (get_user(intval, (int __user *)arg))
919 return -EFAULT;
920 return dasd_eer_resize_buffer(eerb, intval);
921 default:
922 return -ENOIOCTLCMD;
923 }
924}
925
926static ssize_t
927dasd_eer_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
928{
929 int tc,rc;
930 int tailcount,effective_count;
931 unsigned long flags;
932 struct eerbuffer *eerb;
933
934 eerb = (struct eerbuffer *)filp->private_data;
935 if(down_interruptible(&readbuffer_mutex))
936 return -ERESTARTSYS;
937
938 spin_lock_irqsave(&bufferlock, flags);
939
940 if (eerb->residual < 0) { /* the remainder of this record */
941 /* has been deleted */
942 eerb->residual = 0;
943 spin_unlock_irqrestore(&bufferlock, flags);
944 up(&readbuffer_mutex);
945 return -EIO;
946 } else if (eerb->residual > 0) {
947 /* OK we still have a second half of a record to deliver */
948 effective_count = min(eerb->residual, (int)count);
949 eerb->residual -= effective_count;
950 } else {
951 tc = 0;
952 while (!tc) {
953 tc = dasd_eer_read_buffer(eerb,
954 sizeof(tailcount), (char*)(&tailcount));
955 if (!tc) {
956 /* no data available */
957 spin_unlock_irqrestore(&bufferlock, flags);
958 up(&readbuffer_mutex);
959 if (filp->f_flags & O_NONBLOCK)
960 return -EAGAIN;
961 rc = wait_event_interruptible(
962 dasd_eer_read_wait_queue,
963 eerb->head != eerb->tail);
964 if (rc) {
965 return rc;
966 }
967 if(down_interruptible(&readbuffer_mutex))
968 return -ERESTARTSYS;
969 spin_lock_irqsave(&bufferlock, flags);
970 }
971 }
972 WARN_ON(tc != sizeof(tailcount));
973 effective_count = min(tailcount,(int)count);
974 eerb->residual = tailcount - effective_count;
975 }
976
977 tc = dasd_eer_read_buffer(eerb, effective_count, readbuffer);
978 WARN_ON(tc != effective_count);
979
980 spin_unlock_irqrestore(&bufferlock, flags);
981
982 if (copy_to_user(buf, readbuffer, effective_count)) {
983 up(&readbuffer_mutex);
984 return -EFAULT;
985 }
986
987 up(&readbuffer_mutex);
988 return effective_count;
989}
990
991static unsigned int
992dasd_eer_poll (struct file *filp, poll_table *ptable)
993{
994 unsigned int mask;
995 unsigned long flags;
996 struct eerbuffer *eerb;
997
998 eerb = (struct eerbuffer *)filp->private_data;
999 poll_wait(filp, &dasd_eer_read_wait_queue, ptable);
1000 spin_lock_irqsave(&bufferlock, flags);
1001 if (eerb->head != eerb->tail)
1002 mask = POLLIN | POLLRDNORM ;
1003 else
1004 mask = 0;
1005 spin_unlock_irqrestore(&bufferlock, flags);
1006 return mask;
1007}
1008
1009static struct file_operations dasd_eer_fops = {
1010 .open = &dasd_eer_open,
1011 .release = &dasd_eer_close,
1012 .unlocked_ioctl = &dasd_eer_ioctl,
1013 .compat_ioctl = &dasd_eer_ioctl,
1014 .read = &dasd_eer_read,
1015 .poll = &dasd_eer_poll,
1016 .owner = THIS_MODULE,
1017};
1018
1019static struct miscdevice dasd_eer_dev = {
1020 .minor = MISC_DYNAMIC_MINOR,
1021 .name = "dasd_eer",
1022 .fops = &dasd_eer_fops,
1023};
1024
1025
1026/*****************************************************************************/
1027/* Init and exit */
1028/*****************************************************************************/
1029
1030static int
1031__init dasd_eer_init(void)
1032{
1033 int rc;
1034
1035 dasd_eer_workqueue = create_singlethread_workqueue("dasd_eer");
1036 if (!dasd_eer_workqueue) {
1037 MESSAGE(KERN_ERR , "%s", "dasd_eer_init could not "
1038 "create workqueue \n");
1039 rc = -ENOMEM;
1040 goto out;
1041 }
1042
1043 rc = dasd_register_eer_notifier(&dasd_eer_nb);
1044 if (rc) {
1045 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1046 "register error reporting");
1047 goto queue;
1048 }
1049
1050 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERSET, dasd_ioctl_set_eer);
1051 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERGET, dasd_ioctl_get_eer);
1052
1053 /* we don't need our own character device,
1054 * so we just register as misc device */
1055 rc = misc_register(&dasd_eer_dev);
1056 if (rc) {
1057 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1058 "register misc device");
1059 goto unregister;
1060 }
1061
1062 return 0;
1063
1064unregister:
1065 dasd_unregister_eer_notifier(&dasd_eer_nb);
1066 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1067 dasd_ioctl_set_eer);
1068 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1069 dasd_ioctl_get_eer);
1070queue:
1071 destroy_workqueue(dasd_eer_workqueue);
1072out:
1073 return rc;
1074
1075}
1076module_init(dasd_eer_init);
1077
1078static void
1079__exit dasd_eer_exit(void)
1080{
1081 dasd_unregister_eer_notifier(&dasd_eer_nb);
1082 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1083 dasd_ioctl_set_eer);
1084 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1085 dasd_ioctl_get_eer);
1086 destroy_workqueue(dasd_eer_workqueue);
1087
1088 WARN_ON(misc_deregister(&dasd_eer_dev) != 0);
1089}
1090module_exit(dasd_eer_exit);
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index d1b08fa13fd2..0592354cc604 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -275,34 +275,6 @@ struct dasd_discipline {
275 275
276extern struct dasd_discipline *dasd_diag_discipline_pointer; 276extern struct dasd_discipline *dasd_diag_discipline_pointer;
277 277
278
279/*
280 * Notification numbers for extended error reporting notifications:
281 * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
282 * eer pointer) is freed. The error reporting module needs to do all necessary
283 * cleanup steps.
284 * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
285 */
286#define DASD_EER_DISABLE 0
287#define DASD_EER_TRIGGER 1
288
289/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
290#define DASD_EER_FATALERROR 1
291#define DASD_EER_NOPATH 2
292#define DASD_EER_STATECHANGE 3
293#define DASD_EER_PPRCSUSPEND 4
294
295/*
296 * The dasd_eer_trigger structure contains all data that we need to send
297 * along with an DASD_EER_TRIGGER notification.
298 */
299struct dasd_eer_trigger {
300 unsigned int id;
301 struct dasd_device *device;
302 struct dasd_ccw_req *cqr;
303};
304
305
306struct dasd_device { 278struct dasd_device {
307 /* Block device stuff. */ 279 /* Block device stuff. */
308 struct gendisk *gdp; 280 struct gendisk *gdp;
@@ -316,11 +288,9 @@ struct dasd_device {
316 unsigned long flags; /* per device flags */ 288 unsigned long flags; /* per device flags */
317 unsigned short features; /* copy of devmap-features (read-only!) */ 289 unsigned short features; /* copy of devmap-features (read-only!) */
318 290
319 /* extended error reporting stuff (eer) */
320 void *eer;
321
322 /* Device discipline stuff. */ 291 /* Device discipline stuff. */
323 struct dasd_discipline *discipline; 292 struct dasd_discipline *discipline;
293 struct dasd_discipline *base_discipline;
324 char *private; 294 char *private;
325 295
326 /* Device state and target state. */ 296 /* Device state and target state. */
@@ -519,12 +489,6 @@ int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
519int dasd_generic_set_offline (struct ccw_device *cdev); 489int dasd_generic_set_offline (struct ccw_device *cdev);
520int dasd_generic_notify(struct ccw_device *, int); 490int dasd_generic_notify(struct ccw_device *, int);
521void dasd_generic_auto_online (struct ccw_driver *); 491void dasd_generic_auto_online (struct ccw_driver *);
522int dasd_register_eer_notifier(struct notifier_block *);
523int dasd_unregister_eer_notifier(struct notifier_block *);
524void dasd_write_eer_trigger(unsigned int , struct dasd_device *,
525 struct dasd_ccw_req *);
526
527
528 492
529/* externals in dasd_devmap.c */ 493/* externals in dasd_devmap.c */
530extern int dasd_max_devindex; 494extern int dasd_max_devindex;
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 45ce032772f4..9ed37dc9a1b0 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -165,8 +165,13 @@ qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
165 q_no = q->q_no; 165 q_no = q->q_no;
166 if(!q->is_input_q) 166 if(!q->is_input_q)
167 q_no += irq->no_input_qs; 167 q_no += irq->no_input_qs;
168again:
168 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt); 169 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt);
169 rc = qdio_check_ccq(q, ccq); 170 rc = qdio_check_ccq(q, ccq);
171 if (rc == 1) {
172 QDIO_DBF_TEXT5(1,trace,"eqAGAIN");
173 goto again;
174 }
170 if (rc < 0) { 175 if (rc < 0) {
171 QDIO_DBF_TEXT2(1,trace,"eqberr"); 176 QDIO_DBF_TEXT2(1,trace,"eqberr");
172 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt, *cnt, ccq, q_no); 177 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt, *cnt, ccq, q_no);
@@ -195,8 +200,13 @@ qdio_do_sqbs(struct qdio_q *q, unsigned char state,
195 q_no = q->q_no; 200 q_no = q->q_no;
196 if(!q->is_input_q) 201 if(!q->is_input_q)
197 q_no += irq->no_input_qs; 202 q_no += irq->no_input_qs;
203again:
198 ccq = do_sqbs(irq->sch_token, state, q_no, start, cnt); 204 ccq = do_sqbs(irq->sch_token, state, q_no, start, cnt);
199 rc = qdio_check_ccq(q, ccq); 205 rc = qdio_check_ccq(q, ccq);
206 if (rc == 1) {
207 QDIO_DBF_TEXT5(1,trace,"sqAGAIN");
208 goto again;
209 }
200 if (rc < 0) { 210 if (rc < 0) {
201 QDIO_DBF_TEXT3(1,trace,"sqberr"); 211 QDIO_DBF_TEXT3(1,trace,"sqberr");
202 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt,*cnt,ccq,q_no); 212 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt,*cnt,ccq,q_no);
@@ -1187,8 +1197,7 @@ tiqdio_is_inbound_q_done(struct qdio_q *q)
1187 1197
1188 if (!no_used) 1198 if (!no_used)
1189 return 1; 1199 return 1;
1190 1200 if (!q->siga_sync && !irq->is_qebsm)
1191 if (!q->siga_sync)
1192 /* we'll check for more primed buffers in qeth_stop_polling */ 1201 /* we'll check for more primed buffers in qeth_stop_polling */
1193 return 0; 1202 return 0;
1194 if (irq->is_qebsm) { 1203 if (irq->is_qebsm) {
diff --git a/drivers/scsi/esp.c b/drivers/scsi/esp.c
index f6900538be90..87a8c3d2072c 100644
--- a/drivers/scsi/esp.c
+++ b/drivers/scsi/esp.c
@@ -2068,14 +2068,12 @@ static int esp_reset(struct scsi_cmnd *SCptr)
2068{ 2068{
2069 struct esp *esp = (struct esp *) SCptr->device->host->hostdata; 2069 struct esp *esp = (struct esp *) SCptr->device->host->hostdata;
2070 2070
2071 spin_lock_irq(esp->ehost->host_lock);
2071 (void) esp_do_resetbus(esp); 2072 (void) esp_do_resetbus(esp);
2072
2073 spin_unlock_irq(esp->ehost->host_lock); 2073 spin_unlock_irq(esp->ehost->host_lock);
2074 2074
2075 wait_event(esp->reset_queue, (esp->resetting_bus == 0)); 2075 wait_event(esp->reset_queue, (esp->resetting_bus == 0));
2076 2076
2077 spin_lock_irq(esp->ehost->host_lock);
2078
2079 return SUCCESS; 2077 return SUCCESS;
2080} 2078}
2081 2079
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 7ddd5a69352a..5f1d7580218d 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2514,7 +2514,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2514 assert(sg != NULL); 2514 assert(sg != NULL);
2515 2515
2516 if (qc->flags & ATA_QCFLAG_SINGLE) 2516 if (qc->flags & ATA_QCFLAG_SINGLE)
2517 assert(qc->n_elem == 1); 2517 assert(qc->n_elem <= 1);
2518 2518
2519 VPRINTK("unmapping %u sg elements\n", qc->n_elem); 2519 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
2520 2520
@@ -2537,7 +2537,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2537 kunmap_atomic(addr, KM_IRQ0); 2537 kunmap_atomic(addr, KM_IRQ0);
2538 } 2538 }
2539 } else { 2539 } else {
2540 if (sg_dma_len(&sg[0]) > 0) 2540 if (qc->n_elem)
2541 dma_unmap_single(ap->host_set->dev, 2541 dma_unmap_single(ap->host_set->dev,
2542 sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), 2542 sg_dma_address(&sg[0]), sg_dma_len(&sg[0]),
2543 dir); 2543 dir);
@@ -2570,7 +2570,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
2570 unsigned int idx; 2570 unsigned int idx;
2571 2571
2572 assert(qc->__sg != NULL); 2572 assert(qc->__sg != NULL);
2573 assert(qc->n_elem > 0); 2573 assert(qc->n_elem > 0 || qc->pad_len > 0);
2574 2574
2575 idx = 0; 2575 idx = 0;
2576 ata_for_each_sg(sg, qc) { 2576 ata_for_each_sg(sg, qc) {
@@ -2715,6 +2715,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2715 int dir = qc->dma_dir; 2715 int dir = qc->dma_dir;
2716 struct scatterlist *sg = qc->__sg; 2716 struct scatterlist *sg = qc->__sg;
2717 dma_addr_t dma_address; 2717 dma_addr_t dma_address;
2718 int trim_sg = 0;
2718 2719
2719 /* we must lengthen transfers to end on a 32-bit boundary */ 2720 /* we must lengthen transfers to end on a 32-bit boundary */
2720 qc->pad_len = sg->length & 3; 2721 qc->pad_len = sg->length & 3;
@@ -2734,13 +2735,15 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2734 sg_dma_len(psg) = ATA_DMA_PAD_SZ; 2735 sg_dma_len(psg) = ATA_DMA_PAD_SZ;
2735 /* trim sg */ 2736 /* trim sg */
2736 sg->length -= qc->pad_len; 2737 sg->length -= qc->pad_len;
2738 if (sg->length == 0)
2739 trim_sg = 1;
2737 2740
2738 DPRINTK("padding done, sg->length=%u pad_len=%u\n", 2741 DPRINTK("padding done, sg->length=%u pad_len=%u\n",
2739 sg->length, qc->pad_len); 2742 sg->length, qc->pad_len);
2740 } 2743 }
2741 2744
2742 if (!sg->length) { 2745 if (trim_sg) {
2743 sg_dma_address(sg) = 0; 2746 qc->n_elem--;
2744 goto skip_map; 2747 goto skip_map;
2745 } 2748 }
2746 2749
@@ -2753,9 +2756,9 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2753 } 2756 }
2754 2757
2755 sg_dma_address(sg) = dma_address; 2758 sg_dma_address(sg) = dma_address;
2756skip_map:
2757 sg_dma_len(sg) = sg->length; 2759 sg_dma_len(sg) = sg->length;
2758 2760
2761skip_map:
2759 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), 2762 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg),
2760 qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); 2763 qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
2761 2764
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index de05e2883f9c..80480f0fb2b8 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -277,7 +277,7 @@ static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
277 u8 *prd = pp->pkt + QS_CPB_BYTES; 277 u8 *prd = pp->pkt + QS_CPB_BYTES;
278 278
279 assert(qc->__sg != NULL); 279 assert(qc->__sg != NULL);
280 assert(qc->n_elem > 0); 280 assert(qc->n_elem > 0 || qc->pad_len > 0);
281 281
282 nelem = 0; 282 nelem = 0;
283 ata_for_each_sg(sg, qc) { 283 ata_for_each_sg(sg, qc) {
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 791c4dc550ae..94f5e8ed83a7 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -90,7 +90,7 @@ static int spi_suspend(struct device *dev, pm_message_t message)
90 int value; 90 int value;
91 struct spi_driver *drv = to_spi_driver(dev->driver); 91 struct spi_driver *drv = to_spi_driver(dev->driver);
92 92
93 if (!drv->suspend) 93 if (!drv || !drv->suspend)
94 return 0; 94 return 0;
95 95
96 /* suspend will stop irqs and dma; no more i/o */ 96 /* suspend will stop irqs and dma; no more i/o */
@@ -105,7 +105,7 @@ static int spi_resume(struct device *dev)
105 int value; 105 int value;
106 struct spi_driver *drv = to_spi_driver(dev->driver); 106 struct spi_driver *drv = to_spi_driver(dev->driver);
107 107
108 if (!drv->resume) 108 if (!drv || !drv->resume)
109 return 0; 109 return 0;
110 110
111 /* resume may restart the i/o queue */ 111 /* resume may restart the i/o queue */
@@ -449,7 +449,6 @@ void spi_unregister_master(struct spi_master *master)
449{ 449{
450 (void) device_for_each_child(master->cdev.dev, NULL, __unregister); 450 (void) device_for_each_child(master->cdev.dev, NULL, __unregister);
451 class_device_unregister(&master->cdev); 451 class_device_unregister(&master->cdev);
452 master->cdev.dev = NULL;
453} 452}
454EXPORT_SYMBOL_GPL(spi_unregister_master); 453EXPORT_SYMBOL_GPL(spi_unregister_master);
455 454
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 556895e99645..1f8d805c61e5 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -1321,8 +1321,6 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
1321 mdelay( 15); 1321 mdelay( 15);
1322} 1322}
1323 1323
1324#ifdef CONFIG_PPC_OF
1325
1326static void radeon_pm_reset_pad_ctlr_strength(struct radeonfb_info *rinfo) 1324static void radeon_pm_reset_pad_ctlr_strength(struct radeonfb_info *rinfo)
1327{ 1325{
1328 u32 tmp, tmp2; 1326 u32 tmp, tmp2;
@@ -1836,6 +1834,8 @@ static void radeon_reinitialize_M10(struct radeonfb_info *rinfo)
1836 radeon_pm_m10_enable_lvds_spread_spectrum(rinfo); 1834 radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
1837} 1835}
1838 1836
1837#ifdef CONFIG_PPC_OF
1838
1839static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo) 1839static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo)
1840{ 1840{
1841 OUTREG(MC_CNTL, rinfo->save_regs[46]); 1841 OUTREG(MC_CNTL, rinfo->save_regs[46]);
@@ -2728,13 +2728,23 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk)
2728 printk("radeonfb: Dynamic Clock Power Management disabled\n"); 2728 printk("radeonfb: Dynamic Clock Power Management disabled\n");
2729 } 2729 }
2730 2730
2731#if defined(CONFIG_PM)
2731 /* Check if we can power manage on suspend/resume. We can do 2732 /* Check if we can power manage on suspend/resume. We can do
2732 * D2 on M6, M7 and M9, and we can resume from D3 cold a few other 2733 * D2 on M6, M7 and M9, and we can resume from D3 cold a few other
2733 * "Mac" cards, but that's all. We need more infos about what the 2734 * "Mac" cards, but that's all. We need more infos about what the
2734 * BIOS does tho. Right now, all this PM stuff is pmac-only for that 2735 * BIOS does tho. Right now, all this PM stuff is pmac-only for that
2735 * reason. --BenH 2736 * reason. --BenH
2736 */ 2737 */
2737#if defined(CONFIG_PM) && defined(CONFIG_PPC_PMAC) 2738 /* Special case for Samsung P35 laptops
2739 */
2740 if ((rinfo->pdev->vendor == PCI_VENDOR_ID_ATI) &&
2741 (rinfo->pdev->device == PCI_CHIP_RV350_NP) &&
2742 (rinfo->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG) &&
2743 (rinfo->pdev->subsystem_device == 0xc00c)) {
2744 rinfo->reinit_func = radeon_reinitialize_M10;
2745 rinfo->pm_mode |= radeon_pm_off;
2746 }
2747#if defined(CONFIG_PPC_PMAC)
2738 if (_machine == _MACH_Pmac && rinfo->of_node) { 2748 if (_machine == _MACH_Pmac && rinfo->of_node) {
2739 if (rinfo->is_mobility && rinfo->pm_reg && 2749 if (rinfo->is_mobility && rinfo->pm_reg &&
2740 rinfo->family <= CHIP_FAMILY_RV250) 2750 rinfo->family <= CHIP_FAMILY_RV250)
@@ -2778,7 +2788,8 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk)
2778 OUTREG(TV_DAC_CNTL, INREG(TV_DAC_CNTL) | 0x07000000); 2788 OUTREG(TV_DAC_CNTL, INREG(TV_DAC_CNTL) | 0x07000000);
2779#endif 2789#endif
2780 } 2790 }
2781#endif /* defined(CONFIG_PM) && defined(CONFIG_PPC_PMAC) */ 2791#endif /* defined(CONFIG_PPC_PMAC) */
2792#endif /* defined(CONFIG_PM) */
2782} 2793}
2783 2794
2784void radeonfb_pm_exit(struct radeonfb_info *rinfo) 2795void radeonfb_pm_exit(struct radeonfb_info *rinfo)