aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-31 00:57:05 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-31 00:57:05 -0400
commit5bc65793cbf8da0d35f19ef025dda22887e79e80 (patch)
tree8291998abd73055de6f487fafa174ee2a5d3afee /drivers
parent6edae708bf77e012d855a7e2c7766f211d234f4f (diff)
parent3f0a6766e0cc5a577805732e5adb50a585c58175 (diff)
[SCSI] Merge up to linux-2.6 head
Conflicts: drivers/scsi/jazz_esp.c Same changes made by both SCSI and SPARC trees: problem with UTF-8 conversion in the copyright. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/numa.c8
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/ata/ahci.c16
-rw-r--r--drivers/ata/ata_generic.c2
-rw-r--r--drivers/ata/ata_piix.c10
-rw-r--r--drivers/ata/libata-acpi.c10
-rw-r--r--drivers/ata/libata-core.c104
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-scsi.c50
-rw-r--r--drivers/ata/libata.h4
-rw-r--r--drivers/ata/pata_artop.c6
-rw-r--r--drivers/ata/pata_cmd640.c4
-rw-r--r--drivers/ata/pata_cmd64x.c2
-rw-r--r--drivers/ata/pata_cs5520.c2
-rw-r--r--drivers/ata/pata_cs5530.c2
-rw-r--r--drivers/ata/pata_cs5535.c2
-rw-r--r--drivers/ata/pata_cypress.c2
-rw-r--r--drivers/ata/pata_hpt366.c28
-rw-r--r--drivers/ata/pata_hpt37x.c37
-rw-r--r--drivers/ata/pata_hpt3x2n.c4
-rw-r--r--drivers/ata/pata_hpt3x3.c2
-rw-r--r--drivers/ata/pata_isapnp.c2
-rw-r--r--drivers/ata/pata_it8213.c2
-rw-r--r--drivers/ata/pata_it821x.c3
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/ata/pata_jmicron.c2
-rw-r--r--drivers/ata/pata_legacy.c2
-rw-r--r--drivers/ata/pata_platform.c2
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/pata_rz1000.c2
-rw-r--r--drivers/ata/pata_sc1200.c2
-rw-r--r--drivers/ata/pata_scc.c50
-rw-r--r--drivers/ata/pata_serverworks.c2
-rw-r--r--drivers/ata/pata_sis.c46
-rw-r--r--drivers/ata/pata_sl82c105.c2
-rw-r--r--drivers/ata/pata_via.c38
-rw-r--r--drivers/ata/pata_winbond.c2
-rw-r--r--drivers/ata/pdc_adma.c2
-rw-r--r--drivers/ata/sata_inic162x.c2
-rw-r--r--drivers/ata/sata_mv.c46
-rw-r--r--drivers/ata/sata_nv.c24
-rw-r--r--drivers/ata/sata_promise.c2
-rw-r--r--drivers/ata/sata_qstor.c2
-rw-r--r--drivers/ata/sata_sil.c2
-rw-r--r--drivers/ata/sata_sil24.c5
-rw-r--r--drivers/ata/sata_sis.c4
-rw-r--r--drivers/ata/sata_svw.c2
-rw-r--r--drivers/ata/sata_sx4.c2
-rw-r--r--drivers/ata/sata_uli.c2
-rw-r--r--drivers/ata/sata_via.c7
-rw-r--r--drivers/ata/sata_vsc.c2
-rw-r--r--drivers/atm/idt77252.c27
-rw-r--r--drivers/atm/idt77252.h4
-rw-r--r--drivers/base/dmapool.c1
-rw-r--r--drivers/block/cciss.c45
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/bluetooth/hci_usb.c16
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/agp/frontend.c1
-rw-r--r--drivers/char/agp/generic.c1
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/drm/Kconfig2
-rw-r--r--drivers/char/hangcheck-timer.c2
-rw-r--r--drivers/char/random.c67
-rw-r--r--drivers/char/watchdog/booke_wdt.c2
-rw-r--r--drivers/crypto/Kconfig4
-rw-r--r--drivers/crypto/geode-aes.c12
-rw-r--r--drivers/crypto/geode-aes.h3
-rw-r--r--drivers/firewire/Kconfig14
-rw-r--r--drivers/firewire/Makefile12
-rw-r--r--drivers/firewire/fw-cdev.c2
-rw-r--r--drivers/firewire/fw-ohci.c5
-rw-r--r--drivers/hwmon/Kconfig2
-rw-r--r--drivers/hwmon/applesmc.c17
-rw-r--r--drivers/hwmon/coretemp.c32
-rw-r--r--drivers/hwmon/ds1621.c8
-rw-r--r--drivers/hwmon/hwmon-vid.c4
-rw-r--r--drivers/hwmon/w83627hf.c4
-rw-r--r--drivers/i2c/busses/i2c-pxa.c23
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c3
-rw-r--r--drivers/i2c/busses/i2c-tiny-usb.c2
-rw-r--r--drivers/i2c/i2c-core.c5
-rw-r--r--drivers/ide/ide-dma.c4
-rw-r--r--drivers/ide/ide-proc.c2
-rw-r--r--drivers/ide/pci/atiixp.c1
-rw-r--r--drivers/ide/pci/serverworks.c14
-rw-r--r--drivers/ieee1394/eth1394.c91
-rw-r--r--drivers/ieee1394/eth1394.h4
-rw-r--r--drivers/ieee1394/raw1394.c8
-rw-r--r--drivers/ieee1394/sbp2.c1
-rw-r--r--drivers/infiniband/core/cache.c1
-rw-r--r--drivers/infiniband/core/cm.c29
-rw-r--r--drivers/infiniband/core/device.c136
-rw-r--r--drivers/infiniband/core/umem.c5
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c7
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs_mcast.c16
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c236
-rw-r--r--drivers/infiniband/hw/mlx4/srq.c6
-rw-r--r--drivers/infiniband/hw/mlx4/user.h5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c165
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h49
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c206
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c118
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c7
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c40
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c4
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c10
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c5
-rw-r--r--drivers/input/misc/input-polldev.c5
-rw-r--r--drivers/input/mouse/alps.c58
-rw-r--r--drivers/input/mouse/logips2pp.c1
-rw-r--r--drivers/input/serio/sa1111ps2.c4
-rw-r--r--drivers/input/touchscreen/Kconfig8
-rw-r--r--drivers/input/touchscreen/ads7846.c3
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c7
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c4
-rw-r--r--drivers/isdn/hardware/eicon/capifunc.c16
-rw-r--r--drivers/isdn/hardware/eicon/message.c13
-rw-r--r--drivers/isdn/hisax/config.c2
-rw-r--r--drivers/isdn/hisax/hfc_usb.c43
-rw-r--r--drivers/isdn/hisax/hisax_fcpcipnp.c6
-rw-r--r--drivers/isdn/hisax/st5481_init.c7
-rw-r--r--drivers/isdn/hisax/st5481_usb.c1
-rw-r--r--drivers/isdn/icn/icn.c1
-rw-r--r--drivers/isdn/sc/message.c2
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c1
-rw-r--r--drivers/kvm/svm.c1
-rw-r--r--drivers/kvm/vmx.c1
-rw-r--r--drivers/macintosh/Kconfig1
-rw-r--r--drivers/macintosh/adbhid.c16
-rw-r--r--drivers/macintosh/windfarm_core.c10
-rw-r--r--drivers/md/bitmap.c17
-rw-r--r--drivers/md/linear.c10
-rw-r--r--drivers/md/md.c20
-rw-r--r--drivers/md/raid0.c3
-rw-r--r--drivers/media/dvb/bt8xx/dst.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c15
-rw-r--r--drivers/media/video/cafe_ccic-regs.h6
-rw-r--r--drivers/media/video/cafe_ccic.c18
-rw-r--r--drivers/media/video/em28xx/Kconfig3
-rw-r--r--drivers/media/video/ivtv/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h8
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c12
-rw-r--r--drivers/media/video/ov7670.c21
-rw-r--r--drivers/media/video/tuner-simple.c10
-rw-r--r--drivers/message/fusion/mptbase.h2
-rw-r--r--drivers/message/fusion/mptscsih.c8
-rw-r--r--drivers/message/i2o/driver.c26
-rw-r--r--drivers/mfd/ucb1x00-ts.c11
-rw-r--r--drivers/misc/phantom.c29
-rw-r--r--drivers/mmc/card/block.c18
-rw-r--r--drivers/mmc/card/queue.c35
-rw-r--r--drivers/mmc/card/queue.h8
-rw-r--r--drivers/mtd/ubi/eba.c3
-rw-r--r--drivers/net/Kconfig3
-rw-r--r--drivers/net/arcnet/Kconfig17
-rw-r--r--drivers/net/cassini.c5
-rw-r--r--drivers/net/chelsio/suni1x10gexp_regs.h2
-rw-r--r--drivers/net/declance.c2
-rw-r--r--drivers/net/defxx.c1
-rw-r--r--drivers/net/e1000/e1000.h4
-rw-r--r--drivers/net/e1000/e1000_main.c44
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c2
-rw-r--r--drivers/net/forcedeth.c2
-rw-r--r--drivers/net/gianfar.c11
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.c3
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.h3
-rw-r--r--drivers/net/ibm_emac/ibm_emac_phy.c60
-rw-r--r--drivers/net/ibm_emac/ibm_emac_rgmii.c2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_rgmii.h2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_tah.c2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_tah.h2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_zmii.c2
-rw-r--r--drivers/net/ibm_emac/ibm_emac_zmii.h2
-rw-r--r--drivers/net/ixgb/ixgb.h2
-rw-r--r--drivers/net/ixgb/ixgb_main.c36
-rw-r--r--drivers/net/meth.c68
-rw-r--r--drivers/net/mlx4/alloc.c2
-rw-r--r--drivers/net/mlx4/fw.c2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c2
-rw-r--r--drivers/net/phy/fixed.c4
-rw-r--r--drivers/net/sky2.c75
-rw-r--r--drivers/net/sky2.h24
-rw-r--r--drivers/net/spider_net.c9
-rw-r--r--drivers/net/tokenring/Kconfig33
-rw-r--r--drivers/net/ucc_geth.c3
-rw-r--r--drivers/net/ucc_geth_mii.c2
-rw-r--r--drivers/net/usb/asix.c4
-rw-r--r--drivers/net/usb/cdc_ether.c16
-rw-r--r--drivers/net/usb/rndis_host.c1
-rw-r--r--drivers/net/usb/usbnet.c25
-rw-r--r--drivers/net/usb/usbnet.h1
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c13
-rw-r--r--drivers/net/wireless/libertas/decl.h2
-rw-r--r--drivers/net/wireless/libertas/fw.c14
-rw-r--r--drivers/net/wireless/libertas/rx.c24
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c5
-rw-r--r--drivers/oprofile/buffer_sync.c1
-rw-r--r--drivers/parport/parport_pc.c1
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c1
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h1
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/rtc-omap.c4
-rw-r--r--drivers/s390/scsi/zfcp_aux.c1
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c5
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c40
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c3
-rw-r--r--drivers/scsi/Kconfig14
-rw-r--r--drivers/scsi/Makefile3
-rw-r--r--drivers/scsi/aacraid/aachba.c15
-rw-r--r--drivers/scsi/aacraid/aacraid.h3
-rw-r--r--drivers/scsi/aacraid/rx.c8
-rw-r--r--drivers/scsi/aacraid/sa.c9
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_gram.y1
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_tmf.c14
-rw-r--r--drivers/scsi/ipr.c7
-rw-r--r--drivers/scsi/libsrp.c1
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c2
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c67
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h14
-rw-r--r--drivers/scsi/pluto.c18
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/scsi/sd.c18
-rw-r--r--drivers/scsi/stex.c90
-rw-r--r--drivers/serial/8250.c21
-rw-r--r--drivers/serial/amba-pl010.c3
-rw-r--r--drivers/serial/amba-pl011.c3
-rw-r--r--drivers/serial/bfin_5xx.c125
-rw-r--r--drivers/serial/icom.c55
-rw-r--r--drivers/serial/serial_ks8695.c6
-rw-r--r--drivers/serial/suncore.c6
-rw-r--r--drivers/serial/sunhv.c276
-rw-r--r--drivers/serial/sunzilog.c4
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c25
-rw-r--r--drivers/spi/omap_uwire.c4
-rw-r--r--drivers/spi/spi_bfin5xx.c152
-rw-r--r--drivers/spi/spidev.c15
-rw-r--r--drivers/usb/class/usblp.c2
-rw-r--r--drivers/usb/core/config.c10
-rw-r--r--drivers/usb/core/driver.c18
-rw-r--r--drivers/usb/core/hcd.c8
-rw-r--r--drivers/usb/core/hub.c53
-rw-r--r--drivers/usb/core/message.c9
-rw-r--r--drivers/usb/core/sysfs.c7
-rw-r--r--drivers/usb/core/usb.c10
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c8
-rw-r--r--drivers/usb/host/ehci-fsl.c13
-rw-r--r--drivers/usb/host/ehci-fsl.h1
-rw-r--r--drivers/usb/host/ohci-pci.c2
-rw-r--r--drivers/usb/host/pci-quirks.c9
-rw-r--r--drivers/usb/host/u132-hcd.c12
-rw-r--r--drivers/usb/misc/auerswald.c10
-rw-r--r--drivers/usb/misc/ftdi-elan.c12
-rw-r--r--drivers/usb/misc/ldusb.c35
-rw-r--r--drivers/usb/serial/ark3116.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c40
-rw-r--r--drivers/usb/serial/ftdi_sio.h12
-rw-r--r--drivers/usb/serial/mos7840.c5
-rw-r--r--drivers/usb/serial/omninet.c2
-rw-r--r--drivers/usb/serial/option.c1
-rw-r--r--drivers/usb/serial/sierra.c2
-rw-r--r--drivers/usb/storage/onetouch.c9
-rw-r--r--drivers/usb/storage/unusual_devs.h10
-rw-r--r--drivers/video/Kconfig183
-rw-r--r--drivers/video/console/vgacon.c9
-rw-r--r--drivers/video/imxfb.c24
-rw-r--r--drivers/video/pm2fb.c17
-rw-r--r--drivers/video/pm3fb.c333
-rw-r--r--drivers/video/ps3fb.c8
-rw-r--r--drivers/video/w100fb.c14
282 files changed, 3089 insertions, 1960 deletions
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 8fcd6a15517f..a2efae8a4c4e 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -40,19 +40,19 @@ static nodemask_t nodes_found_map = NODE_MASK_NONE;
40#define NID_INVAL -1 40#define NID_INVAL -1
41 41
42/* maps to convert between proximity domain and logical node ID */ 42/* maps to convert between proximity domain and logical node ID */
43int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS] 43static int pxm_to_node_map[MAX_PXM_DOMAINS]
44 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; 44 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL };
45int __cpuinitdata node_to_pxm_map[MAX_NUMNODES] 45static int node_to_pxm_map[MAX_NUMNODES]
46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; 46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
47 47
48int __cpuinit pxm_to_node(int pxm) 48int pxm_to_node(int pxm)
49{ 49{
50 if (pxm < 0) 50 if (pxm < 0)
51 return NID_INVAL; 51 return NID_INVAL;
52 return pxm_to_node_map[pxm]; 52 return pxm_to_node_map[pxm];
53} 53}
54 54
55int __cpuinit node_to_pxm(int node) 55int node_to_pxm(int node)
56{ 56{
57 if (node < 0) 57 if (node < 0)
58 return PXM_INVAL; 58 return PXM_INVAL;
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ad1f59c1b3fc..b4a8d6030e48 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -132,7 +132,7 @@ config SATA_SIS
132 depends on PCI 132 depends on PCI
133 select PATA_SIS 133 select PATA_SIS
134 help 134 help
135 This option enables support for SiS Serial ATA on 135 This option enables support for SiS Serial ATA on
136 SiS 964/965/966/180 and Parallel ATA on SiS 180. 136 SiS 964/965/966/180 and Parallel ATA on SiS 180.
137 The PATA support for SiS 180 requires additionally to 137 The PATA support for SiS 180 requires additionally to
138 enable the PATA_SIS driver in the config. 138 enable the PATA_SIS driver in the config.
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1ae443d7ab92..7baeaffefe7a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -46,7 +46,7 @@
46#include <linux/libata.h> 46#include <linux/libata.h>
47 47
48#define DRV_NAME "ahci" 48#define DRV_NAME "ahci"
49#define DRV_VERSION "2.1" 49#define DRV_VERSION "2.2"
50 50
51 51
52enum { 52enum {
@@ -170,10 +170,12 @@ enum {
170 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */ 170 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */
171 AHCI_FLAG_HONOR_PI = (1 << 26), /* honor PORTS_IMPL */ 171 AHCI_FLAG_HONOR_PI = (1 << 26), /* honor PORTS_IMPL */
172 AHCI_FLAG_IGN_SERR_INTERNAL = (1 << 27), /* ignore SERR_INTERNAL */ 172 AHCI_FLAG_IGN_SERR_INTERNAL = (1 << 27), /* ignore SERR_INTERNAL */
173 AHCI_FLAG_32BIT_ONLY = (1 << 28), /* force 32bit */
173 174
174 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 175 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
175 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 176 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
176 ATA_FLAG_SKIP_D2H_BSY, 177 ATA_FLAG_SKIP_D2H_BSY |
178 ATA_FLAG_ACPI_SATA,
177}; 179};
178 180
179struct ahci_cmd_hdr { 181struct ahci_cmd_hdr {
@@ -353,7 +355,8 @@ static const struct ata_port_info ahci_port_info[] = {
353 /* board_ahci_sb600 */ 355 /* board_ahci_sb600 */
354 { 356 {
355 .flags = AHCI_FLAG_COMMON | 357 .flags = AHCI_FLAG_COMMON |
356 AHCI_FLAG_IGN_SERR_INTERNAL, 358 AHCI_FLAG_IGN_SERR_INTERNAL |
359 AHCI_FLAG_32BIT_ONLY,
357 .pio_mask = 0x1f, /* pio0-4 */ 360 .pio_mask = 0x1f, /* pio0-4 */
358 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 361 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
359 .port_ops = &ahci_ops, 362 .port_ops = &ahci_ops,
@@ -491,6 +494,13 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
491 hpriv->saved_cap = cap = readl(mmio + HOST_CAP); 494 hpriv->saved_cap = cap = readl(mmio + HOST_CAP);
492 hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL); 495 hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL);
493 496
497 /* some chips lie about 64bit support */
498 if ((cap & HOST_CAP_64) && (pi->flags & AHCI_FLAG_32BIT_ONLY)) {
499 dev_printk(KERN_INFO, &pdev->dev,
500 "controller can't do 64bit DMA, forcing 32bit\n");
501 cap &= ~HOST_CAP_64;
502 }
503
494 /* fixup zero port_map */ 504 /* fixup zero port_map */
495 if (!port_map) { 505 if (!port_map) {
496 port_map = (1 << ahci_nr_ports(hpriv->cap)) - 1; 506 port_map = (1 << ahci_nr_ports(hpriv->cap)) - 1;
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index c3d753296bc6..7565f022bd69 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -26,7 +26,7 @@
26#include <linux/libata.h> 26#include <linux/libata.h>
27 27
28#define DRV_NAME "ata_generic" 28#define DRV_NAME "ata_generic"
29#define DRV_VERSION "0.2.11" 29#define DRV_VERSION "0.2.12"
30 30
31/* 31/*
32 * A generic parallel ATA driver using libata 32 * A generic parallel ATA driver using libata
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 13b6b1df2ac4..9c07b88631be 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -155,7 +155,6 @@ struct piix_host_priv {
155static int piix_init_one (struct pci_dev *pdev, 155static int piix_init_one (struct pci_dev *pdev,
156 const struct pci_device_id *ent); 156 const struct pci_device_id *ent);
157static void piix_pata_error_handler(struct ata_port *ap); 157static void piix_pata_error_handler(struct ata_port *ap);
158static void piix_sata_error_handler(struct ata_port *ap);
159static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); 158static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
160static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); 159static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
161static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev); 160static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
@@ -364,7 +363,7 @@ static const struct ata_port_operations piix_sata_ops = {
364 363
365 .freeze = ata_bmdma_freeze, 364 .freeze = ata_bmdma_freeze,
366 .thaw = ata_bmdma_thaw, 365 .thaw = ata_bmdma_thaw,
367 .error_handler = piix_sata_error_handler, 366 .error_handler = ata_bmdma_error_handler,
368 .post_internal_cmd = ata_bmdma_post_internal_cmd, 367 .post_internal_cmd = ata_bmdma_post_internal_cmd,
369 368
370 .irq_handler = ata_interrupt, 369 .irq_handler = ata_interrupt,
@@ -579,6 +578,7 @@ static const struct ich_laptop ich_laptop[] = {
579 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ 578 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */
580 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ 579 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
581 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ 580 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */
581 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */
582 /* end marker */ 582 /* end marker */
583 { 0, } 583 { 0, }
584}; 584};
@@ -641,12 +641,6 @@ static void piix_pata_error_handler(struct ata_port *ap)
641 ata_std_postreset); 641 ata_std_postreset);
642} 642}
643 643
644static void piix_sata_error_handler(struct ata_port *ap)
645{
646 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
647 ata_std_postreset);
648}
649
650/** 644/**
651 * piix_set_piomode - Initialize host controller PATA PIO timings 645 * piix_set_piomode - Initialize host controller PATA PIO timings
652 * @ap: Port whose timings we are configuring 646 * @ap: Port whose timings we are configuring
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ed4138e24b0c..02236739b40f 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -321,7 +321,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
321 321
322 /* Don't continue if device has no _ADR method. 322 /* Don't continue if device has no _ADR method.
323 * _GTF is intended for known motherboard devices. */ 323 * _GTF is intended for known motherboard devices. */
324 if (!(ap->cbl == ATA_CBL_SATA)) { 324 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); 325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
326 if (err < 0) { 326 if (err < 0) {
327 if (ata_msg_probe(ap)) 327 if (ata_msg_probe(ap))
@@ -343,7 +343,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
343 343
344 /* Get this drive's _ADR info. if not already known. */ 344 /* Get this drive's _ADR info. if not already known. */
345 if (!dev->obj_handle) { 345 if (!dev->obj_handle) {
346 if (!(ap->cbl == ATA_CBL_SATA)) { 346 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
347 /* get child objects of dev_handle == channel objects, 347 /* get child objects of dev_handle == channel objects,
348 * + _their_ children == drive objects */ 348 * + _their_ children == drive objects */
349 /* channel is ap->port_no */ 349 /* channel is ap->port_no */
@@ -528,7 +528,7 @@ static int do_drive_set_taskfiles(struct ata_device *dev,
528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
529 __FUNCTION__, ap->port_no); 529 __FUNCTION__, ap->port_no);
530 530
531 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) 531 if (libata_noacpi || !(ap->flags & ATA_FLAG_ACPI_SATA))
532 return 0; 532 return 0;
533 533
534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) 534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
@@ -578,7 +578,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
578 * we should not run GTF on PATA devices since some 578 * we should not run GTF on PATA devices since some
579 * PATA require execution of GTM/STM before GTF. 579 * PATA require execution of GTM/STM before GTF.
580 */ 580 */
581 if (!(ap->cbl == ATA_CBL_SATA)) 581 if (!(ap->flags & ATA_FLAG_ACPI_SATA))
582 return 0; 582 return 0;
583 583
584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { 584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
@@ -641,7 +641,7 @@ int ata_acpi_push_id(struct ata_device *dev)
641 __FUNCTION__, dev->devno, ap->port_no); 641 __FUNCTION__, dev->devno, ap->port_no);
642 642
643 /* Don't continue if not a SATA device. */ 643 /* Don't continue if not a SATA device. */
644 if (!(ap->cbl == ATA_CBL_SATA)) { 644 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
645 if (ata_msg_probe(ap)) 645 if (ata_msg_probe(ap))
646 ata_dev_printk(dev, KERN_DEBUG, 646 ata_dev_printk(dev, KERN_DEBUG,
647 "%s: Not a SATA device\n", __FUNCTION__); 647 "%s: Not a SATA device\n", __FUNCTION__);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4166407eb47c..3ca9c610c110 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -59,7 +59,7 @@
59 59
60#include "libata.h" 60#include "libata.h"
61 61
62#define DRV_VERSION "2.20" /* must be exactly four chars */ 62#define DRV_VERSION "2.21" /* must be exactly four chars */
63 63
64 64
65/* debounce timing parameters in msecs { interval, duration, timeout } */ 65/* debounce timing parameters in msecs { interval, duration, timeout } */
@@ -101,12 +101,6 @@ int libata_noacpi = 1;
101module_param_named(noacpi, libata_noacpi, int, 0444); 101module_param_named(noacpi, libata_noacpi, int, 0444);
102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); 102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
103 103
104int ata_spindown_compat = 1;
105module_param_named(spindown_compat, ata_spindown_compat, int, 0644);
106MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown "
107 "behavior. Will be removed. More info can be found in "
108 "Documentation/feature-removal-schedule.txt\n");
109
110MODULE_AUTHOR("Jeff Garzik"); 104MODULE_AUTHOR("Jeff Garzik");
111MODULE_DESCRIPTION("Library module for ATA devices"); 105MODULE_DESCRIPTION("Library module for ATA devices");
112MODULE_LICENSE("GPL"); 106MODULE_LICENSE("GPL");
@@ -983,7 +977,7 @@ static u64 ata_hpa_resize(struct ata_device *dev)
983{ 977{
984 u64 sectors = dev->n_sectors; 978 u64 sectors = dev->n_sectors;
985 u64 hpa_sectors; 979 u64 hpa_sectors;
986 980
987 if (ata_id_has_lba48(dev->id)) 981 if (ata_id_has_lba48(dev->id))
988 hpa_sectors = ata_read_native_max_address_ext(dev); 982 hpa_sectors = ata_read_native_max_address_ext(dev);
989 else 983 else
@@ -1594,7 +1588,7 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
1594 * Check if the current speed of the device requires IORDY. Used 1588 * Check if the current speed of the device requires IORDY. Used
1595 * by various controllers for chip configuration. 1589 * by various controllers for chip configuration.
1596 */ 1590 */
1597 1591
1598unsigned int ata_pio_need_iordy(const struct ata_device *adev) 1592unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1599{ 1593{
1600 /* Controller doesn't support IORDY. Probably a pointless check 1594 /* Controller doesn't support IORDY. Probably a pointless check
@@ -1617,7 +1611,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1617 * Compute the highest mode possible if we are not using iordy. Return 1611 * Compute the highest mode possible if we are not using iordy. Return
1618 * -1 if no iordy mode is available. 1612 * -1 if no iordy mode is available.
1619 */ 1613 */
1620 1614
1621static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) 1615static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
1622{ 1616{
1623 /* If we have no drive specific rule, then PIO 2 is non IORDY */ 1617 /* If we have no drive specific rule, then PIO 2 is non IORDY */
@@ -1919,7 +1913,6 @@ int ata_dev_configure(struct ata_device *dev)
1919 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); 1913 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
1920 1914
1921 dev->n_sectors = ata_id_n_sectors(id); 1915 dev->n_sectors = ata_id_n_sectors(id);
1922 dev->n_sectors_boot = dev->n_sectors;
1923 1916
1924 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ 1917 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1925 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, 1918 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
@@ -2670,7 +2663,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
2670 t->active += (t->cycle - (t->active + t->recover)) / 2; 2663 t->active += (t->cycle - (t->active + t->recover)) / 2;
2671 t->recover = t->cycle - t->active; 2664 t->recover = t->cycle - t->active;
2672 } 2665 }
2673 2666
2674 /* In a few cases quantisation may produce enough errors to 2667 /* In a few cases quantisation may produce enough errors to
2675 leave t->cycle too low for the sum of active and recovery 2668 leave t->cycle too low for the sum of active and recovery
2676 if so we must correct this */ 2669 if so we must correct this */
@@ -2900,9 +2893,6 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2900 if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX)) 2893 if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX))
2901 ap->host->simplex_claimed = ap; 2894 ap->host->simplex_claimed = ap;
2902 2895
2903 /* step5: chip specific finalisation */
2904 if (ap->ops->post_set_mode)
2905 ap->ops->post_set_mode(ap);
2906 out: 2896 out:
2907 if (rc) 2897 if (rc)
2908 *r_failed_dev = dev; 2898 *r_failed_dev = dev;
@@ -3032,7 +3022,7 @@ int ata_wait_ready(struct ata_port *ap, unsigned long deadline)
3032 3022
3033 if (!(status & ATA_BUSY)) 3023 if (!(status & ATA_BUSY))
3034 return 0; 3024 return 0;
3035 if (status == 0xff) 3025 if (!ata_port_online(ap) && status == 0xff)
3036 return -ENODEV; 3026 return -ENODEV;
3037 if (time_after(now, deadline)) 3027 if (time_after(now, deadline))
3038 return -EBUSY; 3028 return -EBUSY;
@@ -3378,7 +3368,7 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3378 */ 3368 */
3379 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) { 3369 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) {
3380 rc = ata_wait_ready(ap, deadline); 3370 rc = ata_wait_ready(ap, deadline);
3381 if (rc) { 3371 if (rc && rc != -ENODEV) {
3382 ata_port_printk(ap, KERN_WARNING, "device not ready " 3372 ata_port_printk(ap, KERN_WARNING, "device not ready "
3383 "(errno=%d), forcing hardreset\n", rc); 3373 "(errno=%d), forcing hardreset\n", rc);
3384 ehc->i.action |= ATA_EH_HARDRESET; 3374 ehc->i.action |= ATA_EH_HARDRESET;
@@ -3632,7 +3622,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3632 const u16 *old_id = dev->id; 3622 const u16 *old_id = dev->id;
3633 unsigned char model[2][ATA_ID_PROD_LEN + 1]; 3623 unsigned char model[2][ATA_ID_PROD_LEN + 1];
3634 unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; 3624 unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
3635 u64 new_n_sectors;
3636 3625
3637 if (dev->class != new_class) { 3626 if (dev->class != new_class) {
3638 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", 3627 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n",
@@ -3644,7 +3633,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3644 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1])); 3633 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
3645 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0])); 3634 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
3646 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1])); 3635 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
3647 new_n_sectors = ata_id_n_sectors(new_id);
3648 3636
3649 if (strcmp(model[0], model[1])) { 3637 if (strcmp(model[0], model[1])) {
3650 ata_dev_printk(dev, KERN_INFO, "model number mismatch " 3638 ata_dev_printk(dev, KERN_INFO, "model number mismatch "
@@ -3658,25 +3646,12 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3658 return 0; 3646 return 0;
3659 } 3647 }
3660 3648
3661 if (dev->class == ATA_DEV_ATA && dev->n_sectors != new_n_sectors) {
3662 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
3663 "%llu != %llu\n",
3664 (unsigned long long)dev->n_sectors,
3665 (unsigned long long)new_n_sectors);
3666 /* Are we the boot time size - if so we appear to be the
3667 same disk at this point and our HPA got reapplied */
3668 if (ata_ignore_hpa && dev->n_sectors_boot == new_n_sectors
3669 && ata_id_hpa_enabled(new_id))
3670 return 1;
3671 return 0;
3672 }
3673
3674 return 1; 3649 return 1;
3675} 3650}
3676 3651
3677/** 3652/**
3678 * ata_dev_revalidate - Revalidate ATA device 3653 * ata_dev_reread_id - Re-read IDENTIFY data
3679 * @dev: device to revalidate 3654 * @adev: target ATA device
3680 * @readid_flags: read ID flags 3655 * @readid_flags: read ID flags
3681 * 3656 *
3682 * Re-read IDENTIFY page and make sure @dev is still attached to 3657 * Re-read IDENTIFY page and make sure @dev is still attached to
@@ -3688,34 +3663,68 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3688 * RETURNS: 3663 * RETURNS:
3689 * 0 on success, negative errno otherwise 3664 * 0 on success, negative errno otherwise
3690 */ 3665 */
3691int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) 3666int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
3692{ 3667{
3693 unsigned int class = dev->class; 3668 unsigned int class = dev->class;
3694 u16 *id = (void *)dev->ap->sector_buf; 3669 u16 *id = (void *)dev->ap->sector_buf;
3695 int rc; 3670 int rc;
3696 3671
3697 if (!ata_dev_enabled(dev)) {
3698 rc = -ENODEV;
3699 goto fail;
3700 }
3701
3702 /* read ID data */ 3672 /* read ID data */
3703 rc = ata_dev_read_id(dev, &class, readid_flags, id); 3673 rc = ata_dev_read_id(dev, &class, readid_flags, id);
3704 if (rc) 3674 if (rc)
3705 goto fail; 3675 return rc;
3706 3676
3707 /* is the device still there? */ 3677 /* is the device still there? */
3708 if (!ata_dev_same_device(dev, class, id)) { 3678 if (!ata_dev_same_device(dev, class, id))
3709 rc = -ENODEV; 3679 return -ENODEV;
3710 goto fail;
3711 }
3712 3680
3713 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); 3681 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
3682 return 0;
3683}
3684
3685/**
3686 * ata_dev_revalidate - Revalidate ATA device
3687 * @dev: device to revalidate
3688 * @readid_flags: read ID flags
3689 *
3690 * Re-read IDENTIFY page, make sure @dev is still attached to the
3691 * port and reconfigure it according to the new IDENTIFY page.
3692 *
3693 * LOCKING:
3694 * Kernel thread context (may sleep)
3695 *
3696 * RETURNS:
3697 * 0 on success, negative errno otherwise
3698 */
3699int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
3700{
3701 u64 n_sectors = dev->n_sectors;
3702 int rc;
3703
3704 if (!ata_dev_enabled(dev))
3705 return -ENODEV;
3706
3707 /* re-read ID */
3708 rc = ata_dev_reread_id(dev, readid_flags);
3709 if (rc)
3710 goto fail;
3714 3711
3715 /* configure device according to the new ID */ 3712 /* configure device according to the new ID */
3716 rc = ata_dev_configure(dev); 3713 rc = ata_dev_configure(dev);
3717 if (rc == 0) 3714 if (rc)
3718 return 0; 3715 goto fail;
3716
3717 /* verify n_sectors hasn't changed */
3718 if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) {
3719 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
3720 "%llu != %llu\n",
3721 (unsigned long long)n_sectors,
3722 (unsigned long long)dev->n_sectors);
3723 rc = -ENODEV;
3724 goto fail;
3725 }
3726
3727 return 0;
3719 3728
3720 fail: 3729 fail:
3721 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); 3730 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
@@ -3759,6 +3768,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3759 { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, 3768 { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA },
3760 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, 3769 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
3761 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, 3770 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA },
3771 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA },
3762 3772
3763 /* Weird ATAPI devices */ 3773 /* Weird ATAPI devices */
3764 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | 3774 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 5309c312f517..d8070989a39f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1009,7 +1009,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
1009 sense_buf[0] = 0x70; 1009 sense_buf[0] = 0x70;
1010 sense_buf[2] = qc->result_tf.feature >> 4; 1010 sense_buf[2] = qc->result_tf.feature >> 4;
1011 1011
1012 /* some devices time out if garbage left in tf */ 1012 /* some devices time out if garbage left in tf */
1013 ata_tf_init(dev, &tf); 1013 ata_tf_init(dev, &tf);
1014 1014
1015 memset(cdb, 0, ATAPI_CDB_LEN); 1015 memset(cdb, 0, ATAPI_CDB_LEN);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index dd81fa78cdcf..b3900cfbd880 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -893,6 +893,23 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
893 return queue_depth; 893 return queue_depth;
894} 894}
895 895
896/* XXX: for spindown warning */
897static void ata_delayed_done_timerfn(unsigned long arg)
898{
899 struct scsi_cmnd *scmd = (void *)arg;
900
901 scmd->scsi_done(scmd);
902}
903
904/* XXX: for spindown warning */
905static void ata_delayed_done(struct scsi_cmnd *scmd)
906{
907 static struct timer_list timer;
908
909 setup_timer(&timer, ata_delayed_done_timerfn, (unsigned long)scmd);
910 mod_timer(&timer, jiffies + 5 * HZ);
911}
912
896/** 913/**
897 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command 914 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
898 * @qc: Storage for translated ATA taskfile 915 * @qc: Storage for translated ATA taskfile
@@ -949,22 +966,24 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
949 * removed. Read Documentation/feature-removal-schedule.txt 966 * removed. Read Documentation/feature-removal-schedule.txt
950 * for more info. 967 * for more info.
951 */ 968 */
952 if (ata_spindown_compat && 969 if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
953 (system_state == SYSTEM_HALT || 970 (system_state == SYSTEM_HALT ||
954 system_state == SYSTEM_POWER_OFF)) { 971 system_state == SYSTEM_POWER_OFF)) {
955 static int warned = 0; 972 static unsigned long warned = 0;
956 973
957 if (!warned) { 974 if (!test_and_set_bit(0, &warned)) {
958 spin_unlock_irq(qc->ap->lock);
959 ata_dev_printk(qc->dev, KERN_WARNING, 975 ata_dev_printk(qc->dev, KERN_WARNING,
960 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " 976 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
961 "UPDATE SHUTDOWN UTILITY\n"); 977 "UPDATE SHUTDOWN UTILITY\n");
962 ata_dev_printk(qc->dev, KERN_WARNING, 978 ata_dev_printk(qc->dev, KERN_WARNING,
963 "For more info, visit " 979 "For more info, visit "
964 "http://linux-ata.org/shutdown.html\n"); 980 "http://linux-ata.org/shutdown.html\n");
965 warned = 1; 981
966 ssleep(5); 982 /* ->scsi_done is not used, use it for
967 spin_lock_irq(qc->ap->lock); 983 * delayed completion.
984 */
985 scmd->scsi_done = qc->scsidone;
986 qc->scsidone = ata_delayed_done;
968 } 987 }
969 scmd->result = SAM_STAT_GOOD; 988 scmd->result = SAM_STAT_GOOD;
970 return 1; 989 return 1;
@@ -1031,14 +1050,15 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc)
1031static void scsi_6_lba_len(const u8 *cdb, u64 *plba, u32 *plen) 1050static void scsi_6_lba_len(const u8 *cdb, u64 *plba, u32 *plen)
1032{ 1051{
1033 u64 lba = 0; 1052 u64 lba = 0;
1034 u32 len = 0; 1053 u32 len;
1035 1054
1036 VPRINTK("six-byte command\n"); 1055 VPRINTK("six-byte command\n");
1037 1056
1057 lba |= ((u64)(cdb[1] & 0x1f)) << 16;
1038 lba |= ((u64)cdb[2]) << 8; 1058 lba |= ((u64)cdb[2]) << 8;
1039 lba |= ((u64)cdb[3]); 1059 lba |= ((u64)cdb[3]);
1040 1060
1041 len |= ((u32)cdb[4]); 1061 len = cdb[4];
1042 1062
1043 *plba = lba; 1063 *plba = lba;
1044 *plen = len; 1064 *plen = len;
@@ -1375,6 +1395,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1375 } 1395 }
1376 } 1396 }
1377 1397
1398 /* XXX: track spindown state for spindown skipping and warning */
1399 if (unlikely(qc->tf.command == ATA_CMD_STANDBY ||
1400 qc->tf.command == ATA_CMD_STANDBYNOW1))
1401 qc->dev->flags |= ATA_DFLAG_SPUNDOWN;
1402 else if (likely(system_state != SYSTEM_HALT &&
1403 system_state != SYSTEM_POWER_OFF))
1404 qc->dev->flags &= ~ATA_DFLAG_SPUNDOWN;
1405
1378 if (need_sense && !ap->ops->error_handler) 1406 if (need_sense && !ap->ops->error_handler)
1379 ata_dump_status(ap->print_id, &qc->result_tf); 1407 ata_dump_status(ap->print_id, &qc->result_tf);
1380 1408
@@ -1488,14 +1516,14 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1488 1516
1489early_finish: 1517early_finish:
1490 ata_qc_free(qc); 1518 ata_qc_free(qc);
1491 done(cmd); 1519 qc->scsidone(cmd);
1492 DPRINTK("EXIT - early finish (good or error)\n"); 1520 DPRINTK("EXIT - early finish (good or error)\n");
1493 return 0; 1521 return 0;
1494 1522
1495err_did: 1523err_did:
1496 ata_qc_free(qc); 1524 ata_qc_free(qc);
1497 cmd->result = (DID_ERROR << 16); 1525 cmd->result = (DID_ERROR << 16);
1498 done(cmd); 1526 qc->scsidone(cmd);
1499err_mem: 1527err_mem:
1500 DPRINTK("EXIT - internal\n"); 1528 DPRINTK("EXIT - internal\n");
1501 return 0; 1529 return 0;
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 8b71b73a199c..5e2466658420 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -58,7 +58,6 @@ extern int atapi_enabled;
58extern int atapi_dmadir; 58extern int atapi_dmadir;
59extern int libata_fua; 59extern int libata_fua;
60extern int libata_noacpi; 60extern int libata_noacpi;
61extern int ata_spindown_compat;
62extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 61extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
63extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 62extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
64 u64 block, u32 n_block, unsigned int tf_flags, 63 u64 block, u32 n_block, unsigned int tf_flags,
@@ -76,7 +75,8 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev,
76extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 75extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
77extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 76extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
78 unsigned int flags, u16 *id); 77 unsigned int flags, u16 *id);
79extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags); 78extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
79extern int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags);
80extern int ata_dev_configure(struct ata_device *dev); 80extern int ata_dev_configure(struct ata_device *dev);
81extern int sata_down_spd_limit(struct ata_port *ap); 81extern int sata_down_spd_limit(struct ata_port *ap);
82extern int sata_set_spd_needed(struct ata_port *ap); 82extern int sata_set_spd_needed(struct ata_port *ap);
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 9861059dd673..03b6ddd2abd2 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -28,7 +28,7 @@
28#include <linux/ata.h> 28#include <linux/ata.h>
29 29
30#define DRV_NAME "pata_artop" 30#define DRV_NAME "pata_artop"
31#define DRV_VERSION "0.4.2" 31#define DRV_VERSION "0.4.3"
32 32
33/* 33/*
34 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we 34 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
@@ -97,9 +97,9 @@ static int artop6260_pre_reset(struct ata_port *ap, unsigned long deadline)
97 * artop6260_cable_detect - identify cable type 97 * artop6260_cable_detect - identify cable type
98 * @ap: Port 98 * @ap: Port
99 * 99 *
100 * Identify the cable type for the ARTOp interface in question 100 * Identify the cable type for the ARTOP interface in question
101 */ 101 */
102 102
103static int artop6260_cable_detect(struct ata_port *ap) 103static int artop6260_cable_detect(struct ata_port *ap)
104{ 104{
105 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 105 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index ed00fa9d53be..31cbf8daa299 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -107,7 +107,7 @@ static void cmd640_set_piomode(struct ata_port *ap, struct ata_device *adev)
107 pci_write_config_byte(pdev, arttim + 1, (t.active << 4) | t.recover); 107 pci_write_config_byte(pdev, arttim + 1, (t.active << 4) | t.recover);
108 } else { 108 } else {
109 /* Save the shared timings for channel, they will be loaded 109 /* Save the shared timings for channel, they will be loaded
110 by qc_issue_prot. Reloading the setup time is expensive 110 by qc_issue_prot. Reloading the setup time is expensive
111 so we keep a merged one loaded */ 111 so we keep a merged one loaded */
112 pci_read_config_byte(pdev, ARTIM23, &reg); 112 pci_read_config_byte(pdev, ARTIM23, &reg);
113 reg &= 0x3F; 113 reg &= 0x3F;
@@ -231,7 +231,7 @@ static void cmd640_hardware_init(struct pci_dev *pdev)
231 pci_write_config_byte(pdev, CMDTIM, 0); 231 pci_write_config_byte(pdev, CMDTIM, 0);
232 /* 512 byte bursts (sector) */ 232 /* 512 byte bursts (sector) */
233 pci_write_config_byte(pdev, BRST, 0x40); 233 pci_write_config_byte(pdev, BRST, 0x40);
234 /* 234 /*
235 * A reporter a long time ago 235 * A reporter a long time ago
236 * Had problems with the data fifo 236 * Had problems with the data fifo
237 * So don't run the risk 237 * So don't run the risk
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 2a79b335cfcc..320a5b10aa98 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -31,7 +31,7 @@
31#include <linux/libata.h> 31#include <linux/libata.h>
32 32
33#define DRV_NAME "pata_cmd64x" 33#define DRV_NAME "pata_cmd64x"
34#define DRV_VERSION "0.2.2" 34#define DRV_VERSION "0.2.3"
35 35
36/* 36/*
37 * CMD64x specific registers definition. 37 * CMD64x specific registers definition.
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 83bcc5b32597..1aabe15ad9d3 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -41,7 +41,7 @@
41#include <linux/libata.h> 41#include <linux/libata.h>
42 42
43#define DRV_NAME "pata_cs5520" 43#define DRV_NAME "pata_cs5520"
44#define DRV_VERSION "0.6.4" 44#define DRV_VERSION "0.6.5"
45 45
46struct pio_clocks 46struct pio_clocks
47{ 47{
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 1b67923d7a4e..848f0309bf03 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -35,7 +35,7 @@
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36 36
37#define DRV_NAME "pata_cs5530" 37#define DRV_NAME "pata_cs5530"
38#define DRV_VERSION "0.7.2" 38#define DRV_VERSION "0.7.3"
39 39
40static void __iomem *cs5530_port_base(struct ata_port *ap) 40static void __iomem *cs5530_port_base(struct ata_port *ap)
41{ 41{
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index f37d4cd812a1..aa3256fb9f7a 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -39,7 +39,7 @@
39#include <asm/msr.h> 39#include <asm/msr.h>
40 40
41#define DRV_NAME "cs5535" 41#define DRV_NAME "cs5535"
42#define DRV_VERSION "0.2.11" 42#define DRV_VERSION "0.2.12"
43 43
44/* 44/*
45 * The Geode (Aka Athlon GX now) uses an internal MSR based 45 * The Geode (Aka Athlon GX now) uses an internal MSR based
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 27b9f29c01e3..d41a7691dd8e 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -18,7 +18,7 @@
18#include <linux/libata.h> 18#include <linux/libata.h>
19 19
20#define DRV_NAME "pata_cypress" 20#define DRV_NAME "pata_cypress"
21#define DRV_VERSION "0.1.4" 21#define DRV_VERSION "0.1.5"
22 22
23/* here are the offset definitions for the registers */ 23/* here are the offset definitions for the registers */
24 24
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index c6c8a8bb06d0..0c9cb6090711 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -220,32 +220,6 @@ static int hpt36x_cable_detect(struct ata_port *ap)
220 return ATA_CBL_PATA80; 220 return ATA_CBL_PATA80;
221} 221}
222 222
223static int hpt36x_pre_reset(struct ata_port *ap, unsigned long deadline)
224{
225 static const struct pci_bits hpt36x_enable_bits[] = {
226 { 0x50, 1, 0x04, 0x04 },
227 { 0x54, 1, 0x04, 0x04 }
228 };
229 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
230
231 if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
232 return -ENOENT;
233
234 return ata_std_prereset(ap, deadline);
235}
236
237/**
238 * hpt36x_error_handler - reset the hpt36x bus
239 * @ap: ATA port to reset
240 *
241 * Perform the reset handling for the 366/368
242 */
243
244static void hpt36x_error_handler(struct ata_port *ap)
245{
246 ata_bmdma_drive_eh(ap, hpt36x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
247}
248
249/** 223/**
250 * hpt366_set_piomode - PIO setup 224 * hpt366_set_piomode - PIO setup
251 * @ap: ATA interface 225 * @ap: ATA interface
@@ -351,7 +325,7 @@ static struct ata_port_operations hpt366_port_ops = {
351 325
352 .freeze = ata_bmdma_freeze, 326 .freeze = ata_bmdma_freeze,
353 .thaw = ata_bmdma_thaw, 327 .thaw = ata_bmdma_thaw,
354 .error_handler = hpt36x_error_handler, 328 .error_handler = ata_bmdma_error_handler,
355 .post_internal_cmd = ata_bmdma_post_internal_cmd, 329 .post_internal_cmd = ata_bmdma_post_internal_cmd,
356 .cable_detect = hpt36x_cable_detect, 330 .cable_detect = hpt36x_cable_detect,
357 331
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 5a0a410654e2..6446735a46e0 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -26,7 +26,7 @@
26#include <linux/libata.h> 26#include <linux/libata.h>
27 27
28#define DRV_NAME "pata_hpt37x" 28#define DRV_NAME "pata_hpt37x"
29#define DRV_VERSION "0.6.5" 29#define DRV_VERSION "0.6.6"
30 30
31struct hpt_clock { 31struct hpt_clock {
32 u8 xfer_speed; 32 u8 xfer_speed;
@@ -931,15 +931,6 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
931 .udma_mask = 0x7f, 931 .udma_mask = 0x7f,
932 .port_ops = &hpt372_port_ops 932 .port_ops = &hpt372_port_ops
933 }; 933 };
934 /* HPT371, 372 and friends - UDMA100 at 50MHz clock */
935 static const struct ata_port_info info_hpt372_50 = {
936 .sht = &hpt37x_sht,
937 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
938 .pio_mask = 0x1f,
939 .mwdma_mask = 0x07,
940 .udma_mask = 0x3f,
941 .port_ops = &hpt372_port_ops
942 };
943 /* HPT374 - UDMA133 */ 934 /* HPT374 - UDMA133 */
944 static const struct ata_port_info info_hpt374 = { 935 static const struct ata_port_info info_hpt374 = {
945 .sht = &hpt37x_sht, 936 .sht = &hpt37x_sht,
@@ -961,7 +952,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
961 u8 mcr1; 952 u8 mcr1;
962 u32 freq; 953 u32 freq;
963 int prefer_dpll = 1; 954 int prefer_dpll = 1;
964 955
965 unsigned long iobase = pci_resource_start(dev, 4); 956 unsigned long iobase = pci_resource_start(dev, 4);
966 957
967 const struct hpt_chip *chip_table; 958 const struct hpt_chip *chip_table;
@@ -1055,7 +1046,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1055 */ 1046 */
1056 1047
1057 pci_write_config_byte(dev, 0x5b, 0x23); 1048 pci_write_config_byte(dev, 0x5b, 0x23);
1058 1049
1059 /* 1050 /*
1060 * HighPoint does this for HPT372A. 1051 * HighPoint does this for HPT372A.
1061 * NOTE: This register is only writeable via I/O space. 1052 * NOTE: This register is only writeable via I/O space.
@@ -1088,7 +1079,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1088 * Turn the frequency check into a band and then find a timing 1079 * Turn the frequency check into a band and then find a timing
1089 * table to match it. 1080 * table to match it.
1090 */ 1081 */
1091 1082
1092 clock_slot = hpt37x_clock_slot(freq, chip_table->base); 1083 clock_slot = hpt37x_clock_slot(freq, chip_table->base);
1093 if (chip_table->clocks[clock_slot] == NULL || prefer_dpll) { 1084 if (chip_table->clocks[clock_slot] == NULL || prefer_dpll) {
1094 /* 1085 /*
@@ -1098,17 +1089,21 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1098 * use a 50MHz DPLL by choice 1089 * use a 50MHz DPLL by choice
1099 */ 1090 */
1100 unsigned int f_low, f_high; 1091 unsigned int f_low, f_high;
1101 int adjust; 1092 int dpll, adjust;
1102 1093
1103 clock_slot = 2; 1094 /* Compute DPLL */
1095 dpll = 2;
1104 if (port->udma_mask & 0xE0) 1096 if (port->udma_mask & 0xE0)
1105 clock_slot = 3; 1097 dpll = 3;
1106 1098
1107 f_low = (MHz[clock_slot] * chip_table->base) / 192; 1099 f_low = (MHz[clock_slot] * 48) / MHz[dpll];
1108 f_high = f_low + 2; 1100 f_high = f_low + 2;
1101 if (clock_slot > 1)
1102 f_high += 2;
1109 1103
1110 /* Select the DPLL clock. */ 1104 /* Select the DPLL clock. */
1111 pci_write_config_byte(dev, 0x5b, 0x21); 1105 pci_write_config_byte(dev, 0x5b, 0x21);
1106 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
1112 1107
1113 for(adjust = 0; adjust < 8; adjust++) { 1108 for(adjust = 0; adjust < 8; adjust++) {
1114 if (hpt37x_calibrate_dpll(dev)) 1109 if (hpt37x_calibrate_dpll(dev))
@@ -1124,12 +1119,12 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1124 printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n"); 1119 printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n");
1125 return -ENODEV; 1120 return -ENODEV;
1126 } 1121 }
1127 if (clock_slot == 3) 1122 if (dpll == 3)
1128 private_data = (void *)hpt37x_timings_66; 1123 private_data = (void *)hpt37x_timings_66;
1129 else 1124 else
1130 private_data = (void *)hpt37x_timings_50; 1125 private_data = (void *)hpt37x_timings_50;
1131 1126
1132 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); 1127 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[dpll]);
1133 } else { 1128 } else {
1134 private_data = (void *)chip_table->clocks[clock_slot]; 1129 private_data = (void *)chip_table->clocks[clock_slot];
1135 /* 1130 /*
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index f25154aed75d..e947433cb37d 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -521,8 +521,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
521 /* 371N if rev > 1 */ 521 /* 371N if rev > 1 */
522 break; 522 break;
523 case PCI_DEVICE_ID_TTI_HPT372: 523 case PCI_DEVICE_ID_TTI_HPT372:
524 /* 372N if rev >= 1*/ 524 /* 372N if rev >= 2*/
525 if (class_rev == 0) 525 if (class_rev < 2)
526 return -ENODEV; 526 return -ENODEV;
527 break; 527 break;
528 case PCI_DEVICE_ID_TTI_HPT302: 528 case PCI_DEVICE_ID_TTI_HPT302:
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index bbabe7902fbb..8ce5e23a5f75 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -23,7 +23,7 @@
23#include <linux/libata.h> 23#include <linux/libata.h>
24 24
25#define DRV_NAME "pata_hpt3x3" 25#define DRV_NAME "pata_hpt3x3"
26#define DRV_VERSION "0.4.2" 26#define DRV_VERSION "0.4.3"
27 27
28/** 28/**
29 * hpt3x3_set_piomode - PIO setup 29 * hpt3x3_set_piomode - PIO setup
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index d042efdfbac4..1f647b648204 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -17,7 +17,7 @@
17#include <linux/libata.h> 17#include <linux/libata.h>
18 18
19#define DRV_NAME "pata_isapnp" 19#define DRV_NAME "pata_isapnp"
20#define DRV_VERSION "0.2.0" 20#define DRV_VERSION "0.2.1"
21 21
22static struct scsi_host_template isapnp_sht = { 22static struct scsi_host_template isapnp_sht = {
23 .module = THIS_MODULE, 23 .module = THIS_MODULE,
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index a769952646e1..95b0bb61788b 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -19,7 +19,7 @@
19#include <linux/ata.h> 19#include <linux/ata.h>
20 20
21#define DRV_NAME "pata_it8213" 21#define DRV_NAME "pata_it8213"
22#define DRV_VERSION "0.0.2" 22#define DRV_VERSION "0.0.3"
23 23
24/** 24/**
25 * it8213_pre_reset - check for 40/80 pin 25 * it8213_pre_reset - check for 40/80 pin
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index ff9a6fd36657..b3456d7a592c 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ata-it821x.c - IT821x PATA for new ATA layer 2 * pata_it821x.c - IT821x PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * Alan Cox <alan@redhat.com> 4 * Alan Cox <alan@redhat.com>
5 * 5 *
@@ -65,7 +65,6 @@
65 * 65 *
66 * TODO 66 * TODO
67 * - ATAPI and other speed filtering 67 * - ATAPI and other speed filtering
68 * - Command filter in smart mode
69 * - RAID configuration ioctls 68 * - RAID configuration ioctls
70 */ 69 */
71 70
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index b994351fbcd0..8d2bc1e9e871 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -23,7 +23,7 @@
23#include <scsi/scsi_host.h> 23#include <scsi/scsi_host.h>
24 24
25#define DRV_NAME "pata_ixp4xx_cf" 25#define DRV_NAME "pata_ixp4xx_cf"
26#define DRV_VERSION "0.1.2" 26#define DRV_VERSION "0.1.3"
27 27
28static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) 28static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error)
29{ 29{
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 8d799e87f752..2af7ff8256ca 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -19,7 +19,7 @@
19#include <linux/ata.h> 19#include <linux/ata.h>
20 20
21#define DRV_NAME "pata_jmicron" 21#define DRV_NAME "pata_jmicron"
22#define DRV_VERSION "0.1.4" 22#define DRV_VERSION "0.1.5"
23 23
24typedef enum { 24typedef enum {
25 PORT_PATA0 = 0, 25 PORT_PATA0 = 0,
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 707099291e01..edffc25d2d3f 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -64,7 +64,7 @@
64#include <linux/platform_device.h> 64#include <linux/platform_device.h>
65 65
66#define DRV_NAME "pata_legacy" 66#define DRV_NAME "pata_legacy"
67#define DRV_VERSION "0.5.4" 67#define DRV_VERSION "0.5.5"
68 68
69#define NR_HOST 6 69#define NR_HOST 6
70 70
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 1f6384895a4f..cbb7866940d6 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -22,7 +22,7 @@
22#include <linux/pata_platform.h> 22#include <linux/pata_platform.h>
23 23
24#define DRV_NAME "pata_platform" 24#define DRV_NAME "pata_platform"
25#define DRV_VERSION "0.1.2" 25#define DRV_VERSION "1.0"
26 26
27static int pio_mask = 1; 27static int pio_mask = 1;
28 28
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index fb8c9e14b8d4..1998c19e8743 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -26,7 +26,7 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27 27
28#define DRV_NAME "pata_qdi" 28#define DRV_NAME "pata_qdi"
29#define DRV_VERSION "0.3.0" 29#define DRV_VERSION "0.3.1"
30 30
31#define NR_HOST 4 /* Two 6580s */ 31#define NR_HOST 4 /* Two 6580s */
32 32
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 2bfd7ef42af5..a3488b41ad26 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -21,7 +21,7 @@
21#include <linux/libata.h> 21#include <linux/libata.h>
22 22
23#define DRV_NAME "pata_rz1000" 23#define DRV_NAME "pata_rz1000"
24#define DRV_VERSION "0.2.3" 24#define DRV_VERSION "0.2.4"
25 25
26 26
27/** 27/**
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 225013ecf4b6..1233063ab9a8 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -40,7 +40,7 @@
40#include <linux/libata.h> 40#include <linux/libata.h>
41 41
42#define DRV_NAME "sc1200" 42#define DRV_NAME "sc1200"
43#define DRV_VERSION "0.2.4" 43#define DRV_VERSION "0.2.5"
44 44
45#define SC1200_REV_A 0x00 45#define SC1200_REV_A 0x00
46#define SC1200_REV_B1 0x01 46#define SC1200_REV_B1 0x01
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index cca3aa225efe..61502bc7bf1d 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -43,7 +43,7 @@
43#include <linux/libata.h> 43#include <linux/libata.h>
44 44
45#define DRV_NAME "pata_scc" 45#define DRV_NAME "pata_scc"
46#define DRV_VERSION "0.1" 46#define DRV_VERSION "0.2"
47 47
48#define PCI_DEVICE_ID_TOSHIBA_SCC_ATA 0x01b4 48#define PCI_DEVICE_ID_TOSHIBA_SCC_ATA 0x01b4
49 49
@@ -489,23 +489,26 @@ static unsigned int scc_devchk (struct ata_port *ap,
489 * Note: Original code is ata_bus_post_reset(). 489 * Note: Original code is ata_bus_post_reset().
490 */ 490 */
491 491
492static void scc_bus_post_reset (struct ata_port *ap, unsigned int devmask) 492static int scc_bus_post_reset(struct ata_port *ap, unsigned int devmask,
493 unsigned long deadline)
493{ 494{
494 struct ata_ioports *ioaddr = &ap->ioaddr; 495 struct ata_ioports *ioaddr = &ap->ioaddr;
495 unsigned int dev0 = devmask & (1 << 0); 496 unsigned int dev0 = devmask & (1 << 0);
496 unsigned int dev1 = devmask & (1 << 1); 497 unsigned int dev1 = devmask & (1 << 1);
497 unsigned long timeout; 498 int rc;
498 499
499 /* if device 0 was found in ata_devchk, wait for its 500 /* if device 0 was found in ata_devchk, wait for its
500 * BSY bit to clear 501 * BSY bit to clear
501 */ 502 */
502 if (dev0) 503 if (dev0) {
503 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 504 rc = ata_wait_ready(ap, deadline);
505 if (rc && rc != -ENODEV)
506 return rc;
507 }
504 508
505 /* if device 1 was found in ata_devchk, wait for 509 /* if device 1 was found in ata_devchk, wait for
506 * register access, then wait for BSY to clear 510 * register access, then wait for BSY to clear
507 */ 511 */
508 timeout = jiffies + ATA_TMOUT_BOOT;
509 while (dev1) { 512 while (dev1) {
510 u8 nsect, lbal; 513 u8 nsect, lbal;
511 514
@@ -514,14 +517,15 @@ static void scc_bus_post_reset (struct ata_port *ap, unsigned int devmask)
514 lbal = in_be32(ioaddr->lbal_addr); 517 lbal = in_be32(ioaddr->lbal_addr);
515 if ((nsect == 1) && (lbal == 1)) 518 if ((nsect == 1) && (lbal == 1))
516 break; 519 break;
517 if (time_after(jiffies, timeout)) { 520 if (time_after(jiffies, deadline))
518 dev1 = 0; 521 return -EBUSY;
519 break;
520 }
521 msleep(50); /* give drive a breather */ 522 msleep(50); /* give drive a breather */
522 } 523 }
523 if (dev1) 524 if (dev1) {
524 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 525 rc = ata_wait_ready(ap, deadline);
526 if (rc && rc != -ENODEV)
527 return rc;
528 }
525 529
526 /* is all this really necessary? */ 530 /* is all this really necessary? */
527 ap->ops->dev_select(ap, 0); 531 ap->ops->dev_select(ap, 0);
@@ -529,6 +533,8 @@ static void scc_bus_post_reset (struct ata_port *ap, unsigned int devmask)
529 ap->ops->dev_select(ap, 1); 533 ap->ops->dev_select(ap, 1);
530 if (dev0) 534 if (dev0)
531 ap->ops->dev_select(ap, 0); 535 ap->ops->dev_select(ap, 0);
536
537 return 0;
532} 538}
533 539
534/** 540/**
@@ -537,8 +543,8 @@ static void scc_bus_post_reset (struct ata_port *ap, unsigned int devmask)
537 * Note: Original code is ata_bus_softreset(). 543 * Note: Original code is ata_bus_softreset().
538 */ 544 */
539 545
540static unsigned int scc_bus_softreset (struct ata_port *ap, 546static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,
541 unsigned int devmask) 547 unsigned long deadline)
542{ 548{
543 struct ata_ioports *ioaddr = &ap->ioaddr; 549 struct ata_ioports *ioaddr = &ap->ioaddr;
544 550
@@ -570,7 +576,7 @@ static unsigned int scc_bus_softreset (struct ata_port *ap,
570 if (scc_check_status(ap) == 0xFF) 576 if (scc_check_status(ap) == 0xFF)
571 return 0; 577 return 0;
572 578
573 scc_bus_post_reset(ap, devmask); 579 scc_bus_post_reset(ap, devmask, deadline);
574 580
575 return 0; 581 return 0;
576} 582}
@@ -579,11 +585,13 @@ static unsigned int scc_bus_softreset (struct ata_port *ap,
579 * scc_std_softreset - reset host port via ATA SRST 585 * scc_std_softreset - reset host port via ATA SRST
580 * @ap: port to reset 586 * @ap: port to reset
581 * @classes: resulting classes of attached devices 587 * @classes: resulting classes of attached devices
588 * @deadline: deadline jiffies for the operation
582 * 589 *
583 * Note: Original code is ata_std_softreset(). 590 * Note: Original code is ata_std_softreset().
584 */ 591 */
585 592
586static int scc_std_softreset (struct ata_port *ap, unsigned int *classes) 593static int scc_std_softreset (struct ata_port *ap, unsigned int *classes,
594 unsigned long deadline)
587{ 595{
588 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; 596 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
589 unsigned int devmask = 0, err_mask; 597 unsigned int devmask = 0, err_mask;
@@ -607,7 +615,7 @@ static int scc_std_softreset (struct ata_port *ap, unsigned int *classes)
607 615
608 /* issue bus reset */ 616 /* issue bus reset */
609 DPRINTK("about to softreset, devmask=%x\n", devmask); 617 DPRINTK("about to softreset, devmask=%x\n", devmask);
610 err_mask = scc_bus_softreset(ap, devmask); 618 err_mask = scc_bus_softreset(ap, devmask, deadline);
611 if (err_mask) { 619 if (err_mask) {
612 ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n", 620 ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n",
613 err_mask); 621 err_mask);
@@ -676,10 +684,11 @@ static void scc_bmdma_stop (struct ata_queued_cmd *qc)
676 684
677 if (reg & INTSTS_BMSINT) { 685 if (reg & INTSTS_BMSINT) {
678 unsigned int classes; 686 unsigned int classes;
687 unsigned long deadline = jiffies + ATA_TMOUT_BOOT;
679 printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME); 688 printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME);
680 out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT); 689 out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT);
681 /* TBD: SW reset */ 690 /* TBD: SW reset */
682 scc_std_softreset(ap, &classes); 691 scc_std_softreset(ap, &classes, deadline);
683 continue; 692 continue;
684 } 693 }
685 694
@@ -862,12 +871,13 @@ static void scc_bmdma_freeze (struct ata_port *ap)
862/** 871/**
863 * scc_pata_prereset - prepare for reset 872 * scc_pata_prereset - prepare for reset
864 * @ap: ATA port to be reset 873 * @ap: ATA port to be reset
874 * @deadline: deadline jiffies for the operation
865 */ 875 */
866 876
867static int scc_pata_prereset (struct ata_port *ap) 877static int scc_pata_prereset(struct ata_port *ap, unsigned long deadline)
868{ 878{
869 ap->cbl = ATA_CBL_PATA80; 879 ap->cbl = ATA_CBL_PATA80;
870 return ata_std_prereset(ap); 880 return ata_std_prereset(ap, deadline);
871} 881}
872 882
873/** 883/**
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index dee6e211949d..1e8f421963c7 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -41,7 +41,7 @@
41#include <linux/libata.h> 41#include <linux/libata.h>
42 42
43#define DRV_NAME "pata_serverworks" 43#define DRV_NAME "pata_serverworks"
44#define DRV_VERSION "0.4.0" 44#define DRV_VERSION "0.4.1"
45 45
46#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ 46#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
47#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ 47#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index f2231267e011..ec3ae9375015 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -73,14 +73,14 @@ static int sis_short_ata40(struct pci_dev *dev)
73} 73}
74 74
75/** 75/**
76 * sis_port_base - return PCI configuration base for dev 76 * sis_old_port_base - return PCI configuration base for dev
77 * @adev: device 77 * @adev: device
78 * 78 *
79 * Returns the base of the PCI configuration registers for this port 79 * Returns the base of the PCI configuration registers for this port
80 * number. 80 * number.
81 */ 81 */
82 82
83static int sis_port_base(struct ata_device *adev) 83static int sis_old_port_base(struct ata_device *adev)
84{ 84{
85 return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno); 85 return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno);
86} 86}
@@ -211,7 +211,7 @@ static void sis_set_fifo(struct ata_port *ap, struct ata_device *adev)
211static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev) 211static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
212{ 212{
213 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 213 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
214 int port = sis_port_base(adev); 214 int port = sis_old_port_base(adev);
215 u8 t1, t2; 215 u8 t1, t2;
216 int speed = adev->pio_mode - XFER_PIO_0; 216 int speed = adev->pio_mode - XFER_PIO_0;
217 217
@@ -248,7 +248,7 @@ static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
248static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev) 248static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev)
249{ 249{
250 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 250 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
251 int port = sis_port_base(adev); 251 int port = sis_old_port_base(adev);
252 int speed = adev->pio_mode - XFER_PIO_0; 252 int speed = adev->pio_mode - XFER_PIO_0;
253 253
254 const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 }; 254 const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 };
@@ -328,7 +328,7 @@ static void sis_old_set_dmamode (struct ata_port *ap, struct ata_device *adev)
328{ 328{
329 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 329 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
330 int speed = adev->dma_mode - XFER_MW_DMA_0; 330 int speed = adev->dma_mode - XFER_MW_DMA_0;
331 int drive_pci = sis_port_base(adev); 331 int drive_pci = sis_old_port_base(adev);
332 u16 timing; 332 u16 timing;
333 333
334 const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; 334 const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
@@ -367,7 +367,7 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev)
367{ 367{
368 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 368 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
369 int speed = adev->dma_mode - XFER_MW_DMA_0; 369 int speed = adev->dma_mode - XFER_MW_DMA_0;
370 int drive_pci = sis_port_base(adev); 370 int drive_pci = sis_old_port_base(adev);
371 u16 timing; 371 u16 timing;
372 372
373 const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; 373 const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
@@ -378,12 +378,12 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev)
378 if (adev->dma_mode < XFER_UDMA_0) { 378 if (adev->dma_mode < XFER_UDMA_0) {
379 /* bits 3-0 hold recovery timing bits 8-10 active timing and 379 /* bits 3-0 hold recovery timing bits 8-10 active timing and
380 the higer bits are dependant on the device, bit 15 udma */ 380 the higer bits are dependant on the device, bit 15 udma */
381 timing &= ~ 0x870F; 381 timing &= ~0x870F;
382 timing |= mwdma_bits[speed]; 382 timing |= mwdma_bits[speed];
383 } else { 383 } else {
384 /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ 384 /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
385 speed = adev->dma_mode - XFER_UDMA_0; 385 speed = adev->dma_mode - XFER_UDMA_0;
386 timing &= ~0x6000; 386 timing &= ~0xF000;
387 timing |= udma_bits[speed]; 387 timing |= udma_bits[speed];
388 } 388 }
389 pci_write_config_word(pdev, drive_pci, timing); 389 pci_write_config_word(pdev, drive_pci, timing);
@@ -405,22 +405,22 @@ static void sis_100_set_dmamode (struct ata_port *ap, struct ata_device *adev)
405{ 405{
406 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 406 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
407 int speed = adev->dma_mode - XFER_MW_DMA_0; 407 int speed = adev->dma_mode - XFER_MW_DMA_0;
408 int drive_pci = sis_port_base(adev); 408 int drive_pci = sis_old_port_base(adev);
409 u16 timing; 409 u8 timing;
410 410
411 const u16 udma_bits[] = { 0x8B00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100}; 411 const u8 udma_bits[] = { 0x8B, 0x87, 0x85, 0x83, 0x82, 0x81};
412 412
413 pci_read_config_word(pdev, drive_pci, &timing); 413 pci_read_config_byte(pdev, drive_pci + 1, &timing);
414 414
415 if (adev->dma_mode < XFER_UDMA_0) { 415 if (adev->dma_mode < XFER_UDMA_0) {
416 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ 416 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
417 } else { 417 } else {
418 /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ 418 /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
419 speed = adev->dma_mode - XFER_UDMA_0; 419 speed = adev->dma_mode - XFER_UDMA_0;
420 timing &= ~0x0F00; 420 timing &= ~0x8F;
421 timing |= udma_bits[speed]; 421 timing |= udma_bits[speed];
422 } 422 }
423 pci_write_config_word(pdev, drive_pci, timing); 423 pci_write_config_byte(pdev, drive_pci + 1, timing);
424} 424}
425 425
426/** 426/**
@@ -440,22 +440,22 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
440{ 440{
441 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 441 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
442 int speed = adev->dma_mode - XFER_MW_DMA_0; 442 int speed = adev->dma_mode - XFER_MW_DMA_0;
443 int drive_pci = sis_port_base(adev); 443 int drive_pci = sis_old_port_base(adev);
444 u16 timing; 444 u8 timing;
445 445 /* Low 4 bits are timing */
446 static const u16 udma_bits[] = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100}; 446 static const u8 udma_bits[] = { 0x8F, 0x8A, 0x87, 0x85, 0x83, 0x82, 0x81};
447 447
448 pci_read_config_word(pdev, drive_pci, &timing); 448 pci_read_config_byte(pdev, drive_pci + 1, &timing);
449 449
450 if (adev->dma_mode < XFER_UDMA_0) { 450 if (adev->dma_mode < XFER_UDMA_0) {
451 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ 451 /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
452 } else { 452 } else {
453 /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ 453 /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
454 speed = adev->dma_mode - XFER_UDMA_0; 454 speed = adev->dma_mode - XFER_UDMA_0;
455 timing &= ~0x0F00; 455 timing &= ~0x8F;
456 timing |= udma_bits[speed]; 456 timing |= udma_bits[speed];
457 } 457 }
458 pci_write_config_word(pdev, drive_pci, timing); 458 pci_write_config_byte(pdev, drive_pci + 1, timing);
459} 459}
460 460
461/** 461/**
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index f48491ad5f3a..e5aaec43694d 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -26,7 +26,7 @@
26#include <linux/libata.h> 26#include <linux/libata.h>
27 27
28#define DRV_NAME "pata_sl82c105" 28#define DRV_NAME "pata_sl82c105"
29#define DRV_VERSION "0.3.0" 29#define DRV_VERSION "0.3.1"
30 30
31enum { 31enum {
32 /* 32 /*
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index e4c71f76bd55..a8462f1e890b 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -60,6 +60,7 @@
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <scsi/scsi_host.h> 61#include <scsi/scsi_host.h>
62#include <linux/libata.h> 62#include <linux/libata.h>
63#include <linux/dmi.h>
63 64
64#define DRV_NAME "pata_via" 65#define DRV_NAME "pata_via"
65#define DRV_VERSION "0.3.1" 66#define DRV_VERSION "0.3.1"
@@ -122,6 +123,31 @@ static const struct via_isa_bridge {
122 { NULL } 123 { NULL }
123}; 124};
124 125
126
127/*
128 * Cable special cases
129 */
130
131static struct dmi_system_id cable_dmi_table[] = {
132 {
133 .ident = "Acer Ferrari 3400",
134 .matches = {
135 DMI_MATCH(DMI_BOARD_VENDOR, "Acer,Inc."),
136 DMI_MATCH(DMI_BOARD_NAME, "Ferrari 3400"),
137 },
138 },
139 { }
140};
141
142static int via_cable_override(struct pci_dev *pdev)
143{
144 /* Systems by DMI */
145 if (dmi_check_system(cable_dmi_table))
146 return 1;
147 return 0;
148}
149
150
125/** 151/**
126 * via_cable_detect - cable detection 152 * via_cable_detect - cable detection
127 * @ap: ATA port 153 * @ap: ATA port
@@ -139,6 +165,9 @@ static int via_cable_detect(struct ata_port *ap) {
139 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 165 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
140 u32 ata66; 166 u32 ata66;
141 167
168 if (via_cable_override(pdev))
169 return ATA_CBL_PATA40_SHORT;
170
142 /* Early chips are 40 wire */ 171 /* Early chips are 40 wire */
143 if ((config->flags & VIA_UDMA) < VIA_UDMA_66) 172 if ((config->flags & VIA_UDMA) < VIA_UDMA_66)
144 return ATA_CBL_PATA40; 173 return ATA_CBL_PATA40;
@@ -592,10 +621,11 @@ static int via_reinit_one(struct pci_dev *pdev)
592#endif 621#endif
593 622
594static const struct pci_device_id via[] = { 623static const struct pci_device_id via[] = {
595 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), }, 624 { PCI_VDEVICE(VIA, 0x0571), },
596 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), }, 625 { PCI_VDEVICE(VIA, 0x0581), },
597 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), }, 626 { PCI_VDEVICE(VIA, 0x1571), },
598 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), }, 627 { PCI_VDEVICE(VIA, 0x3164), },
628 { PCI_VDEVICE(VIA, 0x5324), },
599 629
600 { }, 630 { },
601}; 631};
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index cc4ad271afb5..83abfeca4057 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -16,7 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17 17
18#define DRV_NAME "pata_winbond" 18#define DRV_NAME "pata_winbond"
19#define DRV_VERSION "0.0.2" 19#define DRV_VERSION "0.0.3"
20 20
21#define NR_HOST 4 /* Two winbond controllers, two channels each */ 21#define NR_HOST 4 /* Two winbond controllers, two channels each */
22 22
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 52b69530ab29..f12c2b6ac08e 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -44,7 +44,7 @@
44#include <linux/libata.h> 44#include <linux/libata.h>
45 45
46#define DRV_NAME "pdc_adma" 46#define DRV_NAME "pdc_adma"
47#define DRV_VERSION "0.05" 47#define DRV_VERSION "0.06"
48 48
49/* macro to calculate base address for ATA regs */ 49/* macro to calculate base address for ATA regs */
50#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) 50#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40))
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index bda5e7747c21..2d80c9d95e95 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -28,7 +28,7 @@
28#include <scsi/scsi_device.h> 28#include <scsi/scsi_device.h>
29 29
30#define DRV_NAME "sata_inic162x" 30#define DRV_NAME "sata_inic162x"
31#define DRV_VERSION "0.1" 31#define DRV_VERSION "0.2"
32 32
33enum { 33enum {
34 MMIO_BAR = 5, 34 MMIO_BAR = 5,
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index cb9b9ac12b4c..c957e6e54ba1 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -21,6 +21,50 @@
21 * 21 *
22 */ 22 */
23 23
24/*
25 sata_mv TODO list:
26
27 1) Needs a full errata audit for all chipsets. I implemented most
28 of the errata workarounds found in the Marvell vendor driver, but
29 I distinctly remember a couple workarounds (one related to PCI-X)
30 are still needed.
31
32 2) Convert to LibATA new EH. Required for hotplug, NCQ, and sane
33 probing/error handling in general. MUST HAVE.
34
35 3) Add hotplug support (easy, once new-EH support appears)
36
37 4) Add NCQ support (easy to intermediate, once new-EH support appears)
38
39 5) Investigate problems with PCI Message Signalled Interrupts (MSI).
40
41 6) Add port multiplier support (intermediate)
42
43 7) Test and verify 3.0 Gbps support
44
45 8) Develop a low-power-consumption strategy, and implement it.
46
47 9) [Experiment, low priority] See if ATAPI can be supported using
48 "unknown FIS" or "vendor-specific FIS" support, or something creative
49 like that.
50
51 10) [Experiment, low priority] Investigate interrupt coalescing.
52 Quite often, especially with PCI Message Signalled Interrupts (MSI),
53 the overhead reduced by interrupt mitigation is quite often not
54 worth the latency cost.
55
56 11) [Experiment, Marvell value added] Is it possible to use target
57 mode to cross-connect two Linux boxes with Marvell cards? If so,
58 creating LibATA target mode support would be very interesting.
59
60 Target mode, for those without docs, is the ability to directly
61 connect two SATA controllers.
62
63 13) Verify that 7042 is fully supported. I only have a 6042.
64
65*/
66
67
24#include <linux/kernel.h> 68#include <linux/kernel.h>
25#include <linux/module.h> 69#include <linux/module.h>
26#include <linux/pci.h> 70#include <linux/pci.h>
@@ -35,7 +79,7 @@
35#include <linux/libata.h> 79#include <linux/libata.h>
36 80
37#define DRV_NAME "sata_mv" 81#define DRV_NAME "sata_mv"
38#define DRV_VERSION "0.8" 82#define DRV_VERSION "0.81"
39 83
40enum { 84enum {
41 /* BAR's are enumerated in terms of pci_resource_start() terms */ 85 /* BAR's are enumerated in terms of pci_resource_start() terms */
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 4cea3ef75226..adfa693db53d 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -49,7 +49,7 @@
49#include <linux/libata.h> 49#include <linux/libata.h>
50 50
51#define DRV_NAME "sata_nv" 51#define DRV_NAME "sata_nv"
52#define DRV_VERSION "3.3" 52#define DRV_VERSION "3.4"
53 53
54#define NV_ADMA_DMA_BOUNDARY 0xffffffffUL 54#define NV_ADMA_DMA_BOUNDARY 0xffffffffUL
55 55
@@ -229,7 +229,6 @@ struct nv_host_priv {
229#define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT))))) 229#define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT)))))
230 230
231static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 231static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
232static void nv_remove_one (struct pci_dev *pdev);
233#ifdef CONFIG_PM 232#ifdef CONFIG_PM
234static int nv_pci_device_resume(struct pci_dev *pdev); 233static int nv_pci_device_resume(struct pci_dev *pdev);
235#endif 234#endif
@@ -288,12 +287,6 @@ static const struct pci_device_id nv_pci_tbl[] = {
288 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 287 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
289 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 288 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
290 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 289 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
291 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
292 PCI_ANY_ID, PCI_ANY_ID,
293 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
294 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
295 PCI_ANY_ID, PCI_ANY_ID,
296 PCI_CLASS_STORAGE_RAID<<8, 0xffff00, GENERIC },
297 290
298 { } /* terminate list */ 291 { } /* terminate list */
299}; 292};
@@ -306,7 +299,7 @@ static struct pci_driver nv_pci_driver = {
306 .suspend = ata_pci_device_suspend, 299 .suspend = ata_pci_device_suspend,
307 .resume = nv_pci_device_resume, 300 .resume = nv_pci_device_resume,
308#endif 301#endif
309 .remove = nv_remove_one, 302 .remove = ata_pci_remove_one,
310}; 303};
311 304
312static struct scsi_host_template nv_sht = { 305static struct scsi_host_template nv_sht = {
@@ -809,7 +802,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
809 u16 status; 802 u16 status;
810 u32 gen_ctl; 803 u32 gen_ctl;
811 u32 notifier, notifier_error; 804 u32 notifier, notifier_error;
812 805
813 /* if ADMA is disabled, use standard ata interrupt handler */ 806 /* if ADMA is disabled, use standard ata interrupt handler */
814 if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) { 807 if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) {
815 u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804) 808 u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804)
@@ -970,7 +963,7 @@ static void nv_adma_irq_clear(struct ata_port *ap)
970 963
971 /* clear ADMA status */ 964 /* clear ADMA status */
972 writew(0xffff, mmio + NV_ADMA_STAT); 965 writew(0xffff, mmio + NV_ADMA_STAT);
973 966
974 /* clear notifiers - note both ports need to be written with 967 /* clear notifiers - note both ports need to be written with
975 something even though we are only clearing on one */ 968 something even though we are only clearing on one */
976 if (ap->port_no == 0) { 969 if (ap->port_no == 0) {
@@ -1613,15 +1606,6 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1613 IRQF_SHARED, ppi[0]->sht); 1606 IRQF_SHARED, ppi[0]->sht);
1614} 1607}
1615 1608
1616static void nv_remove_one (struct pci_dev *pdev)
1617{
1618 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1619 struct nv_host_priv *hpriv = host->private_data;
1620
1621 ata_pci_remove_one(pdev);
1622 kfree(hpriv);
1623}
1624
1625#ifdef CONFIG_PM 1609#ifdef CONFIG_PM
1626static int nv_pci_device_resume(struct pci_dev *pdev) 1610static int nv_pci_device_resume(struct pci_dev *pdev)
1627{ 1611{
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 3a7d9b5332af..2b924a69b365 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -297,7 +297,7 @@ static const struct ata_port_info pdc_port_info[] = {
297 297
298 /* board_2057x_pata */ 298 /* board_2057x_pata */
299 { 299 {
300 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, 300 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS |
301 PDC_FLAG_GEN_II, 301 PDC_FLAG_GEN_II,
302 .pio_mask = 0x1f, /* pio0-4 */ 302 .pio_mask = 0x1f, /* pio0-4 */
303 .mwdma_mask = 0x07, /* mwdma0-2 */ 303 .mwdma_mask = 0x07, /* mwdma0-2 */
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index f5a05de0093d..6688ccb66320 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -39,7 +39,7 @@
39#include <linux/libata.h> 39#include <linux/libata.h>
40 40
41#define DRV_NAME "sata_qstor" 41#define DRV_NAME "sata_qstor"
42#define DRV_VERSION "0.07" 42#define DRV_VERSION "0.08"
43 43
44enum { 44enum {
45 QS_MMIO_BAR = 4, 45 QS_MMIO_BAR = 4,
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index e8483aadd11b..a3b339bcf3cf 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -305,7 +305,7 @@ static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed)
305 u32 tmp, dev_mode[2]; 305 u32 tmp, dev_mode[2];
306 unsigned int i; 306 unsigned int i;
307 int rc; 307 int rc;
308 308
309 rc = ata_do_set_mode(ap, r_failed); 309 rc = ata_do_set_mode(ap, r_failed);
310 if (rc) 310 if (rc)
311 return rc; 311 return rc;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index a69d78cd8e9b..0ddfae9911cd 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -30,7 +30,7 @@
30#include <linux/libata.h> 30#include <linux/libata.h>
31 31
32#define DRV_NAME "sata_sil24" 32#define DRV_NAME "sata_sil24"
33#define DRV_VERSION "0.8" 33#define DRV_VERSION "0.9"
34 34
35/* 35/*
36 * Port request block (PRB) 32 bytes 36 * Port request block (PRB) 32 bytes
@@ -237,7 +237,8 @@ enum {
237 /* host flags */ 237 /* host flags */
238 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 238 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
239 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 239 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
240 ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY, 240 ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY |
241 ATA_FLAG_ACPI_SATA,
241 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */ 242 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */
242 243
243 IRQ_STAT_4PORTS = 0xf, 244 IRQ_STAT_4PORTS = 0xf,
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index ee66c5fa7ac8..221099d1d08f 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -43,7 +43,7 @@
43#include "sis.h" 43#include "sis.h"
44 44
45#define DRV_NAME "sata_sis" 45#define DRV_NAME "sata_sis"
46#define DRV_VERSION "0.7" 46#define DRV_VERSION "0.8"
47 47
48enum { 48enum {
49 sis_180 = 0, 49 sis_180 = 0,
@@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
255{ 255{
256 static int printed_version; 256 static int printed_version;
257 struct ata_port_info pi = sis_port_info; 257 struct ata_port_info pi = sis_port_info;
258 const struct ata_port_info *ppi[] = { &pi, NULL }; 258 const struct ata_port_info *ppi[] = { &pi, &pi };
259 struct ata_host *host; 259 struct ata_host *host;
260 u32 genctl, val; 260 u32 genctl, val;
261 u8 pmr; 261 u8 pmr;
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 17246734fe76..bcb2cd8b063d 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -53,7 +53,7 @@
53#endif /* CONFIG_PPC_OF */ 53#endif /* CONFIG_PPC_OF */
54 54
55#define DRV_NAME "sata_svw" 55#define DRV_NAME "sata_svw"
56#define DRV_VERSION "2.1" 56#define DRV_VERSION "2.2"
57 57
58enum { 58enum {
59 /* ap->flags bits */ 59 /* ap->flags bits */
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 3a4f44559d0a..2d14f3d56d92 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -44,7 +44,7 @@
44#include "sata_promise.h" 44#include "sata_promise.h"
45 45
46#define DRV_NAME "sata_sx4" 46#define DRV_NAME "sata_sx4"
47#define DRV_VERSION "0.10" 47#define DRV_VERSION "0.11"
48 48
49 49
50enum { 50enum {
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index 006f5e352658..6815de7cca79 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -36,7 +36,7 @@
36#include <linux/libata.h> 36#include <linux/libata.h>
37 37
38#define DRV_NAME "sata_uli" 38#define DRV_NAME "sata_uli"
39#define DRV_VERSION "1.1" 39#define DRV_VERSION "1.2"
40 40
41enum { 41enum {
42 uli_5289 = 0, 42 uli_5289 = 0,
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index d105d2c189d2..e8b90e7b42dd 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -46,7 +46,7 @@
46#include <linux/libata.h> 46#include <linux/libata.h>
47 47
48#define DRV_NAME "sata_via" 48#define DRV_NAME "sata_via"
49#define DRV_VERSION "2.1" 49#define DRV_VERSION "2.2"
50 50
51enum board_ids_enum { 51enum board_ids_enum {
52 vt6420, 52 vt6420,
@@ -85,6 +85,9 @@ static const struct pci_device_id svia_pci_tbl[] = {
85 { PCI_VDEVICE(VIA, 0x0591), vt6420 }, 85 { PCI_VDEVICE(VIA, 0x0591), vt6420 },
86 { PCI_VDEVICE(VIA, 0x3149), vt6420 }, 86 { PCI_VDEVICE(VIA, 0x3149), vt6420 },
87 { PCI_VDEVICE(VIA, 0x3249), vt6421 }, 87 { PCI_VDEVICE(VIA, 0x3249), vt6421 },
88 { PCI_VDEVICE(VIA, 0x5287), vt6420 },
89 { PCI_VDEVICE(VIA, 0x5372), vt6420 },
90 { PCI_VDEVICE(VIA, 0x7372), vt6420 },
88 91
89 { } /* terminate list */ 92 { } /* terminate list */
90}; 93};
@@ -441,7 +444,7 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
441 return -ENOMEM; 444 return -ENOMEM;
442 } 445 }
443 446
444 rc = pcim_iomap_regions(pdev, 0x1f, DRV_NAME); 447 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
445 if (rc) { 448 if (rc) {
446 dev_printk(KERN_ERR, &pdev->dev, "failed to request/iomap " 449 dev_printk(KERN_ERR, &pdev->dev, "failed to request/iomap "
447 "PCI BARs (errno=%d)\n", rc); 450 "PCI BARs (errno=%d)\n", rc);
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index 80126f835d32..81330175fc89 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -47,7 +47,7 @@
47#include <linux/libata.h> 47#include <linux/libata.h>
48 48
49#define DRV_NAME "sata_vsc" 49#define DRV_NAME "sata_vsc"
50#define DRV_VERSION "2.1" 50#define DRV_VERSION "2.2"
51 51
52enum { 52enum {
53 VSC_MMIO_BAR = 0, 53 VSC_MMIO_BAR = 0,
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 057efbc55d38..3800bc0cb2ef 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -47,7 +47,8 @@ static char const rcsid[] =
47#include <linux/bitops.h> 47#include <linux/bitops.h>
48#include <linux/wait.h> 48#include <linux/wait.h>
49#include <linux/jiffies.h> 49#include <linux/jiffies.h>
50#include <asm/semaphore.h> 50#include <linux/mutex.h>
51
51#include <asm/io.h> 52#include <asm/io.h>
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53#include <asm/atomic.h> 54#include <asm/atomic.h>
@@ -2435,7 +2436,7 @@ idt77252_open(struct atm_vcc *vcc)
2435 2436
2436 set_bit(ATM_VF_ADDR, &vcc->flags); 2437 set_bit(ATM_VF_ADDR, &vcc->flags);
2437 2438
2438 down(&card->mutex); 2439 mutex_lock(&card->mutex);
2439 2440
2440 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); 2441 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci);
2441 2442
@@ -2446,7 +2447,7 @@ idt77252_open(struct atm_vcc *vcc)
2446 break; 2447 break;
2447 default: 2448 default:
2448 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); 2449 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
2449 up(&card->mutex); 2450 mutex_unlock(&card->mutex);
2450 return -EPROTONOSUPPORT; 2451 return -EPROTONOSUPPORT;
2451 } 2452 }
2452 2453
@@ -2455,7 +2456,7 @@ idt77252_open(struct atm_vcc *vcc)
2455 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); 2456 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
2456 if (!card->vcs[index]) { 2457 if (!card->vcs[index]) {
2457 printk("%s: can't alloc vc in open()\n", card->name); 2458 printk("%s: can't alloc vc in open()\n", card->name);
2458 up(&card->mutex); 2459 mutex_unlock(&card->mutex);
2459 return -ENOMEM; 2460 return -ENOMEM;
2460 } 2461 }
2461 card->vcs[index]->card = card; 2462 card->vcs[index]->card = card;
@@ -2484,14 +2485,14 @@ idt77252_open(struct atm_vcc *vcc)
2484 if (inuse) { 2485 if (inuse) {
2485 printk("%s: %s vci already in use.\n", card->name, 2486 printk("%s: %s vci already in use.\n", card->name,
2486 inuse == 1 ? "tx" : inuse == 2 ? "rx" : "tx and rx"); 2487 inuse == 1 ? "tx" : inuse == 2 ? "rx" : "tx and rx");
2487 up(&card->mutex); 2488 mutex_unlock(&card->mutex);
2488 return -EADDRINUSE; 2489 return -EADDRINUSE;
2489 } 2490 }
2490 2491
2491 if (vcc->qos.txtp.traffic_class != ATM_NONE) { 2492 if (vcc->qos.txtp.traffic_class != ATM_NONE) {
2492 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); 2493 error = idt77252_init_tx(card, vc, vcc, &vcc->qos);
2493 if (error) { 2494 if (error) {
2494 up(&card->mutex); 2495 mutex_unlock(&card->mutex);
2495 return error; 2496 return error;
2496 } 2497 }
2497 } 2498 }
@@ -2499,14 +2500,14 @@ idt77252_open(struct atm_vcc *vcc)
2499 if (vcc->qos.rxtp.traffic_class != ATM_NONE) { 2500 if (vcc->qos.rxtp.traffic_class != ATM_NONE) {
2500 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); 2501 error = idt77252_init_rx(card, vc, vcc, &vcc->qos);
2501 if (error) { 2502 if (error) {
2502 up(&card->mutex); 2503 mutex_unlock(&card->mutex);
2503 return error; 2504 return error;
2504 } 2505 }
2505 } 2506 }
2506 2507
2507 set_bit(ATM_VF_READY, &vcc->flags); 2508 set_bit(ATM_VF_READY, &vcc->flags);
2508 2509
2509 up(&card->mutex); 2510 mutex_unlock(&card->mutex);
2510 return 0; 2511 return 0;
2511} 2512}
2512 2513
@@ -2520,7 +2521,7 @@ idt77252_close(struct atm_vcc *vcc)
2520 unsigned long addr; 2521 unsigned long addr;
2521 unsigned long timeout; 2522 unsigned long timeout;
2522 2523
2523 down(&card->mutex); 2524 mutex_lock(&card->mutex);
2524 2525
2525 IPRINTK("%s: idt77252_close: vc = %d (%d.%d)\n", 2526 IPRINTK("%s: idt77252_close: vc = %d (%d.%d)\n",
2526 card->name, vc->index, vcc->vpi, vcc->vci); 2527 card->name, vc->index, vcc->vpi, vcc->vci);
@@ -2591,7 +2592,7 @@ done:
2591 free_scq(card, vc->scq); 2592 free_scq(card, vc->scq);
2592 } 2593 }
2593 2594
2594 up(&card->mutex); 2595 mutex_unlock(&card->mutex);
2595} 2596}
2596 2597
2597static int 2598static int
@@ -2602,7 +2603,7 @@ idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos, int flags)
2602 struct vc_map *vc = vcc->dev_data; 2603 struct vc_map *vc = vcc->dev_data;
2603 int error = 0; 2604 int error = 0;
2604 2605
2605 down(&card->mutex); 2606 mutex_lock(&card->mutex);
2606 2607
2607 if (qos->txtp.traffic_class != ATM_NONE) { 2608 if (qos->txtp.traffic_class != ATM_NONE) {
2608 if (!test_bit(VCF_TX, &vc->flags)) { 2609 if (!test_bit(VCF_TX, &vc->flags)) {
@@ -2648,7 +2649,7 @@ idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos, int flags)
2648 set_bit(ATM_VF_HASQOS, &vcc->flags); 2649 set_bit(ATM_VF_HASQOS, &vcc->flags);
2649 2650
2650out: 2651out:
2651 up(&card->mutex); 2652 mutex_unlock(&card->mutex);
2652 return error; 2653 return error;
2653} 2654}
2654 2655
@@ -3709,7 +3710,7 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3709 membase = pci_resource_start(pcidev, 1); 3710 membase = pci_resource_start(pcidev, 1);
3710 srambase = pci_resource_start(pcidev, 2); 3711 srambase = pci_resource_start(pcidev, 2);
3711 3712
3712 init_MUTEX(&card->mutex); 3713 mutex_init(&card->mutex);
3713 spin_lock_init(&card->cmd_lock); 3714 spin_lock_init(&card->cmd_lock);
3714 spin_lock_init(&card->tst_lock); 3715 spin_lock_init(&card->tst_lock);
3715 3716
diff --git a/drivers/atm/idt77252.h b/drivers/atm/idt77252.h
index 544b39738291..6f2b4a5875fb 100644
--- a/drivers/atm/idt77252.h
+++ b/drivers/atm/idt77252.h
@@ -37,7 +37,7 @@
37#include <linux/ptrace.h> 37#include <linux/ptrace.h>
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40 40#include <linux/mutex.h>
41 41
42/*****************************************************************************/ 42/*****************************************************************************/
43/* */ 43/* */
@@ -359,7 +359,7 @@ struct idt77252_dev
359 unsigned long srambase; /* SAR's sram base address */ 359 unsigned long srambase; /* SAR's sram base address */
360 void __iomem *fbq[4]; /* FBQ fill addresses */ 360 void __iomem *fbq[4]; /* FBQ fill addresses */
361 361
362 struct semaphore mutex; 362 struct mutex mutex;
363 spinlock_t cmd_lock; /* for r/w utility/sram */ 363 spinlock_t cmd_lock; /* for r/w utility/sram */
364 364
365 unsigned long softstat; 365 unsigned long softstat;
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 9406259754ad..91970e9bb05e 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -8,6 +8,7 @@
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/poison.h> 10#include <linux/poison.h>
11#include <linux/sched.h>
11 12
12/* 13/*
13 * Pool allocator ... wraps the dma_alloc_coherent page allocator, so 14 * Pool allocator ... wraps the dma_alloc_coherent page allocator, so
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 370dfe1c422e..5acc6c44aead 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3469,13 +3469,39 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3469 return -1; 3469 return -1;
3470} 3470}
3471 3471
3472static void cciss_remove_one(struct pci_dev *pdev) 3472static void cciss_shutdown(struct pci_dev *pdev)
3473{ 3473{
3474 ctlr_info_t *tmp_ptr; 3474 ctlr_info_t *tmp_ptr;
3475 int i, j; 3475 int i;
3476 char flush_buf[4]; 3476 char flush_buf[4];
3477 int return_code; 3477 int return_code;
3478 3478
3479 tmp_ptr = pci_get_drvdata(pdev);
3480 if (tmp_ptr == NULL)
3481 return;
3482 i = tmp_ptr->ctlr;
3483 if (hba[i] == NULL)
3484 return;
3485
3486 /* Turn board interrupts off and send the flush cache command */
3487 /* sendcmd will turn off interrupt, and send the flush...
3488 * To write all data in the battery backed cache to disks */
3489 memset(flush_buf, 0, 4);
3490 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL,
3491 TYPE_CMD);
3492 if (return_code == IO_OK) {
3493 printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
3494 } else {
3495 printk(KERN_WARNING "Error flushing cache on controller %d\n", i);
3496 }
3497 free_irq(hba[i]->intr[2], hba[i]);
3498}
3499
3500static void __devexit cciss_remove_one(struct pci_dev *pdev)
3501{
3502 ctlr_info_t *tmp_ptr;
3503 int i, j;
3504
3479 if (pci_get_drvdata(pdev) == NULL) { 3505 if (pci_get_drvdata(pdev) == NULL) {
3480 printk(KERN_ERR "cciss: Unable to remove device \n"); 3506 printk(KERN_ERR "cciss: Unable to remove device \n");
3481 return; 3507 return;
@@ -3506,18 +3532,7 @@ static void cciss_remove_one(struct pci_dev *pdev)
3506 3532
3507 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ 3533 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3508 3534
3509 /* Turn board interrupts off and send the flush cache command */ 3535 cciss_shutdown(pdev);
3510 /* sendcmd will turn off interrupt, and send the flush...
3511 * To write all data in the battery backed cache to disks */
3512 memset(flush_buf, 0, 4);
3513 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL,
3514 TYPE_CMD);
3515 if (return_code == IO_OK) {
3516 printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
3517 } else {
3518 printk(KERN_WARNING "Error flushing cache on controller %d\n", i);
3519 }
3520 free_irq(hba[i]->intr[2], hba[i]);
3521 3536
3522#ifdef CONFIG_PCI_MSI 3537#ifdef CONFIG_PCI_MSI
3523 if (hba[i]->msix_vector) 3538 if (hba[i]->msix_vector)
@@ -3550,7 +3565,7 @@ static struct pci_driver cciss_pci_driver = {
3550 .probe = cciss_init_one, 3565 .probe = cciss_init_one,
3551 .remove = __devexit_p(cciss_remove_one), 3566 .remove = __devexit_p(cciss_remove_one),
3552 .id_table = cciss_pci_device_id, /* id_table */ 3567 .id_table = cciss_pci_device_id, /* id_table */
3553 .shutdown = cciss_remove_one, 3568 .shutdown = cciss_shutdown,
3554}; 3569};
3555 3570
3556/* 3571/*
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 3587cb434371..fe088045dd08 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -670,7 +670,7 @@ static void __reschedule_timeout(int drive, const char *message, int marg)
670 if (drive == current_reqD) 670 if (drive == current_reqD)
671 drive = current_drive; 671 drive = current_drive;
672 del_timer(&fd_timeout); 672 del_timer(&fd_timeout);
673 if (drive < 0 || drive > N_DRIVE) { 673 if (drive < 0 || drive >= N_DRIVE) {
674 fd_timeout.expires = jiffies + 20UL * HZ; 674 fd_timeout.expires = jiffies + 20UL * HZ;
675 drive = 0; 675 drive = 0;
676 } else 676 } else
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index b0238b46dded..7e04dd69f609 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -115,11 +115,11 @@ static struct usb_device_id blacklist_ids[] = {
115 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 }, 115 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 },
116 116
117 /* Broadcom BCM2045 */ 117 /* Broadcom BCM2045 */
118 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = HCI_WRONG_SCO_MTU }, 118 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
119 119
120 /* IBM/Lenovo ThinkPad with Broadcom chip */ 120 /* IBM/Lenovo ThinkPad with Broadcom chip */
121 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU }, 121 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
122 { USB_DEVICE(0x0a5c, 0x2110), .driver_info = HCI_WRONG_SCO_MTU }, 122 { USB_DEVICE(0x0a5c, 0x2110), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
123 123
124 /* Targus ACB10US */ 124 /* Targus ACB10US */
125 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = HCI_RESET }, 125 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = HCI_RESET },
@@ -128,17 +128,17 @@ static struct usb_device_id blacklist_ids[] = {
128 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = HCI_RESET }, 128 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = HCI_RESET },
129 129
130 /* HP laptop with Broadcom chip */ 130 /* HP laptop with Broadcom chip */
131 { USB_DEVICE(0x03f0, 0x171d), .driver_info = HCI_WRONG_SCO_MTU }, 131 { USB_DEVICE(0x03f0, 0x171d), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
132 132
133 /* Dell laptop with Broadcom chip */ 133 /* Dell laptop with Broadcom chip */
134 { USB_DEVICE(0x413c, 0x8126), .driver_info = HCI_WRONG_SCO_MTU }, 134 { USB_DEVICE(0x413c, 0x8126), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
135 135
136 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ 136 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */
137 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, 137 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET },
138 138
139 /* Kensington Bluetooth USB adapter */ 139 /* Kensington Bluetooth USB adapter */
140 { USB_DEVICE(0x047d, 0x105d), .driver_info = HCI_RESET }, 140 { USB_DEVICE(0x047d, 0x105d), .driver_info = HCI_RESET },
141 { USB_DEVICE(0x047d, 0x105e), .driver_info = HCI_WRONG_SCO_MTU }, 141 { USB_DEVICE(0x047d, 0x105e), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
142 142
143 /* ISSC Bluetooth Adapter v3.1 */ 143 /* ISSC Bluetooth Adapter v3.1 */
144 { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET }, 144 { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET },
@@ -148,8 +148,8 @@ static struct usb_device_id blacklist_ids[] = {
148 { USB_DEVICE(0x0400, 0x080a), .driver_info = HCI_BROKEN_ISOC }, 148 { USB_DEVICE(0x0400, 0x080a), .driver_info = HCI_BROKEN_ISOC },
149 149
150 /* Belkin F8T012 and F8T013 devices */ 150 /* Belkin F8T012 and F8T013 devices */
151 { USB_DEVICE(0x050d, 0x0012), .driver_info = HCI_WRONG_SCO_MTU }, 151 { USB_DEVICE(0x050d, 0x0012), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
152 { USB_DEVICE(0x050d, 0x0013), .driver_info = HCI_WRONG_SCO_MTU }, 152 { USB_DEVICE(0x050d, 0x0013), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
153 153
154 /* Digianswer devices */ 154 /* Digianswer devices */
155 { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER }, 155 { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER },
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index abcafac64738..ef683ebd367c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -815,7 +815,7 @@ config SGI_IP27_RTC
815 815
816config GEN_RTC 816config GEN_RTC
817 tristate "Generic /dev/rtc emulation" 817 tristate "Generic /dev/rtc emulation"
818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 && !SUPERH
819 ---help--- 819 ---help---
820 If you say Y here and create a character special file /dev/rtc with 820 If you say Y here and create a character special file /dev/rtc with
821 major number 10 and minor number 135 using mknod ("man mknod"), you 821 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 679d7f972439..c7ed617aa7ff 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -37,6 +37,7 @@
37#include <linux/agpgart.h> 37#include <linux/agpgart.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <asm/pgtable.h> 42#include <asm/pgtable.h>
42#include "agp.h" 43#include "agp.h"
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 45aeb917ec63..d535c406b319 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -37,6 +37,7 @@
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h>
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/cacheflush.h> 42#include <asm/cacheflush.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index c72ee97d3892..ca376b92162c 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1061,6 +1061,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1061 1061
1062 if (data & info->ignore_status_mask) { 1062 if (data & info->ignore_status_mask) {
1063 info->icount.rx++; 1063 info->icount.rx++;
1064 spin_unlock(&cinfo->card_lock);
1064 return; 1065 return;
1065 } 1066 }
1066 if (tty_buffer_request_room(tty, 1)) { 1067 if (tty_buffer_request_room(tty, 1)) {
diff --git a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
index ef833a1c27eb..0b7ffa5191c6 100644
--- a/drivers/char/drm/Kconfig
+++ b/drivers/char/drm/Kconfig
@@ -6,7 +6,7 @@
6# 6#
7config DRM 7config DRM
8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)" 8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
9 depends on (AGP || AGP=n) && PCI 9 depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG
10 help 10 help
11 Kernel-level support for the Direct Rendering Infrastructure (DRI) 11 Kernel-level support for the Direct Rendering Infrastructure (DRI)
12 introduced in XFree86 4.0. If you say Y here, you need to select 12 introduced in XFree86 4.0. If you say Y here, you need to select
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index f0e7263dfcde..0e8ceea5ea78 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -48,7 +48,7 @@
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <linux/sysrq.h> 50#include <linux/sysrq.h>
51 51#include <linux/timer.h>
52 52
53#define VERSION_STR "0.9.0" 53#define VERSION_STR "0.9.0"
54 54
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 46c1b97748b6..0474cac4a84e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -760,7 +760,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
760 760
761static void extract_buf(struct entropy_store *r, __u8 *out) 761static void extract_buf(struct entropy_store *r, __u8 *out)
762{ 762{
763 int i, x; 763 int i;
764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS]; 764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS];
765 765
766 sha_init(buf); 766 sha_init(buf);
@@ -772,9 +772,11 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
772 * attempts to find previous ouputs), unless the hash 772 * attempts to find previous ouputs), unless the hash
773 * function can be inverted. 773 * function can be inverted.
774 */ 774 */
775 for (i = 0, x = 0; i < r->poolinfo->poolwords; i += 16, x+=2) { 775 for (i = 0; i < r->poolinfo->poolwords; i += 16) {
776 sha_transform(buf, (__u8 *)r->pool+i, buf + 5); 776 /* hash blocks of 16 words = 512 bits */
777 add_entropy_words(r, &buf[x % 5], 1); 777 sha_transform(buf, (__u8 *)(r->pool + i), buf + 5);
778 /* feed back portion of the resulting hash */
779 add_entropy_words(r, &buf[i % 5], 1);
778 } 780 }
779 781
780 /* 782 /*
@@ -782,7 +784,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
782 * portion of the pool while mixing, and hash one 784 * portion of the pool while mixing, and hash one
783 * final time. 785 * final time.
784 */ 786 */
785 __add_entropy_words(r, &buf[x % 5], 1, data); 787 __add_entropy_words(r, &buf[i % 5], 1, data);
786 sha_transform(buf, (__u8 *)data, buf + 5); 788 sha_transform(buf, (__u8 *)data, buf + 5);
787 789
788 /* 790 /*
@@ -1018,37 +1020,44 @@ random_poll(struct file *file, poll_table * wait)
1018 return mask; 1020 return mask;
1019} 1021}
1020 1022
1021static ssize_t 1023static int
1022random_write(struct file * file, const char __user * buffer, 1024write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1023 size_t count, loff_t *ppos)
1024{ 1025{
1025 int ret = 0;
1026 size_t bytes; 1026 size_t bytes;
1027 __u32 buf[16]; 1027 __u32 buf[16];
1028 const char __user *p = buffer; 1028 const char __user *p = buffer;
1029 size_t c = count;
1030 1029
1031 while (c > 0) { 1030 while (count > 0) {
1032 bytes = min(c, sizeof(buf)); 1031 bytes = min(count, sizeof(buf));
1032 if (copy_from_user(&buf, p, bytes))
1033 return -EFAULT;
1033 1034
1034 bytes -= copy_from_user(&buf, p, bytes); 1035 count -= bytes;
1035 if (!bytes) {
1036 ret = -EFAULT;
1037 break;
1038 }
1039 c -= bytes;
1040 p += bytes; 1036 p += bytes;
1041 1037
1042 add_entropy_words(&input_pool, buf, (bytes + 3) / 4); 1038 add_entropy_words(r, buf, (bytes + 3) / 4);
1043 }
1044 if (p == buffer) {
1045 return (ssize_t)ret;
1046 } else {
1047 struct inode *inode = file->f_path.dentry->d_inode;
1048 inode->i_mtime = current_fs_time(inode->i_sb);
1049 mark_inode_dirty(inode);
1050 return (ssize_t)(p - buffer);
1051 } 1039 }
1040
1041 return 0;
1042}
1043
1044static ssize_t
1045random_write(struct file * file, const char __user * buffer,
1046 size_t count, loff_t *ppos)
1047{
1048 size_t ret;
1049 struct inode *inode = file->f_path.dentry->d_inode;
1050
1051 ret = write_pool(&blocking_pool, buffer, count);
1052 if (ret)
1053 return ret;
1054 ret = write_pool(&nonblocking_pool, buffer, count);
1055 if (ret)
1056 return ret;
1057
1058 inode->i_mtime = current_fs_time(inode->i_sb);
1059 mark_inode_dirty(inode);
1060 return (ssize_t)count;
1052} 1061}
1053 1062
1054static int 1063static int
@@ -1087,8 +1096,8 @@ random_ioctl(struct inode * inode, struct file * file,
1087 return -EINVAL; 1096 return -EINVAL;
1088 if (get_user(size, p++)) 1097 if (get_user(size, p++))
1089 return -EFAULT; 1098 return -EFAULT;
1090 retval = random_write(file, (const char __user *) p, 1099 retval = write_pool(&input_pool, (const char __user *)p,
1091 size, &file->f_pos); 1100 size);
1092 if (retval < 0) 1101 if (retval < 0)
1093 return retval; 1102 return retval;
1094 credit_entropy_store(&input_pool, ent_count); 1103 credit_entropy_store(&input_pool, ent_count);
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
index 0e23f29f71ab..0f5c77ddd39d 100644
--- a/drivers/char/watchdog/booke_wdt.c
+++ b/drivers/char/watchdog/booke_wdt.c
@@ -24,7 +24,7 @@
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/system.h> 25#include <asm/system.h>
26 26
27/* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot. 27/* If the kernel parameter wdt=1, the watchdog will be enabled at boot.
28 * Also, the wdt_period sets the watchdog timer period timeout. 28 * Also, the wdt_period sets the watchdog timer period timeout.
29 * For E500 cpus the wdt_period sets which bit changing from 0->1 will 29 * For E500 cpus the wdt_period sets which bit changing from 0->1 will
30 * trigger a watchog timeout. This watchdog timeout will occur 3 times, the 30 * trigger a watchog timeout. This watchdog timeout will occur 3 times, the
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index e678a33ea672..bb90cbd7ca51 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -1,10 +1,10 @@
1menu "Hardware crypto devices" 1menu "Hardware crypto devices"
2 2
3config CRYPTO_DEV_PADLOCK 3config CRYPTO_DEV_PADLOCK
4 bool "Support for VIA PadLock ACE" 4 tristate "Support for VIA PadLock ACE"
5 depends on X86_32 5 depends on X86_32
6 select CRYPTO_ALGAPI 6 select CRYPTO_ALGAPI
7 default y 7 default m
8 help 8 help
9 Some VIA processors come with an integrated crypto engine 9 Some VIA processors come with an integrated crypto engine
10 (so called VIA PadLock ACE, Advanced Cryptography Engine) 10 (so called VIA PadLock ACE, Advanced Cryptography Engine)
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
index 6d3840e629de..6a86958b577f 100644
--- a/drivers/crypto/geode-aes.c
+++ b/drivers/crypto/geode-aes.c
@@ -102,10 +102,15 @@ geode_aes_crypt(struct geode_aes_op *op)
102 u32 flags = 0; 102 u32 flags = 0;
103 unsigned long iflags; 103 unsigned long iflags;
104 104
105 if (op->len == 0 || op->src == op->dst) 105 if (op->len == 0)
106 return 0; 106 return 0;
107 107
108 if (op->flags & AES_FLAGS_COHERENT) 108 /* If the source and destination is the same, then
109 * we need to turn on the coherent flags, otherwise
110 * we don't need to worry
111 */
112
113 if (op->src == op->dst)
109 flags |= (AES_CTRL_DCA | AES_CTRL_SCA); 114 flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
110 115
111 if (op->dir == AES_DIR_ENCRYPT) 116 if (op->dir == AES_DIR_ENCRYPT)
@@ -120,7 +125,7 @@ geode_aes_crypt(struct geode_aes_op *op)
120 _writefield(AES_WRITEIV0_REG, op->iv); 125 _writefield(AES_WRITEIV0_REG, op->iv);
121 } 126 }
122 127
123 if (op->flags & AES_FLAGS_USRKEY) { 128 if (!(op->flags & AES_FLAGS_HIDDENKEY)) {
124 flags |= AES_CTRL_WRKEY; 129 flags |= AES_CTRL_WRKEY;
125 _writefield(AES_WRITEKEY0_REG, op->key); 130 _writefield(AES_WRITEKEY0_REG, op->key);
126 } 131 }
@@ -289,6 +294,7 @@ static struct crypto_alg geode_cbc_alg = {
289 .setkey = geode_setkey, 294 .setkey = geode_setkey,
290 .encrypt = geode_cbc_encrypt, 295 .encrypt = geode_cbc_encrypt,
291 .decrypt = geode_cbc_decrypt, 296 .decrypt = geode_cbc_decrypt,
297 .ivsize = AES_IV_LENGTH,
292 } 298 }
293 } 299 }
294}; 300};
diff --git a/drivers/crypto/geode-aes.h b/drivers/crypto/geode-aes.h
index 8003a36f3a83..f47968671ae7 100644
--- a/drivers/crypto/geode-aes.h
+++ b/drivers/crypto/geode-aes.h
@@ -20,8 +20,7 @@
20#define AES_DIR_DECRYPT 0 20#define AES_DIR_DECRYPT 0
21#define AES_DIR_ENCRYPT 1 21#define AES_DIR_ENCRYPT 1
22 22
23#define AES_FLAGS_USRKEY (1 << 0) 23#define AES_FLAGS_HIDDENKEY (1 << 0)
24#define AES_FLAGS_COHERENT (1 << 1)
25 24
26struct geode_aes_op { 25struct geode_aes_op {
27 26
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
index 5932c72f9e42..396dade731f9 100644
--- a/drivers/firewire/Kconfig
+++ b/drivers/firewire/Kconfig
@@ -18,7 +18,7 @@ config FIREWIRE
18 your IEEE 1394 adapter. 18 your IEEE 1394 adapter.
19 19
20 To compile this driver as a module, say M here: the module will be 20 To compile this driver as a module, say M here: the module will be
21 called fw-core. 21 called firewire-core.
22 22
23 This is the "JUJU" FireWire stack, an alternative implementation 23 This is the "JUJU" FireWire stack, an alternative implementation
24 designed for robustness and simplicity. You can build either this 24 designed for robustness and simplicity. You can build either this
@@ -34,11 +34,11 @@ config FIREWIRE_OHCI
34 is the only chipset in use, so say Y here. 34 is the only chipset in use, so say Y here.
35 35
36 To compile this driver as a module, say M here: The module will be 36 To compile this driver as a module, say M here: The module will be
37 called fw-ohci. 37 called firewire-ohci.
38 38
39 If you also build ohci1394 of the classic IEEE 1394 driver stack, 39 If you also build ohci1394 of the classic IEEE 1394 driver stack,
40 blacklist either ohci1394 or fw-ohci to let hotplug load the desired 40 blacklist either ohci1394 or firewire-ohci to let hotplug load the
41 driver. 41 desired driver.
42 42
43config FIREWIRE_SBP2 43config FIREWIRE_SBP2
44 tristate "Support for storage devices (SBP-2 protocol driver)" 44 tristate "Support for storage devices (SBP-2 protocol driver)"
@@ -50,12 +50,12 @@ config FIREWIRE_SBP2
50 like scanners. 50 like scanners.
51 51
52 To compile this driver as a module, say M here: The module will be 52 To compile this driver as a module, say M here: The module will be
53 called fw-sbp2. 53 called firewire-sbp2.
54 54
55 You should also enable support for disks, CD-ROMs, etc. in the SCSI 55 You should also enable support for disks, CD-ROMs, etc. in the SCSI
56 configuration section. 56 configuration section.
57 57
58 If you also build sbp2 of the classic IEEE 1394 driver stack, 58 If you also build sbp2 of the classic IEEE 1394 driver stack,
59 blacklist either sbp2 or fw-sbp2 to let hotplug load the desired 59 blacklist either sbp2 or firewire-sbp2 to let hotplug load the
60 driver. 60 desired driver.
61 61
diff --git a/drivers/firewire/Makefile b/drivers/firewire/Makefile
index fc7d59d4bce0..a7c31e9039c1 100644
--- a/drivers/firewire/Makefile
+++ b/drivers/firewire/Makefile
@@ -2,9 +2,11 @@
2# Makefile for the Linux IEEE 1394 implementation 2# Makefile for the Linux IEEE 1394 implementation
3# 3#
4 4
5fw-core-y += fw-card.o fw-topology.o fw-transaction.o fw-iso.o \ 5firewire-core-y += fw-card.o fw-topology.o fw-transaction.o fw-iso.o \
6 fw-device.o fw-cdev.o 6 fw-device.o fw-cdev.o
7firewire-ohci-y += fw-ohci.o
8firewire-sbp2-y += fw-sbp2.o
7 9
8obj-$(CONFIG_FIREWIRE) += fw-core.o 10obj-$(CONFIG_FIREWIRE) += firewire-core.o
9obj-$(CONFIG_FIREWIRE_OHCI) += fw-ohci.o 11obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o
10obj-$(CONFIG_FIREWIRE_SBP2) += fw-sbp2.o 12obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 0fa5bd54c6a1..3ab3585d3601 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -365,7 +365,7 @@ complete_transaction(struct fw_card *card, int rcode,
365 response->response.data, response->response.length); 365 response->response.data, response->response.length);
366} 366}
367 367
368static ssize_t ioctl_send_request(struct client *client, void *buffer) 368static int ioctl_send_request(struct client *client, void *buffer)
369{ 369{
370 struct fw_device *device = client->device; 370 struct fw_device *device = client->device;
371 struct fw_cdev_send_request *request = buffer; 371 struct fw_cdev_send_request *request = buffer;
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index c17342d3e6fd..2e4cfa57126d 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -268,7 +268,7 @@ static int ar_context_add_page(struct ar_context *ctx)
268 268
269 dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL); 269 dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL);
270 270
271 ctx->last_buffer->descriptor.branch_address = ab_bus | 1; 271 ctx->last_buffer->descriptor.branch_address = cpu_to_le32(ab_bus | 1);
272 ctx->last_buffer->next = ab; 272 ctx->last_buffer->next = ab;
273 ctx->last_buffer = ab; 273 ctx->last_buffer = ab;
274 274
@@ -417,7 +417,8 @@ ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 regs)
417 ctx->current_buffer = ab.next; 417 ctx->current_buffer = ab.next;
418 ctx->pointer = ctx->current_buffer->data; 418 ctx->pointer = ctx->current_buffer->data;
419 419
420 reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ab.descriptor.branch_address); 420 reg_write(ctx->ohci, COMMAND_PTR(ctx->regs),
421 le32_to_cpu(ab.descriptor.branch_address));
421 reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN); 422 reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN);
422 flush_writes(ctx->ohci); 423 flush_writes(ctx->ohci);
423 424
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 4d1cb5b855d1..13eea47dceb3 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -620,7 +620,7 @@ config SENSORS_HDAPS
620 620
621config SENSORS_APPLESMC 621config SENSORS_APPLESMC
622 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" 622 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
623 depends on HWMON && INPUT && X86 623 depends on INPUT && X86
624 select NEW_LEDS 624 select NEW_LEDS
625 select LEDS_CLASS 625 select LEDS_CLASS
626 default n 626 default n
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 0c160675b3ac..fd1281f42209 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -491,6 +491,12 @@ out:
491 491
492/* Sysfs Files */ 492/* Sysfs Files */
493 493
494static ssize_t applesmc_name_show(struct device *dev,
495 struct device_attribute *attr, char *buf)
496{
497 return snprintf(buf, PAGE_SIZE, "applesmc\n");
498}
499
494static ssize_t applesmc_position_show(struct device *dev, 500static ssize_t applesmc_position_show(struct device *dev,
495 struct device_attribute *attr, char *buf) 501 struct device_attribute *attr, char *buf)
496{ 502{
@@ -913,6 +919,8 @@ static struct led_classdev applesmc_backlight = {
913 .brightness_set = applesmc_brightness_set, 919 .brightness_set = applesmc_brightness_set,
914}; 920};
915 921
922static DEVICE_ATTR(name, 0444, applesmc_name_show, NULL);
923
916static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL); 924static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
917static DEVICE_ATTR(calibrate, 0644, 925static DEVICE_ATTR(calibrate, 0644,
918 applesmc_calibrate_show, applesmc_calibrate_store); 926 applesmc_calibrate_show, applesmc_calibrate_store);
@@ -1197,10 +1205,14 @@ static int __init applesmc_init(void)
1197 goto out_driver; 1205 goto out_driver;
1198 } 1206 }
1199 1207
1208 ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_name.attr);
1209 if (ret)
1210 goto out_device;
1211
1200 /* Create key enumeration sysfs files */ 1212 /* Create key enumeration sysfs files */
1201 ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group); 1213 ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group);
1202 if (ret) 1214 if (ret)
1203 goto out_device; 1215 goto out_name;
1204 1216
1205 /* create fan files */ 1217 /* create fan files */
1206 count = applesmc_get_fan_count(); 1218 count = applesmc_get_fan_count();
@@ -1300,6 +1312,8 @@ out_fan_1:
1300 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); 1312 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
1301out_key_enumeration: 1313out_key_enumeration:
1302 sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); 1314 sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
1315out_name:
1316 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
1303out_device: 1317out_device:
1304 platform_device_unregister(pdev); 1318 platform_device_unregister(pdev);
1305out_driver: 1319out_driver:
@@ -1325,6 +1339,7 @@ static void __exit applesmc_exit(void)
1325 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); 1339 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]);
1326 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); 1340 sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
1327 sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); 1341 sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
1342 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
1328 platform_device_unregister(pdev); 1343 platform_device_unregister(pdev);
1329 platform_driver_unregister(&applesmc_driver); 1344 platform_driver_unregister(&applesmc_driver);
1330 release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS); 1345 release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 75e3911810a3..0328382df8fa 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -176,6 +176,22 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
176 goto exit_free; 176 goto exit_free;
177 } 177 }
178 178
179 /* Check if we have problem with errata AE18 of Core processors:
180 Readings might stop update when processor visited too deep sleep,
181 fixed for stepping D0 (6EC).
182 */
183
184 if ((c->x86_model == 0xe) && (c->x86_mask < 0xc)) {
185 /* check for microcode update */
186 rdmsr_on_cpu(data->id, MSR_IA32_UCODE_REV, &eax, &edx);
187 if (edx < 0x39) {
188 dev_err(&pdev->dev,
189 "Errata AE18 not fixed, update BIOS or "
190 "microcode of the CPU!\n");
191 goto exit_free;
192 }
193 }
194
179 /* Some processors have Tjmax 85 following magic should detect it 195 /* Some processors have Tjmax 85 following magic should detect it
180 Intel won't disclose the information without signed NDA, but 196 Intel won't disclose the information without signed NDA, but
181 individuals cannot sign it. Catch(ed) 22. 197 individuals cannot sign it. Catch(ed) 22.
@@ -193,6 +209,19 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
193 } 209 }
194 } 210 }
195 211
212 /* Intel says that above should not work for desktop Core2 processors,
213 but it seems to work. There is no other way how get the absolute
214 readings. Warn the user about this. First check if are desktop,
215 bit 50 of MSR_IA32_PLATFORM_ID should be 0.
216 */
217
218 rdmsr_safe_on_cpu(data->id, MSR_IA32_PLATFORM_ID, &eax, &edx);
219
220 if ((c->x86_model == 0xf) && (!(edx & 0x00040000))) {
221 dev_warn(&pdev->dev, "Using undocumented features, absolute "
222 "temperature might be wrong!\n");
223 }
224
196 platform_set_drvdata(pdev, data); 225 platform_set_drvdata(pdev, data);
197 226
198 if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group))) 227 if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
@@ -330,9 +359,6 @@ static int __init coretemp_init(void)
330 int i, err = -ENODEV; 359 int i, err = -ENODEV;
331 struct pdev_entry *p, *n; 360 struct pdev_entry *p, *n;
332 361
333 printk(KERN_NOTICE DRVNAME ": This driver uses undocumented features "
334 "of Core CPU. Temperature might be wrong!\n");
335
336 /* quick check if we run Intel */ 362 /* quick check if we run Intel */
337 if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL) 363 if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL)
338 goto exit; 364 goto exit;
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index c849c0c6ee9c..d5ac422d73b2 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -53,8 +53,8 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
53 53
54/* The DS1621 registers */ 54/* The DS1621 registers */
55#define DS1621_REG_TEMP 0xAA /* word, RO */ 55#define DS1621_REG_TEMP 0xAA /* word, RO */
56#define DS1621_REG_TEMP_MIN 0xA1 /* word, RW */ 56#define DS1621_REG_TEMP_MIN 0xA2 /* word, RW */
57#define DS1621_REG_TEMP_MAX 0xA2 /* word, RW */ 57#define DS1621_REG_TEMP_MAX 0xA1 /* word, RW */
58#define DS1621_REG_CONF 0xAC /* byte, RW */ 58#define DS1621_REG_CONF 0xAC /* byte, RW */
59#define DS1621_COM_START 0xEE /* no data */ 59#define DS1621_COM_START 0xEE /* no data */
60#define DS1621_COM_STOP 0x22 /* no data */ 60#define DS1621_COM_STOP 0x22 /* no data */
@@ -328,9 +328,9 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
328 328
329 /* reset alarms if necessary */ 329 /* reset alarms if necessary */
330 new_conf = data->conf; 330 new_conf = data->conf;
331 if (data->temp < data->temp_min) 331 if (data->temp > data->temp_min)
332 new_conf &= ~DS1621_ALARM_TEMP_LOW; 332 new_conf &= ~DS1621_ALARM_TEMP_LOW;
333 if (data->temp > data->temp_max) 333 if (data->temp < data->temp_max)
334 new_conf &= ~DS1621_ALARM_TEMP_HIGH; 334 new_conf &= ~DS1621_ALARM_TEMP_HIGH;
335 if (data->conf != new_conf) 335 if (data->conf != new_conf)
336 ds1621_write_value(client, DS1621_REG_CONF, 336 ds1621_write_value(client, DS1621_REG_CONF,
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
index 5aab23b93e24..f17e771e42f8 100644
--- a/drivers/hwmon/hwmon-vid.c
+++ b/drivers/hwmon/hwmon-vid.c
@@ -132,7 +132,9 @@ int vid_from_reg(int val, u8 vrm)
132 val &= 0x7f; 132 val &= 0x7f;
133 return(val > 0x77 ? 0 : (1500000 - (val * 12500) + 500) / 1000); 133 return(val > 0x77 ? 0 : (1500000 - (val * 12500) + 500) / 1000);
134 default: /* report 0 for unknown */ 134 default: /* report 0 for unknown */
135 printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); 135 if (vrm)
136 printk(KERN_WARNING "hwmon-vid: Requested unsupported "
137 "VRM version (%u)\n", (unsigned int)vrm);
136 return 0; 138 return 0;
137 } 139 }
138} 140}
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index a5b774b07cbd..12cb40a975de 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -965,8 +965,10 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
965 case W687THF_DEVID: 965 case W687THF_DEVID:
966 sio_data->type = w83687thf; 966 sio_data->type = w83687thf;
967 break; 967 break;
968 case 0xff: /* No device at all */
969 goto exit;
968 default: 970 default:
969 pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%x)\n", val); 971 pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%02x)\n", val);
970 goto exit; 972 goto exit;
971 } 973 }
972 974
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 8a0a99b93641..28e7b91a4553 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -837,20 +837,10 @@ static const struct i2c_algorithm i2c_pxa_algorithm = {
837 .functionality = i2c_pxa_functionality, 837 .functionality = i2c_pxa_functionality,
838}; 838};
839 839
840static struct pxa_i2c i2c_pxa = {
841 .lock = __SPIN_LOCK_UNLOCKED(i2c_pxa.lock),
842 .adap = {
843 .owner = THIS_MODULE,
844 .algo = &i2c_pxa_algorithm,
845 .name = "pxa2xx-i2c.0",
846 .retries = 5,
847 },
848};
849
850#define res_len(r) ((r)->end - (r)->start + 1) 840#define res_len(r) ((r)->end - (r)->start + 1)
851static int i2c_pxa_probe(struct platform_device *dev) 841static int i2c_pxa_probe(struct platform_device *dev)
852{ 842{
853 struct pxa_i2c *i2c = &i2c_pxa; 843 struct pxa_i2c *i2c;
854 struct resource *res; 844 struct resource *res;
855 struct i2c_pxa_platform_data *plat = dev->dev.platform_data; 845 struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
856 int ret; 846 int ret;
@@ -864,15 +854,20 @@ static int i2c_pxa_probe(struct platform_device *dev)
864 if (!request_mem_region(res->start, res_len(res), res->name)) 854 if (!request_mem_region(res->start, res_len(res), res->name))
865 return -ENOMEM; 855 return -ENOMEM;
866 856
867 i2c = kmalloc(sizeof(struct pxa_i2c), GFP_KERNEL); 857 i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
868 if (!i2c) { 858 if (!i2c) {
869 ret = -ENOMEM; 859 ret = -ENOMEM;
870 goto emalloc; 860 goto emalloc;
871 } 861 }
872 862
873 memcpy(i2c, &i2c_pxa, sizeof(struct pxa_i2c)); 863 i2c->adap.owner = THIS_MODULE;
864 i2c->adap.algo = &i2c_pxa_algorithm;
865 i2c->adap.retries = 5;
866
867 spin_lock_init(&i2c->lock);
874 init_waitqueue_head(&i2c->wait); 868 init_waitqueue_head(&i2c->wait);
875 i2c->adap.name[strlen(i2c->adap.name) - 1] = '0' + dev->id % 10; 869
870 sprintf(i2c->adap.name, "pxa_i2c-i2c.%u", dev->id);
876 871
877 i2c->reg_base = ioremap(res->start, res_len(res)); 872 i2c->reg_base = ioremap(res->start, res_len(res));
878 if (!i2c->reg_base) { 873 if (!i2c->reg_base) {
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index e68a96f589fd..e4540fcf6476 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -830,7 +830,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
830 830
831 i2c->irq = res; 831 i2c->irq = res;
832 832
833 dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start); 833 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
834 (unsigned long)res->start);
834 835
835 ret = i2c_add_adapter(&i2c->adap); 836 ret = i2c_add_adapter(&i2c->adap);
836 if (ret < 0) { 837 if (ret < 0) {
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index 907999049d50..cb9abe7565a7 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -208,7 +208,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
208 dev->adapter.class = I2C_CLASS_HWMON; 208 dev->adapter.class = I2C_CLASS_HWMON;
209 dev->adapter.algo = &usb_algorithm; 209 dev->adapter.algo = &usb_algorithm;
210 dev->adapter.algo_data = dev; 210 dev->adapter.algo_data = dev;
211 snprintf(dev->adapter.name, I2C_NAME_SIZE, 211 snprintf(dev->adapter.name, sizeof(dev->adapter.name),
212 "i2c-tiny-usb at bus %03d device %03d", 212 "i2c-tiny-usb at bus %03d device %03d",
213 dev->usb_dev->bus->busnum, dev->usb_dev->devnum); 213 dev->usb_dev->bus->busnum, dev->usb_dev->devnum);
214 214
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 64f8e56d300e..435925eba437 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -697,9 +697,10 @@ int i2c_attach_client(struct i2c_client *client)
697 if (client->driver) 697 if (client->driver)
698 client->dev.driver = &client->driver->driver; 698 client->dev.driver = &client->driver->driver;
699 699
700 if (client->driver && !is_newstyle_driver(client->driver)) 700 if (client->driver && !is_newstyle_driver(client->driver)) {
701 client->dev.release = i2c_client_release; 701 client->dev.release = i2c_client_release;
702 else 702 client->dev.uevent_suppress = 1;
703 } else
703 client->dev.release = i2c_client_dev_release; 704 client->dev.release = i2c_client_dev_release;
704 705
705 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 706 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index b77b7d138c49..ead141e2db9e 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -119,15 +119,17 @@ static const struct drive_list_entry drive_blacklist [] = {
119 { "HITACHI CDR-8335" , "ALL" }, 119 { "HITACHI CDR-8335" , "ALL" },
120 { "HITACHI CDR-8435" , "ALL" }, 120 { "HITACHI CDR-8435" , "ALL" },
121 { "Toshiba CD-ROM XM-6202B" , "ALL" }, 121 { "Toshiba CD-ROM XM-6202B" , "ALL" },
122 { "TOSHIBA CD-ROM XM-1702BC", "ALL" },
122 { "CD-532E-A" , "ALL" }, 123 { "CD-532E-A" , "ALL" },
123 { "E-IDE CD-ROM CR-840", "ALL" }, 124 { "E-IDE CD-ROM CR-840", "ALL" },
124 { "CD-ROM Drive/F5A", "ALL" }, 125 { "CD-ROM Drive/F5A", "ALL" },
125 { "WPI CDD-820", "ALL" }, 126 { "WPI CDD-820", "ALL" },
126 { "SAMSUNG CD-ROM SC-148C", "ALL" }, 127 { "SAMSUNG CD-ROM SC-148C", "ALL" },
127 { "SAMSUNG CD-ROM SC", "ALL" }, 128 { "SAMSUNG CD-ROM SC", "ALL" },
128 { "SanDisk SDP3B-64" , "ALL" },
129 { "ATAPI CD-ROM DRIVE 40X MAXIMUM", "ALL" }, 129 { "ATAPI CD-ROM DRIVE 40X MAXIMUM", "ALL" },
130 { "_NEC DV5800A", "ALL" }, 130 { "_NEC DV5800A", "ALL" },
131 { "SAMSUNG CD-ROM SN-124", "N001" },
132 { "Seagate STT20000A", "ALL" },
131 { NULL , NULL } 133 { NULL , NULL }
132 134
133}; 135};
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index d50bd996ff22..ea94c9aa1220 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -67,6 +67,8 @@ static int proc_ide_read_imodel
67 case ide_4drives: name = "4drives"; break; 67 case ide_4drives: name = "4drives"; break;
68 case ide_pmac: name = "mac-io"; break; 68 case ide_pmac: name = "mac-io"; break;
69 case ide_au1xxx: name = "au1xxx"; break; 69 case ide_au1xxx: name = "au1xxx"; break;
70 case ide_etrax100: name = "etrax100"; break;
71 case ide_acorn: name = "acorn"; break;
70 default: name = "(unknown)"; break; 72 default: name = "(unknown)"; break;
71 } 73 }
72 len = sprintf(page, "%s\n", name); 74 len = sprintf(page, "%s\n", name);
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 0e52ad722a72..8ab33faf6f76 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -317,6 +317,7 @@ static struct pci_device_id atiixp_pci_tbl[] = {
317 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 317 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
318 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 318 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
319 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 319 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
320 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
320 { 0, }, 321 { 0, },
321}; 322};
322MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); 323MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl);
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 6234f806c6b5..47bcd91c9b5f 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -158,6 +158,12 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
158 pci_read_config_word(dev, 0x4A, &csb5_pio); 158 pci_read_config_word(dev, 0x4A, &csb5_pio);
159 pci_read_config_byte(dev, 0x54, &ultra_enable); 159 pci_read_config_byte(dev, 0x54, &ultra_enable);
160 160
161 /* If we are in RAID mode (eg AMI MegaIDE) then we can't it
162 turns out trust the firmware configuration */
163
164 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
165 goto oem_setup_failed;
166
161 /* Per Specified Design by OEM, and ASIC Architect */ 167 /* Per Specified Design by OEM, and ASIC Architect */
162 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) || 168 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
163 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) { 169 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
@@ -173,7 +179,7 @@ dma_pio:
173 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) { 179 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
174 u8 dmaspeed = dma_timing; 180 u8 dmaspeed = dma_timing;
175 181
176 dma_timing &= ~0xFF; 182 dma_timing &= ~0xFFU;
177 if ((dmaspeed & 0x20) == 0x20) 183 if ((dmaspeed & 0x20) == 0x20)
178 dmaspeed = XFER_MW_DMA_2; 184 dmaspeed = XFER_MW_DMA_2;
179 else if ((dmaspeed & 0x21) == 0x21) 185 else if ((dmaspeed & 0x21) == 0x21)
@@ -187,7 +193,7 @@ dma_pio:
187 } else if (pio_timing) { 193 } else if (pio_timing) {
188 u8 piospeed = pio_timing; 194 u8 piospeed = pio_timing;
189 195
190 pio_timing &= ~0xFF; 196 pio_timing &= ~0xFFU;
191 if ((piospeed & 0x20) == 0x20) 197 if ((piospeed & 0x20) == 0x20)
192 piospeed = XFER_PIO_4; 198 piospeed = XFER_PIO_4;
193 else if ((piospeed & 0x22) == 0x22) 199 else if ((piospeed & 0x22) == 0x22)
@@ -208,8 +214,8 @@ dma_pio:
208 214
209oem_setup_failed: 215oem_setup_failed:
210 216
211 pio_timing &= ~0xFF; 217 pio_timing &= ~0xFFU;
212 dma_timing &= ~0xFF; 218 dma_timing &= ~0xFFU;
213 ultra_timing &= ~(0x0F << (4*unit)); 219 ultra_timing &= ~(0x0F << (4*unit));
214 ultra_enable &= ~(0x01 << drive->dn); 220 ultra_enable &= ~(0x01 << drive->dn);
215 csb5_pio &= ~(0x0F << (4*drive->dn)); 221 csb5_pio &= ~(0x0F << (4*drive->dn));
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 2296d43a2414..5f026b5d7857 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -47,6 +47,7 @@
47#include <linux/types.h> 47#include <linux/types.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/workqueue.h>
50 51
51#include <linux/netdevice.h> 52#include <linux/netdevice.h>
52#include <linux/inetdevice.h> 53#include <linux/inetdevice.h>
@@ -235,6 +236,9 @@ static int ether1394_open(struct net_device *dev)
235/* This is called after an "ifdown" */ 236/* This is called after an "ifdown" */
236static int ether1394_stop(struct net_device *dev) 237static int ether1394_stop(struct net_device *dev)
237{ 238{
239 /* flush priv->wake */
240 flush_scheduled_work();
241
238 netif_stop_queue(dev); 242 netif_stop_queue(dev);
239 return 0; 243 return 0;
240} 244}
@@ -531,6 +535,37 @@ static void ether1394_init_dev(struct net_device *dev)
531} 535}
532 536
533/* 537/*
538 * Wake the queue up after commonly encountered transmit failure conditions are
539 * hopefully over. Currently only tlabel exhaustion is accounted for.
540 */
541static void ether1394_wake_queue(struct work_struct *work)
542{
543 struct eth1394_priv *priv;
544 struct hpsb_packet *packet;
545
546 priv = container_of(work, struct eth1394_priv, wake);
547 packet = hpsb_alloc_packet(0);
548
549 /* This is really bad, but unjam the queue anyway. */
550 if (!packet)
551 goto out;
552
553 packet->host = priv->host;
554 packet->node_id = priv->wake_node;
555 /*
556 * A transaction label is all we really want. If we get one, it almost
557 * always means we can get a lot more because the ieee1394 core recycled
558 * a whole batch of tlabels, at last.
559 */
560 if (hpsb_get_tlabel(packet) == 0)
561 hpsb_free_tlabel(packet);
562
563 hpsb_free_packet(packet);
564out:
565 netif_wake_queue(priv->wake_dev);
566}
567
568/*
534 * This function is called every time a card is found. It is generally called 569 * This function is called every time a card is found. It is generally called
535 * when the module is installed. This is where we add all of our ethernet 570 * when the module is installed. This is where we add all of our ethernet
536 * devices. One for each host. 571 * devices. One for each host.
@@ -564,16 +599,17 @@ static void ether1394_add_host(struct hpsb_host *host)
564 } 599 }
565 600
566 SET_MODULE_OWNER(dev); 601 SET_MODULE_OWNER(dev);
567#if 0 602
568 /* FIXME - Is this the correct parent device anyway? */ 603 /* This used to be &host->device in Linux 2.6.20 and before. */
569 SET_NETDEV_DEV(dev, &host->device); 604 SET_NETDEV_DEV(dev, host->device.parent);
570#endif
571 605
572 priv = netdev_priv(dev); 606 priv = netdev_priv(dev);
573 INIT_LIST_HEAD(&priv->ip_node_list); 607 INIT_LIST_HEAD(&priv->ip_node_list);
574 spin_lock_init(&priv->lock); 608 spin_lock_init(&priv->lock);
575 priv->host = host; 609 priv->host = host;
576 priv->local_fifo = fifo_addr; 610 priv->local_fifo = fifo_addr;
611 INIT_WORK(&priv->wake, ether1394_wake_queue);
612 priv->wake_dev = dev;
577 613
578 hi = hpsb_create_hostinfo(&eth1394_highlevel, host, sizeof(*hi)); 614 hi = hpsb_create_hostinfo(&eth1394_highlevel, host, sizeof(*hi));
579 if (hi == NULL) { 615 if (hi == NULL) {
@@ -1390,22 +1426,17 @@ static int ether1394_prep_write_packet(struct hpsb_packet *p,
1390 u64 addr, void *data, int tx_len) 1426 u64 addr, void *data, int tx_len)
1391{ 1427{
1392 p->node_id = node; 1428 p->node_id = node;
1393 p->data = NULL;
1394 1429
1395 p->tcode = TCODE_WRITEB; 1430 if (hpsb_get_tlabel(p))
1396 p->header[1] = host->node_id << 16 | addr >> 32; 1431 return -EAGAIN;
1397 p->header[2] = addr & 0xffffffff;
1398 1432
1433 p->tcode = TCODE_WRITEB;
1399 p->header_size = 16; 1434 p->header_size = 16;
1400 p->expect_response = 1; 1435 p->expect_response = 1;
1401
1402 if (hpsb_get_tlabel(p)) {
1403 ETH1394_PRINT_G(KERN_ERR, "Out of tlabels\n");
1404 return -1;
1405 }
1406 p->header[0] = 1436 p->header[0] =
1407 p->node_id << 16 | p->tlabel << 10 | 1 << 8 | TCODE_WRITEB << 4; 1437 p->node_id << 16 | p->tlabel << 10 | 1 << 8 | TCODE_WRITEB << 4;
1408 1438 p->header[1] = host->node_id << 16 | addr >> 32;
1439 p->header[2] = addr & 0xffffffff;
1409 p->header[3] = tx_len << 16; 1440 p->header[3] = tx_len << 16;
1410 p->data_size = (tx_len + 3) & ~3; 1441 p->data_size = (tx_len + 3) & ~3;
1411 p->data = data; 1442 p->data = data;
@@ -1451,7 +1482,7 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1451 1482
1452 packet = ether1394_alloc_common_packet(priv->host); 1483 packet = ether1394_alloc_common_packet(priv->host);
1453 if (!packet) 1484 if (!packet)
1454 return -1; 1485 return -ENOMEM;
1455 1486
1456 if (ptask->tx_type == ETH1394_GASP) { 1487 if (ptask->tx_type == ETH1394_GASP) {
1457 int length = tx_len + 2 * sizeof(quadlet_t); 1488 int length = tx_len + 2 * sizeof(quadlet_t);
@@ -1462,7 +1493,7 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1462 ptask->addr, ptask->skb->data, 1493 ptask->addr, ptask->skb->data,
1463 tx_len)) { 1494 tx_len)) {
1464 hpsb_free_packet(packet); 1495 hpsb_free_packet(packet);
1465 return -1; 1496 return -EAGAIN;
1466 } 1497 }
1467 1498
1468 ptask->packet = packet; 1499 ptask->packet = packet;
@@ -1471,7 +1502,7 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1471 1502
1472 if (hpsb_send_packet(packet) < 0) { 1503 if (hpsb_send_packet(packet) < 0) {
1473 ether1394_free_packet(packet); 1504 ether1394_free_packet(packet);
1474 return -1; 1505 return -EIO;
1475 } 1506 }
1476 1507
1477 return 0; 1508 return 0;
@@ -1514,13 +1545,18 @@ static void ether1394_complete_cb(void *__ptask)
1514 1545
1515 ptask->outstanding_pkts--; 1546 ptask->outstanding_pkts--;
1516 if (ptask->outstanding_pkts > 0 && !fail) { 1547 if (ptask->outstanding_pkts > 0 && !fail) {
1517 int tx_len; 1548 int tx_len, err;
1518 1549
1519 /* Add the encapsulation header to the fragment */ 1550 /* Add the encapsulation header to the fragment */
1520 tx_len = ether1394_encapsulate(ptask->skb, ptask->max_payload, 1551 tx_len = ether1394_encapsulate(ptask->skb, ptask->max_payload,
1521 &ptask->hdr); 1552 &ptask->hdr);
1522 if (ether1394_send_packet(ptask, tx_len)) 1553 err = ether1394_send_packet(ptask, tx_len);
1554 if (err) {
1555 if (err == -EAGAIN)
1556 ETH1394_PRINT_G(KERN_ERR, "Out of tlabels\n");
1557
1523 ether1394_dg_complete(ptask, 1); 1558 ether1394_dg_complete(ptask, 1);
1559 }
1524 } else { 1560 } else {
1525 ether1394_dg_complete(ptask, fail); 1561 ether1394_dg_complete(ptask, fail);
1526 } 1562 }
@@ -1633,10 +1669,18 @@ static int ether1394_tx(struct sk_buff *skb, struct net_device *dev)
1633 /* Add the encapsulation header to the fragment */ 1669 /* Add the encapsulation header to the fragment */
1634 tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr); 1670 tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr);
1635 dev->trans_start = jiffies; 1671 dev->trans_start = jiffies;
1636 if (ether1394_send_packet(ptask, tx_len)) 1672 if (ether1394_send_packet(ptask, tx_len)) {
1637 goto fail; 1673 if (dest_node == (LOCAL_BUS | ALL_NODES))
1674 goto fail;
1675
1676 /* Most failures of ether1394_send_packet are recoverable. */
1677 netif_stop_queue(dev);
1678 priv->wake_node = dest_node;
1679 schedule_work(&priv->wake);
1680 kmem_cache_free(packet_task_cache, ptask);
1681 return NETDEV_TX_BUSY;
1682 }
1638 1683
1639 netif_wake_queue(dev);
1640 return NETDEV_TX_OK; 1684 return NETDEV_TX_OK;
1641fail: 1685fail:
1642 if (ptask) 1686 if (ptask)
@@ -1650,9 +1694,6 @@ fail:
1650 priv->stats.tx_errors++; 1694 priv->stats.tx_errors++;
1651 spin_unlock_irqrestore(&priv->lock, flags); 1695 spin_unlock_irqrestore(&priv->lock, flags);
1652 1696
1653 if (netif_queue_stopped(dev))
1654 netif_wake_queue(dev);
1655
1656 /* 1697 /*
1657 * FIXME: According to a patch from 2003-02-26, "returning non-zero 1698 * FIXME: According to a patch from 2003-02-26, "returning non-zero
1658 * causes serious problems" here, allegedly. Before that patch, 1699 * causes serious problems" here, allegedly. Before that patch,
diff --git a/drivers/ieee1394/eth1394.h b/drivers/ieee1394/eth1394.h
index a3439ee7cb4e..4f3e2dd46f00 100644
--- a/drivers/ieee1394/eth1394.h
+++ b/drivers/ieee1394/eth1394.h
@@ -66,6 +66,10 @@ struct eth1394_priv {
66 int bc_dgl; /* Outgoing broadcast datagram label */ 66 int bc_dgl; /* Outgoing broadcast datagram label */
67 struct list_head ip_node_list; /* List of IP capable nodes */ 67 struct list_head ip_node_list; /* List of IP capable nodes */
68 struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */ 68 struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
69
70 struct work_struct wake; /* Wake up after xmit failure */
71 struct net_device *wake_dev; /* Stupid backlink for .wake */
72 nodeid_t wake_node; /* Destination of failed xmit */
69}; 73};
70 74
71 75
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index d382500f4210..f1d05eeb9f51 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -936,6 +936,7 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
936 struct hpsb_packet *packet; 936 struct hpsb_packet *packet;
937 int header_length = req->req.misc & 0xffff; 937 int header_length = req->req.misc & 0xffff;
938 int expect_response = req->req.misc >> 16; 938 int expect_response = req->req.misc >> 16;
939 size_t data_size;
939 940
940 if (header_length > req->req.length || header_length < 12 || 941 if (header_length > req->req.length || header_length < 12 ||
941 header_length > FIELD_SIZEOF(struct hpsb_packet, header)) { 942 header_length > FIELD_SIZEOF(struct hpsb_packet, header)) {
@@ -945,7 +946,8 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
945 return sizeof(struct raw1394_request); 946 return sizeof(struct raw1394_request);
946 } 947 }
947 948
948 packet = hpsb_alloc_packet(req->req.length - header_length); 949 data_size = req->req.length - header_length;
950 packet = hpsb_alloc_packet(data_size);
949 req->packet = packet; 951 req->packet = packet;
950 if (!packet) 952 if (!packet)
951 return -ENOMEM; 953 return -ENOMEM;
@@ -960,7 +962,7 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
960 962
961 if (copy_from_user 963 if (copy_from_user
962 (packet->data, int2ptr(req->req.sendb) + header_length, 964 (packet->data, int2ptr(req->req.sendb) + header_length,
963 packet->data_size)) { 965 data_size)) {
964 req->req.error = RAW1394_ERROR_MEMFAULT; 966 req->req.error = RAW1394_ERROR_MEMFAULT;
965 req->req.length = 0; 967 req->req.length = 0;
966 queue_complete_req(req); 968 queue_complete_req(req);
@@ -974,7 +976,7 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
974 packet->host = fi->host; 976 packet->host = fi->host;
975 packet->expect_response = expect_response; 977 packet->expect_response = expect_response;
976 packet->header_size = header_length; 978 packet->header_size = header_length;
977 packet->data_size = req->req.length - header_length; 979 packet->data_size = data_size;
978 980
979 req->req.length = 0; 981 req->req.length = 0;
980 hpsb_set_packet_complete_task(packet, 982 hpsb_set_packet_complete_task(packet,
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index d0db6f8b5206..ce86ff226a28 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -70,6 +70,7 @@
70#include <linux/stringify.h> 70#include <linux/stringify.h>
71#include <linux/types.h> 71#include <linux/types.h>
72#include <linux/wait.h> 72#include <linux/wait.h>
73#include <linux/workqueue.h>
73 74
74#include <asm/byteorder.h> 75#include <asm/byteorder.h>
75#include <asm/errno.h> 76#include <asm/errno.h>
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 558c9a0fc8b9..e85f7013de57 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -38,6 +38,7 @@
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/workqueue.h>
41 42
42#include <rdma/ib_cache.h> 43#include <rdma/ib_cache.h>
43 44
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index eff591deeb46..40c004a2697e 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -306,7 +306,9 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
306 do { 306 do {
307 spin_lock_irqsave(&cm.lock, flags); 307 spin_lock_irqsave(&cm.lock, flags);
308 ret = idr_get_new_above(&cm.local_id_table, cm_id_priv, 308 ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
309 next_id++, &id); 309 next_id, &id);
310 if (!ret)
311 next_id = ((unsigned) id + 1) & MAX_ID_MASK;
310 spin_unlock_irqrestore(&cm.lock, flags); 312 spin_unlock_irqrestore(&cm.lock, flags);
311 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); 313 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
312 314
@@ -1295,26 +1297,29 @@ static struct cm_id_private * cm_match_req(struct cm_work *work,
1295 1297
1296 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1298 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
1297 1299
1298 /* Check for duplicate REQ and stale connections. */ 1300 /* Check for possible duplicate REQ. */
1299 spin_lock_irqsave(&cm.lock, flags); 1301 spin_lock_irqsave(&cm.lock, flags);
1300 timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info); 1302 timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info);
1301 if (!timewait_info)
1302 timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info);
1303
1304 if (timewait_info) { 1303 if (timewait_info) {
1305 cur_cm_id_priv = cm_get_id(timewait_info->work.local_id, 1304 cur_cm_id_priv = cm_get_id(timewait_info->work.local_id,
1306 timewait_info->work.remote_id); 1305 timewait_info->work.remote_id);
1307 cm_cleanup_timewait(cm_id_priv->timewait_info);
1308 spin_unlock_irqrestore(&cm.lock, flags); 1306 spin_unlock_irqrestore(&cm.lock, flags);
1309 if (cur_cm_id_priv) { 1307 if (cur_cm_id_priv) {
1310 cm_dup_req_handler(work, cur_cm_id_priv); 1308 cm_dup_req_handler(work, cur_cm_id_priv);
1311 cm_deref_id(cur_cm_id_priv); 1309 cm_deref_id(cur_cm_id_priv);
1312 } else 1310 }
1313 cm_issue_rej(work->port, work->mad_recv_wc, 1311 return NULL;
1314 IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ, 1312 }
1315 NULL, 0); 1313
1316 listen_cm_id_priv = NULL; 1314 /* Check for stale connections. */
1317 goto out; 1315 timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info);
1316 if (timewait_info) {
1317 cm_cleanup_timewait(cm_id_priv->timewait_info);
1318 spin_unlock_irqrestore(&cm.lock, flags);
1319 cm_issue_rej(work->port, work->mad_recv_wc,
1320 IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ,
1321 NULL, 0);
1322 return NULL;
1318 } 1323 }
1319 1324
1320 /* Find matching listen request. */ 1325 /* Find matching listen request. */
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 592c90aa3183..3ada17c0f239 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -40,6 +40,7 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43#include <linux/workqueue.h>
43 44
44#include "core_priv.h" 45#include "core_priv.h"
45 46
@@ -149,6 +150,18 @@ static int alloc_name(char *name)
149 return 0; 150 return 0;
150} 151}
151 152
153static int start_port(struct ib_device *device)
154{
155 return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
156}
157
158
159static int end_port(struct ib_device *device)
160{
161 return (device->node_type == RDMA_NODE_IB_SWITCH) ?
162 0 : device->phys_port_cnt;
163}
164
152/** 165/**
153 * ib_alloc_device - allocate an IB device struct 166 * ib_alloc_device - allocate an IB device struct
154 * @size:size of structure to allocate 167 * @size:size of structure to allocate
@@ -208,6 +221,45 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
208 return 0; 221 return 0;
209} 222}
210 223
224static int read_port_table_lengths(struct ib_device *device)
225{
226 struct ib_port_attr *tprops = NULL;
227 int num_ports, ret = -ENOMEM;
228 u8 port_index;
229
230 tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
231 if (!tprops)
232 goto out;
233
234 num_ports = end_port(device) - start_port(device) + 1;
235
236 device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports,
237 GFP_KERNEL);
238 device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports,
239 GFP_KERNEL);
240 if (!device->pkey_tbl_len || !device->gid_tbl_len)
241 goto err;
242
243 for (port_index = 0; port_index < num_ports; ++port_index) {
244 ret = ib_query_port(device, port_index + start_port(device),
245 tprops);
246 if (ret)
247 goto err;
248 device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len;
249 device->gid_tbl_len[port_index] = tprops->gid_tbl_len;
250 }
251
252 ret = 0;
253 goto out;
254
255err:
256 kfree(device->gid_tbl_len);
257 kfree(device->pkey_tbl_len);
258out:
259 kfree(tprops);
260 return ret;
261}
262
211/** 263/**
212 * ib_register_device - Register an IB device with IB core 264 * ib_register_device - Register an IB device with IB core
213 * @device:Device to register 265 * @device:Device to register
@@ -239,10 +291,19 @@ int ib_register_device(struct ib_device *device)
239 spin_lock_init(&device->event_handler_lock); 291 spin_lock_init(&device->event_handler_lock);
240 spin_lock_init(&device->client_data_lock); 292 spin_lock_init(&device->client_data_lock);
241 293
294 ret = read_port_table_lengths(device);
295 if (ret) {
296 printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
297 device->name);
298 goto out;
299 }
300
242 ret = ib_device_register_sysfs(device); 301 ret = ib_device_register_sysfs(device);
243 if (ret) { 302 if (ret) {
244 printk(KERN_WARNING "Couldn't register device %s with driver model\n", 303 printk(KERN_WARNING "Couldn't register device %s with driver model\n",
245 device->name); 304 device->name);
305 kfree(device->gid_tbl_len);
306 kfree(device->pkey_tbl_len);
246 goto out; 307 goto out;
247 } 308 }
248 309
@@ -284,6 +345,9 @@ void ib_unregister_device(struct ib_device *device)
284 345
285 list_del(&device->core_list); 346 list_del(&device->core_list);
286 347
348 kfree(device->gid_tbl_len);
349 kfree(device->pkey_tbl_len);
350
287 mutex_unlock(&device_mutex); 351 mutex_unlock(&device_mutex);
288 352
289 spin_lock_irqsave(&device->client_data_lock, flags); 353 spin_lock_irqsave(&device->client_data_lock, flags);
@@ -506,10 +570,7 @@ int ib_query_port(struct ib_device *device,
506 u8 port_num, 570 u8 port_num,
507 struct ib_port_attr *port_attr) 571 struct ib_port_attr *port_attr)
508{ 572{
509 if (device->node_type == RDMA_NODE_IB_SWITCH) { 573 if (port_num < start_port(device) || port_num > end_port(device))
510 if (port_num)
511 return -EINVAL;
512 } else if (port_num < 1 || port_num > device->phys_port_cnt)
513 return -EINVAL; 574 return -EINVAL;
514 575
515 return device->query_port(device, port_num, port_attr); 576 return device->query_port(device, port_num, port_attr);
@@ -581,10 +642,7 @@ int ib_modify_port(struct ib_device *device,
581 u8 port_num, int port_modify_mask, 642 u8 port_num, int port_modify_mask,
582 struct ib_port_modify *port_modify) 643 struct ib_port_modify *port_modify)
583{ 644{
584 if (device->node_type == RDMA_NODE_IB_SWITCH) { 645 if (port_num < start_port(device) || port_num > end_port(device))
585 if (port_num)
586 return -EINVAL;
587 } else if (port_num < 1 || port_num > device->phys_port_cnt)
588 return -EINVAL; 646 return -EINVAL;
589 647
590 return device->modify_port(device, port_num, port_modify_mask, 648 return device->modify_port(device, port_num, port_modify_mask,
@@ -592,6 +650,68 @@ int ib_modify_port(struct ib_device *device,
592} 650}
593EXPORT_SYMBOL(ib_modify_port); 651EXPORT_SYMBOL(ib_modify_port);
594 652
653/**
654 * ib_find_gid - Returns the port number and GID table index where
655 * a specified GID value occurs.
656 * @device: The device to query.
657 * @gid: The GID value to search for.
658 * @port_num: The port number of the device where the GID value was found.
659 * @index: The index into the GID table where the GID was found. This
660 * parameter may be NULL.
661 */
662int ib_find_gid(struct ib_device *device, union ib_gid *gid,
663 u8 *port_num, u16 *index)
664{
665 union ib_gid tmp_gid;
666 int ret, port, i;
667
668 for (port = start_port(device); port <= end_port(device); ++port) {
669 for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
670 ret = ib_query_gid(device, port, i, &tmp_gid);
671 if (ret)
672 return ret;
673 if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
674 *port_num = port;
675 if (index)
676 *index = i;
677 return 0;
678 }
679 }
680 }
681
682 return -ENOENT;
683}
684EXPORT_SYMBOL(ib_find_gid);
685
686/**
687 * ib_find_pkey - Returns the PKey table index where a specified
688 * PKey value occurs.
689 * @device: The device to query.
690 * @port_num: The port number of the device to search for the PKey.
691 * @pkey: The PKey value to search for.
692 * @index: The index into the PKey table where the PKey was found.
693 */
694int ib_find_pkey(struct ib_device *device,
695 u8 port_num, u16 pkey, u16 *index)
696{
697 int ret, i;
698 u16 tmp_pkey;
699
700 for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
701 ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
702 if (ret)
703 return ret;
704
705 if (pkey == tmp_pkey) {
706 *index = i;
707 return 0;
708 }
709 }
710
711 return -ENOENT;
712}
713EXPORT_SYMBOL(ib_find_pkey);
714
595static int __init ib_core_init(void) 715static int __init ib_core_init(void)
596{ 716{
597 int ret; 717 int ret;
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index f32ca5fbb26b..b4aec5103c99 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -36,6 +36,7 @@
36 36
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/sched.h>
39 40
40#include "uverbs.h" 41#include "uverbs.h"
41 42
@@ -209,8 +210,10 @@ void ib_umem_release(struct ib_umem *umem)
209 __ib_umem_release(umem->context->device, umem, 1); 210 __ib_umem_release(umem->context->device, umem, 1);
210 211
211 mm = get_task_mm(current); 212 mm = get_task_mm(current);
212 if (!mm) 213 if (!mm) {
214 kfree(umem);
213 return; 215 return;
216 }
214 217
215 diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT; 218 diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
216 219
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 84c5bb498563..add79bd44e39 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -2050,13 +2050,10 @@ int ehca_mrmw_map_hrc_alloc(const u64 hipz_rc)
2050 switch (hipz_rc) { 2050 switch (hipz_rc) {
2051 case H_SUCCESS: /* successful completion */ 2051 case H_SUCCESS: /* successful completion */
2052 return 0; 2052 return 0;
2053 case H_ADAPTER_PARM: /* invalid adapter handle */
2054 case H_RT_PARM: /* invalid resource type */
2055 case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */ 2053 case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
2056 case H_MLENGTH_PARM: /* invalid memory length */
2057 case H_MEM_ACCESS_PARM: /* invalid access controls */
2058 case H_CONSTRAINED: /* resource constraint */ 2054 case H_CONSTRAINED: /* resource constraint */
2059 return -EINVAL; 2055 case H_NO_MEM:
2056 return -ENOMEM;
2060 case H_BUSY: /* long busy */ 2057 case H_BUSY: /* long busy */
2061 return -EBUSY; 2058 return -EBUSY;
2062 default: 2059 default:
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index 7f0beec74f70..5766ae3a2029 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -331,7 +331,7 @@ u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
331 0); 331 0);
332 qp->ipz_qp_handle.handle = outs[0]; 332 qp->ipz_qp_handle.handle = outs[0];
333 qp->real_qp_num = (u32)outs[1]; 333 qp->real_qp_num = (u32)outs[1];
334 parms->act_nr_send_sges = 334 parms->act_nr_send_wqes =
335 (u16)EHCA_BMASK_GET(H_ALL_RES_QP_ACT_OUTST_SEND_WR, outs[2]); 335 (u16)EHCA_BMASK_GET(H_ALL_RES_QP_ACT_OUTST_SEND_WR, outs[2]);
336 parms->act_nr_recv_wqes = 336 parms->act_nr_recv_wqes =
337 (u16)EHCA_BMASK_GET(H_ALL_RES_QP_ACT_OUTST_RECV_WR, outs[2]); 337 (u16)EHCA_BMASK_GET(H_ALL_RES_QP_ACT_OUTST_RECV_WR, outs[2]);
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
index 085e28b939ec..dd691cfa5079 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
@@ -165,10 +165,9 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
165{ 165{
166 struct rb_node **n = &mcast_tree.rb_node; 166 struct rb_node **n = &mcast_tree.rb_node;
167 struct rb_node *pn = NULL; 167 struct rb_node *pn = NULL;
168 unsigned long flags;
169 int ret; 168 int ret;
170 169
171 spin_lock_irqsave(&mcast_lock, flags); 170 spin_lock_irq(&mcast_lock);
172 171
173 while (*n) { 172 while (*n) {
174 struct ipath_mcast *tmcast; 173 struct ipath_mcast *tmcast;
@@ -228,7 +227,7 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
228 ret = 0; 227 ret = 0;
229 228
230bail: 229bail:
231 spin_unlock_irqrestore(&mcast_lock, flags); 230 spin_unlock_irq(&mcast_lock);
232 231
233 return ret; 232 return ret;
234} 233}
@@ -289,17 +288,16 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
289 struct ipath_mcast *mcast = NULL; 288 struct ipath_mcast *mcast = NULL;
290 struct ipath_mcast_qp *p, *tmp; 289 struct ipath_mcast_qp *p, *tmp;
291 struct rb_node *n; 290 struct rb_node *n;
292 unsigned long flags;
293 int last = 0; 291 int last = 0;
294 int ret; 292 int ret;
295 293
296 spin_lock_irqsave(&mcast_lock, flags); 294 spin_lock_irq(&mcast_lock);
297 295
298 /* Find the GID in the mcast table. */ 296 /* Find the GID in the mcast table. */
299 n = mcast_tree.rb_node; 297 n = mcast_tree.rb_node;
300 while (1) { 298 while (1) {
301 if (n == NULL) { 299 if (n == NULL) {
302 spin_unlock_irqrestore(&mcast_lock, flags); 300 spin_unlock_irq(&mcast_lock);
303 ret = -EINVAL; 301 ret = -EINVAL;
304 goto bail; 302 goto bail;
305 } 303 }
@@ -334,7 +332,7 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
334 break; 332 break;
335 } 333 }
336 334
337 spin_unlock_irqrestore(&mcast_lock, flags); 335 spin_unlock_irq(&mcast_lock);
338 336
339 if (p) { 337 if (p) {
340 /* 338 /*
@@ -348,9 +346,9 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
348 atomic_dec(&mcast->refcount); 346 atomic_dec(&mcast->refcount);
349 wait_event(mcast->wait, !atomic_read(&mcast->refcount)); 347 wait_event(mcast->wait, !atomic_read(&mcast->refcount));
350 ipath_mcast_free(mcast); 348 ipath_mcast_free(mcast);
351 spin_lock(&dev->n_mcast_grps_lock); 349 spin_lock_irq(&dev->n_mcast_grps_lock);
352 dev->n_mcast_grps_allocated--; 350 dev->n_mcast_grps_allocated--;
353 spin_unlock(&dev->n_mcast_grps_lock); 351 spin_unlock_irq(&dev->n_mcast_grps_lock);
354 } 352 }
355 353
356 ret = 0; 354 ret = 0;
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 5cd706908450..dc137dec2308 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -188,14 +188,32 @@ static int send_wqe_overhead(enum ib_qp_type type)
188 } 188 }
189} 189}
190 190
191static int set_qp_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap, 191static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
192 enum ib_qp_type type, struct mlx4_ib_qp *qp) 192 struct mlx4_ib_qp *qp)
193{ 193{
194 /* Sanity check QP size before proceeding */ 194 /* Sanity check RQ size before proceeding */
195 if (cap->max_recv_wr > dev->dev->caps.max_wqes ||
196 cap->max_recv_sge > dev->dev->caps.max_rq_sg)
197 return -EINVAL;
198
199 qp->rq.max = cap->max_recv_wr ? roundup_pow_of_two(cap->max_recv_wr) : 0;
200
201 qp->rq.wqe_shift = ilog2(roundup_pow_of_two(cap->max_recv_sge *
202 sizeof (struct mlx4_wqe_data_seg)));
203 qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof (struct mlx4_wqe_data_seg);
204
205 cap->max_recv_wr = qp->rq.max;
206 cap->max_recv_sge = qp->rq.max_gs;
207
208 return 0;
209}
210
211static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
212 enum ib_qp_type type, struct mlx4_ib_qp *qp)
213{
214 /* Sanity check SQ size before proceeding */
195 if (cap->max_send_wr > dev->dev->caps.max_wqes || 215 if (cap->max_send_wr > dev->dev->caps.max_wqes ||
196 cap->max_recv_wr > dev->dev->caps.max_wqes ||
197 cap->max_send_sge > dev->dev->caps.max_sq_sg || 216 cap->max_send_sge > dev->dev->caps.max_sq_sg ||
198 cap->max_recv_sge > dev->dev->caps.max_rq_sg ||
199 cap->max_inline_data + send_wqe_overhead(type) + 217 cap->max_inline_data + send_wqe_overhead(type) +
200 sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz) 218 sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
201 return -EINVAL; 219 return -EINVAL;
@@ -208,12 +226,7 @@ static int set_qp_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
208 cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg) 226 cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
209 return -EINVAL; 227 return -EINVAL;
210 228
211 qp->rq.max = cap->max_recv_wr ? roundup_pow_of_two(cap->max_recv_wr) : 0; 229 qp->sq.max = cap->max_send_wr ? roundup_pow_of_two(cap->max_send_wr) : 1;
212 qp->sq.max = cap->max_send_wr ? roundup_pow_of_two(cap->max_send_wr) : 0;
213
214 qp->rq.wqe_shift = ilog2(roundup_pow_of_two(cap->max_recv_sge *
215 sizeof (struct mlx4_wqe_data_seg)));
216 qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof (struct mlx4_wqe_data_seg);
217 230
218 qp->sq.wqe_shift = ilog2(roundup_pow_of_two(max(cap->max_send_sge * 231 qp->sq.wqe_shift = ilog2(roundup_pow_of_two(max(cap->max_send_sge *
219 sizeof (struct mlx4_wqe_data_seg), 232 sizeof (struct mlx4_wqe_data_seg),
@@ -233,23 +246,31 @@ static int set_qp_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
233 qp->sq.offset = 0; 246 qp->sq.offset = 0;
234 } 247 }
235 248
236 cap->max_send_wr = qp->sq.max; 249 cap->max_send_wr = qp->sq.max;
237 cap->max_recv_wr = qp->rq.max; 250 cap->max_send_sge = qp->sq.max_gs;
238 cap->max_send_sge = qp->sq.max_gs;
239 cap->max_recv_sge = qp->rq.max_gs;
240 cap->max_inline_data = (1 << qp->sq.wqe_shift) - send_wqe_overhead(type) - 251 cap->max_inline_data = (1 << qp->sq.wqe_shift) - send_wqe_overhead(type) -
241 sizeof (struct mlx4_wqe_inline_seg); 252 sizeof (struct mlx4_wqe_inline_seg);
242 253
243 return 0; 254 return 0;
244} 255}
245 256
257static int set_user_sq_size(struct mlx4_ib_qp *qp,
258 struct mlx4_ib_create_qp *ucmd)
259{
260 qp->sq.max = 1 << ucmd->log_sq_bb_count;
261 qp->sq.wqe_shift = ucmd->log_sq_stride;
262
263 qp->buf_size = (qp->rq.max << qp->rq.wqe_shift) +
264 (qp->sq.max << qp->sq.wqe_shift);
265
266 return 0;
267}
268
246static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, 269static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
247 struct ib_qp_init_attr *init_attr, 270 struct ib_qp_init_attr *init_attr,
248 struct ib_udata *udata, int sqpn, struct mlx4_ib_qp *qp) 271 struct ib_udata *udata, int sqpn, struct mlx4_ib_qp *qp)
249{ 272{
250 struct mlx4_wqe_ctrl_seg *ctrl;
251 int err; 273 int err;
252 int i;
253 274
254 mutex_init(&qp->mutex); 275 mutex_init(&qp->mutex);
255 spin_lock_init(&qp->sq.lock); 276 spin_lock_init(&qp->sq.lock);
@@ -264,7 +285,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
264 qp->sq.head = 0; 285 qp->sq.head = 0;
265 qp->sq.tail = 0; 286 qp->sq.tail = 0;
266 287
267 err = set_qp_size(dev, &init_attr->cap, init_attr->qp_type, qp); 288 err = set_rq_size(dev, &init_attr->cap, qp);
268 if (err) 289 if (err)
269 goto err; 290 goto err;
270 291
@@ -276,6 +297,10 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
276 goto err; 297 goto err;
277 } 298 }
278 299
300 err = set_user_sq_size(qp, &ucmd);
301 if (err)
302 goto err;
303
279 qp->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, 304 qp->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr,
280 qp->buf_size, 0); 305 qp->buf_size, 0);
281 if (IS_ERR(qp->umem)) { 306 if (IS_ERR(qp->umem)) {
@@ -292,16 +317,24 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
292 if (err) 317 if (err)
293 goto err_mtt; 318 goto err_mtt;
294 319
295 err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context), 320 if (!init_attr->srq) {
296 ucmd.db_addr, &qp->db); 321 err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context),
297 if (err) 322 ucmd.db_addr, &qp->db);
298 goto err_mtt; 323 if (err)
324 goto err_mtt;
325 }
299 } else { 326 } else {
300 err = mlx4_ib_db_alloc(dev, &qp->db, 0); 327 err = set_kernel_sq_size(dev, &init_attr->cap, init_attr->qp_type, qp);
301 if (err) 328 if (err)
302 goto err; 329 goto err;
303 330
304 *qp->db.db = 0; 331 if (!init_attr->srq) {
332 err = mlx4_ib_db_alloc(dev, &qp->db, 0);
333 if (err)
334 goto err;
335
336 *qp->db.db = 0;
337 }
305 338
306 if (mlx4_buf_alloc(dev->dev, qp->buf_size, PAGE_SIZE * 2, &qp->buf)) { 339 if (mlx4_buf_alloc(dev->dev, qp->buf_size, PAGE_SIZE * 2, &qp->buf)) {
307 err = -ENOMEM; 340 err = -ENOMEM;
@@ -317,11 +350,6 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
317 if (err) 350 if (err)
318 goto err_mtt; 351 goto err_mtt;
319 352
320 for (i = 0; i < qp->sq.max; ++i) {
321 ctrl = get_send_wqe(qp, i);
322 ctrl->owner_opcode = cpu_to_be32(1 << 31);
323 }
324
325 qp->sq.wrid = kmalloc(qp->sq.max * sizeof (u64), GFP_KERNEL); 353 qp->sq.wrid = kmalloc(qp->sq.max * sizeof (u64), GFP_KERNEL);
326 qp->rq.wrid = kmalloc(qp->rq.max * sizeof (u64), GFP_KERNEL); 354 qp->rq.wrid = kmalloc(qp->rq.max * sizeof (u64), GFP_KERNEL);
327 355
@@ -355,7 +383,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
355 return 0; 383 return 0;
356 384
357err_wrid: 385err_wrid:
358 if (pd->uobject) 386 if (pd->uobject && !init_attr->srq)
359 mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db); 387 mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db);
360 else { 388 else {
361 kfree(qp->sq.wrid); 389 kfree(qp->sq.wrid);
@@ -372,7 +400,7 @@ err_buf:
372 mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); 400 mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
373 401
374err_db: 402err_db:
375 if (!pd->uobject) 403 if (!pd->uobject && !init_attr->srq)
376 mlx4_ib_db_free(dev, &qp->db); 404 mlx4_ib_db_free(dev, &qp->db);
377 405
378err: 406err:
@@ -450,14 +478,16 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
450 mlx4_mtt_cleanup(dev->dev, &qp->mtt); 478 mlx4_mtt_cleanup(dev->dev, &qp->mtt);
451 479
452 if (is_user) { 480 if (is_user) {
453 mlx4_ib_db_unmap_user(to_mucontext(qp->ibqp.uobject->context), 481 if (!qp->ibqp.srq)
454 &qp->db); 482 mlx4_ib_db_unmap_user(to_mucontext(qp->ibqp.uobject->context),
483 &qp->db);
455 ib_umem_release(qp->umem); 484 ib_umem_release(qp->umem);
456 } else { 485 } else {
457 kfree(qp->sq.wrid); 486 kfree(qp->sq.wrid);
458 kfree(qp->rq.wrid); 487 kfree(qp->rq.wrid);
459 mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); 488 mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
460 mlx4_ib_db_free(dev, &qp->db); 489 if (!qp->ibqp.srq)
490 mlx4_ib_db_free(dev, &qp->db);
461 } 491 }
462} 492}
463 493
@@ -573,7 +603,7 @@ static int to_mlx4_st(enum ib_qp_type type)
573 } 603 }
574} 604}
575 605
576static __be32 to_mlx4_access_flags(struct mlx4_ib_qp *qp, struct ib_qp_attr *attr, 606static __be32 to_mlx4_access_flags(struct mlx4_ib_qp *qp, const struct ib_qp_attr *attr,
577 int attr_mask) 607 int attr_mask)
578{ 608{
579 u8 dest_rd_atomic; 609 u8 dest_rd_atomic;
@@ -603,7 +633,7 @@ static __be32 to_mlx4_access_flags(struct mlx4_ib_qp *qp, struct ib_qp_attr *att
603 return cpu_to_be32(hw_access_flags); 633 return cpu_to_be32(hw_access_flags);
604} 634}
605 635
606static void store_sqp_attrs(struct mlx4_ib_sqp *sqp, struct ib_qp_attr *attr, 636static void store_sqp_attrs(struct mlx4_ib_sqp *sqp, const struct ib_qp_attr *attr,
607 int attr_mask) 637 int attr_mask)
608{ 638{
609 if (attr_mask & IB_QP_PKEY_INDEX) 639 if (attr_mask & IB_QP_PKEY_INDEX)
@@ -619,7 +649,7 @@ static void mlx4_set_sched(struct mlx4_qp_path *path, u8 port)
619 path->sched_queue = (path->sched_queue & 0xbf) | ((port - 1) << 6); 649 path->sched_queue = (path->sched_queue & 0xbf) | ((port - 1) << 6);
620} 650}
621 651
622static int mlx4_set_path(struct mlx4_ib_dev *dev, struct ib_ah_attr *ah, 652static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
623 struct mlx4_qp_path *path, u8 port) 653 struct mlx4_qp_path *path, u8 port)
624{ 654{
625 path->grh_mylmc = ah->src_path_bits & 0x7f; 655 path->grh_mylmc = ah->src_path_bits & 0x7f;
@@ -655,14 +685,14 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, struct ib_ah_attr *ah,
655 return 0; 685 return 0;
656} 686}
657 687
658int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 688static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
659 int attr_mask, struct ib_udata *udata) 689 const struct ib_qp_attr *attr, int attr_mask,
690 enum ib_qp_state cur_state, enum ib_qp_state new_state)
660{ 691{
661 struct mlx4_ib_dev *dev = to_mdev(ibqp->device); 692 struct mlx4_ib_dev *dev = to_mdev(ibqp->device);
662 struct mlx4_ib_qp *qp = to_mqp(ibqp); 693 struct mlx4_ib_qp *qp = to_mqp(ibqp);
663 struct mlx4_qp_context *context; 694 struct mlx4_qp_context *context;
664 enum mlx4_qp_optpar optpar = 0; 695 enum mlx4_qp_optpar optpar = 0;
665 enum ib_qp_state cur_state, new_state;
666 int sqd_event; 696 int sqd_event;
667 int err = -EINVAL; 697 int err = -EINVAL;
668 698
@@ -670,34 +700,6 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
670 if (!context) 700 if (!context)
671 return -ENOMEM; 701 return -ENOMEM;
672 702
673 mutex_lock(&qp->mutex);
674
675 cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
676 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
677
678 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask))
679 goto out;
680
681 if ((attr_mask & IB_QP_PKEY_INDEX) &&
682 attr->pkey_index >= dev->dev->caps.pkey_table_len) {
683 goto out;
684 }
685
686 if ((attr_mask & IB_QP_PORT) &&
687 (attr->port_num == 0 || attr->port_num > dev->dev->caps.num_ports)) {
688 goto out;
689 }
690
691 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
692 attr->max_rd_atomic > dev->dev->caps.max_qp_init_rdma) {
693 goto out;
694 }
695
696 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
697 attr->max_dest_rd_atomic > 1 << dev->dev->caps.max_qp_dest_rdma) {
698 goto out;
699 }
700
701 context->flags = cpu_to_be32((to_mlx4_state(new_state) << 28) | 703 context->flags = cpu_to_be32((to_mlx4_state(new_state) << 28) |
702 (to_mlx4_st(ibqp->qp_type) << 16)); 704 (to_mlx4_st(ibqp->qp_type) << 16));
703 context->flags |= cpu_to_be32(1 << 8); /* DE? */ 705 context->flags |= cpu_to_be32(1 << 8); /* DE? */
@@ -849,7 +851,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
849 if (ibqp->srq) 851 if (ibqp->srq)
850 context->srqn = cpu_to_be32(1 << 24 | to_msrq(ibqp->srq)->msrq.srqn); 852 context->srqn = cpu_to_be32(1 << 24 | to_msrq(ibqp->srq)->msrq.srqn);
851 853
852 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) 854 if (!ibqp->srq && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)
853 context->db_rec_addr = cpu_to_be64(qp->db.dma); 855 context->db_rec_addr = cpu_to_be64(qp->db.dma);
854 856
855 if (cur_state == IB_QPS_INIT && 857 if (cur_state == IB_QPS_INIT &&
@@ -869,6 +871,21 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
869 else 871 else
870 sqd_event = 0; 872 sqd_event = 0;
871 873
874 /*
875 * Before passing a kernel QP to the HW, make sure that the
876 * ownership bits of the send queue are set so that the
877 * hardware doesn't start processing stale work requests.
878 */
879 if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) {
880 struct mlx4_wqe_ctrl_seg *ctrl;
881 int i;
882
883 for (i = 0; i < qp->sq.max; ++i) {
884 ctrl = get_send_wqe(qp, i);
885 ctrl->owner_opcode = cpu_to_be32(1 << 31);
886 }
887 }
888
872 err = mlx4_qp_modify(dev->dev, &qp->mtt, to_mlx4_state(cur_state), 889 err = mlx4_qp_modify(dev->dev, &qp->mtt, to_mlx4_state(cur_state),
873 to_mlx4_state(new_state), context, optpar, 890 to_mlx4_state(new_state), context, optpar,
874 sqd_event, &qp->mqp); 891 sqd_event, &qp->mqp);
@@ -916,15 +933,89 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
916 qp->rq.tail = 0; 933 qp->rq.tail = 0;
917 qp->sq.head = 0; 934 qp->sq.head = 0;
918 qp->sq.tail = 0; 935 qp->sq.tail = 0;
919 *qp->db.db = 0; 936 if (!ibqp->srq)
937 *qp->db.db = 0;
920 } 938 }
921 939
922out: 940out:
923 mutex_unlock(&qp->mutex);
924 kfree(context); 941 kfree(context);
925 return err; 942 return err;
926} 943}
927 944
945static const struct ib_qp_attr mlx4_ib_qp_attr = { .port_num = 1 };
946static const int mlx4_ib_qp_attr_mask_table[IB_QPT_UD + 1] = {
947 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
948 IB_QP_PORT |
949 IB_QP_QKEY),
950 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
951 IB_QP_PORT |
952 IB_QP_ACCESS_FLAGS),
953 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
954 IB_QP_PORT |
955 IB_QP_ACCESS_FLAGS),
956 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
957 IB_QP_QKEY),
958 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
959 IB_QP_QKEY),
960};
961
962int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
963 int attr_mask, struct ib_udata *udata)
964{
965 struct mlx4_ib_dev *dev = to_mdev(ibqp->device);
966 struct mlx4_ib_qp *qp = to_mqp(ibqp);
967 enum ib_qp_state cur_state, new_state;
968 int err = -EINVAL;
969
970 mutex_lock(&qp->mutex);
971
972 cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
973 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
974
975 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask))
976 goto out;
977
978 if ((attr_mask & IB_QP_PKEY_INDEX) &&
979 attr->pkey_index >= dev->dev->caps.pkey_table_len) {
980 goto out;
981 }
982
983 if ((attr_mask & IB_QP_PORT) &&
984 (attr->port_num == 0 || attr->port_num > dev->dev->caps.num_ports)) {
985 goto out;
986 }
987
988 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
989 attr->max_rd_atomic > dev->dev->caps.max_qp_init_rdma) {
990 goto out;
991 }
992
993 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
994 attr->max_dest_rd_atomic > dev->dev->caps.max_qp_dest_rdma) {
995 goto out;
996 }
997
998 if (cur_state == new_state && cur_state == IB_QPS_RESET) {
999 err = 0;
1000 goto out;
1001 }
1002
1003 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
1004 err = __mlx4_ib_modify_qp(ibqp, &mlx4_ib_qp_attr,
1005 mlx4_ib_qp_attr_mask_table[ibqp->qp_type],
1006 IB_QPS_RESET, IB_QPS_INIT);
1007 if (err)
1008 goto out;
1009 cur_state = IB_QPS_INIT;
1010 }
1011
1012 err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
1013
1014out:
1015 mutex_unlock(&qp->mutex);
1016 return err;
1017}
1018
928static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr, 1019static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
929 void *wqe) 1020 void *wqe)
930{ 1021{
@@ -952,6 +1043,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
952 (be32_to_cpu(ah->av.sl_tclass_flowlabel) >> 20) & 0xff; 1043 (be32_to_cpu(ah->av.sl_tclass_flowlabel) >> 20) & 0xff;
953 sqp->ud_header.grh.flow_label = 1044 sqp->ud_header.grh.flow_label =
954 ah->av.sl_tclass_flowlabel & cpu_to_be32(0xfffff); 1045 ah->av.sl_tclass_flowlabel & cpu_to_be32(0xfffff);
1046 sqp->ud_header.grh.hop_limit = ah->av.hop_limit;
955 ib_get_cached_gid(ib_dev, be32_to_cpu(ah->av.port_pd) >> 24, 1047 ib_get_cached_gid(ib_dev, be32_to_cpu(ah->av.port_pd) >> 24,
956 ah->av.gid_index, &sqp->ud_header.grh.source_gid); 1048 ah->av.gid_index, &sqp->ud_header.grh.source_gid);
957 memcpy(sqp->ud_header.grh.destination_gid.raw, 1049 memcpy(sqp->ud_header.grh.destination_gid.raw,
@@ -1192,7 +1284,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1192 */ 1284 */
1193 wmb(); 1285 wmb();
1194 1286
1195 if (wr->opcode < 0 || wr->opcode > ARRAY_SIZE(mlx4_ib_opcode)) { 1287 if (wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mlx4_ib_opcode)) {
1196 err = -EINVAL; 1288 err = -EINVAL;
1197 goto out; 1289 goto out;
1198 } 1290 }
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
index 42ab4a801d6a..12fac1c8989d 100644
--- a/drivers/infiniband/hw/mlx4/srq.c
+++ b/drivers/infiniband/hw/mlx4/srq.c
@@ -297,6 +297,12 @@ int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
297 break; 297 break;
298 } 298 }
299 299
300 if (unlikely(srq->head == srq->tail)) {
301 err = -ENOMEM;
302 *bad_wr = wr;
303 break;
304 }
305
300 srq->wrid[srq->head] = wr->wr_id; 306 srq->wrid[srq->head] = wr->wr_id;
301 307
302 next = get_wqe(srq, srq->head); 308 next = get_wqe(srq, srq->head);
diff --git a/drivers/infiniband/hw/mlx4/user.h b/drivers/infiniband/hw/mlx4/user.h
index 5b8eddc9fa83..88c72d56368b 100644
--- a/drivers/infiniband/hw/mlx4/user.h
+++ b/drivers/infiniband/hw/mlx4/user.h
@@ -39,7 +39,7 @@
39 * Increment this value if any changes that break userspace ABI 39 * Increment this value if any changes that break userspace ABI
40 * compatibility are made. 40 * compatibility are made.
41 */ 41 */
42#define MLX4_IB_UVERBS_ABI_VERSION 1 42#define MLX4_IB_UVERBS_ABI_VERSION 2
43 43
44/* 44/*
45 * Make sure that all structs defined in this file remain laid out so 45 * Make sure that all structs defined in this file remain laid out so
@@ -87,6 +87,9 @@ struct mlx4_ib_create_srq_resp {
87struct mlx4_ib_create_qp { 87struct mlx4_ib_create_qp {
88 __u64 buf_addr; 88 __u64 buf_addr;
89 __u64 db_addr; 89 __u64 db_addr;
90 __u8 log_sq_bb_count;
91 __u8 log_sq_stride;
92 __u8 reserved[6];
90}; 93};
91 94
92#endif /* MLX4_IB_USER_H */ 95#endif /* MLX4_IB_USER_H */
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 27caf3b0648a..4b111a852ff6 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -279,6 +279,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
279 (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; 279 (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff;
280 header->grh.flow_label = 280 header->grh.flow_label =
281 ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff); 281 ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
282 header->grh.hop_limit = ah->av->hop_limit;
282 ib_get_cached_gid(&dev->ib_dev, 283 ib_get_cached_gid(&dev->ib_dev,
283 be32_to_cpu(ah->av->port_pd) >> 24, 284 be32_to_cpu(ah->av->port_pd) >> 24,
284 ah->av->gid_index % dev->limits.gid_table_len, 285 ah->av->gid_index % dev->limits.gid_table_len,
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 71314460b11e..38102520ffb3 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -37,6 +37,7 @@
37#include <linux/completion.h> 37#include <linux/completion.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/sched.h>
40#include <asm/io.h> 41#include <asm/io.h>
41#include <rdma/ib_mad.h> 42#include <rdma/ib_mad.h>
42 43
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index ca224d018af2..be6e1e03bdab 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -37,6 +37,7 @@
37 */ 37 */
38 38
39#include <linux/hardirq.h> 39#include <linux/hardirq.h>
40#include <linux/sched.h>
40 41
41#include <asm/io.h> 42#include <asm/io.h>
42 43
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 773145e29947..aa563e61de65 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -1250,12 +1250,14 @@ static void __mthca_remove_one(struct pci_dev *pdev)
1250int __mthca_restart_one(struct pci_dev *pdev) 1250int __mthca_restart_one(struct pci_dev *pdev)
1251{ 1251{
1252 struct mthca_dev *mdev; 1252 struct mthca_dev *mdev;
1253 int hca_type;
1253 1254
1254 mdev = pci_get_drvdata(pdev); 1255 mdev = pci_get_drvdata(pdev);
1255 if (!mdev) 1256 if (!mdev)
1256 return -ENODEV; 1257 return -ENODEV;
1258 hca_type = mdev->hca_type;
1257 __mthca_remove_one(pdev); 1259 __mthca_remove_one(pdev);
1258 return __mthca_init_one(pdev, mdev->hca_type); 1260 return __mthca_init_one(pdev, hca_type);
1259} 1261}
1260 1262
1261static int __devinit mthca_init_one(struct pci_dev *pdev, 1263static int __devinit mthca_init_one(struct pci_dev *pdev,
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 48f7c65e9aed..e61f3e626980 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -36,6 +36,7 @@
36 36
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/scatterlist.h> 38#include <linux/scatterlist.h>
39#include <linux/sched.h>
39 40
40#include <asm/page.h> 41#include <asm/page.h>
41 42
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 72fabb822f1c..eef415b12b2e 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -37,6 +37,7 @@
37 37
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/sched.h>
40 41
41#include <asm/io.h> 42#include <asm/io.h>
42 43
@@ -295,7 +296,7 @@ static int to_mthca_st(int transport)
295 } 296 }
296} 297}
297 298
298static void store_attrs(struct mthca_sqp *sqp, struct ib_qp_attr *attr, 299static void store_attrs(struct mthca_sqp *sqp, const struct ib_qp_attr *attr,
299 int attr_mask) 300 int attr_mask)
300{ 301{
301 if (attr_mask & IB_QP_PKEY_INDEX) 302 if (attr_mask & IB_QP_PKEY_INDEX)
@@ -327,7 +328,7 @@ static void init_port(struct mthca_dev *dev, int port)
327 mthca_warn(dev, "INIT_IB returned status %02x.\n", status); 328 mthca_warn(dev, "INIT_IB returned status %02x.\n", status);
328} 329}
329 330
330static __be32 get_hw_access_flags(struct mthca_qp *qp, struct ib_qp_attr *attr, 331static __be32 get_hw_access_flags(struct mthca_qp *qp, const struct ib_qp_attr *attr,
331 int attr_mask) 332 int attr_mask)
332{ 333{
333 u8 dest_rd_atomic; 334 u8 dest_rd_atomic;
@@ -510,7 +511,7 @@ out:
510 return err; 511 return err;
511} 512}
512 513
513static int mthca_path_set(struct mthca_dev *dev, struct ib_ah_attr *ah, 514static int mthca_path_set(struct mthca_dev *dev, const struct ib_ah_attr *ah,
514 struct mthca_qp_path *path, u8 port) 515 struct mthca_qp_path *path, u8 port)
515{ 516{
516 path->g_mylmc = ah->src_path_bits & 0x7f; 517 path->g_mylmc = ah->src_path_bits & 0x7f;
@@ -538,12 +539,12 @@ static int mthca_path_set(struct mthca_dev *dev, struct ib_ah_attr *ah,
538 return 0; 539 return 0;
539} 540}
540 541
541int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, 542static int __mthca_modify_qp(struct ib_qp *ibqp,
542 struct ib_udata *udata) 543 const struct ib_qp_attr *attr, int attr_mask,
544 enum ib_qp_state cur_state, enum ib_qp_state new_state)
543{ 545{
544 struct mthca_dev *dev = to_mdev(ibqp->device); 546 struct mthca_dev *dev = to_mdev(ibqp->device);
545 struct mthca_qp *qp = to_mqp(ibqp); 547 struct mthca_qp *qp = to_mqp(ibqp);
546 enum ib_qp_state cur_state, new_state;
547 struct mthca_mailbox *mailbox; 548 struct mthca_mailbox *mailbox;
548 struct mthca_qp_param *qp_param; 549 struct mthca_qp_param *qp_param;
549 struct mthca_qp_context *qp_context; 550 struct mthca_qp_context *qp_context;
@@ -551,60 +552,6 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
551 u8 status; 552 u8 status;
552 int err = -EINVAL; 553 int err = -EINVAL;
553 554
554 mutex_lock(&qp->mutex);
555
556 if (attr_mask & IB_QP_CUR_STATE) {
557 cur_state = attr->cur_qp_state;
558 } else {
559 spin_lock_irq(&qp->sq.lock);
560 spin_lock(&qp->rq.lock);
561 cur_state = qp->state;
562 spin_unlock(&qp->rq.lock);
563 spin_unlock_irq(&qp->sq.lock);
564 }
565
566 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
567
568 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) {
569 mthca_dbg(dev, "Bad QP transition (transport %d) "
570 "%d->%d with attr 0x%08x\n",
571 qp->transport, cur_state, new_state,
572 attr_mask);
573 goto out;
574 }
575
576 if (cur_state == new_state && cur_state == IB_QPS_RESET) {
577 err = 0;
578 goto out;
579 }
580
581 if ((attr_mask & IB_QP_PKEY_INDEX) &&
582 attr->pkey_index >= dev->limits.pkey_table_len) {
583 mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n",
584 attr->pkey_index, dev->limits.pkey_table_len-1);
585 goto out;
586 }
587
588 if ((attr_mask & IB_QP_PORT) &&
589 (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
590 mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
591 goto out;
592 }
593
594 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
595 attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
596 mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",
597 attr->max_rd_atomic, dev->limits.max_qp_init_rdma);
598 goto out;
599 }
600
601 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
602 attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) {
603 mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n",
604 attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift);
605 goto out;
606 }
607
608 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 555 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
609 if (IS_ERR(mailbox)) { 556 if (IS_ERR(mailbox)) {
610 err = PTR_ERR(mailbox); 557 err = PTR_ERR(mailbox);
@@ -891,6 +838,98 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
891 838
892out_mailbox: 839out_mailbox:
893 mthca_free_mailbox(dev, mailbox); 840 mthca_free_mailbox(dev, mailbox);
841out:
842 return err;
843}
844
845static const struct ib_qp_attr dummy_init_attr = { .port_num = 1 };
846static const int dummy_init_attr_mask[] = {
847 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
848 IB_QP_PORT |
849 IB_QP_QKEY),
850 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
851 IB_QP_PORT |
852 IB_QP_ACCESS_FLAGS),
853 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
854 IB_QP_PORT |
855 IB_QP_ACCESS_FLAGS),
856 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
857 IB_QP_QKEY),
858 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
859 IB_QP_QKEY),
860};
861
862int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
863 struct ib_udata *udata)
864{
865 struct mthca_dev *dev = to_mdev(ibqp->device);
866 struct mthca_qp *qp = to_mqp(ibqp);
867 enum ib_qp_state cur_state, new_state;
868 int err = -EINVAL;
869
870 mutex_lock(&qp->mutex);
871 if (attr_mask & IB_QP_CUR_STATE) {
872 cur_state = attr->cur_qp_state;
873 } else {
874 spin_lock_irq(&qp->sq.lock);
875 spin_lock(&qp->rq.lock);
876 cur_state = qp->state;
877 spin_unlock(&qp->rq.lock);
878 spin_unlock_irq(&qp->sq.lock);
879 }
880
881 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
882
883 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) {
884 mthca_dbg(dev, "Bad QP transition (transport %d) "
885 "%d->%d with attr 0x%08x\n",
886 qp->transport, cur_state, new_state,
887 attr_mask);
888 goto out;
889 }
890
891 if ((attr_mask & IB_QP_PKEY_INDEX) &&
892 attr->pkey_index >= dev->limits.pkey_table_len) {
893 mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n",
894 attr->pkey_index, dev->limits.pkey_table_len-1);
895 goto out;
896 }
897
898 if ((attr_mask & IB_QP_PORT) &&
899 (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
900 mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
901 goto out;
902 }
903
904 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
905 attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
906 mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",
907 attr->max_rd_atomic, dev->limits.max_qp_init_rdma);
908 goto out;
909 }
910
911 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
912 attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) {
913 mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n",
914 attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift);
915 goto out;
916 }
917
918 if (cur_state == new_state && cur_state == IB_QPS_RESET) {
919 err = 0;
920 goto out;
921 }
922
923 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
924 err = __mthca_modify_qp(ibqp, &dummy_init_attr,
925 dummy_init_attr_mask[ibqp->qp_type],
926 IB_QPS_RESET, IB_QPS_INIT);
927 if (err)
928 goto out;
929 cur_state = IB_QPS_INIT;
930 }
931
932 err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
894 933
895out: 934out:
896 mutex_unlock(&qp->mutex); 935 mutex_unlock(&qp->mutex);
@@ -2245,10 +2284,10 @@ void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
2245 struct mthca_next_seg *next; 2284 struct mthca_next_seg *next;
2246 2285
2247 /* 2286 /*
2248 * For SRQs, all WQEs generate a CQE, so we're always at the 2287 * For SRQs, all receive WQEs generate a CQE, so we're always
2249 * end of the doorbell chain. 2288 * at the end of the doorbell chain.
2250 */ 2289 */
2251 if (qp->ibqp.srq) { 2290 if (qp->ibqp.srq && !is_send) {
2252 *new_wqe = 0; 2291 *new_wqe = 0;
2253 return; 2292 return;
2254 } 2293 }
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 61974b0296ca..b8f05a526673 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -34,6 +34,7 @@
34 34
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/string.h> 36#include <linux/string.h>
37#include <linux/sched.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39 40
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 87310eeb6df0..285c143115cc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -132,12 +132,46 @@ struct ipoib_cm_data {
132 __be32 mtu; 132 __be32 mtu;
133}; 133};
134 134
135/*
136 * Quoting 10.3.1 Queue Pair and EE Context States:
137 *
138 * Note, for QPs that are associated with an SRQ, the Consumer should take the
139 * QP through the Error State before invoking a Destroy QP or a Modify QP to the
140 * Reset State. The Consumer may invoke the Destroy QP without first performing
141 * a Modify QP to the Error State and waiting for the Affiliated Asynchronous
142 * Last WQE Reached Event. However, if the Consumer does not wait for the
143 * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment
144 * leakage may occur. Therefore, it is good programming practice to tear down a
145 * QP that is associated with an SRQ by using the following process:
146 *
147 * - Put the QP in the Error State
148 * - Wait for the Affiliated Asynchronous Last WQE Reached Event;
149 * - either:
150 * drain the CQ by invoking the Poll CQ verb and either wait for CQ
151 * to be empty or the number of Poll CQ operations has exceeded
152 * CQ capacity size;
153 * - or
154 * post another WR that completes on the same CQ and wait for this
155 * WR to return as a WC;
156 * - and then invoke a Destroy QP or Reset QP.
157 *
158 * We use the second option and wait for a completion on the
159 * same CQ before destroying QPs attached to our SRQ.
160 */
161
162enum ipoib_cm_state {
163 IPOIB_CM_RX_LIVE,
164 IPOIB_CM_RX_ERROR, /* Ignored by stale task */
165 IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */
166};
167
135struct ipoib_cm_rx { 168struct ipoib_cm_rx {
136 struct ib_cm_id *id; 169 struct ib_cm_id *id;
137 struct ib_qp *qp; 170 struct ib_qp *qp;
138 struct list_head list; 171 struct list_head list;
139 struct net_device *dev; 172 struct net_device *dev;
140 unsigned long jiffies; 173 unsigned long jiffies;
174 enum ipoib_cm_state state;
141}; 175};
142 176
143struct ipoib_cm_tx { 177struct ipoib_cm_tx {
@@ -165,10 +199,15 @@ struct ipoib_cm_dev_priv {
165 struct ib_srq *srq; 199 struct ib_srq *srq;
166 struct ipoib_cm_rx_buf *srq_ring; 200 struct ipoib_cm_rx_buf *srq_ring;
167 struct ib_cm_id *id; 201 struct ib_cm_id *id;
168 struct list_head passive_ids; 202 struct list_head passive_ids; /* state: LIVE */
203 struct list_head rx_error_list; /* state: ERROR */
204 struct list_head rx_flush_list; /* state: FLUSH, drain not started */
205 struct list_head rx_drain_list; /* state: FLUSH, drain started */
206 struct list_head rx_reap_list; /* state: FLUSH, drain done */
169 struct work_struct start_task; 207 struct work_struct start_task;
170 struct work_struct reap_task; 208 struct work_struct reap_task;
171 struct work_struct skb_task; 209 struct work_struct skb_task;
210 struct work_struct rx_reap_task;
172 struct delayed_work stale_task; 211 struct delayed_work stale_task;
173 struct sk_buff_head skb_queue; 212 struct sk_buff_head skb_queue;
174 struct list_head start_list; 213 struct list_head start_list;
@@ -201,15 +240,17 @@ struct ipoib_dev_priv {
201 struct list_head multicast_list; 240 struct list_head multicast_list;
202 struct rb_root multicast_tree; 241 struct rb_root multicast_tree;
203 242
204 struct delayed_work pkey_task; 243 struct delayed_work pkey_poll_task;
205 struct delayed_work mcast_task; 244 struct delayed_work mcast_task;
206 struct work_struct flush_task; 245 struct work_struct flush_task;
207 struct work_struct restart_task; 246 struct work_struct restart_task;
208 struct delayed_work ah_reap_task; 247 struct delayed_work ah_reap_task;
248 struct work_struct pkey_event_task;
209 249
210 struct ib_device *ca; 250 struct ib_device *ca;
211 u8 port; 251 u8 port;
212 u16 pkey; 252 u16 pkey;
253 u16 pkey_index;
213 struct ib_pd *pd; 254 struct ib_pd *pd;
214 struct ib_mr *mr; 255 struct ib_mr *mr;
215 struct ib_cq *cq; 256 struct ib_cq *cq;
@@ -333,12 +374,13 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
333 374
334int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 375int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
335void ipoib_ib_dev_flush(struct work_struct *work); 376void ipoib_ib_dev_flush(struct work_struct *work);
377void ipoib_pkey_event(struct work_struct *work);
336void ipoib_ib_dev_cleanup(struct net_device *dev); 378void ipoib_ib_dev_cleanup(struct net_device *dev);
337 379
338int ipoib_ib_dev_open(struct net_device *dev); 380int ipoib_ib_dev_open(struct net_device *dev);
339int ipoib_ib_dev_up(struct net_device *dev); 381int ipoib_ib_dev_up(struct net_device *dev);
340int ipoib_ib_dev_down(struct net_device *dev, int flush); 382int ipoib_ib_dev_down(struct net_device *dev, int flush);
341int ipoib_ib_dev_stop(struct net_device *dev); 383int ipoib_ib_dev_stop(struct net_device *dev, int flush);
342 384
343int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 385int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
344void ipoib_dev_cleanup(struct net_device *dev); 386void ipoib_dev_cleanup(struct net_device *dev);
@@ -386,6 +428,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
386 428
387void ipoib_pkey_poll(struct work_struct *work); 429void ipoib_pkey_poll(struct work_struct *work);
388int ipoib_pkey_dev_delay_open(struct net_device *dev); 430int ipoib_pkey_dev_delay_open(struct net_device *dev);
431void ipoib_drain_cq(struct net_device *dev);
389 432
390#ifdef CONFIG_INFINIBAND_IPOIB_CM 433#ifdef CONFIG_INFINIBAND_IPOIB_CM
391 434
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index eec833b81e9b..076a0bbb63d7 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -37,6 +37,7 @@
37#include <net/dst.h> 37#include <net/dst.h>
38#include <net/icmp.h> 38#include <net/icmp.h>
39#include <linux/icmpv6.h> 39#include <linux/icmpv6.h>
40#include <linux/delay.h>
40 41
41#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA 42#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
42static int data_debug_level; 43static int data_debug_level;
@@ -62,6 +63,17 @@ struct ipoib_cm_id {
62 u32 remote_mtu; 63 u32 remote_mtu;
63}; 64};
64 65
66static struct ib_qp_attr ipoib_cm_err_attr = {
67 .qp_state = IB_QPS_ERR
68};
69
70#define IPOIB_CM_RX_DRAIN_WRID 0x7fffffff
71
72static struct ib_send_wr ipoib_cm_rx_drain_wr = {
73 .wr_id = IPOIB_CM_RX_DRAIN_WRID,
74 .opcode = IB_WR_SEND,
75};
76
65static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id, 77static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id,
66 struct ib_cm_event *event); 78 struct ib_cm_event *event);
67 79
@@ -150,15 +162,54 @@ partial_error:
150 return NULL; 162 return NULL;
151} 163}
152 164
165static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv* priv)
166{
167 struct ib_send_wr *bad_wr;
168 struct ipoib_cm_rx *p;
169
170 /* We only reserved 1 extra slot in CQ for drain WRs, so
171 * make sure we have at most 1 outstanding WR. */
172 if (list_empty(&priv->cm.rx_flush_list) ||
173 !list_empty(&priv->cm.rx_drain_list))
174 return;
175
176 /*
177 * QPs on flush list are error state. This way, a "flush
178 * error" WC will be immediately generated for each WR we post.
179 */
180 p = list_entry(priv->cm.rx_flush_list.next, typeof(*p), list);
181 if (ib_post_send(p->qp, &ipoib_cm_rx_drain_wr, &bad_wr))
182 ipoib_warn(priv, "failed to post drain wr\n");
183
184 list_splice_init(&priv->cm.rx_flush_list, &priv->cm.rx_drain_list);
185}
186
187static void ipoib_cm_rx_event_handler(struct ib_event *event, void *ctx)
188{
189 struct ipoib_cm_rx *p = ctx;
190 struct ipoib_dev_priv *priv = netdev_priv(p->dev);
191 unsigned long flags;
192
193 if (event->event != IB_EVENT_QP_LAST_WQE_REACHED)
194 return;
195
196 spin_lock_irqsave(&priv->lock, flags);
197 list_move(&p->list, &priv->cm.rx_flush_list);
198 p->state = IPOIB_CM_RX_FLUSH;
199 ipoib_cm_start_rx_drain(priv);
200 spin_unlock_irqrestore(&priv->lock, flags);
201}
202
153static struct ib_qp *ipoib_cm_create_rx_qp(struct net_device *dev, 203static struct ib_qp *ipoib_cm_create_rx_qp(struct net_device *dev,
154 struct ipoib_cm_rx *p) 204 struct ipoib_cm_rx *p)
155{ 205{
156 struct ipoib_dev_priv *priv = netdev_priv(dev); 206 struct ipoib_dev_priv *priv = netdev_priv(dev);
157 struct ib_qp_init_attr attr = { 207 struct ib_qp_init_attr attr = {
158 .send_cq = priv->cq, /* does not matter, we never send anything */ 208 .event_handler = ipoib_cm_rx_event_handler,
209 .send_cq = priv->cq, /* For drain WR */
159 .recv_cq = priv->cq, 210 .recv_cq = priv->cq,
160 .srq = priv->cm.srq, 211 .srq = priv->cm.srq,
161 .cap.max_send_wr = 1, /* FIXME: 0 Seems not to work */ 212 .cap.max_send_wr = 1, /* For drain WR */
162 .cap.max_send_sge = 1, /* FIXME: 0 Seems not to work */ 213 .cap.max_send_sge = 1, /* FIXME: 0 Seems not to work */
163 .sq_sig_type = IB_SIGNAL_ALL_WR, 214 .sq_sig_type = IB_SIGNAL_ALL_WR,
164 .qp_type = IB_QPT_RC, 215 .qp_type = IB_QPT_RC,
@@ -198,6 +249,27 @@ static int ipoib_cm_modify_rx_qp(struct net_device *dev,
198 ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret); 249 ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret);
199 return ret; 250 return ret;
200 } 251 }
252
253 /*
254 * Current Mellanox HCA firmware won't generate completions
255 * with error for drain WRs unless the QP has been moved to
256 * RTS first. This work-around leaves a window where a QP has
257 * moved to error asynchronously, but this will eventually get
258 * fixed in firmware, so let's not error out if modify QP
259 * fails.
260 */
261 qp_attr.qp_state = IB_QPS_RTS;
262 ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
263 if (ret) {
264 ipoib_warn(priv, "failed to init QP attr for RTS: %d\n", ret);
265 return 0;
266 }
267 ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
268 if (ret) {
269 ipoib_warn(priv, "failed to modify QP to RTS: %d\n", ret);
270 return 0;
271 }
272
201 return 0; 273 return 0;
202} 274}
203 275
@@ -256,6 +328,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
256 328
257 cm_id->context = p; 329 cm_id->context = p;
258 p->jiffies = jiffies; 330 p->jiffies = jiffies;
331 p->state = IPOIB_CM_RX_LIVE;
259 spin_lock_irq(&priv->lock); 332 spin_lock_irq(&priv->lock);
260 if (list_empty(&priv->cm.passive_ids)) 333 if (list_empty(&priv->cm.passive_ids))
261 queue_delayed_work(ipoib_workqueue, 334 queue_delayed_work(ipoib_workqueue,
@@ -277,7 +350,6 @@ static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
277{ 350{
278 struct ipoib_cm_rx *p; 351 struct ipoib_cm_rx *p;
279 struct ipoib_dev_priv *priv; 352 struct ipoib_dev_priv *priv;
280 int ret;
281 353
282 switch (event->event) { 354 switch (event->event) {
283 case IB_CM_REQ_RECEIVED: 355 case IB_CM_REQ_RECEIVED:
@@ -289,20 +361,9 @@ static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
289 case IB_CM_REJ_RECEIVED: 361 case IB_CM_REJ_RECEIVED:
290 p = cm_id->context; 362 p = cm_id->context;
291 priv = netdev_priv(p->dev); 363 priv = netdev_priv(p->dev);
292 spin_lock_irq(&priv->lock); 364 if (ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE))
293 if (list_empty(&p->list)) 365 ipoib_warn(priv, "unable to move qp to error state\n");
294 ret = 0; /* Connection is going away already. */ 366 /* Fall through */
295 else {
296 list_del_init(&p->list);
297 ret = -ECONNRESET;
298 }
299 spin_unlock_irq(&priv->lock);
300 if (ret) {
301 ib_destroy_qp(p->qp);
302 kfree(p);
303 return ret;
304 }
305 return 0;
306 default: 367 default:
307 return 0; 368 return 0;
308 } 369 }
@@ -354,8 +415,15 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
354 wr_id, wc->status); 415 wr_id, wc->status);
355 416
356 if (unlikely(wr_id >= ipoib_recvq_size)) { 417 if (unlikely(wr_id >= ipoib_recvq_size)) {
357 ipoib_warn(priv, "cm recv completion event with wrid %d (> %d)\n", 418 if (wr_id == (IPOIB_CM_RX_DRAIN_WRID & ~IPOIB_CM_OP_SRQ)) {
358 wr_id, ipoib_recvq_size); 419 spin_lock_irqsave(&priv->lock, flags);
420 list_splice_init(&priv->cm.rx_drain_list, &priv->cm.rx_reap_list);
421 ipoib_cm_start_rx_drain(priv);
422 queue_work(ipoib_workqueue, &priv->cm.rx_reap_task);
423 spin_unlock_irqrestore(&priv->lock, flags);
424 } else
425 ipoib_warn(priv, "cm recv completion event with wrid %d (> %d)\n",
426 wr_id, ipoib_recvq_size);
359 return; 427 return;
360 } 428 }
361 429
@@ -374,9 +442,9 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
374 if (p && time_after_eq(jiffies, p->jiffies + IPOIB_CM_RX_UPDATE_TIME)) { 442 if (p && time_after_eq(jiffies, p->jiffies + IPOIB_CM_RX_UPDATE_TIME)) {
375 spin_lock_irqsave(&priv->lock, flags); 443 spin_lock_irqsave(&priv->lock, flags);
376 p->jiffies = jiffies; 444 p->jiffies = jiffies;
377 /* Move this entry to list head, but do 445 /* Move this entry to list head, but do not re-add it
378 * not re-add it if it has been removed. */ 446 * if it has been moved out of list. */
379 if (!list_empty(&p->list)) 447 if (p->state == IPOIB_CM_RX_LIVE)
380 list_move(&p->list, &priv->cm.passive_ids); 448 list_move(&p->list, &priv->cm.passive_ids);
381 spin_unlock_irqrestore(&priv->lock, flags); 449 spin_unlock_irqrestore(&priv->lock, flags);
382 } 450 }
@@ -592,8 +660,7 @@ int ipoib_cm_dev_open(struct net_device *dev)
592 if (IS_ERR(priv->cm.id)) { 660 if (IS_ERR(priv->cm.id)) {
593 printk(KERN_WARNING "%s: failed to create CM ID\n", priv->ca->name); 661 printk(KERN_WARNING "%s: failed to create CM ID\n", priv->ca->name);
594 ret = PTR_ERR(priv->cm.id); 662 ret = PTR_ERR(priv->cm.id);
595 priv->cm.id = NULL; 663 goto err_cm;
596 return ret;
597 } 664 }
598 665
599 ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num), 666 ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num),
@@ -601,34 +668,76 @@ int ipoib_cm_dev_open(struct net_device *dev)
601 if (ret) { 668 if (ret) {
602 printk(KERN_WARNING "%s: failed to listen on ID 0x%llx\n", priv->ca->name, 669 printk(KERN_WARNING "%s: failed to listen on ID 0x%llx\n", priv->ca->name,
603 IPOIB_CM_IETF_ID | priv->qp->qp_num); 670 IPOIB_CM_IETF_ID | priv->qp->qp_num);
604 ib_destroy_cm_id(priv->cm.id); 671 goto err_listen;
605 priv->cm.id = NULL;
606 return ret;
607 } 672 }
673
608 return 0; 674 return 0;
675
676err_listen:
677 ib_destroy_cm_id(priv->cm.id);
678err_cm:
679 priv->cm.id = NULL;
680 return ret;
609} 681}
610 682
611void ipoib_cm_dev_stop(struct net_device *dev) 683void ipoib_cm_dev_stop(struct net_device *dev)
612{ 684{
613 struct ipoib_dev_priv *priv = netdev_priv(dev); 685 struct ipoib_dev_priv *priv = netdev_priv(dev);
614 struct ipoib_cm_rx *p; 686 struct ipoib_cm_rx *p, *n;
687 unsigned long begin;
688 LIST_HEAD(list);
689 int ret;
615 690
616 if (!IPOIB_CM_SUPPORTED(dev->dev_addr) || !priv->cm.id) 691 if (!IPOIB_CM_SUPPORTED(dev->dev_addr) || !priv->cm.id)
617 return; 692 return;
618 693
619 ib_destroy_cm_id(priv->cm.id); 694 ib_destroy_cm_id(priv->cm.id);
620 priv->cm.id = NULL; 695 priv->cm.id = NULL;
696
621 spin_lock_irq(&priv->lock); 697 spin_lock_irq(&priv->lock);
622 while (!list_empty(&priv->cm.passive_ids)) { 698 while (!list_empty(&priv->cm.passive_ids)) {
623 p = list_entry(priv->cm.passive_ids.next, typeof(*p), list); 699 p = list_entry(priv->cm.passive_ids.next, typeof(*p), list);
624 list_del_init(&p->list); 700 list_move(&p->list, &priv->cm.rx_error_list);
701 p->state = IPOIB_CM_RX_ERROR;
702 spin_unlock_irq(&priv->lock);
703 ret = ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE);
704 if (ret)
705 ipoib_warn(priv, "unable to move qp to error state: %d\n", ret);
706 spin_lock_irq(&priv->lock);
707 }
708
709 /* Wait for all RX to be drained */
710 begin = jiffies;
711
712 while (!list_empty(&priv->cm.rx_error_list) ||
713 !list_empty(&priv->cm.rx_flush_list) ||
714 !list_empty(&priv->cm.rx_drain_list)) {
715 if (time_after(jiffies, begin + 5 * HZ)) {
716 ipoib_warn(priv, "RX drain timing out\n");
717
718 /*
719 * assume the HW is wedged and just free up everything.
720 */
721 list_splice_init(&priv->cm.rx_flush_list, &list);
722 list_splice_init(&priv->cm.rx_error_list, &list);
723 list_splice_init(&priv->cm.rx_drain_list, &list);
724 break;
725 }
625 spin_unlock_irq(&priv->lock); 726 spin_unlock_irq(&priv->lock);
727 msleep(1);
728 ipoib_drain_cq(dev);
729 spin_lock_irq(&priv->lock);
730 }
731
732 list_splice_init(&priv->cm.rx_reap_list, &list);
733
734 spin_unlock_irq(&priv->lock);
735
736 list_for_each_entry_safe(p, n, &list, list) {
626 ib_destroy_cm_id(p->id); 737 ib_destroy_cm_id(p->id);
627 ib_destroy_qp(p->qp); 738 ib_destroy_qp(p->qp);
628 kfree(p); 739 kfree(p);
629 spin_lock_irq(&priv->lock);
630 } 740 }
631 spin_unlock_irq(&priv->lock);
632 741
633 cancel_delayed_work(&priv->cm.stale_task); 742 cancel_delayed_work(&priv->cm.stale_task);
634} 743}
@@ -1079,24 +1188,44 @@ void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb,
1079 queue_work(ipoib_workqueue, &priv->cm.skb_task); 1188 queue_work(ipoib_workqueue, &priv->cm.skb_task);
1080} 1189}
1081 1190
1191static void ipoib_cm_rx_reap(struct work_struct *work)
1192{
1193 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1194 cm.rx_reap_task);
1195 struct ipoib_cm_rx *p, *n;
1196 LIST_HEAD(list);
1197
1198 spin_lock_irq(&priv->lock);
1199 list_splice_init(&priv->cm.rx_reap_list, &list);
1200 spin_unlock_irq(&priv->lock);
1201
1202 list_for_each_entry_safe(p, n, &list, list) {
1203 ib_destroy_cm_id(p->id);
1204 ib_destroy_qp(p->qp);
1205 kfree(p);
1206 }
1207}
1208
1082static void ipoib_cm_stale_task(struct work_struct *work) 1209static void ipoib_cm_stale_task(struct work_struct *work)
1083{ 1210{
1084 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, 1211 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
1085 cm.stale_task.work); 1212 cm.stale_task.work);
1086 struct ipoib_cm_rx *p; 1213 struct ipoib_cm_rx *p;
1214 int ret;
1087 1215
1088 spin_lock_irq(&priv->lock); 1216 spin_lock_irq(&priv->lock);
1089 while (!list_empty(&priv->cm.passive_ids)) { 1217 while (!list_empty(&priv->cm.passive_ids)) {
1090 /* List if sorted by LRU, start from tail, 1218 /* List is sorted by LRU, start from tail,
1091 * stop when we see a recently used entry */ 1219 * stop when we see a recently used entry */
1092 p = list_entry(priv->cm.passive_ids.prev, typeof(*p), list); 1220 p = list_entry(priv->cm.passive_ids.prev, typeof(*p), list);
1093 if (time_before_eq(jiffies, p->jiffies + IPOIB_CM_RX_TIMEOUT)) 1221 if (time_before_eq(jiffies, p->jiffies + IPOIB_CM_RX_TIMEOUT))
1094 break; 1222 break;
1095 list_del_init(&p->list); 1223 list_move(&p->list, &priv->cm.rx_error_list);
1224 p->state = IPOIB_CM_RX_ERROR;
1096 spin_unlock_irq(&priv->lock); 1225 spin_unlock_irq(&priv->lock);
1097 ib_destroy_cm_id(p->id); 1226 ret = ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE);
1098 ib_destroy_qp(p->qp); 1227 if (ret)
1099 kfree(p); 1228 ipoib_warn(priv, "unable to move qp to error state: %d\n", ret);
1100 spin_lock_irq(&priv->lock); 1229 spin_lock_irq(&priv->lock);
1101 } 1230 }
1102 1231
@@ -1164,9 +1293,14 @@ int ipoib_cm_dev_init(struct net_device *dev)
1164 INIT_LIST_HEAD(&priv->cm.passive_ids); 1293 INIT_LIST_HEAD(&priv->cm.passive_ids);
1165 INIT_LIST_HEAD(&priv->cm.reap_list); 1294 INIT_LIST_HEAD(&priv->cm.reap_list);
1166 INIT_LIST_HEAD(&priv->cm.start_list); 1295 INIT_LIST_HEAD(&priv->cm.start_list);
1296 INIT_LIST_HEAD(&priv->cm.rx_error_list);
1297 INIT_LIST_HEAD(&priv->cm.rx_flush_list);
1298 INIT_LIST_HEAD(&priv->cm.rx_drain_list);
1299 INIT_LIST_HEAD(&priv->cm.rx_reap_list);
1167 INIT_WORK(&priv->cm.start_task, ipoib_cm_tx_start); 1300 INIT_WORK(&priv->cm.start_task, ipoib_cm_tx_start);
1168 INIT_WORK(&priv->cm.reap_task, ipoib_cm_tx_reap); 1301 INIT_WORK(&priv->cm.reap_task, ipoib_cm_tx_reap);
1169 INIT_WORK(&priv->cm.skb_task, ipoib_cm_skb_reap); 1302 INIT_WORK(&priv->cm.skb_task, ipoib_cm_skb_reap);
1303 INIT_WORK(&priv->cm.rx_reap_task, ipoib_cm_rx_reap);
1170 INIT_DELAYED_WORK(&priv->cm.stale_task, ipoib_cm_stale_task); 1304 INIT_DELAYED_WORK(&priv->cm.stale_task, ipoib_cm_stale_task);
1171 1305
1172 skb_queue_head_init(&priv->cm.skb_queue); 1306 skb_queue_head_init(&priv->cm.skb_queue);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 68d72c6f7ffb..8404f05b2b6e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -448,6 +448,13 @@ int ipoib_ib_dev_open(struct net_device *dev)
448 struct ipoib_dev_priv *priv = netdev_priv(dev); 448 struct ipoib_dev_priv *priv = netdev_priv(dev);
449 int ret; 449 int ret;
450 450
451 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &priv->pkey_index)) {
452 ipoib_warn(priv, "P_Key 0x%04x not found\n", priv->pkey);
453 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
454 return -1;
455 }
456 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
457
451 ret = ipoib_init_qp(dev); 458 ret = ipoib_init_qp(dev);
452 if (ret) { 459 if (ret) {
453 ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret); 460 ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret);
@@ -457,14 +464,14 @@ int ipoib_ib_dev_open(struct net_device *dev)
457 ret = ipoib_ib_post_receives(dev); 464 ret = ipoib_ib_post_receives(dev);
458 if (ret) { 465 if (ret) {
459 ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); 466 ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret);
460 ipoib_ib_dev_stop(dev); 467 ipoib_ib_dev_stop(dev, 1);
461 return -1; 468 return -1;
462 } 469 }
463 470
464 ret = ipoib_cm_dev_open(dev); 471 ret = ipoib_cm_dev_open(dev);
465 if (ret) { 472 if (ret) {
466 ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); 473 ipoib_warn(priv, "ipoib_cm_dev_open returned %d\n", ret);
467 ipoib_ib_dev_stop(dev); 474 ipoib_ib_dev_stop(dev, 1);
468 return -1; 475 return -1;
469 } 476 }
470 477
@@ -516,7 +523,7 @@ int ipoib_ib_dev_down(struct net_device *dev, int flush)
516 if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { 523 if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
517 mutex_lock(&pkey_mutex); 524 mutex_lock(&pkey_mutex);
518 set_bit(IPOIB_PKEY_STOP, &priv->flags); 525 set_bit(IPOIB_PKEY_STOP, &priv->flags);
519 cancel_delayed_work(&priv->pkey_task); 526 cancel_delayed_work(&priv->pkey_poll_task);
520 mutex_unlock(&pkey_mutex); 527 mutex_unlock(&pkey_mutex);
521 if (flush) 528 if (flush)
522 flush_workqueue(ipoib_workqueue); 529 flush_workqueue(ipoib_workqueue);
@@ -543,13 +550,30 @@ static int recvs_pending(struct net_device *dev)
543 return pending; 550 return pending;
544} 551}
545 552
546int ipoib_ib_dev_stop(struct net_device *dev) 553void ipoib_drain_cq(struct net_device *dev)
554{
555 struct ipoib_dev_priv *priv = netdev_priv(dev);
556 int i, n;
557 do {
558 n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc);
559 for (i = 0; i < n; ++i) {
560 if (priv->ibwc[i].wr_id & IPOIB_CM_OP_SRQ)
561 ipoib_cm_handle_rx_wc(dev, priv->ibwc + i);
562 else if (priv->ibwc[i].wr_id & IPOIB_OP_RECV)
563 ipoib_ib_handle_rx_wc(dev, priv->ibwc + i);
564 else
565 ipoib_ib_handle_tx_wc(dev, priv->ibwc + i);
566 }
567 } while (n == IPOIB_NUM_WC);
568}
569
570int ipoib_ib_dev_stop(struct net_device *dev, int flush)
547{ 571{
548 struct ipoib_dev_priv *priv = netdev_priv(dev); 572 struct ipoib_dev_priv *priv = netdev_priv(dev);
549 struct ib_qp_attr qp_attr; 573 struct ib_qp_attr qp_attr;
550 unsigned long begin; 574 unsigned long begin;
551 struct ipoib_tx_buf *tx_req; 575 struct ipoib_tx_buf *tx_req;
552 int i, n; 576 int i;
553 577
554 clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); 578 clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
555 netif_poll_disable(dev); 579 netif_poll_disable(dev);
@@ -604,17 +628,7 @@ int ipoib_ib_dev_stop(struct net_device *dev)
604 goto timeout; 628 goto timeout;
605 } 629 }
606 630
607 do { 631 ipoib_drain_cq(dev);
608 n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc);
609 for (i = 0; i < n; ++i) {
610 if (priv->ibwc[i].wr_id & IPOIB_CM_OP_SRQ)
611 ipoib_cm_handle_rx_wc(dev, priv->ibwc + i);
612 else if (priv->ibwc[i].wr_id & IPOIB_OP_RECV)
613 ipoib_ib_handle_rx_wc(dev, priv->ibwc + i);
614 else
615 ipoib_ib_handle_tx_wc(dev, priv->ibwc + i);
616 }
617 } while (n == IPOIB_NUM_WC);
618 632
619 msleep(1); 633 msleep(1);
620 } 634 }
@@ -629,7 +643,8 @@ timeout:
629 /* Wait for all AHs to be reaped */ 643 /* Wait for all AHs to be reaped */
630 set_bit(IPOIB_STOP_REAPER, &priv->flags); 644 set_bit(IPOIB_STOP_REAPER, &priv->flags);
631 cancel_delayed_work(&priv->ah_reap_task); 645 cancel_delayed_work(&priv->ah_reap_task);
632 flush_workqueue(ipoib_workqueue); 646 if (flush)
647 flush_workqueue(ipoib_workqueue);
633 648
634 begin = jiffies; 649 begin = jiffies;
635 650
@@ -673,13 +688,24 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
673 return 0; 688 return 0;
674} 689}
675 690
676void ipoib_ib_dev_flush(struct work_struct *work) 691static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
677{ 692{
678 struct ipoib_dev_priv *cpriv, *priv = 693 struct ipoib_dev_priv *cpriv;
679 container_of(work, struct ipoib_dev_priv, flush_task);
680 struct net_device *dev = priv->dev; 694 struct net_device *dev = priv->dev;
695 u16 new_index;
696
697 mutex_lock(&priv->vlan_mutex);
698
699 /*
700 * Flush any child interfaces too -- they might be up even if
701 * the parent is down.
702 */
703 list_for_each_entry(cpriv, &priv->child_intfs, list)
704 __ipoib_ib_dev_flush(cpriv, pkey_event);
681 705
682 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { 706 mutex_unlock(&priv->vlan_mutex);
707
708 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) {
683 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); 709 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
684 return; 710 return;
685 } 711 }
@@ -689,10 +715,32 @@ void ipoib_ib_dev_flush(struct work_struct *work)
689 return; 715 return;
690 } 716 }
691 717
718 if (pkey_event) {
719 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
720 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
721 ipoib_ib_dev_down(dev, 0);
722 ipoib_pkey_dev_delay_open(dev);
723 return;
724 }
725 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
726
727 /* restart QP only if P_Key index is changed */
728 if (new_index == priv->pkey_index) {
729 ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n");
730 return;
731 }
732 priv->pkey_index = new_index;
733 }
734
692 ipoib_dbg(priv, "flushing\n"); 735 ipoib_dbg(priv, "flushing\n");
693 736
694 ipoib_ib_dev_down(dev, 0); 737 ipoib_ib_dev_down(dev, 0);
695 738
739 if (pkey_event) {
740 ipoib_ib_dev_stop(dev, 0);
741 ipoib_ib_dev_open(dev);
742 }
743
696 /* 744 /*
697 * The device could have been brought down between the start and when 745 * The device could have been brought down between the start and when
698 * we get here, don't bring it back up if it's not configured up 746 * we get here, don't bring it back up if it's not configured up
@@ -701,14 +749,24 @@ void ipoib_ib_dev_flush(struct work_struct *work)
701 ipoib_ib_dev_up(dev); 749 ipoib_ib_dev_up(dev);
702 ipoib_mcast_restart_task(&priv->restart_task); 750 ipoib_mcast_restart_task(&priv->restart_task);
703 } 751 }
752}
704 753
705 mutex_lock(&priv->vlan_mutex); 754void ipoib_ib_dev_flush(struct work_struct *work)
755{
756 struct ipoib_dev_priv *priv =
757 container_of(work, struct ipoib_dev_priv, flush_task);
706 758
707 /* Flush any child interfaces too */ 759 ipoib_dbg(priv, "Flushing %s\n", priv->dev->name);
708 list_for_each_entry(cpriv, &priv->child_intfs, list) 760 __ipoib_ib_dev_flush(priv, 0);
709 ipoib_ib_dev_flush(&cpriv->flush_task); 761}
710 762
711 mutex_unlock(&priv->vlan_mutex); 763void ipoib_pkey_event(struct work_struct *work)
764{
765 struct ipoib_dev_priv *priv =
766 container_of(work, struct ipoib_dev_priv, pkey_event_task);
767
768 ipoib_dbg(priv, "Flushing %s and restarting its QP\n", priv->dev->name);
769 __ipoib_ib_dev_flush(priv, 1);
712} 770}
713 771
714void ipoib_ib_dev_cleanup(struct net_device *dev) 772void ipoib_ib_dev_cleanup(struct net_device *dev)
@@ -736,7 +794,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
736void ipoib_pkey_poll(struct work_struct *work) 794void ipoib_pkey_poll(struct work_struct *work)
737{ 795{
738 struct ipoib_dev_priv *priv = 796 struct ipoib_dev_priv *priv =
739 container_of(work, struct ipoib_dev_priv, pkey_task.work); 797 container_of(work, struct ipoib_dev_priv, pkey_poll_task.work);
740 struct net_device *dev = priv->dev; 798 struct net_device *dev = priv->dev;
741 799
742 ipoib_pkey_dev_check_presence(dev); 800 ipoib_pkey_dev_check_presence(dev);
@@ -747,7 +805,7 @@ void ipoib_pkey_poll(struct work_struct *work)
747 mutex_lock(&pkey_mutex); 805 mutex_lock(&pkey_mutex);
748 if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) 806 if (!test_bit(IPOIB_PKEY_STOP, &priv->flags))
749 queue_delayed_work(ipoib_workqueue, 807 queue_delayed_work(ipoib_workqueue,
750 &priv->pkey_task, 808 &priv->pkey_poll_task,
751 HZ); 809 HZ);
752 mutex_unlock(&pkey_mutex); 810 mutex_unlock(&pkey_mutex);
753 } 811 }
@@ -766,7 +824,7 @@ int ipoib_pkey_dev_delay_open(struct net_device *dev)
766 mutex_lock(&pkey_mutex); 824 mutex_lock(&pkey_mutex);
767 clear_bit(IPOIB_PKEY_STOP, &priv->flags); 825 clear_bit(IPOIB_PKEY_STOP, &priv->flags);
768 queue_delayed_work(ipoib_workqueue, 826 queue_delayed_work(ipoib_workqueue,
769 &priv->pkey_task, 827 &priv->pkey_poll_task,
770 HZ); 828 HZ);
771 mutex_unlock(&pkey_mutex); 829 mutex_unlock(&pkey_mutex);
772 return 1; 830 return 1;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 0a428f2b05c7..894b1dcdf3eb 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -107,7 +107,7 @@ int ipoib_open(struct net_device *dev)
107 return -EINVAL; 107 return -EINVAL;
108 108
109 if (ipoib_ib_dev_up(dev)) { 109 if (ipoib_ib_dev_up(dev)) {
110 ipoib_ib_dev_stop(dev); 110 ipoib_ib_dev_stop(dev, 1);
111 return -EINVAL; 111 return -EINVAL;
112 } 112 }
113 113
@@ -152,7 +152,7 @@ static int ipoib_stop(struct net_device *dev)
152 flush_workqueue(ipoib_workqueue); 152 flush_workqueue(ipoib_workqueue);
153 153
154 ipoib_ib_dev_down(dev, 1); 154 ipoib_ib_dev_down(dev, 1);
155 ipoib_ib_dev_stop(dev); 155 ipoib_ib_dev_stop(dev, 1);
156 156
157 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { 157 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
158 struct ipoib_dev_priv *cpriv; 158 struct ipoib_dev_priv *cpriv;
@@ -988,7 +988,8 @@ static void ipoib_setup(struct net_device *dev)
988 INIT_LIST_HEAD(&priv->dead_ahs); 988 INIT_LIST_HEAD(&priv->dead_ahs);
989 INIT_LIST_HEAD(&priv->multicast_list); 989 INIT_LIST_HEAD(&priv->multicast_list);
990 990
991 INIT_DELAYED_WORK(&priv->pkey_task, ipoib_pkey_poll); 991 INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll);
992 INIT_WORK(&priv->pkey_event_task, ipoib_pkey_event);
992 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task); 993 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
993 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush); 994 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush);
994 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task); 995 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 54fbead4de01..aae367057a56 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -524,7 +524,7 @@ void ipoib_mcast_join_task(struct work_struct *work)
524 return; 524 return;
525 525
526 if (ib_query_gid(priv->ca, priv->port, 0, &priv->local_gid)) 526 if (ib_query_gid(priv->ca, priv->port, 0, &priv->local_gid))
527 ipoib_warn(priv, "ib_gid_entry_get() failed\n"); 527 ipoib_warn(priv, "ib_query_gid() failed\n");
528 else 528 else
529 memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid)); 529 memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid));
530 530
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 5c3c6a43a52b..982eb88e27ec 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -33,8 +33,6 @@
33 * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $ 33 * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $
34 */ 34 */
35 35
36#include <rdma/ib_cache.h>
37
38#include "ipoib.h" 36#include "ipoib.h"
39 37
40int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) 38int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
@@ -49,7 +47,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
49 if (!qp_attr) 47 if (!qp_attr)
50 goto out; 48 goto out;
51 49
52 if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) { 50 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
53 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 51 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
54 ret = -ENXIO; 52 ret = -ENXIO;
55 goto out; 53 goto out;
@@ -94,26 +92,16 @@ int ipoib_init_qp(struct net_device *dev)
94{ 92{
95 struct ipoib_dev_priv *priv = netdev_priv(dev); 93 struct ipoib_dev_priv *priv = netdev_priv(dev);
96 int ret; 94 int ret;
97 u16 pkey_index;
98 struct ib_qp_attr qp_attr; 95 struct ib_qp_attr qp_attr;
99 int attr_mask; 96 int attr_mask;
100 97
101 /* 98 if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
102 * Search through the port P_Key table for the requested pkey value. 99 return -1;
103 * The port has to be assigned to the respective IB partition in
104 * advance.
105 */
106 ret = ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index);
107 if (ret) {
108 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
109 return ret;
110 }
111 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
112 100
113 qp_attr.qp_state = IB_QPS_INIT; 101 qp_attr.qp_state = IB_QPS_INIT;
114 qp_attr.qkey = 0; 102 qp_attr.qkey = 0;
115 qp_attr.port_num = priv->port; 103 qp_attr.port_num = priv->port;
116 qp_attr.pkey_index = pkey_index; 104 qp_attr.pkey_index = priv->pkey_index;
117 attr_mask = 105 attr_mask =
118 IB_QP_QKEY | 106 IB_QP_QKEY |
119 IB_QP_PORT | 107 IB_QP_PORT |
@@ -185,7 +173,7 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
185 size = ipoib_sendq_size + ipoib_recvq_size + 1; 173 size = ipoib_sendq_size + ipoib_recvq_size + 1;
186 ret = ipoib_cm_dev_init(dev); 174 ret = ipoib_cm_dev_init(dev);
187 if (!ret) 175 if (!ret)
188 size += ipoib_recvq_size; 176 size += ipoib_recvq_size + 1 /* 1 extra for rx_drain_qp */;
189 177
190 priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0); 178 priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0);
191 if (IS_ERR(priv->cq)) { 179 if (IS_ERR(priv->cq)) {
@@ -259,14 +247,18 @@ void ipoib_event(struct ib_event_handler *handler,
259 struct ipoib_dev_priv *priv = 247 struct ipoib_dev_priv *priv =
260 container_of(handler, struct ipoib_dev_priv, event_handler); 248 container_of(handler, struct ipoib_dev_priv, event_handler);
261 249
262 if ((record->event == IB_EVENT_PORT_ERR || 250 if (record->element.port_num != priv->port)
263 record->event == IB_EVENT_PKEY_CHANGE || 251 return;
264 record->event == IB_EVENT_PORT_ACTIVE || 252
265 record->event == IB_EVENT_LID_CHANGE || 253 if (record->event == IB_EVENT_PORT_ERR ||
266 record->event == IB_EVENT_SM_CHANGE || 254 record->event == IB_EVENT_PORT_ACTIVE ||
267 record->event == IB_EVENT_CLIENT_REREGISTER) && 255 record->event == IB_EVENT_LID_CHANGE ||
268 record->element.port_num == priv->port) { 256 record->event == IB_EVENT_SM_CHANGE ||
257 record->event == IB_EVENT_CLIENT_REREGISTER) {
269 ipoib_dbg(priv, "Port state change event\n"); 258 ipoib_dbg(priv, "Port state change event\n");
270 queue_work(ipoib_workqueue, &priv->flush_task); 259 queue_work(ipoib_workqueue, &priv->flush_task);
260 } else if (record->event == IB_EVENT_PKEY_CHANGE) {
261 ipoib_dbg(priv, "P_Key change event on port:%d\n", priv->port);
262 queue_work(ipoib_workqueue, &priv->pkey_event_task);
271 } 263 }
272} 264}
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index fb129c479a66..682244b1c042 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -370,10 +370,8 @@ int iforce_init_device(struct iforce *iforce)
370 370
371/* 371/*
372 * Disable spring, enable force feedback. 372 * Disable spring, enable force feedback.
373 * FIXME: We should use iforce_set_autocenter() et al here.
374 */ 373 */
375 374 iforce_set_autocenter(input_dev, 0);
376 iforce_send_packet(iforce, FF_CMD_AUTOCENTER, "\004\000");
377 375
378/* 376/*
379 * Find appropriate device entry 377 * Find appropriate device entry
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 21c4e13d3a50..3154ccd74000 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -246,6 +246,8 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
246 246
247int iforce_get_id_packet(struct iforce *iforce, char *packet) 247int iforce_get_id_packet(struct iforce *iforce, char *packet)
248{ 248{
249 int status;
250
249 switch (iforce->bus) { 251 switch (iforce->bus) {
250 252
251 case IFORCE_USB: 253 case IFORCE_USB:
@@ -254,18 +256,22 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
254 iforce->cr.bRequest = packet[0]; 256 iforce->cr.bRequest = packet[0];
255 iforce->ctrl->dev = iforce->usbdev; 257 iforce->ctrl->dev = iforce->usbdev;
256 258
257 if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) 259 status = usb_submit_urb(iforce->ctrl, GFP_ATOMIC);
260 if (status) {
261 err("usb_submit_urb failed %d", status);
258 return -1; 262 return -1;
263 }
259 264
260 wait_event_interruptible_timeout(iforce->wait, 265 wait_event_interruptible_timeout(iforce->wait,
261 iforce->ctrl->status != -EINPROGRESS, HZ); 266 iforce->ctrl->status != -EINPROGRESS, HZ);
262 267
263 if (iforce->ctrl->status) { 268 if (iforce->ctrl->status) {
269 dbg("iforce->ctrl->status = %d", iforce->ctrl->status);
264 usb_unlink_urb(iforce->ctrl); 270 usb_unlink_urb(iforce->ctrl);
265 return -1; 271 return -1;
266 } 272 }
267#else 273#else
268 err("iforce_get_id_packet: iforce->bus = USB!"); 274 dbg("iforce_get_id_packet: iforce->bus = USB!");
269#endif 275#endif
270 break; 276 break;
271 277
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 750099d8e3c6..1457b73850e7 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -65,6 +65,7 @@ void iforce_usb_xmit(struct iforce *iforce)
65 XMIT_INC(iforce->xmit.tail, n); 65 XMIT_INC(iforce->xmit.tail, n);
66 66
67 if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { 67 if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) {
68 clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags);
68 warn("usb_submit_urb failed %d\n", n); 69 warn("usb_submit_urb failed %d\n", n);
69 } 70 }
70 71
@@ -163,8 +164,8 @@ static int iforce_usb_probe(struct usb_interface *intf,
163 usb_fill_int_urb(iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress), 164 usb_fill_int_urb(iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress),
164 iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval); 165 iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval);
165 166
166 usb_fill_bulk_urb(iforce->out, dev, usb_sndbulkpipe(dev, epout->bEndpointAddress), 167 usb_fill_int_urb(iforce->out, dev, usb_sndintpipe(dev, epout->bEndpointAddress),
167 iforce + 1, 32, iforce_usb_out, iforce); 168 iforce + 1, 32, iforce_usb_out, iforce, epout->bInterval);
168 169
169 usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0), 170 usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0),
170 (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce); 171 (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce);
diff --git a/drivers/input/misc/input-polldev.c b/drivers/input/misc/input-polldev.c
index 1b2b9c9c5d88..b773d4c756a6 100644
--- a/drivers/input/misc/input-polldev.c
+++ b/drivers/input/misc/input-polldev.c
@@ -12,6 +12,11 @@
12#include <linux/mutex.h> 12#include <linux/mutex.h>
13#include <linux/input-polldev.h> 13#include <linux/input-polldev.h>
14 14
15MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
16MODULE_DESCRIPTION("Generic implementation of a polled input device");
17MODULE_LICENSE("GPL v2");
18MODULE_VERSION("0.1");
19
15static DEFINE_MUTEX(polldev_mutex); 20static DEFINE_MUTEX(polldev_mutex);
16static int polldev_users; 21static int polldev_users;
17static struct workqueue_struct *polldev_wq; 22static struct workqueue_struct *polldev_wq;
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index cf3e4664e72b..2c5f11a4f6b4 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -251,11 +251,15 @@ static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int
251 251
252 dbg("E7 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]); 252 dbg("E7 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
253 253
254 for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++); 254 if (version) {
255 *version = (param[0] << 8) | (param[1] << 4) | i; 255 for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
256 /* empty */;
257 *version = (param[0] << 8) | (param[1] << 4) | i;
258 }
256 259
257 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) 260 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++)
258 if (!memcmp(param, alps_model_data[i].signature, sizeof(alps_model_data[i].signature))) 261 if (!memcmp(param, alps_model_data[i].signature,
262 sizeof(alps_model_data[i].signature)))
259 return alps_model_data + i; 263 return alps_model_data + i;
260 264
261 return NULL; 265 return NULL;
@@ -380,32 +384,46 @@ static int alps_poll(struct psmouse *psmouse)
380 return 0; 384 return 0;
381} 385}
382 386
383static int alps_reconnect(struct psmouse *psmouse) 387static int alps_hw_init(struct psmouse *psmouse, int *version)
384{ 388{
385 struct alps_data *priv = psmouse->private; 389 struct alps_data *priv = psmouse->private;
386 int version;
387
388 psmouse_reset(psmouse);
389 390
390 if (!(priv->i = alps_get_model(psmouse, &version))) 391 priv->i = alps_get_model(psmouse, version);
392 if (!priv->i)
391 return -1; 393 return -1;
392 394
393 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1)) 395 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
394 return -1; 396 return -1;
395 397
396 if (alps_tap_mode(psmouse, 1)) { 398 if (alps_tap_mode(psmouse, 1)) {
397 printk(KERN_WARNING "alps.c: Failed to reenable hardware tapping\n"); 399 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
398 return -1; 400 return -1;
399 } 401 }
400 402
401 if (alps_absolute_mode(psmouse)) { 403 if (alps_absolute_mode(psmouse)) {
402 printk(KERN_ERR "alps.c: Failed to reenable absolute mode\n"); 404 printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
403 return -1; 405 return -1;
404 } 406 }
405 407
406 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0)) 408 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
407 return -1; 409 return -1;
408 410
411 /* ALPS needs stream mode, otherwise it won't report any data */
412 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) {
413 printk(KERN_ERR "alps.c: Failed to enable stream mode\n");
414 return -1;
415 }
416
417 return 0;
418}
419
420static int alps_reconnect(struct psmouse *psmouse)
421{
422 psmouse_reset(psmouse);
423
424 if (alps_hw_init(psmouse, NULL))
425 return -1;
426
409 return 0; 427 return 0;
410} 428}
411 429
@@ -430,23 +448,9 @@ int alps_init(struct psmouse *psmouse)
430 goto init_fail; 448 goto init_fail;
431 449
432 priv->dev2 = dev2; 450 priv->dev2 = dev2;
451 psmouse->private = priv;
433 452
434 priv->i = alps_get_model(psmouse, &version); 453 if (alps_hw_init(psmouse, &version))
435 if (!priv->i)
436 goto init_fail;
437
438 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
439 goto init_fail;
440
441 if (alps_tap_mode(psmouse, 1))
442 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
443
444 if (alps_absolute_mode(psmouse)) {
445 printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
446 goto init_fail;
447 }
448
449 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
450 goto init_fail; 454 goto init_fail;
451 455
452 dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY); 456 dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
@@ -493,13 +497,13 @@ int alps_init(struct psmouse *psmouse)
493 /* We are having trouble resyncing ALPS touchpads so disable it for now */ 497 /* We are having trouble resyncing ALPS touchpads so disable it for now */
494 psmouse->resync_time = 0; 498 psmouse->resync_time = 0;
495 499
496 psmouse->private = priv;
497 return 0; 500 return 0;
498 501
499init_fail: 502init_fail:
500 psmouse_reset(psmouse); 503 psmouse_reset(psmouse);
501 input_free_device(dev2); 504 input_free_device(dev2);
502 kfree(priv); 505 kfree(priv);
506 psmouse->private = NULL;
503 return -1; 507 return -1;
504} 508}
505 509
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 9df74b72e6c4..0c5660d28caa 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -221,6 +221,7 @@ static const struct ps2pp_info *get_model_info(unsigned char model)
221 { 66, PS2PP_KIND_MX, /* MX3100 reciver */ 221 { 66, PS2PP_KIND_MX, /* MX3100 reciver */
222 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 222 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
223 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL }, 223 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL },
224 { 72, PS2PP_KIND_TRACKMAN, 0 }, /* T-CH11: TrackMan Marble */
224 { 73, 0, PS2PP_SIDE_BTN }, 225 { 73, 0, PS2PP_SIDE_BTN },
225 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 226 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
226 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 227 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
index 559508795af1..d31ece8f68e9 100644
--- a/drivers/input/serio/sa1111ps2.c
+++ b/drivers/input/serio/sa1111ps2.c
@@ -170,7 +170,7 @@ static void ps2_close(struct serio *io)
170/* 170/*
171 * Clear the input buffer. 171 * Clear the input buffer.
172 */ 172 */
173static void __init ps2_clear_input(struct ps2if *ps2if) 173static void __devinit ps2_clear_input(struct ps2if *ps2if)
174{ 174{
175 int maxread = 100; 175 int maxread = 100;
176 176
@@ -228,7 +228,7 @@ static int __init ps2_test(struct ps2if *ps2if)
228/* 228/*
229 * Add one device to this driver. 229 * Add one device to this driver.
230 */ 230 */
231static int ps2_probe(struct sa1111_dev *dev) 231static int __devinit ps2_probe(struct sa1111_dev *dev)
232{ 232{
233 struct ps2if *ps2if; 233 struct ps2if *ps2if;
234 struct serio *serio; 234 struct serio *serio;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 4f091800bfeb..e5cca9bd0406 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -12,17 +12,17 @@ menuconfig INPUT_TOUCHSCREEN
12if INPUT_TOUCHSCREEN 12if INPUT_TOUCHSCREEN
13 13
14config TOUCHSCREEN_ADS7846 14config TOUCHSCREEN_ADS7846
15 tristate "ADS 7846/7843 based touchscreens" 15 tristate "ADS7846/TSC2046 and ADS7843 based touchscreens"
16 depends on SPI_MASTER 16 depends on SPI_MASTER
17 depends on HWMON = n || HWMON 17 depends on HWMON = n || HWMON
18 help 18 help
19 Say Y here if you have a touchscreen interface using the 19 Say Y here if you have a touchscreen interface using the
20 ADS7846 or ADS7843 controller, and your board-specific setup 20 ADS7846/TSC2046 or ADS7843 controller, and your board-specific
21 code includes that in its table of SPI devices. 21 setup code includes that in its table of SPI devices.
22 22
23 If HWMON is selected, and the driver is told the reference voltage 23 If HWMON is selected, and the driver is told the reference voltage
24 on your board, you will also get hwmon interfaces for the voltage 24 on your board, you will also get hwmon interfaces for the voltage
25 (and on ads7846, temperature) sensors of this chip. 25 (and on ads7846/tsc2046, temperature) sensors of this chip.
26 26
27 If unsure, say N (but it's safe to say "Y"). 27 If unsure, say N (but it's safe to say "Y").
28 28
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 693e3b2a65a3..1c9069cd3bae 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -39,6 +39,7 @@
39/* 39/*
40 * This code has been heavily tested on a Nokia 770, and lightly 40 * This code has been heavily tested on a Nokia 770, and lightly
41 * tested on other ads7846 devices (OSK/Mistral, Lubbock). 41 * tested on other ads7846 devices (OSK/Mistral, Lubbock).
42 * TSC2046 is just newer ads7846 silicon.
42 * Support for ads7843 tested on Atmel at91sam926x-EK. 43 * Support for ads7843 tested on Atmel at91sam926x-EK.
43 * Support for ads7845 has only been stubbed in. 44 * Support for ads7845 has only been stubbed in.
44 * 45 *
@@ -847,7 +848,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
847 * may not. So we stick to very-portable 8 bit words, both RX and TX. 848 * may not. So we stick to very-portable 8 bit words, both RX and TX.
848 */ 849 */
849 spi->bits_per_word = 8; 850 spi->bits_per_word = 8;
850 spi->mode = SPI_MODE_1; 851 spi->mode = SPI_MODE_0;
851 err = spi_setup(spi); 852 err = spi_setup(spi);
852 if (err < 0) 853 if (err < 0)
853 return err; 854 return err;
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index 61c15024c2a0..1a15475aedfc 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -1,7 +1,6 @@
1#include <linux/input.h> 1#include <linux/input.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/init.h> 3#include <linux/init.h>
4
5#include <linux/interrupt.h> 4#include <linux/interrupt.h>
6#include <asm/io.h> 5#include <asm/io.h>
7#include <asm/delay.h> 6#include <asm/delay.h>
@@ -18,12 +17,12 @@
18#define PHDR 0xa400012e 17#define PHDR 0xa400012e
19#define SCPDR 0xa4000136 18#define SCPDR 0xa4000136
20 19
21static void do_softint(void *data); 20static void do_softint(struct work_struct *work);
22 21
23static struct input_dev *hp680_ts_dev; 22static struct input_dev *hp680_ts_dev;
24static DECLARE_WORK(work, do_softint); 23static DECLARE_DELAYED_WORK(work, do_softint);
25 24
26static void do_softint(void *data) 25static void do_softint(struct work_struct *work)
27{ 26{
28 int absx = 0, absy = 0; 27 int absx = 0, absy = 0;
29 u8 scpdr; 28 u8 scpdr;
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 6582816a0477..f0cbcdb008ed 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -288,9 +288,9 @@ static int ucb1400_ts_thread(void *_ucb)
288 struct ucb1400 *ucb = _ucb; 288 struct ucb1400 *ucb = _ucb;
289 struct task_struct *tsk = current; 289 struct task_struct *tsk = current;
290 int valid = 0; 290 int valid = 0;
291 struct sched_param param = { .sched_priority = 1 };
291 292
292 tsk->policy = SCHED_FIFO; 293 sched_setscheduler(tsk, SCHED_FIFO, &param);
293 tsk->rt_priority = 1;
294 294
295 while (!kthread_should_stop()) { 295 while (!kthread_should_stop()) {
296 unsigned int x, y, p; 296 unsigned int x, y, p;
diff --git a/drivers/isdn/hardware/eicon/capifunc.c b/drivers/isdn/hardware/eicon/capifunc.c
index ff284aeb8fbb..82edc1c1db7a 100644
--- a/drivers/isdn/hardware/eicon/capifunc.c
+++ b/drivers/isdn/hardware/eicon/capifunc.c
@@ -189,21 +189,21 @@ void *TransmitBufferSet(APPL * appl, dword ref)
189{ 189{
190 appl->xbuffer_used[ref] = true; 190 appl->xbuffer_used[ref] = true;
191 DBG_PRV1(("%d:xbuf_used(%d)", appl->Id, ref + 1)) 191 DBG_PRV1(("%d:xbuf_used(%d)", appl->Id, ref + 1))
192 return (void *) ref; 192 return (void *)(long)ref;
193} 193}
194 194
195void *TransmitBufferGet(APPL * appl, void *p) 195void *TransmitBufferGet(APPL * appl, void *p)
196{ 196{
197 if (appl->xbuffer_internal[(dword) p]) 197 if (appl->xbuffer_internal[(dword)(long)p])
198 return appl->xbuffer_internal[(dword) p]; 198 return appl->xbuffer_internal[(dword)(long)p];
199 199
200 return appl->xbuffer_ptr[(dword) p]; 200 return appl->xbuffer_ptr[(dword)(long)p];
201} 201}
202 202
203void TransmitBufferFree(APPL * appl, void *p) 203void TransmitBufferFree(APPL * appl, void *p)
204{ 204{
205 appl->xbuffer_used[(dword) p] = false; 205 appl->xbuffer_used[(dword)(long)p] = false;
206 DBG_PRV1(("%d:xbuf_free(%d)", appl->Id, ((dword) p) + 1)) 206 DBG_PRV1(("%d:xbuf_free(%d)", appl->Id, ((dword)(long)p) + 1))
207} 207}
208 208
209void *ReceiveBufferGet(APPL * appl, int Num) 209void *ReceiveBufferGet(APPL * appl, int Num)
@@ -301,7 +301,7 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
301 /* if DATA_B3_IND, copy data too */ 301 /* if DATA_B3_IND, copy data too */
302 if (command == _DATA_B3_I) { 302 if (command == _DATA_B3_I) {
303 dword data = GET_DWORD(&msg.info.data_b3_ind.Data); 303 dword data = GET_DWORD(&msg.info.data_b3_ind.Data);
304 memcpy(write + length, (void *) data, dlength); 304 memcpy(write + length, (void *)(long)data, dlength);
305 } 305 }
306 306
307#ifndef DIVA_NO_DEBUGLIB 307#ifndef DIVA_NO_DEBUGLIB
@@ -318,7 +318,7 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...)
318 if (myDriverDebugHandle.dbgMask & DL_BLK) { 318 if (myDriverDebugHandle.dbgMask & DL_BLK) {
319 xlog("\x00\x02", &msg, 0x81, length); 319 xlog("\x00\x02", &msg, 0x81, length);
320 for (i = 0; i < dlength; i += 256) { 320 for (i = 0; i < dlength; i += 256) {
321 DBG_BLK((((char *) GET_DWORD(&msg.info.data_b3_ind.Data)) + i, 321 DBG_BLK((((char *)(long)GET_DWORD(&msg.info.data_b3_ind.Data)) + i,
322 ((dlength - i) < 256) ? (dlength - i) : 256)) 322 ((dlength - i) < 256) ? (dlength - i) : 256))
323 if (!(myDriverDebugHandle.dbgMask & DL_PRV0)) 323 if (!(myDriverDebugHandle.dbgMask & DL_PRV0))
324 break; /* not more if not explicitely requested */ 324 break; /* not more if not explicitely requested */
diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c
index 784232a144c8..ccd35d047ec8 100644
--- a/drivers/isdn/hardware/eicon/message.c
+++ b/drivers/isdn/hardware/eicon/message.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * 2 *
4 Copyright (c) Eicon Networks, 2002. 3 Copyright (c) Eicon Networks, 2002.
@@ -533,7 +532,7 @@ word api_put(APPL * appl, CAPI_MSG * msg)
533 if (m->header.command == _DATA_B3_R) 532 if (m->header.command == _DATA_B3_R)
534 { 533 {
535 534
536 m->info.data_b3_req.Data = (dword)(TransmitBufferSet (appl, m->info.data_b3_req.Data)); 535 m->info.data_b3_req.Data = (dword)(long)(TransmitBufferSet (appl, m->info.data_b3_req.Data));
537 536
538 } 537 }
539 538
@@ -1032,7 +1031,7 @@ static void plci_free_msg_in_queue (PLCI *plci)
1032 { 1031 {
1033 1032
1034 TransmitBufferFree (plci->appl, 1033 TransmitBufferFree (plci->appl,
1035 (byte *)(((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->info.data_b3_req.Data)); 1034 (byte *)(long)(((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->info.data_b3_req.Data));
1036 1035
1037 } 1036 }
1038 1037
@@ -3118,7 +3117,7 @@ byte data_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER * a, PLCI * plci,
3118 && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) 3117 && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue)))
3119 { 3118 {
3120 3119
3121 data->P = (byte *)(*((dword *)(parms[0].info))); 3120 data->P = (byte *)(long)(*((dword *)(parms[0].info)));
3122 3121
3123 } 3122 }
3124 else 3123 else
@@ -3151,7 +3150,7 @@ byte data_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER * a, PLCI * plci,
3151 && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) 3150 && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue)))
3152 { 3151 {
3153 3152
3154 TransmitBufferFree (appl, (byte *)(*((dword *)(parms[0].info)))); 3153 TransmitBufferFree (appl, (byte *)(long)(*((dword *)(parms[0].info))));
3155 3154
3156 } 3155 }
3157 } 3156 }
@@ -4057,7 +4056,7 @@ capi_callback_suffix:
4057 { 4056 {
4058 if (m->header.command == _DATA_B3_R) 4057 if (m->header.command == _DATA_B3_R)
4059 4058
4060 TransmitBufferFree (appl, (byte *)(m->info.data_b3_req.Data)); 4059 TransmitBufferFree (appl, (byte *)(long)(m->info.data_b3_req.Data));
4061 4060
4062 dbug(1,dprintf("Error 0x%04x from msg(0x%04x)", i, m->header.command)); 4061 dbug(1,dprintf("Error 0x%04x from msg(0x%04x)", i, m->header.command));
4063 break; 4062 break;
@@ -7134,7 +7133,7 @@ void nl_ind(PLCI * plci)
7134 case N_UDATA: 7133 case N_UDATA:
7135 if (!(udata_forwarding_table[plci->NL.RBuffer->P[0] >> 5] & (1L << (plci->NL.RBuffer->P[0] & 0x1f)))) 7134 if (!(udata_forwarding_table[plci->NL.RBuffer->P[0] >> 5] & (1L << (plci->NL.RBuffer->P[0] & 0x1f))))
7136 { 7135 {
7137 plci->RData[0].P = plci->internal_ind_buffer + (-((int)(plci->internal_ind_buffer)) & 3); 7136 plci->RData[0].P = plci->internal_ind_buffer + (-((int)(long)(plci->internal_ind_buffer)) & 3);
7138 plci->RData[0].PLength = INTERNAL_IND_BUFFER_SIZE; 7137 plci->RData[0].PLength = INTERNAL_IND_BUFFER_SIZE;
7139 plci->NL.R = plci->RData; 7138 plci->NL.R = plci->RData;
7140 plci->NL.RNum = 1; 7139 plci->NL.RNum = 1;
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index da4196f21e0f..8d53a7fd2671 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1551,7 +1551,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1551 if (retval == 0) { // yuck 1551 if (retval == 0) { // yuck
1552 cards[i].typ = 0; 1552 cards[i].typ = 0;
1553 nrcards--; 1553 nrcards--;
1554 return retval; 1554 return -EINVAL;
1555 } 1555 }
1556 cs = cards[i].cs; 1556 cs = cards[i].cs;
1557 hisax_d_if->cs = cs; 1557 hisax_d_if->cs = cs;
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index 1f18f1993387..b1a26e02df02 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -485,7 +485,6 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
485{ 485{
486 int k; 486 int k;
487 487
488 spin_lock_init(&urb->lock);
489 urb->dev = dev; 488 urb->dev = dev;
490 urb->pipe = pipe; 489 urb->pipe = pipe;
491 urb->complete = complete; 490 urb->complete = complete;
@@ -578,16 +577,14 @@ stop_isoc_chain(usb_fifo * fifo)
578 "HFC-S USB: Stopping iso chain for fifo %i.%i", 577 "HFC-S USB: Stopping iso chain for fifo %i.%i",
579 fifo->fifonum, i); 578 fifo->fifonum, i);
580#endif 579#endif
581 usb_unlink_urb(fifo->iso[i].purb); 580 usb_kill_urb(fifo->iso[i].purb);
582 usb_free_urb(fifo->iso[i].purb); 581 usb_free_urb(fifo->iso[i].purb);
583 fifo->iso[i].purb = NULL; 582 fifo->iso[i].purb = NULL;
584 } 583 }
585 } 584 }
586 if (fifo->urb) { 585 usb_kill_urb(fifo->urb);
587 usb_unlink_urb(fifo->urb); 586 usb_free_urb(fifo->urb);
588 usb_free_urb(fifo->urb); 587 fifo->urb = NULL;
589 fifo->urb = NULL;
590 }
591 fifo->active = 0; 588 fifo->active = 0;
592} 589}
593 590
@@ -1305,7 +1302,11 @@ usb_init(hfcusb_data * hfc)
1305 } 1302 }
1306 /* default Prot: EURO ISDN, should be a module_param */ 1303 /* default Prot: EURO ISDN, should be a module_param */
1307 hfc->protocol = 2; 1304 hfc->protocol = 2;
1308 hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol); 1305 i = hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);
1306 if (i) {
1307 printk(KERN_INFO "HFC-S USB: hisax_register -> %d\n", i);
1308 return i;
1309 }
1309 1310
1310#ifdef CONFIG_HISAX_DEBUG 1311#ifdef CONFIG_HISAX_DEBUG
1311 hfc_debug = debug; 1312 hfc_debug = debug;
@@ -1626,11 +1627,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1626#endif 1627#endif
1627 /* init the chip and register the driver */ 1628 /* init the chip and register the driver */
1628 if (usb_init(context)) { 1629 if (usb_init(context)) {
1629 if (context->ctrl_urb) { 1630 usb_kill_urb(context->ctrl_urb);
1630 usb_unlink_urb(context->ctrl_urb); 1631 usb_free_urb(context->ctrl_urb);
1631 usb_free_urb(context->ctrl_urb); 1632 context->ctrl_urb = NULL;
1632 context->ctrl_urb = NULL;
1633 }
1634 kfree(context); 1633 kfree(context);
1635 return (-EIO); 1634 return (-EIO);
1636 } 1635 }
@@ -1682,21 +1681,15 @@ hfc_usb_disconnect(struct usb_interface
1682 i); 1681 i);
1683#endif 1682#endif
1684 } 1683 }
1685 if (context->fifos[i].urb) { 1684 usb_kill_urb(context->fifos[i].urb);
1686 usb_unlink_urb(context->fifos[i].urb); 1685 usb_free_urb(context->fifos[i].urb);
1687 usb_free_urb(context->fifos[i].urb); 1686 context->fifos[i].urb = NULL;
1688 context->fifos[i].urb = NULL;
1689 }
1690 } 1687 }
1691 context->fifos[i].active = 0; 1688 context->fifos[i].active = 0;
1692 } 1689 }
1693 /* wait for all URBS to terminate */ 1690 usb_kill_urb(context->ctrl_urb);
1694 mdelay(10); 1691 usb_free_urb(context->ctrl_urb);
1695 if (context->ctrl_urb) { 1692 context->ctrl_urb = NULL;
1696 usb_unlink_urb(context->ctrl_urb);
1697 usb_free_urb(context->ctrl_urb);
1698 context->ctrl_urb = NULL;
1699 }
1700 hisax_unregister(&context->d_if); 1693 hisax_unregister(&context->d_if);
1701 kfree(context); /* free our structure again */ 1694 kfree(context); /* free our structure again */
1702} /* hfc_usb_disconnect */ 1695} /* hfc_usb_disconnect */
diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c
index 9e088fce8c3a..7993e01f9fc5 100644
--- a/drivers/isdn/hisax/hisax_fcpcipnp.c
+++ b/drivers/isdn/hisax/hisax_fcpcipnp.c
@@ -859,7 +859,11 @@ new_adapter(void)
859 for (i = 0; i < 2; i++) 859 for (i = 0; i < 2; i++)
860 b_if[i] = &adapter->bcs[i].b_if; 860 b_if[i] = &adapter->bcs[i].b_if;
861 861
862 hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp", protocol); 862 if (hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp",
863 protocol) != 0) {
864 kfree(adapter);
865 adapter = NULL;
866 }
863 867
864 return adapter; 868 return adapter;
865} 869}
diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c
index bb3a28a53ff4..13751237bfcd 100644
--- a/drivers/isdn/hisax/st5481_init.c
+++ b/drivers/isdn/hisax/st5481_init.c
@@ -107,12 +107,17 @@ static int probe_st5481(struct usb_interface *intf,
107 for (i = 0; i < 2; i++) 107 for (i = 0; i < 2; i++)
108 b_if[i] = &adapter->bcs[i].b_if; 108 b_if[i] = &adapter->bcs[i].b_if;
109 109
110 hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb", protocol); 110 if (hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb",
111 protocol) != 0)
112 goto err_b1;
113
111 st5481_start(adapter); 114 st5481_start(adapter);
112 115
113 usb_set_intfdata(intf, adapter); 116 usb_set_intfdata(intf, adapter);
114 return 0; 117 return 0;
115 118
119 err_b1:
120 st5481_release_b(&adapter->bcs[1]);
116 err_b: 121 err_b:
117 st5481_release_b(&adapter->bcs[0]); 122 st5481_release_b(&adapter->bcs[0]);
118 err_d: 123 err_d:
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c
index ff1595122048..4ada66b8b679 100644
--- a/drivers/isdn/hisax/st5481_usb.c
+++ b/drivers/isdn/hisax/st5481_usb.c
@@ -407,7 +407,6 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev,
407{ 407{
408 int k; 408 int k;
409 409
410 spin_lock_init(&urb->lock);
411 urb->dev=dev; 410 urb->dev=dev;
412 urb->pipe=pipe; 411 urb->pipe=pipe;
413 urb->interval = 1; 412 urb->interval = 1;
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 1e699bcaba0f..82d957bde299 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -12,6 +12,7 @@
12#include "icn.h" 12#include "icn.h"
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/sched.h>
15 16
16static int portbase = ICN_BASEADDR; 17static int portbase = ICN_BASEADDR;
17static unsigned long membase = ICN_MEMADDR; 18static unsigned long membase = ICN_MEMADDR;
diff --git a/drivers/isdn/sc/message.c b/drivers/isdn/sc/message.c
index c5a307e3c496..0b4c4f15abdd 100644
--- a/drivers/isdn/sc/message.c
+++ b/drivers/isdn/sc/message.c
@@ -16,7 +16,7 @@
16 * +1 (416) 297-8565 16 * +1 (416) 297-8565
17 * +1 (416) 297-6433 Facsimile 17 * +1 (416) 297-6433 Facsimile
18 */ 18 */
19 19#include <linux/sched.h>
20#include "includes.h" 20#include "includes.h"
21#include "hardware.h" 21#include "hardware.h"
22#include "message.h" 22#include "message.h"
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 41634fde8e13..1c040d80c641 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -11,6 +11,7 @@
11#include <linux/mutex.h> 11#include <linux/mutex.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/signal.h>
14 15
15#include "vmx.h" 16#include "vmx.h"
16#include <linux/kvm.h> 17#include <linux/kvm.h>
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 0d892600ff00..da985b31b17e 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -40,6 +40,7 @@
40#include <linux/file.h> 40#include <linux/file.h>
41#include <linux/fs.h> 41#include <linux/fs.h>
42#include <linux/mount.h> 42#include <linux/mount.h>
43#include <linux/sched.h>
43 44
44#include "x86_emulate.h" 45#include "x86_emulate.h"
45#include "segment_descriptor.h" 46#include "segment_descriptor.h"
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 9c15f32eea18..fa17d6d4f0cb 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -19,6 +19,7 @@
19#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/profile.h> 21#include <linux/profile.h>
22#include <linux/sched.h>
22#include <asm/desc.h> 23#include <asm/desc.h>
23 24
24#include "kvm_svm.h" 25#include "kvm_svm.h"
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 724db0027f00..e6e4d240b2a6 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/highmem.h> 23#include <linux/highmem.h>
24#include <linux/profile.h> 24#include <linux/profile.h>
25#include <linux/sched.h>
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/desc.h> 27#include <asm/desc.h>
27 28
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 58926da0ae18..f44c94abd883 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -113,7 +113,6 @@ config PMAC_SMU
113 113
114config PMAC_APM_EMU 114config PMAC_APM_EMU
115 tristate "APM emulation" 115 tristate "APM emulation"
116 select SYS_SUPPORTS_APM_EMULATION
117 select APM_EMULATION 116 select APM_EMULATION
118 depends on ADB_PMU && PM 117 depends on ADB_PMU && PM
119 118
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index b77ef5187d6d..b46817f699f1 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -628,16 +628,16 @@ static void real_leds(unsigned char leds, int device)
628 */ 628 */
629static int adbhid_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 629static int adbhid_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
630{ 630{
631 struct adbhid *adbhid = dev->private; 631 struct adbhid *adbhid = input_get_drvdata(dev);
632 unsigned char leds; 632 unsigned char leds;
633 633
634 switch (type) { 634 switch (type) {
635 case EV_LED: 635 case EV_LED:
636 leds = (test_bit(LED_SCROLLL, dev->led) ? 4 : 0) 636 leds = (test_bit(LED_SCROLLL, dev->led) ? 4 : 0) |
637 | (test_bit(LED_NUML, dev->led) ? 1 : 0) 637 (test_bit(LED_NUML, dev->led) ? 1 : 0) |
638 | (test_bit(LED_CAPSL, dev->led) ? 2 : 0); 638 (test_bit(LED_CAPSL, dev->led) ? 2 : 0);
639 real_leds(leds, adbhid->id); 639 real_leds(leds, adbhid->id);
640 return 0; 640 return 0;
641 } 641 }
642 642
643 return -1; 643 return -1;
@@ -649,7 +649,7 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x)
649 switch (code) { 649 switch (code) {
650 case ADB_MSG_PRE_RESET: 650 case ADB_MSG_PRE_RESET:
651 case ADB_MSG_POWERDOWN: 651 case ADB_MSG_POWERDOWN:
652 /* Stop the repeat timer. Autopoll is already off at this point */ 652 /* Stop the repeat timer. Autopoll is already off at this point */
653 { 653 {
654 int i; 654 int i;
655 for (i = 1; i < 16; i++) { 655 for (i = 1; i < 16; i++) {
@@ -699,7 +699,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
699 hid->current_handler_id = current_handler_id; 699 hid->current_handler_id = current_handler_id;
700 hid->mouse_kind = mouse_kind; 700 hid->mouse_kind = mouse_kind;
701 hid->flags = 0; 701 hid->flags = 0;
702 input_dev->private = hid; 702 input_set_drvdata(input_dev, hid);
703 input_dev->name = hid->name; 703 input_dev->name = hid->name;
704 input_dev->phys = hid->phys; 704 input_dev->phys = hid->phys;
705 input_dev->id.bustype = BUS_ADB; 705 input_dev->id.bustype = BUS_ADB;
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index 192b26e97777..11ced17f438a 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -216,7 +216,10 @@ int wf_register_control(struct wf_control *new_ct)
216 new_ct->attr.attr.mode = 0644; 216 new_ct->attr.attr.mode = 0644;
217 new_ct->attr.show = wf_show_control; 217 new_ct->attr.show = wf_show_control;
218 new_ct->attr.store = wf_store_control; 218 new_ct->attr.store = wf_store_control;
219 device_create_file(&wf_platform_device.dev, &new_ct->attr); 219 if (device_create_file(&wf_platform_device.dev, &new_ct->attr))
220 printk(KERN_WARNING "windfarm: device_create_file failed"
221 " for %s\n", new_ct->name);
222 /* the subsystem still does useful work without the file */
220 223
221 DBG("wf: Registered control %s\n", new_ct->name); 224 DBG("wf: Registered control %s\n", new_ct->name);
222 225
@@ -326,7 +329,10 @@ int wf_register_sensor(struct wf_sensor *new_sr)
326 new_sr->attr.attr.mode = 0444; 329 new_sr->attr.attr.mode = 0444;
327 new_sr->attr.show = wf_show_sensor; 330 new_sr->attr.show = wf_show_sensor;
328 new_sr->attr.store = NULL; 331 new_sr->attr.store = NULL;
329 device_create_file(&wf_platform_device.dev, &new_sr->attr); 332 if (device_create_file(&wf_platform_device.dev, &new_sr->attr))
333 printk(KERN_WARNING "windfarm: device_create_file failed"
334 " for %s\n", new_sr->name);
335 /* the subsystem still does useful work without the file */
330 336
331 DBG("wf: Registered sensor %s\n", new_sr->name); 337 DBG("wf: Registered sensor %s\n", new_sr->name);
332 338
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5a4a74c1097c..9620d452d030 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -255,19 +255,25 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde
255 255
256} 256}
257 257
258static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wait) 258static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
259{ 259{
260 mdk_rdev_t *rdev; 260 mdk_rdev_t *rdev;
261 struct list_head *tmp; 261 struct list_head *tmp;
262 mddev_t *mddev = bitmap->mddev;
262 263
263 ITERATE_RDEV(mddev, rdev, tmp) 264 ITERATE_RDEV(mddev, rdev, tmp)
264 if (test_bit(In_sync, &rdev->flags) 265 if (test_bit(In_sync, &rdev->flags)
265 && !test_bit(Faulty, &rdev->flags)) 266 && !test_bit(Faulty, &rdev->flags)) {
267 int size = PAGE_SIZE;
268 if (page->index == bitmap->file_pages-1)
269 size = roundup(bitmap->last_page_size,
270 bdev_hardsect_size(rdev->bdev));
266 md_super_write(mddev, rdev, 271 md_super_write(mddev, rdev,
267 (rdev->sb_offset<<1) + offset 272 (rdev->sb_offset<<1) + bitmap->offset
268 + page->index * (PAGE_SIZE/512), 273 + page->index * (PAGE_SIZE/512),
269 PAGE_SIZE, 274 size,
270 page); 275 page);
276 }
271 277
272 if (wait) 278 if (wait)
273 md_super_wait(mddev); 279 md_super_wait(mddev);
@@ -282,7 +288,7 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait)
282 struct buffer_head *bh; 288 struct buffer_head *bh;
283 289
284 if (bitmap->file == NULL) 290 if (bitmap->file == NULL)
285 return write_sb_page(bitmap->mddev, bitmap->offset, page, wait); 291 return write_sb_page(bitmap, page, wait);
286 292
287 bh = page_buffers(page); 293 bh = page_buffers(page);
288 294
@@ -923,6 +929,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
923 } 929 }
924 930
925 bitmap->filemap[bitmap->file_pages++] = page; 931 bitmap->filemap[bitmap->file_pages++] = page;
932 bitmap->last_page_size = count;
926 } 933 }
927 paddr = kmap_atomic(page, KM_USER0); 934 paddr = kmap_atomic(page, KM_USER0);
928 if (bitmap->flags & BITMAP_HOSTENDIAN) 935 if (bitmap->flags & BITMAP_HOSTENDIAN)
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index d5ecd2d53046..192741083196 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -139,8 +139,6 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
139 if (!conf) 139 if (!conf)
140 return NULL; 140 return NULL;
141 141
142 mddev->private = conf;
143
144 cnt = 0; 142 cnt = 0;
145 conf->array_size = 0; 143 conf->array_size = 0;
146 144
@@ -232,7 +230,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
232 * First calculate the device offsets. 230 * First calculate the device offsets.
233 */ 231 */
234 conf->disks[0].offset = 0; 232 conf->disks[0].offset = 0;
235 for (i=1; i<mddev->raid_disks; i++) 233 for (i = 1; i < raid_disks; i++)
236 conf->disks[i].offset = 234 conf->disks[i].offset =
237 conf->disks[i-1].offset + 235 conf->disks[i-1].offset +
238 conf->disks[i-1].size; 236 conf->disks[i-1].size;
@@ -244,7 +242,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
244 curr_offset < conf->array_size; 242 curr_offset < conf->array_size;
245 curr_offset += conf->hash_spacing) { 243 curr_offset += conf->hash_spacing) {
246 244
247 while (i < mddev->raid_disks-1 && 245 while (i < raid_disks-1 &&
248 curr_offset >= conf->disks[i+1].offset) 246 curr_offset >= conf->disks[i+1].offset)
249 i++; 247 i++;
250 248
@@ -299,9 +297,11 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
299 */ 297 */
300 linear_conf_t *newconf; 298 linear_conf_t *newconf;
301 299
302 if (rdev->raid_disk != mddev->raid_disks) 300 if (rdev->saved_raid_disk != mddev->raid_disks)
303 return -EINVAL; 301 return -EINVAL;
304 302
303 rdev->raid_disk = rdev->saved_raid_disk;
304
305 newconf = linear_conf(mddev,mddev->raid_disks+1); 305 newconf = linear_conf(mddev,mddev->raid_disks+1);
306 306
307 if (!newconf) 307 if (!newconf)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c10ce91b64e9..1c54f3c1cca7 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1298,8 +1298,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1298 ITERATE_RDEV(mddev,rdev2,tmp) 1298 ITERATE_RDEV(mddev,rdev2,tmp)
1299 if (rdev2->desc_nr+1 > max_dev) 1299 if (rdev2->desc_nr+1 > max_dev)
1300 max_dev = rdev2->desc_nr+1; 1300 max_dev = rdev2->desc_nr+1;
1301 1301
1302 sb->max_dev = cpu_to_le32(max_dev); 1302 if (max_dev > le32_to_cpu(sb->max_dev))
1303 sb->max_dev = cpu_to_le32(max_dev);
1303 for (i=0; i<max_dev;i++) 1304 for (i=0; i<max_dev;i++)
1304 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1305 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1305 1306
@@ -1365,10 +1366,14 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1365 } 1366 }
1366 /* make sure rdev->size exceeds mddev->size */ 1367 /* make sure rdev->size exceeds mddev->size */
1367 if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { 1368 if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) {
1368 if (mddev->pers) 1369 if (mddev->pers) {
1369 /* Cannot change size, so fail */ 1370 /* Cannot change size, so fail
1370 return -ENOSPC; 1371 * If mddev->level <= 0, then we don't care
1371 else 1372 * about aligning sizes (e.g. linear)
1373 */
1374 if (mddev->level > 0)
1375 return -ENOSPC;
1376 } else
1372 mddev->size = rdev->size; 1377 mddev->size = rdev->size;
1373 } 1378 }
1374 1379
@@ -2142,6 +2147,9 @@ static void analyze_sbs(mddev_t * mddev)
2142 rdev->desc_nr = i++; 2147 rdev->desc_nr = i++;
2143 rdev->raid_disk = rdev->desc_nr; 2148 rdev->raid_disk = rdev->desc_nr;
2144 set_bit(In_sync, &rdev->flags); 2149 set_bit(In_sync, &rdev->flags);
2150 } else if (rdev->raid_disk >= mddev->raid_disks) {
2151 rdev->raid_disk = -1;
2152 clear_bit(In_sync, &rdev->flags);
2145 } 2153 }
2146 } 2154 }
2147 2155
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index dfe32149ad3a..2c404f73a377 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -415,7 +415,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
415 raid0_conf_t *conf = mddev_to_conf(mddev); 415 raid0_conf_t *conf = mddev_to_conf(mddev);
416 struct strip_zone *zone; 416 struct strip_zone *zone;
417 mdk_rdev_t *tmp_dev; 417 mdk_rdev_t *tmp_dev;
418 unsigned long chunk; 418 sector_t chunk;
419 sector_t block, rsect; 419 sector_t block, rsect;
420 const int rw = bio_data_dir(bio); 420 const int rw = bio_data_dir(bio);
421 421
@@ -470,7 +470,6 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
470 470
471 sector_div(x, zone->nb_dev); 471 sector_div(x, zone->nb_dev);
472 chunk = x; 472 chunk = x;
473 BUG_ON(x != (sector_t)chunk);
474 473
475 x = block >> chunksize_bits; 474 x = block >> chunksize_bits;
476 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; 475 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)];
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 0393a3d19920..e908e3cf1e50 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1721,9 +1721,6 @@ static void dst_release(struct dvb_frontend *fe)
1721 symbol_put(dst_ca_attach); 1721 symbol_put(dst_ca_attach);
1722#endif 1722#endif
1723 } 1723 }
1724#ifdef CONFIG_DVB_CORE_ATTACH
1725 symbol_put(dst_attach);
1726#endif
1727 kfree(state); 1724 kfree(state);
1728} 1725}
1729 1726
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index e23d8a0ea1d3..a9fa3337dd81 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -200,7 +200,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
200{ 200{
201 struct dvb_device *dvbdev; 201 struct dvb_device *dvbdev;
202 struct file_operations *dvbdevfops; 202 struct file_operations *dvbdevfops;
203 203 struct class_device *clsdev;
204 int id; 204 int id;
205 205
206 mutex_lock(&dvbdev_register_lock); 206 mutex_lock(&dvbdev_register_lock);
@@ -242,8 +242,15 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
242 242
243 mutex_unlock(&dvbdev_register_lock); 243 mutex_unlock(&dvbdev_register_lock);
244 244
245 class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 245 clsdev = class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR,
246 adap->device, "dvb%d.%s%d", adap->num, dnames[type], id); 246 nums2minor(adap->num, type, id)),
247 adap->device, "dvb%d.%s%d", adap->num,
248 dnames[type], id);
249 if (IS_ERR(clsdev)) {
250 printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
251 __FUNCTION__, adap->num, dnames[type], id, PTR_ERR(clsdev));
252 return PTR_ERR(clsdev);
253 }
247 254
248 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", 255 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
249 adap->num, dnames[type], id, nums2minor(adap->num, type, id), 256 adap->num, dnames[type], id, nums2minor(adap->num, type, id),
@@ -431,7 +438,7 @@ static void __exit exit_dvbdev(void)
431 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 438 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
432} 439}
433 440
434module_init(init_dvbdev); 441subsys_initcall(init_dvbdev);
435module_exit(exit_dvbdev); 442module_exit(exit_dvbdev);
436 443
437MODULE_DESCRIPTION("DVB Core Driver"); 444MODULE_DESCRIPTION("DVB Core Driver");
diff --git a/drivers/media/video/cafe_ccic-regs.h b/drivers/media/video/cafe_ccic-regs.h
index b2c22a0d6643..8e2a87cdc791 100644
--- a/drivers/media/video/cafe_ccic-regs.h
+++ b/drivers/media/video/cafe_ccic-regs.h
@@ -150,6 +150,12 @@
150#define REG_GL_IMASK 0x300c /* Interrupt mask register */ 150#define REG_GL_IMASK 0x300c /* Interrupt mask register */
151#define GIMSK_CCIC_EN 0x00000004 /* CCIC Interrupt enable */ 151#define GIMSK_CCIC_EN 0x00000004 /* CCIC Interrupt enable */
152 152
153#define REG_GL_FCR 0x3038 /* GPIO functional control register */
154#define GFCR_GPIO_ON 0x08 /* Camera GPIO enabled */
155#define REG_GL_GPIOR 0x315c /* GPIO register */
156#define GGPIO_OUT 0x80000 /* GPIO output */
157#define GGPIO_VAL 0x00008 /* Output pin value */
158
153#define REG_LEN REG_GL_IMASK + 4 159#define REG_LEN REG_GL_IMASK + 4
154 160
155 161
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 96254dbaf625..c08f650df423 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -775,6 +775,12 @@ static void cafe_ctlr_power_up(struct cafe_camera *cam)
775 spin_lock_irqsave(&cam->dev_lock, flags); 775 spin_lock_irqsave(&cam->dev_lock, flags);
776 cafe_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN); 776 cafe_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN);
777 /* 777 /*
778 * Part one of the sensor dance: turn the global
779 * GPIO signal on.
780 */
781 cafe_reg_write(cam, REG_GL_FCR, GFCR_GPIO_ON);
782 cafe_reg_write(cam, REG_GL_GPIOR, GGPIO_OUT|GGPIO_VAL);
783 /*
778 * Put the sensor into operational mode (assumes OLPC-style 784 * Put the sensor into operational mode (assumes OLPC-style
779 * wiring). Control 0 is reset - set to 1 to operate. 785 * wiring). Control 0 is reset - set to 1 to operate.
780 * Control 1 is power down, set to 0 to operate. 786 * Control 1 is power down, set to 0 to operate.
@@ -784,6 +790,7 @@ static void cafe_ctlr_power_up(struct cafe_camera *cam)
784 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C0); 790 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C0);
785// mdelay(1); /* Enough? */ 791// mdelay(1); /* Enough? */
786 spin_unlock_irqrestore(&cam->dev_lock, flags); 792 spin_unlock_irqrestore(&cam->dev_lock, flags);
793 msleep(5); /* Just to be sure */
787} 794}
788 795
789static void cafe_ctlr_power_down(struct cafe_camera *cam) 796static void cafe_ctlr_power_down(struct cafe_camera *cam)
@@ -792,6 +799,8 @@ static void cafe_ctlr_power_down(struct cafe_camera *cam)
792 799
793 spin_lock_irqsave(&cam->dev_lock, flags); 800 spin_lock_irqsave(&cam->dev_lock, flags);
794 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C1); 801 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C1);
802 cafe_reg_write(cam, REG_GL_FCR, GFCR_GPIO_ON);
803 cafe_reg_write(cam, REG_GL_GPIOR, GGPIO_OUT);
795 cafe_reg_set_bit(cam, REG_CTRL1, C1_PWRDWN); 804 cafe_reg_set_bit(cam, REG_CTRL1, C1_PWRDWN);
796 spin_unlock_irqrestore(&cam->dev_lock, flags); 805 spin_unlock_irqrestore(&cam->dev_lock, flags);
797} 806}
@@ -851,6 +860,7 @@ static int cafe_cam_init(struct cafe_camera *cam)
851 ret = 0; 860 ret = 0;
852 cam->state = S_IDLE; 861 cam->state = S_IDLE;
853 out: 862 out:
863 cafe_ctlr_power_down(cam);
854 mutex_unlock(&cam->s_mutex); 864 mutex_unlock(&cam->s_mutex);
855 return ret; 865 return ret;
856} 866}
@@ -2103,10 +2113,16 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2103 ret = request_irq(pdev->irq, cafe_irq, IRQF_SHARED, "cafe-ccic", cam); 2113 ret = request_irq(pdev->irq, cafe_irq, IRQF_SHARED, "cafe-ccic", cam);
2104 if (ret) 2114 if (ret)
2105 goto out_iounmap; 2115 goto out_iounmap;
2116 /*
2117 * Initialize the controller and leave it powered up. It will
2118 * stay that way until the sensor driver shows up.
2119 */
2106 cafe_ctlr_init(cam); 2120 cafe_ctlr_init(cam);
2107 cafe_ctlr_power_up(cam); 2121 cafe_ctlr_power_up(cam);
2108 /* 2122 /*
2109 * Set up I2C/SMBUS communications 2123 * Set up I2C/SMBUS communications. We have to drop the mutex here
2124 * because the sensor could attach in this call chain, leading to
2125 * unsightly deadlocks.
2110 */ 2126 */
2111 mutex_unlock(&cam->s_mutex); /* attach can deadlock */ 2127 mutex_unlock(&cam->s_mutex); /* attach can deadlock */
2112 ret = cafe_smbus_setup(cam); 2128 ret = cafe_smbus_setup(cam);
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index 2c450bd05af5..5b6a40371602 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,7 +1,6 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM2800/2820/2840 USB video capture support" 2 tristate "Empia EM2800/2820/2840 USB video capture support"
3 depends on VIDEO_V4L1 && I2C && PCI 3 depends on VIDEO_V4L1 && I2C
4 select VIDEO_BUF
5 select VIDEO_TUNER 4 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 5 select VIDEO_TVEEPROM
7 select VIDEO_IR 6 select VIDEO_IR
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index 0cc98a0e2496..1aaeaa02f158 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && USB && I2C && EXPERIMENTAL && PCI 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 9a412d6c6d06..552f04511ead 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -67,14 +67,6 @@
67 67
68#include <media/ivtv.h> 68#include <media/ivtv.h>
69 69
70#ifdef CONFIG_LIRC_I2C
71# error "This driver is not compatible with the LIRC I2C kernel configuration option."
72#endif /* CONFIG_LIRC_I2C */
73
74#ifndef CONFIG_PCI
75# error "This driver requires kernel PCI support."
76#endif /* CONFIG_PCI */
77
78#define IVTV_ENCODER_OFFSET 0x00000000 70#define IVTV_ENCODER_OFFSET 0x00000000
79#define IVTV_ENCODER_SIZE 0x00800000 /* Last half isn't needed 0x01000000 */ 71#define IVTV_ENCODER_SIZE 0x00800000 /* Last half isn't needed 0x01000000 */
80 72
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 794a6a02f82f..1989ec1cb973 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -362,8 +362,6 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
362 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 362 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
363 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 363 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
364 return -EINVAL; 364 return -EINVAL;
365 fmt->fmt.pix.left = itv->main_rect.left;
366 fmt->fmt.pix.top = itv->main_rect.top;
367 fmt->fmt.pix.width = itv->main_rect.width; 365 fmt->fmt.pix.width = itv->main_rect.width;
368 fmt->fmt.pix.height = itv->main_rect.height; 366 fmt->fmt.pix.height = itv->main_rect.height;
369 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 367 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -402,8 +400,6 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
402 break; 400 break;
403 401
404 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 402 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
405 fmt->fmt.pix.left = 0;
406 fmt->fmt.pix.top = 0;
407 fmt->fmt.pix.width = itv->params.width; 403 fmt->fmt.pix.width = itv->params.width;
408 fmt->fmt.pix.height = itv->params.height; 404 fmt->fmt.pix.height = itv->params.height;
409 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 405 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -498,15 +494,13 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
498 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 494 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
499 return -EINVAL; 495 return -EINVAL;
500 field = fmt->fmt.pix.field; 496 field = fmt->fmt.pix.field;
501 r.top = fmt->fmt.pix.top; 497 r.top = 0;
502 r.left = fmt->fmt.pix.left; 498 r.left = 0;
503 r.width = fmt->fmt.pix.width; 499 r.width = fmt->fmt.pix.width;
504 r.height = fmt->fmt.pix.height; 500 r.height = fmt->fmt.pix.height;
505 ivtv_get_fmt(itv, streamtype, fmt); 501 ivtv_get_fmt(itv, streamtype, fmt);
506 if (itv->output_mode != OUT_UDMA_YUV) { 502 if (itv->output_mode != OUT_UDMA_YUV) {
507 /* TODO: would setting the rect also be valid for this mode? */ 503 /* TODO: would setting the rect also be valid for this mode? */
508 fmt->fmt.pix.top = r.top;
509 fmt->fmt.pix.left = r.left;
510 fmt->fmt.pix.width = r.width; 504 fmt->fmt.pix.width = r.width;
511 fmt->fmt.pix.height = r.height; 505 fmt->fmt.pix.height = r.height;
512 } 506 }
@@ -1141,8 +1135,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1141 fb->fmt.pixelformat = itv->osd_pixelformat; 1135 fb->fmt.pixelformat = itv->osd_pixelformat;
1142 fb->fmt.width = itv->osd_rect.width; 1136 fb->fmt.width = itv->osd_rect.width;
1143 fb->fmt.height = itv->osd_rect.height; 1137 fb->fmt.height = itv->osd_rect.height;
1144 fb->fmt.left = itv->osd_rect.left;
1145 fb->fmt.top = itv->osd_rect.top;
1146 fb->base = (void *)itv->osd_video_pbase; 1138 fb->base = (void *)itv->osd_video_pbase;
1147 if (itv->osd_global_alpha_state) 1139 if (itv->osd_global_alpha_state)
1148 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; 1140 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 03bc369a9e49..3ceb8a6249dd 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -720,12 +720,22 @@ static int ov7670_s_fmt(struct i2c_client *c, struct v4l2_format *fmt)
720 struct ov7670_format_struct *ovfmt; 720 struct ov7670_format_struct *ovfmt;
721 struct ov7670_win_size *wsize; 721 struct ov7670_win_size *wsize;
722 struct ov7670_info *info = i2c_get_clientdata(c); 722 struct ov7670_info *info = i2c_get_clientdata(c);
723 unsigned char com7; 723 unsigned char com7, clkrc;
724 724
725 ret = ov7670_try_fmt(c, fmt, &ovfmt, &wsize); 725 ret = ov7670_try_fmt(c, fmt, &ovfmt, &wsize);
726 if (ret) 726 if (ret)
727 return ret; 727 return ret;
728 /* 728 /*
729 * HACK: if we're running rgb565 we need to grab then rewrite
730 * CLKRC. If we're *not*, however, then rewriting clkrc hoses
731 * the colors.
732 */
733 if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565) {
734 ret = ov7670_read(c, REG_CLKRC, &clkrc);
735 if (ret)
736 return ret;
737 }
738 /*
729 * COM7 is a pain in the ass, it doesn't like to be read then 739 * COM7 is a pain in the ass, it doesn't like to be read then
730 * quickly written afterward. But we have everything we need 740 * quickly written afterward. But we have everything we need
731 * to set it absolutely here, as long as the format-specific 741 * to set it absolutely here, as long as the format-specific
@@ -744,7 +754,10 @@ static int ov7670_s_fmt(struct i2c_client *c, struct v4l2_format *fmt)
744 if (wsize->regs) 754 if (wsize->regs)
745 ret = ov7670_write_array(c, wsize->regs); 755 ret = ov7670_write_array(c, wsize->regs);
746 info->fmt = ovfmt; 756 info->fmt = ovfmt;
747 return 0; 757
758 if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565 && ret == 0)
759 ret = ov7670_write(c, REG_CLKRC, clkrc);
760 return ret;
748} 761}
749 762
750/* 763/*
@@ -1267,7 +1280,9 @@ static int ov7670_attach(struct i2c_adapter *adapter)
1267 ret = ov7670_detect(client); 1280 ret = ov7670_detect(client);
1268 if (ret) 1281 if (ret)
1269 goto out_free_info; 1282 goto out_free_info;
1270 i2c_attach_client(client); 1283 ret = i2c_attach_client(client);
1284 if (ret)
1285 goto out_free_info;
1271 return 0; 1286 return 0;
1272 1287
1273 out_free_info: 1288 out_free_info:
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 1b9b0742f753..c40b92ce1fad 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -205,9 +205,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
205 /* 0x01 -> ??? no change ??? */ 205 /* 0x01 -> ??? no change ??? */
206 /* 0x02 -> PAL BDGHI / SECAM L */ 206 /* 0x02 -> PAL BDGHI / SECAM L */
207 /* 0x04 -> ??? PAL others / SECAM others ??? */ 207 /* 0x04 -> ??? PAL others / SECAM others ??? */
208 cb &= ~0x02; 208 cb &= ~0x03;
209 if (t->std & V4L2_STD_SECAM) 209 if (t->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM
210 cb |= 0x02; 210 cb |= PHILIPS_MF_SET_PAL_L;
211 else if (t->std & V4L2_STD_SECAM_LC)
212 cb |= PHILIPS_MF_SET_PAL_L2;
213 else /* V4L2_STD_B|V4L2_STD_GH */
214 cb |= PHILIPS_MF_SET_BG;
211 break; 215 break;
212 216
213 case TUNER_TEMIC_4046FM5: 217 case TUNER_TEMIC_4046FM5:
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index d25d3be8fcd2..165f81d16d00 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -436,7 +436,7 @@ typedef struct _MPT_SAS_MGMT {
436typedef struct _mpt_ioctl_events { 436typedef struct _mpt_ioctl_events {
437 u32 event; /* Specified by define above */ 437 u32 event; /* Specified by define above */
438 u32 eventContext; /* Index or counter */ 438 u32 eventContext; /* Index or counter */
439 int data[2]; /* First 8 bytes of Event Data */ 439 u32 data[2]; /* First 8 bytes of Event Data */
440} MPT_IOCTL_EVENTS; 440} MPT_IOCTL_EVENTS;
441 441
442/* 442/*
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 561074a04b03..bc740a6dd93c 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -2423,11 +2423,11 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2423 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; 2423 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE;
2424 ioc->events[idx].eventContext = ioc->eventContext; 2424 ioc->events[idx].eventContext = ioc->eventContext;
2425 2425
2426 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) || 2426 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) |
2427 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) || 2427 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) |
2428 (sc->device->channel << 8) || sc->device->id; 2428 (sc->device->channel << 8) | sc->device->id;
2429 2429
2430 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12]; 2430 ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12];
2431 2431
2432 ioc->eventContext++; 2432 ioc->eventContext++;
2433 if (hd->ioc->pcidev->vendor == 2433 if (hd->ioc->pcidev->vendor ==
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index d3235f213c89..e0d474b17433 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -123,8 +123,12 @@ int i2o_driver_register(struct i2o_driver *drv)
123 } 123 }
124 124
125 rc = driver_register(&drv->driver); 125 rc = driver_register(&drv->driver);
126 if (rc) 126 if (rc) {
127 destroy_workqueue(drv->event_queue); 127 if (drv->event) {
128 destroy_workqueue(drv->event_queue);
129 drv->event_queue = NULL;
130 }
131 }
128 132
129 return rc; 133 return rc;
130}; 134};
@@ -256,7 +260,7 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
256 int i; 260 int i;
257 struct i2o_driver *drv; 261 struct i2o_driver *drv;
258 262
259 for (i = 0; i < I2O_MAX_DRIVERS; i++) { 263 for (i = 0; i < i2o_max_drivers; i++) {
260 drv = i2o_drivers[i]; 264 drv = i2o_drivers[i];
261 265
262 if (drv) 266 if (drv)
@@ -276,7 +280,7 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
276 int i; 280 int i;
277 struct i2o_driver *drv; 281 struct i2o_driver *drv;
278 282
279 for (i = 0; i < I2O_MAX_DRIVERS; i++) { 283 for (i = 0; i < i2o_max_drivers; i++) {
280 drv = i2o_drivers[i]; 284 drv = i2o_drivers[i];
281 285
282 if (drv) 286 if (drv)
@@ -295,7 +299,7 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
295 int i; 299 int i;
296 struct i2o_driver *drv; 300 struct i2o_driver *drv;
297 301
298 for (i = 0; i < I2O_MAX_DRIVERS; i++) { 302 for (i = 0; i < i2o_max_drivers; i++) {
299 drv = i2o_drivers[i]; 303 drv = i2o_drivers[i];
300 304
301 if (drv) 305 if (drv)
@@ -314,7 +318,7 @@ void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
314 int i; 318 int i;
315 struct i2o_driver *drv; 319 struct i2o_driver *drv;
316 320
317 for (i = 0; i < I2O_MAX_DRIVERS; i++) { 321 for (i = 0; i < i2o_max_drivers; i++) {
318 drv = i2o_drivers[i]; 322 drv = i2o_drivers[i];
319 323
320 if (drv) 324 if (drv)
@@ -335,17 +339,15 @@ int __init i2o_driver_init(void)
335 339
336 spin_lock_init(&i2o_drivers_lock); 340 spin_lock_init(&i2o_drivers_lock);
337 341
338 if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) || 342 if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) {
339 ((i2o_max_drivers ^ (i2o_max_drivers - 1)) != 343 osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n",
340 (2 * i2o_max_drivers - 1))) { 344 i2o_max_drivers);
341 osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
342 "a power of 2\n", i2o_max_drivers);
343 i2o_max_drivers = I2O_MAX_DRIVERS; 345 i2o_max_drivers = I2O_MAX_DRIVERS;
344 } 346 }
345 osm_info("max drivers = %d\n", i2o_max_drivers); 347 osm_info("max drivers = %d\n", i2o_max_drivers);
346 348
347 i2o_drivers = 349 i2o_drivers =
348 kzalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL); 350 kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
349 if (!i2o_drivers) 351 if (!i2o_drivers)
350 return -ENOMEM; 352 return -ENOMEM;
351 353
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index cb8c264eaff0..7772bd1d92b4 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -207,16 +207,7 @@ static int ucb1x00_thread(void *_ts)
207 struct ucb1x00_ts *ts = _ts; 207 struct ucb1x00_ts *ts = _ts;
208 struct task_struct *tsk = current; 208 struct task_struct *tsk = current;
209 DECLARE_WAITQUEUE(wait, tsk); 209 DECLARE_WAITQUEUE(wait, tsk);
210 int valid; 210 int valid = 0;
211
212 /*
213 * We could run as a real-time thread. However, thus far
214 * this doesn't seem to be necessary.
215 */
216// tsk->policy = SCHED_FIFO;
217// tsk->rt_priority = 1;
218
219 valid = 0;
220 211
221 add_wait_queue(&ts->irq_wait, &wait); 212 add_wait_queue(&ts->irq_wait, &wait);
222 while (!kthread_should_stop()) { 213 while (!kthread_should_stop()) {
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index 35b139b0e5f2..5108b7c576df 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -47,6 +47,7 @@ struct phantom_device {
47 struct cdev cdev; 47 struct cdev cdev;
48 48
49 struct mutex open_lock; 49 struct mutex open_lock;
50 spinlock_t ioctl_lock;
50}; 51};
51 52
52static unsigned char phantom_devices[PHANTOM_MAX_MINORS]; 53static unsigned char phantom_devices[PHANTOM_MAX_MINORS];
@@ -59,8 +60,11 @@ static int phantom_status(struct phantom_device *dev, unsigned long newstat)
59 atomic_set(&dev->counter, 0); 60 atomic_set(&dev->counter, 0);
60 iowrite32(PHN_CTL_IRQ, dev->iaddr + PHN_CONTROL); 61 iowrite32(PHN_CTL_IRQ, dev->iaddr + PHN_CONTROL);
61 iowrite32(0x43, dev->caddr + PHN_IRQCTL); 62 iowrite32(0x43, dev->caddr + PHN_IRQCTL);
62 } else if ((dev->status & PHB_RUNNING) && !(newstat & PHB_RUNNING)) 63 ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */
64 } else if ((dev->status & PHB_RUNNING) && !(newstat & PHB_RUNNING)) {
63 iowrite32(0, dev->caddr + PHN_IRQCTL); 65 iowrite32(0, dev->caddr + PHN_IRQCTL);
66 ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */
67 }
64 68
65 dev->status = newstat; 69 dev->status = newstat;
66 70
@@ -71,8 +75,8 @@ static int phantom_status(struct phantom_device *dev, unsigned long newstat)
71 * File ops 75 * File ops
72 */ 76 */
73 77
74static int phantom_ioctl(struct inode *inode, struct file *file, u_int cmd, 78static long phantom_ioctl(struct file *file, unsigned int cmd,
75 u_long arg) 79 unsigned long arg)
76{ 80{
77 struct phantom_device *dev = file->private_data; 81 struct phantom_device *dev = file->private_data;
78 struct phm_regs rs; 82 struct phm_regs rs;
@@ -92,24 +96,32 @@ static int phantom_ioctl(struct inode *inode, struct file *file, u_int cmd,
92 if (r.reg > 7) 96 if (r.reg > 7)
93 return -EINVAL; 97 return -EINVAL;
94 98
99 spin_lock(&dev->ioctl_lock);
95 if (r.reg == PHN_CONTROL && (r.value & PHN_CTL_IRQ) && 100 if (r.reg == PHN_CONTROL && (r.value & PHN_CTL_IRQ) &&
96 phantom_status(dev, dev->status | PHB_RUNNING)) 101 phantom_status(dev, dev->status | PHB_RUNNING)){
102 spin_unlock(&dev->ioctl_lock);
97 return -ENODEV; 103 return -ENODEV;
104 }
98 105
99 pr_debug("phantom: writing %x to %u\n", r.value, r.reg); 106 pr_debug("phantom: writing %x to %u\n", r.value, r.reg);
100 iowrite32(r.value, dev->iaddr + r.reg); 107 iowrite32(r.value, dev->iaddr + r.reg);
108 ioread32(dev->iaddr); /* PCI posting */
101 109
102 if (r.reg == PHN_CONTROL && !(r.value & PHN_CTL_IRQ)) 110 if (r.reg == PHN_CONTROL && !(r.value & PHN_CTL_IRQ))
103 phantom_status(dev, dev->status & ~PHB_RUNNING); 111 phantom_status(dev, dev->status & ~PHB_RUNNING);
112 spin_unlock(&dev->ioctl_lock);
104 break; 113 break;
105 case PHN_SET_REGS: 114 case PHN_SET_REGS:
106 if (copy_from_user(&rs, argp, sizeof(rs))) 115 if (copy_from_user(&rs, argp, sizeof(rs)))
107 return -EFAULT; 116 return -EFAULT;
108 117
109 pr_debug("phantom: SRS %u regs %x\n", rs.count, rs.mask); 118 pr_debug("phantom: SRS %u regs %x\n", rs.count, rs.mask);
119 spin_lock(&dev->ioctl_lock);
110 for (i = 0; i < min(rs.count, 8U); i++) 120 for (i = 0; i < min(rs.count, 8U); i++)
111 if ((1 << i) & rs.mask) 121 if ((1 << i) & rs.mask)
112 iowrite32(rs.values[i], dev->oaddr + i); 122 iowrite32(rs.values[i], dev->oaddr + i);
123 ioread32(dev->iaddr); /* PCI posting */
124 spin_unlock(&dev->ioctl_lock);
113 break; 125 break;
114 case PHN_GET_REG: 126 case PHN_GET_REG:
115 if (copy_from_user(&r, argp, sizeof(r))) 127 if (copy_from_user(&r, argp, sizeof(r)))
@@ -128,9 +140,11 @@ static int phantom_ioctl(struct inode *inode, struct file *file, u_int cmd,
128 return -EFAULT; 140 return -EFAULT;
129 141
130 pr_debug("phantom: GRS %u regs %x\n", rs.count, rs.mask); 142 pr_debug("phantom: GRS %u regs %x\n", rs.count, rs.mask);
143 spin_lock(&dev->ioctl_lock);
131 for (i = 0; i < min(rs.count, 8U); i++) 144 for (i = 0; i < min(rs.count, 8U); i++)
132 if ((1 << i) & rs.mask) 145 if ((1 << i) & rs.mask)
133 rs.values[i] = ioread32(dev->iaddr + i); 146 rs.values[i] = ioread32(dev->iaddr + i);
147 spin_unlock(&dev->ioctl_lock);
134 148
135 if (copy_to_user(argp, &rs, sizeof(rs))) 149 if (copy_to_user(argp, &rs, sizeof(rs)))
136 return -EFAULT; 150 return -EFAULT;
@@ -199,7 +213,7 @@ static unsigned int phantom_poll(struct file *file, poll_table *wait)
199static struct file_operations phantom_file_ops = { 213static struct file_operations phantom_file_ops = {
200 .open = phantom_open, 214 .open = phantom_open,
201 .release = phantom_release, 215 .release = phantom_release,
202 .ioctl = phantom_ioctl, 216 .unlocked_ioctl = phantom_ioctl,
203 .poll = phantom_poll, 217 .poll = phantom_poll,
204}; 218};
205 219
@@ -212,6 +226,7 @@ static irqreturn_t phantom_isr(int irq, void *data)
212 226
213 iowrite32(0, dev->iaddr); 227 iowrite32(0, dev->iaddr);
214 iowrite32(0xc0, dev->iaddr); 228 iowrite32(0xc0, dev->iaddr);
229 ioread32(dev->iaddr); /* PCI posting */
215 230
216 atomic_inc(&dev->counter); 231 atomic_inc(&dev->counter);
217 wake_up_interruptible(&dev->wait); 232 wake_up_interruptible(&dev->wait);
@@ -282,11 +297,13 @@ static int __devinit phantom_probe(struct pci_dev *pdev,
282 } 297 }
283 298
284 mutex_init(&pht->open_lock); 299 mutex_init(&pht->open_lock);
300 spin_lock_init(&pht->ioctl_lock);
285 init_waitqueue_head(&pht->wait); 301 init_waitqueue_head(&pht->wait);
286 cdev_init(&pht->cdev, &phantom_file_ops); 302 cdev_init(&pht->cdev, &phantom_file_ops);
287 pht->cdev.owner = THIS_MODULE; 303 pht->cdev.owner = THIS_MODULE;
288 304
289 iowrite32(0, pht->caddr + PHN_IRQCTL); 305 iowrite32(0, pht->caddr + PHN_IRQCTL);
306 ioread32(pht->caddr + PHN_IRQCTL); /* PCI posting */
290 retval = request_irq(pdev->irq, phantom_isr, 307 retval = request_irq(pdev->irq, phantom_isr,
291 IRQF_SHARED | IRQF_DISABLED, "phantom", pht); 308 IRQF_SHARED | IRQF_DISABLED, "phantom", pht);
292 if (retval) { 309 if (retval) {
@@ -337,6 +354,7 @@ static void __devexit phantom_remove(struct pci_dev *pdev)
337 cdev_del(&pht->cdev); 354 cdev_del(&pht->cdev);
338 355
339 iowrite32(0, pht->caddr + PHN_IRQCTL); 356 iowrite32(0, pht->caddr + PHN_IRQCTL);
357 ioread32(pht->caddr + PHN_IRQCTL); /* PCI posting */
340 free_irq(pdev->irq, pht); 358 free_irq(pdev->irq, pht);
341 359
342 pci_iounmap(pdev, pht->oaddr); 360 pci_iounmap(pdev, pht->oaddr);
@@ -358,6 +376,7 @@ static int phantom_suspend(struct pci_dev *pdev, pm_message_t state)
358 struct phantom_device *dev = pci_get_drvdata(pdev); 376 struct phantom_device *dev = pci_get_drvdata(pdev);
359 377
360 iowrite32(0, dev->caddr + PHN_IRQCTL); 378 iowrite32(0, dev->caddr + PHN_IRQCTL);
379 ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */
361 380
362 return 0; 381 return 0;
363} 382}
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index a7562f7fc0b3..540ff4bea54c 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -135,23 +135,6 @@ struct mmc_blk_request {
135 struct mmc_data data; 135 struct mmc_data data;
136}; 136};
137 137
138static int mmc_blk_prep_rq(struct mmc_queue *mq, struct request *req)
139{
140 struct mmc_blk_data *md = mq->data;
141 int stat = BLKPREP_OK;
142
143 /*
144 * If we have no device, we haven't finished initialising.
145 */
146 if (!md || !mq->card) {
147 printk(KERN_ERR "%s: killing request - no device/host\n",
148 req->rq_disk->disk_name);
149 stat = BLKPREP_KILL;
150 }
151
152 return stat;
153}
154
155static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) 138static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
156{ 139{
157 int err; 140 int err;
@@ -460,7 +443,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
460 if (ret) 443 if (ret)
461 goto err_putdisk; 444 goto err_putdisk;
462 445
463 md->queue.prep_fn = mmc_blk_prep_rq;
464 md->queue.issue_fn = mmc_blk_issue_rq; 446 md->queue.issue_fn = mmc_blk_issue_rq;
465 md->queue.data = md; 447 md->queue.data = md;
466 448
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 2e77963db334..dd97bc798409 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -20,40 +20,21 @@
20#define MMC_QUEUE_SUSPENDED (1 << 0) 20#define MMC_QUEUE_SUSPENDED (1 << 0)
21 21
22/* 22/*
23 * Prepare a MMC request. Essentially, this means passing the 23 * Prepare a MMC request. This just filters out odd stuff.
24 * preparation off to the media driver. The media driver will
25 * create a mmc_io_request in req->special.
26 */ 24 */
27static int mmc_prep_request(struct request_queue *q, struct request *req) 25static int mmc_prep_request(struct request_queue *q, struct request *req)
28{ 26{
29 struct mmc_queue *mq = q->queuedata; 27 /*
30 int ret = BLKPREP_KILL; 28 * We only like normal block requests.
31 29 */
32 if (blk_special_request(req)) { 30 if (!blk_fs_request(req) && !blk_pc_request(req)) {
33 /*
34 * Special commands already have the command
35 * blocks already setup in req->special.
36 */
37 BUG_ON(!req->special);
38
39 ret = BLKPREP_OK;
40 } else if (blk_fs_request(req) || blk_pc_request(req)) {
41 /*
42 * Block I/O requests need translating according
43 * to the protocol.
44 */
45 ret = mq->prep_fn(mq, req);
46 } else {
47 /*
48 * Everything else is invalid.
49 */
50 blk_dump_rq_flags(req, "MMC bad request"); 31 blk_dump_rq_flags(req, "MMC bad request");
32 return BLKPREP_KILL;
51 } 33 }
52 34
53 if (ret == BLKPREP_OK) 35 req->cmd_flags |= REQ_DONTPREP;
54 req->cmd_flags |= REQ_DONTPREP;
55 36
56 return ret; 37 return BLKPREP_OK;
57} 38}
58 39
59static int mmc_queue_thread(void *d) 40static int mmc_queue_thread(void *d)
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
index c9f139e764f6..1590b3f3f1f7 100644
--- a/drivers/mmc/card/queue.h
+++ b/drivers/mmc/card/queue.h
@@ -10,20 +10,12 @@ struct mmc_queue {
10 struct semaphore thread_sem; 10 struct semaphore thread_sem;
11 unsigned int flags; 11 unsigned int flags;
12 struct request *req; 12 struct request *req;
13 int (*prep_fn)(struct mmc_queue *, struct request *);
14 int (*issue_fn)(struct mmc_queue *, struct request *); 13 int (*issue_fn)(struct mmc_queue *, struct request *);
15 void *data; 14 void *data;
16 struct request_queue *queue; 15 struct request_queue *queue;
17 struct scatterlist *sg; 16 struct scatterlist *sg;
18}; 17};
19 18
20struct mmc_io_request {
21 struct request *rq;
22 int num;
23 struct mmc_command selcmd; /* mmc_queue private */
24 struct mmc_command cmd[4]; /* max 4 commands */
25};
26
27extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *); 19extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *);
28extern void mmc_cleanup_queue(struct mmc_queue *); 20extern void mmc_cleanup_queue(struct mmc_queue *);
29extern void mmc_queue_suspend(struct mmc_queue *); 21extern void mmc_queue_suspend(struct mmc_queue *);
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 3dba5733ed1f..74002945b71b 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -940,9 +940,6 @@ static void ltree_entry_ctor(void *obj, struct kmem_cache *cache,
940{ 940{
941 struct ltree_entry *le = obj; 941 struct ltree_entry *le = obj;
942 942
943 if (flags & SLAB_CTOR_CONSTRUCTOR)
944 return;
945
946 le->users = 0; 943 le->users = 0;
947 init_rwsem(&le->mutex); 944 init_rwsem(&le->mutex);
948} 945}
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index c5baa197bc08..1798a9f9fb25 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2218,7 +2218,7 @@ config SK98LIN
2218 2218
2219config VIA_VELOCITY 2219config VIA_VELOCITY
2220 tristate "VIA Velocity support" 2220 tristate "VIA Velocity support"
2221 depends on NET_PCI && PCI 2221 depends on PCI
2222 select CRC32 2222 select CRC32
2223 select CRC_CCITT 2223 select CRC_CCITT
2224 select MII 2224 select MII
@@ -2280,7 +2280,6 @@ config GFAR_NAPI
2280config UCC_GETH 2280config UCC_GETH
2281 tristate "Freescale QE Gigabit Ethernet" 2281 tristate "Freescale QE Gigabit Ethernet"
2282 depends on QUICC_ENGINE 2282 depends on QUICC_ENGINE
2283 select UCC_FAST
2284 help 2283 help
2285 This driver supports the Gigabit Ethernet mode of the QUICC Engine, 2284 This driver supports the Gigabit Ethernet mode of the QUICC Engine,
2286 which is available on some Freescale SOCs. 2285 which is available on some Freescale SOCs.
diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index 7284ccad0b91..4030274fe788 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -2,10 +2,8 @@
2# Arcnet configuration 2# Arcnet configuration
3# 3#
4 4
5menu "ARCnet devices" 5menuconfig ARCNET
6 depends on NETDEVICES && (ISA || PCI) 6 depends on NETDEVICES && (ISA || PCI)
7
8config ARCNET
9 tristate "ARCnet support" 7 tristate "ARCnet support"
10 ---help--- 8 ---help---
11 If you have a network card of this type, say Y and check out the 9 If you have a network card of this type, say Y and check out the
@@ -25,9 +23,10 @@ config ARCNET
25 <file:Documentation/networking/net-modules.txt>. The module will 23 <file:Documentation/networking/net-modules.txt>. The module will
26 be called arcnet. 24 be called arcnet.
27 25
26if ARCNET
27
28config ARCNET_1201 28config ARCNET_1201
29 tristate "Enable standard ARCNet packet format (RFC 1201)" 29 tristate "Enable standard ARCNet packet format (RFC 1201)"
30 depends on ARCNET
31 help 30 help
32 This allows you to use RFC1201 with your ARCnet card via the virtual 31 This allows you to use RFC1201 with your ARCnet card via the virtual
33 arc0 device. You need to say Y here to communicate with 32 arc0 device. You need to say Y here to communicate with
@@ -38,7 +37,6 @@ config ARCNET_1201
38 37
39config ARCNET_1051 38config ARCNET_1051
40 tristate "Enable old ARCNet packet format (RFC 1051)" 39 tristate "Enable old ARCNet packet format (RFC 1051)"
41 depends on ARCNET
42 ---help--- 40 ---help---
43 This allows you to use RFC1051 with your ARCnet card via the virtual 41 This allows you to use RFC1051 with your ARCnet card via the virtual
44 arc0s device. You only need arc0s if you want to talk to ARCnet 42 arc0s device. You only need arc0s if you want to talk to ARCnet
@@ -53,7 +51,6 @@ config ARCNET_1051
53 51
54config ARCNET_RAW 52config ARCNET_RAW
55 tristate "Enable raw mode packet interface" 53 tristate "Enable raw mode packet interface"
56 depends on ARCNET
57 help 54 help
58 ARCnet "raw mode" packet encapsulation, no soft headers. Unlikely 55 ARCnet "raw mode" packet encapsulation, no soft headers. Unlikely
59 to work unless talking to a copy of the same Linux arcnet driver, 56 to work unless talking to a copy of the same Linux arcnet driver,
@@ -61,7 +58,6 @@ config ARCNET_RAW
61 58
62config ARCNET_CAP 59config ARCNET_CAP
63 tristate "Enable CAP mode packet interface" 60 tristate "Enable CAP mode packet interface"
64 depends on ARCNET
65 help 61 help
66 ARCnet "cap mode" packet encapsulation. Used to get the hardware 62 ARCnet "cap mode" packet encapsulation. Used to get the hardware
67 acknowledge back to userspace. After the initial protocol byte every 63 acknowledge back to userspace. After the initial protocol byte every
@@ -80,7 +76,6 @@ config ARCNET_CAP
80 76
81config ARCNET_COM90xx 77config ARCNET_COM90xx
82 tristate "ARCnet COM90xx (normal) chipset driver" 78 tristate "ARCnet COM90xx (normal) chipset driver"
83 depends on ARCNET
84 help 79 help
85 This is the chipset driver for the standard COM90xx cards. If you 80 This is the chipset driver for the standard COM90xx cards. If you
86 have always used the old ARCnet driver without knowing what type of 81 have always used the old ARCnet driver without knowing what type of
@@ -92,7 +87,6 @@ config ARCNET_COM90xx
92 87
93config ARCNET_COM90xxIO 88config ARCNET_COM90xxIO
94 tristate "ARCnet COM90xx (IO mapped) chipset driver" 89 tristate "ARCnet COM90xx (IO mapped) chipset driver"
95 depends on ARCNET
96 ---help--- 90 ---help---
97 This is the chipset driver for the COM90xx cards, using them in 91 This is the chipset driver for the COM90xx cards, using them in
98 IO-mapped mode instead of memory-mapped mode. This is slower than 92 IO-mapped mode instead of memory-mapped mode. This is slower than
@@ -105,7 +99,6 @@ config ARCNET_COM90xxIO
105 99
106config ARCNET_RIM_I 100config ARCNET_RIM_I
107 tristate "ARCnet COM90xx (RIM I) chipset driver" 101 tristate "ARCnet COM90xx (RIM I) chipset driver"
108 depends on ARCNET
109 ---help--- 102 ---help---
110 This is yet another chipset driver for the COM90xx cards, but this 103 This is yet another chipset driver for the COM90xx cards, but this
111 time only using memory-mapped mode, and no IO ports at all. This 104 time only using memory-mapped mode, and no IO ports at all. This
@@ -118,7 +111,6 @@ config ARCNET_RIM_I
118 111
119config ARCNET_COM20020 112config ARCNET_COM20020
120 tristate "ARCnet COM20020 chipset driver" 113 tristate "ARCnet COM20020 chipset driver"
121 depends on ARCNET
122 help 114 help
123 This is the driver for the new COM20020 chipset. It supports such 115 This is the driver for the new COM20020 chipset. It supports such
124 things as promiscuous mode, so packet sniffing is possible, and 116 things as promiscuous mode, so packet sniffing is possible, and
@@ -136,5 +128,4 @@ config ARCNET_COM20020_PCI
136 tristate "Support for COM20020 on PCI" 128 tristate "Support for COM20020 on PCI"
137 depends on ARCNET_COM20020 && PCI 129 depends on ARCNET_COM20020 && PCI
138 130
139endmenu 131endif # ARCNET
140
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 4aec747d9e43..9fe3a38883ee 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4919,7 +4919,10 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4919 pci_cmd &= ~PCI_COMMAND_SERR; 4919 pci_cmd &= ~PCI_COMMAND_SERR;
4920 pci_cmd |= PCI_COMMAND_PARITY; 4920 pci_cmd |= PCI_COMMAND_PARITY;
4921 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); 4921 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
4922 pci_set_mwi(pdev); 4922 if (pci_set_mwi(pdev))
4923 printk(KERN_WARNING PFX "Could enable MWI for %s\n",
4924 pci_name(pdev));
4925
4923 /* 4926 /*
4924 * On some architectures, the default cache line size set 4927 * On some architectures, the default cache line size set
4925 * by pci_set_mwi reduces perforamnce. We have to increase 4928 * by pci_set_mwi reduces perforamnce. We have to increase
diff --git a/drivers/net/chelsio/suni1x10gexp_regs.h b/drivers/net/chelsio/suni1x10gexp_regs.h
index 269d097dd927..d0f87d82566a 100644
--- a/drivers/net/chelsio/suni1x10gexp_regs.h
+++ b/drivers/net/chelsio/suni1x10gexp_regs.h
@@ -105,7 +105,7 @@
105#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_LOW(filterId) (0x204A + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId)) 105#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_LOW(filterId) (0x204A + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
106#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_MID(filterId) (0x204B + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId)) 106#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_MID(filterId) (0x204B + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
107#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_HIGH(filterId)(0x204C + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId)) 107#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_HIGH(filterId)(0x204C + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
108#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID(filterId) (0x2062 + mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId) 108#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID(filterId) (0x2062 + mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId))
109#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_LOW 0x204A 109#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_LOW 0x204A
110#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_MID 0x204B 110#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_MID 0x204B
111#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_HIGH 0x204C 111#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_HIGH 0x204C
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 95d854e2295c..b2577f40124e 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -932,8 +932,6 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
932 /* Kick the lance: transmit now */ 932 /* Kick the lance: transmit now */
933 writereg(&ll->rdp, LE_C0_INEA | LE_C0_TDMD); 933 writereg(&ll->rdp, LE_C0_INEA | LE_C0_TDMD);
934 934
935 spin_unlock_irq(&lp->lock);
936
937 dev->trans_start = jiffies; 935 dev->trans_start = jiffies;
938 dev_kfree_skb(skb); 936 dev_kfree_skb(skb);
939 937
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index 571d82f8008c..7df23dc28190 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -566,6 +566,7 @@ static int __devinit dfx_register(struct device *bdev)
566 bp->base.mem = ioremap_nocache(bar_start, bar_len); 566 bp->base.mem = ioremap_nocache(bar_start, bar_len);
567 if (!bp->base.mem) { 567 if (!bp->base.mem) {
568 printk(KERN_ERR "%s: Cannot map MMIO\n", print_name); 568 printk(KERN_ERR "%s: Cannot map MMIO\n", print_name);
569 err = -ENOMEM;
569 goto err_out_region; 570 goto err_out_region;
570 } 571 }
571 } else { 572 } else {
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index a9ea67e75c1b..16a6edfeba41 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -333,11 +333,9 @@ struct e1000_adapter {
333 struct e1000_tx_ring test_tx_ring; 333 struct e1000_tx_ring test_tx_ring;
334 struct e1000_rx_ring test_rx_ring; 334 struct e1000_rx_ring test_rx_ring;
335 335
336
337 int msg_enable; 336 int msg_enable;
338#ifdef CONFIG_PCI_MSI
339 boolean_t have_msi; 337 boolean_t have_msi;
340#endif 338
341 /* to not mess up cache alignment, always add to the bottom */ 339 /* to not mess up cache alignment, always add to the bottom */
342 boolean_t tso_force; 340 boolean_t tso_force;
343 boolean_t smart_power_down; /* phy smart power down */ 341 boolean_t smart_power_down; /* phy smart power down */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 637ae8f68791..9ec35b7a8207 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -158,9 +158,7 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
158static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 158static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
159static int e1000_set_mac(struct net_device *netdev, void *p); 159static int e1000_set_mac(struct net_device *netdev, void *p);
160static irqreturn_t e1000_intr(int irq, void *data); 160static irqreturn_t e1000_intr(int irq, void *data);
161#ifdef CONFIG_PCI_MSI
162static irqreturn_t e1000_intr_msi(int irq, void *data); 161static irqreturn_t e1000_intr_msi(int irq, void *data);
163#endif
164static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter, 162static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
165 struct e1000_tx_ring *tx_ring); 163 struct e1000_tx_ring *tx_ring);
166#ifdef CONFIG_E1000_NAPI 164#ifdef CONFIG_E1000_NAPI
@@ -300,31 +298,26 @@ module_exit(e1000_exit_module);
300static int e1000_request_irq(struct e1000_adapter *adapter) 298static int e1000_request_irq(struct e1000_adapter *adapter)
301{ 299{
302 struct net_device *netdev = adapter->netdev; 300 struct net_device *netdev = adapter->netdev;
303 int flags, err = 0; 301 void (*handler) = &e1000_intr;
302 int irq_flags = IRQF_SHARED;
303 int err;
304 304
305 flags = IRQF_SHARED;
306#ifdef CONFIG_PCI_MSI
307 if (adapter->hw.mac_type >= e1000_82571) { 305 if (adapter->hw.mac_type >= e1000_82571) {
308 adapter->have_msi = TRUE; 306 adapter->have_msi = !pci_enable_msi(adapter->pdev);
309 if ((err = pci_enable_msi(adapter->pdev))) { 307 if (adapter->have_msi) {
310 DPRINTK(PROBE, ERR, 308 handler = &e1000_intr_msi;
311 "Unable to allocate MSI interrupt Error: %d\n", err); 309 irq_flags = 0;
312 adapter->have_msi = FALSE;
313 } 310 }
314 } 311 }
315 if (adapter->have_msi) { 312
316 flags &= ~IRQF_SHARED; 313 err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
317 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags, 314 netdev);
318 netdev->name, netdev); 315 if (err) {
319 if (err) 316 if (adapter->have_msi)
320 DPRINTK(PROBE, ERR, 317 pci_disable_msi(adapter->pdev);
321 "Unable to allocate interrupt Error: %d\n", err);
322 } else
323#endif
324 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
325 netdev->name, netdev)))
326 DPRINTK(PROBE, ERR, 318 DPRINTK(PROBE, ERR,
327 "Unable to allocate interrupt Error: %d\n", err); 319 "Unable to allocate interrupt Error: %d\n", err);
320 }
328 321
329 return err; 322 return err;
330} 323}
@@ -335,10 +328,8 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
335 328
336 free_irq(adapter->pdev->irq, netdev); 329 free_irq(adapter->pdev->irq, netdev);
337 330
338#ifdef CONFIG_PCI_MSI
339 if (adapter->have_msi) 331 if (adapter->have_msi)
340 pci_disable_msi(adapter->pdev); 332 pci_disable_msi(adapter->pdev);
341#endif
342} 333}
343 334
344/** 335/**
@@ -1334,7 +1325,10 @@ e1000_sw_init(struct e1000_adapter *adapter)
1334 spin_lock_init(&adapter->tx_queue_lock); 1325 spin_lock_init(&adapter->tx_queue_lock);
1335#endif 1326#endif
1336 1327
1337 atomic_set(&adapter->irq_sem, 1); 1328 /* Explicitly disable IRQ since the NIC can be in any state. */
1329 atomic_set(&adapter->irq_sem, 0);
1330 e1000_irq_disable(adapter);
1331
1338 spin_lock_init(&adapter->stats_lock); 1332 spin_lock_init(&adapter->stats_lock);
1339 1333
1340 set_bit(__E1000_DOWN, &adapter->flags); 1334 set_bit(__E1000_DOWN, &adapter->flags);
@@ -3744,7 +3738,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
3744 3738
3745 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3739 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3746} 3740}
3747#ifdef CONFIG_PCI_MSI
3748 3741
3749/** 3742/**
3750 * e1000_intr_msi - Interrupt Handler 3743 * e1000_intr_msi - Interrupt Handler
@@ -3810,7 +3803,6 @@ e1000_intr_msi(int irq, void *data)
3810 3803
3811 return IRQ_HANDLED; 3804 return IRQ_HANDLED;
3812} 3805}
3813#endif
3814 3806
3815/** 3807/**
3816 * e1000_intr - Interrupt Handler 3808 * e1000_intr - Interrupt Handler
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 602872dbe15f..e85a933a4762 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0058" 42#define DRV_VERSION "EHEA_0061"
43 43
44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f6e0cb1ada1f..152bb2016a2c 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -428,7 +428,7 @@ static struct ehea_cqe *ehea_proc_rwqes(struct net_device *dev,
428 } 428 }
429 skb_copy_to_linear_data(skb, ((char*)cqe) + 64, 429 skb_copy_to_linear_data(skb, ((char*)cqe) + 64,
430 cqe->num_bytes_transfered - 4); 430 cqe->num_bytes_transfered - 4);
431 ehea_fill_skb(dev, skb, cqe); 431 ehea_fill_skb(port->netdev, skb, cqe);
432 } else if (rq == 2) { /* RQ2 */ 432 } else if (rq == 2) { /* RQ2 */
433 skb = get_skb_by_index(skb_arr_rq2, 433 skb = get_skb_by_index(skb_arr_rq2,
434 skb_arr_rq2_len, cqe); 434 skb_arr_rq2_len, cqe);
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 7a018027fcc0..4154fd000746 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -195,7 +195,7 @@ enum {
195#define NVREG_IRQ_TX_FORCED 0x0100 195#define NVREG_IRQ_TX_FORCED 0x0100
196#define NVREG_IRQ_RECOVER_ERROR 0x8000 196#define NVREG_IRQ_RECOVER_ERROR 0x8000
197#define NVREG_IRQMASK_THROUGHPUT 0x00df 197#define NVREG_IRQMASK_THROUGHPUT 0x00df
198#define NVREG_IRQMASK_CPU 0x0040 198#define NVREG_IRQMASK_CPU 0x0060
199#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED) 199#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED)
200#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED) 200#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED)
201#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RECOVER_ERROR) 201#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RECOVER_ERROR)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b666a0cc0642..f5b3cba23fc5 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1025,6 +1025,15 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1025 1025
1026 dev->trans_start = jiffies; 1026 dev->trans_start = jiffies;
1027 1027
1028 /* The powerpc-specific eieio() is used, as wmb() has too strong
1029 * semantics (it requires synchronization between cacheable and
1030 * uncacheable mappings, which eieio doesn't provide and which we
1031 * don't need), thus requiring a more expensive sync instruction. At
1032 * some point, the set of architecture-independent barrier functions
1033 * should be expanded to include weaker barriers.
1034 */
1035
1036 eieio();
1028 txbdp->status = status; 1037 txbdp->status = status;
1029 1038
1030 /* If this was the last BD in the ring, the next one */ 1039 /* If this was the last BD in the ring, the next one */
@@ -1301,6 +1310,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1301 bdp->length = 0; 1310 bdp->length = 0;
1302 1311
1303 /* Mark the buffer empty */ 1312 /* Mark the buffer empty */
1313 eieio();
1304 bdp->status |= (RXBD_EMPTY | RXBD_INTERRUPT); 1314 bdp->status |= (RXBD_EMPTY | RXBD_INTERRUPT);
1305 1315
1306 return skb; 1316 return skb;
@@ -1484,6 +1494,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
1484 bdp = priv->cur_rx; 1494 bdp = priv->cur_rx;
1485 1495
1486 while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) { 1496 while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {
1497 rmb();
1487 skb = priv->rx_skbuff[priv->skb_currx]; 1498 skb = priv->rx_skbuff[priv->skb_currx];
1488 1499
1489 if (!(bdp->status & 1500 if (!(bdp->status &
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 50035ebd4f52..f752e5fc65ba 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -926,7 +926,7 @@ static int emac_link_differs(struct ocp_enet_private *dev)
926 int duplex = r & EMAC_MR1_FDE ? DUPLEX_FULL : DUPLEX_HALF; 926 int duplex = r & EMAC_MR1_FDE ? DUPLEX_FULL : DUPLEX_HALF;
927 int speed, pause, asym_pause; 927 int speed, pause, asym_pause;
928 928
929 if (r & (EMAC_MR1_MF_1000 | EMAC_MR1_MF_1000GPCS)) 929 if (r & EMAC_MR1_MF_1000)
930 speed = SPEED_1000; 930 speed = SPEED_1000;
931 else if (r & EMAC_MR1_MF_100) 931 else if (r & EMAC_MR1_MF_100)
932 speed = SPEED_100; 932 speed = SPEED_100;
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c b/drivers/net/ibm_emac/ibm_emac_mal.c
index 6c0f071e4052..cabd9846a5ee 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.c
+++ b/drivers/net/ibm_emac/ibm_emac_mal.c
@@ -59,8 +59,7 @@ int __init mal_register_commac(struct ibm_ocp_mal *mal,
59 return 0; 59 return 0;
60} 60}
61 61
62void __exit mal_unregister_commac(struct ibm_ocp_mal *mal, 62void mal_unregister_commac(struct ibm_ocp_mal *mal, struct mal_commac *commac)
63 struct mal_commac *commac)
64{ 63{
65 unsigned long flags; 64 unsigned long flags;
66 local_irq_save(flags); 65 local_irq_save(flags);
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index 407d2acbf7c7..64bc338acc6c 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -223,8 +223,7 @@ void mal_exit(void) __exit;
223 223
224int mal_register_commac(struct ibm_ocp_mal *mal, 224int mal_register_commac(struct ibm_ocp_mal *mal,
225 struct mal_commac *commac) __init; 225 struct mal_commac *commac) __init;
226void mal_unregister_commac(struct ibm_ocp_mal *mal, 226void mal_unregister_commac(struct ibm_ocp_mal *mal, struct mal_commac *commac);
227 struct mal_commac *commac) __exit;
228int mal_set_rcbs(struct ibm_ocp_mal *mal, int channel, unsigned long size); 227int mal_set_rcbs(struct ibm_ocp_mal *mal, int channel, unsigned long size);
229 228
230/* Returns BD ring offset for a particular channel 229/* Returns BD ring offset for a particular channel
diff --git a/drivers/net/ibm_emac/ibm_emac_phy.c b/drivers/net/ibm_emac/ibm_emac_phy.c
index 9074f76ee2bf..e57862b34cae 100644
--- a/drivers/net/ibm_emac/ibm_emac_phy.c
+++ b/drivers/net/ibm_emac/ibm_emac_phy.c
@@ -22,6 +22,7 @@
22 22
23#include <asm/ocp.h> 23#include <asm/ocp.h>
24 24
25#include "ibm_emac_core.h"
25#include "ibm_emac_phy.h" 26#include "ibm_emac_phy.h"
26 27
27static inline int phy_read(struct mii_phy *phy, int reg) 28static inline int phy_read(struct mii_phy *phy, int reg)
@@ -34,11 +35,39 @@ static inline void phy_write(struct mii_phy *phy, int reg, int val)
34 phy->mdio_write(phy->dev, phy->address, reg, val); 35 phy->mdio_write(phy->dev, phy->address, reg, val);
35} 36}
36 37
37int mii_reset_phy(struct mii_phy *phy) 38/*
39 * polls MII_BMCR until BMCR_RESET bit clears or operation times out.
40 *
41 * returns:
42 * >= 0 => success, value in BMCR returned to caller
43 * -EBUSY => failure, RESET bit never cleared
44 * otherwise => failure, lower level PHY read failed
45 */
46static int mii_spin_reset_complete(struct mii_phy *phy)
38{ 47{
39 int val; 48 int val;
40 int limit = 10000; 49 int limit = 10000;
41 50
51 while (limit--) {
52 val = phy_read(phy, MII_BMCR);
53 if (val >= 0 && !(val & BMCR_RESET))
54 return val; /* success */
55 udelay(10);
56 }
57 if (val & BMCR_RESET)
58 val = -EBUSY;
59
60 if (net_ratelimit())
61 printk(KERN_ERR "emac%d: PHY reset timeout (%d)\n",
62 ((struct ocp_enet_private *)phy->dev->priv)->def->index,
63 val);
64 return val;
65}
66
67int mii_reset_phy(struct mii_phy *phy)
68{
69 int val;
70
42 val = phy_read(phy, MII_BMCR); 71 val = phy_read(phy, MII_BMCR);
43 val &= ~BMCR_ISOLATE; 72 val &= ~BMCR_ISOLATE;
44 val |= BMCR_RESET; 73 val |= BMCR_RESET;
@@ -46,16 +75,11 @@ int mii_reset_phy(struct mii_phy *phy)
46 75
47 udelay(300); 76 udelay(300);
48 77
49 while (limit--) { 78 val = mii_spin_reset_complete(phy);
50 val = phy_read(phy, MII_BMCR); 79 if (val >= 0 && (val & BMCR_ISOLATE))
51 if (val >= 0 && (val & BMCR_RESET) == 0)
52 break;
53 udelay(10);
54 }
55 if ((val & BMCR_ISOLATE) && limit > 0)
56 phy_write(phy, MII_BMCR, val & ~BMCR_ISOLATE); 80 phy_write(phy, MII_BMCR, val & ~BMCR_ISOLATE);
57 81
58 return limit <= 0; 82 return val < 0;
59} 83}
60 84
61static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise) 85static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
@@ -102,8 +126,14 @@ static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
102 } 126 }
103 127
104 /* Start/Restart aneg */ 128 /* Start/Restart aneg */
105 ctl = phy_read(phy, MII_BMCR); 129 /* on some PHYs (e.g. National DP83843) a write to MII_ADVERTISE
106 ctl |= (BMCR_ANENABLE | BMCR_ANRESTART); 130 * causes BMCR_RESET to be set on the next read of MII_BMCR, which
131 * if not checked for causes the PHY to be reset below */
132 ctl = mii_spin_reset_complete(phy);
133 if (ctl < 0)
134 return ctl;
135
136 ctl |= BMCR_ANENABLE | BMCR_ANRESTART;
107 phy_write(phy, MII_BMCR, ctl); 137 phy_write(phy, MII_BMCR, ctl);
108 138
109 return 0; 139 return 0;
@@ -118,13 +148,13 @@ static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
118 phy->duplex = fd; 148 phy->duplex = fd;
119 phy->pause = phy->asym_pause = 0; 149 phy->pause = phy->asym_pause = 0;
120 150
151 /* First reset the PHY */
152 mii_reset_phy(phy);
153
121 ctl = phy_read(phy, MII_BMCR); 154 ctl = phy_read(phy, MII_BMCR);
122 if (ctl < 0) 155 if (ctl < 0)
123 return ctl; 156 return ctl;
124 ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_ANENABLE); 157 ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_ANENABLE | BMCR_SPEED1000);
125
126 /* First reset the PHY */
127 phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
128 158
129 /* Select speed & duplex */ 159 /* Select speed & duplex */
130 switch (speed) { 160 switch (speed) {
diff --git a/drivers/net/ibm_emac/ibm_emac_rgmii.c b/drivers/net/ibm_emac/ibm_emac_rgmii.c
index 53d281cb9a16..9dbb5e5936c3 100644
--- a/drivers/net/ibm_emac/ibm_emac_rgmii.c
+++ b/drivers/net/ibm_emac/ibm_emac_rgmii.c
@@ -162,7 +162,7 @@ void rgmii_set_speed(struct ocp_device *ocpdev, int input, int speed)
162 out_be32(&dev->base->ssr, ssr); 162 out_be32(&dev->base->ssr, ssr);
163} 163}
164 164
165void __exit __rgmii_fini(struct ocp_device *ocpdev, int input) 165void __rgmii_fini(struct ocp_device *ocpdev, int input)
166{ 166{
167 struct ibm_ocp_rgmii *dev = ocp_get_drvdata(ocpdev); 167 struct ibm_ocp_rgmii *dev = ocp_get_drvdata(ocpdev);
168 BUG_ON(!dev || dev->users == 0); 168 BUG_ON(!dev || dev->users == 0);
diff --git a/drivers/net/ibm_emac/ibm_emac_rgmii.h b/drivers/net/ibm_emac/ibm_emac_rgmii.h
index 117ea486c2ca..971e45815c6c 100644
--- a/drivers/net/ibm_emac/ibm_emac_rgmii.h
+++ b/drivers/net/ibm_emac/ibm_emac_rgmii.h
@@ -37,7 +37,7 @@ struct ibm_ocp_rgmii {
37#ifdef CONFIG_IBM_EMAC_RGMII 37#ifdef CONFIG_IBM_EMAC_RGMII
38int rgmii_attach(void *emac) __init; 38int rgmii_attach(void *emac) __init;
39 39
40void __rgmii_fini(struct ocp_device *ocpdev, int input) __exit; 40void __rgmii_fini(struct ocp_device *ocpdev, int input);
41static inline void rgmii_fini(struct ocp_device *ocpdev, int input) 41static inline void rgmii_fini(struct ocp_device *ocpdev, int input)
42{ 42{
43 if (ocpdev) 43 if (ocpdev)
diff --git a/drivers/net/ibm_emac/ibm_emac_tah.c b/drivers/net/ibm_emac/ibm_emac_tah.c
index e287b451bb44..3c2d5ba522a1 100644
--- a/drivers/net/ibm_emac/ibm_emac_tah.c
+++ b/drivers/net/ibm_emac/ibm_emac_tah.c
@@ -63,7 +63,7 @@ int __init tah_attach(void *emac)
63 return 0; 63 return 0;
64} 64}
65 65
66void __exit __tah_fini(struct ocp_device *ocpdev) 66void __tah_fini(struct ocp_device *ocpdev)
67{ 67{
68 struct tah_regs *p = ocp_get_drvdata(ocpdev); 68 struct tah_regs *p = ocp_get_drvdata(ocpdev);
69 BUG_ON(!p); 69 BUG_ON(!p);
diff --git a/drivers/net/ibm_emac/ibm_emac_tah.h b/drivers/net/ibm_emac/ibm_emac_tah.h
index 38153945a240..ccf64915e1e4 100644
--- a/drivers/net/ibm_emac/ibm_emac_tah.h
+++ b/drivers/net/ibm_emac/ibm_emac_tah.h
@@ -55,7 +55,7 @@ struct tah_regs {
55#ifdef CONFIG_IBM_EMAC_TAH 55#ifdef CONFIG_IBM_EMAC_TAH
56int tah_attach(void *emac) __init; 56int tah_attach(void *emac) __init;
57 57
58void __tah_fini(struct ocp_device *ocpdev) __exit; 58void __tah_fini(struct ocp_device *ocpdev);
59static inline void tah_fini(struct ocp_device *ocpdev) 59static inline void tah_fini(struct ocp_device *ocpdev)
60{ 60{
61 if (ocpdev) 61 if (ocpdev)
diff --git a/drivers/net/ibm_emac/ibm_emac_zmii.c b/drivers/net/ibm_emac/ibm_emac_zmii.c
index 37dc8f342868..2c0fdb0cabff 100644
--- a/drivers/net/ibm_emac/ibm_emac_zmii.c
+++ b/drivers/net/ibm_emac/ibm_emac_zmii.c
@@ -215,7 +215,7 @@ void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed)
215 out_be32(&dev->base->ssr, ssr); 215 out_be32(&dev->base->ssr, ssr);
216} 216}
217 217
218void __exit __zmii_fini(struct ocp_device *ocpdev, int input) 218void __zmii_fini(struct ocp_device *ocpdev, int input)
219{ 219{
220 struct ibm_ocp_zmii *dev = ocp_get_drvdata(ocpdev); 220 struct ibm_ocp_zmii *dev = ocp_get_drvdata(ocpdev);
221 BUG_ON(!dev || dev->users == 0); 221 BUG_ON(!dev || dev->users == 0);
diff --git a/drivers/net/ibm_emac/ibm_emac_zmii.h b/drivers/net/ibm_emac/ibm_emac_zmii.h
index 972e3a44a09f..fad6d8bf983a 100644
--- a/drivers/net/ibm_emac/ibm_emac_zmii.h
+++ b/drivers/net/ibm_emac/ibm_emac_zmii.h
@@ -40,7 +40,7 @@ struct ibm_ocp_zmii {
40#ifdef CONFIG_IBM_EMAC_ZMII 40#ifdef CONFIG_IBM_EMAC_ZMII
41int zmii_attach(void *emac) __init; 41int zmii_attach(void *emac) __init;
42 42
43void __zmii_fini(struct ocp_device *ocpdev, int input) __exit; 43void __zmii_fini(struct ocp_device *ocpdev, int input);
44static inline void zmii_fini(struct ocp_device *ocpdev, int input) 44static inline void zmii_fini(struct ocp_device *ocpdev, int input)
45{ 45{
46 if (ocpdev) 46 if (ocpdev)
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index c8e90861f869..3569d5b03388 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -193,8 +193,6 @@ struct ixgb_adapter {
193 u16 msg_enable; 193 u16 msg_enable;
194 struct ixgb_hw_stats stats; 194 struct ixgb_hw_stats stats;
195 uint32_t alloc_rx_buff_failed; 195 uint32_t alloc_rx_buff_failed;
196#ifdef CONFIG_PCI_MSI
197 boolean_t have_msi; 196 boolean_t have_msi;
198#endif
199}; 197};
200#endif /* _IXGB_H_ */ 198#endif /* _IXGB_H_ */
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 6d2b059371f1..991c8833e23c 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -227,7 +227,7 @@ int
227ixgb_up(struct ixgb_adapter *adapter) 227ixgb_up(struct ixgb_adapter *adapter)
228{ 228{
229 struct net_device *netdev = adapter->netdev; 229 struct net_device *netdev = adapter->netdev;
230 int err; 230 int err, irq_flags = IRQF_SHARED;
231 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH; 231 int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
232 struct ixgb_hw *hw = &adapter->hw; 232 struct ixgb_hw *hw = &adapter->hw;
233 233
@@ -246,26 +246,21 @@ ixgb_up(struct ixgb_adapter *adapter)
246 /* disable interrupts and get the hardware into a known state */ 246 /* disable interrupts and get the hardware into a known state */
247 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff); 247 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
248 248
249#ifdef CONFIG_PCI_MSI 249 /* only enable MSI if bus is in PCI-X mode */
250 { 250 if (IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_PCIX_MODE) {
251 boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) & 251 err = pci_enable_msi(adapter->pdev);
252 IXGB_STATUS_PCIX_MODE) ? TRUE : FALSE; 252 if (!err) {
253 adapter->have_msi = TRUE; 253 adapter->have_msi = 1;
254 254 irq_flags = 0;
255 if (!pcix) 255 }
256 adapter->have_msi = FALSE;
257 else if((err = pci_enable_msi(adapter->pdev))) {
258 DPRINTK(PROBE, ERR,
259 "Unable to allocate MSI interrupt Error: %d\n", err);
260 adapter->have_msi = FALSE;
261 /* proceed to try to request regular interrupt */ 256 /* proceed to try to request regular interrupt */
262 } 257 }
263 }
264 258
265#endif 259 err = request_irq(adapter->pdev->irq, &ixgb_intr, irq_flags,
266 if((err = request_irq(adapter->pdev->irq, &ixgb_intr, 260 netdev->name, netdev);
267 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 261 if (err) {
268 netdev->name, netdev))) { 262 if (adapter->have_msi)
263 pci_disable_msi(adapter->pdev);
269 DPRINTK(PROBE, ERR, 264 DPRINTK(PROBE, ERR,
270 "Unable to allocate interrupt Error: %d\n", err); 265 "Unable to allocate interrupt Error: %d\n", err);
271 return err; 266 return err;
@@ -307,11 +302,10 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
307 302
308 ixgb_irq_disable(adapter); 303 ixgb_irq_disable(adapter);
309 free_irq(adapter->pdev->irq, netdev); 304 free_irq(adapter->pdev->irq, netdev);
310#ifdef CONFIG_PCI_MSI 305
311 if(adapter->have_msi == TRUE) 306 if (adapter->have_msi)
312 pci_disable_msi(adapter->pdev); 307 pci_disable_msi(adapter->pdev);
313 308
314#endif
315 if(kill_watchdog) 309 if(kill_watchdog)
316 del_timer_sync(&adapter->watchdog_timer); 310 del_timer_sync(&adapter->watchdog_timer);
317#ifdef CONFIG_IXGB_NAPI 311#ifdef CONFIG_IXGB_NAPI
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 0343ea12b299..92b403bf38b0 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -8,15 +8,16 @@
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11#include <linux/module.h>
12#include <linux/init.h>
13
14#include <linux/kernel.h> /* printk() */
15#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/dma-mapping.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/errno.h> /* error codes */ 18#include <linux/errno.h>
18#include <linux/types.h> /* size_t */ 19#include <linux/types.h>
19#include <linux/interrupt.h> /* mark_bh */ 20#include <linux/interrupt.h>
20 21
21#include <linux/in.h> 22#include <linux/in.h>
22#include <linux/in6.h> 23#include <linux/in6.h>
@@ -33,7 +34,6 @@
33 34
34#include <asm/io.h> 35#include <asm/io.h>
35#include <asm/scatterlist.h> 36#include <asm/scatterlist.h>
36#include <linux/dma-mapping.h>
37 37
38#include "meth.h" 38#include "meth.h"
39 39
@@ -51,8 +51,6 @@
51 51
52 52
53static const char *meth_str="SGI O2 Fast Ethernet"; 53static const char *meth_str="SGI O2 Fast Ethernet";
54MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>");
55MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
56 54
57#define HAVE_TX_TIMEOUT 55#define HAVE_TX_TIMEOUT
58/* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */ 56/* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */
@@ -784,15 +782,15 @@ static struct net_device_stats *meth_stats(struct net_device *dev)
784/* 782/*
785 * The init function. 783 * The init function.
786 */ 784 */
787static struct net_device *meth_init(void) 785static int __init meth_probe(struct platform_device *pdev)
788{ 786{
789 struct net_device *dev; 787 struct net_device *dev;
790 struct meth_private *priv; 788 struct meth_private *priv;
791 int ret; 789 int err;
792 790
793 dev = alloc_etherdev(sizeof(struct meth_private)); 791 dev = alloc_etherdev(sizeof(struct meth_private));
794 if (!dev) 792 if (!dev)
795 return ERR_PTR(-ENOMEM); 793 return -ENOMEM;
796 794
797 dev->open = meth_open; 795 dev->open = meth_open;
798 dev->stop = meth_release; 796 dev->stop = meth_release;
@@ -808,11 +806,12 @@ static struct net_device *meth_init(void)
808 806
809 priv = netdev_priv(dev); 807 priv = netdev_priv(dev);
810 spin_lock_init(&priv->meth_lock); 808 spin_lock_init(&priv->meth_lock);
809 SET_NETDEV_DEV(dev, &pdev->dev);
811 810
812 ret = register_netdev(dev); 811 err = register_netdev(dev);
813 if (ret) { 812 if (err) {
814 free_netdev(dev); 813 free_netdev(dev);
815 return ERR_PTR(ret); 814 return err;
816 } 815 }
817 816
818 printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n", 817 printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n",
@@ -820,21 +819,44 @@ static struct net_device *meth_init(void)
820 return 0; 819 return 0;
821} 820}
822 821
823static struct net_device *meth_dev; 822static int __exit meth_remove(struct platform_device *pdev)
823{
824 struct net_device *dev = platform_get_drvdata(pdev);
825
826 unregister_netdev(dev);
827 free_netdev(dev);
828 platform_set_drvdata(pdev, NULL);
829
830 return 0;
831}
832
833static struct platform_driver meth_driver = {
834 .probe = meth_probe,
835 .remove = __devexit_p(meth_remove),
836 .driver = {
837 .name = "meth",
838 }
839};
824 840
825static int __init meth_init_module(void) 841static int __init meth_init_module(void)
826{ 842{
827 meth_dev = meth_init(); 843 int err;
828 if (IS_ERR(meth_dev)) 844
829 return PTR_ERR(meth_dev); 845 err = platform_driver_register(&meth_driver);
830 return 0; 846 if (err)
847 printk(KERN_ERR "Driver registration failed\n");
848
849 return err;
831} 850}
832 851
833static void __exit meth_exit_module(void) 852static void __exit meth_exit_module(void)
834{ 853{
835 unregister_netdev(meth_dev); 854 platform_driver_unregister(&meth_driver);
836 free_netdev(meth_dev);
837} 855}
838 856
839module_init(meth_init_module); 857module_init(meth_init_module);
840module_exit(meth_exit_module); 858module_exit(meth_exit_module);
859
860MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>");
861MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
862MODULE_LICENSE("GPL");
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c
index dfbd5809d744..f8d63d39f592 100644
--- a/drivers/net/mlx4/alloc.c
+++ b/drivers/net/mlx4/alloc.c
@@ -51,8 +51,8 @@ u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap)
51 51
52 if (obj < bitmap->max) { 52 if (obj < bitmap->max) {
53 set_bit(obj, bitmap->table); 53 set_bit(obj, bitmap->table);
54 bitmap->last = (obj + 1) & (bitmap->max - 1);
54 obj |= bitmap->top; 55 obj |= bitmap->top;
55 bitmap->last = obj + 1;
56 } else 56 } else
57 obj = -1; 57 obj = -1;
58 58
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index c42717313663..cfa5cc072339 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -90,7 +90,7 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u32 flags)
90 int i; 90 int i;
91 91
92 mlx4_dbg(dev, "DEV_CAP flags:\n"); 92 mlx4_dbg(dev, "DEV_CAP flags:\n");
93 for (i = 0; i < 32; ++i) 93 for (i = 0; i < ARRAY_SIZE(fname); ++i)
94 if (fname[i] && (flags & (1 << i))) 94 if (fname[i] && (flags & (1 << i)))
95 mlx4_dbg(dev, " %s\n", fname[i]); 95 mlx4_dbg(dev, " %s\n", fname[i]);
96} 96}
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index cf0e96adfe44..a36892457761 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -1216,7 +1216,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1216 /* Window = 1 */ 1216 /* Window = 1 */
1217 writel(consumer, 1217 writel(consumer,
1218 NETXEN_CRB_NORMALIZE(adapter, 1218 NETXEN_CRB_NORMALIZE(adapter,
1219 recv_crb_registers[ctxid]. 1219 recv_crb_registers[adapter->portnum].
1220 crb_rcv_status_consumer)); 1220 crb_rcv_status_consumer));
1221 } 1221 }
1222 1222
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 68c99b4c5255..bb966911a137 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -89,6 +89,7 @@ EXPORT_SYMBOL(fixed_mdio_set_link_update);
89/*----------------------------------------------------------------------------- 89/*-----------------------------------------------------------------------------
90 * This is used for updating internal mii regs from the status 90 * This is used for updating internal mii regs from the status
91 *-----------------------------------------------------------------------------*/ 91 *-----------------------------------------------------------------------------*/
92#if defined(CONFIG_FIXED_MII_100_FDX) || defined(CONFIG_FIXED_MII_10_FDX)
92static int fixed_mdio_update_regs(struct fixed_info *fixed) 93static int fixed_mdio_update_regs(struct fixed_info *fixed)
93{ 94{
94 u16 *regs = fixed->regs; 95 u16 *regs = fixed->regs;
@@ -165,6 +166,7 @@ static int fixed_mii_reset(struct mii_bus *bus)
165 /*nothing here - no way/need to reset it*/ 166 /*nothing here - no way/need to reset it*/
166 return 0; 167 return 0;
167} 168}
169#endif
168 170
169static int fixed_config_aneg(struct phy_device *phydev) 171static int fixed_config_aneg(struct phy_device *phydev)
170{ 172{
@@ -194,6 +196,7 @@ static struct phy_driver fixed_mdio_driver = {
194 * number is used to create multiple fixed PHYs, so that several devices can 196 * number is used to create multiple fixed PHYs, so that several devices can
195 * utilize them simultaneously. 197 * utilize them simultaneously.
196 *-----------------------------------------------------------------------------*/ 198 *-----------------------------------------------------------------------------*/
199#if defined(CONFIG_FIXED_MII_100_FDX) || defined(CONFIG_FIXED_MII_10_FDX)
197static int fixed_mdio_register_device(int number, int speed, int duplex) 200static int fixed_mdio_register_device(int number, int speed, int duplex)
198{ 201{
199 struct mii_bus *new_bus; 202 struct mii_bus *new_bus;
@@ -301,6 +304,7 @@ device_create_fail:
301 304
302 return err; 305 return err;
303} 306}
307#endif
304 308
305 309
306MODULE_DESCRIPTION("Fixed PHY device & driver for PAL"); 310MODULE_DESCRIPTION("Fixed PHY device & driver for PAL");
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 104e20456e6f..adfbe81693a6 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -40,7 +40,6 @@
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/prefetch.h> 41#include <linux/prefetch.h>
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/dmi.h>
44 43
45#include <asm/irq.h> 44#include <asm/irq.h>
46 45
@@ -151,8 +150,6 @@ static const char *yukon2_name[] = {
151 "FE", /* 0xb7 */ 150 "FE", /* 0xb7 */
152}; 151};
153 152
154static int dmi_blacklisted;
155
156/* Access to external PHY */ 153/* Access to external PHY */
157static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) 154static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
158{ 155{
@@ -307,10 +304,13 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
307 PHY_M_EC_MAC_S_MSK); 304 PHY_M_EC_MAC_S_MSK);
308 ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ); 305 ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ);
309 306
307 /* on PHY 88E1040 Rev.D0 (and newer) downshift control changed */
310 if (hw->chip_id == CHIP_ID_YUKON_EC) 308 if (hw->chip_id == CHIP_ID_YUKON_EC)
309 /* set downshift counter to 3x and enable downshift */
311 ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA; 310 ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA;
312 else 311 else
313 ectrl |= PHY_M_EC_M_DSC(2) | PHY_M_EC_S_DSC(3); 312 /* set master & slave downshift counter to 1x */
313 ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
314 314
315 gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl); 315 gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl);
316 } 316 }
@@ -327,10 +327,12 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
327 /* enable automatic crossover */ 327 /* enable automatic crossover */
328 ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); 328 ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO);
329 329
330 /* downshift on PHY 88E1112 and 88E1149 is changed */
330 if (sky2->autoneg == AUTONEG_ENABLE 331 if (sky2->autoneg == AUTONEG_ENABLE
331 && (hw->chip_id == CHIP_ID_YUKON_XL 332 && (hw->chip_id == CHIP_ID_YUKON_XL
332 || hw->chip_id == CHIP_ID_YUKON_EC_U 333 || hw->chip_id == CHIP_ID_YUKON_EC_U
333 || hw->chip_id == CHIP_ID_YUKON_EX)) { 334 || hw->chip_id == CHIP_ID_YUKON_EX)) {
335 /* set downshift counter to 3x and enable downshift */
334 ctrl &= ~PHY_M_PC_DSC_MSK; 336 ctrl &= ~PHY_M_PC_DSC_MSK;
335 ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; 337 ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA;
336 } 338 }
@@ -362,7 +364,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
362 /* for SFP-module set SIGDET polarity to low */ 364 /* for SFP-module set SIGDET polarity to low */
363 ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); 365 ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
364 ctrl |= PHY_M_FIB_SIGD_POL; 366 ctrl |= PHY_M_FIB_SIGD_POL;
365 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl); 367 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl);
366 } 368 }
367 369
368 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 370 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
@@ -656,7 +658,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
656 const u8 *addr = hw->dev[port]->dev_addr; 658 const u8 *addr = hw->dev[port]->dev_addr;
657 659
658 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); 660 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
659 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR|GPC_ENA_PAUSE); 661 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR);
660 662
661 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); 663 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
662 664
@@ -842,10 +844,12 @@ static inline struct tx_ring_info *tx_le_re(struct sky2_port *sky2,
842/* Update chip's next pointer */ 844/* Update chip's next pointer */
843static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx) 845static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
844{ 846{
845 q = Y2_QADDR(q, PREF_UNIT_PUT_IDX); 847 /* Make sure write' to descriptors are complete before we tell hardware */
846 wmb(); 848 wmb();
847 sky2_write16(hw, q, idx); 849 sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx);
848 sky2_read16(hw, q); 850
851 /* Synchronize I/O on since next processor may write to tail */
852 mmiowb();
849} 853}
850 854
851 855
@@ -977,6 +981,7 @@ stopped:
977 981
978 /* reset the Rx prefetch unit */ 982 /* reset the Rx prefetch unit */
979 sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); 983 sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
984 mmiowb();
980} 985}
981 986
982/* Clean out receive buffer area, assumes receiver hardware stopped */ 987/* Clean out receive buffer area, assumes receiver hardware stopped */
@@ -1196,7 +1201,7 @@ static int sky2_rx_start(struct sky2_port *sky2)
1196 } 1201 }
1197 1202
1198 /* Tell chip about available buffers */ 1203 /* Tell chip about available buffers */
1199 sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put); 1204 sky2_put_idx(hw, rxq, sky2->rx_put);
1200 return 0; 1205 return 0;
1201nomem: 1206nomem:
1202 sky2_rx_clean(sky2); 1207 sky2_rx_clean(sky2);
@@ -1427,7 +1432,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1427 tcpsum = offset << 16; /* sum start */ 1432 tcpsum = offset << 16; /* sum start */
1428 tcpsum |= offset + skb->csum_offset; /* sum write */ 1433 tcpsum |= offset + skb->csum_offset; /* sum write */
1429 1434
1430 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM; 1435 ctrl |= CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1431 if (ip_hdr(skb)->protocol == IPPROTO_UDP) 1436 if (ip_hdr(skb)->protocol == IPPROTO_UDP)
1432 ctrl |= UDPTCP; 1437 ctrl |= UDPTCP;
1433 1438
@@ -1538,6 +1543,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1538 } 1543 }
1539 1544
1540 sky2->tx_cons = idx; 1545 sky2->tx_cons = idx;
1546 smp_mb();
1547
1541 if (tx_avail(sky2) > MAX_SKB_TX_LE + 4) 1548 if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
1542 netif_wake_queue(dev); 1549 netif_wake_queue(dev);
1543} 1550}
@@ -1577,13 +1584,6 @@ static int sky2_down(struct net_device *dev)
1577 imask &= ~portirq_msk[port]; 1584 imask &= ~portirq_msk[port];
1578 sky2_write32(hw, B0_IMSK, imask); 1585 sky2_write32(hw, B0_IMSK, imask);
1579 1586
1580 /*
1581 * Both ports share the NAPI poll on port 0, so if necessary undo the
1582 * the disable that is done in dev_close.
1583 */
1584 if (sky2->port == 0 && hw->ports > 1)
1585 netif_poll_enable(dev);
1586
1587 sky2_gmac_reset(hw, port); 1587 sky2_gmac_reset(hw, port);
1588 1588
1589 /* Stop transmitter */ 1589 /* Stop transmitter */
@@ -2139,8 +2139,10 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
2139 switch (le->opcode & ~HW_OWNER) { 2139 switch (le->opcode & ~HW_OWNER) {
2140 case OP_RXSTAT: 2140 case OP_RXSTAT:
2141 skb = sky2_receive(dev, length, status); 2141 skb = sky2_receive(dev, length, status);
2142 if (!skb) 2142 if (unlikely(!skb)) {
2143 sky2->net_stats.rx_dropped++;
2143 goto force_update; 2144 goto force_update;
2145 }
2144 2146
2145 skb->protocol = eth_type_trans(skb, dev); 2147 skb->protocol = eth_type_trans(skb, dev);
2146 sky2->net_stats.rx_packets++; 2148 sky2->net_stats.rx_packets++;
@@ -2221,6 +2223,7 @@ force_update:
2221 2223
2222 /* Fully processed status ring so clear irq */ 2224 /* Fully processed status ring so clear irq */
2223 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); 2225 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
2226 mmiowb();
2224 2227
2225exit_loop: 2228exit_loop:
2226 if (buf_write[0]) { 2229 if (buf_write[0]) {
@@ -2341,6 +2344,12 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
2341 printk(KERN_INFO PFX "%s: mac interrupt status 0x%x\n", 2344 printk(KERN_INFO PFX "%s: mac interrupt status 0x%x\n",
2342 dev->name, status); 2345 dev->name, status);
2343 2346
2347 if (status & GM_IS_RX_CO_OV)
2348 gma_read16(hw, port, GM_RX_IRQ_SRC);
2349
2350 if (status & GM_IS_TX_CO_OV)
2351 gma_read16(hw, port, GM_TX_IRQ_SRC);
2352
2344 if (status & GM_IS_RX_FF_OR) { 2353 if (status & GM_IS_RX_FF_OR) {
2345 ++sky2->net_stats.rx_fifo_errors; 2354 ++sky2->net_stats.rx_fifo_errors;
2346 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO); 2355 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
@@ -2439,6 +2448,7 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2439 if (work_done < work_limit) { 2448 if (work_done < work_limit) {
2440 netif_rx_complete(dev0); 2449 netif_rx_complete(dev0);
2441 2450
2451 /* end of interrupt, re-enables also acts as I/O synchronization */
2442 sky2_read32(hw, B0_Y2_SP_LISR); 2452 sky2_read32(hw, B0_Y2_SP_LISR);
2443 return 0; 2453 return 0;
2444 } else { 2454 } else {
@@ -2534,17 +2544,6 @@ static int __devinit sky2_init(struct sky2_hw *hw)
2534 return -EOPNOTSUPP; 2544 return -EOPNOTSUPP;
2535 } 2545 }
2536 2546
2537
2538 /* Some Gigabyte motherboards have 88e8056 but cause problems
2539 * There is some unresolved hardware related problem that causes
2540 * descriptor errors and receive data corruption.
2541 */
2542 if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) {
2543 dev_err(&hw->pdev->dev,
2544 "88E8056 on this motherboard not supported\n");
2545 return -EOPNOTSUPP;
2546 }
2547
2548 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); 2547 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
2549 hw->ports = 1; 2548 hw->ports = 1;
2550 t8 = sky2_read8(hw, B2_Y2_HW_RES); 2549 t8 = sky2_read8(hw, B2_Y2_HW_RES);
@@ -3910,24 +3909,8 @@ static struct pci_driver sky2_driver = {
3910 .shutdown = sky2_shutdown, 3909 .shutdown = sky2_shutdown,
3911}; 3910};
3912 3911
3913static struct dmi_system_id __initdata broken_dmi_table[] = {
3914 {
3915 .ident = "Gigabyte 965P-S3",
3916 .matches = {
3917 DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."),
3918 DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"),
3919
3920 },
3921 },
3922 { }
3923};
3924
3925static int __init sky2_init_module(void) 3912static int __init sky2_init_module(void)
3926{ 3913{
3927 /* Look for sick motherboards */
3928 if (dmi_check_system(broken_dmi_table))
3929 dmi_blacklisted = 1;
3930
3931 return pci_register_driver(&sky2_driver); 3914 return pci_register_driver(&sky2_driver);
3932} 3915}
3933 3916
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 5efb5afc45ba..b8c4a3b5eadf 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1149,7 +1149,7 @@ enum {
1149 PHY_M_IS_JABBER = 1<<0, /* Jabber */ 1149 PHY_M_IS_JABBER = 1<<0, /* Jabber */
1150 1150
1151 PHY_M_DEF_MSK = PHY_M_IS_LSP_CHANGE | PHY_M_IS_LST_CHANGE 1151 PHY_M_DEF_MSK = PHY_M_IS_LSP_CHANGE | PHY_M_IS_LST_CHANGE
1152 | PHY_M_IS_FIFO_ERROR, 1152 | PHY_M_IS_DUP_CHANGE,
1153 PHY_M_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL, 1153 PHY_M_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL,
1154}; 1154};
1155 1155
@@ -1732,28 +1732,6 @@ enum {
1732 1732
1733/* GPHY_CTRL 32 bit GPHY Control Reg (YUKON only) */ 1733/* GPHY_CTRL 32 bit GPHY Control Reg (YUKON only) */
1734enum { 1734enum {
1735 GPC_SEL_BDT = 1<<28, /* Select Bi-Dir. Transfer for MDC/MDIO */
1736 GPC_INT_POL_HI = 1<<27, /* IRQ Polarity is Active HIGH */
1737 GPC_75_OHM = 1<<26, /* Use 75 Ohm Termination instead of 50 */
1738 GPC_DIS_FC = 1<<25, /* Disable Automatic Fiber/Copper Detection */
1739 GPC_DIS_SLEEP = 1<<24, /* Disable Energy Detect */
1740 GPC_HWCFG_M_3 = 1<<23, /* HWCFG_MODE[3] */
1741 GPC_HWCFG_M_2 = 1<<22, /* HWCFG_MODE[2] */
1742 GPC_HWCFG_M_1 = 1<<21, /* HWCFG_MODE[1] */
1743 GPC_HWCFG_M_0 = 1<<20, /* HWCFG_MODE[0] */
1744 GPC_ANEG_0 = 1<<19, /* ANEG[0] */
1745 GPC_ENA_XC = 1<<18, /* Enable MDI crossover */
1746 GPC_DIS_125 = 1<<17, /* Disable 125 MHz clock */
1747 GPC_ANEG_3 = 1<<16, /* ANEG[3] */
1748 GPC_ANEG_2 = 1<<15, /* ANEG[2] */
1749 GPC_ANEG_1 = 1<<14, /* ANEG[1] */
1750 GPC_ENA_PAUSE = 1<<13, /* Enable Pause (SYM_OR_REM) */
1751 GPC_PHYADDR_4 = 1<<12, /* Bit 4 of Phy Addr */
1752 GPC_PHYADDR_3 = 1<<11, /* Bit 3 of Phy Addr */
1753 GPC_PHYADDR_2 = 1<<10, /* Bit 2 of Phy Addr */
1754 GPC_PHYADDR_1 = 1<<9, /* Bit 1 of Phy Addr */
1755 GPC_PHYADDR_0 = 1<<8, /* Bit 0 of Phy Addr */
1756 /* Bits 7..2: reserved */
1757 GPC_RST_CLR = 1<<1, /* Clear GPHY Reset */ 1735 GPC_RST_CLR = 1<<1, /* Clear GPHY Reset */
1758 GPC_RST_SET = 1<<0, /* Set GPHY Reset */ 1736 GPC_RST_SET = 1<<0, /* Set GPHY Reset */
1759}; 1737};
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 108adbf5b5eb..ef84d7c757a0 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -430,7 +430,8 @@ spider_net_prepare_rx_descr(struct spider_net_card *card,
430 /* and we need to have it 128 byte aligned, therefore we allocate a 430 /* and we need to have it 128 byte aligned, therefore we allocate a
431 * bit more */ 431 * bit more */
432 /* allocate an skb */ 432 /* allocate an skb */
433 descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1); 433 descr->skb = netdev_alloc_skb(card->netdev,
434 bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
434 if (!descr->skb) { 435 if (!descr->skb) {
435 if (netif_msg_rx_err(card) && net_ratelimit()) 436 if (netif_msg_rx_err(card) && net_ratelimit())
436 pr_err("Not enough memory to allocate rx buffer\n"); 437 pr_err("Not enough memory to allocate rx buffer\n");
@@ -1013,12 +1014,12 @@ spider_net_pass_skb_up(struct spider_net_descr *descr,
1013 */ 1014 */
1014 } 1015 }
1015 1016
1016 /* pass skb up to stack */
1017 netif_receive_skb(skb);
1018
1019 /* update netdevice statistics */ 1017 /* update netdevice statistics */
1020 card->netdev_stats.rx_packets++; 1018 card->netdev_stats.rx_packets++;
1021 card->netdev_stats.rx_bytes += skb->len; 1019 card->netdev_stats.rx_bytes += skb->len;
1020
1021 /* pass skb up to stack */
1022 netif_receive_skb(skb);
1022} 1023}
1023 1024
1024#ifdef DEBUG 1025#ifdef DEBUG
diff --git a/drivers/net/tokenring/Kconfig b/drivers/net/tokenring/Kconfig
index 99c4c1922f19..e6b2e06493e7 100644
--- a/drivers/net/tokenring/Kconfig
+++ b/drivers/net/tokenring/Kconfig
@@ -2,12 +2,10 @@
2# Token Ring driver configuration 2# Token Ring driver configuration
3# 3#
4 4
5menu "Token Ring devices"
6 depends on NETDEVICES && !UML
7
8# So far, we only have PCI, ISA, and MCA token ring devices 5# So far, we only have PCI, ISA, and MCA token ring devices
9config TR 6menuconfig TR
10 bool "Token Ring driver support" 7 bool "Token Ring driver support"
8 depends on NETDEVICES && !UML
11 depends on (PCI || ISA || MCA || CCW) 9 depends on (PCI || ISA || MCA || CCW)
12 select LLC 10 select LLC
13 help 11 help
@@ -20,9 +18,11 @@ config TR
20 from <http://www.tldp.org/docs.html#howto>. Most people can 18 from <http://www.tldp.org/docs.html#howto>. Most people can
21 say N here. 19 say N here.
22 20
21if TR
22
23config IBMTR 23config IBMTR
24 tristate "IBM Tropic chipset based adapter support" 24 tristate "IBM Tropic chipset based adapter support"
25 depends on TR && (ISA || MCA) 25 depends on ISA || MCA
26 ---help--- 26 ---help---
27 This is support for all IBM Token Ring cards that don't use DMA. If 27 This is support for all IBM Token Ring cards that don't use DMA. If
28 you have such a beast, say Y and read the Token-Ring mini-HOWTO, 28 you have such a beast, say Y and read the Token-Ring mini-HOWTO,
@@ -36,7 +36,7 @@ config IBMTR
36 36
37config IBMOL 37config IBMOL
38 tristate "IBM Olympic chipset PCI adapter support" 38 tristate "IBM Olympic chipset PCI adapter support"
39 depends on TR && PCI 39 depends on PCI
40 ---help--- 40 ---help---
41 This is support for all non-Lanstreamer IBM PCI Token Ring Cards. 41 This is support for all non-Lanstreamer IBM PCI Token Ring Cards.
42 Specifically this is all IBM PCI, PCI Wake On Lan, PCI II, PCI II 42 Specifically this is all IBM PCI, PCI Wake On Lan, PCI II, PCI II
@@ -54,7 +54,7 @@ config IBMOL
54 54
55config IBMLS 55config IBMLS
56 tristate "IBM Lanstreamer chipset PCI adapter support" 56 tristate "IBM Lanstreamer chipset PCI adapter support"
57 depends on TR && PCI && !64BIT 57 depends on PCI && !64BIT
58 help 58 help
59 This is support for IBM Lanstreamer PCI Token Ring Cards. 59 This is support for IBM Lanstreamer PCI Token Ring Cards.
60 60
@@ -66,7 +66,7 @@ config IBMLS
66 66
67config 3C359 67config 3C359
68 tristate "3Com 3C359 Token Link Velocity XL adapter support" 68 tristate "3Com 3C359 Token Link Velocity XL adapter support"
69 depends on TR && PCI 69 depends on PCI
70 ---help--- 70 ---help---
71 This is support for the 3Com PCI Velocity XL cards, specifically 71 This is support for the 3Com PCI Velocity XL cards, specifically
72 the 3Com 3C359, please note this is not for the 3C339 cards, you 72 the 3Com 3C359, please note this is not for the 3C339 cards, you
@@ -84,7 +84,7 @@ config 3C359
84 84
85config TMS380TR 85config TMS380TR
86 tristate "Generic TMS380 Token Ring ISA/PCI adapter support" 86 tristate "Generic TMS380 Token Ring ISA/PCI adapter support"
87 depends on TR && (PCI || ISA && ISA_DMA_API || MCA) 87 depends on PCI || ISA && ISA_DMA_API || MCA
88 select FW_LOADER 88 select FW_LOADER
89 ---help--- 89 ---help---
90 This driver provides generic support for token ring adapters 90 This driver provides generic support for token ring adapters
@@ -108,7 +108,7 @@ config TMS380TR
108 108
109config TMSPCI 109config TMSPCI
110 tristate "Generic TMS380 PCI support" 110 tristate "Generic TMS380 PCI support"
111 depends on TR && TMS380TR && PCI 111 depends on TMS380TR && PCI
112 ---help--- 112 ---help---
113 This tms380 module supports generic TMS380-based PCI cards. 113 This tms380 module supports generic TMS380-based PCI cards.
114 114
@@ -123,7 +123,7 @@ config TMSPCI
123 123
124config SKISA 124config SKISA
125 tristate "SysKonnect TR4/16 ISA support" 125 tristate "SysKonnect TR4/16 ISA support"
126 depends on TR && TMS380TR && ISA 126 depends on TMS380TR && ISA
127 help 127 help
128 This tms380 module supports SysKonnect TR4/16 ISA cards. 128 This tms380 module supports SysKonnect TR4/16 ISA cards.
129 129
@@ -135,7 +135,7 @@ config SKISA
135 135
136config PROTEON 136config PROTEON
137 tristate "Proteon ISA support" 137 tristate "Proteon ISA support"
138 depends on TR && TMS380TR && ISA 138 depends on TMS380TR && ISA
139 help 139 help
140 This tms380 module supports Proteon ISA cards. 140 This tms380 module supports Proteon ISA cards.
141 141
@@ -148,7 +148,7 @@ config PROTEON
148 148
149config ABYSS 149config ABYSS
150 tristate "Madge Smart 16/4 PCI Mk2 support" 150 tristate "Madge Smart 16/4 PCI Mk2 support"
151 depends on TR && TMS380TR && PCI 151 depends on TMS380TR && PCI
152 help 152 help
153 This tms380 module supports the Madge Smart 16/4 PCI Mk2 153 This tms380 module supports the Madge Smart 16/4 PCI Mk2
154 cards (51-02). 154 cards (51-02).
@@ -158,7 +158,7 @@ config ABYSS
158 158
159config MADGEMC 159config MADGEMC
160 tristate "Madge Smart 16/4 Ringnode MicroChannel" 160 tristate "Madge Smart 16/4 Ringnode MicroChannel"
161 depends on TR && TMS380TR && MCA 161 depends on TMS380TR && MCA
162 help 162 help
163 This tms380 module supports the Madge Smart 16/4 MC16 and MC32 163 This tms380 module supports the Madge Smart 16/4 MC16 and MC32
164 MicroChannel adapters. 164 MicroChannel adapters.
@@ -168,7 +168,7 @@ config MADGEMC
168 168
169config SMCTR 169config SMCTR
170 tristate "SMC ISA/MCA adapter support" 170 tristate "SMC ISA/MCA adapter support"
171 depends on TR && (ISA || MCA_LEGACY) && (BROKEN || !64BIT) 171 depends on (ISA || MCA_LEGACY) && (BROKEN || !64BIT)
172 ---help--- 172 ---help---
173 This is support for the ISA and MCA SMC Token Ring cards, 173 This is support for the ISA and MCA SMC Token Ring cards,
174 specifically SMC TokenCard Elite (8115T) and SMC TokenCard Elite/A 174 specifically SMC TokenCard Elite (8115T) and SMC TokenCard Elite/A
@@ -182,5 +182,4 @@ config SMCTR
182 To compile this driver as a module, choose M here: the module will be 182 To compile this driver as a module, choose M here: the module will be
183 called smctr. 183 called smctr.
184 184
185endmenu 185endif # TR
186
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index c2ccbd098f53..18b731bb4da1 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -23,11 +23,8 @@
23#include <linux/skbuff.h> 23#include <linux/skbuff.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/ethtool.h>
27#include <linux/delay.h>
28#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
29#include <linux/fsl_devices.h> 27#include <linux/fsl_devices.h>
30#include <linux/ethtool.h>
31#include <linux/mii.h> 28#include <linux/mii.h>
32#include <linux/phy.h> 29#include <linux/phy.h>
33#include <linux/workqueue.h> 30#include <linux/workqueue.h>
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index f96966d4bcc2..7bcb82f50cf7 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -260,8 +260,6 @@ static struct of_device_id uec_mdio_match[] = {
260 {}, 260 {},
261}; 261};
262 262
263MODULE_DEVICE_TABLE(of, uec_mdio_match);
264
265static struct of_platform_driver uec_mdio_driver = { 263static struct of_platform_driver uec_mdio_driver = {
266 .name = DRV_NAME, 264 .name = DRV_NAME,
267 .probe = uec_mdio_probe, 265 .probe = uec_mdio_probe,
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index d5ef97bc4d01..6d95cacd5284 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1458,6 +1458,10 @@ static const struct usb_device_id products [] = {
1458 // IO-DATA ETG-US2 1458 // IO-DATA ETG-US2
1459 USB_DEVICE (0x04bb, 0x0930), 1459 USB_DEVICE (0x04bb, 0x0930),
1460 .driver_info = (unsigned long) &ax88178_info, 1460 .driver_info = (unsigned long) &ax88178_info,
1461}, {
1462 // Belkin F5D5055
1463 USB_DEVICE(0x050d, 0x5055),
1464 .driver_info = (unsigned long) &ax88178_info,
1461}, 1465},
1462 { }, // END 1466 { }, // END
1463}; 1467};
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 5a21f06bf8a5..675ac99a79c6 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -91,6 +91,22 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
91 "CDC descriptors on config\n"); 91 "CDC descriptors on config\n");
92 } 92 }
93 93
94 /* Maybe CDC descriptors are after the endpoint? This bug has
95 * been seen on some 2Wire Inc RNDIS-ish products.
96 */
97 if (len == 0) {
98 struct usb_host_endpoint *hep;
99
100 hep = intf->cur_altsetting->endpoint;
101 if (hep) {
102 buf = hep->extra;
103 len = hep->extralen;
104 }
105 if (len)
106 dev_dbg(&intf->dev,
107 "CDC descriptors on endpoint\n");
108 }
109
94 /* this assumes that if there's a non-RNDIS vendor variant 110 /* this assumes that if there's a non-RNDIS vendor variant
95 * of cdc-acm, it'll fail RNDIS requests cleanly. 111 * of cdc-acm, it'll fail RNDIS requests cleanly.
96 */ 112 */
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 980e4aaa97aa..cd991a0f75bb 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -515,6 +515,7 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
515 dev_err(&intf->dev, 515 dev_err(&intf->dev,
516 "dev can't take %u byte packets (max %u)\n", 516 "dev can't take %u byte packets (max %u)\n",
517 dev->hard_mtu, tmp); 517 dev->hard_mtu, tmp);
518 retval = -EINVAL;
518 goto fail_and_release; 519 goto fail_and_release;
519 } 520 }
520 521
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f9cd42d058b0..5b16d9a1269a 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1252,20 +1252,23 @@ EXPORT_SYMBOL_GPL(usbnet_probe);
1252 1252
1253/*-------------------------------------------------------------------------*/ 1253/*-------------------------------------------------------------------------*/
1254 1254
1255/* FIXME these suspend/resume methods assume non-CDC style 1255/*
1256 * devices, with only one interface. 1256 * suspend the whole driver as soon as the first interface is suspended
1257 * resume only when the last interface is resumed
1257 */ 1258 */
1258 1259
1259int usbnet_suspend (struct usb_interface *intf, pm_message_t message) 1260int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
1260{ 1261{
1261 struct usbnet *dev = usb_get_intfdata(intf); 1262 struct usbnet *dev = usb_get_intfdata(intf);
1262 1263
1263 /* accelerate emptying of the rx and queues, to avoid 1264 if (!dev->suspend_count++) {
1264 * having everything error out. 1265 /* accelerate emptying of the rx and queues, to avoid
1265 */ 1266 * having everything error out.
1266 netif_device_detach (dev->net); 1267 */
1267 (void) unlink_urbs (dev, &dev->rxq); 1268 netif_device_detach (dev->net);
1268 (void) unlink_urbs (dev, &dev->txq); 1269 (void) unlink_urbs (dev, &dev->rxq);
1270 (void) unlink_urbs (dev, &dev->txq);
1271 }
1269 return 0; 1272 return 0;
1270} 1273}
1271EXPORT_SYMBOL_GPL(usbnet_suspend); 1274EXPORT_SYMBOL_GPL(usbnet_suspend);
@@ -1274,8 +1277,10 @@ int usbnet_resume (struct usb_interface *intf)
1274{ 1277{
1275 struct usbnet *dev = usb_get_intfdata(intf); 1278 struct usbnet *dev = usb_get_intfdata(intf);
1276 1279
1277 netif_device_attach (dev->net); 1280 if (!--dev->suspend_count) {
1278 tasklet_schedule (&dev->bh); 1281 netif_device_attach (dev->net);
1282 tasklet_schedule (&dev->bh);
1283 }
1279 return 0; 1284 return 0;
1280} 1285}
1281EXPORT_SYMBOL_GPL(usbnet_resume); 1286EXPORT_SYMBOL_GPL(usbnet_resume);
diff --git a/drivers/net/usb/usbnet.h b/drivers/net/usb/usbnet.h
index 82db5a8e528e..a3f8b9e7bc00 100644
--- a/drivers/net/usb/usbnet.h
+++ b/drivers/net/usb/usbnet.h
@@ -32,6 +32,7 @@ struct usbnet {
32 const char *driver_name; 32 const char *driver_name;
33 wait_queue_head_t *wait; 33 wait_queue_head_t *wait;
34 struct mutex phy_mutex; 34 struct mutex phy_mutex;
35 unsigned char suspend_count;
35 36
36 /* i/o info: pipes etc */ 37 /* i/o info: pipes etc */
37 unsigned in, out; 38 unsigned in, out;
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 246fac0e8001..3df3c60263d4 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -311,7 +311,7 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
311 local_info_t *local; 311 local_info_t *local;
312 struct ieee80211_hdr_4addr *hdr; 312 struct ieee80211_hdr_4addr *hdr;
313 u16 fc; 313 u16 fc;
314 int hdr_len, res; 314 int prefix_len, postfix_len, hdr_len, res;
315 315
316 iface = netdev_priv(skb->dev); 316 iface = netdev_priv(skb->dev);
317 local = iface->local; 317 local = iface->local;
@@ -337,10 +337,13 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
337 if (skb == NULL) 337 if (skb == NULL)
338 return NULL; 338 return NULL;
339 339
340 if ((skb_headroom(skb) < crypt->ops->extra_mpdu_prefix_len || 340 prefix_len = crypt->ops->extra_mpdu_prefix_len +
341 skb_tailroom(skb) < crypt->ops->extra_mpdu_postfix_len) && 341 crypt->ops->extra_msdu_prefix_len;
342 pskb_expand_head(skb, crypt->ops->extra_mpdu_prefix_len, 342 postfix_len = crypt->ops->extra_mpdu_postfix_len +
343 crypt->ops->extra_mpdu_postfix_len, GFP_ATOMIC)) { 343 crypt->ops->extra_msdu_postfix_len;
344 if ((skb_headroom(skb) < prefix_len ||
345 skb_tailroom(skb) < postfix_len) &&
346 pskb_expand_head(skb, prefix_len, postfix_len, GFP_ATOMIC)) {
344 kfree_skb(skb); 347 kfree_skb(skb);
345 return NULL; 348 return NULL;
346 } 349 }
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 606bdd002be7..dfe27642322c 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -46,7 +46,7 @@ u32 libertas_index_to_data_rate(u8 index);
46u8 libertas_data_rate_to_index(u32 rate); 46u8 libertas_data_rate_to_index(u32 rate);
47void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen); 47void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen);
48 48
49int libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb); 49void libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb);
50 50
51/** The proc fs interface */ 51/** The proc fs interface */
52int libertas_process_rx_command(wlan_private * priv); 52int libertas_process_rx_command(wlan_private * priv);
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c
index 441123c85e62..5c63c9b1659c 100644
--- a/drivers/net/wireless/libertas/fw.c
+++ b/drivers/net/wireless/libertas/fw.c
@@ -333,18 +333,22 @@ static void command_timer_fn(unsigned long data)
333 unsigned long flags; 333 unsigned long flags;
334 334
335 ptempnode = adapter->cur_cmd; 335 ptempnode = adapter->cur_cmd;
336 if (ptempnode == NULL) {
337 lbs_pr_debug(1, "PTempnode Empty\n");
338 return;
339 }
340
336 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr; 341 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr;
342 if (!cmd) {
343 lbs_pr_debug(1, "cmd is NULL\n");
344 return;
345 }
337 346
338 lbs_pr_info("command_timer_fn fired (%x)\n", cmd->command); 347 lbs_pr_info("command_timer_fn fired (%x)\n", cmd->command);
339 348
340 if (!adapter->fw_ready) 349 if (!adapter->fw_ready)
341 return; 350 return;
342 351
343 if (ptempnode == NULL) {
344 lbs_pr_debug(1, "PTempnode Empty\n");
345 return;
346 }
347
348 spin_lock_irqsave(&adapter->driver_lock, flags); 352 spin_lock_irqsave(&adapter->driver_lock, flags);
349 adapter->cur_cmd = NULL; 353 adapter->cur_cmd = NULL;
350 spin_unlock_irqrestore(&adapter->driver_lock, flags); 354 spin_unlock_irqrestore(&adapter->driver_lock, flags);
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index d17924f764e5..96619a32951b 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -136,7 +136,7 @@ static void wlan_compute_rssi(wlan_private * priv, struct rxpd *p_rx_pd)
136 LEAVE(); 136 LEAVE();
137} 137}
138 138
139int libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb) 139void libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb)
140{ 140{
141 lbs_pr_debug(1, "skb->data=%p\n", skb->data); 141 lbs_pr_debug(1, "skb->data=%p\n", skb->data);
142 142
@@ -148,8 +148,6 @@ int libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb)
148 skb->ip_summed = CHECKSUM_UNNECESSARY; 148 skb->ip_summed = CHECKSUM_UNNECESSARY;
149 149
150 netif_rx(skb); 150 netif_rx(skb);
151
152 return 0;
153} 151}
154 152
155/** 153/**
@@ -269,15 +267,11 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb)
269 wlan_compute_rssi(priv, p_rx_pd); 267 wlan_compute_rssi(priv, p_rx_pd);
270 268
271 lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len); 269 lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len);
272 if (libertas_upload_rx_packet(priv, skb)) {
273 lbs_pr_debug(1, "RX error: libertas_upload_rx_packet"
274 " returns failure\n");
275 ret = -1;
276 goto done;
277 }
278 priv->stats.rx_bytes += skb->len; 270 priv->stats.rx_bytes += skb->len;
279 priv->stats.rx_packets++; 271 priv->stats.rx_packets++;
280 272
273 libertas_upload_rx_packet(priv, skb);
274
281 ret = 0; 275 ret = 0;
282done: 276done:
283 LEAVE(); 277 LEAVE();
@@ -438,22 +432,14 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb)
438 wlan_compute_rssi(priv, prxpd); 432 wlan_compute_rssi(priv, prxpd);
439 433
440 lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len); 434 lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len);
441
442 if (libertas_upload_rx_packet(priv, skb)) {
443 lbs_pr_debug(1, "RX error: libertas_upload_rx_packet "
444 "returns failure\n");
445 ret = -1;
446 goto done;
447 }
448
449 priv->stats.rx_bytes += skb->len; 435 priv->stats.rx_bytes += skb->len;
450 priv->stats.rx_packets++; 436 priv->stats.rx_packets++;
451 437
438 libertas_upload_rx_packet(priv, skb);
439
452 ret = 0; 440 ret = 0;
453done: 441done:
454 LEAVE(); 442 LEAVE();
455 443
456 skb->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
457
458 return (ret); 444 return (ret);
459} 445}
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index dd070cccf324..f49eb068c7d0 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -378,9 +378,10 @@ islpci_eth_receive(islpci_private *priv)
378 display_buffer((char *) skb->data, skb->len); 378 display_buffer((char *) skb->data, skb->len);
379#endif 379#endif
380 /* take care of monitor mode and spy monitoring. */ 380 /* take care of monitor mode and spy monitoring. */
381 if (unlikely(priv->iw_mode == IW_MODE_MONITOR)) 381 if (unlikely(priv->iw_mode == IW_MODE_MONITOR)) {
382 skb->dev = ndev;
382 discard = islpci_monitor_rx(priv, &skb); 383 discard = islpci_monitor_rx(priv, &skb);
383 else { 384 } else {
384 if (unlikely(skb->data[2 * ETH_ALEN] == 0)) { 385 if (unlikely(skb->data[2 * ETH_ALEN] == 0)) {
385 /* The packet has a rx_annex. Read it for spy monitoring, Then 386 /* The packet has a rx_annex. Read it for spy monitoring, Then
386 * remove it, while keeping the 2 leading MAC addr. 387 * remove it, while keeping the 2 leading MAC addr.
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 78c2e6e4b42e..edd6de995726 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -26,6 +26,7 @@
26#include <linux/profile.h> 26#include <linux/profile.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/fs.h> 28#include <linux/fs.h>
29#include <linux/sched.h>
29 30
30#include "oprofile_stats.h" 31#include "oprofile_stats.h"
31#include "event_buffer.h" 32#include "event_buffer.h"
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 02c0d52c9f76..7bfbad57879d 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -51,6 +51,7 @@
51#include <linux/ioport.h> 51#include <linux/ioport.h>
52#include <linux/kernel.h> 52#include <linux/kernel.h>
53#include <linux/slab.h> 53#include <linux/slab.h>
54#include <linux/dma-mapping.h>
54#include <linux/pci.h> 55#include <linux/pci.h>
55#include <linux/pnp.h> 56#include <linux/pnp.h>
56#include <linux/platform_device.h> 57#include <linux/platform_device.h>
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 46abaa8c41f1..d06ccb69e411 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/sched.h>
37 38
38#include "ibmphp.h" 39#include "ibmphp.h"
39 40
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index bf655dbaf8e2..5cca394d5999 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -8,6 +8,7 @@
8#ifndef _AERDRV_H_ 8#ifndef _AERDRV_H_
9#define _AERDRV_H_ 9#define _AERDRV_H_
10 10
11#include <linux/workqueue.h>
11#include <linux/pcieport_if.h> 12#include <linux/pcieport_if.h>
12#include <linux/aer.h> 13#include <linux/aer.h>
13 14
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 95ce8f49e382..4e4c10a7fd3a 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -59,7 +59,7 @@ comment "RTC interfaces"
59 depends on RTC_CLASS 59 depends on RTC_CLASS
60 60
61config RTC_INTF_SYSFS 61config RTC_INTF_SYSFS
62 boolean "sysfs" 62 boolean "/sys/class/rtc/rtcN (sysfs)"
63 depends on RTC_CLASS && SYSFS 63 depends on RTC_CLASS && SYSFS
64 default RTC_CLASS 64 default RTC_CLASS
65 help 65 help
@@ -70,7 +70,7 @@ config RTC_INTF_SYSFS
70 will be called rtc-sysfs. 70 will be called rtc-sysfs.
71 71
72config RTC_INTF_PROC 72config RTC_INTF_PROC
73 boolean "proc" 73 boolean "/proc/driver/rtc (procfs for rtc0)"
74 depends on RTC_CLASS && PROC_FS 74 depends on RTC_CLASS && PROC_FS
75 default RTC_CLASS 75 default RTC_CLASS
76 help 76 help
@@ -82,7 +82,7 @@ config RTC_INTF_PROC
82 will be called rtc-proc. 82 will be called rtc-proc.
83 83
84config RTC_INTF_DEV 84config RTC_INTF_DEV
85 boolean "dev" 85 boolean "/dev/rtcN (character devices)"
86 depends on RTC_CLASS 86 depends on RTC_CLASS
87 default RTC_CLASS 87 default RTC_CLASS
88 help 88 help
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 60a8a4bb8bd2..a2f84f169588 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -371,7 +371,7 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
371 goto fail; 371 goto fail;
372 } 372 }
373 platform_set_drvdata(pdev, rtc); 373 platform_set_drvdata(pdev, rtc);
374 dev_set_devdata(&rtc->dev, mem); 374 dev_set_drvdata(&rtc->dev, mem);
375 375
376 /* clear pending irqs, and set 1/second periodic, 376 /* clear pending irqs, and set 1/second periodic,
377 * which we'll use instead of update irqs 377 * which we'll use instead of update irqs
@@ -453,7 +453,7 @@ static int __devexit omap_rtc_remove(struct platform_device *pdev)
453 free_irq(omap_rtc_timer, rtc); 453 free_irq(omap_rtc_timer, rtc);
454 free_irq(omap_rtc_alarm, rtc); 454 free_irq(omap_rtc_alarm, rtc);
455 455
456 release_resource(dev_get_devdata(&rtc->dev)); 456 release_resource(dev_get_drvdata(&rtc->dev));
457 rtc_device_unregister(rtc); 457 rtc_device_unregister(rtc);
458 return 0; 458 return 0;
459} 459}
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index ddff40c4212c..821cde65e369 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -1127,6 +1127,7 @@ zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
1127 int retval = 0; 1127 int retval = 0;
1128 unsigned long flags; 1128 unsigned long flags;
1129 1129
1130 zfcp_adapter_scsi_unregister(adapter);
1130 device_unregister(&adapter->generic_services); 1131 device_unregister(&adapter->generic_services);
1131 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev); 1132 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);
1132 dev_set_drvdata(&adapter->ccw_device->dev, NULL); 1133 dev_set_drvdata(&adapter->ccw_device->dev, NULL);
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 81680efa1721..1c8f71a59855 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -189,9 +189,7 @@ zfcp_ccw_set_online(struct ccw_device *ccw_device)
189 * @ccw_device: pointer to belonging ccw device 189 * @ccw_device: pointer to belonging ccw device
190 * 190 *
191 * This function gets called by the common i/o layer and sets an adapter 191 * This function gets called by the common i/o layer and sets an adapter
192 * into state offline. Setting an fcp device offline means that it will be 192 * into state offline.
193 * unregistered from the SCSI stack and that the adapter will be shut down
194 * asynchronously.
195 */ 193 */
196static int 194static int
197zfcp_ccw_set_offline(struct ccw_device *ccw_device) 195zfcp_ccw_set_offline(struct ccw_device *ccw_device)
@@ -202,7 +200,6 @@ zfcp_ccw_set_offline(struct ccw_device *ccw_device)
202 adapter = dev_get_drvdata(&ccw_device->dev); 200 adapter = dev_get_drvdata(&ccw_device->dev);
203 zfcp_erp_adapter_shutdown(adapter, 0); 201 zfcp_erp_adapter_shutdown(adapter, 0);
204 zfcp_erp_wait(adapter); 202 zfcp_erp_wait(adapter);
205 zfcp_adapter_scsi_unregister(adapter);
206 zfcp_erp_thread_kill(adapter); 203 zfcp_erp_thread_kill(adapter);
207 zfcp_adapter_debug_unregister(adapter); 204 zfcp_adapter_debug_unregister(adapter);
208 up(&zfcp_data.config_sema); 205 up(&zfcp_data.config_sema);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index a8b02542ac2d..0eb31e162b15 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -156,44 +156,30 @@ zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req)
156 kfree(fsf_req); 156 kfree(fsf_req);
157} 157}
158 158
159/** 159/*
160 * zfcp_fsf_req_dismiss - dismiss a single fsf request 160 * Never ever call this without shutting down the adapter first.
161 */ 161 * Otherwise the adapter would continue using and corrupting s390 storage.
162static void zfcp_fsf_req_dismiss(struct zfcp_adapter *adapter, 162 * Included BUG_ON() call to ensure this is done.
163 struct zfcp_fsf_req *fsf_req, 163 * ERP is supposed to be the only user of this function.
164 unsigned int counter)
165{
166 u64 dbg_tmp[2];
167
168 dbg_tmp[0] = (u64) atomic_read(&adapter->reqs_active);
169 dbg_tmp[1] = (u64) counter;
170 debug_event(adapter->erp_dbf, 4, (void *) dbg_tmp, 16);
171 list_del(&fsf_req->list);
172 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
173 zfcp_fsf_req_complete(fsf_req);
174}
175
176/**
177 * zfcp_fsf_req_dismiss_all - dismiss all remaining fsf requests
178 */ 164 */
179void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter) 165void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
180{ 166{
181 struct zfcp_fsf_req *request, *tmp; 167 struct zfcp_fsf_req *fsf_req, *tmp;
182 unsigned long flags; 168 unsigned long flags;
183 LIST_HEAD(remove_queue); 169 LIST_HEAD(remove_queue);
184 unsigned int i, counter; 170 unsigned int i;
185 171
172 BUG_ON(atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status));
186 spin_lock_irqsave(&adapter->req_list_lock, flags); 173 spin_lock_irqsave(&adapter->req_list_lock, flags);
187 atomic_set(&adapter->reqs_active, 0); 174 atomic_set(&adapter->reqs_active, 0);
188 for (i=0; i<REQUEST_LIST_SIZE; i++) 175 for (i = 0; i < REQUEST_LIST_SIZE; i++)
189 list_splice_init(&adapter->req_list[i], &remove_queue); 176 list_splice_init(&adapter->req_list[i], &remove_queue);
190
191 spin_unlock_irqrestore(&adapter->req_list_lock, flags); 177 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
192 178
193 counter = 0; 179 list_for_each_entry_safe(fsf_req, tmp, &remove_queue, list) {
194 list_for_each_entry_safe(request, tmp, &remove_queue, list) { 180 list_del(&fsf_req->list);
195 zfcp_fsf_req_dismiss(adapter, request, counter); 181 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
196 counter++; 182 zfcp_fsf_req_complete(fsf_req);
197 } 183 }
198} 184}
199 185
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 16e2d64658af..0acf6db0a08d 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -569,6 +569,9 @@ zfcp_adapter_scsi_register(struct zfcp_adapter *adapter)
569 int retval = 0; 569 int retval = 0;
570 static unsigned int unique_id = 0; 570 static unsigned int unique_id = 0;
571 571
572 if (adapter->scsi_host)
573 goto out;
574
572 /* register adapter as SCSI host with mid layer of SCSI stack */ 575 /* register adapter as SCSI host with mid layer of SCSI stack */
573 adapter->scsi_host = scsi_host_alloc(&zfcp_data.scsi_host_template, 576 adapter->scsi_host = scsi_host_alloc(&zfcp_data.scsi_host_template,
574 sizeof (struct zfcp_adapter *)); 577 sizeof (struct zfcp_adapter *));
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index d6510ef03035..aac9cd9a172f 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1753,23 +1753,9 @@ config SUN3X_ESP
1753 The ESP was an on-board SCSI controller used on Sun 3/80 1753 The ESP was an on-board SCSI controller used on Sun 3/80
1754 machines. Say Y here to compile in support for it. 1754 machines. Say Y here to compile in support for it.
1755 1755
1756config SCSI_ESP_CORE
1757 tristate "ESP Scsi Driver Core"
1758 depends on SCSI
1759 select SCSI_SPI_ATTRS
1760 help
1761 This is a core driver for NCR53c9x based scsi chipsets,
1762 also known as "ESP" for Emulex Scsi Processor or
1763 Enhanced Scsi Processor. This driver does not exist by
1764 itself, there are front-end drivers which, when enabled,
1765 select and enable this driver. One example is SCSI_SUNESP.
1766 These front-end drivers provide probing, DMA, and register
1767 access support for the core driver.
1768
1769config SCSI_SUNESP 1756config SCSI_SUNESP
1770 tristate "Sparc ESP Scsi Driver" 1757 tristate "Sparc ESP Scsi Driver"
1771 depends on SBUS && SCSI 1758 depends on SBUS && SCSI
1772 select SCSI_ESP_CORE
1773 help 1759 help
1774 This is the driver for the Sun ESP SCSI host adapter. The ESP 1760 This is the driver for the Sun ESP SCSI host adapter. The ESP
1775 chipset is present in most SPARC SBUS-based computers. 1761 chipset is present in most SPARC SBUS-based computers.
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 51cba91cd228..cba39679f947 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -103,8 +103,7 @@ obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
103obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/ 103obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
104obj-$(CONFIG_MEGARAID_SAS) += megaraid/ 104obj-$(CONFIG_MEGARAID_SAS) += megaraid/
105obj-$(CONFIG_SCSI_ACARD) += atp870u.o 105obj-$(CONFIG_SCSI_ACARD) += atp870u.o
106obj-$(CONFIG_SCSI_ESP_CORE) += esp_scsi.o 106obj-$(CONFIG_SCSI_SUNESP) += esp_scsi.o sun_esp.o
107obj-$(CONFIG_SCSI_SUNESP) += sun_esp.o
108obj-$(CONFIG_SCSI_GDTH) += gdth.o 107obj-$(CONFIG_SCSI_GDTH) += gdth.o
109obj-$(CONFIG_SCSI_INITIO) += initio.o 108obj-$(CONFIG_SCSI_INITIO) += initio.o
110obj-$(CONFIG_SCSI_INIA100) += a100u2w.o 109obj-$(CONFIG_SCSI_INIA100) += a100u2w.o
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index a333e62fc487..47014beef96e 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -146,7 +146,7 @@ static char *aac_get_status_string(u32 status);
146static int nondasd = -1; 146static int nondasd = -1;
147static int dacmode = -1; 147static int dacmode = -1;
148 148
149static int commit = -1; 149int aac_commit = -1;
150int startup_timeout = 180; 150int startup_timeout = 180;
151int aif_timeout = 120; 151int aif_timeout = 120;
152 152
@@ -154,7 +154,7 @@ module_param(nondasd, int, S_IRUGO|S_IWUSR);
154MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on"); 154MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");
155module_param(dacmode, int, S_IRUGO|S_IWUSR); 155module_param(dacmode, int, S_IRUGO|S_IWUSR);
156MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on"); 156MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
157module_param(commit, int, S_IRUGO|S_IWUSR); 157module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR);
158MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on"); 158MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on");
159module_param(startup_timeout, int, S_IRUGO|S_IWUSR); 159module_param(startup_timeout, int, S_IRUGO|S_IWUSR);
160MODULE_PARM_DESC(startup_timeout, "The duration of time in seconds to wait for adapter to have it's kernel up and\nrunning. This is typically adjusted for large systems that do not have a BIOS."); 160MODULE_PARM_DESC(startup_timeout, "The duration of time in seconds to wait for adapter to have it's kernel up and\nrunning. This is typically adjusted for large systems that do not have a BIOS.");
@@ -173,6 +173,9 @@ int expose_physicals = -1;
173module_param(expose_physicals, int, S_IRUGO|S_IWUSR); 173module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
174MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on"); 174MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
175 175
176int aac_reset_devices = 0;
177module_param_named(reset_devices, aac_reset_devices, int, S_IRUGO|S_IWUSR);
178MODULE_PARM_DESC(reset_devices, "Force an adapter reset at initialization.");
176 179
177static inline int aac_valid_context(struct scsi_cmnd *scsicmd, 180static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
178 struct fib *fibptr) { 181 struct fib *fibptr) {
@@ -246,7 +249,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag)
246 aac_fib_complete(fibptr); 249 aac_fib_complete(fibptr);
247 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */ 250 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
248 if (status >= 0) { 251 if (status >= 0) {
249 if ((commit == 1) || commit_flag) { 252 if ((aac_commit == 1) || commit_flag) {
250 struct aac_commit_config * dinfo; 253 struct aac_commit_config * dinfo;
251 aac_fib_init(fibptr); 254 aac_fib_init(fibptr);
252 dinfo = (struct aac_commit_config *) fib_data(fibptr); 255 dinfo = (struct aac_commit_config *) fib_data(fibptr);
@@ -261,7 +264,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag)
261 1, 1, 264 1, 1,
262 NULL, NULL); 265 NULL, NULL);
263 aac_fib_complete(fibptr); 266 aac_fib_complete(fibptr);
264 } else if (commit == 0) { 267 } else if (aac_commit == 0) {
265 printk(KERN_WARNING 268 printk(KERN_WARNING
266 "aac_get_config_status: Foreign device configurations are being ignored\n"); 269 "aac_get_config_status: Foreign device configurations are being ignored\n");
267 } 270 }
@@ -340,7 +343,7 @@ int aac_get_containers(struct aac_dev *dev)
340static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigned int offset, unsigned int len) 343static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigned int offset, unsigned int len)
341{ 344{
342 void *buf; 345 void *buf;
343 unsigned int transfer_len; 346 int transfer_len;
344 struct scatterlist *sg = scsicmd->request_buffer; 347 struct scatterlist *sg = scsicmd->request_buffer;
345 348
346 if (scsicmd->use_sg) { 349 if (scsicmd->use_sg) {
@@ -351,7 +354,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne
351 transfer_len = min(scsicmd->request_bufflen, len + offset); 354 transfer_len = min(scsicmd->request_bufflen, len + offset);
352 } 355 }
353 transfer_len -= offset; 356 transfer_len -= offset;
354 if (buf && transfer_len) 357 if (buf && transfer_len > 0)
355 memcpy(buf + offset, data, transfer_len); 358 memcpy(buf + offset, data, transfer_len);
356 359
357 if (scsicmd->use_sg) 360 if (scsicmd->use_sg)
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index a3138ee91050..fdbedb17d03b 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -1826,9 +1826,12 @@ int aac_send_shutdown(struct aac_dev *dev);
1826int aac_probe_container(struct aac_dev *dev, int cid); 1826int aac_probe_container(struct aac_dev *dev, int cid);
1827int _aac_rx_init(struct aac_dev *dev); 1827int _aac_rx_init(struct aac_dev *dev);
1828int aac_rx_select_comm(struct aac_dev *dev, int comm); 1828int aac_rx_select_comm(struct aac_dev *dev, int comm);
1829int aac_rx_deliver_producer(struct fib * fib);
1829extern int numacb; 1830extern int numacb;
1830extern int acbsize; 1831extern int acbsize;
1831extern char aac_driver_version[]; 1832extern char aac_driver_version[];
1832extern int startup_timeout; 1833extern int startup_timeout;
1833extern int aif_timeout; 1834extern int aif_timeout;
1834extern int expose_physicals; 1835extern int expose_physicals;
1836extern int aac_reset_devices;
1837extern int aac_commit;
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index 291cd14f4e98..ae978a373c56 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -378,7 +378,7 @@ static int aac_rx_check_health(struct aac_dev *dev)
378 * 378 *
379 * Will send a fib, returning 0 if successful. 379 * Will send a fib, returning 0 if successful.
380 */ 380 */
381static int aac_rx_deliver_producer(struct fib * fib) 381int aac_rx_deliver_producer(struct fib * fib)
382{ 382{
383 struct aac_dev *dev = fib->dev; 383 struct aac_dev *dev = fib->dev;
384 struct aac_queue *q = &dev->queues->queue[AdapNormCmdQueue]; 384 struct aac_queue *q = &dev->queues->queue[AdapNormCmdQueue];
@@ -488,6 +488,8 @@ static int aac_rx_restart_adapter(struct aac_dev *dev, int bled)
488 return -EINVAL; 488 return -EINVAL;
489 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) 489 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC)
490 return -ENODEV; 490 return -ENODEV;
491 if (startup_timeout < 300)
492 startup_timeout = 300;
491 return 0; 493 return 0;
492} 494}
493 495
@@ -542,7 +544,7 @@ int _aac_rx_init(struct aac_dev *dev)
542 dev->a_ops.adapter_sync_cmd = rx_sync_cmd; 544 dev->a_ops.adapter_sync_cmd = rx_sync_cmd;
543 dev->a_ops.adapter_enable_int = aac_rx_disable_interrupt; 545 dev->a_ops.adapter_enable_int = aac_rx_disable_interrupt;
544 dev->OIMR = status = rx_readb (dev, MUnit.OIMR); 546 dev->OIMR = status = rx_readb (dev, MUnit.OIMR);
545 if ((((status & 0x0c) != 0x0c) || reset_devices) && 547 if ((((status & 0x0c) != 0x0c) || aac_reset_devices || reset_devices) &&
546 !aac_rx_restart_adapter(dev, 0)) 548 !aac_rx_restart_adapter(dev, 0))
547 ++restart; 549 ++restart;
548 /* 550 /*
@@ -594,6 +596,8 @@ int _aac_rx_init(struct aac_dev *dev)
594 } 596 }
595 msleep(1); 597 msleep(1);
596 } 598 }
599 if (restart)
600 aac_commit = 1;
597 /* 601 /*
598 * Fill in the common function dispatch table. 602 * Fill in the common function dispatch table.
599 */ 603 */
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index f4b5e9742ab0..85b91bc578c9 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -257,6 +257,11 @@ static void aac_sa_start_adapter(struct aac_dev *dev)
257 NULL, NULL, NULL, NULL, NULL); 257 NULL, NULL, NULL, NULL, NULL);
258} 258}
259 259
260static int aac_sa_restart_adapter(struct aac_dev *dev, int bled)
261{
262 return -EINVAL;
263}
264
260/** 265/**
261 * aac_sa_check_health 266 * aac_sa_check_health
262 * @dev: device to check if healthy 267 * @dev: device to check if healthy
@@ -366,7 +371,9 @@ int aac_sa_init(struct aac_dev *dev)
366 dev->a_ops.adapter_notify = aac_sa_notify_adapter; 371 dev->a_ops.adapter_notify = aac_sa_notify_adapter;
367 dev->a_ops.adapter_sync_cmd = sa_sync_cmd; 372 dev->a_ops.adapter_sync_cmd = sa_sync_cmd;
368 dev->a_ops.adapter_check_health = aac_sa_check_health; 373 dev->a_ops.adapter_check_health = aac_sa_check_health;
374 dev->a_ops.adapter_restart = aac_sa_restart_adapter;
369 dev->a_ops.adapter_intr = aac_sa_intr; 375 dev->a_ops.adapter_intr = aac_sa_intr;
376 dev->a_ops.adapter_deliver = aac_rx_deliver_producer;
370 dev->a_ops.adapter_ioremap = aac_sa_ioremap; 377 dev->a_ops.adapter_ioremap = aac_sa_ioremap;
371 378
372 /* 379 /*
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y b/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
index c328596def3c..6066998ed562 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
@@ -106,6 +106,7 @@ static void make_expression(expression_t *immed, int value);
106static void add_conditional(symbol_t *symbol); 106static void add_conditional(symbol_t *symbol);
107static void add_version(const char *verstring); 107static void add_version(const char *verstring);
108static int is_download_const(expression_t *immed); 108static int is_download_const(expression_t *immed);
109void yyerror(const char *string);
109 110
110#define SRAM_SYMNAME "SRAM_BASE" 111#define SRAM_SYMNAME "SRAM_BASE"
111#define SCB_SYMNAME "SCB_BASE" 112#define SCB_SYMNAME "SCB_BASE"
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y b/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y
index 439f760b34b5..ff46aa6801bf 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_macro_gram.y
@@ -65,6 +65,7 @@
65static symbol_t *macro_symbol; 65static symbol_t *macro_symbol;
66 66
67static void add_macro_arg(const char *argtext, int position); 67static void add_macro_arg(const char *argtext, int position);
68void mmerror(const char *string);
68 69
69%} 70%}
70 71
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index 9a14a6d97275..c0d0b7d7a8ce 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -290,6 +290,7 @@ static void asd_tmf_tasklet_complete(struct asd_ascb *ascb,
290static inline int asd_clear_nexus(struct sas_task *task) 290static inline int asd_clear_nexus(struct sas_task *task)
291{ 291{
292 int res = TMF_RESP_FUNC_FAILED; 292 int res = TMF_RESP_FUNC_FAILED;
293 int leftover;
293 struct asd_ascb *tascb = task->lldd_task; 294 struct asd_ascb *tascb = task->lldd_task;
294 unsigned long flags; 295 unsigned long flags;
295 296
@@ -298,10 +299,12 @@ static inline int asd_clear_nexus(struct sas_task *task)
298 res = asd_clear_nexus_tag(task); 299 res = asd_clear_nexus_tag(task);
299 else 300 else
300 res = asd_clear_nexus_index(task); 301 res = asd_clear_nexus_index(task);
301 wait_for_completion_timeout(&tascb->completion, 302 leftover = wait_for_completion_timeout(&tascb->completion,
302 AIC94XX_SCB_TIMEOUT); 303 AIC94XX_SCB_TIMEOUT);
303 ASD_DPRINTK("came back from clear nexus\n"); 304 ASD_DPRINTK("came back from clear nexus\n");
304 spin_lock_irqsave(&task->task_state_lock, flags); 305 spin_lock_irqsave(&task->task_state_lock, flags);
306 if (leftover < 1)
307 res = TMF_RESP_FUNC_FAILED;
305 if (task->task_state_flags & SAS_TASK_STATE_DONE) 308 if (task->task_state_flags & SAS_TASK_STATE_DONE)
306 res = TMF_RESP_FUNC_COMPLETE; 309 res = TMF_RESP_FUNC_COMPLETE;
307 spin_unlock_irqrestore(&task->task_state_lock, flags); 310 spin_unlock_irqrestore(&task->task_state_lock, flags);
@@ -350,6 +353,7 @@ int asd_abort_task(struct sas_task *task)
350 unsigned long flags; 353 unsigned long flags;
351 struct asd_ascb *ascb = NULL; 354 struct asd_ascb *ascb = NULL;
352 struct scb *scb; 355 struct scb *scb;
356 int leftover;
353 357
354 spin_lock_irqsave(&task->task_state_lock, flags); 358 spin_lock_irqsave(&task->task_state_lock, flags);
355 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 359 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
@@ -455,9 +459,11 @@ int asd_abort_task(struct sas_task *task)
455 break; 459 break;
456 case TF_TMF_TASK_DONE + 0xFF00: /* done but not reported yet */ 460 case TF_TMF_TASK_DONE + 0xFF00: /* done but not reported yet */
457 res = TMF_RESP_FUNC_FAILED; 461 res = TMF_RESP_FUNC_FAILED;
458 wait_for_completion_timeout(&tascb->completion, 462 leftover = wait_for_completion_timeout(&tascb->completion,
459 AIC94XX_SCB_TIMEOUT); 463 AIC94XX_SCB_TIMEOUT);
460 spin_lock_irqsave(&task->task_state_lock, flags); 464 spin_lock_irqsave(&task->task_state_lock, flags);
465 if (leftover < 1)
466 res = TMF_RESP_FUNC_FAILED;
461 if (task->task_state_flags & SAS_TASK_STATE_DONE) 467 if (task->task_state_flags & SAS_TASK_STATE_DONE)
462 res = TMF_RESP_FUNC_COMPLETE; 468 res = TMF_RESP_FUNC_COMPLETE;
463 spin_unlock_irqrestore(&task->task_state_lock, flags); 469 spin_unlock_irqrestore(&task->task_state_lock, flags);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 6411c458d336..072f57715658 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3928,6 +3928,13 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
3928 spin_unlock_irq(scsi_cmd->device->host->host_lock); 3928 spin_unlock_irq(scsi_cmd->device->host->host_lock);
3929 ata_do_eh(ap, NULL, NULL, ipr_sata_reset, NULL); 3929 ata_do_eh(ap, NULL, NULL, ipr_sata_reset, NULL);
3930 spin_lock_irq(scsi_cmd->device->host->host_lock); 3930 spin_lock_irq(scsi_cmd->device->host->host_lock);
3931
3932 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
3933 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) {
3934 rc = -EIO;
3935 break;
3936 }
3937 }
3931 } else 3938 } else
3932 rc = ipr_device_reset(ioa_cfg, res); 3939 rc = ipr_device_reset(ioa_cfg, res);
3933 res->resetting_device = 0; 3940 res->resetting_device = 0;
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 5631c199a8eb..732446e63963 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -254,6 +254,7 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
254 254
255 sg_init_one(&dummy, md, id->table_desc.len); 255 sg_init_one(&dummy, md, id->table_desc.len);
256 sg_dma_address(&dummy) = token; 256 sg_dma_address(&dummy) = token;
257 sg_dma_len(&dummy) = id->table_desc.len;
257 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE, 258 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
258 id->table_desc.len); 259 id->table_desc.len);
259 if (err) { 260 if (err) {
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index e075a52ac104..84d9c27133d4 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -14,7 +14,7 @@
14 * 14 *
15 * Common management module 15 * Common management module
16 */ 16 */
17 17#include <linux/sched.h>
18#include "megaraid_mm.h" 18#include "megaraid_mm.h"
19 19
20 20
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 7a812677ff8a..e2cf12ef3688 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -10,7 +10,7 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 * 11 *
12 * FILE : megaraid_sas.c 12 * FILE : megaraid_sas.c
13 * Version : v00.00.03.10-rc1 13 * Version : v00.00.03.10-rc5
14 * 14 *
15 * Authors: 15 * Authors:
16 * (email-id : megaraidlinux@lsi.com) 16 * (email-id : megaraidlinux@lsi.com)
@@ -886,6 +886,7 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
886 goto out_return_cmd; 886 goto out_return_cmd;
887 887
888 cmd->scmd = scmd; 888 cmd->scmd = scmd;
889 scmd->SCp.ptr = (char *)cmd;
889 890
890 /* 891 /*
891 * Issue the command to the FW 892 * Issue the command to the FW
@@ -919,7 +920,7 @@ static int megasas_slave_configure(struct scsi_device *sdev)
919 * The RAID firmware may require extended timeouts. 920 * The RAID firmware may require extended timeouts.
920 */ 921 */
921 if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS) 922 if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS)
922 sdev->timeout = 90 * HZ; 923 sdev->timeout = MEGASAS_DEFAULT_CMD_TIMEOUT * HZ;
923 return 0; 924 return 0;
924} 925}
925 926
@@ -981,8 +982,8 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
981 982
982 instance = (struct megasas_instance *)scmd->device->host->hostdata; 983 instance = (struct megasas_instance *)scmd->device->host->hostdata;
983 984
984 scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x\n", 985 scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",
985 scmd->serial_number, scmd->cmnd[0]); 986 scmd->serial_number, scmd->cmnd[0], scmd->retries);
986 987
987 if (instance->hw_crit_error) { 988 if (instance->hw_crit_error) {
988 printk(KERN_ERR "megasas: cannot recover from previous reset " 989 printk(KERN_ERR "megasas: cannot recover from previous reset "
@@ -1000,6 +1001,39 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
1000} 1001}
1001 1002
1002/** 1003/**
1004 * megasas_reset_timer - quiesce the adapter if required
1005 * @scmd: scsi cmnd
1006 *
1007 * Sets the FW busy flag and reduces the host->can_queue if the
1008 * cmd has not been completed within the timeout period.
1009 */
1010static enum
1011scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
1012{
1013 struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
1014 struct megasas_instance *instance;
1015 unsigned long flags;
1016
1017 if (time_after(jiffies, scmd->jiffies_at_alloc +
1018 (MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) {
1019 return EH_NOT_HANDLED;
1020 }
1021
1022 instance = cmd->instance;
1023 if (!(instance->flag & MEGASAS_FW_BUSY)) {
1024 /* FW is busy, throttle IO */
1025 spin_lock_irqsave(instance->host->host_lock, flags);
1026
1027 instance->host->can_queue = 16;
1028 instance->last_time = jiffies;
1029 instance->flag |= MEGASAS_FW_BUSY;
1030
1031 spin_unlock_irqrestore(instance->host->host_lock, flags);
1032 }
1033 return EH_RESET_TIMER;
1034}
1035
1036/**
1003 * megasas_reset_device - Device reset handler entry point 1037 * megasas_reset_device - Device reset handler entry point
1004 */ 1038 */
1005static int megasas_reset_device(struct scsi_cmnd *scmd) 1039static int megasas_reset_device(struct scsi_cmnd *scmd)
@@ -1112,6 +1146,7 @@ static struct scsi_host_template megasas_template = {
1112 .eh_device_reset_handler = megasas_reset_device, 1146 .eh_device_reset_handler = megasas_reset_device,
1113 .eh_bus_reset_handler = megasas_reset_bus_host, 1147 .eh_bus_reset_handler = megasas_reset_bus_host,
1114 .eh_host_reset_handler = megasas_reset_bus_host, 1148 .eh_host_reset_handler = megasas_reset_bus_host,
1149 .eh_timed_out = megasas_reset_timer,
1115 .bios_param = megasas_bios_param, 1150 .bios_param = megasas_bios_param,
1116 .use_clustering = ENABLE_CLUSTERING, 1151 .use_clustering = ENABLE_CLUSTERING,
1117}; 1152};
@@ -1215,9 +1250,8 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
1215 int exception = 0; 1250 int exception = 0;
1216 struct megasas_header *hdr = &cmd->frame->hdr; 1251 struct megasas_header *hdr = &cmd->frame->hdr;
1217 1252
1218 if (cmd->scmd) { 1253 if (cmd->scmd)
1219 cmd->scmd->SCp.ptr = (char *)0; 1254 cmd->scmd->SCp.ptr = NULL;
1220 }
1221 1255
1222 switch (hdr->cmd) { 1256 switch (hdr->cmd) {
1223 1257
@@ -1806,6 +1840,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
1806 u32 context; 1840 u32 context;
1807 struct megasas_cmd *cmd; 1841 struct megasas_cmd *cmd;
1808 struct megasas_instance *instance = (struct megasas_instance *)instance_addr; 1842 struct megasas_instance *instance = (struct megasas_instance *)instance_addr;
1843 unsigned long flags;
1809 1844
1810 /* If we have already declared adapter dead, donot complete cmds */ 1845 /* If we have already declared adapter dead, donot complete cmds */
1811 if (instance->hw_crit_error) 1846 if (instance->hw_crit_error)
@@ -1828,6 +1863,22 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
1828 } 1863 }
1829 1864
1830 *instance->consumer = producer; 1865 *instance->consumer = producer;
1866
1867 /*
1868 * Check if we can restore can_queue
1869 */
1870 if (instance->flag & MEGASAS_FW_BUSY
1871 && time_after(jiffies, instance->last_time + 5 * HZ)
1872 && atomic_read(&instance->fw_outstanding) < 17) {
1873
1874 spin_lock_irqsave(instance->host->host_lock, flags);
1875 instance->flag &= ~MEGASAS_FW_BUSY;
1876 instance->host->can_queue =
1877 instance->max_fw_cmds - MEGASAS_INT_CMDS;
1878
1879 spin_unlock_irqrestore(instance->host->host_lock, flags);
1880 }
1881
1831} 1882}
1832 1883
1833/** 1884/**
@@ -2398,6 +2449,8 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2398 instance->init_id = MEGASAS_DEFAULT_INIT_ID; 2449 instance->init_id = MEGASAS_DEFAULT_INIT_ID;
2399 2450
2400 megasas_dbg_lvl = 0; 2451 megasas_dbg_lvl = 0;
2452 instance->flag = 0;
2453 instance->last_time = 0;
2401 2454
2402 /* 2455 /*
2403 * Initialize MFI Firmware 2456 * Initialize MFI Firmware
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index e862992ee377..4dffc918a414 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -18,9 +18,9 @@
18/* 18/*
19 * MegaRAID SAS Driver meta data 19 * MegaRAID SAS Driver meta data
20 */ 20 */
21#define MEGASAS_VERSION "00.00.03.10-rc1" 21#define MEGASAS_VERSION "00.00.03.10-rc5"
22#define MEGASAS_RELDATE "Feb 14, 2007" 22#define MEGASAS_RELDATE "May 17, 2007"
23#define MEGASAS_EXT_VERSION "Wed Feb 14 10:14:25 PST 2007" 23#define MEGASAS_EXT_VERSION "Thu May 17 10:09:32 PDT 2007"
24 24
25/* 25/*
26 * Device IDs 26 * Device IDs
@@ -539,6 +539,8 @@ struct megasas_ctrl_info {
539 539
540#define MEGASAS_DBG_LVL 1 540#define MEGASAS_DBG_LVL 1
541 541
542#define MEGASAS_FW_BUSY 1
543
542/* 544/*
543 * When SCSI mid-layer calls driver's reset routine, driver waits for 545 * When SCSI mid-layer calls driver's reset routine, driver waits for
544 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note 546 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
@@ -549,8 +551,8 @@ struct megasas_ctrl_info {
549#define MEGASAS_RESET_WAIT_TIME 180 551#define MEGASAS_RESET_WAIT_TIME 180
550#define MEGASAS_INTERNAL_CMD_WAIT_TIME 180 552#define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
551#define MEGASAS_RESET_NOTICE_INTERVAL 5 553#define MEGASAS_RESET_NOTICE_INTERVAL 5
552
553#define MEGASAS_IOCTL_CMD 0 554#define MEGASAS_IOCTL_CMD 0
555#define MEGASAS_DEFAULT_CMD_TIMEOUT 90
554 556
555/* 557/*
556 * FW reports the maximum of number of commands that it can accept (maximum 558 * FW reports the maximum of number of commands that it can accept (maximum
@@ -1073,7 +1075,6 @@ struct megasas_instance {
1073 struct megasas_register_set __iomem *reg_set; 1075 struct megasas_register_set __iomem *reg_set;
1074 1076
1075 s8 init_id; 1077 s8 init_id;
1076 u8 reserved[3];
1077 1078
1078 u16 max_num_sge; 1079 u16 max_num_sge;
1079 u16 max_fw_cmds; 1080 u16 max_fw_cmds;
@@ -1104,6 +1105,9 @@ struct megasas_instance {
1104 1105
1105 struct megasas_instance_template *instancet; 1106 struct megasas_instance_template *instancet;
1106 struct tasklet_struct isr_tasklet; 1107 struct tasklet_struct isr_tasklet;
1108
1109 u8 flag;
1110 unsigned long last_time;
1107}; 1111};
1108 1112
1109#define MEGASAS_IS_LOGICAL(scp) \ 1113#define MEGASAS_IS_LOGICAL(scp) \
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index 3b2e1a53e6e2..d953d43fe2e6 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -4,6 +4,7 @@
4 * 4 *
5 */ 5 */
6 6
7#include <linux/completion.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/delay.h> 9#include <linux/delay.h>
9#include <linux/types.h> 10#include <linux/types.h>
@@ -50,16 +51,10 @@ static struct ctrl_inquiry {
50} *fcs __initdata; 51} *fcs __initdata;
51static int fcscount __initdata = 0; 52static int fcscount __initdata = 0;
52static atomic_t fcss __initdata = ATOMIC_INIT(0); 53static atomic_t fcss __initdata = ATOMIC_INIT(0);
53DECLARE_MUTEX_LOCKED(fc_sem); 54static DECLARE_COMPLETION(fc_detect_complete);
54 55
55static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); 56static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd);
56 57
57static void __init pluto_detect_timeout(unsigned long data)
58{
59 PLND(("Timeout\n"))
60 up(&fc_sem);
61}
62
63static void __init pluto_detect_done(Scsi_Cmnd *SCpnt) 58static void __init pluto_detect_done(Scsi_Cmnd *SCpnt)
64{ 59{
65 /* Do nothing */ 60 /* Do nothing */
@@ -69,7 +64,7 @@ static void __init pluto_detect_scsi_done(Scsi_Cmnd *SCpnt)
69{ 64{
70 PLND(("Detect done %08lx\n", (long)SCpnt)) 65 PLND(("Detect done %08lx\n", (long)SCpnt))
71 if (atomic_dec_and_test (&fcss)) 66 if (atomic_dec_and_test (&fcss))
72 up(&fc_sem); 67 complete(&fc_detect_complete);
73} 68}
74 69
75int pluto_slave_configure(struct scsi_device *device) 70int pluto_slave_configure(struct scsi_device *device)
@@ -96,7 +91,6 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
96 int i, retry, nplutos; 91 int i, retry, nplutos;
97 fc_channel *fc; 92 fc_channel *fc;
98 struct scsi_device dev; 93 struct scsi_device dev;
99 DEFINE_TIMER(fc_timer, pluto_detect_timeout, 0, 0);
100 94
101 tpnt->proc_name = "pluto"; 95 tpnt->proc_name = "pluto";
102 fcscount = 0; 96 fcscount = 0;
@@ -187,15 +181,11 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
187 } 181 }
188 } 182 }
189 183
190 fc_timer.expires = jiffies + 10 * HZ; 184 wait_for_completion_timeout(&fc_detect_complete, 10 * HZ);
191 add_timer(&fc_timer);
192
193 down(&fc_sem);
194 PLND(("Woken up\n")) 185 PLND(("Woken up\n"))
195 if (!atomic_read(&fcss)) 186 if (!atomic_read(&fcss))
196 break; /* All fc channels have answered us */ 187 break; /* All fc channels have answered us */
197 } 188 }
198 del_timer_sync(&fc_timer);
199 189
200 PLND(("Finished search\n")) 190 PLND(("Finished search\n"))
201 for (i = 0, nplutos = 0; i < fcscount; i++) { 191 for (i = 0, nplutos = 0; i < fcscount; i++) {
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index ce63044b1ec8..18dd5cc4d7c6 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -209,6 +209,7 @@ static struct {
209 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 209 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
210 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 210 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
211 {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 211 {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
212 {"Promise", "", NULL, BLIST_SPARSELUN},
212 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, 213 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
213 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN}, 214 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
214 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */ 215 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f071b9edaf36..448d316f12d7 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1789,7 +1789,7 @@ static void sd_shutdown(struct device *dev)
1789static int sd_suspend(struct device *dev, pm_message_t mesg) 1789static int sd_suspend(struct device *dev, pm_message_t mesg)
1790{ 1790{
1791 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1791 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1792 int ret; 1792 int ret = 0;
1793 1793
1794 if (!sdkp) 1794 if (!sdkp)
1795 return 0; /* this can happen */ 1795 return 0; /* this can happen */
@@ -1798,30 +1798,34 @@ static int sd_suspend(struct device *dev, pm_message_t mesg)
1798 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 1798 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
1799 ret = sd_sync_cache(sdkp); 1799 ret = sd_sync_cache(sdkp);
1800 if (ret) 1800 if (ret)
1801 return ret; 1801 goto done;
1802 } 1802 }
1803 1803
1804 if (mesg.event == PM_EVENT_SUSPEND && 1804 if (mesg.event == PM_EVENT_SUSPEND &&
1805 sdkp->device->manage_start_stop) { 1805 sdkp->device->manage_start_stop) {
1806 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 1806 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
1807 ret = sd_start_stop_device(sdkp, 0); 1807 ret = sd_start_stop_device(sdkp, 0);
1808 if (ret)
1809 return ret;
1810 } 1808 }
1811 1809
1812 return 0; 1810done:
1811 scsi_disk_put(sdkp);
1812 return ret;
1813} 1813}
1814 1814
1815static int sd_resume(struct device *dev) 1815static int sd_resume(struct device *dev)
1816{ 1816{
1817 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1817 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1818 int ret = 0;
1818 1819
1819 if (!sdkp->device->manage_start_stop) 1820 if (!sdkp->device->manage_start_stop)
1820 return 0; 1821 goto done;
1821 1822
1822 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 1823 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
1824 ret = sd_start_stop_device(sdkp, 1);
1823 1825
1824 return sd_start_stop_device(sdkp, 1); 1826done:
1827 scsi_disk_put(sdkp);
1828 return ret;
1825} 1829}
1826 1830
1827/** 1831/**
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index baf516d09d79..adda296b594b 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -32,11 +32,12 @@
32#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
33#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
34#include <scsi/scsi_tcq.h> 34#include <scsi/scsi_tcq.h>
35#include <scsi/scsi_dbg.h>
35 36
36#define DRV_NAME "stex" 37#define DRV_NAME "stex"
37#define ST_DRIVER_VERSION "3.1.0.1" 38#define ST_DRIVER_VERSION "3.6.0000.1"
38#define ST_VER_MAJOR 3 39#define ST_VER_MAJOR 3
39#define ST_VER_MINOR 1 40#define ST_VER_MINOR 6
40#define ST_OEM 0 41#define ST_OEM 0
41#define ST_BUILD_VER 1 42#define ST_BUILD_VER 1
42 43
@@ -113,10 +114,6 @@ enum {
113 SG_CF_64B = 0x40, /* 64 bit item */ 114 SG_CF_64B = 0x40, /* 64 bit item */
114 SG_CF_HOST = 0x20, /* sg in host memory */ 115 SG_CF_HOST = 0x20, /* sg in host memory */
115 116
116 ST_MAX_ARRAY_SUPPORTED = 16,
117 ST_MAX_TARGET_NUM = (ST_MAX_ARRAY_SUPPORTED+1),
118 ST_MAX_LUN_PER_TARGET = 16,
119
120 st_shasta = 0, 117 st_shasta = 0,
121 st_vsc = 1, 118 st_vsc = 1,
122 st_vsc1 = 2, 119 st_vsc1 = 2,
@@ -561,7 +558,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
561 u16 tag; 558 u16 tag;
562 host = cmd->device->host; 559 host = cmd->device->host;
563 id = cmd->device->id; 560 id = cmd->device->id;
564 lun = cmd->device->channel; /* firmware lun issue work around */ 561 lun = cmd->device->lun;
565 hba = (struct st_hba *) &host->hostdata[0]; 562 hba = (struct st_hba *) &host->hostdata[0];
566 563
567 switch (cmd->cmnd[0]) { 564 switch (cmd->cmnd[0]) {
@@ -580,8 +577,26 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
580 stex_invalid_field(cmd, done); 577 stex_invalid_field(cmd, done);
581 return 0; 578 return 0;
582 } 579 }
580 case REPORT_LUNS:
581 /*
582 * The shasta firmware does not report actual luns in the
583 * target, so fail the command to force sequential lun scan.
584 * Also, the console device does not support this command.
585 */
586 if (hba->cardtype == st_shasta || id == host->max_id - 1) {
587 stex_invalid_field(cmd, done);
588 return 0;
589 }
590 break;
591 case TEST_UNIT_READY:
592 if (id == host->max_id - 1) {
593 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
594 done(cmd);
595 return 0;
596 }
597 break;
583 case INQUIRY: 598 case INQUIRY:
584 if (id != ST_MAX_ARRAY_SUPPORTED) 599 if (id != host->max_id - 1)
585 break; 600 break;
586 if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) { 601 if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) {
587 stex_direct_copy(cmd, console_inq_page, 602 stex_direct_copy(cmd, console_inq_page,
@@ -599,7 +614,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
599 ver.oem = ST_OEM; 614 ver.oem = ST_OEM;
600 ver.build = ST_BUILD_VER; 615 ver.build = ST_BUILD_VER;
601 ver.signature[0] = PASSTHRU_SIGNATURE; 616 ver.signature[0] = PASSTHRU_SIGNATURE;
602 ver.console_id = ST_MAX_ARRAY_SUPPORTED; 617 ver.console_id = host->max_id - 1;
603 ver.host_no = hba->host->host_no; 618 ver.host_no = hba->host->host_no;
604 cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ? 619 cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ?
605 DID_OK << 16 | COMMAND_COMPLETE << 8 : 620 DID_OK << 16 | COMMAND_COMPLETE << 8 :
@@ -620,13 +635,8 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
620 635
621 req = stex_alloc_req(hba); 636 req = stex_alloc_req(hba);
622 637
623 if (hba->cardtype == st_yosemite) { 638 req->lun = lun;
624 req->lun = lun * (ST_MAX_TARGET_NUM - 1) + id; 639 req->target = id;
625 req->target = 0;
626 } else {
627 req->lun = lun;
628 req->target = id;
629 }
630 640
631 /* cdb */ 641 /* cdb */
632 memcpy(req->cdb, cmd->cmnd, STEX_CDB_LENGTH); 642 memcpy(req->cdb, cmd->cmnd, STEX_CDB_LENGTH);
@@ -730,18 +740,6 @@ static void stex_ys_commands(struct st_hba *hba,
730 ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT; 740 ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT;
731 else 741 else
732 ccb->srb_status = SRB_STATUS_SUCCESS; 742 ccb->srb_status = SRB_STATUS_SUCCESS;
733 } else if (ccb->cmd->cmnd[0] == REPORT_LUNS) {
734 u8 *report_lun_data = (u8 *)hba->copy_buffer;
735
736 count = STEX_EXTRA_SIZE;
737 stex_internal_copy(ccb->cmd, report_lun_data,
738 &count, ccb->sg_count, ST_FROM_CMD);
739 if (report_lun_data[2] || report_lun_data[3]) {
740 report_lun_data[2] = 0x00;
741 report_lun_data[3] = 0x08;
742 stex_internal_copy(ccb->cmd, report_lun_data,
743 &count, ccb->sg_count, ST_TO_CMD);
744 }
745 } 743 }
746} 744}
747 745
@@ -958,6 +956,11 @@ static int stex_abort(struct scsi_cmnd *cmd)
958 u32 data; 956 u32 data;
959 int result = SUCCESS; 957 int result = SUCCESS;
960 unsigned long flags; 958 unsigned long flags;
959
960 printk(KERN_INFO DRV_NAME
961 "(%s): aborting command\n", pci_name(hba->pdev));
962 scsi_print_command(cmd);
963
961 base = hba->mmio_base; 964 base = hba->mmio_base;
962 spin_lock_irqsave(host->host_lock, flags); 965 spin_lock_irqsave(host->host_lock, flags);
963 if (tag < host->can_queue && hba->ccb[tag].cmd == cmd) 966 if (tag < host->can_queue && hba->ccb[tag].cmd == cmd)
@@ -1014,7 +1017,12 @@ static void stex_hard_reset(struct st_hba *hba)
1014 pci_read_config_byte(bus->self, PCI_BRIDGE_CONTROL, &pci_bctl); 1017 pci_read_config_byte(bus->self, PCI_BRIDGE_CONTROL, &pci_bctl);
1015 pci_bctl |= PCI_BRIDGE_CTL_BUS_RESET; 1018 pci_bctl |= PCI_BRIDGE_CTL_BUS_RESET;
1016 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl); 1019 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl);
1017 msleep(1); 1020
1021 /*
1022 * 1 ms may be enough for 8-port controllers. But 16-port controllers
1023 * require more time to finish bus reset. Use 100 ms here for safety
1024 */
1025 msleep(100);
1018 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET; 1026 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET;
1019 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl); 1027 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl);
1020 1028
@@ -1038,6 +1046,10 @@ static int stex_reset(struct scsi_cmnd *cmd)
1038 unsigned long before; 1046 unsigned long before;
1039 hba = (struct st_hba *) &cmd->device->host->hostdata[0]; 1047 hba = (struct st_hba *) &cmd->device->host->hostdata[0];
1040 1048
1049 printk(KERN_INFO DRV_NAME
1050 "(%s): resetting host\n", pci_name(hba->pdev));
1051 scsi_print_command(cmd);
1052
1041 hba->mu_status = MU_STATE_RESETTING; 1053 hba->mu_status = MU_STATE_RESETTING;
1042 1054
1043 if (hba->cardtype == st_shasta) 1055 if (hba->cardtype == st_shasta)
@@ -1157,7 +1169,7 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1157 goto out_scsi_host_put; 1169 goto out_scsi_host_put;
1158 } 1170 }
1159 1171
1160 hba->mmio_base = ioremap(pci_resource_start(pdev, 0), 1172 hba->mmio_base = ioremap_nocache(pci_resource_start(pdev, 0),
1161 pci_resource_len(pdev, 0)); 1173 pci_resource_len(pdev, 0));
1162 if ( !hba->mmio_base) { 1174 if ( !hba->mmio_base) {
1163 printk(KERN_ERR DRV_NAME "(%s): memory map failed\n", 1175 printk(KERN_ERR DRV_NAME "(%s): memory map failed\n",
@@ -1192,12 +1204,18 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1192 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE; 1204 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE;
1193 hba->mu_status = MU_STATE_STARTING; 1205 hba->mu_status = MU_STATE_STARTING;
1194 1206
1195 /* firmware uses id/lun pair for a logical drive, but lun would be 1207 if (hba->cardtype == st_shasta) {
1196 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use 1208 host->max_lun = 8;
1197 channel to map lun here */ 1209 host->max_id = 16 + 1;
1198 host->max_channel = ST_MAX_LUN_PER_TARGET - 1; 1210 } else if (hba->cardtype == st_yosemite) {
1199 host->max_id = ST_MAX_TARGET_NUM; 1211 host->max_lun = 128;
1200 host->max_lun = 1; 1212 host->max_id = 1 + 1;
1213 } else {
1214 /* st_vsc and st_vsc1 */
1215 host->max_lun = 1;
1216 host->max_id = 128 + 1;
1217 }
1218 host->max_channel = 0;
1201 host->unique_id = host->host_no; 1219 host->unique_id = host->host_no;
1202 host->max_cmd_len = STEX_CDB_LENGTH; 1220 host->max_cmd_len = STEX_CDB_LENGTH;
1203 1221
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 48e259a0167d..c84dab083a85 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -894,7 +894,7 @@ static void autoconfig_16550a(struct uart_8250_port *up)
894 quot = serial_dl_read(up); 894 quot = serial_dl_read(up);
895 quot <<= 3; 895 quot <<= 3;
896 896
897 status1 = serial_in(up, 0x04); /* EXCR1 */ 897 status1 = serial_in(up, 0x04); /* EXCR2 */
898 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */ 898 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
899 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */ 899 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
900 serial_outp(up, 0x04, status1); 900 serial_outp(up, 0x04, status1);
@@ -2617,7 +2617,22 @@ void serial8250_suspend_port(int line)
2617 */ 2617 */
2618void serial8250_resume_port(int line) 2618void serial8250_resume_port(int line)
2619{ 2619{
2620 uart_resume_port(&serial8250_reg, &serial8250_ports[line].port); 2620 struct uart_8250_port *up = &serial8250_ports[line];
2621
2622 if (up->capabilities & UART_NATSEMI) {
2623 unsigned char tmp;
2624
2625 /* Ensure it's still in high speed mode */
2626 serial_outp(up, UART_LCR, 0xE0);
2627
2628 tmp = serial_in(up, 0x04); /* EXCR2 */
2629 tmp &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
2630 tmp |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
2631 serial_outp(up, 0x04, tmp);
2632
2633 serial_outp(up, UART_LCR, 0);
2634 }
2635 uart_resume_port(&serial8250_reg, &up->port);
2621} 2636}
2622 2637
2623/* 2638/*
@@ -2694,7 +2709,7 @@ static int serial8250_resume(struct platform_device *dev)
2694 struct uart_8250_port *up = &serial8250_ports[i]; 2709 struct uart_8250_port *up = &serial8250_ports[i];
2695 2710
2696 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 2711 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
2697 uart_resume_port(&serial8250_reg, &up->port); 2712 serial8250_resume_port(i);
2698 } 2713 }
2699 2714
2700 return 0; 2715 return 0;
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 1a9a24b82636..00d1255e4c12 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -167,8 +167,9 @@ static void pl010_rx_chars(struct uart_amba_port *uap)
167 ignore_char: 167 ignore_char:
168 status = readb(uap->port.membase + UART01x_FR); 168 status = readb(uap->port.membase + UART01x_FR);
169 } 169 }
170 spin_unlock(&port->lock);
170 tty_flip_buffer_push(tty); 171 tty_flip_buffer_push(tty);
171 return; 172 spin_lock(&port->lock);
172} 173}
173 174
174static void pl010_tx_chars(struct uart_amba_port *uap) 175static void pl010_tx_chars(struct uart_amba_port *uap)
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 44639e71372a..954073c6ce3a 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -153,8 +153,9 @@ static void pl011_rx_chars(struct uart_amba_port *uap)
153 ignore_char: 153 ignore_char:
154 status = readw(uap->port.membase + UART01x_FR); 154 status = readw(uap->port.membase + UART01x_FR);
155 } 155 }
156 spin_unlock(&uap->port.lock);
156 tty_flip_buffer_push(tty); 157 tty_flip_buffer_push(tty);
157 return; 158 spin_lock(&uap->port.lock);
158} 159}
159 160
160static void pl011_tx_chars(struct uart_amba_port *uap) 161static void pl011_tx_chars(struct uart_amba_port *uap)
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 408390f93db9..787dc7168f3e 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -6,8 +6,6 @@
6 * Created: 6 * Created:
7 * Description: Driver for blackfin 5xx serial ports 7 * Description: Driver for blackfin 5xx serial ports
8 * 8 *
9 * Rev: $Id: bfin_5xx.c,v 1.19 2006/09/24 02:33:53 aubrey Exp $
10 *
11 * Modified: 9 * Modified:
12 * Copyright 2006 Analog Devices Inc. 10 * Copyright 2006 Analog Devices Inc.
13 * 11 *
@@ -152,7 +150,7 @@ static void local_put_char(struct bfin_serial_port *uart, char ch)
152 150
153static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 151static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
154{ 152{
155 struct tty_struct *tty = uart->port.info?uart->port.info->tty:0; 153 struct tty_struct *tty = uart->port.info->tty;
156 unsigned int status, ch, flg; 154 unsigned int status, ch, flg;
157#ifdef BF533_FAMILY 155#ifdef BF533_FAMILY
158 static int in_break = 0; 156 static int in_break = 0;
@@ -173,8 +171,10 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
173 if (ch != 0) { 171 if (ch != 0) {
174 in_break = 0; 172 in_break = 0;
175 ch = UART_GET_CHAR(uart); 173 ch = UART_GET_CHAR(uart);
176 } 174 if (bfin_revid() < 5)
177 return; 175 return;
176 } else
177 return;
178 } 178 }
179#endif 179#endif
180 180
@@ -185,27 +185,32 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
185 uart->port.icount.brk++; 185 uart->port.icount.brk++;
186 if (uart_handle_break(&uart->port)) 186 if (uart_handle_break(&uart->port))
187 goto ignore_char; 187 goto ignore_char;
188 flg = TTY_BREAK; 188 }
189 } else if (status & PE) { 189 if (status & PE)
190 flg = TTY_PARITY;
191 uart->port.icount.parity++; 190 uart->port.icount.parity++;
192 } else if (status & OE) { 191 if (status & OE)
193 flg = TTY_OVERRUN;
194 uart->port.icount.overrun++; 192 uart->port.icount.overrun++;
195 } else if (status & FE) { 193 if (status & FE)
196 flg = TTY_FRAME;
197 uart->port.icount.frame++; 194 uart->port.icount.frame++;
198 } else 195
196 status &= uart->port.read_status_mask;
197
198 if (status & BI)
199 flg = TTY_BREAK;
200 else if (status & PE)
201 flg = TTY_PARITY;
202 else if (status & FE)
203 flg = TTY_FRAME;
204 else
199 flg = TTY_NORMAL; 205 flg = TTY_NORMAL;
200 206
201 if (uart_handle_sysrq_char(&uart->port, ch)) 207 if (uart_handle_sysrq_char(&uart->port, ch))
202 goto ignore_char; 208 goto ignore_char;
203 if (tty)
204 uart_insert_char(&uart->port, status, 2, ch, flg);
205 209
206ignore_char: 210 uart_insert_char(&uart->port, status, OE, ch, flg);
207 if (tty) 211
208 tty_flip_buffer_push(tty); 212 ignore_char:
213 tty_flip_buffer_push(tty);
209} 214}
210 215
211static void bfin_serial_tx_chars(struct bfin_serial_port *uart) 216static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
@@ -240,24 +245,29 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
240 bfin_serial_stop_tx(&uart->port); 245 bfin_serial_stop_tx(&uart->port);
241} 246}
242 247
243static irqreturn_t bfin_serial_int(int irq, void *dev_id) 248static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
244{ 249{
245 struct bfin_serial_port *uart = dev_id; 250 struct bfin_serial_port *uart = dev_id;
246 unsigned short status;
247 251
248 spin_lock(&uart->port.lock); 252 spin_lock(&uart->port.lock);
249 status = UART_GET_IIR(uart); 253 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_RX_READY)
250 do { 254 bfin_serial_rx_chars(uart);
251 if ((status & IIR_STATUS) == IIR_TX_READY)
252 bfin_serial_tx_chars(uart);
253 if ((status & IIR_STATUS) == IIR_RX_READY)
254 bfin_serial_rx_chars(uart);
255 status = UART_GET_IIR(uart);
256 } while (status & (IIR_TX_READY | IIR_RX_READY));
257 spin_unlock(&uart->port.lock); 255 spin_unlock(&uart->port.lock);
258 return IRQ_HANDLED; 256 return IRQ_HANDLED;
259} 257}
260 258
259static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
260{
261 struct bfin_serial_port *uart = dev_id;
262
263 spin_lock(&uart->port.lock);
264 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_TX_READY)
265 bfin_serial_tx_chars(uart);
266 spin_unlock(&uart->port.lock);
267 return IRQ_HANDLED;
268}
269
270
261static void bfin_serial_do_work(struct work_struct *work) 271static void bfin_serial_do_work(struct work_struct *work)
262{ 272{
263 struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue); 273 struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue);
@@ -319,7 +329,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
319 spin_unlock_irqrestore(&uart->port.lock, flags); 329 spin_unlock_irqrestore(&uart->port.lock, flags);
320} 330}
321 331
322static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart) 332static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
323{ 333{
324 struct tty_struct *tty = uart->port.info->tty; 334 struct tty_struct *tty = uart->port.info->tty;
325 int i, flg, status; 335 int i, flg, status;
@@ -331,25 +341,32 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart)
331 uart->port.icount.brk++; 341 uart->port.icount.brk++;
332 if (uart_handle_break(&uart->port)) 342 if (uart_handle_break(&uart->port))
333 goto dma_ignore_char; 343 goto dma_ignore_char;
334 flg = TTY_BREAK; 344 }
335 } else if (status & PE) { 345 if (status & PE)
336 flg = TTY_PARITY;
337 uart->port.icount.parity++; 346 uart->port.icount.parity++;
338 } else if (status & OE) { 347 if (status & OE)
339 flg = TTY_OVERRUN;
340 uart->port.icount.overrun++; 348 uart->port.icount.overrun++;
341 } else if (status & FE) { 349 if (status & FE)
342 flg = TTY_FRAME;
343 uart->port.icount.frame++; 350 uart->port.icount.frame++;
344 } else 351
352 status &= uart->port.read_status_mask;
353
354 if (status & BI)
355 flg = TTY_BREAK;
356 else if (status & PE)
357 flg = TTY_PARITY;
358 else if (status & FE)
359 flg = TTY_FRAME;
360 else
345 flg = TTY_NORMAL; 361 flg = TTY_NORMAL;
346 362
347 for (i = uart->rx_dma_buf.head; i < uart->rx_dma_buf.tail; i++) { 363 for (i = uart->rx_dma_buf.head; i < uart->rx_dma_buf.tail; i++) {
348 if (uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i])) 364 if (uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
349 goto dma_ignore_char; 365 goto dma_ignore_char;
350 uart_insert_char(&uart->port, status, 2, uart->rx_dma_buf.buf[i], flg); 366 uart_insert_char(&uart->port, status, OE, uart->rx_dma_buf.buf[i], flg);
351 } 367 }
352dma_ignore_char: 368
369 dma_ignore_char:
353 tty_flip_buffer_push(tty); 370 tty_flip_buffer_push(tty);
354} 371}
355 372
@@ -545,14 +562,14 @@ static int bfin_serial_startup(struct uart_port *port)
545 add_timer(&(uart->rx_dma_timer)); 562 add_timer(&(uart->rx_dma_timer));
546#else 563#else
547 if (request_irq 564 if (request_irq
548 (uart->port.irq, bfin_serial_int, IRQF_DISABLED, 565 (uart->port.irq, bfin_serial_rx_int, IRQF_DISABLED,
549 "BFIN_UART_RX", uart)) { 566 "BFIN_UART_RX", uart)) {
550 printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n"); 567 printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n");
551 return -EBUSY; 568 return -EBUSY;
552 } 569 }
553 570
554 if (request_irq 571 if (request_irq
555 (uart->port.irq+1, bfin_serial_int, IRQF_DISABLED, 572 (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED,
556 "BFIN_UART_TX", uart)) { 573 "BFIN_UART_TX", uart)) {
557 printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n"); 574 printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n");
558 free_irq(uart->port.irq, uart); 575 free_irq(uart->port.irq, uart);
@@ -614,13 +631,27 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
614 lcr |= EPS; 631 lcr |= EPS;
615 } 632 }
616 633
617 /* These controls are not implemented for this port */ 634 port->read_status_mask = OE;
618 termios->c_iflag |= INPCK | BRKINT | PARMRK; 635 if (termios->c_iflag & INPCK)
619 termios->c_iflag &= ~(IGNPAR | IGNBRK); 636 port->read_status_mask |= (FE | PE);
637 if (termios->c_iflag & (BRKINT | PARMRK))
638 port->read_status_mask |= BI;
620 639
621 /* These controls are not implemented for this port */ 640 /*
622 termios->c_iflag |= INPCK | BRKINT | PARMRK; 641 * Characters to ignore
623 termios->c_iflag &= ~(IGNPAR | IGNBRK); 642 */
643 port->ignore_status_mask = 0;
644 if (termios->c_iflag & IGNPAR)
645 port->ignore_status_mask |= FE | PE;
646 if (termios->c_iflag & IGNBRK) {
647 port->ignore_status_mask |= BI;
648 /*
649 * If we're ignoring parity and break indicators,
650 * ignore overruns too (for real raw support).
651 */
652 if (termios->c_iflag & IGNPAR)
653 port->ignore_status_mask |= OE;
654 }
624 655
625 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 656 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
626 quot = uart_get_divisor(port, baud); 657 quot = uart_get_divisor(port, baud);
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 6202995e8211..9d3105b64a7a 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -69,33 +69,40 @@
69 69
70static const struct pci_device_id icom_pci_table[] = { 70static const struct pci_device_id icom_pci_table[] = {
71 { 71 {
72 .vendor = PCI_VENDOR_ID_IBM, 72 .vendor = PCI_VENDOR_ID_IBM,
73 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1, 73 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1,
74 .subvendor = PCI_ANY_ID, 74 .subvendor = PCI_ANY_ID,
75 .subdevice = PCI_ANY_ID, 75 .subdevice = PCI_ANY_ID,
76 .driver_data = ADAPTER_V1, 76 .driver_data = ADAPTER_V1,
77 }, 77 },
78 { 78 {
79 .vendor = PCI_VENDOR_ID_IBM, 79 .vendor = PCI_VENDOR_ID_IBM,
80 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2, 80 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
81 .subvendor = PCI_VENDOR_ID_IBM, 81 .subvendor = PCI_VENDOR_ID_IBM,
82 .subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX, 82 .subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX,
83 .driver_data = ADAPTER_V2, 83 .driver_data = ADAPTER_V2,
84 }, 84 },
85 { 85 {
86 .vendor = PCI_VENDOR_ID_IBM, 86 .vendor = PCI_VENDOR_ID_IBM,
87 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2, 87 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
88 .subvendor = PCI_VENDOR_ID_IBM, 88 .subvendor = PCI_VENDOR_ID_IBM,
89 .subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM, 89 .subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM,
90 .driver_data = ADAPTER_V2, 90 .driver_data = ADAPTER_V2,
91 }, 91 },
92 { 92 {
93 .vendor = PCI_VENDOR_ID_IBM, 93 .vendor = PCI_VENDOR_ID_IBM,
94 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2, 94 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
95 .subvendor = PCI_VENDOR_ID_IBM, 95 .subvendor = PCI_VENDOR_ID_IBM,
96 .subdevice = PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL, 96 .subdevice = PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL,
97 .driver_data = ADAPTER_V2, 97 .driver_data = ADAPTER_V2,
98 }, 98 },
99 {
100 .vendor = PCI_VENDOR_ID_IBM,
101 .device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
102 .subvendor = PCI_VENDOR_ID_IBM,
103 .subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM_PCIE,
104 .driver_data = ADAPTER_V2,
105 },
99 {} 106 {}
100}; 107};
101 108
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c
index c5346d677315..8721afe1ae4f 100644
--- a/drivers/serial/serial_ks8695.c
+++ b/drivers/serial/serial_ks8695.c
@@ -301,11 +301,11 @@ static int ks8695uart_startup(struct uart_port *port)
301 301
302 retval = request_irq(KS8695_IRQ_UART_LINE_STATUS, ks8695uart_rx_chars, IRQF_DISABLED, "UART LineStatus", port); 302 retval = request_irq(KS8695_IRQ_UART_LINE_STATUS, ks8695uart_rx_chars, IRQF_DISABLED, "UART LineStatus", port);
303 if (retval) 303 if (retval)
304 return err_ls; 304 goto err_ls;
305 305
306 retval = request_irq(KS8695_IRQ_UART_MODEM_STATUS, ks8695uart_modem_status, IRQF_DISABLED, "UART ModemStatus", port); 306 retval = request_irq(KS8695_IRQ_UART_MODEM_STATUS, ks8695uart_modem_status, IRQF_DISABLED, "UART ModemStatus", port);
307 if (retval) 307 if (retval)
308 return err_ms; 308 goto err_ms;
309 309
310 return 0; 310 return 0;
311 311
@@ -589,7 +589,7 @@ static int __init ks8695_console_setup(struct console *co, char *options)
589 return uart_set_options(port, co, baud, parity, bits, flow); 589 return uart_set_options(port, co, baud, parity, bits, flow);
590} 590}
591 591
592extern struct uart_driver ks8695_reg; 592static struct uart_driver ks8695_reg;
593 593
594static struct console ks8695_console = { 594static struct console ks8695_console = {
595 .name = SERIAL_KS8695_DEVNAME, 595 .name = SERIAL_KS8695_DEVNAME,
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c
index e35d9ab359f1..b45ba5392dd3 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/serial/suncore.c
@@ -30,9 +30,9 @@ void
30sunserial_console_termios(struct console *con) 30sunserial_console_termios(struct console *con)
31{ 31{
32 char mode[16], buf[16], *s; 32 char mode[16], buf[16], *s;
33 char *mode_prop = "ttyX-mode"; 33 char mode_prop[] = "ttyX-mode";
34 char *cd_prop = "ttyX-ignore-cd"; 34 char cd_prop[] = "ttyX-ignore-cd";
35 char *dtr_prop = "ttyX-rts-dtr-off"; 35 char dtr_prop[] = "ttyX-rts-dtr-off";
36 char *ssp_console_modes_prop = "ssp-console-modes"; 36 char *ssp_console_modes_prop = "ssp-console-modes";
37 int baud, bits, stop, cflag; 37 int baud, bits, stop, cflag;
38 char parity; 38 char parity;
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c
index c3a6bd2e7950..96557e6dba60 100644
--- a/drivers/serial/sunhv.c
+++ b/drivers/serial/sunhv.c
@@ -1,6 +1,6 @@
1/* sunhv.c: Serial driver for SUN4V hypervisor console. 1/* sunhv.c: Serial driver for SUN4V hypervisor console.
2 * 2 *
3 * Copyright (C) 2006 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -35,57 +35,51 @@
35#define CON_BREAK ((long)-1) 35#define CON_BREAK ((long)-1)
36#define CON_HUP ((long)-2) 36#define CON_HUP ((long)-2)
37 37
38static inline long hypervisor_con_getchar(long *status) 38#define IGNORE_BREAK 0x1
39{ 39#define IGNORE_ALL 0x2
40 register unsigned long func asm("%o5");
41 register unsigned long arg0 asm("%o0");
42 register unsigned long arg1 asm("%o1");
43
44 func = HV_FAST_CONS_GETCHAR;
45 arg0 = 0;
46 arg1 = 0;
47 __asm__ __volatile__("ta %6"
48 : "=&r" (func), "=&r" (arg0), "=&r" (arg1)
49 : "0" (func), "1" (arg0), "2" (arg1),
50 "i" (HV_FAST_TRAP));
51 40
52 *status = arg0; 41static char *con_write_page;
42static char *con_read_page;
53 43
54 return (long) arg1; 44static int hung_up = 0;
55}
56 45
57static inline long hypervisor_con_putchar(long ch) 46static void transmit_chars_putchar(struct uart_port *port, struct circ_buf *xmit)
58{ 47{
59 register unsigned long func asm("%o5"); 48 while (!uart_circ_empty(xmit)) {
60 register unsigned long arg0 asm("%o0"); 49 long status = sun4v_con_putchar(xmit->buf[xmit->tail]);
61 50
62 func = HV_FAST_CONS_PUTCHAR; 51 if (status != HV_EOK)
63 arg0 = ch; 52 break;
64 __asm__ __volatile__("ta %4"
65 : "=&r" (func), "=&r" (arg0)
66 : "0" (func), "1" (arg0), "i" (HV_FAST_TRAP));
67 53
68 return (long) arg0; 54 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
55 port->icount.tx++;
56 }
69} 57}
70 58
71#define IGNORE_BREAK 0x1 59static void transmit_chars_write(struct uart_port *port, struct circ_buf *xmit)
72#define IGNORE_ALL 0x2 60{
61 while (!uart_circ_empty(xmit)) {
62 unsigned long ra = __pa(xmit->buf + xmit->tail);
63 unsigned long len, status, sent;
73 64
74static int hung_up = 0; 65 len = CIRC_CNT_TO_END(xmit->head, xmit->tail,
66 UART_XMIT_SIZE);
67 status = sun4v_con_write(ra, len, &sent);
68 if (status != HV_EOK)
69 break;
70 xmit->tail = (xmit->tail + sent) & (UART_XMIT_SIZE - 1);
71 port->icount.tx += sent;
72 }
73}
75 74
76static struct tty_struct *receive_chars(struct uart_port *port) 75static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty)
77{ 76{
78 struct tty_struct *tty = NULL;
79 int saw_console_brk = 0; 77 int saw_console_brk = 0;
80 int limit = 10000; 78 int limit = 10000;
81 79
82 if (port->info != NULL) /* Unopened serial console */
83 tty = port->info->tty;
84
85 while (limit-- > 0) { 80 while (limit-- > 0) {
86 long status; 81 long status;
87 long c = hypervisor_con_getchar(&status); 82 long c = sun4v_con_getchar(&status);
88 unsigned char flag;
89 83
90 if (status == HV_EWOULDBLOCK) 84 if (status == HV_EWOULDBLOCK)
91 break; 85 break;
@@ -110,27 +104,90 @@ static struct tty_struct *receive_chars(struct uart_port *port)
110 continue; 104 continue;
111 } 105 }
112 106
113 flag = TTY_NORMAL;
114 port->icount.rx++; 107 port->icount.rx++;
115 if (c == CON_BREAK) {
116 port->icount.brk++;
117 if (uart_handle_break(port))
118 continue;
119 flag = TTY_BREAK;
120 }
121 108
122 if (uart_handle_sysrq_char(port, c)) 109 if (uart_handle_sysrq_char(port, c))
123 continue; 110 continue;
124 111
125 if ((port->ignore_status_mask & IGNORE_ALL) || 112 tty_insert_flip_char(tty, c, TTY_NORMAL);
126 ((port->ignore_status_mask & IGNORE_BREAK) && 113 }
127 (c == CON_BREAK))) 114
115 return saw_console_brk;
116}
117
118static int receive_chars_read(struct uart_port *port, struct tty_struct *tty)
119{
120 int saw_console_brk = 0;
121 int limit = 10000;
122
123 while (limit-- > 0) {
124 unsigned long ra = __pa(con_read_page);
125 unsigned long bytes_read, i;
126 long stat = sun4v_con_read(ra, PAGE_SIZE, &bytes_read);
127
128 if (stat != HV_EOK) {
129 bytes_read = 0;
130
131 if (stat == CON_BREAK) {
132 if (uart_handle_break(port))
133 continue;
134 saw_console_brk = 1;
135 *con_read_page = 0;
136 bytes_read = 1;
137 } else if (stat == CON_HUP) {
138 hung_up = 1;
139 uart_handle_dcd_change(port, 0);
140 continue;
141 } else {
142 /* HV_EWOULDBLOCK, etc. */
143 break;
144 }
145 }
146
147 if (hung_up) {
148 hung_up = 0;
149 uart_handle_dcd_change(port, 1);
150 }
151
152 for (i = 0; i < bytes_read; i++)
153 uart_handle_sysrq_char(port, con_read_page[i]);
154
155 if (tty == NULL)
128 continue; 156 continue;
129 157
130 tty_insert_flip_char(tty, c, flag); 158 port->icount.rx += bytes_read;
159
160 tty_insert_flip_string(tty, con_read_page, bytes_read);
131 } 161 }
132 162
133 if (saw_console_brk) 163 return saw_console_brk;
164}
165
166struct sunhv_ops {
167 void (*transmit_chars)(struct uart_port *port, struct circ_buf *xmit);
168 int (*receive_chars)(struct uart_port *port, struct tty_struct *tty);
169};
170
171static struct sunhv_ops bychar_ops = {
172 .transmit_chars = transmit_chars_putchar,
173 .receive_chars = receive_chars_getchar,
174};
175
176static struct sunhv_ops bywrite_ops = {
177 .transmit_chars = transmit_chars_write,
178 .receive_chars = receive_chars_read,
179};
180
181static struct sunhv_ops *sunhv_ops = &bychar_ops;
182
183static struct tty_struct *receive_chars(struct uart_port *port)
184{
185 struct tty_struct *tty = NULL;
186
187 if (port->info != NULL) /* Unopened serial console */
188 tty = port->info->tty;
189
190 if (sunhv_ops->receive_chars(port, tty))
134 sun_do_break(); 191 sun_do_break();
135 192
136 return tty; 193 return tty;
@@ -147,15 +204,7 @@ static void transmit_chars(struct uart_port *port)
147 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) 204 if (uart_circ_empty(xmit) || uart_tx_stopped(port))
148 return; 205 return;
149 206
150 while (!uart_circ_empty(xmit)) { 207 sunhv_ops->transmit_chars(port, xmit);
151 long status = hypervisor_con_putchar(xmit->buf[xmit->tail]);
152
153 if (status != HV_EOK)
154 break;
155
156 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
157 port->icount.tx++;
158 }
159 208
160 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 209 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
161 uart_write_wakeup(port); 210 uart_write_wakeup(port);
@@ -212,7 +261,7 @@ static void sunhv_start_tx(struct uart_port *port)
212 struct circ_buf *xmit = &port->info->xmit; 261 struct circ_buf *xmit = &port->info->xmit;
213 262
214 while (!uart_circ_empty(xmit)) { 263 while (!uart_circ_empty(xmit)) {
215 long status = hypervisor_con_putchar(xmit->buf[xmit->tail]); 264 long status = sun4v_con_putchar(xmit->buf[xmit->tail]);
216 265
217 if (status != HV_EOK) 266 if (status != HV_EOK)
218 break; 267 break;
@@ -231,9 +280,10 @@ static void sunhv_send_xchar(struct uart_port *port, char ch)
231 spin_lock_irqsave(&port->lock, flags); 280 spin_lock_irqsave(&port->lock, flags);
232 281
233 while (limit-- > 0) { 282 while (limit-- > 0) {
234 long status = hypervisor_con_putchar(ch); 283 long status = sun4v_con_putchar(ch);
235 if (status == HV_EOK) 284 if (status == HV_EOK)
236 break; 285 break;
286 udelay(1);
237 } 287 }
238 288
239 spin_unlock_irqrestore(&port->lock, flags); 289 spin_unlock_irqrestore(&port->lock, flags);
@@ -254,15 +304,15 @@ static void sunhv_break_ctl(struct uart_port *port, int break_state)
254{ 304{
255 if (break_state) { 305 if (break_state) {
256 unsigned long flags; 306 unsigned long flags;
257 int limit = 1000000; 307 int limit = 10000;
258 308
259 spin_lock_irqsave(&port->lock, flags); 309 spin_lock_irqsave(&port->lock, flags);
260 310
261 while (limit-- > 0) { 311 while (limit-- > 0) {
262 long status = hypervisor_con_putchar(CON_BREAK); 312 long status = sun4v_con_putchar(CON_BREAK);
263 if (status == HV_EOK) 313 if (status == HV_EOK)
264 break; 314 break;
265 udelay(2); 315 udelay(1);
266 } 316 }
267 317
268 spin_unlock_irqrestore(&port->lock, flags); 318 spin_unlock_irqrestore(&port->lock, flags);
@@ -359,38 +409,99 @@ static struct uart_driver sunhv_reg = {
359 409
360static struct uart_port *sunhv_port; 410static struct uart_port *sunhv_port;
361 411
362static inline void sunhv_console_putchar(struct uart_port *port, char c) 412/* Copy 's' into the con_write_page, decoding "\n" into
413 * "\r\n" along the way. We have to return two lengths
414 * because the caller needs to know how much to advance
415 * 's' and also how many bytes to output via con_write_page.
416 */
417static int fill_con_write_page(const char *s, unsigned int n,
418 unsigned long *page_bytes)
419{
420 const char *orig_s = s;
421 char *p = con_write_page;
422 int left = PAGE_SIZE;
423
424 while (n--) {
425 if (*s == '\n') {
426 if (left < 2)
427 break;
428 *p++ = '\r';
429 left--;
430 } else if (left < 1)
431 break;
432 *p++ = *s++;
433 left--;
434 }
435 *page_bytes = p - con_write_page;
436 return s - orig_s;
437}
438
439static void sunhv_console_write_paged(struct console *con, const char *s, unsigned n)
363{ 440{
441 struct uart_port *port = sunhv_port;
364 unsigned long flags; 442 unsigned long flags;
365 int limit = 1000000;
366 443
367 spin_lock_irqsave(&port->lock, flags); 444 spin_lock_irqsave(&port->lock, flags);
445 while (n > 0) {
446 unsigned long ra = __pa(con_write_page);
447 unsigned long page_bytes;
448 unsigned int cpy = fill_con_write_page(s, n,
449 &page_bytes);
450
451 n -= cpy;
452 s += cpy;
453 while (page_bytes > 0) {
454 unsigned long written;
455 int limit = 1000000;
456
457 while (limit--) {
458 unsigned long stat;
459
460 stat = sun4v_con_write(ra, page_bytes,
461 &written);
462 if (stat == HV_EOK)
463 break;
464 udelay(1);
465 }
466 if (limit <= 0)
467 break;
468 page_bytes -= written;
469 ra += written;
470 }
471 }
472 spin_unlock_irqrestore(&port->lock, flags);
473}
474
475static inline void sunhv_console_putchar(struct uart_port *port, char c)
476{
477 int limit = 1000000;
368 478
369 while (limit-- > 0) { 479 while (limit-- > 0) {
370 long status = hypervisor_con_putchar(c); 480 long status = sun4v_con_putchar(c);
371 if (status == HV_EOK) 481 if (status == HV_EOK)
372 break; 482 break;
373 udelay(2); 483 udelay(1);
374 } 484 }
375
376 spin_unlock_irqrestore(&port->lock, flags);
377} 485}
378 486
379static void sunhv_console_write(struct console *con, const char *s, unsigned n) 487static void sunhv_console_write_bychar(struct console *con, const char *s, unsigned n)
380{ 488{
381 struct uart_port *port = sunhv_port; 489 struct uart_port *port = sunhv_port;
490 unsigned long flags;
382 int i; 491 int i;
383 492
493 spin_lock_irqsave(&port->lock, flags);
384 for (i = 0; i < n; i++) { 494 for (i = 0; i < n; i++) {
385 if (*s == '\n') 495 if (*s == '\n')
386 sunhv_console_putchar(port, '\r'); 496 sunhv_console_putchar(port, '\r');
387 sunhv_console_putchar(port, *s++); 497 sunhv_console_putchar(port, *s++);
388 } 498 }
499 spin_unlock_irqrestore(&port->lock, flags);
389} 500}
390 501
391static struct console sunhv_console = { 502static struct console sunhv_console = {
392 .name = "ttyHV", 503 .name = "ttyHV",
393 .write = sunhv_console_write, 504 .write = sunhv_console_write_bychar,
394 .device = uart_console_device, 505 .device = uart_console_device,
395 .flags = CON_PRINTBUFFER, 506 .flags = CON_PRINTBUFFER,
396 .index = -1, 507 .index = -1,
@@ -410,6 +521,7 @@ static inline struct console *SUNHV_CONSOLE(void)
410static int __devinit hv_probe(struct of_device *op, const struct of_device_id *match) 521static int __devinit hv_probe(struct of_device *op, const struct of_device_id *match)
411{ 522{
412 struct uart_port *port; 523 struct uart_port *port;
524 unsigned long minor;
413 int err; 525 int err;
414 526
415 if (op->irqs[0] == 0xffffffff) 527 if (op->irqs[0] == 0xffffffff)
@@ -419,6 +531,22 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m
419 if (unlikely(!port)) 531 if (unlikely(!port))
420 return -ENOMEM; 532 return -ENOMEM;
421 533
534 minor = 1;
535 if (sun4v_hvapi_register(HV_GRP_CORE, 1, &minor) == 0 &&
536 minor >= 1) {
537 err = -ENOMEM;
538 con_write_page = kzalloc(PAGE_SIZE, GFP_KERNEL);
539 if (!con_write_page)
540 goto out_free_port;
541
542 con_read_page = kzalloc(PAGE_SIZE, GFP_KERNEL);
543 if (!con_read_page)
544 goto out_free_con_write_page;
545
546 sunhv_console.write = sunhv_console_write_paged;
547 sunhv_ops = &bywrite_ops;
548 }
549
422 sunhv_port = port; 550 sunhv_port = port;
423 551
424 port->line = 0; 552 port->line = 0;
@@ -437,7 +565,7 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m
437 565
438 err = uart_register_driver(&sunhv_reg); 566 err = uart_register_driver(&sunhv_reg);
439 if (err) 567 if (err)
440 goto out_free_port; 568 goto out_free_con_read_page;
441 569
442 sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64; 570 sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64;
443 sunserial_current_minor += 1; 571 sunserial_current_minor += 1;
@@ -463,6 +591,12 @@ out_unregister_driver:
463 sunserial_current_minor -= 1; 591 sunserial_current_minor -= 1;
464 uart_unregister_driver(&sunhv_reg); 592 uart_unregister_driver(&sunhv_reg);
465 593
594out_free_con_read_page:
595 kfree(con_read_page);
596
597out_free_con_write_page:
598 kfree(con_write_page);
599
466out_free_port: 600out_free_port:
467 kfree(port); 601 kfree(port);
468 sunhv_port = NULL; 602 sunhv_port = NULL;
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 0985193dc57d..15b6e1cb040b 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1239,7 +1239,7 @@ static inline struct console *SUNZILOG_CONSOLE(void)
1239#define SUNZILOG_CONSOLE() (NULL) 1239#define SUNZILOG_CONSOLE() (NULL)
1240#endif 1240#endif
1241 1241
1242static void __init sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channel) 1242static void __devinit sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channel)
1243{ 1243{
1244 int baud, brg; 1244 int baud, brg;
1245 1245
@@ -1259,7 +1259,7 @@ static void __init sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channe
1259} 1259}
1260 1260
1261#ifdef CONFIG_SERIO 1261#ifdef CONFIG_SERIO
1262static void __init sunzilog_register_serio(struct uart_sunzilog_port *up) 1262static void __devinit sunzilog_register_serio(struct uart_sunzilog_port *up)
1263{ 1263{
1264 struct serio *serio = &up->serio; 1264 struct serio *serio = &up->serio;
1265 1265
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 052359fc41ee..11f36bef3057 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -329,8 +329,8 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps)
329 int ret = 0; 329 int ret = 0;
330 330
331#if defined(CONFIG_PPC_MERGE) 331#if defined(CONFIG_PPC_MERGE)
332 cdm = mpc52xx_find_and_map("mpc52xx-cdm"); 332 cdm = mpc52xx_find_and_map("mpc5200-cdm");
333 gpio = mpc52xx_find_and_map("mpc52xx-gpio"); 333 gpio = mpc52xx_find_and_map("mpc5200-gpio");
334#else 334#else
335 cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE); 335 cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
336 gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE); 336 gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
@@ -445,9 +445,6 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
445 struct spi_master *master; 445 struct spi_master *master;
446 int ret; 446 int ret;
447 447
448 if (pdata == NULL)
449 return -ENODEV;
450
451 master = spi_alloc_master(dev, sizeof *mps); 448 master = spi_alloc_master(dev, sizeof *mps);
452 if (master == NULL) 449 if (master == NULL)
453 return -ENOMEM; 450 return -ENOMEM;
@@ -594,17 +591,17 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
594 } 591 }
595 regaddr64 = of_translate_address(op->node, regaddr_p); 592 regaddr64 = of_translate_address(op->node, regaddr_p);
596 593
594 /* get PSC id (1..6, used by port_config) */
597 if (op->dev.platform_data == NULL) { 595 if (op->dev.platform_data == NULL) {
598 struct device_node *np; 596 const u32 *psc_nump;
599 int i = 0;
600 597
601 for_each_node_by_type(np, "spi") { 598 psc_nump = of_get_property(op->node, "cell-index", NULL);
602 if (of_find_device_by_node(np) == op) { 599 if (!psc_nump || *psc_nump > 5) {
603 id = i; 600 printk(KERN_ERR "mpc52xx_psc_spi: Device node %s has invalid "
604 break; 601 "cell-index property\n", op->node->full_name);
605 } 602 return -EINVAL;
606 i++;
607 } 603 }
604 id = *psc_nump + 1;
608 } 605 }
609 606
610 return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, 607 return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
@@ -617,7 +614,7 @@ static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op)
617} 614}
618 615
619static struct of_device_id mpc52xx_psc_spi_of_match[] = { 616static struct of_device_id mpc52xx_psc_spi_of_match[] = {
620 { .type = "spi", .compatible = "mpc52xx-psc-spi", }, 617 { .type = "spi", .compatible = "mpc5200-psc-spi", },
621 {}, 618 {},
622}; 619};
623 620
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index 96f62b2df300..95183e1df525 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -358,11 +358,11 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
358 switch (spi->mode & (SPI_CPOL | SPI_CPHA)) { 358 switch (spi->mode & (SPI_CPOL | SPI_CPHA)) {
359 case SPI_MODE_0: 359 case SPI_MODE_0:
360 case SPI_MODE_3: 360 case SPI_MODE_3:
361 flags |= UWIRE_WRITE_RISING_EDGE | UWIRE_READ_FALLING_EDGE; 361 flags |= UWIRE_WRITE_FALLING_EDGE | UWIRE_READ_RISING_EDGE;
362 break; 362 break;
363 case SPI_MODE_1: 363 case SPI_MODE_1:
364 case SPI_MODE_2: 364 case SPI_MODE_2:
365 flags |= UWIRE_WRITE_FALLING_EDGE | UWIRE_READ_RISING_EDGE; 365 flags |= UWIRE_WRITE_RISING_EDGE | UWIRE_READ_FALLING_EDGE;
366 break; 366 break;
367 } 367 }
368 368
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index ce3c0ce2316e..7d2d9ec6cac3 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -126,7 +126,7 @@ struct chip_data {
126 126
127 u8 chip_select_num; 127 u8 chip_select_num;
128 u8 n_bytes; 128 u8 n_bytes;
129 u32 width; /* 0 or 1 */ 129 u8 width; /* 0 or 1 */
130 u8 enable_dma; 130 u8 enable_dma;
131 u8 bits_per_word; /* 8 or 16 */ 131 u8 bits_per_word; /* 8 or 16 */
132 u8 cs_change_per_word; 132 u8 cs_change_per_word;
@@ -136,7 +136,7 @@ struct chip_data {
136 void (*duplex) (struct driver_data *); 136 void (*duplex) (struct driver_data *);
137}; 137};
138 138
139void bfin_spi_enable(struct driver_data *drv_data) 139static void bfin_spi_enable(struct driver_data *drv_data)
140{ 140{
141 u16 cr; 141 u16 cr;
142 142
@@ -145,7 +145,7 @@ void bfin_spi_enable(struct driver_data *drv_data)
145 SSYNC(); 145 SSYNC();
146} 146}
147 147
148void bfin_spi_disable(struct driver_data *drv_data) 148static void bfin_spi_disable(struct driver_data *drv_data)
149{ 149{
150 u16 cr; 150 u16 cr;
151 151
@@ -163,9 +163,6 @@ static u16 hz_to_spi_baud(u32 speed_hz)
163 if ((sclk % (2 * speed_hz)) > 0) 163 if ((sclk % (2 * speed_hz)) > 0)
164 spi_baud++; 164 spi_baud++;
165 165
166 pr_debug("sclk = %ld, speed_hz = %d, spi_baud = %d\n", sclk, speed_hz,
167 spi_baud);
168
169 return spi_baud; 166 return spi_baud;
170} 167}
171 168
@@ -190,11 +187,12 @@ static void restore_state(struct driver_data *drv_data)
190 /* Clear status and disable clock */ 187 /* Clear status and disable clock */
191 write_STAT(BIT_STAT_CLR); 188 write_STAT(BIT_STAT_CLR);
192 bfin_spi_disable(drv_data); 189 bfin_spi_disable(drv_data);
193 pr_debug("restoring spi ctl state\n"); 190 dev_dbg(&drv_data->pdev->dev, "restoring spi ctl state\n");
194 191
195#if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537) 192#if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537)
196 pr_debug("chip select number is %d\n", chip->chip_select_num); 193 dev_dbg(&drv_data->pdev->dev,
197 194 "chip select number is %d\n", chip->chip_select_num);
195
198 switch (chip->chip_select_num) { 196 switch (chip->chip_select_num) {
199 case 1: 197 case 1:
200 bfin_write_PORTF_FER(bfin_read_PORTF_FER() | 0x3c00); 198 bfin_write_PORTF_FER(bfin_read_PORTF_FER() | 0x3c00);
@@ -280,7 +278,8 @@ static void null_reader(struct driver_data *drv_data)
280 278
281static void u8_writer(struct driver_data *drv_data) 279static void u8_writer(struct driver_data *drv_data)
282{ 280{
283 pr_debug("cr8-s is 0x%x\n", read_STAT()); 281 dev_dbg(&drv_data->pdev->dev,
282 "cr8-s is 0x%x\n", read_STAT());
284 while (drv_data->tx < drv_data->tx_end) { 283 while (drv_data->tx < drv_data->tx_end) {
285 write_TDBR(*(u8 *) (drv_data->tx)); 284 write_TDBR(*(u8 *) (drv_data->tx));
286 while (read_STAT() & BIT_STAT_TXS) 285 while (read_STAT() & BIT_STAT_TXS)
@@ -318,7 +317,8 @@ static void u8_cs_chg_writer(struct driver_data *drv_data)
318 317
319static void u8_reader(struct driver_data *drv_data) 318static void u8_reader(struct driver_data *drv_data)
320{ 319{
321 pr_debug("cr-8 is 0x%x\n", read_STAT()); 320 dev_dbg(&drv_data->pdev->dev,
321 "cr-8 is 0x%x\n", read_STAT());
322 322
323 /* clear TDBR buffer before read(else it will be shifted out) */ 323 /* clear TDBR buffer before read(else it will be shifted out) */
324 write_TDBR(0xFFFF); 324 write_TDBR(0xFFFF);
@@ -404,7 +404,9 @@ static void u8_cs_chg_duplex(struct driver_data *drv_data)
404 404
405static void u16_writer(struct driver_data *drv_data) 405static void u16_writer(struct driver_data *drv_data)
406{ 406{
407 pr_debug("cr16 is 0x%x\n", read_STAT()); 407 dev_dbg(&drv_data->pdev->dev,
408 "cr16 is 0x%x\n", read_STAT());
409
408 while (drv_data->tx < drv_data->tx_end) { 410 while (drv_data->tx < drv_data->tx_end) {
409 write_TDBR(*(u16 *) (drv_data->tx)); 411 write_TDBR(*(u16 *) (drv_data->tx));
410 while ((read_STAT() & BIT_STAT_TXS)) 412 while ((read_STAT() & BIT_STAT_TXS))
@@ -442,7 +444,8 @@ static void u16_cs_chg_writer(struct driver_data *drv_data)
442 444
443static void u16_reader(struct driver_data *drv_data) 445static void u16_reader(struct driver_data *drv_data)
444{ 446{
445 pr_debug("cr-16 is 0x%x\n", read_STAT()); 447 dev_dbg(&drv_data->pdev->dev,
448 "cr-16 is 0x%x\n", read_STAT());
446 dummy_read(); 449 dummy_read();
447 450
448 while (drv_data->rx < (drv_data->rx_end - 2)) { 451 while (drv_data->rx < (drv_data->rx_end - 2)) {
@@ -571,12 +574,12 @@ static void giveback(struct driver_data *drv_data)
571 msg->complete(msg->context); 574 msg->complete(msg->context);
572} 575}
573 576
574static irqreturn_t dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs) 577static irqreturn_t dma_irq_handler(int irq, void *dev_id)
575{ 578{
576 struct driver_data *drv_data = (struct driver_data *)dev_id; 579 struct driver_data *drv_data = (struct driver_data *)dev_id;
577 struct spi_message *msg = drv_data->cur_msg; 580 struct spi_message *msg = drv_data->cur_msg;
578 581
579 pr_debug("in dma_irq_handler\n"); 582 dev_dbg(&drv_data->pdev->dev, "in dma_irq_handler\n");
580 clear_dma_irqstat(CH_SPI); 583 clear_dma_irqstat(CH_SPI);
581 584
582 /* 585 /*
@@ -604,7 +607,9 @@ static irqreturn_t dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
604 tasklet_schedule(&drv_data->pump_transfers); 607 tasklet_schedule(&drv_data->pump_transfers);
605 608
606 /* free the irq handler before next transfer */ 609 /* free the irq handler before next transfer */
607 pr_debug("disable dma channel irq%d\n", CH_SPI); 610 dev_dbg(&drv_data->pdev->dev,
611 "disable dma channel irq%d\n",
612 CH_SPI);
608 dma_disable_irq(CH_SPI); 613 dma_disable_irq(CH_SPI);
609 614
610 return IRQ_HANDLED; 615 return IRQ_HANDLED;
@@ -617,7 +622,8 @@ static void pump_transfers(unsigned long data)
617 struct spi_transfer *transfer = NULL; 622 struct spi_transfer *transfer = NULL;
618 struct spi_transfer *previous = NULL; 623 struct spi_transfer *previous = NULL;
619 struct chip_data *chip = NULL; 624 struct chip_data *chip = NULL;
620 u16 cr, width, dma_width, dma_config; 625 u8 width;
626 u16 cr, dma_width, dma_config;
621 u32 tranf_success = 1; 627 u32 tranf_success = 1;
622 628
623 /* Get current state information */ 629 /* Get current state information */
@@ -662,8 +668,8 @@ static void pump_transfers(unsigned long data)
662 if (transfer->tx_buf != NULL) { 668 if (transfer->tx_buf != NULL) {
663 drv_data->tx = (void *)transfer->tx_buf; 669 drv_data->tx = (void *)transfer->tx_buf;
664 drv_data->tx_end = drv_data->tx + transfer->len; 670 drv_data->tx_end = drv_data->tx + transfer->len;
665 pr_debug("tx_buf is %p, tx_end is %p\n", transfer->tx_buf, 671 dev_dbg(&drv_data->pdev->dev, "tx_buf is %p, tx_end is %p\n",
666 drv_data->tx_end); 672 transfer->tx_buf, drv_data->tx_end);
667 } else { 673 } else {
668 drv_data->tx = NULL; 674 drv_data->tx = NULL;
669 } 675 }
@@ -671,8 +677,8 @@ static void pump_transfers(unsigned long data)
671 if (transfer->rx_buf != NULL) { 677 if (transfer->rx_buf != NULL) {
672 drv_data->rx = transfer->rx_buf; 678 drv_data->rx = transfer->rx_buf;
673 drv_data->rx_end = drv_data->rx + transfer->len; 679 drv_data->rx_end = drv_data->rx + transfer->len;
674 pr_debug("rx_buf is %p, rx_end is %p\n", transfer->rx_buf, 680 dev_dbg(&drv_data->pdev->dev, "rx_buf is %p, rx_end is %p\n",
675 drv_data->rx_end); 681 transfer->rx_buf, drv_data->rx_end);
676 } else { 682 } else {
677 drv_data->rx = NULL; 683 drv_data->rx = NULL;
678 } 684 }
@@ -690,9 +696,9 @@ static void pump_transfers(unsigned long data)
690 drv_data->write = drv_data->tx ? chip->write : null_writer; 696 drv_data->write = drv_data->tx ? chip->write : null_writer;
691 drv_data->read = drv_data->rx ? chip->read : null_reader; 697 drv_data->read = drv_data->rx ? chip->read : null_reader;
692 drv_data->duplex = chip->duplex ? chip->duplex : null_writer; 698 drv_data->duplex = chip->duplex ? chip->duplex : null_writer;
693 pr_debug 699 dev_dbg(&drv_data->pdev->dev,
694 ("transfer: drv_data->write is %p, chip->write is %p, null_wr is %p\n", 700 "transfer: drv_data->write is %p, chip->write is %p, null_wr is %p\n",
695 drv_data->write, chip->write, null_writer); 701 drv_data->write, chip->write, null_writer);
696 702
697 /* speed and width has been set on per message */ 703 /* speed and width has been set on per message */
698 message->state = RUNNING_STATE; 704 message->state = RUNNING_STATE;
@@ -706,8 +712,9 @@ static void pump_transfers(unsigned long data)
706 } 712 }
707 write_FLAG(chip->flag); 713 write_FLAG(chip->flag);
708 714
709 pr_debug("now pumping a transfer: width is %d, len is %d\n", width, 715 dev_dbg(&drv_data->pdev->dev,
710 transfer->len); 716 "now pumping a transfer: width is %d, len is %d\n",
717 width, transfer->len);
711 718
712 /* 719 /*
713 * Try to map dma buffer and do a dma transfer if 720 * Try to map dma buffer and do a dma transfer if
@@ -722,7 +729,7 @@ static void pump_transfers(unsigned long data)
722 bfin_spi_disable(drv_data); 729 bfin_spi_disable(drv_data);
723 730
724 /* config dma channel */ 731 /* config dma channel */
725 pr_debug("doing dma transfer\n"); 732 dev_dbg(&drv_data->pdev->dev, "doing dma transfer\n");
726 if (width == CFG_SPI_WORDSIZE16) { 733 if (width == CFG_SPI_WORDSIZE16) {
727 set_dma_x_count(CH_SPI, drv_data->len); 734 set_dma_x_count(CH_SPI, drv_data->len);
728 set_dma_x_modify(CH_SPI, 2); 735 set_dma_x_modify(CH_SPI, 2);
@@ -738,7 +745,8 @@ static void pump_transfers(unsigned long data)
738 745
739 /* dirty hack for autobuffer DMA mode */ 746 /* dirty hack for autobuffer DMA mode */
740 if (drv_data->tx_dma == 0xFFFF) { 747 if (drv_data->tx_dma == 0xFFFF) {
741 pr_debug("doing autobuffer DMA out.\n"); 748 dev_dbg(&drv_data->pdev->dev,
749 "doing autobuffer DMA out.\n");
742 750
743 /* no irq in autobuffer mode */ 751 /* no irq in autobuffer mode */
744 dma_config = 752 dma_config =
@@ -758,7 +766,7 @@ static void pump_transfers(unsigned long data)
758 /* In dma mode, rx or tx must be NULL in one transfer */ 766 /* In dma mode, rx or tx must be NULL in one transfer */
759 if (drv_data->rx != NULL) { 767 if (drv_data->rx != NULL) {
760 /* set transfer mode, and enable SPI */ 768 /* set transfer mode, and enable SPI */
761 pr_debug("doing DMA in.\n"); 769 dev_dbg(&drv_data->pdev->dev, "doing DMA in.\n");
762 770
763 /* disable SPI before write to TDBR */ 771 /* disable SPI before write to TDBR */
764 write_CTRL(cr & ~BIT_CTL_ENABLE); 772 write_CTRL(cr & ~BIT_CTL_ENABLE);
@@ -781,7 +789,7 @@ static void pump_transfers(unsigned long data)
781 /* set transfer mode, and enable SPI */ 789 /* set transfer mode, and enable SPI */
782 write_CTRL(cr); 790 write_CTRL(cr);
783 } else if (drv_data->tx != NULL) { 791 } else if (drv_data->tx != NULL) {
784 pr_debug("doing DMA out.\n"); 792 dev_dbg(&drv_data->pdev->dev, "doing DMA out.\n");
785 793
786 /* start dma */ 794 /* start dma */
787 dma_enable_irq(CH_SPI); 795 dma_enable_irq(CH_SPI);
@@ -796,7 +804,7 @@ static void pump_transfers(unsigned long data)
796 } 804 }
797 } else { 805 } else {
798 /* IO mode write then read */ 806 /* IO mode write then read */
799 pr_debug("doing IO transfer\n"); 807 dev_dbg(&drv_data->pdev->dev, "doing IO transfer\n");
800 808
801 write_STAT(BIT_STAT_CLR); 809 write_STAT(BIT_STAT_CLR);
802 810
@@ -804,11 +812,11 @@ static void pump_transfers(unsigned long data)
804 /* full duplex mode */ 812 /* full duplex mode */
805 BUG_ON((drv_data->tx_end - drv_data->tx) != 813 BUG_ON((drv_data->tx_end - drv_data->tx) !=
806 (drv_data->rx_end - drv_data->rx)); 814 (drv_data->rx_end - drv_data->rx));
807 cr = (read_CTRL() & (~BIT_CTL_TIMOD)); /* clear the TIMOD bits */ 815 cr = (read_CTRL() & (~BIT_CTL_TIMOD));
808 cr |= 816 cr |= CFG_SPI_WRITE | (width << 8) |
809 CFG_SPI_WRITE | (width << 8) | (CFG_SPI_ENABLE << 817 (CFG_SPI_ENABLE << 14);
810 14); 818 dev_dbg(&drv_data->pdev->dev,
811 pr_debug("IO duplex: cr is 0x%x\n", cr); 819 "IO duplex: cr is 0x%x\n", cr);
812 820
813 write_CTRL(cr); 821 write_CTRL(cr);
814 SSYNC(); 822 SSYNC();
@@ -819,11 +827,11 @@ static void pump_transfers(unsigned long data)
819 tranf_success = 0; 827 tranf_success = 0;
820 } else if (drv_data->tx != NULL) { 828 } else if (drv_data->tx != NULL) {
821 /* write only half duplex */ 829 /* write only half duplex */
822 cr = (read_CTRL() & (~BIT_CTL_TIMOD)); /* clear the TIMOD bits */ 830 cr = (read_CTRL() & (~BIT_CTL_TIMOD));
823 cr |= 831 cr |= CFG_SPI_WRITE | (width << 8) |
824 CFG_SPI_WRITE | (width << 8) | (CFG_SPI_ENABLE << 832 (CFG_SPI_ENABLE << 14);
825 14); 833 dev_dbg(&drv_data->pdev->dev,
826 pr_debug("IO write: cr is 0x%x\n", cr); 834 "IO write: cr is 0x%x\n", cr);
827 835
828 write_CTRL(cr); 836 write_CTRL(cr);
829 SSYNC(); 837 SSYNC();
@@ -834,11 +842,11 @@ static void pump_transfers(unsigned long data)
834 tranf_success = 0; 842 tranf_success = 0;
835 } else if (drv_data->rx != NULL) { 843 } else if (drv_data->rx != NULL) {
836 /* read only half duplex */ 844 /* read only half duplex */
837 cr = (read_CTRL() & (~BIT_CTL_TIMOD)); /* cleare the TIMOD bits */ 845 cr = (read_CTRL() & (~BIT_CTL_TIMOD));
838 cr |= 846 cr |= CFG_SPI_READ | (width << 8) |
839 CFG_SPI_READ | (width << 8) | (CFG_SPI_ENABLE << 847 (CFG_SPI_ENABLE << 14);
840 14); 848 dev_dbg(&drv_data->pdev->dev,
841 pr_debug("IO read: cr is 0x%x\n", cr); 849 "IO read: cr is 0x%x\n", cr);
842 850
843 write_CTRL(cr); 851 write_CTRL(cr);
844 SSYNC(); 852 SSYNC();
@@ -849,7 +857,8 @@ static void pump_transfers(unsigned long data)
849 } 857 }
850 858
851 if (!tranf_success) { 859 if (!tranf_success) {
852 pr_debug("IO write error!\n"); 860 dev_dbg(&drv_data->pdev->dev,
861 "IO write error!\n");
853 message->state = ERROR_STATE; 862 message->state = ERROR_STATE;
854 } else { 863 } else {
855 /* Update total byte transfered */ 864 /* Update total byte transfered */
@@ -899,11 +908,14 @@ static void pump_messages(struct work_struct *work)
899 /* Setup the SSP using the per chip configuration */ 908 /* Setup the SSP using the per chip configuration */
900 drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi); 909 drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi);
901 restore_state(drv_data); 910 restore_state(drv_data);
902 pr_debug 911 dev_dbg(&drv_data->pdev->dev,
903 ("got a message to pump, state is set to: baud %d, flag 0x%x, ctl 0x%x\n", 912 "got a message to pump, state is set to: baud %d, flag 0x%x, ctl 0x%x\n",
904 drv_data->cur_chip->baud, drv_data->cur_chip->flag, 913 drv_data->cur_chip->baud, drv_data->cur_chip->flag,
905 drv_data->cur_chip->ctl_reg); 914 drv_data->cur_chip->ctl_reg);
906 pr_debug("the first transfer len is %d\n", drv_data->cur_transfer->len); 915
916 dev_dbg(&drv_data->pdev->dev,
917 "the first transfer len is %d\n",
918 drv_data->cur_transfer->len);
907 919
908 /* Mark as busy and launch transfers */ 920 /* Mark as busy and launch transfers */
909 tasklet_schedule(&drv_data->pump_transfers); 921 tasklet_schedule(&drv_data->pump_transfers);
@@ -932,7 +944,7 @@ static int transfer(struct spi_device *spi, struct spi_message *msg)
932 msg->status = -EINPROGRESS; 944 msg->status = -EINPROGRESS;
933 msg->state = START_STATE; 945 msg->state = START_STATE;
934 946
935 pr_debug("adding an msg in transfer() \n"); 947 dev_dbg(&spi->dev, "adding an msg in transfer() \n");
936 list_add_tail(&msg->queue, &drv_data->queue); 948 list_add_tail(&msg->queue, &drv_data->queue);
937 949
938 if (drv_data->run == QUEUE_RUNNING && !drv_data->busy) 950 if (drv_data->run == QUEUE_RUNNING && !drv_data->busy)
@@ -1002,13 +1014,13 @@ static int setup(struct spi_device *spi)
1002 if (chip->enable_dma && !dma_requested) { 1014 if (chip->enable_dma && !dma_requested) {
1003 /* register dma irq handler */ 1015 /* register dma irq handler */
1004 if (request_dma(CH_SPI, "BF53x_SPI_DMA") < 0) { 1016 if (request_dma(CH_SPI, "BF53x_SPI_DMA") < 0) {
1005 pr_debug 1017 dev_dbg(&spi->dev,
1006 ("Unable to request BlackFin SPI DMA channel\n"); 1018 "Unable to request BlackFin SPI DMA channel\n");
1007 return -ENODEV; 1019 return -ENODEV;
1008 } 1020 }
1009 if (set_dma_callback(CH_SPI, (void *)dma_irq_handler, drv_data) 1021 if (set_dma_callback(CH_SPI, (void *)dma_irq_handler, drv_data)
1010 < 0) { 1022 < 0) {
1011 pr_debug("Unable to set dma callback\n"); 1023 dev_dbg(&spi->dev, "Unable to set dma callback\n");
1012 return -EPERM; 1024 return -EPERM;
1013 } 1025 }
1014 dma_disable_irq(CH_SPI); 1026 dma_disable_irq(CH_SPI);
@@ -1054,9 +1066,9 @@ static int setup(struct spi_device *spi)
1054 return -ENODEV; 1066 return -ENODEV;
1055 } 1067 }
1056 1068
1057 pr_debug("setup spi chip %s, width is %d, dma is %d,", 1069 dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d,",
1058 spi->modalias, chip->width, chip->enable_dma); 1070 spi->modalias, chip->width, chip->enable_dma);
1059 pr_debug("ctl_reg is 0x%x, flag_reg is 0x%x\n", 1071 dev_dbg(&spi->dev, "ctl_reg is 0x%x, flag_reg is 0x%x\n",
1060 chip->ctl_reg, chip->flag); 1072 chip->ctl_reg, chip->flag);
1061 1073
1062 spi_set_ctldata(spi, chip); 1074 spi_set_ctldata(spi, chip);
@@ -1068,7 +1080,7 @@ static int setup(struct spi_device *spi)
1068 * callback for spi framework. 1080 * callback for spi framework.
1069 * clean driver specific data 1081 * clean driver specific data
1070 */ 1082 */
1071static void cleanup(const struct spi_device *spi) 1083static void cleanup(struct spi_device *spi)
1072{ 1084{
1073 struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi); 1085 struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
1074 1086
@@ -1207,7 +1219,7 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
1207 dev_err(&pdev->dev, "problem registering spi master\n"); 1219 dev_err(&pdev->dev, "problem registering spi master\n");
1208 goto out_error_queue_alloc; 1220 goto out_error_queue_alloc;
1209 } 1221 }
1210 pr_debug("controller probe successfully\n"); 1222 dev_dbg(&pdev->dev, "controller probe successfully\n");
1211 return status; 1223 return status;
1212 1224
1213 out_error_queue_alloc: 1225 out_error_queue_alloc:
@@ -1287,27 +1299,23 @@ static int bfin5xx_spi_resume(struct platform_device *pdev)
1287#endif /* CONFIG_PM */ 1299#endif /* CONFIG_PM */
1288 1300
1289static struct platform_driver bfin5xx_spi_driver = { 1301static struct platform_driver bfin5xx_spi_driver = {
1290 .driver = { 1302 .driver = {
1291 .name = "bfin-spi-master", 1303 .name = "bfin-spi-master",
1292 .bus = &platform_bus_type, 1304 .owner = THIS_MODULE,
1293 .owner = THIS_MODULE, 1305 },
1294 }, 1306 .suspend = bfin5xx_spi_suspend,
1295 .probe = bfin5xx_spi_probe, 1307 .resume = bfin5xx_spi_resume,
1296 .remove = __devexit_p(bfin5xx_spi_remove), 1308 .remove = __devexit_p(bfin5xx_spi_remove),
1297 .suspend = bfin5xx_spi_suspend,
1298 .resume = bfin5xx_spi_resume,
1299}; 1309};
1300 1310
1301static int __init bfin5xx_spi_init(void) 1311static int __init bfin5xx_spi_init(void)
1302{ 1312{
1303 return platform_driver_register(&bfin5xx_spi_driver); 1313 return platform_driver_probe(&bfin5xx_spi_driver, bfin5xx_spi_probe);
1304} 1314}
1305
1306module_init(bfin5xx_spi_init); 1315module_init(bfin5xx_spi_init);
1307 1316
1308static void __exit bfin5xx_spi_exit(void) 1317static void __exit bfin5xx_spi_exit(void)
1309{ 1318{
1310 platform_driver_unregister(&bfin5xx_spi_driver); 1319 platform_driver_unregister(&bfin5xx_spi_driver);
1311} 1320}
1312
1313module_exit(bfin5xx_spi_exit); 1321module_exit(bfin5xx_spi_exit);
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index c0a6dce800a3..d04242aee40d 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -168,6 +168,12 @@ static int spidev_message(struct spidev_data *spidev,
168 n--, k_tmp++, u_tmp++) { 168 n--, k_tmp++, u_tmp++) {
169 k_tmp->len = u_tmp->len; 169 k_tmp->len = u_tmp->len;
170 170
171 total += k_tmp->len;
172 if (total > bufsiz) {
173 status = -EMSGSIZE;
174 goto done;
175 }
176
171 if (u_tmp->rx_buf) { 177 if (u_tmp->rx_buf) {
172 k_tmp->rx_buf = buf; 178 k_tmp->rx_buf = buf;
173 if (!access_ok(VERIFY_WRITE, u_tmp->rx_buf, u_tmp->len)) 179 if (!access_ok(VERIFY_WRITE, u_tmp->rx_buf, u_tmp->len))
@@ -179,12 +185,6 @@ static int spidev_message(struct spidev_data *spidev,
179 u_tmp->len)) 185 u_tmp->len))
180 goto done; 186 goto done;
181 } 187 }
182
183 total += k_tmp->len;
184 if (total > bufsiz) {
185 status = -EMSGSIZE;
186 goto done;
187 }
188 buf += k_tmp->len; 188 buf += k_tmp->len;
189 189
190 k_tmp->cs_change = !!u_tmp->cs_change; 190 k_tmp->cs_change = !!u_tmp->cs_change;
@@ -364,6 +364,7 @@ spidev_ioctl(struct inode *inode, struct file *filp,
364 break; 364 break;
365 } 365 }
366 if (__copy_from_user(ioc, (void __user *)arg, tmp)) { 366 if (__copy_from_user(ioc, (void __user *)arg, tmp)) {
367 kfree(ioc);
367 retval = -EFAULT; 368 retval = -EFAULT;
368 break; 369 break;
369 } 370 }
@@ -484,7 +485,7 @@ static int spidev_probe(struct spi_device *spi)
484 * Reusing minors is fine so long as udev or mdev is working. 485 * Reusing minors is fine so long as udev or mdev is working.
485 */ 486 */
486 mutex_lock(&device_list_lock); 487 mutex_lock(&device_list_lock);
487 minor = find_first_zero_bit(minors, ARRAY_SIZE(minors)); 488 minor = find_first_zero_bit(minors, N_SPI_MINORS);
488 if (minor < N_SPI_MINORS) { 489 if (minor < N_SPI_MINORS) {
489 spidev->dev.parent = &spi->dev; 490 spidev->dev.parent = &spi->dev;
490 spidev->dev.class = &spidev_class; 491 spidev->dev.class = &spidev_class;
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 15e740e3a5c4..7b1edfe46b28 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1003,7 +1003,7 @@ abort:
1003 usblp->writebuf, usblp->writeurb->transfer_dma); 1003 usblp->writebuf, usblp->writeurb->transfer_dma);
1004 if (usblp->readbuf) 1004 if (usblp->readbuf)
1005 usb_buffer_free (usblp->dev, USBLP_BUF_SIZE, 1005 usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
1006 usblp->readbuf, usblp->writeurb->transfer_dma); 1006 usblp->readbuf, usblp->readurb->transfer_dma);
1007 kfree(usblp->statusbuf); 1007 kfree(usblp->statusbuf);
1008 kfree(usblp->device_id_string); 1008 kfree(usblp->device_id_string);
1009 usb_free_urb(usblp->writeurb); 1009 usb_free_urb(usblp->writeurb);
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index bfb3731d42db..2d4fd530e5e4 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
185 num_ep = USB_MAXENDPOINTS; 185 num_ep = USB_MAXENDPOINTS;
186 } 186 }
187 187
188 len = sizeof(struct usb_host_endpoint) * num_ep; 188 if (num_ep > 0) { /* Can't allocate 0 bytes */
189 alt->endpoint = kzalloc(len, GFP_KERNEL); 189 len = sizeof(struct usb_host_endpoint) * num_ep;
190 if (!alt->endpoint) 190 alt->endpoint = kzalloc(len, GFP_KERNEL);
191 return -ENOMEM; 191 if (!alt->endpoint)
192 return -ENOMEM;
193 }
192 194
193 /* Parse all the endpoint descriptors */ 195 /* Parse all the endpoint descriptors */
194 n = 0; 196 n = 0;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index b9f7f90aef82..2619986e5300 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -983,7 +983,10 @@ static int autosuspend_check(struct usb_device *udev)
983 983
984#else 984#else
985 985
986#define autosuspend_check(udev) 0 986static inline int autosuspend_check(struct usb_device *udev)
987{
988 return 0;
989}
987 990
988#endif /* CONFIG_USB_SUSPEND */ 991#endif /* CONFIG_USB_SUSPEND */
989 992
@@ -1041,7 +1044,6 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1041 if (status < 0) 1044 if (status < 0)
1042 goto done; 1045 goto done;
1043 } 1046 }
1044 cancel_delayed_work(&udev->autosuspend);
1045 1047
1046 /* Suspend all the interfaces and then udev itself */ 1048 /* Suspend all the interfaces and then udev itself */
1047 if (udev->actconfig) { 1049 if (udev->actconfig) {
@@ -1062,9 +1064,16 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1062 usb_resume_interface(intf); 1064 usb_resume_interface(intf);
1063 } 1065 }
1064 1066
1067 /* Try another autosuspend when the interfaces aren't busy */
1068 if (udev->auto_pm)
1069 autosuspend_check(udev);
1070
1065 /* If the suspend succeeded, propagate it up the tree */ 1071 /* If the suspend succeeded, propagate it up the tree */
1066 } else if (parent) 1072 } else {
1067 usb_autosuspend_device(parent); 1073 cancel_delayed_work(&udev->autosuspend);
1074 if (parent)
1075 usb_autosuspend_device(parent);
1076 }
1068 1077
1069 done: 1078 done:
1070 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1079 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
@@ -1475,6 +1484,7 @@ int usb_external_resume_device(struct usb_device *udev)
1475 usb_pm_lock(udev); 1484 usb_pm_lock(udev);
1476 udev->auto_pm = 0; 1485 udev->auto_pm = 0;
1477 status = usb_resume_both(udev); 1486 status = usb_resume_both(udev);
1487 udev->last_busy = jiffies;
1478 usb_pm_unlock(udev); 1488 usb_pm_unlock(udev);
1479 1489
1480 /* Now that the device is awake, we can start trying to autosuspend 1490 /* Now that the device is awake, we can start trying to autosuspend
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 40cf882293e6..8969e42434b9 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1018,8 +1018,8 @@ done:
1018 atomic_dec (&urb->use_count); 1018 atomic_dec (&urb->use_count);
1019 if (urb->reject) 1019 if (urb->reject)
1020 wake_up (&usb_kill_urb_queue); 1020 wake_up (&usb_kill_urb_queue);
1021 usb_put_urb (urb);
1022 usbmon_urb_submit_error(&hcd->self, urb, status); 1021 usbmon_urb_submit_error(&hcd->self, urb, status);
1022 usb_put_urb (urb);
1023 } 1023 }
1024 return status; 1024 return status;
1025} 1025}
@@ -1175,10 +1175,6 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
1175 struct urb *urb; 1175 struct urb *urb;
1176 1176
1177 hcd = bus_to_hcd(udev->bus); 1177 hcd = bus_to_hcd(udev->bus);
1178
1179 WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT &&
1180 udev->state != USB_STATE_NOTATTACHED);
1181
1182 local_irq_disable (); 1178 local_irq_disable ();
1183 1179
1184 /* ep is already gone from udev->ep_{in,out}[]; no more submits */ 1180 /* ep is already gone from udev->ep_{in,out}[]; no more submits */
@@ -1685,7 +1681,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
1685 spin_unlock_irq (&hcd_root_hub_lock); 1681 spin_unlock_irq (&hcd_root_hub_lock);
1686 1682
1687#ifdef CONFIG_PM 1683#ifdef CONFIG_PM
1688 flush_workqueue(ksuspend_usb_wq); 1684 cancel_work_sync(&hcd->wakeup_work);
1689#endif 1685#endif
1690 1686
1691 mutex_lock(&usb_bus_list_lock); 1687 mutex_lock(&usb_bus_list_lock);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f6b74a678de5..24f10a19dbdb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1158,6 +1158,30 @@ static void release_address(struct usb_device *udev)
1158 } 1158 }
1159} 1159}
1160 1160
1161#ifdef CONFIG_USB_SUSPEND
1162
1163static void usb_stop_pm(struct usb_device *udev)
1164{
1165 /* Synchronize with the ksuspend thread to prevent any more
1166 * autosuspend requests from being submitted, and decrement
1167 * the parent's count of unsuspended children.
1168 */
1169 usb_pm_lock(udev);
1170 if (udev->parent && !udev->discon_suspended)
1171 usb_autosuspend_device(udev->parent);
1172 usb_pm_unlock(udev);
1173
1174 /* Stop any autosuspend requests already submitted */
1175 cancel_rearming_delayed_work(&udev->autosuspend);
1176}
1177
1178#else
1179
1180static inline void usb_stop_pm(struct usb_device *udev)
1181{ }
1182
1183#endif
1184
1161/** 1185/**
1162 * usb_disconnect - disconnect a device (usbcore-internal) 1186 * usb_disconnect - disconnect a device (usbcore-internal)
1163 * @pdev: pointer to device being disconnected 1187 * @pdev: pointer to device being disconnected
@@ -1224,13 +1248,7 @@ void usb_disconnect(struct usb_device **pdev)
1224 *pdev = NULL; 1248 *pdev = NULL;
1225 spin_unlock_irq(&device_state_lock); 1249 spin_unlock_irq(&device_state_lock);
1226 1250
1227 /* Decrement the parent's count of unsuspended children */ 1251 usb_stop_pm(udev);
1228 if (udev->parent) {
1229 usb_pm_lock(udev);
1230 if (!udev->discon_suspended)
1231 usb_autosuspend_device(udev->parent);
1232 usb_pm_unlock(udev);
1233 }
1234 1252
1235 put_device(&udev->dev); 1253 put_device(&udev->dev);
1236} 1254}
@@ -2201,14 +2219,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2201 continue; 2219 continue;
2202 } 2220 }
2203 2221
2204 /* Use a short timeout the first time through, 2222 /* Retry on all errors; some devices are flakey.
2205 * so that recalcitrant full-speed devices with 2223 * 255 is for WUSB devices, we actually need to use
2206 * 8- or 16-byte ep0-maxpackets won't slow things 2224 * 512 (WUSB1.0[4.8.1]).
2207 * down tremendously by NAKing the unexpectedly
2208 * early status stage. Also, retry on all errors;
2209 * some devices are flakey.
2210 * 255 is for WUSB devices, we actually need to use 512.
2211 * WUSB1.0[4.8.1].
2212 */ 2225 */
2213 for (j = 0; j < 3; ++j) { 2226 for (j = 0; j < 3; ++j) {
2214 buf->bMaxPacketSize0 = 0; 2227 buf->bMaxPacketSize0 = 0;
@@ -2216,7 +2229,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2216 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, 2229 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
2217 USB_DT_DEVICE << 8, 0, 2230 USB_DT_DEVICE << 8, 0,
2218 buf, GET_DESCRIPTOR_BUFSIZE, 2231 buf, GET_DESCRIPTOR_BUFSIZE,
2219 (i ? USB_CTRL_GET_TIMEOUT : 1000)); 2232 USB_CTRL_GET_TIMEOUT);
2220 switch (buf->bMaxPacketSize0) { 2233 switch (buf->bMaxPacketSize0) {
2221 case 8: case 16: case 32: case 64: case 255: 2234 case 8: case 16: case 32: case 64: case 255:
2222 if (buf->bDescriptorType == 2235 if (buf->bDescriptorType ==
@@ -2426,10 +2439,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2426 2439
2427 if (portchange & USB_PORT_STAT_C_CONNECTION) { 2440 if (portchange & USB_PORT_STAT_C_CONNECTION) {
2428 status = hub_port_debounce(hub, port1); 2441 status = hub_port_debounce(hub, port1);
2429 if (status < 0 && printk_ratelimit()) { 2442 if (status < 0) {
2430 dev_err (hub_dev, 2443 if (printk_ratelimit())
2431 "connect-debounce failed, port %d disabled\n", 2444 dev_err (hub_dev, "connect-debounce failed, "
2432 port1); 2445 "port %d disabled\n", port1);
2433 goto done; 2446 goto done;
2434 } 2447 }
2435 portstatus = status; 2448 portstatus = status;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index b7434787db5f..f9fed34bf7d8 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -221,15 +221,10 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
221 221
222 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 222 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
223 USB_ENDPOINT_XFER_INT) { 223 USB_ENDPOINT_XFER_INT) {
224 int interval;
225
226 if (usb_dev->speed == USB_SPEED_HIGH)
227 interval = 1 << min(15, ep->desc.bInterval - 1);
228 else
229 interval = ep->desc.bInterval;
230 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); 224 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
231 usb_fill_int_urb(urb, usb_dev, pipe, data, len, 225 usb_fill_int_urb(urb, usb_dev, pipe, data, len,
232 usb_api_blocking_completion, NULL, interval); 226 usb_api_blocking_completion, NULL,
227 ep->desc.bInterval);
233 } else 228 } else
234 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, 229 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
235 usb_api_blocking_completion, NULL); 230 usb_api_blocking_completion, NULL);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index e7c982377488..be37c863fdfb 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -232,12 +232,15 @@ set_level(struct device *dev, struct device_attribute *attr,
232 int len = count; 232 int len = count;
233 char *cp; 233 char *cp;
234 int rc = 0; 234 int rc = 0;
235 int old_autosuspend_disabled, old_autoresume_disabled;
235 236
236 cp = memchr(buf, '\n', count); 237 cp = memchr(buf, '\n', count);
237 if (cp) 238 if (cp)
238 len = cp - buf; 239 len = cp - buf;
239 240
240 usb_lock_device(udev); 241 usb_lock_device(udev);
242 old_autosuspend_disabled = udev->autosuspend_disabled;
243 old_autoresume_disabled = udev->autoresume_disabled;
241 244
242 /* Setting the flags without calling usb_pm_lock is a subject to 245 /* Setting the flags without calling usb_pm_lock is a subject to
243 * races, but who cares... 246 * races, but who cares...
@@ -263,6 +266,10 @@ set_level(struct device *dev, struct device_attribute *attr,
263 } else 266 } else
264 rc = -EINVAL; 267 rc = -EINVAL;
265 268
269 if (rc) {
270 udev->autosuspend_disabled = old_autosuspend_disabled;
271 udev->autoresume_disabled = old_autoresume_disabled;
272 }
266 usb_unlock_device(udev); 273 usb_unlock_device(udev);
267 return (rc < 0 ? rc : count); 274 return (rc < 0 ? rc : count);
268} 275}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 18ddc5e67e39..4a6299bd0047 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -184,10 +184,6 @@ static void usb_release_dev(struct device *dev)
184 184
185 udev = to_usb_device(dev); 185 udev = to_usb_device(dev);
186 186
187#ifdef CONFIG_USB_SUSPEND
188 cancel_delayed_work(&udev->autosuspend);
189 flush_workqueue(ksuspend_usb_wq);
190#endif
191 usb_destroy_configuration(udev); 187 usb_destroy_configuration(udev);
192 usb_put_hcd(bus_to_hcd(udev->bus)); 188 usb_put_hcd(bus_to_hcd(udev->bus));
193 kfree(udev->product); 189 kfree(udev->product);
@@ -205,7 +201,11 @@ struct device_type usb_device_type = {
205 201
206static int ksuspend_usb_init(void) 202static int ksuspend_usb_init(void)
207{ 203{
208 ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd"); 204 /* This workqueue is supposed to be both freezable and
205 * singlethreaded. Its job doesn't justify running on more
206 * than one CPU.
207 */
208 ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd");
209 if (!ksuspend_usb_wq) 209 if (!ksuspend_usb_wq)
210 return -ENOMEM; 210 return -ENOMEM;
211 return 0; 211 return 0;
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 157054ea3978..3ca2b3159f00 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -228,13 +228,15 @@ static int dr_controller_setup(struct fsl_udc *udc)
228 228
229 /* Config PHY interface */ 229 /* Config PHY interface */
230 portctrl = fsl_readl(&dr_regs->portsc1); 230 portctrl = fsl_readl(&dr_regs->portsc1);
231 portctrl &= ~PORTSCX_PHY_TYPE_SEL; 231 portctrl &= ~(PORTSCX_PHY_TYPE_SEL & PORTSCX_PORT_WIDTH);
232 switch (udc->phy_mode) { 232 switch (udc->phy_mode) {
233 case FSL_USB2_PHY_ULPI: 233 case FSL_USB2_PHY_ULPI:
234 portctrl |= PORTSCX_PTS_ULPI; 234 portctrl |= PORTSCX_PTS_ULPI;
235 break; 235 break;
236 case FSL_USB2_PHY_UTMI:
237 case FSL_USB2_PHY_UTMI_WIDE: 236 case FSL_USB2_PHY_UTMI_WIDE:
237 portctrl |= PORTSCX_PTW_16BIT;
238 /* fall through */
239 case FSL_USB2_PHY_UTMI:
238 portctrl |= PORTSCX_PTS_UTMI; 240 portctrl |= PORTSCX_PTS_UTMI;
239 break; 241 break;
240 case FSL_USB2_PHY_SERIAL: 242 case FSL_USB2_PHY_SERIAL:
@@ -625,7 +627,7 @@ static void fsl_free_buffer(struct usb_ep *_ep, void *buf,
625 struct fsl_ep *ep; 627 struct fsl_ep *ep;
626 628
627 if (!_ep) 629 if (!_ep)
628 return NULL; 630 return;
629 631
630 ep = container_of(_ep, struct fsl_ep, ep); 632 ep = container_of(_ep, struct fsl_ep, ep);
631 633
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index a52480505f78..c7a7c590426f 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -193,6 +193,19 @@ static void mpc83xx_usb_setup(struct usb_hcd *hcd)
193 out_be32(non_ehci + FSL_SOC_USB_CTRL, 0x00000004); 193 out_be32(non_ehci + FSL_SOC_USB_CTRL, 0x00000004);
194 out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b); 194 out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b);
195 195
196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
197 /*
198 * Turn on cache snooping hardware, since some PowerPC platforms
199 * wholly rely on hardware to deal with cache coherent
200 */
201
202 /* Setup Snooping for all the 4GB space */
203 /* SNOOP1 starts from 0x0, size 2G */
204 out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
205 /* SNOOP2 starts from 0x80000000, size 2G */
206 out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB);
207#endif
208
196 if (pdata->operating_mode == FSL_USB2_DR_HOST) 209 if (pdata->operating_mode == FSL_USB2_DR_HOST)
197 mpc83xx_setup_phy(ehci, pdata->phy_mode, 0); 210 mpc83xx_setup_phy(ehci, pdata->phy_mode, 0);
198 211
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index f28736a917e4..b5e59db53347 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -34,4 +34,5 @@
34#define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */ 34#define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */
35#define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */ 35#define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */
36#define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */ 36#define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */
37#define SNOOP_SIZE_2GB 0x1e
37#endif /* _EHCI_FSL_H */ 38#endif /* _EHCI_FSL_H */
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 79705609fd0c..ca62cb583221 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -137,7 +137,7 @@ static const struct pci_device_id ohci_pci_quirks[] = {
137 /* Toshiba portege 4000 */ 137 /* Toshiba portege 4000 */
138 .vendor = PCI_VENDOR_ID_AL, 138 .vendor = PCI_VENDOR_ID_AL,
139 .device = 0x5237, 139 .device = 0x5237,
140 .subvendor = PCI_VENDOR_ID_TOSHIBA_2, 140 .subvendor = PCI_VENDOR_ID_TOSHIBA,
141 .subdevice = 0x0004, 141 .subdevice = 0x0004,
142 .driver_data = (unsigned long) broken_suspend, 142 .driver_data = (unsigned long) broken_suspend,
143 }, 143 },
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 20861650905e..c225159ca3d3 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -44,6 +44,7 @@
44#define EHCI_USBSTS 4 /* status register */ 44#define EHCI_USBSTS 4 /* status register */
45#define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */ 45#define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
46#define EHCI_USBINTR 8 /* interrupt register */ 46#define EHCI_USBINTR 8 /* interrupt register */
47#define EHCI_CONFIGFLAG 0x40 /* configured flag register */
47#define EHCI_USBLEGSUP 0 /* legacy support register */ 48#define EHCI_USBLEGSUP 0 /* legacy support register */
48#define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */ 49#define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
49#define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */ 50#define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
@@ -216,6 +217,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
216 u32 hcc_params, val; 217 u32 hcc_params, val;
217 u8 offset, cap_length; 218 u8 offset, cap_length;
218 int count = 256/4; 219 int count = 256/4;
220 int tried_handoff = 0;
219 221
220 if (!mmio_resource_enabled(pdev, 0)) 222 if (!mmio_resource_enabled(pdev, 0))
221 return; 223 return;
@@ -273,6 +275,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
273 */ 275 */
274 msec = 5000; 276 msec = 5000;
275 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { 277 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
278 tried_handoff = 1;
276 msleep(10); 279 msleep(10);
277 msec -= 10; 280 msec -= 10;
278 pci_read_config_dword(pdev, offset, &cap); 281 pci_read_config_dword(pdev, offset, &cap);
@@ -292,6 +295,12 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
292 pci_write_config_dword(pdev, 295 pci_write_config_dword(pdev,
293 offset + EHCI_USBLEGCTLSTS, 296 offset + EHCI_USBLEGCTLSTS,
294 0); 297 0);
298
299 /* If the BIOS ever owned the controller then we
300 * can't expect any power sessions to remain intact.
301 */
302 if (tried_handoff)
303 writel(0, op_reg_base + EHCI_CONFIGFLAG);
295 break; 304 break;
296 case 0: /* illegal reserved capability */ 305 case 0: /* illegal reserved capability */
297 cap = 0; 306 cap = 0;
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index ff0dba01f1c7..e98df2ee9901 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -57,6 +57,13 @@
57#include <asm/system.h> 57#include <asm/system.h>
58#include <asm/byteorder.h> 58#include <asm/byteorder.h>
59#include "../core/hcd.h" 59#include "../core/hcd.h"
60
61 /* FIXME ohci.h is ONLY for internal use by the OHCI driver.
62 * If you're going to try stuff like this, you need to split
63 * out shareable stuff (register declarations?) into its own
64 * file, maybe name <linux/usb/ohci.h>
65 */
66
60#include "ohci.h" 67#include "ohci.h"
61#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 68#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
62#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ 69#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
@@ -173,11 +180,6 @@ struct u132_ring {
173 struct u132_endp *curr_endp; 180 struct u132_endp *curr_endp;
174 struct delayed_work scheduler; 181 struct delayed_work scheduler;
175}; 182};
176#define OHCI_QUIRK_AMD756 0x01
177#define OHCI_QUIRK_SUPERIO 0x02
178#define OHCI_QUIRK_INITRESET 0x04
179#define OHCI_BIG_ENDIAN 0x08
180#define OHCI_QUIRK_ZFMICRO 0x10
181struct u132 { 183struct u132 {
182 struct kref kref; 184 struct kref kref;
183 struct list_head u132_list; 185 struct list_head u132_list;
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 88fb56d5db8f..cac1500cba62 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -1822,16 +1822,10 @@ static int auerchar_release (struct inode *inode, struct file *file)
1822 pauerswald_t cp; 1822 pauerswald_t cp;
1823 dbg("release"); 1823 dbg("release");
1824 1824
1825 /* get the mutexes */ 1825 down(&ccp->mutex);
1826 if (down_interruptible (&ccp->mutex)) {
1827 return -ERESTARTSYS;
1828 }
1829 cp = ccp->auerdev; 1826 cp = ccp->auerdev;
1830 if (cp) { 1827 if (cp) {
1831 if (down_interruptible (&cp->mutex)) { 1828 down(&cp->mutex);
1832 up (&ccp->mutex);
1833 return -ERESTARTSYS;
1834 }
1835 /* remove an open service */ 1829 /* remove an open service */
1836 auerswald_removeservice (cp, &ccp->scontext); 1830 auerswald_removeservice (cp, &ccp->scontext);
1837 /* detach from device */ 1831 /* detach from device */
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index e2172e5cf152..e0f122e131d7 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -73,6 +73,13 @@ static struct list_head ftdi_static_list;
73#include "usb_u132.h" 73#include "usb_u132.h"
74#include <asm/io.h> 74#include <asm/io.h>
75#include "../core/hcd.h" 75#include "../core/hcd.h"
76
77 /* FIXME ohci.h is ONLY for internal use by the OHCI driver.
78 * If you're going to try stuff like this, you need to split
79 * out shareable stuff (register declarations?) into its own
80 * file, maybe name <linux/usb/ohci.h>
81 */
82
76#include "../host/ohci.h" 83#include "../host/ohci.h"
77/* Define these values to match your devices*/ 84/* Define these values to match your devices*/
78#define USB_FTDI_ELAN_VENDOR_ID 0x0403 85#define USB_FTDI_ELAN_VENDOR_ID 0x0403
@@ -2300,10 +2307,7 @@ static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi)
2300 offsetof(struct ohci_regs, member), 0, data); 2307 offsetof(struct ohci_regs, member), 0, data);
2301#define ftdi_write_pcimem(ftdi, member, data) ftdi_elan_write_pcimem(ftdi, \ 2308#define ftdi_write_pcimem(ftdi, member, data) ftdi_elan_write_pcimem(ftdi, \
2302 offsetof(struct ohci_regs, member), 0, data); 2309 offsetof(struct ohci_regs, member), 0, data);
2303#define OHCI_QUIRK_AMD756 0x01 2310
2304#define OHCI_QUIRK_SUPERIO 0x02
2305#define OHCI_QUIRK_INITRESET 0x04
2306#define OHCI_BIG_ENDIAN 0x08
2307#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 2311#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
2308#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ 2312#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
2309 OHCI_INTR_WDH) 2313 OHCI_INTR_WDH)
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 11555bde655b..7bad49404762 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -165,6 +165,8 @@ struct ld_usb {
165 size_t interrupt_in_endpoint_size; 165 size_t interrupt_in_endpoint_size;
166 int interrupt_in_running; 166 int interrupt_in_running;
167 int interrupt_in_done; 167 int interrupt_in_done;
168 int buffer_overflow;
169 spinlock_t rbsl;
168 170
169 char* interrupt_out_buffer; 171 char* interrupt_out_buffer;
170 struct usb_endpoint_descriptor* interrupt_out_endpoint; 172 struct usb_endpoint_descriptor* interrupt_out_endpoint;
@@ -230,10 +232,12 @@ static void ld_usb_interrupt_in_callback(struct urb *urb)
230 } else { 232 } else {
231 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", 233 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
232 __FUNCTION__, urb->status); 234 __FUNCTION__, urb->status);
235 spin_lock(&dev->rbsl);
233 goto resubmit; /* maybe we can recover */ 236 goto resubmit; /* maybe we can recover */
234 } 237 }
235 } 238 }
236 239
240 spin_lock(&dev->rbsl);
237 if (urb->actual_length > 0) { 241 if (urb->actual_length > 0) {
238 next_ring_head = (dev->ring_head+1) % ring_buffer_size; 242 next_ring_head = (dev->ring_head+1) % ring_buffer_size;
239 if (next_ring_head != dev->ring_tail) { 243 if (next_ring_head != dev->ring_tail) {
@@ -244,21 +248,25 @@ static void ld_usb_interrupt_in_callback(struct urb *urb)
244 dev->ring_head = next_ring_head; 248 dev->ring_head = next_ring_head;
245 dbg_info(&dev->intf->dev, "%s: received %d bytes\n", 249 dbg_info(&dev->intf->dev, "%s: received %d bytes\n",
246 __FUNCTION__, urb->actual_length); 250 __FUNCTION__, urb->actual_length);
247 } else 251 } else {
248 dev_warn(&dev->intf->dev, 252 dev_warn(&dev->intf->dev,
249 "Ring buffer overflow, %d bytes dropped\n", 253 "Ring buffer overflow, %d bytes dropped\n",
250 urb->actual_length); 254 urb->actual_length);
255 dev->buffer_overflow = 1;
256 }
251 } 257 }
252 258
253resubmit: 259resubmit:
254 /* resubmit if we're still running */ 260 /* resubmit if we're still running */
255 if (dev->interrupt_in_running && dev->intf) { 261 if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) {
256 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); 262 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
257 if (retval) 263 if (retval) {
258 dev_err(&dev->intf->dev, 264 dev_err(&dev->intf->dev,
259 "usb_submit_urb failed (%d)\n", retval); 265 "usb_submit_urb failed (%d)\n", retval);
266 dev->buffer_overflow = 1;
267 }
260 } 268 }
261 269 spin_unlock(&dev->rbsl);
262exit: 270exit:
263 dev->interrupt_in_done = 1; 271 dev->interrupt_in_done = 1;
264 wake_up_interruptible(&dev->read_wait); 272 wake_up_interruptible(&dev->read_wait);
@@ -330,6 +338,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
330 /* initialize in direction */ 338 /* initialize in direction */
331 dev->ring_head = 0; 339 dev->ring_head = 0;
332 dev->ring_tail = 0; 340 dev->ring_tail = 0;
341 dev->buffer_overflow = 0;
333 usb_fill_int_urb(dev->interrupt_in_urb, 342 usb_fill_int_urb(dev->interrupt_in_urb,
334 interface_to_usbdev(interface), 343 interface_to_usbdev(interface),
335 usb_rcvintpipe(interface_to_usbdev(interface), 344 usb_rcvintpipe(interface_to_usbdev(interface),
@@ -439,6 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
439 size_t *actual_buffer; 448 size_t *actual_buffer;
440 size_t bytes_to_read; 449 size_t bytes_to_read;
441 int retval = 0; 450 int retval = 0;
451 int rv;
442 452
443 dev = file->private_data; 453 dev = file->private_data;
444 454
@@ -460,7 +470,10 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
460 } 470 }
461 471
462 /* wait for data */ 472 /* wait for data */
473 spin_lock_irq(&dev->rbsl);
463 if (dev->ring_head == dev->ring_tail) { 474 if (dev->ring_head == dev->ring_tail) {
475 dev->interrupt_in_done = 0;
476 spin_unlock_irq(&dev->rbsl);
464 if (file->f_flags & O_NONBLOCK) { 477 if (file->f_flags & O_NONBLOCK) {
465 retval = -EAGAIN; 478 retval = -EAGAIN;
466 goto unlock_exit; 479 goto unlock_exit;
@@ -468,6 +481,8 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
468 retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done); 481 retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done);
469 if (retval < 0) 482 if (retval < 0)
470 goto unlock_exit; 483 goto unlock_exit;
484 } else {
485 spin_unlock_irq(&dev->rbsl);
471 } 486 }
472 487
473 /* actual_buffer contains actual_length + interrupt_in_buffer */ 488 /* actual_buffer contains actual_length + interrupt_in_buffer */
@@ -486,6 +501,17 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
486 501
487 retval = bytes_to_read; 502 retval = bytes_to_read;
488 503
504 spin_lock_irq(&dev->rbsl);
505 if (dev->buffer_overflow) {
506 dev->buffer_overflow = 0;
507 spin_unlock_irq(&dev->rbsl);
508 rv = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
509 if (rv < 0)
510 dev->buffer_overflow = 1;
511 } else {
512 spin_unlock_irq(&dev->rbsl);
513 }
514
489unlock_exit: 515unlock_exit:
490 /* unlock the device */ 516 /* unlock the device */
491 up(&dev->sem); 517 up(&dev->sem);
@@ -635,6 +661,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
635 goto exit; 661 goto exit;
636 } 662 }
637 init_MUTEX(&dev->sem); 663 init_MUTEX(&dev->sem);
664 spin_lock_init(&dev->rbsl);
638 dev->intf = intf; 665 dev->intf = intf;
639 init_waitqueue_head(&dev->read_wait); 666 init_waitqueue_head(&dev->read_wait);
640 init_waitqueue_head(&dev->write_wait); 667 init_waitqueue_head(&dev->write_wait);
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index ea2175bb2274..fe437125f14b 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -63,7 +63,8 @@ static inline void ARK3116_RCV(struct usb_serial *serial, int seq,
63 request, requesttype, value, index, 63 request, requesttype, value, index,
64 buf, 0x0000001, 1000); 64 buf, 0x0000001, 1000);
65 if (result) 65 if (result)
66 dbg("%03d < %d bytes [0x%02X]", seq, result, buf[0]); 66 dbg("%03d < %d bytes [0x%02X]", seq, result,
67 ((unsigned char *)buf)[0]);
67 else 68 else
68 dbg("%03d < 0 bytes", seq); 69 dbg("%03d < 0 bytes", seq);
69} 70}
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 95a1805b064f..2353679f601e 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -273,12 +273,18 @@ static __u16 product;
273 273
274/* struct ftdi_sio_quirk is used by devices requiring special attention. */ 274/* struct ftdi_sio_quirk is used by devices requiring special attention. */
275struct ftdi_sio_quirk { 275struct ftdi_sio_quirk {
276 int (*probe)(struct usb_serial *);
276 void (*setup)(struct usb_serial *); /* Special settings during startup. */ 277 void (*setup)(struct usb_serial *); /* Special settings during startup. */
277}; 278};
278 279
280static int ftdi_olimex_probe (struct usb_serial *serial);
279static void ftdi_USB_UIRT_setup (struct usb_serial *serial); 281static void ftdi_USB_UIRT_setup (struct usb_serial *serial);
280static void ftdi_HE_TIRA1_setup (struct usb_serial *serial); 282static void ftdi_HE_TIRA1_setup (struct usb_serial *serial);
281 283
284static struct ftdi_sio_quirk ftdi_olimex_quirk = {
285 .probe = ftdi_olimex_probe,
286};
287
282static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { 288static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
283 .setup = ftdi_USB_UIRT_setup, 289 .setup = ftdi_USB_UIRT_setup,
284}; 290};
@@ -319,6 +325,7 @@ static struct usb_device_id id_table_combined [] = {
319 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 325 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
320 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, 326 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
321 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 327 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
328 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
322 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 329 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
323 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 330 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
324 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) }, 331 { USB_DEVICE(FTDI_VID, FTDI_XF_632_PID) },
@@ -525,6 +532,9 @@ static struct usb_device_id id_table_combined [] = {
525 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 532 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
526 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, 533 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
527 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 534 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
535 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
536 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID),
537 .driver_info = (kernel_ulong_t)&ftdi_olimex_quirk },
528 { }, /* Optional parameter entry */ 538 { }, /* Optional parameter entry */
529 { } /* Terminating entry */ 539 { } /* Terminating entry */
530}; 540};
@@ -669,7 +679,7 @@ static struct usb_serial_driver ftdi_sio_device = {
669 679
670/* 680/*
671 * *************************************************************************** 681 * ***************************************************************************
672 * Utlity functions 682 * Utility functions
673 * *************************************************************************** 683 * ***************************************************************************
674 */ 684 */
675 685
@@ -1171,9 +1181,17 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
1171/* Probe function to check for special devices */ 1181/* Probe function to check for special devices */
1172static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id) 1182static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id)
1173{ 1183{
1184 struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info;
1185
1186 if (quirk && quirk->probe) {
1187 int ret = quirk->probe(serial);
1188 if (ret != 0)
1189 return ret;
1190 }
1191
1174 usb_set_serial_data(serial, (void *)id->driver_info); 1192 usb_set_serial_data(serial, (void *)id->driver_info);
1175 1193
1176 return (0); 1194 return 0;
1177} 1195}
1178 1196
1179static int ftdi_sio_port_probe(struct usb_serial_port *port) 1197static int ftdi_sio_port_probe(struct usb_serial_port *port)
@@ -1268,6 +1286,24 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1268 priv->force_rtscts = 1; 1286 priv->force_rtscts = 1;
1269} /* ftdi_HE_TIRA1_setup */ 1287} /* ftdi_HE_TIRA1_setup */
1270 1288
1289/*
1290 * First port on Olimex arm-usb-ocd is reserved for JTAG interface
1291 * and can be accessed from userspace using openocd.
1292 */
1293static int ftdi_olimex_probe(struct usb_serial *serial)
1294{
1295 struct usb_device *udev = serial->dev;
1296 struct usb_interface *interface = serial->interface;
1297
1298 dbg("%s",__FUNCTION__);
1299
1300 if (interface == udev->actconfig->interface[0]) {
1301 info("Ignoring reserved serial port on Olimex arm-usb-ocd\n");
1302 return -ENODEV;
1303 }
1304
1305 return 0;
1306}
1271 1307
1272/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1308/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
1273 * it is called when the usb device is disconnected 1309 * it is called when the usb device is disconnected
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 77ad0a09b384..33aee9047242 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -60,6 +60,9 @@
60/* DMX4ALL DMX Interfaces */ 60/* DMX4ALL DMX Interfaces */
61#define FTDI_DMX4ALL 0xC850 61#define FTDI_DMX4ALL 0xC850
62 62
63/* OpenDCC (www.opendcc.de) product id */
64#define FTDI_OPENDCC_PID 0xBFD8
65
63/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 66/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
64/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 67/* they use the ftdi chipset for the USB interface and the vendor id is the same */
65#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 68#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -518,6 +521,15 @@
518#define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */ 521#define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */
519#define FTDI_IBS_PROD_PID 0xff3f /* future device */ 522#define FTDI_IBS_PROD_PID 0xff3f /* future device */
520 523
524/*
525 * MaxStream devices www.maxstream.net
526 */
527#define FTDI_MAXSTREAM_PID 0xEE18 /* Xbee PKG-U Module */
528
529/* Olimex */
530#define OLIMEX_VID 0x15BA
531#define OLIMEX_ARM_USB_OCD_PID 0x0003
532
521/* Commands */ 533/* Commands */
522#define FTDI_SIO_RESET 0 /* Reset the port */ 534#define FTDI_SIO_RESET 0 /* Reset the port */
523#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 535#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 2366e7b63ece..36620c651079 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -769,11 +769,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
769 return; 769 return;
770 } 770 }
771 771
772 if (!mos7840_port) {
773 dbg("%s", "NULL mos7840_port pointer \n");
774 return;
775 }
776
777 if (mos7840_port_paranoia_check(mos7840_port->port, __FUNCTION__)) { 772 if (mos7840_port_paranoia_check(mos7840_port->port, __FUNCTION__)) {
778 dbg("%s", "Port Paranoia failed \n"); 773 dbg("%s", "Port Paranoia failed \n");
779 return; 774 return;
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 4adfab988e86..00afc1712c39 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -165,12 +165,10 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
165{ 165{
166 struct usb_serial *serial = port->serial; 166 struct usb_serial *serial = port->serial;
167 struct usb_serial_port *wport; 167 struct usb_serial_port *wport;
168 struct omninet_data *od = usb_get_serial_port_data(port);
169 int result = 0; 168 int result = 0;
170 169
171 dbg("%s - port %d", __FUNCTION__, port->number); 170 dbg("%s - port %d", __FUNCTION__, port->number);
172 171
173 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
174 wport = serial->port[1]; 172 wport = serial->port[1];
175 wport->tty = port->tty; 173 wport->tty = port->tty;
176 174
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 8c3f55b080b4..89f067d95076 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -165,7 +165,6 @@ static struct usb_device_id option_ids[] = {
165 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1410) }, /* Novatel U740 */ 165 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1410) }, /* Novatel U740 */
166 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1420) }, /* Novatel EU870 */ 166 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1420) }, /* Novatel EU870 */
167 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */ 167 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */
168 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1430) }, /* Novatel XU870 */
169 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2100) }, /* Novatel EV620 CDMA/EV-DO */ 168 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2100) }, /* Novatel EV620 CDMA/EV-DO */
170 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ 169 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */
171 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ 170 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 644607de4c11..ac1829c6e8f0 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -35,6 +35,7 @@ static struct usb_device_id id_table [] = {
35 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 35 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
36 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 36 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
38 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 39 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
39 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 40 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
40 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
@@ -60,6 +61,7 @@ static struct usb_device_id id_table_3port [] = {
60 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 61 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
61 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 62 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
62 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 63 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
64 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
63 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 65 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
64 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 66 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
65 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 67 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 6d3dad3d1dae..d35369392fed 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -84,7 +84,7 @@ resubmit:
84 84
85static int usb_onetouch_open(struct input_dev *dev) 85static int usb_onetouch_open(struct input_dev *dev)
86{ 86{
87 struct usb_onetouch *onetouch = dev->private; 87 struct usb_onetouch *onetouch = input_get_drvdata(dev);
88 88
89 onetouch->is_open = 1; 89 onetouch->is_open = 1;
90 onetouch->irq->dev = onetouch->udev; 90 onetouch->irq->dev = onetouch->udev;
@@ -98,7 +98,7 @@ static int usb_onetouch_open(struct input_dev *dev)
98 98
99static void usb_onetouch_close(struct input_dev *dev) 99static void usb_onetouch_close(struct input_dev *dev)
100{ 100{
101 struct usb_onetouch *onetouch = dev->private; 101 struct usb_onetouch *onetouch = input_get_drvdata(dev);
102 102
103 usb_kill_urb(onetouch->irq); 103 usb_kill_urb(onetouch->irq);
104 onetouch->is_open = 0; 104 onetouch->is_open = 0;
@@ -185,13 +185,14 @@ int onetouch_connect_input(struct us_data *ss)
185 input_dev->name = onetouch->name; 185 input_dev->name = onetouch->name;
186 input_dev->phys = onetouch->phys; 186 input_dev->phys = onetouch->phys;
187 usb_to_input_id(udev, &input_dev->id); 187 usb_to_input_id(udev, &input_dev->id);
188 input_dev->cdev.dev = &udev->dev; 188 input_dev->dev.parent = &udev->dev;
189 189
190 set_bit(EV_KEY, input_dev->evbit); 190 set_bit(EV_KEY, input_dev->evbit);
191 set_bit(ONETOUCH_BUTTON, input_dev->keybit); 191 set_bit(ONETOUCH_BUTTON, input_dev->keybit);
192 clear_bit(0, input_dev->keybit); 192 clear_bit(0, input_dev->keybit);
193 193
194 input_dev->private = onetouch; 194 input_set_drvdata(input_dev, onetouch);
195
195 input_dev->open = usb_onetouch_open; 196 input_dev->open = usb_onetouch_open;
196 input_dev->close = usb_onetouch_close; 197 input_dev->close = usb_onetouch_close;
197 198
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 8b3145ab7757..d230ee72f9cd 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1179,14 +1179,20 @@ UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1179 US_SC_DEVICE, US_PR_DEVICE, NULL, 1179 US_SC_DEVICE, US_PR_DEVICE, NULL,
1180 US_FL_FIX_INQUIRY ), 1180 US_FL_FIX_INQUIRY ),
1181 1181
1182/* This is a virtual windows driver CD, which the zd1211rw driver automatically 1182/* These are virtual windows driver CDs, which the zd1211rw driver automatically
1183 * converts into a WLAN device. */ 1183 * converts into a WLAN devices. */
1184UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1184UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
1185 "ZyXEL", 1185 "ZyXEL",
1186 "G-220F USB-WLAN Install", 1186 "G-220F USB-WLAN Install",
1187 US_SC_DEVICE, US_PR_DEVICE, NULL, 1187 US_SC_DEVICE, US_PR_DEVICE, NULL,
1188 US_FL_IGNORE_DEVICE ), 1188 US_FL_IGNORE_DEVICE ),
1189 1189
1190UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1191 "SiteCom",
1192 "WL-117 USB-WLAN Install",
1193 US_SC_DEVICE, US_PR_DEVICE, NULL,
1194 US_FL_IGNORE_DEVICE ),
1195
1190#ifdef CONFIG_USB_STORAGE_ISD200 1196#ifdef CONFIG_USB_STORAGE_ISD200
1191UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1197UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1192 "ATI", 1198 "ATI",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4d7485fa553f..6e1f1ea21b38 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -704,6 +704,91 @@ config FB_CG6
704 This is the frame buffer device driver for the CGsix (GX, TurboGX) 704 This is the frame buffer device driver for the CGsix (GX, TurboGX)
705 frame buffer. 705 frame buffer.
706 706
707config FB_FFB
708 bool "Creator/Creator3D/Elite3D support"
709 depends on FB_SBUS && SPARC64
710 select FB_CFB_COPYAREA
711 select FB_CFB_IMAGEBLIT
712 help
713 This is the frame buffer device driver for the Creator, Creator3D,
714 and Elite3D graphics boards.
715
716config FB_TCX
717 bool "TCX (SS4/SS5 only) support"
718 depends on FB_SBUS
719 select FB_CFB_FILLRECT
720 select FB_CFB_COPYAREA
721 select FB_CFB_IMAGEBLIT
722 help
723 This is the frame buffer device driver for the TCX 24/8bit frame
724 buffer.
725
726config FB_CG14
727 bool "CGfourteen (SX) support"
728 depends on FB_SBUS
729 select FB_CFB_FILLRECT
730 select FB_CFB_COPYAREA
731 select FB_CFB_IMAGEBLIT
732 help
733 This is the frame buffer device driver for the CGfourteen frame
734 buffer on Desktop SPARCsystems with the SX graphics option.
735
736config FB_P9100
737 bool "P9100 (Sparcbook 3 only) support"
738 depends on FB_SBUS
739 select FB_CFB_FILLRECT
740 select FB_CFB_COPYAREA
741 select FB_CFB_IMAGEBLIT
742 help
743 This is the frame buffer device driver for the P9100 card
744 supported on Sparcbook 3 machines.
745
746config FB_LEO
747 bool "Leo (ZX) support"
748 depends on FB_SBUS
749 select FB_CFB_FILLRECT
750 select FB_CFB_COPYAREA
751 select FB_CFB_IMAGEBLIT
752 help
753 This is the frame buffer device driver for the SBUS-based Sun ZX
754 (leo) frame buffer cards.
755
756config FB_IGA
757 bool "IGA 168x display support"
758 depends on FB && SPARC32
759 select FB_CFB_FILLRECT
760 select FB_CFB_COPYAREA
761 select FB_CFB_IMAGEBLIT
762 help
763 This is the framebuffer device for the INTERGRAPHICS 1680 and
764 successor frame buffer cards.
765
766config FB_XVR500
767 bool "Sun XVR-500 3DLABS Wildcat support"
768 depends on FB && PCI && SPARC64
769 select FB_CFB_FILLRECT
770 select FB_CFB_COPYAREA
771 select FB_CFB_IMAGEBLIT
772 help
773 This is the framebuffer device for the Sun XVR-500 and similar
774 graphics cards based upon the 3DLABS Wildcat chipset. The driver
775 only works on sparc64 systems where the system firwmare has
776 mostly initialized the card already. It is treated as a
777 completely dumb framebuffer device.
778
779config FB_XVR2500
780 bool "Sun XVR-2500 3DLABS Wildcat support"
781 depends on FB && PCI && SPARC64
782 select FB_CFB_FILLRECT
783 select FB_CFB_COPYAREA
784 select FB_CFB_IMAGEBLIT
785 help
786 This is the framebuffer device for the Sun XVR-2500 and similar
787 graphics cards based upon the 3DLABS Wildcat chipset. The driver
788 only works on sparc64 systems where the system firwmare has
789 mostly initialized the card already. It is treated as a
790 completely dumb framebuffer device.
791
707config FB_PVR2 792config FB_PVR2
708 tristate "NEC PowerVR 2 display support" 793 tristate "NEC PowerVR 2 display support"
709 depends on FB && SH_DREAMCAST 794 depends on FB && SH_DREAMCAST
@@ -1195,7 +1280,7 @@ config FB_ATY
1195config FB_ATY_CT 1280config FB_ATY_CT
1196 bool "Mach64 CT/VT/GT/LT (incl. 3D RAGE) support" 1281 bool "Mach64 CT/VT/GT/LT (incl. 3D RAGE) support"
1197 depends on PCI && FB_ATY 1282 depends on PCI && FB_ATY
1198 default y if SPARC64 && FB_PCI 1283 default y if SPARC64 && PCI
1199 help 1284 help
1200 Say Y here to support use of ATI's 64-bit Rage boards (or other 1285 Say Y here to support use of ATI's 64-bit Rage boards (or other
1201 boards based on the Mach64 CT, VT, GT, and LT chipsets) as a 1286 boards based on the Mach64 CT, VT, GT, and LT chipsets) as a
@@ -1484,95 +1569,6 @@ config FB_AU1200
1484 1569
1485source "drivers/video/geode/Kconfig" 1570source "drivers/video/geode/Kconfig"
1486 1571
1487config FB_FFB
1488 bool "Creator/Creator3D/Elite3D support"
1489 depends on FB_SBUS && SPARC64
1490 select FB_CFB_COPYAREA
1491 select FB_CFB_IMAGEBLIT
1492 help
1493 This is the frame buffer device driver for the Creator, Creator3D,
1494 and Elite3D graphics boards.
1495
1496config FB_TCX
1497 bool "TCX (SS4/SS5 only) support"
1498 depends on FB_SBUS
1499 select FB_CFB_FILLRECT
1500 select FB_CFB_COPYAREA
1501 select FB_CFB_IMAGEBLIT
1502 help
1503 This is the frame buffer device driver for the TCX 24/8bit frame
1504 buffer.
1505
1506config FB_CG14
1507 bool "CGfourteen (SX) support"
1508 depends on FB_SBUS
1509 select FB_CFB_FILLRECT
1510 select FB_CFB_COPYAREA
1511 select FB_CFB_IMAGEBLIT
1512 help
1513 This is the frame buffer device driver for the CGfourteen frame
1514 buffer on Desktop SPARCsystems with the SX graphics option.
1515
1516config FB_P9100
1517 bool "P9100 (Sparcbook 3 only) support"
1518 depends on FB_SBUS
1519 select FB_CFB_FILLRECT
1520 select FB_CFB_COPYAREA
1521 select FB_CFB_IMAGEBLIT
1522 help
1523 This is the frame buffer device driver for the P9100 card
1524 supported on Sparcbook 3 machines.
1525
1526config FB_LEO
1527 bool "Leo (ZX) support"
1528 depends on FB_SBUS
1529 select FB_CFB_FILLRECT
1530 select FB_CFB_COPYAREA
1531 select FB_CFB_IMAGEBLIT
1532 help
1533 This is the frame buffer device driver for the SBUS-based Sun ZX
1534 (leo) frame buffer cards.
1535
1536config FB_XVR500
1537 bool "Sun XVR-500 3DLABS Wildcat support"
1538 depends on (FB = y) && PCI && SPARC64
1539 select FB_CFB_FILLRECT
1540 select FB_CFB_COPYAREA
1541 select FB_CFB_IMAGEBLIT
1542 help
1543 This is the framebuffer device for the Sun XVR-500 and similar
1544 graphics cards based upon the 3DLABS Wildcat chipset. The driver
1545 only works on sparc64 systems where the system firwmare has
1546 mostly initialized the card already. It is treated as a
1547 completely dumb framebuffer device.
1548
1549config FB_XVR2500
1550 bool "Sun XVR-2500 3DLABS Wildcat support"
1551 depends on (FB = y) && PCI && SPARC64
1552 select FB_CFB_FILLRECT
1553 select FB_CFB_COPYAREA
1554 select FB_CFB_IMAGEBLIT
1555 help
1556 This is the framebuffer device for the Sun XVR-2500 and similar
1557 graphics cards based upon the 3DLABS Wildcat chipset. The driver
1558 only works on sparc64 systems where the system firwmare has
1559 mostly initialized the card already. It is treated as a
1560 completely dumb framebuffer device.
1561
1562config FB_PCI
1563 bool "PCI framebuffers"
1564 depends on (FB = y) && PCI && SPARC
1565
1566config FB_IGA
1567 bool "IGA 168x display support"
1568 depends on SPARC32 && FB_PCI
1569 select FB_CFB_FILLRECT
1570 select FB_CFB_COPYAREA
1571 select FB_CFB_IMAGEBLIT
1572 help
1573 This is the framebuffer device for the INTERGRAPHICS 1680 and
1574 successor frame buffer cards.
1575
1576config FB_HIT 1572config FB_HIT
1577 tristate "HD64461 Frame Buffer support" 1573 tristate "HD64461 Frame Buffer support"
1578 depends on FB && HD64461 1574 depends on FB && HD64461
@@ -1796,9 +1792,10 @@ config FB_IBM_GXT4500
1796config FB_PS3 1792config FB_PS3
1797 bool "PS3 GPU framebuffer driver" 1793 bool "PS3 GPU framebuffer driver"
1798 depends on (FB = y) && PS3_PS3AV 1794 depends on (FB = y) && PS3_PS3AV
1799 select FB_CFB_FILLRECT 1795 select FB_SYS_FILLRECT
1800 select FB_CFB_COPYAREA 1796 select FB_SYS_COPYAREA
1801 select FB_CFB_IMAGEBLIT 1797 select FB_SYS_IMAGEBLIT
1798 select FB_SYS_FOPS
1802 ---help--- 1799 ---help---
1803 Include support for the virtual frame buffer in the PS3 platform. 1800 Include support for the virtual frame buffer in the PS3 platform.
1804 1801
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 2460b82a1d93..f46fe95f69fb 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -368,9 +368,14 @@ static const char *vgacon_startup(void)
368#endif 368#endif
369 } 369 }
370 370
371 /* SCREEN_INFO initialized? */
372 if ((ORIG_VIDEO_MODE == 0) &&
373 (ORIG_VIDEO_LINES == 0) &&
374 (ORIG_VIDEO_COLS == 0))
375 goto no_vga;
376
371 /* VGA16 modes are not handled by VGACON */ 377 /* VGA16 modes are not handled by VGACON */
372 if ((ORIG_VIDEO_MODE == 0x00) || /* SCREEN_INFO not initialized */ 378 if ((ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */
373 (ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */
374 (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */ 379 (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */
375 (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */ 380 (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */
376 (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */ 381 (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 267c1ff9ebd9..a12589898597 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -394,26 +394,18 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi)
394 394
395 /* initialize GPIOs */ 395 /* initialize GPIOs */
396 imx_gpio_mode(PD6_PF_LSCLK); 396 imx_gpio_mode(PD6_PF_LSCLK);
397 imx_gpio_mode(PD10_PF_SPL_SPR);
398 imx_gpio_mode(PD11_PF_CONTRAST); 397 imx_gpio_mode(PD11_PF_CONTRAST);
399 imx_gpio_mode(PD14_PF_FLM_VSYNC); 398 imx_gpio_mode(PD14_PF_FLM_VSYNC);
400 imx_gpio_mode(PD13_PF_LP_HSYNC); 399 imx_gpio_mode(PD13_PF_LP_HSYNC);
401 imx_gpio_mode(PD7_PF_REV);
402 imx_gpio_mode(PD8_PF_CLS);
403
404#ifndef CONFIG_MACH_PIMX1
405 /* on PiMX1 used as buffers enable signal
406 */
407 imx_gpio_mode(PD9_PF_PS);
408#endif
409
410#ifndef CONFIG_MACH_MX1FS2
411 /* on mx1fs2 this pin is used to (de)activate the display, so we need
412 * it as a normal gpio
413 */
414 imx_gpio_mode(PD12_PF_ACD_OE); 400 imx_gpio_mode(PD12_PF_ACD_OE);
415#endif
416 401
402 /* These are only needed for Sharp HR TFT displays */
403 if (fbi->pcr & PCR_SHARP) {
404 imx_gpio_mode(PD7_PF_REV);
405 imx_gpio_mode(PD8_PF_CLS);
406 imx_gpio_mode(PD9_PF_PS);
407 imx_gpio_mode(PD10_PF_SPL_SPR);
408 }
417} 409}
418 410
419#ifdef CONFIG_PM 411#ifdef CONFIG_PM
@@ -476,7 +468,6 @@ static int __init imxfb_init_fbinfo(struct device *dev)
476 468
477 info->fbops = &imxfb_ops; 469 info->fbops = &imxfb_ops;
478 info->flags = FBINFO_FLAG_DEFAULT; 470 info->flags = FBINFO_FLAG_DEFAULT;
479 info->pseudo_palette = (fbi + 1);
480 471
481 fbi->rgb[RGB_16] = &def_rgb_16; 472 fbi->rgb[RGB_16] = &def_rgb_16;
482 fbi->rgb[RGB_8] = &def_rgb_8; 473 fbi->rgb[RGB_8] = &def_rgb_8;
@@ -499,6 +490,7 @@ static int __init imxfb_init_fbinfo(struct device *dev)
499 info->var.sync = inf->sync; 490 info->var.sync = inf->sync;
500 info->var.grayscale = inf->cmap_greyscale; 491 info->var.grayscale = inf->cmap_greyscale;
501 fbi->cmap_inverse = inf->cmap_inverse; 492 fbi->cmap_inverse = inf->cmap_inverse;
493 fbi->cmap_static = inf->cmap_static;
502 fbi->pcr = inf->pcr; 494 fbi->pcr = inf->pcr;
503 fbi->lscr1 = inf->lscr1; 495 fbi->lscr1 = inf->lscr1;
504 fbi->dmacr = inf->dmacr; 496 fbi->dmacr = inf->dmacr;
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index ab5e66890e4e..0a04483aa3e0 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -183,15 +183,17 @@ static inline void pm2_RDAC_WR(struct pm2fb_par* p, s32 idx, u32 v)
183 index = PM2VR_RD_INDEXED_DATA; 183 index = PM2VR_RD_INDEXED_DATA;
184 break; 184 break;
185 } 185 }
186 mb(); 186 wmb();
187 pm2_WR(p, index, v); 187 pm2_WR(p, index, v);
188 wmb();
188} 189}
189 190
190static inline void pm2v_RDAC_WR(struct pm2fb_par* p, s32 idx, u32 v) 191static inline void pm2v_RDAC_WR(struct pm2fb_par* p, s32 idx, u32 v)
191{ 192{
192 pm2_WR(p, PM2VR_RD_INDEX_LOW, idx & 0xff); 193 pm2_WR(p, PM2VR_RD_INDEX_LOW, idx & 0xff);
193 mb(); 194 wmb();
194 pm2_WR(p, PM2VR_RD_INDEXED_DATA, v); 195 pm2_WR(p, PM2VR_RD_INDEXED_DATA, v);
196 wmb();
195} 197}
196 198
197#ifdef CONFIG_FB_PM2_FIFO_DISCONNECT 199#ifdef CONFIG_FB_PM2_FIFO_DISCONNECT
@@ -466,11 +468,9 @@ static void set_memclock(struct pm2fb_par* par, u32 clk)
466 WAIT_FIFO(par, 8); 468 WAIT_FIFO(par, 8);
467 pm2_WR(par, PM2VR_RD_INDEX_HIGH, PM2VI_RD_MCLK_CONTROL >> 8); 469 pm2_WR(par, PM2VR_RD_INDEX_HIGH, PM2VI_RD_MCLK_CONTROL >> 8);
468 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 0); 470 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 0);
469 wmb();
470 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_PRESCALE, m); 471 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_PRESCALE, m);
471 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_FEEDBACK, n); 472 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_FEEDBACK, n);
472 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_POSTSCALE, p); 473 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_POSTSCALE, p);
473 wmb();
474 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 1); 474 pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 1);
475 rmb(); 475 rmb();
476 for (i = 256; 476 for (i = 256;
@@ -483,12 +483,9 @@ static void set_memclock(struct pm2fb_par* par, u32 clk)
483 pm2_mnp(clk, &m, &n, &p); 483 pm2_mnp(clk, &m, &n, &p);
484 WAIT_FIFO(par, 10); 484 WAIT_FIFO(par, 10);
485 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 6); 485 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 6);
486 wmb();
487 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_1, m); 486 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_1, m);
488 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_2, n); 487 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_2, n);
489 wmb();
490 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 8|p); 488 pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 8|p);
491 wmb();
492 pm2_RDAC_RD(par, PM2I_RD_MEMORY_CLOCK_STATUS); 489 pm2_RDAC_RD(par, PM2I_RD_MEMORY_CLOCK_STATUS);
493 rmb(); 490 rmb();
494 for (i = 256; 491 for (i = 256;
@@ -509,12 +506,9 @@ static void set_pixclock(struct pm2fb_par* par, u32 clk)
509 pm2_mnp(clk, &m, &n, &p); 506 pm2_mnp(clk, &m, &n, &p);
510 WAIT_FIFO(par, 8); 507 WAIT_FIFO(par, 8);
511 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 0); 508 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 0);
512 wmb();
513 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A1, m); 509 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A1, m);
514 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A2, n); 510 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A2, n);
515 wmb();
516 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 8|p); 511 pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 8|p);
517 wmb();
518 pm2_RDAC_RD(par, PM2I_RD_PIXEL_CLOCK_STATUS); 512 pm2_RDAC_RD(par, PM2I_RD_PIXEL_CLOCK_STATUS);
519 rmb(); 513 rmb();
520 for (i = 256; 514 for (i = 256;
@@ -1066,10 +1060,9 @@ static void pm2fb_block_op(struct fb_info* info, int copy,
1066 1060
1067 if (!w || !h) 1061 if (!w || !h)
1068 return; 1062 return;
1069 WAIT_FIFO(par, 6); 1063 WAIT_FIFO(par, 5);
1070 pm2_WR(par, PM2R_CONFIG, PM2F_CONFIG_FB_WRITE_ENABLE | 1064 pm2_WR(par, PM2R_CONFIG, PM2F_CONFIG_FB_WRITE_ENABLE |
1071 PM2F_CONFIG_FB_READ_SOURCE_ENABLE); 1065 PM2F_CONFIG_FB_READ_SOURCE_ENABLE);
1072 pm2_WR(par, PM2R_FB_PIXEL_OFFSET, 0);
1073 if (copy) 1066 if (copy)
1074 pm2_WR(par, PM2R_FB_SOURCE_DELTA, 1067 pm2_WR(par, PM2R_FB_SOURCE_DELTA,
1075 ((ysrc-y) & 0xfff) << 16 | ((xsrc-x) & 0xfff)); 1068 ((ysrc-y) & 0xfff) << 16 | ((xsrc-x) & 0xfff));
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index c77a1a1fd46b..616a0c08e30c 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -52,11 +52,6 @@
52static char *mode_option __devinitdata; 52static char *mode_option __devinitdata;
53 53
54/* 54/*
55 * If your driver supports multiple boards, you should make the
56 * below data types arrays, or allocate them dynamically (using kmalloc()).
57 */
58
59/*
60 * This structure defines the hardware state of the graphics card. Normally 55 * This structure defines the hardware state of the graphics card. Normally
61 * you place this in a header file in linux/include/video. This file usually 56 * you place this in a header file in linux/include/video. This file usually
62 * also includes register information. That allows other driver subsystems 57 * also includes register information. That allows other driver subsystems
@@ -67,7 +62,7 @@ struct pm3_par {
67 unsigned char __iomem *v_regs;/* virtual address of p_regs */ 62 unsigned char __iomem *v_regs;/* virtual address of p_regs */
68 u32 video; /* video flags before blanking */ 63 u32 video; /* video flags before blanking */
69 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ 64 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
70 u32 palette[16]; 65 u32 palette[16];
71}; 66};
72 67
73/* 68/*
@@ -104,36 +99,28 @@ static inline void PM3_WAIT(struct pm3_par *par, u32 n)
104 while (PM3_READ_REG(par, PM3InFIFOSpace) < n); 99 while (PM3_READ_REG(par, PM3InFIFOSpace) < n);
105} 100}
106 101
107static inline void PM3_SLOW_WRITE_REG(struct pm3_par *par, s32 off, u32 v)
108{
109 if (par->v_regs) {
110 mb();
111 PM3_WAIT(par, 1);
112 wmb();
113 PM3_WRITE_REG(par, off, v);
114 }
115}
116
117static inline void PM3_SET_INDEX(struct pm3_par *par, unsigned index)
118{
119 PM3_SLOW_WRITE_REG(par, PM3RD_IndexHigh, (index >> 8) & 0xff);
120 PM3_SLOW_WRITE_REG(par, PM3RD_IndexLow, index & 0xff);
121}
122
123static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v) 102static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v)
124{ 103{
125 PM3_SET_INDEX(par, r); 104 PM3_WAIT(par, 3);
105 PM3_WRITE_REG(par, PM3RD_IndexHigh, (r >> 8) & 0xff);
106 PM3_WRITE_REG(par, PM3RD_IndexLow, r & 0xff);
126 wmb(); 107 wmb();
127 PM3_WRITE_REG(par, PM3RD_IndexedData, v); 108 PM3_WRITE_REG(par, PM3RD_IndexedData, v);
109 wmb();
128} 110}
129 111
130static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno, 112static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno,
131 unsigned char r, unsigned char g, unsigned char b) 113 unsigned char r, unsigned char g, unsigned char b)
132{ 114{
133 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno); 115 PM3_WAIT(par, 4);
134 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, r); 116 PM3_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno);
135 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, g); 117 wmb();
136 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, b); 118 PM3_WRITE_REG(par, PM3RD_PaletteData, r);
119 wmb();
120 PM3_WRITE_REG(par, PM3RD_PaletteData, g);
121 wmb();
122 PM3_WRITE_REG(par, PM3RD_PaletteData, b);
123 wmb();
137} 124}
138 125
139static void pm3fb_clear_colormap(struct pm3_par *par, 126static void pm3fb_clear_colormap(struct pm3_par *par,
@@ -141,7 +128,7 @@ static void pm3fb_clear_colormap(struct pm3_par *par,
141{ 128{
142 int i; 129 int i;
143 130
144 for (i = 0; i < 256 ; i++) /* fill color map with white */ 131 for (i = 0; i < 256 ; i++)
145 pm3fb_set_color(par, i, r, g, b); 132 pm3fb_set_color(par, i, r, g, b);
146 133
147} 134}
@@ -175,19 +162,26 @@ static void pm3fb_calculate_clock(unsigned long reqclock,
175 } 162 }
176} 163}
177 164
178static inline int pm3fb_shift_bpp(unsigned long depth, int v) 165static inline int pm3fb_depth(const struct fb_var_screeninfo *var)
179{ 166{
180 switch (depth) { 167 if ( var->bits_per_pixel == 16 )
168 return var->red.length + var->green.length
169 + var->blue.length;
170
171 return var->bits_per_pixel;
172}
173
174static inline int pm3fb_shift_bpp(unsigned bpp, int v)
175{
176 switch (bpp) {
181 case 8: 177 case 8:
182 return (v >> 4); 178 return (v >> 4);
183 case 12:
184 case 15:
185 case 16: 179 case 16:
186 return (v >> 3); 180 return (v >> 3);
187 case 32: 181 case 32:
188 return (v >> 2); 182 return (v >> 2);
189 } 183 }
190 DPRINTK("Unsupported depth %ld\n", depth); 184 DPRINTK("Unsupported depth %u\n", bpp);
191 return 0; 185 return 0;
192} 186}
193 187
@@ -206,56 +200,50 @@ static void pm3fb_write_mode(struct fb_info *info)
206 const u32 vbend = vsend + info->var.upper_margin; 200 const u32 vbend = vsend + info->var.upper_margin;
207 const u32 vtotal = info->var.yres + vbend; 201 const u32 vtotal = info->var.yres + vbend;
208 const u32 width = (info->var.xres_virtual + 7) & ~7; 202 const u32 width = (info->var.xres_virtual + 7) & ~7;
209 203 const unsigned bpp = info->var.bits_per_pixel;
210 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff); 204
211 PM3_SLOW_WRITE_REG(par, PM3Aperture0, 0x00000000); 205 PM3_WAIT(par, 20);
212 PM3_SLOW_WRITE_REG(par, PM3Aperture1, 0x00000000); 206 PM3_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff);
213 PM3_SLOW_WRITE_REG(par, PM3FIFODis, 0x00000007); 207 PM3_WRITE_REG(par, PM3Aperture0, 0x00000000);
214 208 PM3_WRITE_REG(par, PM3Aperture1, 0x00000000);
215 PM3_SLOW_WRITE_REG(par, PM3HTotal, 209 PM3_WRITE_REG(par, PM3FIFODis, 0x00000007);
216 pm3fb_shift_bpp(info->var.bits_per_pixel, 210
217 htotal - 1)); 211 PM3_WRITE_REG(par, PM3HTotal,
218 PM3_SLOW_WRITE_REG(par, PM3HsEnd, 212 pm3fb_shift_bpp(bpp, htotal - 1));
219 pm3fb_shift_bpp(info->var.bits_per_pixel, 213 PM3_WRITE_REG(par, PM3HsEnd,
220 hsend)); 214 pm3fb_shift_bpp(bpp, hsend));
221 PM3_SLOW_WRITE_REG(par, PM3HsStart, 215 PM3_WRITE_REG(par, PM3HsStart,
222 pm3fb_shift_bpp(info->var.bits_per_pixel, 216 pm3fb_shift_bpp(bpp, hsstart));
223 hsstart)); 217 PM3_WRITE_REG(par, PM3HbEnd,
224 PM3_SLOW_WRITE_REG(par, PM3HbEnd, 218 pm3fb_shift_bpp(bpp, hbend));
225 pm3fb_shift_bpp(info->var.bits_per_pixel, 219 PM3_WRITE_REG(par, PM3HgEnd,
226 hbend)); 220 pm3fb_shift_bpp(bpp, hbend));
227 PM3_SLOW_WRITE_REG(par, PM3HgEnd, 221 PM3_WRITE_REG(par, PM3ScreenStride,
228 pm3fb_shift_bpp(info->var.bits_per_pixel, 222 pm3fb_shift_bpp(bpp, width));
229 hbend)); 223 PM3_WRITE_REG(par, PM3VTotal, vtotal - 1);
230 PM3_SLOW_WRITE_REG(par, PM3ScreenStride, 224 PM3_WRITE_REG(par, PM3VsEnd, vsend - 1);
231 pm3fb_shift_bpp(info->var.bits_per_pixel, 225 PM3_WRITE_REG(par, PM3VsStart, vsstart - 1);
232 width)); 226 PM3_WRITE_REG(par, PM3VbEnd, vbend);
233 PM3_SLOW_WRITE_REG(par, PM3VTotal, vtotal - 1); 227
234 PM3_SLOW_WRITE_REG(par, PM3VsEnd, vsend - 1); 228 switch (bpp) {
235 PM3_SLOW_WRITE_REG(par, PM3VsStart, vsstart - 1);
236 PM3_SLOW_WRITE_REG(par, PM3VbEnd, vbend);
237
238 switch (info->var.bits_per_pixel) {
239 case 8: 229 case 8:
240 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, 230 PM3_WRITE_REG(par, PM3ByAperture1Mode,
241 PM3ByApertureMode_PIXELSIZE_8BIT); 231 PM3ByApertureMode_PIXELSIZE_8BIT);
242 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, 232 PM3_WRITE_REG(par, PM3ByAperture2Mode,
243 PM3ByApertureMode_PIXELSIZE_8BIT); 233 PM3ByApertureMode_PIXELSIZE_8BIT);
244 break; 234 break;
245 235
246 case 12:
247 case 15:
248 case 16: 236 case 16:
249#ifndef __BIG_ENDIAN 237#ifndef __BIG_ENDIAN
250 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, 238 PM3_WRITE_REG(par, PM3ByAperture1Mode,
251 PM3ByApertureMode_PIXELSIZE_16BIT); 239 PM3ByApertureMode_PIXELSIZE_16BIT);
252 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, 240 PM3_WRITE_REG(par, PM3ByAperture2Mode,
253 PM3ByApertureMode_PIXELSIZE_16BIT); 241 PM3ByApertureMode_PIXELSIZE_16BIT);
254#else 242#else
255 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, 243 PM3_WRITE_REG(par, PM3ByAperture1Mode,
256 PM3ByApertureMode_PIXELSIZE_16BIT | 244 PM3ByApertureMode_PIXELSIZE_16BIT |
257 PM3ByApertureMode_BYTESWAP_BADC); 245 PM3ByApertureMode_BYTESWAP_BADC);
258 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, 246 PM3_WRITE_REG(par, PM3ByAperture2Mode,
259 PM3ByApertureMode_PIXELSIZE_16BIT | 247 PM3ByApertureMode_PIXELSIZE_16BIT |
260 PM3ByApertureMode_BYTESWAP_BADC); 248 PM3ByApertureMode_BYTESWAP_BADC);
261#endif /* ! __BIG_ENDIAN */ 249#endif /* ! __BIG_ENDIAN */
@@ -263,23 +251,22 @@ static void pm3fb_write_mode(struct fb_info *info)
263 251
264 case 32: 252 case 32:
265#ifndef __BIG_ENDIAN 253#ifndef __BIG_ENDIAN
266 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, 254 PM3_WRITE_REG(par, PM3ByAperture1Mode,
267 PM3ByApertureMode_PIXELSIZE_32BIT); 255 PM3ByApertureMode_PIXELSIZE_32BIT);
268 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, 256 PM3_WRITE_REG(par, PM3ByAperture2Mode,
269 PM3ByApertureMode_PIXELSIZE_32BIT); 257 PM3ByApertureMode_PIXELSIZE_32BIT);
270#else 258#else
271 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, 259 PM3_WRITE_REG(par, PM3ByAperture1Mode,
272 PM3ByApertureMode_PIXELSIZE_32BIT | 260 PM3ByApertureMode_PIXELSIZE_32BIT |
273 PM3ByApertureMode_BYTESWAP_DCBA); 261 PM3ByApertureMode_BYTESWAP_DCBA);
274 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, 262 PM3_WRITE_REG(par, PM3ByAperture2Mode,
275 PM3ByApertureMode_PIXELSIZE_32BIT | 263 PM3ByApertureMode_PIXELSIZE_32BIT |
276 PM3ByApertureMode_BYTESWAP_DCBA); 264 PM3ByApertureMode_BYTESWAP_DCBA);
277#endif /* ! __BIG_ENDIAN */ 265#endif /* ! __BIG_ENDIAN */
278 break; 266 break;
279 267
280 default: 268 default:
281 DPRINTK("Unsupported depth %d\n", 269 DPRINTK("Unsupported depth %d\n", bpp);
282 info->var.bits_per_pixel);
283 break; 270 break;
284 } 271 }
285 272
@@ -296,14 +283,15 @@ static void pm3fb_write_mode(struct fb_info *info)
296 PM3VideoControl_VSYNC_MASK); 283 PM3VideoControl_VSYNC_MASK);
297 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | 284 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
298 PM3VideoControl_VSYNC_ACTIVE_HIGH; 285 PM3VideoControl_VSYNC_ACTIVE_HIGH;
299 PM3_SLOW_WRITE_REG(par, PM3VideoControl, video); 286 PM3_WRITE_REG(par, PM3VideoControl, video);
300 } 287 }
301 PM3_SLOW_WRITE_REG(par, PM3VClkCtl, 288 PM3_WRITE_REG(par, PM3VClkCtl,
302 (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC)); 289 (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC));
303 PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); 290 PM3_WRITE_REG(par, PM3ScreenBase, par->base);
304 PM3_SLOW_WRITE_REG(par, PM3ChipConfig, 291 PM3_WRITE_REG(par, PM3ChipConfig,
305 (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD)); 292 (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD));
306 293
294 wmb();
307 { 295 {
308 unsigned char uninitialized_var(m); /* ClkPreScale */ 296 unsigned char uninitialized_var(m); /* ClkPreScale */
309 unsigned char uninitialized_var(n); /* ClkFeedBackScale */ 297 unsigned char uninitialized_var(n); /* ClkFeedBackScale */
@@ -337,7 +325,7 @@ static void pm3fb_write_mode(struct fb_info *info)
337 325
338 PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00); 326 PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00);
339 327
340 switch (info->var.bits_per_pixel) { 328 switch (pm3fb_depth(&info->var)) {
341 case 8: 329 case 8:
342 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, 330 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
343 PM3RD_PixelSize_8_BIT_PIXELS); 331 PM3RD_PixelSize_8_BIT_PIXELS);
@@ -393,57 +381,44 @@ static void pm3fb_write_mode(struct fb_info *info)
393 * hardware independent functions 381 * hardware independent functions
394 */ 382 */
395int pm3fb_init(void); 383int pm3fb_init(void);
396int pm3fb_setup(char*);
397 384
398static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 385static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
399{ 386{
400 u32 lpitch; 387 u32 lpitch;
388 unsigned bpp = var->red.length + var->green.length
389 + var->blue.length + var->transp.length;
401 390
402 var->transp.offset = 0; 391 if ( bpp != var->bits_per_pixel ) {
403 var->transp.length = 0; 392 /* set predefined mode for bits_per_pixel settings */
404 switch(var->bits_per_pixel) { 393
405 case 8: 394 switch(var->bits_per_pixel) {
406 var->red.length = var->green.length = var->blue.length = 8; 395 case 8:
407 var->red.offset = var->green.offset = var->blue.offset = 0; 396 var->red.length = var->green.length = var->blue.length = 8;
408 break; 397 var->red.offset = var->green.offset = var->blue.offset = 0;
409 case 12: 398 var->transp.offset = 0;
410 var->red.offset = 8; 399 var->transp.length = 0;
411 var->red.length = 4; 400 break;
412 var->green.offset = 4; 401 case 16:
413 var->green.length = 4; 402 var->red.length = var->blue.length = 5;
414 var->blue.offset = 0; 403 var->green.length = 6;
415 var->blue.length = 4; 404 var->transp.length = 0;
416 var->transp.offset = 12; 405 break;
417 var->transp.length = 4; 406 case 32:
418 case 15: 407 var->red.length = var->green.length = var->blue.length = 8;
419 var->red.offset = 10; 408 var->transp.length = 8;
420 var->red.length = 5; 409 break;
421 var->green.offset = 5; 410 default:
422 var->green.length = 5; 411 DPRINTK("depth not supported: %u\n", var->bits_per_pixel);
423 var->blue.offset = 0; 412 return -EINVAL;
424 var->blue.length = 5; 413 }
425 var->transp.offset = 15; 414 }
426 var->transp.length = 1; 415 /* it is assumed BGRA order */
427 break; 416 if (var->bits_per_pixel > 8 )
428 case 16: 417 {
429 var->red.offset = 11; 418 var->blue.offset = 0;
430 var->red.length = 5; 419 var->green.offset = var->blue.length;
431 var->green.offset = 5; 420 var->red.offset = var->green.offset + var->green.length;
432 var->green.length = 6; 421 var->transp.offset = var->red.offset + var->red.length;
433 var->blue.offset = 0;
434 var->blue.length = 5;
435 break;
436 case 32:
437 var->transp.offset = 24;
438 var->transp.length = 8;
439 var->red.offset = 16;
440 var->green.offset = 8;
441 var->blue.offset = 0;
442 var->red.length = var->green.length = var->blue.length = 8;
443 break;
444 default:
445 DPRINTK("depth not supported: %u\n", var->bits_per_pixel);
446 return -EINVAL;
447 } 422 }
448 var->height = var->width = -1; 423 var->height = var->width = -1;
449 424
@@ -502,10 +477,9 @@ static int pm3fb_set_par(struct fb_info *info)
502{ 477{
503 struct pm3_par *par = info->par; 478 struct pm3_par *par = info->par;
504 const u32 xres = (info->var.xres + 31) & ~31; 479 const u32 xres = (info->var.xres + 31) & ~31;
505 const int depth = (info->var.bits_per_pixel + 7) & ~7; 480 const unsigned bpp = info->var.bits_per_pixel;
506 481
507 par->base = pm3fb_shift_bpp(info->var.bits_per_pixel, 482 par->base = pm3fb_shift_bpp(bpp,(info->var.yoffset * xres)
508 (info->var.yoffset * xres)
509 + info->var.xoffset); 483 + info->var.xoffset);
510 par->video = 0; 484 par->video = 0;
511 485
@@ -530,12 +504,10 @@ static int pm3fb_set_par(struct fb_info *info)
530 par->video |= PM3VideoControl_DISABLE; 504 par->video |= PM3VideoControl_DISABLE;
531 DPRINTK("PM3Video disabled\n"); 505 DPRINTK("PM3Video disabled\n");
532 } 506 }
533 switch (depth) { 507 switch (bpp) {
534 case 8: 508 case 8:
535 par->video |= PM3VideoControl_PIXELSIZE_8BIT; 509 par->video |= PM3VideoControl_PIXELSIZE_8BIT;
536 break; 510 break;
537 case 12:
538 case 15:
539 case 16: 511 case 16:
540 par->video |= PM3VideoControl_PIXELSIZE_16BIT; 512 par->video |= PM3VideoControl_PIXELSIZE_16BIT;
541 break; 513 break;
@@ -548,9 +520,9 @@ static int pm3fb_set_par(struct fb_info *info)
548 } 520 }
549 521
550 info->fix.visual = 522 info->fix.visual =
551 (depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; 523 (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
552 info->fix.line_length = ((info->var.xres_virtual + 7) & ~7) 524 info->fix.line_length = ((info->var.xres_virtual + 7) & ~7)
553 * depth / 8; 525 * bpp / 8;
554 526
555/* pm3fb_clear_memory(info, 0);*/ 527/* pm3fb_clear_memory(info, 0);*/
556 pm3fb_clear_colormap(par, 0, 0, 0); 528 pm3fb_clear_colormap(par, 0, 0, 0);
@@ -580,8 +552,8 @@ static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
580 * var->{color}.length contains length of bitfield 552 * var->{color}.length contains length of bitfield
581 * {hardwarespecific} contains width of DAC 553 * {hardwarespecific} contains width of DAC
582 * pseudo_palette[X] is programmed to (X << red.offset) | 554 * pseudo_palette[X] is programmed to (X << red.offset) |
583 * (X << green.offset) | 555 * (X << green.offset) |
584 * (X << blue.offset) 556 * (X << blue.offset)
585 * RAMDAC[X] is programmed to (red, green, blue) 557 * RAMDAC[X] is programmed to (red, green, blue)
586 * color depth = SUM(var->{color}.length) 558 * color depth = SUM(var->{color}.length)
587 * 559 *
@@ -621,7 +593,6 @@ static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
621 case 8: 593 case 8:
622 break; 594 break;
623 case 16: 595 case 16:
624 case 24:
625 case 32: 596 case 32:
626 ((u32*)(info->pseudo_palette))[regno] = v; 597 ((u32*)(info->pseudo_palette))[regno] = v;
627 break; 598 break;
@@ -643,7 +614,8 @@ static int pm3fb_pan_display(struct fb_var_screeninfo *var,
643 par->base = pm3fb_shift_bpp(var->bits_per_pixel, 614 par->base = pm3fb_shift_bpp(var->bits_per_pixel,
644 (var->yoffset * xres) 615 (var->yoffset * xres)
645 + var->xoffset); 616 + var->xoffset);
646 PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); 617 PM3_WAIT(par, 1);
618 PM3_WRITE_REG(par, PM3ScreenBase, par->base);
647 return 0; 619 return 0;
648} 620}
649 621
@@ -665,31 +637,31 @@ static int pm3fb_blank(int blank_mode, struct fb_info *info)
665 637
666 switch (blank_mode) { 638 switch (blank_mode) {
667 case FB_BLANK_UNBLANK: 639 case FB_BLANK_UNBLANK:
668 video = video | PM3VideoControl_ENABLE; 640 video |= PM3VideoControl_ENABLE;
669 break; 641 break;
670 case FB_BLANK_NORMAL: /* FIXME */ 642 case FB_BLANK_NORMAL:
671 video = video & ~(PM3VideoControl_ENABLE); 643 video &= ~(PM3VideoControl_ENABLE);
672 break; 644 break;
673 case FB_BLANK_HSYNC_SUSPEND: 645 case FB_BLANK_HSYNC_SUSPEND:
674 video = video & ~(PM3VideoControl_HSYNC_MASK | 646 video &= ~(PM3VideoControl_HSYNC_MASK |
675 PM3VideoControl_BLANK_ACTIVE_LOW); 647 PM3VideoControl_BLANK_ACTIVE_LOW);
676 break; 648 break;
677 case FB_BLANK_VSYNC_SUSPEND: 649 case FB_BLANK_VSYNC_SUSPEND:
678 video = video & ~(PM3VideoControl_VSYNC_MASK | 650 video &= ~(PM3VideoControl_VSYNC_MASK |
679 PM3VideoControl_BLANK_ACTIVE_LOW); 651 PM3VideoControl_BLANK_ACTIVE_LOW);
680 break; 652 break;
681 case FB_BLANK_POWERDOWN: 653 case FB_BLANK_POWERDOWN:
682 video = video & ~(PM3VideoControl_HSYNC_MASK | 654 video &= ~(PM3VideoControl_HSYNC_MASK |
683 PM3VideoControl_VSYNC_MASK | 655 PM3VideoControl_VSYNC_MASK |
684 PM3VideoControl_BLANK_ACTIVE_LOW); 656 PM3VideoControl_BLANK_ACTIVE_LOW);
685 break; 657 break;
686 default: 658 default:
687 DPRINTK("Unsupported blanking %d\n", blank_mode); 659 DPRINTK("Unsupported blanking %d\n", blank_mode);
688 return 1; 660 return 1;
689 } 661 }
690 662
691 PM3_SLOW_WRITE_REG(par,PM3VideoControl, video); 663 PM3_WAIT(par, 1);
692 664 PM3_WRITE_REG(par,PM3VideoControl, video);
693 return 0; 665 return 0;
694} 666}
695 667
@@ -703,9 +675,9 @@ static struct fb_ops pm3fb_ops = {
703 .fb_set_par = pm3fb_set_par, 675 .fb_set_par = pm3fb_set_par,
704 .fb_setcolreg = pm3fb_setcolreg, 676 .fb_setcolreg = pm3fb_setcolreg,
705 .fb_pan_display = pm3fb_pan_display, 677 .fb_pan_display = pm3fb_pan_display,
706 .fb_fillrect = cfb_fillrect, /* Needed !!! */ 678 .fb_fillrect = cfb_fillrect,
707 .fb_copyarea = cfb_copyarea, /* Needed !!! */ 679 .fb_copyarea = cfb_copyarea,
708 .fb_imageblit = cfb_imageblit, /* Needed !!! */ 680 .fb_imageblit = cfb_imageblit,
709 .fb_blank = pm3fb_blank, 681 .fb_blank = pm3fb_blank,
710}; 682};
711 683
@@ -722,7 +694,7 @@ static unsigned long pm3fb_size_memory(struct pm3_par *par)
722 unsigned long memsize = 0, tempBypass, i, temp1, temp2; 694 unsigned long memsize = 0, tempBypass, i, temp1, temp2;
723 unsigned char __iomem *screen_mem; 695 unsigned char __iomem *screen_mem;
724 696
725 pm3fb_fix.smem_len = 64 * 1024 * 1024; /* request full aperture size */ 697 pm3fb_fix.smem_len = 64 * 1024l * 1024; /* request full aperture size */
726 /* Linear frame buffer - request region and map it. */ 698 /* Linear frame buffer - request region and map it. */
727 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len, 699 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len,
728 "pm3fb smem")) { 700 "pm3fb smem")) {
@@ -744,7 +716,8 @@ static unsigned long pm3fb_size_memory(struct pm3_par *par)
744 716
745 DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass); 717 DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
746 718
747 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF); 719 PM3_WAIT(par, 1);
720 PM3_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF);
748 721
749 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */ 722 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
750 for (i = 0; i < 32; i++) { 723 for (i = 0; i < 32; i++) {
@@ -765,10 +738,9 @@ static unsigned long pm3fb_size_memory(struct pm3_par *par)
765 if (memsize + 1 == i) { 738 if (memsize + 1 == i) {
766 for (i = 0; i < 32; i++) { 739 for (i = 0; i < 32; i++) {
767 /* Clear first 32MB ; 0 is 0, no need to byteswap */ 740 /* Clear first 32MB ; 0 is 0, no need to byteswap */
768 writel(0x0000000, 741 writel(0x0000000, (screen_mem + (i * 1048576)));
769 (screen_mem + (i * 1048576)));
770 mb();
771 } 742 }
743 wmb();
772 744
773 for (i = 32; i < 64; i++) { 745 for (i = 32; i < 64; i++) {
774 fb_writel(i * 0x00345678, 746 fb_writel(i * 0x00345678,
@@ -787,7 +759,8 @@ static unsigned long pm3fb_size_memory(struct pm3_par *par)
787 } 759 }
788 DPRINTK("Second detect pass got %ld MB\n", memsize + 1); 760 DPRINTK("Second detect pass got %ld MB\n", memsize + 1);
789 761
790 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass); 762 PM3_WAIT(par, 1);
763 PM3_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass);
791 764
792 iounmap(screen_mem); 765 iounmap(screen_mem);
793 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); 766 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
@@ -890,7 +863,6 @@ static int __devinit pm3fb_probe(struct pci_dev *dev,
890 goto err_exit_both; 863 goto err_exit_both;
891 } 864 }
892 865
893 /* This has to been done !!! */
894 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 866 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
895 retval = -ENOMEM; 867 retval = -ENOMEM;
896 goto err_exit_both; 868 goto err_exit_both;
@@ -907,7 +879,7 @@ static int __devinit pm3fb_probe(struct pci_dev *dev,
907 } 879 }
908 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, 880 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
909 info->fix.id); 881 info->fix.id);
910 pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */ 882 pci_set_drvdata(dev, info);
911 return 0; 883 return 0;
912 884
913 err_exit_all: 885 err_exit_all:
@@ -949,8 +921,7 @@ static void __devexit pm3fb_remove(struct pci_dev *dev)
949 921
950static struct pci_device_id pm3fb_id_table[] = { 922static struct pci_device_id pm3fb_id_table[] = {
951 { PCI_VENDOR_ID_3DLABS, 0x0a, 923 { PCI_VENDOR_ID_3DLABS, 0x0a,
952 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, 924 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
953 0xff0000, 0 },
954 { 0, } 925 { 0, }
955}; 926};
956 927
@@ -964,6 +935,22 @@ static struct pci_driver pm3fb_driver = {
964 935
965MODULE_DEVICE_TABLE(pci, pm3fb_id_table); 936MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
966 937
938#ifndef MODULE
939 /*
940 * Setup
941 */
942
943/*
944 * Only necessary if your driver takes special options,
945 * otherwise we fall back on the generic fb_setup().
946 */
947static int __init pm3fb_setup(char *options)
948{
949 /* Parse user speficied options (`video=pm3fb:') */
950 return 0;
951}
952#endif /* MODULE */
953
967int __init pm3fb_init(void) 954int __init pm3fb_init(void)
968{ 955{
969 /* 956 /*
@@ -985,22 +972,6 @@ static void __exit pm3fb_exit(void)
985 pci_unregister_driver(&pm3fb_driver); 972 pci_unregister_driver(&pm3fb_driver);
986} 973}
987 974
988#ifndef MODULE
989 /*
990 * Setup
991 */
992
993/*
994 * Only necessary if your driver takes special options,
995 * otherwise we fall back on the generic fb_setup().
996 */
997int __init pm3fb_setup(char *options)
998{
999 /* Parse user speficied options (`video=pm3fb:') */
1000 return 0;
1001}
1002#endif /* MODULE */
1003
1004module_init(pm3fb_init); 975module_init(pm3fb_init);
1005module_exit(pm3fb_exit); 976module_exit(pm3fb_exit);
1006 977
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 9756a728b74f..9cf92ba5d6e3 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -951,12 +951,14 @@ static int ps3fb_xdr_settings(u64 xdr_lpar)
951static struct fb_ops ps3fb_ops = { 951static struct fb_ops ps3fb_ops = {
952 .fb_open = ps3fb_open, 952 .fb_open = ps3fb_open,
953 .fb_release = ps3fb_release, 953 .fb_release = ps3fb_release,
954 .fb_read = fb_sys_read,
955 .fb_write = fb_sys_write,
954 .fb_check_var = ps3fb_check_var, 956 .fb_check_var = ps3fb_check_var,
955 .fb_set_par = ps3fb_set_par, 957 .fb_set_par = ps3fb_set_par,
956 .fb_setcolreg = ps3fb_setcolreg, 958 .fb_setcolreg = ps3fb_setcolreg,
957 .fb_fillrect = cfb_fillrect, 959 .fb_fillrect = sys_fillrect,
958 .fb_copyarea = cfb_copyarea, 960 .fb_copyarea = sys_copyarea,
959 .fb_imageblit = cfb_imageblit, 961 .fb_imageblit = sys_imageblit,
960 .fb_mmap = ps3fb_mmap, 962 .fb_mmap = ps3fb_mmap,
961 .fb_blank = ps3fb_blank, 963 .fb_blank = ps3fb_blank,
962 .fb_ioctl = ps3fb_ioctl, 964 .fb_ioctl = ps3fb_ioctl,
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 5fc86ea20692..003c49a490eb 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -660,7 +660,7 @@ int __init w100fb_probe(struct platform_device *pdev)
660 err = -ENODEV; 660 err = -ENODEV;
661 goto out; 661 goto out;
662 } 662 }
663 printk(" at 0x%08lx.\n", mem->start+W100_CFG_BASE); 663 printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE);
664 664
665 /* Remap the framebuffer */ 665 /* Remap the framebuffer */
666 remapped_fbuf = ioremap_nocache(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE); 666 remapped_fbuf = ioremap_nocache(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
@@ -753,10 +753,14 @@ int __init w100fb_probe(struct platform_device *pdev)
753 goto out; 753 goto out;
754 } 754 }
755 755
756 device_create_file(&pdev->dev, &dev_attr_fastpllclk); 756 err = device_create_file(&pdev->dev, &dev_attr_fastpllclk);
757 device_create_file(&pdev->dev, &dev_attr_reg_read); 757 err |= device_create_file(&pdev->dev, &dev_attr_reg_read);
758 device_create_file(&pdev->dev, &dev_attr_reg_write); 758 err |= device_create_file(&pdev->dev, &dev_attr_reg_write);
759 device_create_file(&pdev->dev, &dev_attr_flip); 759 err |= device_create_file(&pdev->dev, &dev_attr_flip);
760
761 if (err != 0)
762 printk(KERN_WARNING "fb%d: failed to register attributes (%d)\n",
763 info->node, err);
760 764
761 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); 765 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
762 return 0; 766 return 0;