aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/ata/Kconfig4
-rw-r--r--drivers/ata/ahci.c60
-rw-r--r--drivers/ata/ata_generic.c6
-rw-r--r--drivers/ata/libata-core.c14
-rw-r--r--drivers/ata/libata-sff.c21
-rw-r--r--drivers/ata/pata_cmd64x.c23
-rw-r--r--drivers/ata/pata_hpt3x2n.c6
-rw-r--r--drivers/ata/pata_it821x.c4
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c5
-rw-r--r--drivers/ata/pata_legacy.c4
-rw-r--r--drivers/ata/pata_rz1000.c6
-rw-r--r--drivers/ata/sata_uli.c3
-rw-r--r--drivers/ata/sata_via.c12
-rw-r--r--drivers/firmware/efivars.c29
-rw-r--r--drivers/isdn/gigaset/common.c61
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c17
-rw-r--r--drivers/kvm/mmu.c16
-rw-r--r--drivers/kvm/paging_tmpl.h77
-rw-r--r--drivers/kvm/svm.c23
-rw-r--r--drivers/md/bitmap.c12
-rw-r--r--drivers/md/dm.c27
-rw-r--r--drivers/md/md.c32
-rw-r--r--drivers/md/raid1.c7
-rw-r--r--drivers/md/raid5.c5
-rw-r--r--drivers/rtc/rtc-sysfs.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c5
-rw-r--r--drivers/spi/spi.c23
-rw-r--r--drivers/spi/spi_s3c24xx.c28
30 files changed, 354 insertions, 183 deletions
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 5207f9e4b44..cbb6f0814ce 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -322,10 +322,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
322 if (result) 322 if (result)
323 return result; 323 return result;
324 324
325 result = acpi_processor_get_platform_limit(pr);
326 if (result)
327 return result;
328
329 return 0; 325 return 0;
330} 326}
331 327
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index da21552d2b1..1c94b43d2c9 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -19,6 +19,10 @@ config ATA
19 19
20if ATA 20if ATA
21 21
22config ATA_NONSTANDARD
23 bool
24 default n
25
22config SATA_AHCI 26config SATA_AHCI
23 tristate "AHCI SATA support" 27 tristate "AHCI SATA support"
24 depends on PCI 28 depends on PCI
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index e3c7b312287..28a82e3403f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -75,6 +75,7 @@ enum {
75 AHCI_CMD_CLR_BUSY = (1 << 10), 75 AHCI_CMD_CLR_BUSY = (1 << 10),
76 76
77 RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */ 77 RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
78 RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
78 RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */ 79 RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
79 80
80 board_ahci = 0, 81 board_ahci = 0,
@@ -202,6 +203,10 @@ struct ahci_port_priv {
202 dma_addr_t cmd_tbl_dma; 203 dma_addr_t cmd_tbl_dma;
203 void *rx_fis; 204 void *rx_fis;
204 dma_addr_t rx_fis_dma; 205 dma_addr_t rx_fis_dma;
206 /* for NCQ spurious interrupt analysis */
207 int ncq_saw_spurious_sdb_cnt;
208 unsigned int ncq_saw_d2h:1;
209 unsigned int ncq_saw_dmas:1;
205}; 210};
206 211
207static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); 212static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -898,7 +903,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
898 903
899 /* clear D2H reception area to properly wait for D2H FIS */ 904 /* clear D2H reception area to properly wait for D2H FIS */
900 ata_tf_init(ap->device, &tf); 905 ata_tf_init(ap->device, &tf);
901 tf.command = 0xff; 906 tf.command = 0x80;
902 ata_tf_to_fis(&tf, d2h_fis, 0); 907 ata_tf_to_fis(&tf, d2h_fis, 0);
903 908
904 rc = sata_std_hardreset(ap, class); 909 rc = sata_std_hardreset(ap, class);
@@ -1109,8 +1114,9 @@ static void ahci_host_intr(struct ata_port *ap)
1109 void __iomem *mmio = ap->host->mmio_base; 1114 void __iomem *mmio = ap->host->mmio_base;
1110 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 1115 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1111 struct ata_eh_info *ehi = &ap->eh_info; 1116 struct ata_eh_info *ehi = &ap->eh_info;
1117 struct ahci_port_priv *pp = ap->private_data;
1112 u32 status, qc_active; 1118 u32 status, qc_active;
1113 int rc; 1119 int rc, known_irq = 0;
1114 1120
1115 status = readl(port_mmio + PORT_IRQ_STAT); 1121 status = readl(port_mmio + PORT_IRQ_STAT);
1116 writel(status, port_mmio + PORT_IRQ_STAT); 1122 writel(status, port_mmio + PORT_IRQ_STAT);
@@ -1137,17 +1143,53 @@ static void ahci_host_intr(struct ata_port *ap)
1137 1143
1138 /* hmmm... a spurious interupt */ 1144 /* hmmm... a spurious interupt */
1139 1145
1140 /* some devices send D2H reg with I bit set during NCQ command phase */ 1146 /* if !NCQ, ignore. No modern ATA device has broken HSM
1141 if (ap->sactive && (status & PORT_IRQ_D2H_REG_FIS)) 1147 * implementation for non-NCQ commands.
1148 */
1149 if (!ap->sactive)
1142 return; 1150 return;
1143 1151
1144 /* ignore interim PIO setup fis interrupts */ 1152 if (status & PORT_IRQ_D2H_REG_FIS) {
1145 if (ata_tag_valid(ap->active_tag) && (status & PORT_IRQ_PIOS_FIS)) 1153 if (!pp->ncq_saw_d2h)
1146 return; 1154 ata_port_printk(ap, KERN_INFO,
1155 "D2H reg with I during NCQ, "
1156 "this message won't be printed again\n");
1157 pp->ncq_saw_d2h = 1;
1158 known_irq = 1;
1159 }
1160
1161 if (status & PORT_IRQ_DMAS_FIS) {
1162 if (!pp->ncq_saw_dmas)
1163 ata_port_printk(ap, KERN_INFO,
1164 "DMAS FIS during NCQ, "
1165 "this message won't be printed again\n");
1166 pp->ncq_saw_dmas = 1;
1167 known_irq = 1;
1168 }
1169
1170 if (status & PORT_IRQ_SDB_FIS &&
1171 pp->ncq_saw_spurious_sdb_cnt < 10) {
1172 /* SDB FIS containing spurious completions might be
1173 * dangerous, we need to know more about them. Print
1174 * more of it.
1175 */
1176 const u32 *f = pp->rx_fis + RX_FIS_SDB;
1177
1178 ata_port_printk(ap, KERN_INFO, "Spurious SDB FIS during NCQ "
1179 "issue=0x%x SAct=0x%x FIS=%08x:%08x%s\n",
1180 readl(port_mmio + PORT_CMD_ISSUE),
1181 readl(port_mmio + PORT_SCR_ACT),
1182 le32_to_cpu(f[0]), le32_to_cpu(f[1]),
1183 pp->ncq_saw_spurious_sdb_cnt < 10 ?
1184 "" : ", shutting up");
1185
1186 pp->ncq_saw_spurious_sdb_cnt++;
1187 known_irq = 1;
1188 }
1147 1189
1148 if (ata_ratelimit()) 1190 if (!known_irq)
1149 ata_port_printk(ap, KERN_INFO, "spurious interrupt " 1191 ata_port_printk(ap, KERN_INFO, "spurious interrupt "
1150 "(irq_stat 0x%x active_tag %d sactive 0x%x)\n", 1192 "(irq_stat 0x%x active_tag 0x%x sactive 0x%x)\n",
1151 status, ap->active_tag, ap->sactive); 1193 status, ap->active_tag, ap->sactive);
1152} 1194}
1153 1195
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 908751d27e7..24af56081b5 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -64,6 +64,7 @@ static void generic_error_handler(struct ata_port *ap)
64/** 64/**
65 * generic_set_mode - mode setting 65 * generic_set_mode - mode setting
66 * @ap: interface to set up 66 * @ap: interface to set up
67 * @unused: returned device on error
67 * 68 *
68 * Use a non standard set_mode function. We don't want to be tuned. 69 * Use a non standard set_mode function. We don't want to be tuned.
69 * The BIOS configured everything. Our job is not to fiddle. We 70 * The BIOS configured everything. Our job is not to fiddle. We
@@ -71,7 +72,7 @@ static void generic_error_handler(struct ata_port *ap)
71 * and respect them. 72 * and respect them.
72 */ 73 */
73 74
74static void generic_set_mode(struct ata_port *ap) 75static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
75{ 76{
76 int dma_enabled = 0; 77 int dma_enabled = 0;
77 int i; 78 int i;
@@ -82,7 +83,7 @@ static void generic_set_mode(struct ata_port *ap)
82 83
83 for (i = 0; i < ATA_MAX_DEVICES; i++) { 84 for (i = 0; i < ATA_MAX_DEVICES; i++) {
84 struct ata_device *dev = &ap->device[i]; 85 struct ata_device *dev = &ap->device[i];
85 if (ata_dev_enabled(dev)) { 86 if (ata_dev_ready(dev)) {
86 /* We don't really care */ 87 /* We don't really care */
87 dev->pio_mode = XFER_PIO_0; 88 dev->pio_mode = XFER_PIO_0;
88 dev->dma_mode = XFER_MW_DMA_0; 89 dev->dma_mode = XFER_MW_DMA_0;
@@ -99,6 +100,7 @@ static void generic_set_mode(struct ata_port *ap)
99 } 100 }
100 } 101 }
101 } 102 }
103 return 0;
102} 104}
103 105
104static struct scsi_host_template generic_sht = { 106static struct scsi_host_template generic_sht = {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 0d51d13b16b..a388a8df004 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2431,18 +2431,8 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2431 int i, rc = 0, used_dma = 0, found = 0; 2431 int i, rc = 0, used_dma = 0, found = 0;
2432 2432
2433 /* has private set_mode? */ 2433 /* has private set_mode? */
2434 if (ap->ops->set_mode) { 2434 if (ap->ops->set_mode)
2435 /* FIXME: make ->set_mode handle no device case and 2435 return ap->ops->set_mode(ap, r_failed_dev);
2436 * return error code and failing device on failure.
2437 */
2438 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2439 if (ata_dev_ready(&ap->device[i])) {
2440 ap->ops->set_mode(ap);
2441 break;
2442 }
2443 }
2444 return 0;
2445 }
2446 2436
2447 /* step 1: calculate xfer_mask */ 2437 /* step 1: calculate xfer_mask */
2448 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2438 for (i = 0; i < ATA_MAX_DEVICES; i++) {
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 623cec914c9..12c88c58803 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -827,7 +827,8 @@ void ata_bmdma_error_handler(struct ata_port *ap)
827 */ 827 */
828void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc) 828void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
829{ 829{
830 ata_bmdma_stop(qc); 830 if (qc->ap->ioaddr.bmdma_addr)
831 ata_bmdma_stop(qc);
831} 832}
832 833
833#ifdef CONFIG_PCI 834#ifdef CONFIG_PCI
@@ -870,7 +871,8 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
870 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; 871 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
871 bmdma = pci_resource_start(pdev, 4); 872 bmdma = pci_resource_start(pdev, 4);
872 if (bmdma) { 873 if (bmdma) {
873 if (inb(bmdma + 2) & 0x80) 874 if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
875 (inb(bmdma + 2) & 0x80))
874 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 876 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
875 probe_ent->port[p].bmdma_addr = bmdma; 877 probe_ent->port[p].bmdma_addr = bmdma;
876 } 878 }
@@ -886,7 +888,8 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
886 bmdma = pci_resource_start(pdev, 4); 888 bmdma = pci_resource_start(pdev, 4);
887 if (bmdma) { 889 if (bmdma) {
888 bmdma += 8; 890 bmdma += 8;
889 if(inb(bmdma + 2) & 0x80) 891 if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
892 (inb(bmdma + 2) & 0x80))
890 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 893 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
891 probe_ent->port[p].bmdma_addr = bmdma; 894 probe_ent->port[p].bmdma_addr = bmdma;
892 } 895 }
@@ -914,13 +917,14 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
914 probe_ent->irq_flags = IRQF_SHARED; 917 probe_ent->irq_flags = IRQF_SHARED;
915 918
916 if (port_mask & ATA_PORT_PRIMARY) { 919 if (port_mask & ATA_PORT_PRIMARY) {
917 probe_ent->irq = ATA_PRIMARY_IRQ; 920 probe_ent->irq = ATA_PRIMARY_IRQ(pdev);
918 probe_ent->port[0].cmd_addr = ATA_PRIMARY_CMD; 921 probe_ent->port[0].cmd_addr = ATA_PRIMARY_CMD;
919 probe_ent->port[0].altstatus_addr = 922 probe_ent->port[0].altstatus_addr =
920 probe_ent->port[0].ctl_addr = ATA_PRIMARY_CTL; 923 probe_ent->port[0].ctl_addr = ATA_PRIMARY_CTL;
921 if (bmdma) { 924 if (bmdma) {
922 probe_ent->port[0].bmdma_addr = bmdma; 925 probe_ent->port[0].bmdma_addr = bmdma;
923 if (inb(bmdma + 2) & 0x80) 926 if ((!(port[0]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
927 (inb(bmdma + 2) & 0x80))
924 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 928 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
925 } 929 }
926 ata_std_ports(&probe_ent->port[0]); 930 ata_std_ports(&probe_ent->port[0]);
@@ -929,15 +933,16 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
929 933
930 if (port_mask & ATA_PORT_SECONDARY) { 934 if (port_mask & ATA_PORT_SECONDARY) {
931 if (probe_ent->irq) 935 if (probe_ent->irq)
932 probe_ent->irq2 = ATA_SECONDARY_IRQ; 936 probe_ent->irq2 = ATA_SECONDARY_IRQ(pdev);
933 else 937 else
934 probe_ent->irq = ATA_SECONDARY_IRQ; 938 probe_ent->irq = ATA_SECONDARY_IRQ(pdev);
935 probe_ent->port[1].cmd_addr = ATA_SECONDARY_CMD; 939 probe_ent->port[1].cmd_addr = ATA_SECONDARY_CMD;
936 probe_ent->port[1].altstatus_addr = 940 probe_ent->port[1].altstatus_addr =
937 probe_ent->port[1].ctl_addr = ATA_SECONDARY_CTL; 941 probe_ent->port[1].ctl_addr = ATA_SECONDARY_CTL;
938 if (bmdma) { 942 if (bmdma) {
939 probe_ent->port[1].bmdma_addr = bmdma + 8; 943 probe_ent->port[1].bmdma_addr = bmdma + 8;
940 if (inb(bmdma + 10) & 0x80) 944 if ((!(port[1]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
945 (inb(bmdma + 10) & 0x80))
941 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 946 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
942 } 947 }
943 ata_std_ports(&probe_ent->port[1]); 948 ata_std_ports(&probe_ent->port[1]);
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 15841a56369..449162cbf93 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -197,7 +197,7 @@ static void cmd64x_set_piomode(struct ata_port *ap, struct ata_device *adev)
197static void cmd64x_set_dmamode(struct ata_port *ap, struct ata_device *adev) 197static void cmd64x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
198{ 198{
199 static const u8 udma_data[] = { 199 static const u8 udma_data[] = {
200 0x31, 0x21, 0x11, 0x25, 0x15, 0x05 200 0x30, 0x20, 0x10, 0x20, 0x10, 0x00
201 }; 201 };
202 static const u8 mwdma_data[] = { 202 static const u8 mwdma_data[] = {
203 0x30, 0x20, 0x10 203 0x30, 0x20, 0x10
@@ -213,12 +213,21 @@ static void cmd64x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
213 pci_read_config_byte(pdev, pciD, &regD); 213 pci_read_config_byte(pdev, pciD, &regD);
214 pci_read_config_byte(pdev, pciU, &regU); 214 pci_read_config_byte(pdev, pciU, &regU);
215 215
216 regD &= ~(0x20 << shift); 216 /* DMA bits off */
217 regU &= ~(0x35 << shift); 217 regD &= ~(0x20 << adev->devno);
218 /* DMA control bits */
219 regU &= ~(0x30 << shift);
220 /* DMA timing bits */
221 regU &= ~(0x05 << adev->devno);
218 222
219 if (adev->dma_mode >= XFER_UDMA_0) 223 if (adev->dma_mode >= XFER_UDMA_0) {
224 /* Merge thge timing value */
220 regU |= udma_data[adev->dma_mode - XFER_UDMA_0] << shift; 225 regU |= udma_data[adev->dma_mode - XFER_UDMA_0] << shift;
221 else 226 /* Merge the control bits */
227 regU |= 1 << adev->devno; /* UDMA on */
228 if (adev->dma_mode > 2) /* 15nS timing */
229 regU |= 4 << adev->devno;
230 } else
222 regD |= mwdma_data[adev->dma_mode - XFER_MW_DMA_0] << shift; 231 regD |= mwdma_data[adev->dma_mode - XFER_MW_DMA_0] << shift;
223 232
224 regD |= 0x20 << adev->devno; 233 regD |= 0x20 << adev->devno;
@@ -239,8 +248,8 @@ static void cmd648_bmdma_stop(struct ata_queued_cmd *qc)
239 struct ata_port *ap = qc->ap; 248 struct ata_port *ap = qc->ap;
240 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 249 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
241 u8 dma_intr; 250 u8 dma_intr;
242 int dma_reg = ap->port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0; 251 int dma_mask = ap->port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0;
243 int dma_mask = ap->port_no ? ARTTIM2 : CFR; 252 int dma_reg = ap->port_no ? ARTTIM2 : CFR;
244 253
245 ata_bmdma_stop(qc); 254 ata_bmdma_stop(qc);
246 255
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index f6817b4093a..886fab9aa62 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt3x2n" 27#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3" 28#define DRV_VERSION "0.3.2"
29 29
30enum { 30enum {
31 HPT_PCI_FAST = (1 << 31), 31 HPT_PCI_FAST = (1 << 31),
@@ -297,11 +297,11 @@ static int hpt3x2n_pair_idle(struct ata_port *ap)
297 return 0; 297 return 0;
298} 298}
299 299
300static int hpt3x2n_use_dpll(struct ata_port *ap, int reading) 300static int hpt3x2n_use_dpll(struct ata_port *ap, int writing)
301{ 301{
302 long flags = (long)ap->host->private_data; 302 long flags = (long)ap->host->private_data;
303 /* See if we should use the DPLL */ 303 /* See if we should use the DPLL */
304 if (reading == 0) 304 if (writing)
305 return USE_DPLL; /* Needed for write */ 305 return USE_DPLL; /* Needed for write */
306 if (flags & PCI66) 306 if (flags & PCI66)
307 return USE_DPLL; /* Needed at 66Mhz */ 307 return USE_DPLL; /* Needed at 66Mhz */
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 0b56ff3d1cf..e8afd486434 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -476,6 +476,7 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
476/** 476/**
477 * it821x_smart_set_mode - mode setting 477 * it821x_smart_set_mode - mode setting
478 * @ap: interface to set up 478 * @ap: interface to set up
479 * @unused: device that failed (error only)
479 * 480 *
480 * Use a non standard set_mode function. We don't want to be tuned. 481 * Use a non standard set_mode function. We don't want to be tuned.
481 * The BIOS configured everything. Our job is not to fiddle. We 482 * The BIOS configured everything. Our job is not to fiddle. We
@@ -483,7 +484,7 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
483 * and respect them. 484 * and respect them.
484 */ 485 */
485 486
486static void it821x_smart_set_mode(struct ata_port *ap) 487static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused)
487{ 488{
488 int dma_enabled = 0; 489 int dma_enabled = 0;
489 int i; 490 int i;
@@ -512,6 +513,7 @@ static void it821x_smart_set_mode(struct ata_port *ap)
512 } 513 }
513 } 514 }
514 } 515 }
516 return 0;
515} 517}
516 518
517/** 519/**
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index cb8924109f5..23b8aab3ebd 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -23,9 +23,9 @@
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.1" 26#define DRV_VERSION "0.1.1ac1"
27 27
28static void ixp4xx_set_mode(struct ata_port *ap) 28static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device *adev)
29{ 29{
30 int i; 30 int i;
31 31
@@ -38,6 +38,7 @@ static void ixp4xx_set_mode(struct ata_port *ap)
38 dev->flags |= ATA_DFLAG_PIO; 38 dev->flags |= ATA_DFLAG_PIO;
39 } 39 }
40 } 40 }
41 return 0;
41} 42}
42 43
43static void ixp4xx_phy_reset(struct ata_port *ap) 44static void ixp4xx_phy_reset(struct ata_port *ap)
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index e7bf9d89c8e..581cb33c6f4 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -96,6 +96,7 @@ static int pio_mask = 0x1F; /* PIO range for autospeed devices */
96/** 96/**
97 * legacy_set_mode - mode setting 97 * legacy_set_mode - mode setting
98 * @ap: IDE interface 98 * @ap: IDE interface
99 * @unused: Device that failed when error is returned
99 * 100 *
100 * Use a non standard set_mode function. We don't want to be tuned. 101 * Use a non standard set_mode function. We don't want to be tuned.
101 * 102 *
@@ -105,7 +106,7 @@ static int pio_mask = 0x1F; /* PIO range for autospeed devices */
105 * expand on this as per hdparm in the base kernel. 106 * expand on this as per hdparm in the base kernel.
106 */ 107 */
107 108
108static void legacy_set_mode(struct ata_port *ap) 109static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused)
109{ 110{
110 int i; 111 int i;
111 112
@@ -118,6 +119,7 @@ static void legacy_set_mode(struct ata_port *ap)
118 dev->flags |= ATA_DFLAG_PIO; 119 dev->flags |= ATA_DFLAG_PIO;
119 } 120 }
120 } 121 }
122 return 0;
121} 123}
122 124
123static struct scsi_host_template legacy_sht = { 125static struct scsi_host_template legacy_sht = {
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index adf4cc134f2..cec0729225e 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -52,19 +52,20 @@ static void rz1000_error_handler(struct ata_port *ap)
52/** 52/**
53 * rz1000_set_mode - mode setting function 53 * rz1000_set_mode - mode setting function
54 * @ap: ATA interface 54 * @ap: ATA interface
55 * @unused: returned device on set_mode failure
55 * 56 *
56 * Use a non standard set_mode function. We don't want to be tuned. We 57 * Use a non standard set_mode function. We don't want to be tuned. We
57 * would prefer to be BIOS generic but for the fact our hardware is 58 * would prefer to be BIOS generic but for the fact our hardware is
58 * whacked out. 59 * whacked out.
59 */ 60 */
60 61
61static void rz1000_set_mode(struct ata_port *ap) 62static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused)
62{ 63{
63 int i; 64 int i;
64 65
65 for (i = 0; i < ATA_MAX_DEVICES; i++) { 66 for (i = 0; i < ATA_MAX_DEVICES; i++) {
66 struct ata_device *dev = &ap->device[i]; 67 struct ata_device *dev = &ap->device[i];
67 if (ata_dev_enabled(dev)) { 68 if (ata_dev_ready(dev)) {
68 /* We don't really care */ 69 /* We don't really care */
69 dev->pio_mode = XFER_PIO_0; 70 dev->pio_mode = XFER_PIO_0;
70 dev->xfer_mode = XFER_PIO_0; 71 dev->xfer_mode = XFER_PIO_0;
@@ -72,6 +73,7 @@ static void rz1000_set_mode(struct ata_port *ap)
72 dev->flags |= ATA_DFLAG_PIO; 73 dev->flags |= ATA_DFLAG_PIO;
73 } 74 }
74 } 75 }
76 return 0;
75} 77}
76 78
77 79
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index 5c603ca3a50..a43aec62d50 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -128,7 +128,8 @@ static const struct ata_port_operations uli_ops = {
128 128
129static struct ata_port_info uli_port_info = { 129static struct ata_port_info uli_port_info = {
130 .sht = &uli_sht, 130 .sht = &uli_sht,
131 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 131 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
132 ATA_FLAG_IGN_SIMPLEX,
132 .pio_mask = 0x1f, /* pio0-4 */ 133 .pio_mask = 0x1f, /* pio0-4 */
133 .udma_mask = 0x7f, /* udma0-6 */ 134 .udma_mask = 0x7f, /* udma0-6 */
134 .port_ops = &uli_ops, 135 .port_ops = &uli_ops,
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 88f0565c888..d3d5c0d5703 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -74,6 +74,7 @@ enum {
74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg); 75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg);
76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
77static void svia_noop_freeze(struct ata_port *ap);
77static void vt6420_error_handler(struct ata_port *ap); 78static void vt6420_error_handler(struct ata_port *ap);
78 79
79static const struct pci_device_id svia_pci_tbl[] = { 80static const struct pci_device_id svia_pci_tbl[] = {
@@ -128,7 +129,7 @@ static const struct ata_port_operations vt6420_sata_ops = {
128 .qc_issue = ata_qc_issue_prot, 129 .qc_issue = ata_qc_issue_prot,
129 .data_xfer = ata_pio_data_xfer, 130 .data_xfer = ata_pio_data_xfer,
130 131
131 .freeze = ata_bmdma_freeze, 132 .freeze = svia_noop_freeze,
132 .thaw = ata_bmdma_thaw, 133 .thaw = ata_bmdma_thaw,
133 .error_handler = vt6420_error_handler, 134 .error_handler = vt6420_error_handler,
134 .post_internal_cmd = ata_bmdma_post_internal_cmd, 135 .post_internal_cmd = ata_bmdma_post_internal_cmd,
@@ -204,6 +205,15 @@ static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
204 outl(val, ap->ioaddr.scr_addr + (4 * sc_reg)); 205 outl(val, ap->ioaddr.scr_addr + (4 * sc_reg));
205} 206}
206 207
208static void svia_noop_freeze(struct ata_port *ap)
209{
210 /* Some VIA controllers choke if ATA_NIEN is manipulated in
211 * certain way. Leave it alone and just clear pending IRQ.
212 */
213 ata_chk_status(ap);
214 ata_bmdma_irq_clear(ap);
215}
216
207/** 217/**
208 * vt6420_prereset - prereset for vt6420 218 * vt6420_prereset - prereset for vt6420
209 * @ap: target ATA port 219 * @ap: target ATA port
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 5ab5e393b88..c6281ccd4fe 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -122,8 +122,6 @@ struct efivar_entry {
122 struct kobject kobj; 122 struct kobject kobj;
123}; 123};
124 124
125#define get_efivar_entry(n) list_entry(n, struct efivar_entry, list)
126
127struct efivar_attribute { 125struct efivar_attribute {
128 struct attribute attr; 126 struct attribute attr;
129 ssize_t (*show) (struct efivar_entry *entry, char *buf); 127 ssize_t (*show) (struct efivar_entry *entry, char *buf);
@@ -386,9 +384,6 @@ static struct sysfs_ops efivar_attr_ops = {
386static void efivar_release(struct kobject *kobj) 384static void efivar_release(struct kobject *kobj)
387{ 385{
388 struct efivar_entry *var = container_of(kobj, struct efivar_entry, kobj); 386 struct efivar_entry *var = container_of(kobj, struct efivar_entry, kobj);
389 spin_lock(&efivars_lock);
390 list_del(&var->list);
391 spin_unlock(&efivars_lock);
392 kfree(var); 387 kfree(var);
393} 388}
394 389
@@ -430,9 +425,8 @@ static ssize_t
430efivar_create(struct subsystem *sub, const char *buf, size_t count) 425efivar_create(struct subsystem *sub, const char *buf, size_t count)
431{ 426{
432 struct efi_variable *new_var = (struct efi_variable *)buf; 427 struct efi_variable *new_var = (struct efi_variable *)buf;
433 struct efivar_entry *search_efivar = NULL; 428 struct efivar_entry *search_efivar, *n;
434 unsigned long strsize1, strsize2; 429 unsigned long strsize1, strsize2;
435 struct list_head *pos, *n;
436 efi_status_t status = EFI_NOT_FOUND; 430 efi_status_t status = EFI_NOT_FOUND;
437 int found = 0; 431 int found = 0;
438 432
@@ -444,8 +438,7 @@ efivar_create(struct subsystem *sub, const char *buf, size_t count)
444 /* 438 /*
445 * Does this variable already exist? 439 * Does this variable already exist?
446 */ 440 */
447 list_for_each_safe(pos, n, &efivar_list) { 441 list_for_each_entry_safe(search_efivar, n, &efivar_list, list) {
448 search_efivar = get_efivar_entry(pos);
449 strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024); 442 strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024);
450 strsize2 = utf8_strsize(new_var->VariableName, 1024); 443 strsize2 = utf8_strsize(new_var->VariableName, 1024);
451 if (strsize1 == strsize2 && 444 if (strsize1 == strsize2 &&
@@ -490,9 +483,8 @@ static ssize_t
490efivar_delete(struct subsystem *sub, const char *buf, size_t count) 483efivar_delete(struct subsystem *sub, const char *buf, size_t count)
491{ 484{
492 struct efi_variable *del_var = (struct efi_variable *)buf; 485 struct efi_variable *del_var = (struct efi_variable *)buf;
493 struct efivar_entry *search_efivar = NULL; 486 struct efivar_entry *search_efivar, *n;
494 unsigned long strsize1, strsize2; 487 unsigned long strsize1, strsize2;
495 struct list_head *pos, *n;
496 efi_status_t status = EFI_NOT_FOUND; 488 efi_status_t status = EFI_NOT_FOUND;
497 int found = 0; 489 int found = 0;
498 490
@@ -504,8 +496,7 @@ efivar_delete(struct subsystem *sub, const char *buf, size_t count)
504 /* 496 /*
505 * Does this variable already exist? 497 * Does this variable already exist?
506 */ 498 */
507 list_for_each_safe(pos, n, &efivar_list) { 499 list_for_each_entry_safe(search_efivar, n, &efivar_list, list) {
508 search_efivar = get_efivar_entry(pos);
509 strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024); 500 strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024);
510 strsize2 = utf8_strsize(del_var->VariableName, 1024); 501 strsize2 = utf8_strsize(del_var->VariableName, 1024);
511 if (strsize1 == strsize2 && 502 if (strsize1 == strsize2 &&
@@ -537,9 +528,9 @@ efivar_delete(struct subsystem *sub, const char *buf, size_t count)
537 spin_unlock(&efivars_lock); 528 spin_unlock(&efivars_lock);
538 return -EIO; 529 return -EIO;
539 } 530 }
531 list_del(&search_efivar->list);
540 /* We need to release this lock before unregistering. */ 532 /* We need to release this lock before unregistering. */
541 spin_unlock(&efivars_lock); 533 spin_unlock(&efivars_lock);
542
543 efivar_unregister(search_efivar); 534 efivar_unregister(search_efivar);
544 535
545 /* It's dead Jim.... */ 536 /* It's dead Jim.... */
@@ -768,10 +759,14 @@ out_free:
768static void __exit 759static void __exit
769efivars_exit(void) 760efivars_exit(void)
770{ 761{
771 struct list_head *pos, *n; 762 struct efivar_entry *entry, *n;
772 763
773 list_for_each_safe(pos, n, &efivar_list) 764 list_for_each_entry_safe(entry, n, &efivar_list, list) {
774 efivar_unregister(get_efivar_entry(pos)); 765 spin_lock(&efivars_lock);
766 list_del(&entry->list);
767 spin_unlock(&efivars_lock);
768 efivar_unregister(entry);
769 }
775 770
776 subsystem_unregister(&vars_subsys); 771 subsystem_unregister(&vars_subsys);
777 firmware_unregister(&efi_subsys); 772 firmware_unregister(&efi_subsys);
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 95eff3b2917..4f75cce6fdf 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -356,16 +356,17 @@ static struct cardstate *alloc_cs(struct gigaset_driver *drv)
356{ 356{
357 unsigned long flags; 357 unsigned long flags;
358 unsigned i; 358 unsigned i;
359 static struct cardstate *ret = NULL; 359 struct cardstate *ret = NULL;
360 360
361 spin_lock_irqsave(&drv->lock, flags); 361 spin_lock_irqsave(&drv->lock, flags);
362 for (i = 0; i < drv->minors; ++i) { 362 for (i = 0; i < drv->minors; ++i) {
363 if (!(drv->flags[i] & VALID_MINOR)) { 363 if (!(drv->flags[i] & VALID_MINOR)) {
364 drv->flags[i] = VALID_MINOR; 364 if (try_module_get(drv->owner)) {
365 ret = drv->cs + i; 365 drv->flags[i] = VALID_MINOR;
366 } 366 ret = drv->cs + i;
367 if (ret) 367 }
368 break; 368 break;
369 }
369 } 370 }
370 spin_unlock_irqrestore(&drv->lock, flags); 371 spin_unlock_irqrestore(&drv->lock, flags);
371 return ret; 372 return ret;
@@ -376,6 +377,8 @@ static void free_cs(struct cardstate *cs)
376 unsigned long flags; 377 unsigned long flags;
377 struct gigaset_driver *drv = cs->driver; 378 struct gigaset_driver *drv = cs->driver;
378 spin_lock_irqsave(&drv->lock, flags); 379 spin_lock_irqsave(&drv->lock, flags);
380 if (drv->flags[cs->minor_index] & VALID_MINOR)
381 module_put(drv->owner);
379 drv->flags[cs->minor_index] = 0; 382 drv->flags[cs->minor_index] = 0;
380 spin_unlock_irqrestore(&drv->lock, flags); 383 spin_unlock_irqrestore(&drv->lock, flags);
381} 384}
@@ -579,7 +582,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
579 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 582 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
580 skb_reserve(bcs->skb, HW_HDR_LEN); 583 skb_reserve(bcs->skb, HW_HDR_LEN);
581 else { 584 else {
582 warn("could not allocate skb\n"); 585 warn("could not allocate skb");
583 bcs->inputstate |= INS_skip_frame; 586 bcs->inputstate |= INS_skip_frame;
584 } 587 }
585 588
@@ -632,17 +635,25 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
632 int i; 635 int i;
633 636
634 gig_dbg(DEBUG_INIT, "allocating cs"); 637 gig_dbg(DEBUG_INIT, "allocating cs");
635 cs = alloc_cs(drv); 638 if (!(cs = alloc_cs(drv))) {
636 if (!cs) 639 err("maximum number of devices exceeded");
637 goto error; 640 return NULL;
641 }
642 mutex_init(&cs->mutex);
643 mutex_lock(&cs->mutex);
644
638 gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); 645 gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
639 cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); 646 cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
640 if (!cs->bcs) 647 if (!cs->bcs) {
648 err("out of memory");
641 goto error; 649 goto error;
650 }
642 gig_dbg(DEBUG_INIT, "allocating inbuf"); 651 gig_dbg(DEBUG_INIT, "allocating inbuf");
643 cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); 652 cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
644 if (!cs->inbuf) 653 if (!cs->inbuf) {
654 err("out of memory");
645 goto error; 655 goto error;
656 }
646 657
647 cs->cs_init = 0; 658 cs->cs_init = 0;
648 cs->channels = channels; 659 cs->channels = channels;
@@ -654,8 +665,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
654 spin_lock_init(&cs->ev_lock); 665 spin_lock_init(&cs->ev_lock);
655 cs->ev_tail = 0; 666 cs->ev_tail = 0;
656 cs->ev_head = 0; 667 cs->ev_head = 0;
657 mutex_init(&cs->mutex);
658 mutex_lock(&cs->mutex);
659 668
660 tasklet_init(&cs->event_tasklet, &gigaset_handle_event, 669 tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
661 (unsigned long) cs); 670 (unsigned long) cs);
@@ -684,8 +693,10 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
684 693
685 for (i = 0; i < channels; ++i) { 694 for (i = 0; i < channels; ++i) {
686 gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i); 695 gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
687 if (!gigaset_initbcs(cs->bcs + i, cs, i)) 696 if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
697 err("could not allocate channel %d data", i);
688 goto error; 698 goto error;
699 }
689 } 700 }
690 701
691 ++cs->cs_init; 702 ++cs->cs_init;
@@ -720,8 +731,10 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
720 make_valid(cs, VALID_ID); 731 make_valid(cs, VALID_ID);
721 ++cs->cs_init; 732 ++cs->cs_init;
722 gig_dbg(DEBUG_INIT, "setting up hw"); 733 gig_dbg(DEBUG_INIT, "setting up hw");
723 if (!cs->ops->initcshw(cs)) 734 if (!cs->ops->initcshw(cs)) {
735 err("could not allocate device specific data");
724 goto error; 736 goto error;
737 }
725 738
726 ++cs->cs_init; 739 ++cs->cs_init;
727 740
@@ -743,8 +756,8 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
743 mutex_unlock(&cs->mutex); 756 mutex_unlock(&cs->mutex);
744 return cs; 757 return cs;
745 758
746error: if (cs) 759error:
747 mutex_unlock(&cs->mutex); 760 mutex_unlock(&cs->mutex);
748 gig_dbg(DEBUG_INIT, "failed"); 761 gig_dbg(DEBUG_INIT, "failed");
749 gigaset_freecs(cs); 762 gigaset_freecs(cs);
750 return NULL; 763 return NULL;
@@ -1040,7 +1053,6 @@ void gigaset_freedriver(struct gigaset_driver *drv)
1040 spin_unlock_irqrestore(&driver_lock, flags); 1053 spin_unlock_irqrestore(&driver_lock, flags);
1041 1054
1042 gigaset_if_freedriver(drv); 1055 gigaset_if_freedriver(drv);
1043 module_put(drv->owner);
1044 1056
1045 kfree(drv->cs); 1057 kfree(drv->cs);
1046 kfree(drv->flags); 1058 kfree(drv->flags);
@@ -1072,10 +1084,6 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
1072 if (!drv) 1084 if (!drv)
1073 return NULL; 1085 return NULL;
1074 1086
1075 if (!try_module_get(owner))
1076 goto out1;
1077
1078 drv->cs = NULL;
1079 drv->have_tty = 0; 1087 drv->have_tty = 0;
1080 drv->minor = minor; 1088 drv->minor = minor;
1081 drv->minors = minors; 1089 drv->minors = minors;
@@ -1087,11 +1095,11 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
1087 1095
1088 drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL); 1096 drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
1089 if (!drv->cs) 1097 if (!drv->cs)
1090 goto out2; 1098 goto error;
1091 1099
1092 drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL); 1100 drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL);
1093 if (!drv->flags) 1101 if (!drv->flags)
1094 goto out3; 1102 goto error;
1095 1103
1096 for (i = 0; i < minors; ++i) { 1104 for (i = 0; i < minors; ++i) {
1097 drv->flags[i] = 0; 1105 drv->flags[i] = 0;
@@ -1108,11 +1116,8 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
1108 1116
1109 return drv; 1117 return drv;
1110 1118
1111out3: 1119error:
1112 kfree(drv->cs); 1120 kfree(drv->cs);
1113out2:
1114 module_put(owner);
1115out1:
1116 kfree(drv); 1121 kfree(drv);
1117 return NULL; 1122 return NULL;
1118} 1123}
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 91e0c75aca8..2db1ca4c680 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -242,6 +242,7 @@ struct kvm_vcpu {
242 u64 pdptrs[4]; /* pae */ 242 u64 pdptrs[4]; /* pae */
243 u64 shadow_efer; 243 u64 shadow_efer;
244 u64 apic_base; 244 u64 apic_base;
245 u64 ia32_misc_enable_msr;
245 int nmsrs; 246 int nmsrs;
246 struct vmx_msr_entry *guest_msrs; 247 struct vmx_msr_entry *guest_msrs;
247 struct vmx_msr_entry *host_msrs; 248 struct vmx_msr_entry *host_msrs;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index be4651abe72..b10972ed0c9 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1226,6 +1226,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1226 case MSR_IA32_APICBASE: 1226 case MSR_IA32_APICBASE:
1227 data = vcpu->apic_base; 1227 data = vcpu->apic_base;
1228 break; 1228 break;
1229 case MSR_IA32_MISC_ENABLE:
1230 data = vcpu->ia32_misc_enable_msr;
1231 break;
1229#ifdef CONFIG_X86_64 1232#ifdef CONFIG_X86_64
1230 case MSR_EFER: 1233 case MSR_EFER:
1231 data = vcpu->shadow_efer; 1234 data = vcpu->shadow_efer;
@@ -1297,6 +1300,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1297 case MSR_IA32_APICBASE: 1300 case MSR_IA32_APICBASE:
1298 vcpu->apic_base = data; 1301 vcpu->apic_base = data;
1299 break; 1302 break;
1303 case MSR_IA32_MISC_ENABLE:
1304 vcpu->ia32_misc_enable_msr = data;
1305 break;
1300 default: 1306 default:
1301 printk(KERN_ERR "kvm: unhandled wrmsr: 0x%x\n", msr); 1307 printk(KERN_ERR "kvm: unhandled wrmsr: 0x%x\n", msr);
1302 return 1; 1308 return 1;
@@ -1600,6 +1606,10 @@ static u32 msrs_to_save[] = {
1600 1606
1601static unsigned num_msrs_to_save; 1607static unsigned num_msrs_to_save;
1602 1608
1609static u32 emulated_msrs[] = {
1610 MSR_IA32_MISC_ENABLE,
1611};
1612
1603static __init void kvm_init_msr_list(void) 1613static __init void kvm_init_msr_list(void)
1604{ 1614{
1605 u32 dummy[2]; 1615 u32 dummy[2];
@@ -1925,7 +1935,7 @@ static long kvm_dev_ioctl(struct file *filp,
1925 if (copy_from_user(&msr_list, user_msr_list, sizeof msr_list)) 1935 if (copy_from_user(&msr_list, user_msr_list, sizeof msr_list))
1926 goto out; 1936 goto out;
1927 n = msr_list.nmsrs; 1937 n = msr_list.nmsrs;
1928 msr_list.nmsrs = num_msrs_to_save; 1938 msr_list.nmsrs = num_msrs_to_save + ARRAY_SIZE(emulated_msrs);
1929 if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list)) 1939 if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list))
1930 goto out; 1940 goto out;
1931 r = -E2BIG; 1941 r = -E2BIG;
@@ -1935,6 +1945,11 @@ static long kvm_dev_ioctl(struct file *filp,
1935 if (copy_to_user(user_msr_list->indices, &msrs_to_save, 1945 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
1936 num_msrs_to_save * sizeof(u32))) 1946 num_msrs_to_save * sizeof(u32)))
1937 goto out; 1947 goto out;
1948 if (copy_to_user(user_msr_list->indices
1949 + num_msrs_to_save * sizeof(u32),
1950 &emulated_msrs,
1951 ARRAY_SIZE(emulated_msrs) * sizeof(u32)))
1952 goto out;
1938 r = 0; 1953 r = 0;
1939 break; 1954 break;
1940 } 1955 }
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index c6f972914f0..22c426cd8cb 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -143,6 +143,7 @@ static int dbg = 1;
143#define PFERR_PRESENT_MASK (1U << 0) 143#define PFERR_PRESENT_MASK (1U << 0)
144#define PFERR_WRITE_MASK (1U << 1) 144#define PFERR_WRITE_MASK (1U << 1)
145#define PFERR_USER_MASK (1U << 2) 145#define PFERR_USER_MASK (1U << 2)
146#define PFERR_FETCH_MASK (1U << 4)
146 147
147#define PT64_ROOT_LEVEL 4 148#define PT64_ROOT_LEVEL 4
148#define PT32_ROOT_LEVEL 2 149#define PT32_ROOT_LEVEL 2
@@ -168,6 +169,11 @@ static int is_cpuid_PSE36(void)
168 return 1; 169 return 1;
169} 170}
170 171
172static int is_nx(struct kvm_vcpu *vcpu)
173{
174 return vcpu->shadow_efer & EFER_NX;
175}
176
171static int is_present_pte(unsigned long pte) 177static int is_present_pte(unsigned long pte)
172{ 178{
173 return pte & PT_PRESENT_MASK; 179 return pte & PT_PRESENT_MASK;
@@ -992,16 +998,6 @@ static inline int fix_read_pf(u64 *shadow_ent)
992 return 0; 998 return 0;
993} 999}
994 1000
995static int may_access(u64 pte, int write, int user)
996{
997
998 if (user && !(pte & PT_USER_MASK))
999 return 0;
1000 if (write && !(pte & PT_WRITABLE_MASK))
1001 return 0;
1002 return 1;
1003}
1004
1005static void paging_free(struct kvm_vcpu *vcpu) 1001static void paging_free(struct kvm_vcpu *vcpu)
1006{ 1002{
1007 nonpaging_free(vcpu); 1003 nonpaging_free(vcpu);
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 6bc41950fbb..149fa45fd9a 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -63,13 +63,15 @@ struct guest_walker {
63 pt_element_t *ptep; 63 pt_element_t *ptep;
64 pt_element_t inherited_ar; 64 pt_element_t inherited_ar;
65 gfn_t gfn; 65 gfn_t gfn;
66 u32 error_code;
66}; 67};
67 68
68/* 69/*
69 * Fetch a guest pte for a guest virtual address 70 * Fetch a guest pte for a guest virtual address
70 */ 71 */
71static void FNAME(walk_addr)(struct guest_walker *walker, 72static int FNAME(walk_addr)(struct guest_walker *walker,
72 struct kvm_vcpu *vcpu, gva_t addr) 73 struct kvm_vcpu *vcpu, gva_t addr,
74 int write_fault, int user_fault, int fetch_fault)
73{ 75{
74 hpa_t hpa; 76 hpa_t hpa;
75 struct kvm_memory_slot *slot; 77 struct kvm_memory_slot *slot;
@@ -86,7 +88,7 @@ static void FNAME(walk_addr)(struct guest_walker *walker,
86 walker->ptep = &vcpu->pdptrs[(addr >> 30) & 3]; 88 walker->ptep = &vcpu->pdptrs[(addr >> 30) & 3];
87 root = *walker->ptep; 89 root = *walker->ptep;
88 if (!(root & PT_PRESENT_MASK)) 90 if (!(root & PT_PRESENT_MASK))
89 return; 91 goto not_present;
90 --walker->level; 92 --walker->level;
91 } 93 }
92#endif 94#endif
@@ -111,11 +113,23 @@ static void FNAME(walk_addr)(struct guest_walker *walker,
111 ASSERT(((unsigned long)walker->table & PAGE_MASK) == 113 ASSERT(((unsigned long)walker->table & PAGE_MASK) ==
112 ((unsigned long)ptep & PAGE_MASK)); 114 ((unsigned long)ptep & PAGE_MASK));
113 115
114 if (is_present_pte(*ptep) && !(*ptep & PT_ACCESSED_MASK))
115 *ptep |= PT_ACCESSED_MASK;
116
117 if (!is_present_pte(*ptep)) 116 if (!is_present_pte(*ptep))
118 break; 117 goto not_present;
118
119 if (write_fault && !is_writeble_pte(*ptep))
120 if (user_fault || is_write_protection(vcpu))
121 goto access_error;
122
123 if (user_fault && !(*ptep & PT_USER_MASK))
124 goto access_error;
125
126#if PTTYPE == 64
127 if (fetch_fault && is_nx(vcpu) && (*ptep & PT64_NX_MASK))
128 goto access_error;
129#endif
130
131 if (!(*ptep & PT_ACCESSED_MASK))
132 *ptep |= PT_ACCESSED_MASK; /* avoid rmw */
119 133
120 if (walker->level == PT_PAGE_TABLE_LEVEL) { 134 if (walker->level == PT_PAGE_TABLE_LEVEL) {
121 walker->gfn = (*ptep & PT_BASE_ADDR_MASK) 135 walker->gfn = (*ptep & PT_BASE_ADDR_MASK)
@@ -146,6 +160,23 @@ static void FNAME(walk_addr)(struct guest_walker *walker,
146 } 160 }
147 walker->ptep = ptep; 161 walker->ptep = ptep;
148 pgprintk("%s: pte %llx\n", __FUNCTION__, (u64)*ptep); 162 pgprintk("%s: pte %llx\n", __FUNCTION__, (u64)*ptep);
163 return 1;
164
165not_present:
166 walker->error_code = 0;
167 goto err;
168
169access_error:
170 walker->error_code = PFERR_PRESENT_MASK;
171
172err:
173 if (write_fault)
174 walker->error_code |= PFERR_WRITE_MASK;
175 if (user_fault)
176 walker->error_code |= PFERR_USER_MASK;
177 if (fetch_fault)
178 walker->error_code |= PFERR_FETCH_MASK;
179 return 0;
149} 180}
150 181
151static void FNAME(release_walker)(struct guest_walker *walker) 182static void FNAME(release_walker)(struct guest_walker *walker)
@@ -347,8 +378,8 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
347 u32 error_code) 378 u32 error_code)
348{ 379{
349 int write_fault = error_code & PFERR_WRITE_MASK; 380 int write_fault = error_code & PFERR_WRITE_MASK;
350 int pte_present = error_code & PFERR_PRESENT_MASK;
351 int user_fault = error_code & PFERR_USER_MASK; 381 int user_fault = error_code & PFERR_USER_MASK;
382 int fetch_fault = error_code & PFERR_FETCH_MASK;
352 struct guest_walker walker; 383 struct guest_walker walker;
353 u64 *shadow_pte; 384 u64 *shadow_pte;
354 int fixed; 385 int fixed;
@@ -365,19 +396,20 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
365 /* 396 /*
366 * Look up the shadow pte for the faulting address. 397 * Look up the shadow pte for the faulting address.
367 */ 398 */
368 FNAME(walk_addr)(&walker, vcpu, addr); 399 r = FNAME(walk_addr)(&walker, vcpu, addr, write_fault, user_fault,
369 shadow_pte = FNAME(fetch)(vcpu, addr, &walker); 400 fetch_fault);
370 401
371 /* 402 /*
372 * The page is not mapped by the guest. Let the guest handle it. 403 * The page is not mapped by the guest. Let the guest handle it.
373 */ 404 */
374 if (!shadow_pte) { 405 if (!r) {
375 pgprintk("%s: not mapped\n", __FUNCTION__); 406 pgprintk("%s: guest page fault\n", __FUNCTION__);
376 inject_page_fault(vcpu, addr, error_code); 407 inject_page_fault(vcpu, addr, walker.error_code);
377 FNAME(release_walker)(&walker); 408 FNAME(release_walker)(&walker);
378 return 0; 409 return 0;
379 } 410 }
380 411
412 shadow_pte = FNAME(fetch)(vcpu, addr, &walker);
381 pgprintk("%s: shadow pte %p %llx\n", __FUNCTION__, 413 pgprintk("%s: shadow pte %p %llx\n", __FUNCTION__,
382 shadow_pte, *shadow_pte); 414 shadow_pte, *shadow_pte);
383 415
@@ -399,22 +431,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
399 * mmio: emulate if accessible, otherwise its a guest fault. 431 * mmio: emulate if accessible, otherwise its a guest fault.
400 */ 432 */
401 if (is_io_pte(*shadow_pte)) { 433 if (is_io_pte(*shadow_pte)) {
402 if (may_access(*shadow_pte, write_fault, user_fault)) 434 return 1;
403 return 1;
404 pgprintk("%s: io work, no access\n", __FUNCTION__);
405 inject_page_fault(vcpu, addr,
406 error_code | PFERR_PRESENT_MASK);
407 kvm_mmu_audit(vcpu, "post page fault (io)");
408 return 0;
409 }
410
411 /*
412 * pte not present, guest page fault.
413 */
414 if (pte_present && !fixed && !write_pt) {
415 inject_page_fault(vcpu, addr, error_code);
416 kvm_mmu_audit(vcpu, "post page fault (guest)");
417 return 0;
418 } 435 }
419 436
420 ++kvm_stat.pf_fixed; 437 ++kvm_stat.pf_fixed;
@@ -429,7 +446,7 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
429 pt_element_t guest_pte; 446 pt_element_t guest_pte;
430 gpa_t gpa; 447 gpa_t gpa;
431 448
432 FNAME(walk_addr)(&walker, vcpu, vaddr); 449 FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0, 0);
433 guest_pte = *walker.ptep; 450 guest_pte = *walker.ptep;
434 FNAME(release_walker)(&walker); 451 FNAME(release_walker)(&walker);
435 452
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 7397bfbbcb1..9c70ff65e6b 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -502,6 +502,7 @@ static void init_vmcb(struct vmcb *vmcb)
502 (1ULL << INTERCEPT_IOIO_PROT) | 502 (1ULL << INTERCEPT_IOIO_PROT) |
503 (1ULL << INTERCEPT_MSR_PROT) | 503 (1ULL << INTERCEPT_MSR_PROT) |
504 (1ULL << INTERCEPT_TASK_SWITCH) | 504 (1ULL << INTERCEPT_TASK_SWITCH) |
505 (1ULL << INTERCEPT_SHUTDOWN) |
505 (1ULL << INTERCEPT_VMRUN) | 506 (1ULL << INTERCEPT_VMRUN) |
506 (1ULL << INTERCEPT_VMMCALL) | 507 (1ULL << INTERCEPT_VMMCALL) |
507 (1ULL << INTERCEPT_VMLOAD) | 508 (1ULL << INTERCEPT_VMLOAD) |
@@ -680,14 +681,14 @@ static void svm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
680 681
681static void svm_get_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) 682static void svm_get_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
682{ 683{
683 dt->limit = vcpu->svm->vmcb->save.ldtr.limit; 684 dt->limit = vcpu->svm->vmcb->save.idtr.limit;
684 dt->base = vcpu->svm->vmcb->save.ldtr.base; 685 dt->base = vcpu->svm->vmcb->save.idtr.base;
685} 686}
686 687
687static void svm_set_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) 688static void svm_set_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
688{ 689{
689 vcpu->svm->vmcb->save.ldtr.limit = dt->limit; 690 vcpu->svm->vmcb->save.idtr.limit = dt->limit;
690 vcpu->svm->vmcb->save.ldtr.base = dt->base ; 691 vcpu->svm->vmcb->save.idtr.base = dt->base ;
691} 692}
692 693
693static void svm_get_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) 694static void svm_get_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
@@ -892,6 +893,19 @@ static int pf_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
892 return 0; 893 return 0;
893} 894}
894 895
896static int shutdown_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
897{
898 /*
899 * VMCB is undefined after a SHUTDOWN intercept
900 * so reinitialize it.
901 */
902 memset(vcpu->svm->vmcb, 0, PAGE_SIZE);
903 init_vmcb(vcpu->svm->vmcb);
904
905 kvm_run->exit_reason = KVM_EXIT_SHUTDOWN;
906 return 0;
907}
908
895static int io_get_override(struct kvm_vcpu *vcpu, 909static int io_get_override(struct kvm_vcpu *vcpu,
896 struct vmcb_seg **seg, 910 struct vmcb_seg **seg,
897 int *addr_override) 911 int *addr_override)
@@ -1249,6 +1263,7 @@ static int (*svm_exit_handlers[])(struct kvm_vcpu *vcpu,
1249 [SVM_EXIT_IOIO] = io_interception, 1263 [SVM_EXIT_IOIO] = io_interception,
1250 [SVM_EXIT_MSR] = msr_interception, 1264 [SVM_EXIT_MSR] = msr_interception,
1251 [SVM_EXIT_TASK_SWITCH] = task_switch_interception, 1265 [SVM_EXIT_TASK_SWITCH] = task_switch_interception,
1266 [SVM_EXIT_SHUTDOWN] = shutdown_interception,
1252 [SVM_EXIT_VMRUN] = invalid_op_interception, 1267 [SVM_EXIT_VMRUN] = invalid_op_interception,
1253 [SVM_EXIT_VMMCALL] = invalid_op_interception, 1268 [SVM_EXIT_VMMCALL] = invalid_op_interception,
1254 [SVM_EXIT_VMLOAD] = invalid_op_interception, 1269 [SVM_EXIT_VMLOAD] = invalid_op_interception,
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5432d07c074..11108165e26 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -479,9 +479,12 @@ static int bitmap_read_sb(struct bitmap *bitmap)
479 int err = -EINVAL; 479 int err = -EINVAL;
480 480
481 /* page 0 is the superblock, read it... */ 481 /* page 0 is the superblock, read it... */
482 if (bitmap->file) 482 if (bitmap->file) {
483 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, PAGE_SIZE); 483 loff_t isize = i_size_read(bitmap->file->f_mapping->host);
484 else { 484 int bytes = isize > PAGE_SIZE ? PAGE_SIZE : isize;
485
486 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes);
487 } else {
485 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 0); 488 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 0);
486 } 489 }
487 if (IS_ERR(bitmap->sb_page)) { 490 if (IS_ERR(bitmap->sb_page)) {
@@ -877,7 +880,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
877 int count; 880 int count;
878 /* unmap the old page, we're done with it */ 881 /* unmap the old page, we're done with it */
879 if (index == num_pages-1) 882 if (index == num_pages-1)
880 count = bytes - index * PAGE_SIZE; 883 count = bytes + sizeof(bitmap_super_t)
884 - index * PAGE_SIZE;
881 else 885 else
882 count = PAGE_SIZE; 886 count = PAGE_SIZE;
883 if (index == 0) { 887 if (index == 0) {
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index fe7c56e1043..3668b170ea6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1116,7 +1116,8 @@ static int __bind(struct mapped_device *md, struct dm_table *t)
1116 if (size != get_capacity(md->disk)) 1116 if (size != get_capacity(md->disk))
1117 memset(&md->geometry, 0, sizeof(md->geometry)); 1117 memset(&md->geometry, 0, sizeof(md->geometry));
1118 1118
1119 __set_size(md, size); 1119 if (md->suspended_bdev)
1120 __set_size(md, size);
1120 if (size == 0) 1121 if (size == 0)
1121 return 0; 1122 return 0;
1122 1123
@@ -1264,6 +1265,11 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
1264 if (!dm_suspended(md)) 1265 if (!dm_suspended(md))
1265 goto out; 1266 goto out;
1266 1267
1268 /* without bdev, the device size cannot be changed */
1269 if (!md->suspended_bdev)
1270 if (get_capacity(md->disk) != dm_table_get_size(table))
1271 goto out;
1272
1267 __unbind(md); 1273 __unbind(md);
1268 r = __bind(md, table); 1274 r = __bind(md, table);
1269 1275
@@ -1341,11 +1347,14 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
1341 /* This does not get reverted if there's an error later. */ 1347 /* This does not get reverted if there's an error later. */
1342 dm_table_presuspend_targets(map); 1348 dm_table_presuspend_targets(map);
1343 1349
1344 md->suspended_bdev = bdget_disk(md->disk, 0); 1350 /* bdget() can stall if the pending I/Os are not flushed */
1345 if (!md->suspended_bdev) { 1351 if (!noflush) {
1346 DMWARN("bdget failed in dm_suspend"); 1352 md->suspended_bdev = bdget_disk(md->disk, 0);
1347 r = -ENOMEM; 1353 if (!md->suspended_bdev) {
1348 goto flush_and_out; 1354 DMWARN("bdget failed in dm_suspend");
1355 r = -ENOMEM;
1356 goto flush_and_out;
1357 }
1349 } 1358 }
1350 1359
1351 /* 1360 /*
@@ -1473,8 +1482,10 @@ int dm_resume(struct mapped_device *md)
1473 1482
1474 unlock_fs(md); 1483 unlock_fs(md);
1475 1484
1476 bdput(md->suspended_bdev); 1485 if (md->suspended_bdev) {
1477 md->suspended_bdev = NULL; 1486 bdput(md->suspended_bdev);
1487 md->suspended_bdev = NULL;
1488 }
1478 1489
1479 clear_bit(DMF_SUSPENDED, &md->flags); 1490 clear_bit(DMF_SUSPENDED, &md->flags);
1480 1491
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d1cb45f6d6a..e8807ea5377 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1633,7 +1633,8 @@ repeat:
1633 * and 'events' is odd, we can roll back to the previous clean state */ 1633 * and 'events' is odd, we can roll back to the previous clean state */
1634 if (nospares 1634 if (nospares
1635 && (mddev->in_sync && mddev->recovery_cp == MaxSector) 1635 && (mddev->in_sync && mddev->recovery_cp == MaxSector)
1636 && (mddev->events & 1)) 1636 && (mddev->events & 1)
1637 && mddev->events != 1)
1637 mddev->events--; 1638 mddev->events--;
1638 else { 1639 else {
1639 /* otherwise we have to go forward and ... */ 1640 /* otherwise we have to go forward and ... */
@@ -3563,6 +3564,8 @@ static int get_bitmap_file(mddev_t * mddev, void __user * arg)
3563 char *ptr, *buf = NULL; 3564 char *ptr, *buf = NULL;
3564 int err = -ENOMEM; 3565 int err = -ENOMEM;
3565 3566
3567 md_allow_write(mddev);
3568
3566 file = kmalloc(sizeof(*file), GFP_KERNEL); 3569 file = kmalloc(sizeof(*file), GFP_KERNEL);
3567 if (!file) 3570 if (!file)
3568 goto out; 3571 goto out;
@@ -5031,6 +5034,33 @@ void md_write_end(mddev_t *mddev)
5031 } 5034 }
5032} 5035}
5033 5036
5037/* md_allow_write(mddev)
5038 * Calling this ensures that the array is marked 'active' so that writes
5039 * may proceed without blocking. It is important to call this before
5040 * attempting a GFP_KERNEL allocation while holding the mddev lock.
5041 * Must be called with mddev_lock held.
5042 */
5043void md_allow_write(mddev_t *mddev)
5044{
5045 if (!mddev->pers)
5046 return;
5047 if (mddev->ro)
5048 return;
5049
5050 spin_lock_irq(&mddev->write_lock);
5051 if (mddev->in_sync) {
5052 mddev->in_sync = 0;
5053 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
5054 if (mddev->safemode_delay &&
5055 mddev->safemode == 0)
5056 mddev->safemode = 1;
5057 spin_unlock_irq(&mddev->write_lock);
5058 md_update_sb(mddev, 0);
5059 } else
5060 spin_unlock_irq(&mddev->write_lock);
5061}
5062EXPORT_SYMBOL_GPL(md_allow_write);
5063
5034static DECLARE_WAIT_QUEUE_HEAD(resync_wait); 5064static DECLARE_WAIT_QUEUE_HEAD(resync_wait);
5035 5065
5036#define SYNC_MARKS 10 5066#define SYNC_MARKS 10
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 164b25dca10..97ee870b265 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1266,6 +1266,11 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
1266 sbio->bi_sector = r1_bio->sector + 1266 sbio->bi_sector = r1_bio->sector +
1267 conf->mirrors[i].rdev->data_offset; 1267 conf->mirrors[i].rdev->data_offset;
1268 sbio->bi_bdev = conf->mirrors[i].rdev->bdev; 1268 sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
1269 for (j = 0; j < vcnt ; j++)
1270 memcpy(page_address(sbio->bi_io_vec[j].bv_page),
1271 page_address(pbio->bi_io_vec[j].bv_page),
1272 PAGE_SIZE);
1273
1269 } 1274 }
1270 } 1275 }
1271 } 1276 }
@@ -2099,6 +2104,8 @@ static int raid1_reshape(mddev_t *mddev)
2099 return -EINVAL; 2104 return -EINVAL;
2100 } 2105 }
2101 2106
2107 md_allow_write(mddev);
2108
2102 raid_disks = mddev->raid_disks + mddev->delta_disks; 2109 raid_disks = mddev->raid_disks + mddev->delta_disks;
2103 2110
2104 if (raid_disks < conf->raid_disks) { 2111 if (raid_disks < conf->raid_disks) {
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index be008f034ad..467c16982d0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -405,6 +405,8 @@ static int resize_stripes(raid5_conf_t *conf, int newsize)
405 if (newsize <= conf->pool_size) 405 if (newsize <= conf->pool_size)
406 return 0; /* never bother to shrink */ 406 return 0; /* never bother to shrink */
407 407
408 md_allow_write(conf->mddev);
409
408 /* Step 1 */ 410 /* Step 1 */
409 sc = kmem_cache_create(conf->cache_name[1-conf->active_name], 411 sc = kmem_cache_create(conf->cache_name[1-conf->active_name],
410 sizeof(struct stripe_head)+(newsize-1)*sizeof(struct r5dev), 412 sizeof(struct stripe_head)+(newsize-1)*sizeof(struct r5dev),
@@ -2678,7 +2680,7 @@ static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
2678 mdk_rdev_t *rdev; 2680 mdk_rdev_t *rdev;
2679 2681
2680 if (!in_chunk_boundary(mddev, raid_bio)) { 2682 if (!in_chunk_boundary(mddev, raid_bio)) {
2681 printk("chunk_aligned_read : non aligned\n"); 2683 PRINTK("chunk_aligned_read : non aligned\n");
2682 return 0; 2684 return 0;
2683 } 2685 }
2684 /* 2686 /*
@@ -3250,6 +3252,7 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
3250 else 3252 else
3251 break; 3253 break;
3252 } 3254 }
3255 md_allow_write(mddev);
3253 while (new > conf->max_nr_stripes) { 3256 while (new > conf->max_nr_stripes) {
3254 if (grow_one_stripe(conf)) 3257 if (grow_one_stripe(conf))
3255 conf->max_nr_stripes++; 3258 conf->max_nr_stripes++;
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 9418a59fb36..2ddd0cf0714 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -78,7 +78,7 @@ static struct attribute_group rtc_attr_group = {
78 .attrs = rtc_attrs, 78 .attrs = rtc_attrs,
79}; 79};
80 80
81static int __devinit rtc_sysfs_add_device(struct class_device *class_dev, 81static int rtc_sysfs_add_device(struct class_device *class_dev,
82 struct class_interface *class_intf) 82 struct class_interface *class_intf)
83{ 83{
84 int err; 84 int err;
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 6ed3f1da929..8b41f9cc256 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1169,8 +1169,9 @@ static int setup(struct spi_device *spi)
1169 spi->bits_per_word - 16 : spi->bits_per_word) 1169 spi->bits_per_word - 16 : spi->bits_per_word)
1170 | SSCR0_SSE 1170 | SSCR0_SSE
1171 | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0); 1171 | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0);
1172 chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) << 4) 1172 chip->cr1 &= ~(SSCR1_SPO | SSCR1_SPH);
1173 | (((spi->mode & SPI_CPOL) != 0) << 3); 1173 chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) ? SSCR1_SPH : 0)
1174 | (((spi->mode & SPI_CPOL) != 0) ? SSCR1_SPO : 0);
1174 1175
1175 /* NOTE: PXA25x_SSP _could_ use external clocking ... */ 1176 /* NOTE: PXA25x_SSP _could_ use external clocking ... */
1176 if (drv_data->ssp_type != PXA25x_SSP) 1177 if (drv_data->ssp_type != PXA25x_SSP)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 270e6211c2e..6307428d2c9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -366,7 +366,6 @@ spi_alloc_master(struct device *dev, unsigned size)
366 366
367 class_device_initialize(&master->cdev); 367 class_device_initialize(&master->cdev);
368 master->cdev.class = &spi_master_class; 368 master->cdev.class = &spi_master_class;
369 kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
370 master->cdev.dev = get_device(dev); 369 master->cdev.dev = get_device(dev);
371 spi_master_set_devdata(master, &master[1]); 370 spi_master_set_devdata(master, &master[1]);
372 371
@@ -466,14 +465,20 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
466 */ 465 */
467struct spi_master *spi_busnum_to_master(u16 bus_num) 466struct spi_master *spi_busnum_to_master(u16 bus_num)
468{ 467{
469 char name[9]; 468 struct class_device *cdev;
470 struct kobject *bus; 469 struct spi_master *master = NULL;
471 470 struct spi_master *m;
472 snprintf(name, sizeof name, "spi%u", bus_num); 471
473 bus = kset_find_obj(&spi_master_class.subsys.kset, name); 472 down(&spi_master_class.sem);
474 if (bus) 473 list_for_each_entry(cdev, &spi_master_class.children, node) {
475 return container_of(bus, struct spi_master, cdev.kobj); 474 m = container_of(cdev, struct spi_master, cdev);
476 return NULL; 475 if (m->bus_num == bus_num) {
476 master = spi_master_get(m);
477 break;
478 }
479 }
480 up(&spi_master_class.sem);
481 return master;
477} 482}
478EXPORT_SYMBOL_GPL(spi_busnum_to_master); 483EXPORT_SYMBOL_GPL(spi_busnum_to_master);
479 484
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 8ca08713528..651379c51ae 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -10,9 +10,6 @@
10 * 10 *
11*/ 11*/
12 12
13
14//#define DEBUG
15
16#include <linux/init.h> 13#include <linux/init.h>
17#include <linux/spinlock.h> 14#include <linux/spinlock.h>
18#include <linux/workqueue.h> 15#include <linux/workqueue.h>
@@ -44,6 +41,9 @@ struct s3c24xx_spi {
44 int len; 41 int len;
45 int count; 42 int count;
46 43
44 int (*set_cs)(struct s3c2410_spi_info *spi,
45 int cs, int pol);
46
47 /* data buffers */ 47 /* data buffers */
48 const unsigned char *tx; 48 const unsigned char *tx;
49 unsigned char *rx; 49 unsigned char *rx;
@@ -64,6 +64,11 @@ static inline struct s3c24xx_spi *to_hw(struct spi_device *sdev)
64 return spi_master_get_devdata(sdev->master); 64 return spi_master_get_devdata(sdev->master);
65} 65}
66 66
67static void s3c24xx_spi_gpiocs(struct s3c2410_spi_info *spi, int cs, int pol)
68{
69 s3c2410_gpio_setpin(spi->pin_cs, pol);
70}
71
67static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) 72static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
68{ 73{
69 struct s3c24xx_spi *hw = to_hw(spi); 74 struct s3c24xx_spi *hw = to_hw(spi);
@@ -72,10 +77,7 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
72 77
73 switch (value) { 78 switch (value) {
74 case BITBANG_CS_INACTIVE: 79 case BITBANG_CS_INACTIVE:
75 if (hw->pdata->set_cs) 80 hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol^1);
76 hw->pdata->set_cs(hw->pdata, value, cspol);
77 else
78 s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol ^ 1);
79 break; 81 break;
80 82
81 case BITBANG_CS_ACTIVE: 83 case BITBANG_CS_ACTIVE:
@@ -96,14 +98,9 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
96 /* write new configration */ 98 /* write new configration */
97 99
98 writeb(spcon, hw->regs + S3C2410_SPCON); 100 writeb(spcon, hw->regs + S3C2410_SPCON);
99 101 hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol);
100 if (hw->pdata->set_cs)
101 hw->pdata->set_cs(hw->pdata, value, cspol);
102 else
103 s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol);
104 102
105 break; 103 break;
106
107 } 104 }
108} 105}
109 106
@@ -330,9 +327,12 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
330 /* setup any gpio we can */ 327 /* setup any gpio we can */
331 328
332 if (!hw->pdata->set_cs) { 329 if (!hw->pdata->set_cs) {
330 hw->set_cs = s3c24xx_spi_gpiocs;
331
333 s3c2410_gpio_setpin(hw->pdata->pin_cs, 1); 332 s3c2410_gpio_setpin(hw->pdata->pin_cs, 1);
334 s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT); 333 s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT);
335 } 334 } else
335 hw->set_cs = hw->pdata->set_cs;
336 336
337 /* register our spi controller */ 337 /* register our spi controller */
338 338