diff options
Diffstat (limited to 'drivers')
111 files changed, 1297 insertions, 1100 deletions
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 3839efd5ea..1538355c26 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -194,6 +194,23 @@ static int get_date_field(char **p, u32 * value) | |||
194 | return result; | 194 | return result; |
195 | } | 195 | } |
196 | 196 | ||
197 | /* Read a possibly BCD register, always return binary */ | ||
198 | static u32 cmos_bcd_read(int offset, int rtc_control) | ||
199 | { | ||
200 | u32 val = CMOS_READ(offset); | ||
201 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
202 | BCD_TO_BIN(val); | ||
203 | return val; | ||
204 | } | ||
205 | |||
206 | /* Write binary value into possibly BCD register */ | ||
207 | static void cmos_bcd_write(u32 val, int offset, int rtc_control) | ||
208 | { | ||
209 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
210 | BIN_TO_BCD(val); | ||
211 | CMOS_WRITE(val, offset); | ||
212 | } | ||
213 | |||
197 | static ssize_t | 214 | static ssize_t |
198 | acpi_system_write_alarm(struct file *file, | 215 | acpi_system_write_alarm(struct file *file, |
199 | const char __user * buffer, size_t count, loff_t * ppos) | 216 | const char __user * buffer, size_t count, loff_t * ppos) |
@@ -258,35 +275,18 @@ acpi_system_write_alarm(struct file *file, | |||
258 | spin_lock_irq(&rtc_lock); | 275 | spin_lock_irq(&rtc_lock); |
259 | 276 | ||
260 | rtc_control = CMOS_READ(RTC_CONTROL); | 277 | rtc_control = CMOS_READ(RTC_CONTROL); |
261 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
262 | BIN_TO_BCD(yr); | ||
263 | BIN_TO_BCD(mo); | ||
264 | BIN_TO_BCD(day); | ||
265 | BIN_TO_BCD(hr); | ||
266 | BIN_TO_BCD(min); | ||
267 | BIN_TO_BCD(sec); | ||
268 | } | ||
269 | 278 | ||
270 | if (adjust) { | 279 | if (adjust) { |
271 | yr += CMOS_READ(RTC_YEAR); | 280 | yr += cmos_bcd_read(RTC_YEAR, rtc_control); |
272 | mo += CMOS_READ(RTC_MONTH); | 281 | mo += cmos_bcd_read(RTC_MONTH, rtc_control); |
273 | day += CMOS_READ(RTC_DAY_OF_MONTH); | 282 | day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control); |
274 | hr += CMOS_READ(RTC_HOURS); | 283 | hr += cmos_bcd_read(RTC_HOURS, rtc_control); |
275 | min += CMOS_READ(RTC_MINUTES); | 284 | min += cmos_bcd_read(RTC_MINUTES, rtc_control); |
276 | sec += CMOS_READ(RTC_SECONDS); | 285 | sec += cmos_bcd_read(RTC_SECONDS, rtc_control); |
277 | } | 286 | } |
278 | 287 | ||
279 | spin_unlock_irq(&rtc_lock); | 288 | spin_unlock_irq(&rtc_lock); |
280 | 289 | ||
281 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
282 | BCD_TO_BIN(yr); | ||
283 | BCD_TO_BIN(mo); | ||
284 | BCD_TO_BIN(day); | ||
285 | BCD_TO_BIN(hr); | ||
286 | BCD_TO_BIN(min); | ||
287 | BCD_TO_BIN(sec); | ||
288 | } | ||
289 | |||
290 | if (sec > 59) { | 290 | if (sec > 59) { |
291 | min++; | 291 | min++; |
292 | sec -= 60; | 292 | sec -= 60; |
@@ -307,14 +307,6 @@ acpi_system_write_alarm(struct file *file, | |||
307 | yr++; | 307 | yr++; |
308 | mo -= 12; | 308 | mo -= 12; |
309 | } | 309 | } |
310 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
311 | BIN_TO_BCD(yr); | ||
312 | BIN_TO_BCD(mo); | ||
313 | BIN_TO_BCD(day); | ||
314 | BIN_TO_BCD(hr); | ||
315 | BIN_TO_BCD(min); | ||
316 | BIN_TO_BCD(sec); | ||
317 | } | ||
318 | 310 | ||
319 | spin_lock_irq(&rtc_lock); | 311 | spin_lock_irq(&rtc_lock); |
320 | /* | 312 | /* |
@@ -326,9 +318,9 @@ acpi_system_write_alarm(struct file *file, | |||
326 | CMOS_READ(RTC_INTR_FLAGS); | 318 | CMOS_READ(RTC_INTR_FLAGS); |
327 | 319 | ||
328 | /* write the fields the rtc knows about */ | 320 | /* write the fields the rtc knows about */ |
329 | CMOS_WRITE(hr, RTC_HOURS_ALARM); | 321 | cmos_bcd_write(hr, RTC_HOURS_ALARM, rtc_control); |
330 | CMOS_WRITE(min, RTC_MINUTES_ALARM); | 322 | cmos_bcd_write(min, RTC_MINUTES_ALARM, rtc_control); |
331 | CMOS_WRITE(sec, RTC_SECONDS_ALARM); | 323 | cmos_bcd_write(sec, RTC_SECONDS_ALARM, rtc_control); |
332 | 324 | ||
333 | /* | 325 | /* |
334 | * If the system supports an enhanced alarm it will have non-zero | 326 | * If the system supports an enhanced alarm it will have non-zero |
@@ -336,11 +328,11 @@ acpi_system_write_alarm(struct file *file, | |||
336 | * to the RTC area of memory. | 328 | * to the RTC area of memory. |
337 | */ | 329 | */ |
338 | if (acpi_gbl_FADT.day_alarm) | 330 | if (acpi_gbl_FADT.day_alarm) |
339 | CMOS_WRITE(day, acpi_gbl_FADT.day_alarm); | 331 | cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control); |
340 | if (acpi_gbl_FADT.month_alarm) | 332 | if (acpi_gbl_FADT.month_alarm) |
341 | CMOS_WRITE(mo, acpi_gbl_FADT.month_alarm); | 333 | cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control); |
342 | if (acpi_gbl_FADT.century) | 334 | if (acpi_gbl_FADT.century) |
343 | CMOS_WRITE(yr / 100, acpi_gbl_FADT.century); | 335 | cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control); |
344 | /* enable the rtc alarm interrupt */ | 336 | /* enable the rtc alarm interrupt */ |
345 | rtc_control |= RTC_AIE; | 337 | rtc_control |= RTC_AIE; |
346 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 338 | CMOS_WRITE(rtc_control, RTC_CONTROL); |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 95229e77bf..49cf4cf1a5 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <linux/dmi.h> | ||
44 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
45 | #include <scsi/scsi_cmnd.h> | 46 | #include <scsi/scsi_cmnd.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -241,6 +242,7 @@ static void ahci_pmp_attach(struct ata_port *ap); | |||
241 | static void ahci_pmp_detach(struct ata_port *ap); | 242 | static void ahci_pmp_detach(struct ata_port *ap); |
242 | static void ahci_error_handler(struct ata_port *ap); | 243 | static void ahci_error_handler(struct ata_port *ap); |
243 | static void ahci_vt8251_error_handler(struct ata_port *ap); | 244 | static void ahci_vt8251_error_handler(struct ata_port *ap); |
245 | static void ahci_p5wdh_error_handler(struct ata_port *ap); | ||
244 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); | 246 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); |
245 | static int ahci_port_resume(struct ata_port *ap); | 247 | static int ahci_port_resume(struct ata_port *ap); |
246 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); | 248 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); |
@@ -339,6 +341,40 @@ static const struct ata_port_operations ahci_vt8251_ops = { | |||
339 | .port_stop = ahci_port_stop, | 341 | .port_stop = ahci_port_stop, |
340 | }; | 342 | }; |
341 | 343 | ||
344 | static const struct ata_port_operations ahci_p5wdh_ops = { | ||
345 | .check_status = ahci_check_status, | ||
346 | .check_altstatus = ahci_check_status, | ||
347 | .dev_select = ata_noop_dev_select, | ||
348 | |||
349 | .tf_read = ahci_tf_read, | ||
350 | |||
351 | .qc_defer = sata_pmp_qc_defer_cmd_switch, | ||
352 | .qc_prep = ahci_qc_prep, | ||
353 | .qc_issue = ahci_qc_issue, | ||
354 | |||
355 | .irq_clear = ahci_irq_clear, | ||
356 | |||
357 | .scr_read = ahci_scr_read, | ||
358 | .scr_write = ahci_scr_write, | ||
359 | |||
360 | .freeze = ahci_freeze, | ||
361 | .thaw = ahci_thaw, | ||
362 | |||
363 | .error_handler = ahci_p5wdh_error_handler, | ||
364 | .post_internal_cmd = ahci_post_internal_cmd, | ||
365 | |||
366 | .pmp_attach = ahci_pmp_attach, | ||
367 | .pmp_detach = ahci_pmp_detach, | ||
368 | |||
369 | #ifdef CONFIG_PM | ||
370 | .port_suspend = ahci_port_suspend, | ||
371 | .port_resume = ahci_port_resume, | ||
372 | #endif | ||
373 | |||
374 | .port_start = ahci_port_start, | ||
375 | .port_stop = ahci_port_stop, | ||
376 | }; | ||
377 | |||
342 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) | 378 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) |
343 | 379 | ||
344 | static const struct ata_port_info ahci_port_info[] = { | 380 | static const struct ata_port_info ahci_port_info[] = { |
@@ -1213,6 +1249,53 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, | |||
1213 | return rc ?: -EAGAIN; | 1249 | return rc ?: -EAGAIN; |
1214 | } | 1250 | } |
1215 | 1251 | ||
1252 | static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, | ||
1253 | unsigned long deadline) | ||
1254 | { | ||
1255 | struct ata_port *ap = link->ap; | ||
1256 | struct ahci_port_priv *pp = ap->private_data; | ||
1257 | u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; | ||
1258 | struct ata_taskfile tf; | ||
1259 | int rc; | ||
1260 | |||
1261 | ahci_stop_engine(ap); | ||
1262 | |||
1263 | /* clear D2H reception area to properly wait for D2H FIS */ | ||
1264 | ata_tf_init(link->device, &tf); | ||
1265 | tf.command = 0x80; | ||
1266 | ata_tf_to_fis(&tf, 0, 0, d2h_fis); | ||
1267 | |||
1268 | rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context), | ||
1269 | deadline); | ||
1270 | |||
1271 | ahci_start_engine(ap); | ||
1272 | |||
1273 | if (rc || ata_link_offline(link)) | ||
1274 | return rc; | ||
1275 | |||
1276 | /* spec mandates ">= 2ms" before checking status */ | ||
1277 | msleep(150); | ||
1278 | |||
1279 | /* The pseudo configuration device on SIMG4726 attached to | ||
1280 | * ASUS P5W-DH Deluxe doesn't send signature FIS after | ||
1281 | * hardreset if no device is attached to the first downstream | ||
1282 | * port && the pseudo device locks up on SRST w/ PMP==0. To | ||
1283 | * work around this, wait for !BSY only briefly. If BSY isn't | ||
1284 | * cleared, perform CLO and proceed to IDENTIFY (achieved by | ||
1285 | * ATA_LFLAG_NO_SRST and ATA_LFLAG_ASSUME_ATA). | ||
1286 | * | ||
1287 | * Wait for two seconds. Devices attached to downstream port | ||
1288 | * which can't process the following IDENTIFY after this will | ||
1289 | * have to be reset again. For most cases, this should | ||
1290 | * suffice while making probing snappish enough. | ||
1291 | */ | ||
1292 | rc = ata_wait_ready(ap, jiffies + 2 * HZ); | ||
1293 | if (rc) | ||
1294 | ahci_kick_engine(ap, 0); | ||
1295 | |||
1296 | return 0; | ||
1297 | } | ||
1298 | |||
1216 | static void ahci_postreset(struct ata_link *link, unsigned int *class) | 1299 | static void ahci_postreset(struct ata_link *link, unsigned int *class) |
1217 | { | 1300 | { |
1218 | struct ata_port *ap = link->ap; | 1301 | struct ata_port *ap = link->ap; |
@@ -1670,6 +1753,19 @@ static void ahci_vt8251_error_handler(struct ata_port *ap) | |||
1670 | ahci_postreset); | 1753 | ahci_postreset); |
1671 | } | 1754 | } |
1672 | 1755 | ||
1756 | static void ahci_p5wdh_error_handler(struct ata_port *ap) | ||
1757 | { | ||
1758 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) { | ||
1759 | /* restart engine */ | ||
1760 | ahci_stop_engine(ap); | ||
1761 | ahci_start_engine(ap); | ||
1762 | } | ||
1763 | |||
1764 | /* perform recovery */ | ||
1765 | ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_p5wdh_hardreset, | ||
1766 | ahci_postreset); | ||
1767 | } | ||
1768 | |||
1673 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) | 1769 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) |
1674 | { | 1770 | { |
1675 | struct ata_port *ap = qc->ap; | 1771 | struct ata_port *ap = qc->ap; |
@@ -1955,6 +2051,51 @@ static void ahci_print_info(struct ata_host *host) | |||
1955 | ); | 2051 | ); |
1956 | } | 2052 | } |
1957 | 2053 | ||
2054 | /* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is | ||
2055 | * hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't | ||
2056 | * support PMP and the 4726 either directly exports the device | ||
2057 | * attached to the first downstream port or acts as a hardware storage | ||
2058 | * controller and emulate a single ATA device (can be RAID 0/1 or some | ||
2059 | * other configuration). | ||
2060 | * | ||
2061 | * When there's no device attached to the first downstream port of the | ||
2062 | * 4726, "Config Disk" appears, which is a pseudo ATA device to | ||
2063 | * configure the 4726. However, ATA emulation of the device is very | ||
2064 | * lame. It doesn't send signature D2H Reg FIS after the initial | ||
2065 | * hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues. | ||
2066 | * | ||
2067 | * The following function works around the problem by always using | ||
2068 | * hardreset on the port and not depending on receiving signature FIS | ||
2069 | * afterward. If signature FIS isn't received soon, ATA class is | ||
2070 | * assumed without follow-up softreset. | ||
2071 | */ | ||
2072 | static void ahci_p5wdh_workaround(struct ata_host *host) | ||
2073 | { | ||
2074 | static struct dmi_system_id sysids[] = { | ||
2075 | { | ||
2076 | .ident = "P5W DH Deluxe", | ||
2077 | .matches = { | ||
2078 | DMI_MATCH(DMI_SYS_VENDOR, | ||
2079 | "ASUSTEK COMPUTER INC"), | ||
2080 | DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"), | ||
2081 | }, | ||
2082 | }, | ||
2083 | { } | ||
2084 | }; | ||
2085 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
2086 | |||
2087 | if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) && | ||
2088 | dmi_check_system(sysids)) { | ||
2089 | struct ata_port *ap = host->ports[1]; | ||
2090 | |||
2091 | dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH " | ||
2092 | "Deluxe on-board SIMG4726 workaround\n"); | ||
2093 | |||
2094 | ap->ops = &ahci_p5wdh_ops; | ||
2095 | ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA; | ||
2096 | } | ||
2097 | } | ||
2098 | |||
1958 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 2099 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1959 | { | 2100 | { |
1960 | static int printed_version; | 2101 | static int printed_version; |
@@ -2024,6 +2165,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2024 | ap->ops = &ata_dummy_port_ops; | 2165 | ap->ops = &ata_dummy_port_ops; |
2025 | } | 2166 | } |
2026 | 2167 | ||
2168 | /* apply workaround for ASUS P5W DH Deluxe mainboard */ | ||
2169 | ahci_p5wdh_workaround(host); | ||
2170 | |||
2027 | /* initialize adapter */ | 2171 | /* initialize adapter */ |
2028 | rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); | 2172 | rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); |
2029 | if (rc) | 2173 | if (rc) |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2d147b51c9..081e3dfb64 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -68,7 +68,8 @@ const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; | |||
68 | static unsigned int ata_dev_init_params(struct ata_device *dev, | 68 | static unsigned int ata_dev_init_params(struct ata_device *dev, |
69 | u16 heads, u16 sectors); | 69 | u16 heads, u16 sectors); |
70 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); | 70 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); |
71 | static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable); | 71 | static unsigned int ata_dev_set_feature(struct ata_device *dev, |
72 | u8 enable, u8 feature); | ||
72 | static void ata_dev_xfermask(struct ata_device *dev); | 73 | static void ata_dev_xfermask(struct ata_device *dev); |
73 | static unsigned long ata_dev_blacklisted(const struct ata_device *dev); | 74 | static unsigned long ata_dev_blacklisted(const struct ata_device *dev); |
74 | 75 | ||
@@ -1799,13 +1800,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1799 | * SET_FEATURES spin-up subcommand before it will accept | 1800 | * SET_FEATURES spin-up subcommand before it will accept |
1800 | * anything other than the original IDENTIFY command. | 1801 | * anything other than the original IDENTIFY command. |
1801 | */ | 1802 | */ |
1802 | ata_tf_init(dev, &tf); | 1803 | err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0); |
1803 | tf.command = ATA_CMD_SET_FEATURES; | ||
1804 | tf.feature = SETFEATURES_SPINUP; | ||
1805 | tf.protocol = ATA_PROT_NODATA; | ||
1806 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1807 | err_mask = ata_exec_internal(dev, &tf, NULL, | ||
1808 | DMA_NONE, NULL, 0, 0); | ||
1809 | if (err_mask && id[2] != 0x738c) { | 1804 | if (err_mask && id[2] != 0x738c) { |
1810 | rc = -EIO; | 1805 | rc = -EIO; |
1811 | reason = "SPINUP failed"; | 1806 | reason = "SPINUP failed"; |
@@ -2075,7 +2070,8 @@ int ata_dev_configure(struct ata_device *dev) | |||
2075 | unsigned int err_mask; | 2070 | unsigned int err_mask; |
2076 | 2071 | ||
2077 | /* issue SET feature command to turn this on */ | 2072 | /* issue SET feature command to turn this on */ |
2078 | err_mask = ata_dev_set_AN(dev, SETFEATURES_SATA_ENABLE); | 2073 | err_mask = ata_dev_set_feature(dev, |
2074 | SETFEATURES_SATA_ENABLE, SATA_AN); | ||
2079 | if (err_mask) | 2075 | if (err_mask) |
2080 | ata_dev_printk(dev, KERN_ERR, | 2076 | ata_dev_printk(dev, KERN_ERR, |
2081 | "failed to enable ATAPI AN " | 2077 | "failed to enable ATAPI AN " |
@@ -2886,6 +2882,13 @@ static int ata_dev_set_mode(struct ata_device *dev) | |||
2886 | dev->pio_mode <= XFER_PIO_2) | 2882 | dev->pio_mode <= XFER_PIO_2) |
2887 | err_mask &= ~AC_ERR_DEV; | 2883 | err_mask &= ~AC_ERR_DEV; |
2888 | 2884 | ||
2885 | /* Early MWDMA devices do DMA but don't allow DMA mode setting. | ||
2886 | Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */ | ||
2887 | if (dev->xfer_shift == ATA_SHIFT_MWDMA && | ||
2888 | dev->dma_mode == XFER_MW_DMA_0 && | ||
2889 | (dev->id[63] >> 8) & 1) | ||
2890 | err_mask &= ~AC_ERR_DEV; | ||
2891 | |||
2889 | if (err_mask) { | 2892 | if (err_mask) { |
2890 | ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " | 2893 | ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " |
2891 | "(err_mask=0x%x)\n", err_mask); | 2894 | "(err_mask=0x%x)\n", err_mask); |
@@ -3947,9 +3950,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3947 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, | 3950 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, |
3948 | { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, | 3951 | { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, |
3949 | { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, | 3952 | { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, |
3950 | { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */ | ||
3951 | { "IOMEGA ZIP 250 ATAPI Floppy", | ||
3952 | NULL, ATA_HORKAGE_NODMA }, | ||
3953 | /* Odd clown on sil3726/4726 PMPs */ | 3953 | /* Odd clown on sil3726/4726 PMPs */ |
3954 | { "Config Disk", NULL, ATA_HORKAGE_NODMA | | 3954 | { "Config Disk", NULL, ATA_HORKAGE_NODMA | |
3955 | ATA_HORKAGE_SKIP_PM }, | 3955 | ATA_HORKAGE_SKIP_PM }, |
@@ -4007,7 +4007,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4007 | { } | 4007 | { } |
4008 | }; | 4008 | }; |
4009 | 4009 | ||
4010 | int strn_pattern_cmp(const char *patt, const char *name, int wildchar) | 4010 | static int strn_pattern_cmp(const char *patt, const char *name, int wildchar) |
4011 | { | 4011 | { |
4012 | const char *p; | 4012 | const char *p; |
4013 | int len; | 4013 | int len; |
@@ -4181,15 +4181,14 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) | |||
4181 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 4181 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
4182 | return err_mask; | 4182 | return err_mask; |
4183 | } | 4183 | } |
4184 | |||
4185 | /** | 4184 | /** |
4186 | * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES | 4185 | * ata_dev_set_feature - Issue SET FEATURES - SATA FEATURES |
4187 | * @dev: Device to which command will be sent | 4186 | * @dev: Device to which command will be sent |
4188 | * @enable: Whether to enable or disable the feature | 4187 | * @enable: Whether to enable or disable the feature |
4188 | * @feature: The sector count represents the feature to set | ||
4189 | * | 4189 | * |
4190 | * Issue SET FEATURES - SATA FEATURES command to device @dev | 4190 | * Issue SET FEATURES - SATA FEATURES command to device @dev |
4191 | * on port @ap with sector count set to indicate Asynchronous | 4191 | * on port @ap with sector count |
4192 | * Notification feature | ||
4193 | * | 4192 | * |
4194 | * LOCKING: | 4193 | * LOCKING: |
4195 | * PCI/etc. bus probe sem. | 4194 | * PCI/etc. bus probe sem. |
@@ -4197,7 +4196,8 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) | |||
4197 | * RETURNS: | 4196 | * RETURNS: |
4198 | * 0 on success, AC_ERR_* mask otherwise. | 4197 | * 0 on success, AC_ERR_* mask otherwise. |
4199 | */ | 4198 | */ |
4200 | static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) | 4199 | static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, |
4200 | u8 feature) | ||
4201 | { | 4201 | { |
4202 | struct ata_taskfile tf; | 4202 | struct ata_taskfile tf; |
4203 | unsigned int err_mask; | 4203 | unsigned int err_mask; |
@@ -4210,7 +4210,7 @@ static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) | |||
4210 | tf.feature = enable; | 4210 | tf.feature = enable; |
4211 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 4211 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
4212 | tf.protocol = ATA_PROT_NODATA; | 4212 | tf.protocol = ATA_PROT_NODATA; |
4213 | tf.nsect = SATA_AN; | 4213 | tf.nsect = feature; |
4214 | 4214 | ||
4215 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); | 4215 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
4216 | 4216 | ||
@@ -4689,8 +4689,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4689 | * data in this function or read data in ata_sg_clean. | 4689 | * data in this function or read data in ata_sg_clean. |
4690 | */ | 4690 | */ |
4691 | offset = lsg->offset + lsg->length - qc->pad_len; | 4691 | offset = lsg->offset + lsg->length - qc->pad_len; |
4692 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); | 4692 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT), |
4693 | psg->offset = offset_in_page(offset); | 4693 | qc->pad_len, offset_in_page(offset)); |
4694 | 4694 | ||
4695 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 4695 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
4696 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); | 4696 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); |
@@ -6921,7 +6921,7 @@ int ata_host_activate(struct ata_host *host, int irq, | |||
6921 | * LOCKING: | 6921 | * LOCKING: |
6922 | * Kernel thread context (may sleep). | 6922 | * Kernel thread context (may sleep). |
6923 | */ | 6923 | */ |
6924 | void ata_port_detach(struct ata_port *ap) | 6924 | static void ata_port_detach(struct ata_port *ap) |
6925 | { | 6925 | { |
6926 | unsigned long flags; | 6926 | unsigned long flags; |
6927 | struct ata_link *link; | 6927 | struct ata_link *link; |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 93e2b545b4..8cb35bb876 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -2071,7 +2071,7 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2071 | int try = 0; | 2071 | int try = 0; |
2072 | struct ata_device *dev; | 2072 | struct ata_device *dev; |
2073 | unsigned long deadline; | 2073 | unsigned long deadline; |
2074 | unsigned int action; | 2074 | unsigned int tmp_action; |
2075 | ata_reset_fn_t reset; | 2075 | ata_reset_fn_t reset; |
2076 | unsigned long flags; | 2076 | unsigned long flags; |
2077 | int rc; | 2077 | int rc; |
@@ -2086,14 +2086,14 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2086 | /* Determine which reset to use and record in ehc->i.action. | 2086 | /* Determine which reset to use and record in ehc->i.action. |
2087 | * prereset() may examine and modify it. | 2087 | * prereset() may examine and modify it. |
2088 | */ | 2088 | */ |
2089 | action = ehc->i.action; | ||
2090 | ehc->i.action &= ~ATA_EH_RESET_MASK; | ||
2091 | if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) && | 2089 | if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) && |
2092 | !sata_set_spd_needed(link) && | 2090 | !sata_set_spd_needed(link) && |
2093 | !(action & ATA_EH_HARDRESET)))) | 2091 | !(ehc->i.action & ATA_EH_HARDRESET)))) |
2094 | ehc->i.action |= ATA_EH_SOFTRESET; | 2092 | tmp_action = ATA_EH_SOFTRESET; |
2095 | else | 2093 | else |
2096 | ehc->i.action |= ATA_EH_HARDRESET; | 2094 | tmp_action = ATA_EH_HARDRESET; |
2095 | |||
2096 | ehc->i.action = (ehc->i.action & ~ATA_EH_RESET_MASK) | tmp_action; | ||
2097 | 2097 | ||
2098 | if (prereset) { | 2098 | if (prereset) { |
2099 | rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); | 2099 | rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); |
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c index be30923566..842fe08a3c 100644 --- a/drivers/ata/pata_icside.c +++ b/drivers/ata/pata_icside.c | |||
@@ -332,12 +332,13 @@ static void ata_dummy_noret(struct ata_port *port) | |||
332 | { | 332 | { |
333 | } | 333 | } |
334 | 334 | ||
335 | static void pata_icside_postreset(struct ata_port *ap, unsigned int *classes) | 335 | static void pata_icside_postreset(struct ata_link *link, unsigned int *classes) |
336 | { | 336 | { |
337 | struct ata_port *ap = link->ap; | ||
337 | struct pata_icside_state *state = ap->host->private_data; | 338 | struct pata_icside_state *state = ap->host->private_data; |
338 | 339 | ||
339 | if (classes[0] != ATA_DEV_NONE || classes[1] != ATA_DEV_NONE) | 340 | if (classes[0] != ATA_DEV_NONE || classes[1] != ATA_DEV_NONE) |
340 | return ata_std_postreset(ap, classes); | 341 | return ata_std_postreset(link, classes); |
341 | 342 | ||
342 | state->port[ap->port_no].disabled = 1; | 343 | state->port[ap->port_no].disabled = 1; |
343 | 344 | ||
@@ -395,29 +396,30 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
395 | 396 | ||
396 | static void __devinit | 397 | static void __devinit |
397 | pata_icside_setup_ioaddr(struct ata_port *ap, void __iomem *base, | 398 | pata_icside_setup_ioaddr(struct ata_port *ap, void __iomem *base, |
398 | const struct portinfo *info) | 399 | struct pata_icside_info *info, |
400 | const struct portinfo *port) | ||
399 | { | 401 | { |
400 | struct ata_ioports *ioaddr = &ap->ioaddr; | 402 | struct ata_ioports *ioaddr = &ap->ioaddr; |
401 | void __iomem *cmd = base + info->dataoffset; | 403 | void __iomem *cmd = base + port->dataoffset; |
402 | 404 | ||
403 | ioaddr->cmd_addr = cmd; | 405 | ioaddr->cmd_addr = cmd; |
404 | ioaddr->data_addr = cmd + (ATA_REG_DATA << info->stepping); | 406 | ioaddr->data_addr = cmd + (ATA_REG_DATA << port->stepping); |
405 | ioaddr->error_addr = cmd + (ATA_REG_ERR << info->stepping); | 407 | ioaddr->error_addr = cmd + (ATA_REG_ERR << port->stepping); |
406 | ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << info->stepping); | 408 | ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << port->stepping); |
407 | ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << info->stepping); | 409 | ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << port->stepping); |
408 | ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << info->stepping); | 410 | ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << port->stepping); |
409 | ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << info->stepping); | 411 | ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << port->stepping); |
410 | ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << info->stepping); | 412 | ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << port->stepping); |
411 | ioaddr->device_addr = cmd + (ATA_REG_DEVICE << info->stepping); | 413 | ioaddr->device_addr = cmd + (ATA_REG_DEVICE << port->stepping); |
412 | ioaddr->status_addr = cmd + (ATA_REG_STATUS << info->stepping); | 414 | ioaddr->status_addr = cmd + (ATA_REG_STATUS << port->stepping); |
413 | ioaddr->command_addr = cmd + (ATA_REG_CMD << info->stepping); | 415 | ioaddr->command_addr = cmd + (ATA_REG_CMD << port->stepping); |
414 | 416 | ||
415 | ioaddr->ctl_addr = base + info->ctrloffset; | 417 | ioaddr->ctl_addr = base + port->ctrloffset; |
416 | ioaddr->altstatus_addr = ioaddr->ctl_addr; | 418 | ioaddr->altstatus_addr = ioaddr->ctl_addr; |
417 | 419 | ||
418 | ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", | 420 | ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", |
419 | info->raw_base + info->dataoffset, | 421 | info->raw_base + port->dataoffset, |
420 | info->raw_base + info->ctrloffset); | 422 | info->raw_base + port->ctrloffset); |
421 | 423 | ||
422 | if (info->raw_ioc_base) | 424 | if (info->raw_ioc_base) |
423 | ata_port_desc(ap, "iocbase 0x%lx", info->raw_ioc_base); | 425 | ata_port_desc(ap, "iocbase 0x%lx", info->raw_ioc_base); |
@@ -441,7 +443,7 @@ static int __devinit pata_icside_register_v5(struct pata_icside_info *info) | |||
441 | info->nr_ports = 1; | 443 | info->nr_ports = 1; |
442 | info->port[0] = &pata_icside_portinfo_v5; | 444 | info->port[0] = &pata_icside_portinfo_v5; |
443 | 445 | ||
444 | info->raw_base = ecard_resource_start(ec, ECARD_RES_MEMC); | 446 | info->raw_base = ecard_resource_start(info->ec, ECARD_RES_MEMC); |
445 | 447 | ||
446 | return 0; | 448 | return 0; |
447 | } | 449 | } |
@@ -522,7 +524,7 @@ static int __devinit pata_icside_add_ports(struct pata_icside_info *info) | |||
522 | ap->flags |= ATA_FLAG_SLAVE_POSS; | 524 | ap->flags |= ATA_FLAG_SLAVE_POSS; |
523 | ap->ops = &pata_icside_port_ops; | 525 | ap->ops = &pata_icside_port_ops; |
524 | 526 | ||
525 | pata_icside_setup_ioaddr(ap, info->base, info->port[i]); | 527 | pata_icside_setup_ioaddr(ap, info->base, info, info->port[i]); |
526 | } | 528 | } |
527 | 529 | ||
528 | return ata_host_activate(host, ec->irq, ata_interrupt, 0, | 530 | return ata_host_activate(host, ec->irq, ata_interrupt, 0, |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 2e0279fdd7..f1b422f7c7 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -365,9 +365,9 @@ static const struct pci_device_id nv_pci_tbl[] = { | |||
365 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, | 365 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, |
366 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, | 366 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, |
367 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, | 367 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, |
368 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), SWNCQ }, | 368 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, |
369 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), SWNCQ }, | 369 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, |
370 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), SWNCQ }, | 370 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, |
371 | 371 | ||
372 | { } /* terminate list */ | 372 | { } /* terminate list */ |
373 | }; | 373 | }; |
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 1b58b01079..241167878e 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c | |||
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
150 | u32 iv[4] = { 0, }; | 150 | u32 iv[4] = { 0, }; |
151 | iv[0] = cpu_to_le32(IV & 0xffffffff); | 151 | iv[0] = cpu_to_le32(IV & 0xffffffff); |
152 | 152 | ||
153 | sg_set_page(&sg_in, in_page); | 153 | sg_set_page(&sg_in, in_page, sz, in_offs); |
154 | sg_in.offset = in_offs; | 154 | sg_set_page(&sg_out, out_page, sz, out_offs); |
155 | sg_in.length = sz; | ||
156 | |||
157 | sg_set_page(&sg_out, out_page); | ||
158 | sg_out.offset = out_offs; | ||
159 | sg_out.length = sz; | ||
160 | 155 | ||
161 | desc.info = iv; | 156 | desc.info = iv; |
162 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); | 157 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); |
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 7276f7d207..fac4c6cd04 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/scatterlist.h> | ||
18 | 19 | ||
19 | #include <asm/vio.h> | 20 | #include <asm/vio.h> |
20 | #include <asm/ldc.h> | 21 | #include <asm/ldc.h> |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 14143f2c48..08e909dc79 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -1428,9 +1428,9 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1428 | scmd->state = UB_CMDST_INIT; | 1428 | scmd->state = UB_CMDST_INIT; |
1429 | scmd->nsg = 1; | 1429 | scmd->nsg = 1; |
1430 | sg = &scmd->sgv[0]; | 1430 | sg = &scmd->sgv[0]; |
1431 | sg_set_page(sg, virt_to_page(sc->top_sense)); | 1431 | sg_init_table(sg, UB_MAX_REQ_SG); |
1432 | sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); | 1432 | sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE, |
1433 | sg->length = UB_SENSE_SIZE; | 1433 | (unsigned long)sc->top_sense & (PAGE_SIZE-1)); |
1434 | scmd->len = UB_SENSE_SIZE; | 1434 | scmd->len = UB_SENSE_SIZE; |
1435 | scmd->lun = cmd->lun; | 1435 | scmd->lun = cmd->lun; |
1436 | scmd->done = ub_top_sense_done; | 1436 | scmd->done = ub_top_sense_done; |
@@ -1864,9 +1864,8 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, | |||
1864 | cmd->state = UB_CMDST_INIT; | 1864 | cmd->state = UB_CMDST_INIT; |
1865 | cmd->nsg = 1; | 1865 | cmd->nsg = 1; |
1866 | sg = &cmd->sgv[0]; | 1866 | sg = &cmd->sgv[0]; |
1867 | sg_set_page(sg, virt_to_page(p)); | 1867 | sg_init_table(sg, UB_MAX_REQ_SG); |
1868 | sg->offset = (unsigned long)p & (PAGE_SIZE-1); | 1868 | sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1)); |
1869 | sg->length = 8; | ||
1870 | cmd->len = 8; | 1869 | cmd->len = 8; |
1871 | cmd->lun = lun; | 1870 | cmd->lun = lun; |
1872 | cmd->done = ub_probe_done; | 1871 | cmd->done = ub_probe_done; |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index a901eee64b..3cf7129d83 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -4,7 +4,9 @@ | |||
4 | #include <linux/hdreg.h> | 4 | #include <linux/hdreg.h> |
5 | #include <linux/virtio.h> | 5 | #include <linux/virtio.h> |
6 | #include <linux/virtio_blk.h> | 6 | #include <linux/virtio_blk.h> |
7 | #include <linux/virtio_blk.h> | 7 | #include <linux/scatterlist.h> |
8 | |||
9 | #define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) | ||
8 | 10 | ||
9 | static unsigned char virtblk_index = 'a'; | 11 | static unsigned char virtblk_index = 'a'; |
10 | struct virtio_blk | 12 | struct virtio_blk |
@@ -23,7 +25,7 @@ struct virtio_blk | |||
23 | mempool_t *pool; | 25 | mempool_t *pool; |
24 | 26 | ||
25 | /* Scatterlist: can be too big for stack. */ | 27 | /* Scatterlist: can be too big for stack. */ |
26 | struct scatterlist sg[3+MAX_PHYS_SEGMENTS]; | 28 | struct scatterlist sg[VIRTIO_MAX_SG]; |
27 | }; | 29 | }; |
28 | 30 | ||
29 | struct virtblk_req | 31 | struct virtblk_req |
@@ -94,8 +96,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, | |||
94 | if (blk_barrier_rq(vbr->req)) | 96 | if (blk_barrier_rq(vbr->req)) |
95 | vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; | 97 | vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; |
96 | 98 | ||
97 | /* We have to zero this, otherwise blk_rq_map_sg gets upset. */ | 99 | /* This init could be done at vblk creation time */ |
98 | memset(vblk->sg, 0, sizeof(vblk->sg)); | 100 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); |
99 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); | 101 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); |
100 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); | 102 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); |
101 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); | 103 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); |
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 880b5dce3a..d8bb44b98a 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -41,9 +41,9 @@ | |||
41 | #include <linux/completion.h> | 41 | #include <linux/completion.h> |
42 | #include <linux/proc_fs.h> | 42 | #include <linux/proc_fs.h> |
43 | #include <linux/seq_file.h> | 43 | #include <linux/seq_file.h> |
44 | #include <linux/scatterlist.h> | ||
44 | 45 | ||
45 | #include <asm/vio.h> | 46 | #include <asm/vio.h> |
46 | #include <asm/scatterlist.h> | ||
47 | #include <asm/iseries/hv_types.h> | 47 | #include <asm/iseries/hv_types.h> |
48 | #include <asm/iseries/hv_lp_event.h> | 48 | #include <asm/iseries/hv_lp_event.h> |
49 | #include <asm/iseries/vio.h> | 49 | #include <asm/iseries/vio.h> |
@@ -258,6 +258,7 @@ static int send_request(struct request *req) | |||
258 | cmd = viomajorsubtype_cdio | viocdwrite; | 258 | cmd = viomajorsubtype_cdio | viocdwrite; |
259 | } | 259 | } |
260 | 260 | ||
261 | sg_init_table(&sg, 1); | ||
261 | if (blk_rq_map_sg(req->q, req, &sg) == 0) { | 262 | if (blk_rq_map_sg(req->q, req, &sg) == 0) { |
262 | printk(VIOCD_KERN_WARNING | 263 | printk(VIOCD_KERN_WARNING |
263 | "error setting up scatter/gather list\n"); | 264 | "error setting up scatter/gather list\n"); |
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c index 4e8de162fc..c666b4e093 100644 --- a/drivers/crypto/padlock-sha.c +++ b/drivers/crypto/padlock-sha.c | |||
@@ -55,7 +55,7 @@ static void padlock_sha_bypass(struct crypto_tfm *tfm) | |||
55 | if (ctx(tfm)->data && ctx(tfm)->used) { | 55 | if (ctx(tfm)->data && ctx(tfm)->used) { |
56 | struct scatterlist sg; | 56 | struct scatterlist sg; |
57 | 57 | ||
58 | sg_set_buf(&sg, ctx(tfm)->data, ctx(tfm)->used); | 58 | sg_init_one(&sg, ctx(tfm)->data, ctx(tfm)->used); |
59 | crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); | 59 | crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); |
60 | } | 60 | } |
61 | 61 | ||
@@ -79,7 +79,7 @@ static void padlock_sha_update(struct crypto_tfm *tfm, | |||
79 | 79 | ||
80 | if (unlikely(ctx(tfm)->bypass)) { | 80 | if (unlikely(ctx(tfm)->bypass)) { |
81 | struct scatterlist sg; | 81 | struct scatterlist sg; |
82 | sg_set_buf(&sg, (uint8_t *)data, length); | 82 | sg_init_one(&sg, (uint8_t *)data, length); |
83 | crypto_hash_update(&ctx(tfm)->fallback, &sg, length); | 83 | crypto_hash_update(&ctx(tfm)->fallback, &sg, length); |
84 | return; | 84 | return; |
85 | } | 85 | } |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 410a0d13e3..93f71fcfc0 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -316,13 +316,13 @@ static int icside_dma_end(ide_drive_t *drive) | |||
316 | 316 | ||
317 | drive->waiting_for_dma = 0; | 317 | drive->waiting_for_dma = 0; |
318 | 318 | ||
319 | disable_dma(state->dev->dma); | 319 | disable_dma(ECARD_DEV(state->dev)->dma); |
320 | 320 | ||
321 | /* Teardown mappings after DMA has completed. */ | 321 | /* Teardown mappings after DMA has completed. */ |
322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, | 322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, |
323 | hwif->sg_dma_direction); | 323 | hwif->sg_dma_direction); |
324 | 324 | ||
325 | return get_dma_residue(state->dev->dma) != 0; | 325 | return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static void icside_dma_start(ide_drive_t *drive) | 328 | static void icside_dma_start(ide_drive_t *drive) |
@@ -331,8 +331,8 @@ static void icside_dma_start(ide_drive_t *drive) | |||
331 | struct icside_state *state = hwif->hwif_data; | 331 | struct icside_state *state = hwif->hwif_data; |
332 | 332 | ||
333 | /* We can not enable DMA on both channels simultaneously. */ | 333 | /* We can not enable DMA on both channels simultaneously. */ |
334 | BUG_ON(dma_channel_active(state->dev->dma)); | 334 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); |
335 | enable_dma(state->dev->dma); | 335 | enable_dma(ECARD_DEV(state->dev)->dma); |
336 | } | 336 | } |
337 | 337 | ||
338 | static int icside_dma_setup(ide_drive_t *drive) | 338 | static int icside_dma_setup(ide_drive_t *drive) |
@@ -350,7 +350,7 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
350 | /* | 350 | /* |
351 | * We can not enable DMA on both channels. | 351 | * We can not enable DMA on both channels. |
352 | */ | 352 | */ |
353 | BUG_ON(dma_channel_active(state->dev->dma)); | 353 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); |
354 | 354 | ||
355 | icside_build_sglist(drive, rq); | 355 | icside_build_sglist(drive, rq); |
356 | 356 | ||
@@ -367,14 +367,14 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
367 | /* | 367 | /* |
368 | * Select the correct timing for this drive. | 368 | * Select the correct timing for this drive. |
369 | */ | 369 | */ |
370 | set_dma_speed(state->dev->dma, drive->drive_data); | 370 | set_dma_speed(ECARD_DEV(state->dev)->dma, drive->drive_data); |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * Tell the DMA engine about the SG table and | 373 | * Tell the DMA engine about the SG table and |
374 | * data direction. | 374 | * data direction. |
375 | */ | 375 | */ |
376 | set_dma_sg(state->dev->dma, hwif->sg_table, hwif->sg_nents); | 376 | set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents); |
377 | set_dma_mode(state->dev->dma, dma_mode); | 377 | set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode); |
378 | 378 | ||
379 | drive->waiting_for_dma = 1; | 379 | drive->waiting_for_dma = 1; |
380 | 380 | ||
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 95168833d0..dcda0f109d 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -582,9 +582,12 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list); | |||
582 | /* | 582 | /* |
583 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. | 583 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. |
584 | * We list them here and depend on the device side cable detection for them. | 584 | * We list them here and depend on the device side cable detection for them. |
585 | * | ||
586 | * Some optical devices with the buggy firmwares have the same problem. | ||
585 | */ | 587 | */ |
586 | static const struct drive_list_entry ivb_list[] = { | 588 | static const struct drive_list_entry ivb_list[] = { |
587 | { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, | 589 | { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, |
590 | { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, | ||
588 | { NULL , NULL } | 591 | { NULL , NULL } |
589 | }; | 592 | }; |
590 | 593 | ||
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 3ef4fc10fe..1cd4e9cb05 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cy82c693.c Version 0.41 Aug 27, 2007 | 2 | * linux/drivers/ide/pci/cy82c693.c Version 0.42 Oct 23, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer | 4 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer |
5 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator | 5 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator |
@@ -436,10 +436,10 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | |||
436 | hwif->ide_dma_on = &cy82c693_ide_dma_on; | 436 | hwif->ide_dma_on = &cy82c693_ide_dma_on; |
437 | } | 437 | } |
438 | 438 | ||
439 | static __devinitdata ide_hwif_t *primary; | ||
440 | |||
441 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 439 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
442 | { | 440 | { |
441 | static ide_hwif_t *primary; | ||
442 | |||
443 | if (PCI_FUNC(hwif->pci_dev->devfn) == 1) | 443 | if (PCI_FUNC(hwif->pci_dev->devfn) == 1) |
444 | primary = hwif; | 444 | primary = hwif; |
445 | else { | 445 | else { |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index f44d70852c..06885697ed 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -49,7 +49,7 @@ static int __init ide_generic_all_on(char *unused) | |||
49 | printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); | 49 | printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | __setup("all-generic-ide", ide_generic_all_on); | 52 | const __setup("all-generic-ide", ide_generic_all_on); |
53 | #endif | 53 | #endif |
54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); | 54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); |
55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); | 55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 612b795241..5682895d36 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt366.c Version 1.20 Oct 1, 2007 | 2 | * linux/drivers/ide/pci/hpt366.c Version 1.21 Oct 23, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
@@ -433,7 +433,7 @@ static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = { | |||
433 | sixty_six_base_hpt37x | 433 | sixty_six_base_hpt37x |
434 | }; | 434 | }; |
435 | 435 | ||
436 | static struct hpt_info hpt36x __devinitdata = { | 436 | static const struct hpt_info hpt36x __devinitdata = { |
437 | .chip_name = "HPT36x", | 437 | .chip_name = "HPT36x", |
438 | .chip_type = HPT36x, | 438 | .chip_type = HPT36x, |
439 | .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, | 439 | .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, |
@@ -441,7 +441,7 @@ static struct hpt_info hpt36x __devinitdata = { | |||
441 | .settings = hpt36x_settings | 441 | .settings = hpt36x_settings |
442 | }; | 442 | }; |
443 | 443 | ||
444 | static struct hpt_info hpt370 __devinitdata = { | 444 | static const struct hpt_info hpt370 __devinitdata = { |
445 | .chip_name = "HPT370", | 445 | .chip_name = "HPT370", |
446 | .chip_type = HPT370, | 446 | .chip_type = HPT370, |
447 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, | 447 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
@@ -449,7 +449,7 @@ static struct hpt_info hpt370 __devinitdata = { | |||
449 | .settings = hpt37x_settings | 449 | .settings = hpt37x_settings |
450 | }; | 450 | }; |
451 | 451 | ||
452 | static struct hpt_info hpt370a __devinitdata = { | 452 | static const struct hpt_info hpt370a __devinitdata = { |
453 | .chip_name = "HPT370A", | 453 | .chip_name = "HPT370A", |
454 | .chip_type = HPT370A, | 454 | .chip_type = HPT370A, |
455 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, | 455 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
@@ -457,7 +457,7 @@ static struct hpt_info hpt370a __devinitdata = { | |||
457 | .settings = hpt37x_settings | 457 | .settings = hpt37x_settings |
458 | }; | 458 | }; |
459 | 459 | ||
460 | static struct hpt_info hpt374 __devinitdata = { | 460 | static const struct hpt_info hpt374 __devinitdata = { |
461 | .chip_name = "HPT374", | 461 | .chip_name = "HPT374", |
462 | .chip_type = HPT374, | 462 | .chip_type = HPT374, |
463 | .udma_mask = ATA_UDMA5, | 463 | .udma_mask = ATA_UDMA5, |
@@ -465,7 +465,7 @@ static struct hpt_info hpt374 __devinitdata = { | |||
465 | .settings = hpt37x_settings | 465 | .settings = hpt37x_settings |
466 | }; | 466 | }; |
467 | 467 | ||
468 | static struct hpt_info hpt372 __devinitdata = { | 468 | static const struct hpt_info hpt372 __devinitdata = { |
469 | .chip_name = "HPT372", | 469 | .chip_name = "HPT372", |
470 | .chip_type = HPT372, | 470 | .chip_type = HPT372, |
471 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 471 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -473,7 +473,7 @@ static struct hpt_info hpt372 __devinitdata = { | |||
473 | .settings = hpt37x_settings | 473 | .settings = hpt37x_settings |
474 | }; | 474 | }; |
475 | 475 | ||
476 | static struct hpt_info hpt372a __devinitdata = { | 476 | static const struct hpt_info hpt372a __devinitdata = { |
477 | .chip_name = "HPT372A", | 477 | .chip_name = "HPT372A", |
478 | .chip_type = HPT372A, | 478 | .chip_type = HPT372A, |
479 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 479 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -481,7 +481,7 @@ static struct hpt_info hpt372a __devinitdata = { | |||
481 | .settings = hpt37x_settings | 481 | .settings = hpt37x_settings |
482 | }; | 482 | }; |
483 | 483 | ||
484 | static struct hpt_info hpt302 __devinitdata = { | 484 | static const struct hpt_info hpt302 __devinitdata = { |
485 | .chip_name = "HPT302", | 485 | .chip_name = "HPT302", |
486 | .chip_type = HPT302, | 486 | .chip_type = HPT302, |
487 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 487 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -489,7 +489,7 @@ static struct hpt_info hpt302 __devinitdata = { | |||
489 | .settings = hpt37x_settings | 489 | .settings = hpt37x_settings |
490 | }; | 490 | }; |
491 | 491 | ||
492 | static struct hpt_info hpt371 __devinitdata = { | 492 | static const struct hpt_info hpt371 __devinitdata = { |
493 | .chip_name = "HPT371", | 493 | .chip_name = "HPT371", |
494 | .chip_type = HPT371, | 494 | .chip_type = HPT371, |
495 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 495 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -497,7 +497,7 @@ static struct hpt_info hpt371 __devinitdata = { | |||
497 | .settings = hpt37x_settings | 497 | .settings = hpt37x_settings |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static struct hpt_info hpt372n __devinitdata = { | 500 | static const struct hpt_info hpt372n __devinitdata = { |
501 | .chip_name = "HPT372N", | 501 | .chip_name = "HPT372N", |
502 | .chip_type = HPT372N, | 502 | .chip_type = HPT372N, |
503 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 503 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -505,7 +505,7 @@ static struct hpt_info hpt372n __devinitdata = { | |||
505 | .settings = hpt37x_settings | 505 | .settings = hpt37x_settings |
506 | }; | 506 | }; |
507 | 507 | ||
508 | static struct hpt_info hpt302n __devinitdata = { | 508 | static const struct hpt_info hpt302n __devinitdata = { |
509 | .chip_name = "HPT302N", | 509 | .chip_name = "HPT302N", |
510 | .chip_type = HPT302N, | 510 | .chip_type = HPT302N, |
511 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 511 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -513,7 +513,7 @@ static struct hpt_info hpt302n __devinitdata = { | |||
513 | .settings = hpt37x_settings | 513 | .settings = hpt37x_settings |
514 | }; | 514 | }; |
515 | 515 | ||
516 | static struct hpt_info hpt371n __devinitdata = { | 516 | static const struct hpt_info hpt371n __devinitdata = { |
517 | .chip_name = "HPT371N", | 517 | .chip_name = "HPT371N", |
518 | .chip_type = HPT371N, | 518 | .chip_type = HPT371N, |
519 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 519 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -1508,7 +1508,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1508 | */ | 1508 | */ |
1509 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 1509 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1510 | { | 1510 | { |
1511 | struct hpt_info *info = NULL; | 1511 | const struct hpt_info *info = NULL; |
1512 | struct pci_dev *dev2 = NULL; | 1512 | struct pci_dev *dev2 = NULL; |
1513 | struct ide_port_info d; | 1513 | struct ide_port_info d; |
1514 | u8 idx = id->driver_data; | 1514 | u8 idx = id->driver_data; |
@@ -1522,7 +1522,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1522 | if (rev < 3) | 1522 | if (rev < 3) |
1523 | info = &hpt36x; | 1523 | info = &hpt36x; |
1524 | else { | 1524 | else { |
1525 | static struct hpt_info *hpt37x_info[] = | 1525 | static const struct hpt_info *hpt37x_info[] = |
1526 | { &hpt370, &hpt370a, &hpt372, &hpt372n }; | 1526 | { &hpt370, &hpt370a, &hpt372, &hpt372n }; |
1527 | 1527 | ||
1528 | info = hpt37x_info[min_t(u8, rev, 6) - 3]; | 1528 | info = hpt37x_info[min_t(u8, rev, 6) - 3]; |
@@ -1552,7 +1552,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1552 | d.name = info->chip_name; | 1552 | d.name = info->chip_name; |
1553 | d.udma_mask = info->udma_mask; | 1553 | d.udma_mask = info->udma_mask; |
1554 | 1554 | ||
1555 | pci_set_drvdata(dev, info); | 1555 | pci_set_drvdata(dev, (void *)info); |
1556 | 1556 | ||
1557 | if (info == &hpt36x || info == &hpt374) | 1557 | if (info == &hpt36x || info == &hpt374) |
1558 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 1558 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
@@ -1560,7 +1560,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1560 | if (dev2) { | 1560 | if (dev2) { |
1561 | int ret; | 1561 | int ret; |
1562 | 1562 | ||
1563 | pci_set_drvdata(dev2, info); | 1563 | pci_set_drvdata(dev2, (void *)info); |
1564 | 1564 | ||
1565 | if (info == &hpt374) | 1565 | if (info == &hpt374) |
1566 | hpt374_init(dev, dev2); | 1566 | hpt374_init(dev, dev2); |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index d2c8b5524f..0a7b320206 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -324,17 +324,18 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
324 | 324 | ||
325 | pci_disable_device(dev); | 325 | pci_disable_device(dev); |
326 | pci_set_power_state(dev, pci_choose_state(dev, state)); | 326 | pci_set_power_state(dev, pci_choose_state(dev, state)); |
327 | dev->current_state = state.event; | ||
328 | return 0; | 327 | return 0; |
329 | } | 328 | } |
330 | 329 | ||
331 | static int sc1200_resume (struct pci_dev *dev) | 330 | static int sc1200_resume (struct pci_dev *dev) |
332 | { | 331 | { |
333 | ide_hwif_t *hwif = NULL; | 332 | ide_hwif_t *hwif = NULL; |
333 | int i; | ||
334 | |||
335 | i = pci_enable_device(dev); | ||
336 | if (i) | ||
337 | return i; | ||
334 | 338 | ||
335 | pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state | ||
336 | dev->current_state = PM_EVENT_ON; | ||
337 | pci_enable_device(dev); | ||
338 | // | 339 | // |
339 | // loop over all interfaces that are part of this pci device: | 340 | // loop over all interfaces that are part of this pci device: |
340 | // | 341 | // |
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c index 3051e312fd..f5f4983dfb 100644 --- a/drivers/ieee1394/dma.c +++ b/drivers/ieee1394/dma.c | |||
@@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, | |||
111 | unsigned long va = | 111 | unsigned long va = |
112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); | 112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); |
113 | 113 | ||
114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); | 114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va), |
115 | dma->sglist[i].length = PAGE_SIZE; | 115 | PAGE_SIZE, 0); |
116 | } | 116 | } |
117 | 117 | ||
118 | /* map sglist to the IOMMU */ | 118 | /* map sglist to the IOMMU */ |
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 14159ff294..4e3128ff73 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c | |||
@@ -171,9 +171,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
171 | if (vma_list && | 171 | if (vma_list && |
172 | !is_vm_hugetlb_page(vma_list[i + off])) | 172 | !is_vm_hugetlb_page(vma_list[i + off])) |
173 | umem->hugetlb = 0; | 173 | umem->hugetlb = 0; |
174 | sg_set_page(&chunk->page_list[i], page_list[i + off]); | 174 | sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0); |
175 | chunk->page_list[i].offset = 0; | ||
176 | chunk->page_list[i].length = PAGE_SIZE; | ||
177 | } | 175 | } |
178 | 176 | ||
179 | chunk->nmap = ib_dma_map_sg(context->device, | 177 | chunk->nmap = ib_dma_map_sg(context->device, |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 007b38157f..1f4d27d7c1 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -113,9 +113,7 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m | |||
113 | if (!page) | 113 | if (!page) |
114 | return -ENOMEM; | 114 | return -ENOMEM; |
115 | 115 | ||
116 | sg_set_page(mem, page); | 116 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
117 | mem->length = PAGE_SIZE << order; | ||
118 | mem->offset = 0; | ||
119 | return 0; | 117 | return 0; |
120 | } | 118 | } |
121 | 119 | ||
@@ -481,9 +479,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
481 | if (ret < 0) | 479 | if (ret < 0) |
482 | goto out; | 480 | goto out; |
483 | 481 | ||
484 | sg_set_page(&db_tab->page[i].mem, pages[0]); | 482 | sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, |
485 | db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; | 483 | uaddr & ~PAGE_MASK); |
486 | db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; | ||
487 | 484 | ||
488 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 485 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
489 | if (ret < 0) { | 486 | if (ret < 0) { |
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c index 034d41a61a..e0331e0094 100644 --- a/drivers/isdn/sc/shmem.c +++ b/drivers/isdn/sc/shmem.c | |||
@@ -28,15 +28,15 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) | |||
28 | { | 28 | { |
29 | unsigned long flags; | 29 | unsigned long flags; |
30 | unsigned char ch; | 30 | unsigned char ch; |
31 | unsigned long dest_rem = ((unsigned long) dest) % 0x4000; | ||
31 | 32 | ||
32 | if(!IS_VALID_CARD(card)) { | 33 | if (!IS_VALID_CARD(card)) { |
33 | pr_debug("Invalid param: %d is not a valid card id\n", card); | 34 | pr_debug("Invalid param: %d is not a valid card id\n", card); |
34 | return; | 35 | return; |
35 | } | 36 | } |
36 | 37 | ||
37 | if(n > SRAM_PAGESIZE) { | 38 | if (n > SRAM_PAGESIZE) |
38 | return; | 39 | return; |
39 | } | ||
40 | 40 | ||
41 | /* | 41 | /* |
42 | * determine the page to load from the address | 42 | * determine the page to load from the address |
@@ -50,8 +50,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) | |||
50 | 50 | ||
51 | outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, | 51 | outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, |
52 | sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); | 52 | sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); |
53 | memcpy_toio(sc_adapter[card]->rambase + | 53 | memcpy_toio(sc_adapter[card]->rambase + dest_rem, src, n); |
54 | ((unsigned long) dest % 0x4000), src, n); | ||
55 | spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); | 54 | spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); |
56 | pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, | 55 | pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, |
57 | ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); | 56 | ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); |
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c index 35d19ae58d..cb4c67025d 100644 --- a/drivers/lguest/core.c +++ b/drivers/lguest/core.c | |||
@@ -128,9 +128,12 @@ static void unmap_switcher(void) | |||
128 | __free_pages(switcher_page[i], 0); | 128 | __free_pages(switcher_page[i], 0); |
129 | } | 129 | } |
130 | 130 | ||
131 | /*L:305 | 131 | /*H:032 |
132 | * Dealing With Guest Memory. | 132 | * Dealing With Guest Memory. |
133 | * | 133 | * |
134 | * Before we go too much further into the Host, we need to grok the routines | ||
135 | * we use to deal with Guest memory. | ||
136 | * | ||
134 | * When the Guest gives us (what it thinks is) a physical address, we can use | 137 | * When the Guest gives us (what it thinks is) a physical address, we can use |
135 | * the normal copy_from_user() & copy_to_user() on the corresponding place in | 138 | * the normal copy_from_user() & copy_to_user() on the corresponding place in |
136 | * the memory region allocated by the Launcher. | 139 | * the memory region allocated by the Launcher. |
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index 9d5184c7c1..b478affe8f 100644 --- a/drivers/lguest/hypercalls.c +++ b/drivers/lguest/hypercalls.c | |||
@@ -90,6 +90,7 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) | |||
90 | lg->pending_notify = args->arg1; | 90 | lg->pending_notify = args->arg1; |
91 | break; | 91 | break; |
92 | default: | 92 | default: |
93 | /* It should be an architecture-specific hypercall. */ | ||
93 | if (lguest_arch_do_hcall(lg, args)) | 94 | if (lguest_arch_do_hcall(lg, args)) |
94 | kill_guest(lg, "Bad hypercall %li\n", args->arg0); | 95 | kill_guest(lg, "Bad hypercall %li\n", args->arg0); |
95 | } | 96 | } |
@@ -157,7 +158,6 @@ static void do_async_hcalls(struct lguest *lg) | |||
157 | * Guest makes a hypercall, we end up here to set things up: */ | 158 | * Guest makes a hypercall, we end up here to set things up: */ |
158 | static void initialize(struct lguest *lg) | 159 | static void initialize(struct lguest *lg) |
159 | { | 160 | { |
160 | |||
161 | /* You can't do anything until you're initialized. The Guest knows the | 161 | /* You can't do anything until you're initialized. The Guest knows the |
162 | * rules, so we're unforgiving here. */ | 162 | * rules, so we're unforgiving here. */ |
163 | if (lg->hcall->arg0 != LHCALL_LGUEST_INIT) { | 163 | if (lg->hcall->arg0 != LHCALL_LGUEST_INIT) { |
@@ -174,7 +174,8 @@ static void initialize(struct lguest *lg) | |||
174 | || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)) | 174 | || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)) |
175 | kill_guest(lg, "bad guest page %p", lg->lguest_data); | 175 | kill_guest(lg, "bad guest page %p", lg->lguest_data); |
176 | 176 | ||
177 | /* We write the current time into the Guest's data page once now. */ | 177 | /* We write the current time into the Guest's data page once so it can |
178 | * set its clock. */ | ||
178 | write_timestamp(lg); | 179 | write_timestamp(lg); |
179 | 180 | ||
180 | /* page_tables.c will also do some setup. */ | 181 | /* page_tables.c will also do some setup. */ |
@@ -182,8 +183,8 @@ static void initialize(struct lguest *lg) | |||
182 | 183 | ||
183 | /* This is the one case where the above accesses might have been the | 184 | /* This is the one case where the above accesses might have been the |
184 | * first write to a Guest page. This may have caused a copy-on-write | 185 | * first write to a Guest page. This may have caused a copy-on-write |
185 | * fault, but the Guest might be referring to the old (read-only) | 186 | * fault, but the old page might be (read-only) in the Guest |
186 | * page. */ | 187 | * pagetable. */ |
187 | guest_pagetable_clear_all(lg); | 188 | guest_pagetable_clear_all(lg); |
188 | } | 189 | } |
189 | 190 | ||
@@ -220,7 +221,7 @@ void do_hypercalls(struct lguest *lg) | |||
220 | * Normally it doesn't matter: the Guest will run again and | 221 | * Normally it doesn't matter: the Guest will run again and |
221 | * update the trap number before we come back here. | 222 | * update the trap number before we come back here. |
222 | * | 223 | * |
223 | * However, if we are signalled or the Guest sends DMA to the | 224 | * However, if we are signalled or the Guest sends I/O to the |
224 | * Launcher, the run_guest() loop will exit without running the | 225 | * Launcher, the run_guest() loop will exit without running the |
225 | * Guest. When it comes back it would try to re-run the | 226 | * Guest. When it comes back it would try to re-run the |
226 | * hypercall. */ | 227 | * hypercall. */ |
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index 82966982cb..2b66f79c20 100644 --- a/drivers/lguest/interrupts_and_traps.c +++ b/drivers/lguest/interrupts_and_traps.c | |||
@@ -92,8 +92,8 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) | |||
92 | 92 | ||
93 | /* Remember that we never let the Guest actually disable interrupts, so | 93 | /* Remember that we never let the Guest actually disable interrupts, so |
94 | * the "Interrupt Flag" bit is always set. We copy that bit from the | 94 | * the "Interrupt Flag" bit is always set. We copy that bit from the |
95 | * Guest's "irq_enabled" field into the eflags word: the Guest copies | 95 | * Guest's "irq_enabled" field into the eflags word: we saw the Guest |
96 | * it back in "lguest_iret". */ | 96 | * copy it back in "lguest_iret". */ |
97 | eflags = lg->regs->eflags; | 97 | eflags = lg->regs->eflags; |
98 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 | 98 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 |
99 | && !(irq_enable & X86_EFLAGS_IF)) | 99 | && !(irq_enable & X86_EFLAGS_IF)) |
@@ -124,7 +124,7 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) | |||
124 | kill_guest(lg, "Disabling interrupts"); | 124 | kill_guest(lg, "Disabling interrupts"); |
125 | } | 125 | } |
126 | 126 | ||
127 | /*H:200 | 127 | /*H:205 |
128 | * Virtual Interrupts. | 128 | * Virtual Interrupts. |
129 | * | 129 | * |
130 | * maybe_do_interrupt() gets called before every entry to the Guest, to see if | 130 | * maybe_do_interrupt() gets called before every entry to the Guest, to see if |
@@ -256,19 +256,21 @@ int deliver_trap(struct lguest *lg, unsigned int num) | |||
256 | * bogus one in): if we fail here, the Guest will be killed. */ | 256 | * bogus one in): if we fail here, the Guest will be killed. */ |
257 | if (!idt_present(lg->arch.idt[num].a, lg->arch.idt[num].b)) | 257 | if (!idt_present(lg->arch.idt[num].a, lg->arch.idt[num].b)) |
258 | return 0; | 258 | return 0; |
259 | set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, has_err(num)); | 259 | set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, |
260 | has_err(num)); | ||
260 | return 1; | 261 | return 1; |
261 | } | 262 | } |
262 | 263 | ||
263 | /*H:250 Here's the hard part: returning to the Host every time a trap happens | 264 | /*H:250 Here's the hard part: returning to the Host every time a trap happens |
264 | * and then calling deliver_trap() and re-entering the Guest is slow. | 265 | * and then calling deliver_trap() and re-entering the Guest is slow. |
265 | * Particularly because Guest userspace system calls are traps (trap 128). | 266 | * Particularly because Guest userspace system calls are traps (usually trap |
267 | * 128). | ||
266 | * | 268 | * |
267 | * So we'd like to set up the IDT to tell the CPU to deliver traps directly | 269 | * So we'd like to set up the IDT to tell the CPU to deliver traps directly |
268 | * into the Guest. This is possible, but the complexities cause the size of | 270 | * into the Guest. This is possible, but the complexities cause the size of |
269 | * this file to double! However, 150 lines of code is worth writing for taking | 271 | * this file to double! However, 150 lines of code is worth writing for taking |
270 | * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all | 272 | * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all |
271 | * the other hypervisors would tease it. | 273 | * the other hypervisors would beat it up at lunchtime. |
272 | * | 274 | * |
273 | * This routine indicates if a particular trap number could be delivered | 275 | * This routine indicates if a particular trap number could be delivered |
274 | * directly. */ | 276 | * directly. */ |
@@ -331,7 +333,7 @@ void pin_stack_pages(struct lguest *lg) | |||
331 | * change stacks on each context switch. */ | 333 | * change stacks on each context switch. */ |
332 | void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) | 334 | void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) |
333 | { | 335 | { |
334 | /* You are not allowd have a stack segment with privilege level 0: bad | 336 | /* You are not allowed have a stack segment with privilege level 0: bad |
335 | * Guest! */ | 337 | * Guest! */ |
336 | if ((seg & 0x3) != GUEST_PL) | 338 | if ((seg & 0x3) != GUEST_PL) |
337 | kill_guest(lg, "bad stack segment %i", seg); | 339 | kill_guest(lg, "bad stack segment %i", seg); |
@@ -350,7 +352,7 @@ void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) | |||
350 | * part of the Host: page table handling. */ | 352 | * part of the Host: page table handling. */ |
351 | 353 | ||
352 | /*H:235 This is the routine which actually checks the Guest's IDT entry and | 354 | /*H:235 This is the routine which actually checks the Guest's IDT entry and |
353 | * transfers it into our entry in "struct lguest": */ | 355 | * transfers it into the entry in "struct lguest": */ |
354 | static void set_trap(struct lguest *lg, struct desc_struct *trap, | 356 | static void set_trap(struct lguest *lg, struct desc_struct *trap, |
355 | unsigned int num, u32 lo, u32 hi) | 357 | unsigned int num, u32 lo, u32 hi) |
356 | { | 358 | { |
@@ -456,6 +458,18 @@ void copy_traps(const struct lguest *lg, struct desc_struct *idt, | |||
456 | } | 458 | } |
457 | } | 459 | } |
458 | 460 | ||
461 | /*H:200 | ||
462 | * The Guest Clock. | ||
463 | * | ||
464 | * There are two sources of virtual interrupts. We saw one in lguest_user.c: | ||
465 | * the Launcher sending interrupts for virtual devices. The other is the Guest | ||
466 | * timer interrupt. | ||
467 | * | ||
468 | * The Guest uses the LHCALL_SET_CLOCKEVENT hypercall to tell us how long to | ||
469 | * the next timer interrupt (in nanoseconds). We use the high-resolution timer | ||
470 | * infrastructure to set a callback at that time. | ||
471 | * | ||
472 | * 0 means "turn off the clock". */ | ||
459 | void guest_set_clockevent(struct lguest *lg, unsigned long delta) | 473 | void guest_set_clockevent(struct lguest *lg, unsigned long delta) |
460 | { | 474 | { |
461 | ktime_t expires; | 475 | ktime_t expires; |
@@ -466,20 +480,27 @@ void guest_set_clockevent(struct lguest *lg, unsigned long delta) | |||
466 | return; | 480 | return; |
467 | } | 481 | } |
468 | 482 | ||
483 | /* We use wallclock time here, so the Guest might not be running for | ||
484 | * all the time between now and the timer interrupt it asked for. This | ||
485 | * is almost always the right thing to do. */ | ||
469 | expires = ktime_add_ns(ktime_get_real(), delta); | 486 | expires = ktime_add_ns(ktime_get_real(), delta); |
470 | hrtimer_start(&lg->hrt, expires, HRTIMER_MODE_ABS); | 487 | hrtimer_start(&lg->hrt, expires, HRTIMER_MODE_ABS); |
471 | } | 488 | } |
472 | 489 | ||
490 | /* This is the function called when the Guest's timer expires. */ | ||
473 | static enum hrtimer_restart clockdev_fn(struct hrtimer *timer) | 491 | static enum hrtimer_restart clockdev_fn(struct hrtimer *timer) |
474 | { | 492 | { |
475 | struct lguest *lg = container_of(timer, struct lguest, hrt); | 493 | struct lguest *lg = container_of(timer, struct lguest, hrt); |
476 | 494 | ||
495 | /* Remember the first interrupt is the timer interrupt. */ | ||
477 | set_bit(0, lg->irqs_pending); | 496 | set_bit(0, lg->irqs_pending); |
497 | /* If the Guest is actually stopped, we need to wake it up. */ | ||
478 | if (lg->halted) | 498 | if (lg->halted) |
479 | wake_up_process(lg->tsk); | 499 | wake_up_process(lg->tsk); |
480 | return HRTIMER_NORESTART; | 500 | return HRTIMER_NORESTART; |
481 | } | 501 | } |
482 | 502 | ||
503 | /* This sets up the timer for this Guest. */ | ||
483 | void init_clockdev(struct lguest *lg) | 504 | void init_clockdev(struct lguest *lg) |
484 | { | 505 | { |
485 | hrtimer_init(&lg->hrt, CLOCK_REALTIME, HRTIMER_MODE_ABS); | 506 | hrtimer_init(&lg->hrt, CLOCK_REALTIME, HRTIMER_MODE_ABS); |
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index d9144beca8..86924891b5 100644 --- a/drivers/lguest/lg.h +++ b/drivers/lguest/lg.h | |||
@@ -74,9 +74,6 @@ struct lguest | |||
74 | u32 pgdidx; | 74 | u32 pgdidx; |
75 | struct pgdir pgdirs[4]; | 75 | struct pgdir pgdirs[4]; |
76 | 76 | ||
77 | /* Cached wakeup: we hold a reference to this task. */ | ||
78 | struct task_struct *wake; | ||
79 | |||
80 | unsigned long noirq_start, noirq_end; | 77 | unsigned long noirq_start, noirq_end; |
81 | unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ | 78 | unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ |
82 | 79 | ||
@@ -103,7 +100,7 @@ int lguest_address_ok(const struct lguest *lg, | |||
103 | void __lgread(struct lguest *, void *, unsigned long, unsigned); | 100 | void __lgread(struct lguest *, void *, unsigned long, unsigned); |
104 | void __lgwrite(struct lguest *, unsigned long, const void *, unsigned); | 101 | void __lgwrite(struct lguest *, unsigned long, const void *, unsigned); |
105 | 102 | ||
106 | /*L:306 Using memory-copy operations like that is usually inconvient, so we | 103 | /*H:035 Using memory-copy operations like that is usually inconvient, so we |
107 | * have the following helper macros which read and write a specific type (often | 104 | * have the following helper macros which read and write a specific type (often |
108 | * an unsigned long). | 105 | * an unsigned long). |
109 | * | 106 | * |
@@ -191,7 +188,7 @@ void write_timestamp(struct lguest *lg); | |||
191 | * Let's step aside for the moment, to study one important routine that's used | 188 | * Let's step aside for the moment, to study one important routine that's used |
192 | * widely in the Host code. | 189 | * widely in the Host code. |
193 | * | 190 | * |
194 | * There are many cases where the Guest does something invalid, like pass crap | 191 | * There are many cases where the Guest can do something invalid, like pass crap |
195 | * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite | 192 | * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite |
196 | * acceptable to simply terminate the Guest and give the Launcher a nicely | 193 | * acceptable to simply terminate the Guest and give the Launcher a nicely |
197 | * formatted reason. It's also simpler for the Guest itself, which doesn't | 194 | * formatted reason. It's also simpler for the Guest itself, which doesn't |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 71c64837b4..8904f72f97 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -53,7 +53,8 @@ struct lguest_device { | |||
53 | * Device configurations | 53 | * Device configurations |
54 | * | 54 | * |
55 | * The configuration information for a device consists of a series of fields. | 55 | * The configuration information for a device consists of a series of fields. |
56 | * The device will look for these fields during setup. | 56 | * We don't really care what they are: the Launcher set them up, and the driver |
57 | * will look at them during setup. | ||
57 | * | 58 | * |
58 | * For us these fields come immediately after that device's descriptor in the | 59 | * For us these fields come immediately after that device's descriptor in the |
59 | * lguest_devices page. | 60 | * lguest_devices page. |
@@ -122,8 +123,8 @@ static void lg_set_status(struct virtio_device *vdev, u8 status) | |||
122 | * The other piece of infrastructure virtio needs is a "virtqueue": a way of | 123 | * The other piece of infrastructure virtio needs is a "virtqueue": a way of |
123 | * the Guest device registering buffers for the other side to read from or | 124 | * the Guest device registering buffers for the other side to read from or |
124 | * write into (ie. send and receive buffers). Each device can have multiple | 125 | * write into (ie. send and receive buffers). Each device can have multiple |
125 | * virtqueues: for example the console has one queue for sending and one for | 126 | * virtqueues: for example the console driver uses one queue for sending and |
126 | * receiving. | 127 | * another for receiving. |
127 | * | 128 | * |
128 | * Fortunately for us, a very fast shared-memory-plus-descriptors virtqueue | 129 | * Fortunately for us, a very fast shared-memory-plus-descriptors virtqueue |
129 | * already exists in virtio_ring.c. We just need to connect it up. | 130 | * already exists in virtio_ring.c. We just need to connect it up. |
@@ -158,7 +159,7 @@ static void lg_notify(struct virtqueue *vq) | |||
158 | * | 159 | * |
159 | * This is kind of an ugly duckling. It'd be nicer to have a standard | 160 | * This is kind of an ugly duckling. It'd be nicer to have a standard |
160 | * representation of a virtqueue in the configuration space, but it seems that | 161 | * representation of a virtqueue in the configuration space, but it seems that |
161 | * everyone wants to do it differently. The KVM guys want the Guest to | 162 | * everyone wants to do it differently. The KVM coders want the Guest to |
162 | * allocate its own pages and tell the Host where they are, but for lguest it's | 163 | * allocate its own pages and tell the Host where they are, but for lguest it's |
163 | * simpler for the Host to simply tell us where the pages are. | 164 | * simpler for the Host to simply tell us where the pages are. |
164 | * | 165 | * |
@@ -284,6 +285,8 @@ static void add_lguest_device(struct lguest_device_desc *d) | |||
284 | { | 285 | { |
285 | struct lguest_device *ldev; | 286 | struct lguest_device *ldev; |
286 | 287 | ||
288 | /* Start with zeroed memory; Linux's device layer seems to count on | ||
289 | * it. */ | ||
287 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); | 290 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); |
288 | if (!ldev) { | 291 | if (!ldev) { |
289 | printk(KERN_EMERG "Cannot allocate lguest dev %u\n", | 292 | printk(KERN_EMERG "Cannot allocate lguest dev %u\n", |
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c index ee405b3838..9d716fa42c 100644 --- a/drivers/lguest/lguest_user.c +++ b/drivers/lguest/lguest_user.c | |||
@@ -8,20 +8,22 @@ | |||
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | #include "lg.h" | 9 | #include "lg.h" |
10 | 10 | ||
11 | /*L:315 To force the Guest to stop running and return to the Launcher, the | 11 | /*L:055 When something happens, the Waker process needs a way to stop the |
12 | * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The | 12 | * kernel running the Guest and return to the Launcher. So the Waker writes |
13 | * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ | 13 | * LHREQ_BREAK and the value "1" to /dev/lguest to do this. Once the Launcher |
14 | * has done whatever needs attention, it writes LHREQ_BREAK and "0" to release | ||
15 | * the Waker. */ | ||
14 | static int break_guest_out(struct lguest *lg, const unsigned long __user *input) | 16 | static int break_guest_out(struct lguest *lg, const unsigned long __user *input) |
15 | { | 17 | { |
16 | unsigned long on; | 18 | unsigned long on; |
17 | 19 | ||
18 | /* Fetch whether they're turning break on or off.. */ | 20 | /* Fetch whether they're turning break on or off. */ |
19 | if (get_user(on, input) != 0) | 21 | if (get_user(on, input) != 0) |
20 | return -EFAULT; | 22 | return -EFAULT; |
21 | 23 | ||
22 | if (on) { | 24 | if (on) { |
23 | lg->break_out = 1; | 25 | lg->break_out = 1; |
24 | /* Pop it out (may be running on different CPU) */ | 26 | /* Pop it out of the Guest (may be running on different CPU) */ |
25 | wake_up_process(lg->tsk); | 27 | wake_up_process(lg->tsk); |
26 | /* Wait for them to reset it */ | 28 | /* Wait for them to reset it */ |
27 | return wait_event_interruptible(lg->break_wq, !lg->break_out); | 29 | return wait_event_interruptible(lg->break_wq, !lg->break_out); |
@@ -58,7 +60,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) | |||
58 | if (!lg) | 60 | if (!lg) |
59 | return -EINVAL; | 61 | return -EINVAL; |
60 | 62 | ||
61 | /* If you're not the task which owns the guest, go away. */ | 63 | /* If you're not the task which owns the Guest, go away. */ |
62 | if (current != lg->tsk) | 64 | if (current != lg->tsk) |
63 | return -EPERM; | 65 | return -EPERM; |
64 | 66 | ||
@@ -92,8 +94,8 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) | |||
92 | * base: The start of the Guest-physical memory inside the Launcher memory. | 94 | * base: The start of the Guest-physical memory inside the Launcher memory. |
93 | * | 95 | * |
94 | * pfnlimit: The highest (Guest-physical) page number the Guest should be | 96 | * pfnlimit: The highest (Guest-physical) page number the Guest should be |
95 | * allowed to access. The Launcher has to live in Guest memory, so it sets | 97 | * allowed to access. The Guest memory lives inside the Launcher, so it sets |
96 | * this to ensure the Guest can't reach it. | 98 | * this to ensure the Guest can only reach its own memory. |
97 | * | 99 | * |
98 | * pgdir: The (Guest-physical) address of the top of the initial Guest | 100 | * pgdir: The (Guest-physical) address of the top of the initial Guest |
99 | * pagetables (which are set up by the Launcher). | 101 | * pagetables (which are set up by the Launcher). |
@@ -189,7 +191,7 @@ unlock: | |||
189 | } | 191 | } |
190 | 192 | ||
191 | /*L:010 The first operation the Launcher does must be a write. All writes | 193 | /*L:010 The first operation the Launcher does must be a write. All writes |
192 | * start with a 32 bit number: for the first write this must be | 194 | * start with an unsigned long number: for the first write this must be |
193 | * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use | 195 | * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use |
194 | * writes of other values to send interrupts. */ | 196 | * writes of other values to send interrupts. */ |
195 | static ssize_t write(struct file *file, const char __user *in, | 197 | static ssize_t write(struct file *file, const char __user *in, |
@@ -275,8 +277,7 @@ static int close(struct inode *inode, struct file *file) | |||
275 | * The Launcher is the Host userspace program which sets up, runs and services | 277 | * The Launcher is the Host userspace program which sets up, runs and services |
276 | * the Guest. In fact, many comments in the Drivers which refer to "the Host" | 278 | * the Guest. In fact, many comments in the Drivers which refer to "the Host" |
277 | * doing things are inaccurate: the Launcher does all the device handling for | 279 | * doing things are inaccurate: the Launcher does all the device handling for |
278 | * the Guest. The Guest can't tell what's done by the the Launcher and what by | 280 | * the Guest, but the Guest can't know that. |
279 | * the Host. | ||
280 | * | 281 | * |
281 | * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we | 282 | * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we |
282 | * shall see more of that later. | 283 | * shall see more of that later. |
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c index 2a45f0691c..fffabb3271 100644 --- a/drivers/lguest/page_tables.c +++ b/drivers/lguest/page_tables.c | |||
@@ -26,7 +26,8 @@ | |||
26 | * | 26 | * |
27 | * We use two-level page tables for the Guest. If you're not entirely | 27 | * We use two-level page tables for the Guest. If you're not entirely |
28 | * comfortable with virtual addresses, physical addresses and page tables then | 28 | * comfortable with virtual addresses, physical addresses and page tables then |
29 | * I recommend you review lguest.c's "Page Table Handling" (with diagrams!). | 29 | * I recommend you review arch/x86/lguest/boot.c's "Page Table Handling" (with |
30 | * diagrams!). | ||
30 | * | 31 | * |
31 | * The Guest keeps page tables, but we maintain the actual ones here: these are | 32 | * The Guest keeps page tables, but we maintain the actual ones here: these are |
32 | * called "shadow" page tables. Which is a very Guest-centric name: these are | 33 | * called "shadow" page tables. Which is a very Guest-centric name: these are |
@@ -36,11 +37,11 @@ | |||
36 | * | 37 | * |
37 | * Anyway, this is the most complicated part of the Host code. There are seven | 38 | * Anyway, this is the most complicated part of the Host code. There are seven |
38 | * parts to this: | 39 | * parts to this: |
39 | * (i) Setting up a page table entry for the Guest when it faults, | 40 | * (i) Looking up a page table entry when the Guest faults, |
40 | * (ii) Setting up the page table entry for the Guest stack, | 41 | * (ii) Making sure the Guest stack is mapped, |
41 | * (iii) Setting up a page table entry when the Guest tells us it has changed, | 42 | * (iii) Setting up a page table entry when the Guest tells us one has changed, |
42 | * (iv) Switching page tables, | 43 | * (iv) Switching page tables, |
43 | * (v) Flushing (thowing away) page tables, | 44 | * (v) Flushing (throwing away) page tables, |
44 | * (vi) Mapping the Switcher when the Guest is about to run, | 45 | * (vi) Mapping the Switcher when the Guest is about to run, |
45 | * (vii) Setting up the page tables initially. | 46 | * (vii) Setting up the page tables initially. |
46 | :*/ | 47 | :*/ |
@@ -57,16 +58,15 @@ | |||
57 | static DEFINE_PER_CPU(pte_t *, switcher_pte_pages); | 58 | static DEFINE_PER_CPU(pte_t *, switcher_pte_pages); |
58 | #define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) | 59 | #define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) |
59 | 60 | ||
60 | /*H:320 With our shadow and Guest types established, we need to deal with | 61 | /*H:320 The page table code is curly enough to need helper functions to keep it |
61 | * them: the page table code is curly enough to need helper functions to keep | 62 | * clear and clean. |
62 | * it clear and clean. | ||
63 | * | 63 | * |
64 | * There are two functions which return pointers to the shadow (aka "real") | 64 | * There are two functions which return pointers to the shadow (aka "real") |
65 | * page tables. | 65 | * page tables. |
66 | * | 66 | * |
67 | * spgd_addr() takes the virtual address and returns a pointer to the top-level | 67 | * spgd_addr() takes the virtual address and returns a pointer to the top-level |
68 | * page directory entry for that address. Since we keep track of several page | 68 | * page directory entry (PGD) for that address. Since we keep track of several |
69 | * tables, the "i" argument tells us which one we're interested in (it's | 69 | * page tables, the "i" argument tells us which one we're interested in (it's |
70 | * usually the current one). */ | 70 | * usually the current one). */ |
71 | static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) | 71 | static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) |
72 | { | 72 | { |
@@ -81,9 +81,9 @@ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) | |||
81 | return &lg->pgdirs[i].pgdir[index]; | 81 | return &lg->pgdirs[i].pgdir[index]; |
82 | } | 82 | } |
83 | 83 | ||
84 | /* This routine then takes the PGD entry given above, which contains the | 84 | /* This routine then takes the page directory entry returned above, which |
85 | * address of the PTE page. It then returns a pointer to the PTE entry for the | 85 | * contains the address of the page table entry (PTE) page. It then returns a |
86 | * given address. */ | 86 | * pointer to the PTE entry for the given address. */ |
87 | static pte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) | 87 | static pte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) |
88 | { | 88 | { |
89 | pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); | 89 | pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); |
@@ -191,7 +191,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | /*H:330 | 193 | /*H:330 |
194 | * (i) Setting up a page table entry for the Guest when it faults | 194 | * (i) Looking up a page table entry when the Guest faults. |
195 | * | 195 | * |
196 | * We saw this call in run_guest(): when we see a page fault in the Guest, we | 196 | * We saw this call in run_guest(): when we see a page fault in the Guest, we |
197 | * come here. That's because we only set up the shadow page tables lazily as | 197 | * come here. That's because we only set up the shadow page tables lazily as |
@@ -199,7 +199,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) | |||
199 | * and return to the Guest without it knowing. | 199 | * and return to the Guest without it knowing. |
200 | * | 200 | * |
201 | * If we fixed up the fault (ie. we mapped the address), this routine returns | 201 | * If we fixed up the fault (ie. we mapped the address), this routine returns |
202 | * true. */ | 202 | * true. Otherwise, it was a real fault and we need to tell the Guest. */ |
203 | int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | 203 | int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) |
204 | { | 204 | { |
205 | pgd_t gpgd; | 205 | pgd_t gpgd; |
@@ -246,16 +246,16 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | |||
246 | if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) | 246 | if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) |
247 | return 0; | 247 | return 0; |
248 | 248 | ||
249 | /* User access to a kernel page? (bit 3 == user access) */ | 249 | /* User access to a kernel-only page? (bit 3 == user access) */ |
250 | if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) | 250 | if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) |
251 | return 0; | 251 | return 0; |
252 | 252 | ||
253 | /* Check that the Guest PTE flags are OK, and the page number is below | 253 | /* Check that the Guest PTE flags are OK, and the page number is below |
254 | * the pfn_limit (ie. not mapping the Launcher binary). */ | 254 | * the pfn_limit (ie. not mapping the Launcher binary). */ |
255 | check_gpte(lg, gpte); | 255 | check_gpte(lg, gpte); |
256 | |||
256 | /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */ | 257 | /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */ |
257 | gpte = pte_mkyoung(gpte); | 258 | gpte = pte_mkyoung(gpte); |
258 | |||
259 | if (errcode & 2) | 259 | if (errcode & 2) |
260 | gpte = pte_mkdirty(gpte); | 260 | gpte = pte_mkdirty(gpte); |
261 | 261 | ||
@@ -272,23 +272,28 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | |||
272 | else | 272 | else |
273 | /* If this is a read, don't set the "writable" bit in the page | 273 | /* If this is a read, don't set the "writable" bit in the page |
274 | * table entry, even if the Guest says it's writable. That way | 274 | * table entry, even if the Guest says it's writable. That way |
275 | * we come back here when a write does actually ocur, so we can | 275 | * we will come back here when a write does actually occur, so |
276 | * update the Guest's _PAGE_DIRTY flag. */ | 276 | * we can update the Guest's _PAGE_DIRTY flag. */ |
277 | *spte = gpte_to_spte(lg, pte_wrprotect(gpte), 0); | 277 | *spte = gpte_to_spte(lg, pte_wrprotect(gpte), 0); |
278 | 278 | ||
279 | /* Finally, we write the Guest PTE entry back: we've set the | 279 | /* Finally, we write the Guest PTE entry back: we've set the |
280 | * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */ | 280 | * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */ |
281 | lgwrite(lg, gpte_ptr, pte_t, gpte); | 281 | lgwrite(lg, gpte_ptr, pte_t, gpte); |
282 | 282 | ||
283 | /* We succeeded in mapping the page! */ | 283 | /* The fault is fixed, the page table is populated, the mapping |
284 | * manipulated, the result returned and the code complete. A small | ||
285 | * delay and a trace of alliteration are the only indications the Guest | ||
286 | * has that a page fault occurred at all. */ | ||
284 | return 1; | 287 | return 1; |
285 | } | 288 | } |
286 | 289 | ||
287 | /*H:360 (ii) Setting up the page table entry for the Guest stack. | 290 | /*H:360 |
291 | * (ii) Making sure the Guest stack is mapped. | ||
288 | * | 292 | * |
289 | * Remember pin_stack_pages() which makes sure the stack is mapped? It could | 293 | * Remember that direct traps into the Guest need a mapped Guest kernel stack. |
290 | * simply call demand_page(), but as we've seen that logic is quite long, and | 294 | * pin_stack_pages() calls us here: we could simply call demand_page(), but as |
291 | * usually the stack pages are already mapped anyway, so it's not required. | 295 | * we've seen that logic is quite long, and usually the stack pages are already |
296 | * mapped, so it's overkill. | ||
292 | * | 297 | * |
293 | * This is a quick version which answers the question: is this virtual address | 298 | * This is a quick version which answers the question: is this virtual address |
294 | * mapped by the shadow page tables, and is it writable? */ | 299 | * mapped by the shadow page tables, and is it writable? */ |
@@ -297,7 +302,7 @@ static int page_writable(struct lguest *lg, unsigned long vaddr) | |||
297 | pgd_t *spgd; | 302 | pgd_t *spgd; |
298 | unsigned long flags; | 303 | unsigned long flags; |
299 | 304 | ||
300 | /* Look at the top level entry: is it present? */ | 305 | /* Look at the current top level entry: is it present? */ |
301 | spgd = spgd_addr(lg, lg->pgdidx, vaddr); | 306 | spgd = spgd_addr(lg, lg->pgdidx, vaddr); |
302 | if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) | 307 | if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) |
303 | return 0; | 308 | return 0; |
@@ -333,15 +338,14 @@ static void release_pgd(struct lguest *lg, pgd_t *spgd) | |||
333 | release_pte(ptepage[i]); | 338 | release_pte(ptepage[i]); |
334 | /* Now we can free the page of PTEs */ | 339 | /* Now we can free the page of PTEs */ |
335 | free_page((long)ptepage); | 340 | free_page((long)ptepage); |
336 | /* And zero out the PGD entry we we never release it twice. */ | 341 | /* And zero out the PGD entry so we never release it twice. */ |
337 | *spgd = __pgd(0); | 342 | *spgd = __pgd(0); |
338 | } | 343 | } |
339 | } | 344 | } |
340 | 345 | ||
341 | /*H:440 (v) Flushing (thowing away) page tables, | 346 | /*H:445 We saw flush_user_mappings() twice: once from the flush_user_mappings() |
342 | * | 347 | * hypercall and once in new_pgdir() when we re-used a top-level pgdir page. |
343 | * We saw flush_user_mappings() called when we re-used a top-level pgdir page. | 348 | * It simply releases every PTE page from 0 up to the Guest's kernel address. */ |
344 | * It simply releases every PTE page from 0 up to the kernel address. */ | ||
345 | static void flush_user_mappings(struct lguest *lg, int idx) | 349 | static void flush_user_mappings(struct lguest *lg, int idx) |
346 | { | 350 | { |
347 | unsigned int i; | 351 | unsigned int i; |
@@ -350,8 +354,10 @@ static void flush_user_mappings(struct lguest *lg, int idx) | |||
350 | release_pgd(lg, lg->pgdirs[idx].pgdir + i); | 354 | release_pgd(lg, lg->pgdirs[idx].pgdir + i); |
351 | } | 355 | } |
352 | 356 | ||
353 | /* The Guest also has a hypercall to do this manually: it's used when a large | 357 | /*H:440 (v) Flushing (throwing away) page tables, |
354 | * number of mappings have been changed. */ | 358 | * |
359 | * The Guest has a hypercall to throw away the page tables: it's used when a | ||
360 | * large number of mappings have been changed. */ | ||
355 | void guest_pagetable_flush_user(struct lguest *lg) | 361 | void guest_pagetable_flush_user(struct lguest *lg) |
356 | { | 362 | { |
357 | /* Drop the userspace part of the current page table. */ | 363 | /* Drop the userspace part of the current page table. */ |
@@ -423,8 +429,9 @@ static unsigned int new_pgdir(struct lguest *lg, | |||
423 | 429 | ||
424 | /*H:430 (iv) Switching page tables | 430 | /*H:430 (iv) Switching page tables |
425 | * | 431 | * |
426 | * This is what happens when the Guest changes page tables (ie. changes the | 432 | * Now we've seen all the page table setting and manipulation, let's see what |
427 | * top-level pgdir). This happens on almost every context switch. */ | 433 | * what happens when the Guest changes page tables (ie. changes the top-level |
434 | * pgdir). This occurs on almost every context switch. */ | ||
428 | void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) | 435 | void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) |
429 | { | 436 | { |
430 | int newpgdir, repin = 0; | 437 | int newpgdir, repin = 0; |
@@ -443,7 +450,8 @@ void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) | |||
443 | } | 450 | } |
444 | 451 | ||
445 | /*H:470 Finally, a routine which throws away everything: all PGD entries in all | 452 | /*H:470 Finally, a routine which throws away everything: all PGD entries in all |
446 | * the shadow page tables. This is used when we destroy the Guest. */ | 453 | * the shadow page tables, including the Guest's kernel mappings. This is used |
454 | * when we destroy the Guest. */ | ||
447 | static void release_all_pagetables(struct lguest *lg) | 455 | static void release_all_pagetables(struct lguest *lg) |
448 | { | 456 | { |
449 | unsigned int i, j; | 457 | unsigned int i, j; |
@@ -458,13 +466,22 @@ static void release_all_pagetables(struct lguest *lg) | |||
458 | 466 | ||
459 | /* We also throw away everything when a Guest tells us it's changed a kernel | 467 | /* We also throw away everything when a Guest tells us it's changed a kernel |
460 | * mapping. Since kernel mappings are in every page table, it's easiest to | 468 | * mapping. Since kernel mappings are in every page table, it's easiest to |
461 | * throw them all away. This is amazingly slow, but thankfully rare. */ | 469 | * throw them all away. This traps the Guest in amber for a while as |
470 | * everything faults back in, but it's rare. */ | ||
462 | void guest_pagetable_clear_all(struct lguest *lg) | 471 | void guest_pagetable_clear_all(struct lguest *lg) |
463 | { | 472 | { |
464 | release_all_pagetables(lg); | 473 | release_all_pagetables(lg); |
465 | /* We need the Guest kernel stack mapped again. */ | 474 | /* We need the Guest kernel stack mapped again. */ |
466 | pin_stack_pages(lg); | 475 | pin_stack_pages(lg); |
467 | } | 476 | } |
477 | /*:*/ | ||
478 | /*M:009 Since we throw away all mappings when a kernel mapping changes, our | ||
479 | * performance sucks for guests using highmem. In fact, a guest with | ||
480 | * PAGE_OFFSET 0xc0000000 (the default) and more than about 700MB of RAM is | ||
481 | * usually slower than a Guest with less memory. | ||
482 | * | ||
483 | * This, of course, cannot be fixed. It would take some kind of... well, I | ||
484 | * don't know, but the term "puissant code-fu" comes to mind. :*/ | ||
468 | 485 | ||
469 | /*H:420 This is the routine which actually sets the page table entry for then | 486 | /*H:420 This is the routine which actually sets the page table entry for then |
470 | * "idx"'th shadow page table. | 487 | * "idx"'th shadow page table. |
@@ -483,7 +500,7 @@ void guest_pagetable_clear_all(struct lguest *lg) | |||
483 | static void do_set_pte(struct lguest *lg, int idx, | 500 | static void do_set_pte(struct lguest *lg, int idx, |
484 | unsigned long vaddr, pte_t gpte) | 501 | unsigned long vaddr, pte_t gpte) |
485 | { | 502 | { |
486 | /* Look up the matching shadow page directot entry. */ | 503 | /* Look up the matching shadow page directory entry. */ |
487 | pgd_t *spgd = spgd_addr(lg, idx, vaddr); | 504 | pgd_t *spgd = spgd_addr(lg, idx, vaddr); |
488 | 505 | ||
489 | /* If the top level isn't present, there's no entry to update. */ | 506 | /* If the top level isn't present, there's no entry to update. */ |
@@ -500,7 +517,8 @@ static void do_set_pte(struct lguest *lg, int idx, | |||
500 | *spte = gpte_to_spte(lg, gpte, | 517 | *spte = gpte_to_spte(lg, gpte, |
501 | pte_flags(gpte) & _PAGE_DIRTY); | 518 | pte_flags(gpte) & _PAGE_DIRTY); |
502 | } else | 519 | } else |
503 | /* Otherwise we can demand_page() it in later. */ | 520 | /* Otherwise kill it and we can demand_page() it in |
521 | * later. */ | ||
504 | *spte = __pte(0); | 522 | *spte = __pte(0); |
505 | } | 523 | } |
506 | } | 524 | } |
@@ -535,7 +553,7 @@ void guest_set_pte(struct lguest *lg, | |||
535 | } | 553 | } |
536 | 554 | ||
537 | /*H:400 | 555 | /*H:400 |
538 | * (iii) Setting up a page table entry when the Guest tells us it has changed. | 556 | * (iii) Setting up a page table entry when the Guest tells us one has changed. |
539 | * | 557 | * |
540 | * Just like we did in interrupts_and_traps.c, it makes sense for us to deal | 558 | * Just like we did in interrupts_and_traps.c, it makes sense for us to deal |
541 | * with the other side of page tables while we're here: what happens when the | 559 | * with the other side of page tables while we're here: what happens when the |
@@ -612,9 +630,10 @@ void free_guest_pagetable(struct lguest *lg) | |||
612 | 630 | ||
613 | /*H:480 (vi) Mapping the Switcher when the Guest is about to run. | 631 | /*H:480 (vi) Mapping the Switcher when the Guest is about to run. |
614 | * | 632 | * |
615 | * The Switcher and the two pages for this CPU need to be available to the | 633 | * The Switcher and the two pages for this CPU need to be visible in the |
616 | * Guest (and not the pages for other CPUs). We have the appropriate PTE pages | 634 | * Guest (and not the pages for other CPUs). We have the appropriate PTE pages |
617 | * for each CPU already set up, we just need to hook them in. */ | 635 | * for each CPU already set up, we just need to hook them in now we know which |
636 | * Guest is about to run on this CPU. */ | ||
618 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) | 637 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) |
619 | { | 638 | { |
620 | pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); | 639 | pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); |
@@ -677,6 +696,18 @@ static __init void populate_switcher_pte_page(unsigned int cpu, | |||
677 | __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)); | 696 | __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)); |
678 | } | 697 | } |
679 | 698 | ||
699 | /* We've made it through the page table code. Perhaps our tired brains are | ||
700 | * still processing the details, or perhaps we're simply glad it's over. | ||
701 | * | ||
702 | * If nothing else, note that all this complexity in juggling shadow page | ||
703 | * tables in sync with the Guest's page tables is for one reason: for most | ||
704 | * Guests this page table dance determines how bad performance will be. This | ||
705 | * is why Xen uses exotic direct Guest pagetable manipulation, and why both | ||
706 | * Intel and AMD have implemented shadow page table support directly into | ||
707 | * hardware. | ||
708 | * | ||
709 | * There is just one file remaining in the Host. */ | ||
710 | |||
680 | /*H:510 At boot or module load time, init_pagetables() allocates and populates | 711 | /*H:510 At boot or module load time, init_pagetables() allocates and populates |
681 | * the Switcher PTE page for each CPU. */ | 712 | * the Switcher PTE page for each CPU. */ |
682 | __init int init_pagetables(struct page **switcher_page, unsigned int pages) | 713 | __init int init_pagetables(struct page **switcher_page, unsigned int pages) |
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index c2434ec99f..9e189cbec7 100644 --- a/drivers/lguest/segments.c +++ b/drivers/lguest/segments.c | |||
@@ -12,8 +12,6 @@ | |||
12 | #include "lg.h" | 12 | #include "lg.h" |
13 | 13 | ||
14 | /*H:600 | 14 | /*H:600 |
15 | * We've almost completed the Host; there's just one file to go! | ||
16 | * | ||
17 | * Segments & The Global Descriptor Table | 15 | * Segments & The Global Descriptor Table |
18 | * | 16 | * |
19 | * (That title sounds like a bad Nerdcore group. Not to suggest that there are | 17 | * (That title sounds like a bad Nerdcore group. Not to suggest that there are |
@@ -55,7 +53,7 @@ static int ignored_gdt(unsigned int num) | |||
55 | || num == GDT_ENTRY_DOUBLEFAULT_TSS); | 53 | || num == GDT_ENTRY_DOUBLEFAULT_TSS); |
56 | } | 54 | } |
57 | 55 | ||
58 | /*H:610 Once the GDT has been changed, we fix the new entries up a little. We | 56 | /*H:630 Once the Guest gave us new GDT entries, we fix them up a little. We |
59 | * don't care if they're invalid: the worst that can happen is a General | 57 | * don't care if they're invalid: the worst that can happen is a General |
60 | * Protection Fault in the Switcher when it restores a Guest segment register | 58 | * Protection Fault in the Switcher when it restores a Guest segment register |
61 | * which tries to use that entry. Then we kill the Guest for causing such a | 59 | * which tries to use that entry. Then we kill the Guest for causing such a |
@@ -84,25 +82,33 @@ static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end) | |||
84 | } | 82 | } |
85 | } | 83 | } |
86 | 84 | ||
87 | /* This routine is called at boot or modprobe time for each CPU to set up the | 85 | /*H:610 Like the IDT, we never simply use the GDT the Guest gives us. We keep |
88 | * "constant" GDT entries for Guests running on that CPU. */ | 86 | * a GDT for each CPU, and copy across the Guest's entries each time we want to |
87 | * run the Guest on that CPU. | ||
88 | * | ||
89 | * This routine is called at boot or modprobe time for each CPU to set up the | ||
90 | * constant GDT entries: the ones which are the same no matter what Guest we're | ||
91 | * running. */ | ||
89 | void setup_default_gdt_entries(struct lguest_ro_state *state) | 92 | void setup_default_gdt_entries(struct lguest_ro_state *state) |
90 | { | 93 | { |
91 | struct desc_struct *gdt = state->guest_gdt; | 94 | struct desc_struct *gdt = state->guest_gdt; |
92 | unsigned long tss = (unsigned long)&state->guest_tss; | 95 | unsigned long tss = (unsigned long)&state->guest_tss; |
93 | 96 | ||
94 | /* The hypervisor segments are full 0-4G segments, privilege level 0 */ | 97 | /* The Switcher segments are full 0-4G segments, privilege level 0 */ |
95 | gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; | 98 | gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; |
96 | gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; | 99 | gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; |
97 | 100 | ||
98 | /* The TSS segment refers to the TSS entry for this CPU, so we cannot | 101 | /* The TSS segment refers to the TSS entry for this particular CPU. |
99 | * copy it from the Guest. Forgive the magic flags */ | 102 | * Forgive the magic flags: the 0x8900 means the entry is Present, it's |
103 | * privilege level 0 Available 386 TSS system segment, and the 0x67 | ||
104 | * means Saturn is eclipsed by Mercury in the twelfth house. */ | ||
100 | gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); | 105 | gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); |
101 | gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) | 106 | gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) |
102 | | ((tss >> 16) & 0x000000FF); | 107 | | ((tss >> 16) & 0x000000FF); |
103 | } | 108 | } |
104 | 109 | ||
105 | /* This routine is called before the Guest is run for the first time. */ | 110 | /* This routine sets up the initial Guest GDT for booting. All entries start |
111 | * as 0 (unusable). */ | ||
106 | void setup_guest_gdt(struct lguest *lg) | 112 | void setup_guest_gdt(struct lguest *lg) |
107 | { | 113 | { |
108 | /* Start with full 0-4G segments... */ | 114 | /* Start with full 0-4G segments... */ |
@@ -114,13 +120,8 @@ void setup_guest_gdt(struct lguest *lg) | |||
114 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); | 120 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); |
115 | } | 121 | } |
116 | 122 | ||
117 | /* Like the IDT, we never simply use the GDT the Guest gives us. We set up the | 123 | /*H:650 An optimization of copy_gdt(), for just the three "thead-local storage" |
118 | * GDTs for each CPU, then we copy across the entries each time we want to run | 124 | * entries. */ |
119 | * a different Guest on that CPU. */ | ||
120 | |||
121 | /* A partial GDT load, for the three "thead-local storage" entries. Otherwise | ||
122 | * it's just like load_guest_gdt(). So much, in fact, it would probably be | ||
123 | * neater to have a single hypercall to cover both. */ | ||
124 | void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) | 125 | void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) |
125 | { | 126 | { |
126 | unsigned int i; | 127 | unsigned int i; |
@@ -129,7 +130,9 @@ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) | |||
129 | gdt[i] = lg->arch.gdt[i]; | 130 | gdt[i] = lg->arch.gdt[i]; |
130 | } | 131 | } |
131 | 132 | ||
132 | /* This is the full version */ | 133 | /*H:640 When the Guest is run on a different CPU, or the GDT entries have |
134 | * changed, copy_gdt() is called to copy the Guest's GDT entries across to this | ||
135 | * CPU's GDT. */ | ||
133 | void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) | 136 | void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) |
134 | { | 137 | { |
135 | unsigned int i; | 138 | unsigned int i; |
@@ -141,7 +144,8 @@ void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) | |||
141 | gdt[i] = lg->arch.gdt[i]; | 144 | gdt[i] = lg->arch.gdt[i]; |
142 | } | 145 | } |
143 | 146 | ||
144 | /* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */ | 147 | /*H:620 This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). |
148 | * We copy it from the Guest and tweak the entries. */ | ||
145 | void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | 149 | void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) |
146 | { | 150 | { |
147 | /* We assume the Guest has the same number of GDT entries as the | 151 | /* We assume the Guest has the same number of GDT entries as the |
@@ -157,16 +161,22 @@ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | |||
157 | lg->changed |= CHANGED_GDT; | 161 | lg->changed |= CHANGED_GDT; |
158 | } | 162 | } |
159 | 163 | ||
164 | /* This is the fast-track version for just changing the three TLS entries. | ||
165 | * Remember that this happens on every context switch, so it's worth | ||
166 | * optimizing. But wouldn't it be neater to have a single hypercall to cover | ||
167 | * both cases? */ | ||
160 | void guest_load_tls(struct lguest *lg, unsigned long gtls) | 168 | void guest_load_tls(struct lguest *lg, unsigned long gtls) |
161 | { | 169 | { |
162 | struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; | 170 | struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; |
163 | 171 | ||
164 | __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); | 172 | __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); |
165 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); | 173 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); |
174 | /* Note that just the TLS entries have changed. */ | ||
166 | lg->changed |= CHANGED_GDT_TLS; | 175 | lg->changed |= CHANGED_GDT_TLS; |
167 | } | 176 | } |
177 | /*:*/ | ||
168 | 178 | ||
169 | /* | 179 | /*H:660 |
170 | * With this, we have finished the Host. | 180 | * With this, we have finished the Host. |
171 | * | 181 | * |
172 | * Five of the seven parts of our task are complete. You have made it through | 182 | * Five of the seven parts of our task are complete. You have made it through |
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index 9eed12d5a3..482aec2a96 100644 --- a/drivers/lguest/x86/core.c +++ b/drivers/lguest/x86/core.c | |||
@@ -63,7 +63,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu) | |||
63 | static DEFINE_PER_CPU(struct lguest *, last_guest); | 63 | static DEFINE_PER_CPU(struct lguest *, last_guest); |
64 | 64 | ||
65 | /*S:010 | 65 | /*S:010 |
66 | * We are getting close to the Switcher. | 66 | * We approach the Switcher. |
67 | * | 67 | * |
68 | * Remember that each CPU has two pages which are visible to the Guest when it | 68 | * Remember that each CPU has two pages which are visible to the Guest when it |
69 | * runs on that CPU. This has to contain the state for that Guest: we copy the | 69 | * runs on that CPU. This has to contain the state for that Guest: we copy the |
@@ -134,7 +134,7 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) | |||
134 | * | 134 | * |
135 | * The lcall also pushes the old code segment (KERNEL_CS) onto the | 135 | * The lcall also pushes the old code segment (KERNEL_CS) onto the |
136 | * stack, then the address of this call. This stack layout happens to | 136 | * stack, then the address of this call. This stack layout happens to |
137 | * exactly match the stack of an interrupt... */ | 137 | * exactly match the stack layout created by an interrupt... */ |
138 | asm volatile("pushf; lcall *lguest_entry" | 138 | asm volatile("pushf; lcall *lguest_entry" |
139 | /* This is how we tell GCC that %eax ("a") and %ebx ("b") | 139 | /* This is how we tell GCC that %eax ("a") and %ebx ("b") |
140 | * are changed by this routine. The "=" means output. */ | 140 | * are changed by this routine. The "=" means output. */ |
@@ -151,40 +151,46 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) | |||
151 | } | 151 | } |
152 | /*:*/ | 152 | /*:*/ |
153 | 153 | ||
154 | /*M:002 There are hooks in the scheduler which we can register to tell when we | ||
155 | * get kicked off the CPU (preempt_notifier_register()). This would allow us | ||
156 | * to lazily disable SYSENTER which would regain some performance, and should | ||
157 | * also simplify copy_in_guest_info(). Note that we'd still need to restore | ||
158 | * things when we exit to Launcher userspace, but that's fairly easy. | ||
159 | * | ||
160 | * The hooks were designed for KVM, but we can also put them to good use. :*/ | ||
161 | |||
154 | /*H:040 This is the i386-specific code to setup and run the Guest. Interrupts | 162 | /*H:040 This is the i386-specific code to setup and run the Guest. Interrupts |
155 | * are disabled: we own the CPU. */ | 163 | * are disabled: we own the CPU. */ |
156 | void lguest_arch_run_guest(struct lguest *lg) | 164 | void lguest_arch_run_guest(struct lguest *lg) |
157 | { | 165 | { |
158 | /* Remember the awfully-named TS bit? If the Guest has asked | 166 | /* Remember the awfully-named TS bit? If the Guest has asked to set it |
159 | * to set it we set it now, so we can trap and pass that trap | 167 | * we set it now, so we can trap and pass that trap to the Guest if it |
160 | * to the Guest if it uses the FPU. */ | 168 | * uses the FPU. */ |
161 | if (lg->ts) | 169 | if (lg->ts) |
162 | lguest_set_ts(); | 170 | lguest_set_ts(); |
163 | 171 | ||
164 | /* SYSENTER is an optimized way of doing system calls. We | 172 | /* SYSENTER is an optimized way of doing system calls. We can't allow |
165 | * can't allow it because it always jumps to privilege level 0. | 173 | * it because it always jumps to privilege level 0. A normal Guest |
166 | * A normal Guest won't try it because we don't advertise it in | 174 | * won't try it because we don't advertise it in CPUID, but a malicious |
167 | * CPUID, but a malicious Guest (or malicious Guest userspace | 175 | * Guest (or malicious Guest userspace program) could, so we tell the |
168 | * program) could, so we tell the CPU to disable it before | 176 | * CPU to disable it before running the Guest. */ |
169 | * running the Guest. */ | ||
170 | if (boot_cpu_has(X86_FEATURE_SEP)) | 177 | if (boot_cpu_has(X86_FEATURE_SEP)) |
171 | wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); | 178 | wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); |
172 | 179 | ||
173 | /* Now we actually run the Guest. It will pop back out when | 180 | /* Now we actually run the Guest. It will return when something |
174 | * something interesting happens, and we can examine its | 181 | * interesting happens, and we can examine its registers to see what it |
175 | * registers to see what it was doing. */ | 182 | * was doing. */ |
176 | run_guest_once(lg, lguest_pages(raw_smp_processor_id())); | 183 | run_guest_once(lg, lguest_pages(raw_smp_processor_id())); |
177 | 184 | ||
178 | /* The "regs" pointer contains two extra entries which are not | 185 | /* Note that the "regs" pointer contains two extra entries which are |
179 | * really registers: a trap number which says what interrupt or | 186 | * not really registers: a trap number which says what interrupt or |
180 | * trap made the switcher code come back, and an error code | 187 | * trap made the switcher code come back, and an error code which some |
181 | * which some traps set. */ | 188 | * traps set. */ |
182 | 189 | ||
183 | /* If the Guest page faulted, then the cr2 register will tell | 190 | /* If the Guest page faulted, then the cr2 register will tell us the |
184 | * us the bad virtual address. We have to grab this now, | 191 | * bad virtual address. We have to grab this now, because once we |
185 | * because once we re-enable interrupts an interrupt could | 192 | * re-enable interrupts an interrupt could fault and thus overwrite |
186 | * fault and thus overwrite cr2, or we could even move off to a | 193 | * cr2, or we could even move off to a different CPU. */ |
187 | * different CPU. */ | ||
188 | if (lg->regs->trapnum == 14) | 194 | if (lg->regs->trapnum == 14) |
189 | lg->arch.last_pagefault = read_cr2(); | 195 | lg->arch.last_pagefault = read_cr2(); |
190 | /* Similarly, if we took a trap because the Guest used the FPU, | 196 | /* Similarly, if we took a trap because the Guest used the FPU, |
@@ -197,14 +203,15 @@ void lguest_arch_run_guest(struct lguest *lg) | |||
197 | wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); | 203 | wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); |
198 | } | 204 | } |
199 | 205 | ||
200 | /*H:130 Our Guest is usually so well behaved; it never tries to do things it | 206 | /*H:130 Now we've examined the hypercall code; our Guest can make requests. |
201 | * isn't allowed to. Unfortunately, Linux's paravirtual infrastructure isn't | 207 | * Our Guest is usually so well behaved; it never tries to do things it isn't |
202 | * quite complete, because it doesn't contain replacements for the Intel I/O | 208 | * allowed to, and uses hypercalls instead. Unfortunately, Linux's paravirtual |
203 | * instructions. As a result, the Guest sometimes fumbles across one during | 209 | * infrastructure isn't quite complete, because it doesn't contain replacements |
204 | * the boot process as it probes for various things which are usually attached | 210 | * for the Intel I/O instructions. As a result, the Guest sometimes fumbles |
205 | * to a PC. | 211 | * across one during the boot process as it probes for various things which are |
212 | * usually attached to a PC. | ||
206 | * | 213 | * |
207 | * When the Guest uses one of these instructions, we get trap #13 (General | 214 | * When the Guest uses one of these instructions, we get a trap (General |
208 | * Protection Fault) and come here. We see if it's one of those troublesome | 215 | * Protection Fault) and come here. We see if it's one of those troublesome |
209 | * instructions and skip over it. We return true if we did. */ | 216 | * instructions and skip over it. We return true if we did. */ |
210 | static int emulate_insn(struct lguest *lg) | 217 | static int emulate_insn(struct lguest *lg) |
@@ -275,43 +282,43 @@ static int emulate_insn(struct lguest *lg) | |||
275 | void lguest_arch_handle_trap(struct lguest *lg) | 282 | void lguest_arch_handle_trap(struct lguest *lg) |
276 | { | 283 | { |
277 | switch (lg->regs->trapnum) { | 284 | switch (lg->regs->trapnum) { |
278 | case 13: /* We've intercepted a GPF. */ | 285 | case 13: /* We've intercepted a General Protection Fault. */ |
279 | /* Check if this was one of those annoying IN or OUT | 286 | /* Check if this was one of those annoying IN or OUT |
280 | * instructions which we need to emulate. If so, we | 287 | * instructions which we need to emulate. If so, we just go |
281 | * just go back into the Guest after we've done it. */ | 288 | * back into the Guest after we've done it. */ |
282 | if (lg->regs->errcode == 0) { | 289 | if (lg->regs->errcode == 0) { |
283 | if (emulate_insn(lg)) | 290 | if (emulate_insn(lg)) |
284 | return; | 291 | return; |
285 | } | 292 | } |
286 | break; | 293 | break; |
287 | case 14: /* We've intercepted a page fault. */ | 294 | case 14: /* We've intercepted a Page Fault. */ |
288 | /* The Guest accessed a virtual address that wasn't | 295 | /* The Guest accessed a virtual address that wasn't mapped. |
289 | * mapped. This happens a lot: we don't actually set | 296 | * This happens a lot: we don't actually set up most of the |
290 | * up most of the page tables for the Guest at all when | 297 | * page tables for the Guest at all when we start: as it runs |
291 | * we start: as it runs it asks for more and more, and | 298 | * it asks for more and more, and we set them up as |
292 | * we set them up as required. In this case, we don't | 299 | * required. In this case, we don't even tell the Guest that |
293 | * even tell the Guest that the fault happened. | 300 | * the fault happened. |
294 | * | 301 | * |
295 | * The errcode tells whether this was a read or a | 302 | * The errcode tells whether this was a read or a write, and |
296 | * write, and whether kernel or userspace code. */ | 303 | * whether kernel or userspace code. */ |
297 | if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode)) | 304 | if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode)) |
298 | return; | 305 | return; |
299 | 306 | ||
300 | /* OK, it's really not there (or not OK): the Guest | 307 | /* OK, it's really not there (or not OK): the Guest needs to |
301 | * needs to know. We write out the cr2 value so it | 308 | * know. We write out the cr2 value so it knows where the |
302 | * knows where the fault occurred. | 309 | * fault occurred. |
303 | * | 310 | * |
304 | * Note that if the Guest were really messed up, this | 311 | * Note that if the Guest were really messed up, this could |
305 | * could happen before it's done the INITIALIZE | 312 | * happen before it's done the LHCALL_LGUEST_INIT hypercall, so |
306 | * hypercall, so lg->lguest_data will be NULL */ | 313 | * lg->lguest_data could be NULL */ |
307 | if (lg->lguest_data && | 314 | if (lg->lguest_data && |
308 | put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) | 315 | put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) |
309 | kill_guest(lg, "Writing cr2"); | 316 | kill_guest(lg, "Writing cr2"); |
310 | break; | 317 | break; |
311 | case 7: /* We've intercepted a Device Not Available fault. */ | 318 | case 7: /* We've intercepted a Device Not Available fault. */ |
312 | /* If the Guest doesn't want to know, we already | 319 | /* If the Guest doesn't want to know, we already restored the |
313 | * restored the Floating Point Unit, so we just | 320 | * Floating Point Unit, so we just continue without telling |
314 | * continue without telling it. */ | 321 | * it. */ |
315 | if (!lg->ts) | 322 | if (!lg->ts) |
316 | return; | 323 | return; |
317 | break; | 324 | break; |
@@ -536,9 +543,6 @@ int lguest_arch_init_hypercalls(struct lguest *lg) | |||
536 | 543 | ||
537 | return 0; | 544 | return 0; |
538 | } | 545 | } |
539 | /* Now we've examined the hypercall code; our Guest can make requests. There | ||
540 | * is one other way we can do things for the Guest, as we see in | ||
541 | * emulate_insn(). :*/ | ||
542 | 546 | ||
543 | /*L:030 lguest_arch_setup_regs() | 547 | /*L:030 lguest_arch_setup_regs() |
544 | * | 548 | * |
@@ -562,7 +566,7 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) | |||
562 | * is supposed to always be "1". Bit 9 (0x200) controls whether | 566 | * is supposed to always be "1". Bit 9 (0x200) controls whether |
563 | * interrupts are enabled. We always leave interrupts enabled while | 567 | * interrupts are enabled. We always leave interrupts enabled while |
564 | * running the Guest. */ | 568 | * running the Guest. */ |
565 | regs->eflags = 0x202; | 569 | regs->eflags = X86_EFLAGS_IF | 0x2; |
566 | 570 | ||
567 | /* The "Extended Instruction Pointer" register says where the Guest is | 571 | /* The "Extended Instruction Pointer" register says where the Guest is |
568 | * running. */ | 572 | * running. */ |
@@ -570,8 +574,8 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) | |||
570 | 574 | ||
571 | /* %esi points to our boot information, at physical address 0, so don't | 575 | /* %esi points to our boot information, at physical address 0, so don't |
572 | * touch it. */ | 576 | * touch it. */ |
577 | |||
573 | /* There are a couple of GDT entries the Guest expects when first | 578 | /* There are a couple of GDT entries the Guest expects when first |
574 | * booting. */ | 579 | * booting. */ |
575 | |||
576 | setup_guest_gdt(lg); | 580 | setup_guest_gdt(lg); |
577 | } | 581 | } |
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S index 1010b90b11..0af8baaa0d 100644 --- a/drivers/lguest/x86/switcher_32.S +++ b/drivers/lguest/x86/switcher_32.S | |||
@@ -6,6 +6,37 @@ | |||
6 | * are feeling invigorated and refreshed then the next, more challenging stage | 6 | * are feeling invigorated and refreshed then the next, more challenging stage |
7 | * can be found in "make Guest". :*/ | 7 | * can be found in "make Guest". :*/ |
8 | 8 | ||
9 | /*M:012 Lguest is meant to be simple: my rule of thumb is that 1% more LOC must | ||
10 | * gain at least 1% more performance. Since neither LOC nor performance can be | ||
11 | * measured beforehand, it generally means implementing a feature then deciding | ||
12 | * if it's worth it. And once it's implemented, who can say no? | ||
13 | * | ||
14 | * This is why I haven't implemented this idea myself. I want to, but I | ||
15 | * haven't. You could, though. | ||
16 | * | ||
17 | * The main place where lguest performance sucks is Guest page faulting. When | ||
18 | * a Guest userspace process hits an unmapped page we switch back to the Host, | ||
19 | * walk the page tables, find it's not mapped, switch back to the Guest page | ||
20 | * fault handler, which calls a hypercall to set the page table entry, then | ||
21 | * finally returns to userspace. That's two round-trips. | ||
22 | * | ||
23 | * If we had a small walker in the Switcher, we could quickly check the Guest | ||
24 | * page table and if the page isn't mapped, immediately reflect the fault back | ||
25 | * into the Guest. This means the Switcher would have to know the top of the | ||
26 | * Guest page table and the page fault handler address. | ||
27 | * | ||
28 | * For simplicity, the Guest should only handle the case where the privilege | ||
29 | * level of the fault is 3 and probably only not present or write faults. It | ||
30 | * should also detect recursive faults, and hand the original fault to the | ||
31 | * Host (which is actually really easy). | ||
32 | * | ||
33 | * Two questions remain. Would the performance gain outweigh the complexity? | ||
34 | * And who would write the verse documenting it? :*/ | ||
35 | |||
36 | /*M:011 Lguest64 handles NMI. This gave me NMI envy (until I looked at their | ||
37 | * code). It's worth doing though, since it would let us use oprofile in the | ||
38 | * Host when a Guest is running. :*/ | ||
39 | |||
9 | /*S:100 | 40 | /*S:100 |
10 | * Welcome to the Switcher itself! | 41 | * Welcome to the Switcher itself! |
11 | * | 42 | * |
@@ -88,7 +119,7 @@ ENTRY(switch_to_guest) | |||
88 | 119 | ||
89 | // All saved and there's now five steps before us: | 120 | // All saved and there's now five steps before us: |
90 | // Stack, GDT, IDT, TSS | 121 | // Stack, GDT, IDT, TSS |
91 | // And last of all the page tables are flipped. | 122 | // Then last of all the page tables are flipped. |
92 | 123 | ||
93 | // Yet beware that our stack pointer must be | 124 | // Yet beware that our stack pointer must be |
94 | // Always valid lest an NMI hits | 125 | // Always valid lest an NMI hits |
@@ -103,25 +134,25 @@ ENTRY(switch_to_guest) | |||
103 | lgdt LGUEST_PAGES_guest_gdt_desc(%eax) | 134 | lgdt LGUEST_PAGES_guest_gdt_desc(%eax) |
104 | 135 | ||
105 | // The Guest's IDT we did partially | 136 | // The Guest's IDT we did partially |
106 | // Move to the "struct lguest_pages" as well. | 137 | // Copy to "struct lguest_pages" as well. |
107 | lidt LGUEST_PAGES_guest_idt_desc(%eax) | 138 | lidt LGUEST_PAGES_guest_idt_desc(%eax) |
108 | 139 | ||
109 | // The TSS entry which controls traps | 140 | // The TSS entry which controls traps |
110 | // Must be loaded up with "ltr" now: | 141 | // Must be loaded up with "ltr" now: |
142 | // The GDT entry that TSS uses | ||
143 | // Changes type when we load it: damn Intel! | ||
111 | // For after we switch over our page tables | 144 | // For after we switch over our page tables |
112 | // It (as the rest) will be writable no more. | 145 | // That entry will be read-only: we'd crash. |
113 | // (The GDT entry TSS needs | ||
114 | // Changes type when we load it: damn Intel!) | ||
115 | movl $(GDT_ENTRY_TSS*8), %edx | 146 | movl $(GDT_ENTRY_TSS*8), %edx |
116 | ltr %dx | 147 | ltr %dx |
117 | 148 | ||
118 | // Look back now, before we take this last step! | 149 | // Look back now, before we take this last step! |
119 | // The Host's TSS entry was also marked used; | 150 | // The Host's TSS entry was also marked used; |
120 | // Let's clear it again, ere we return. | 151 | // Let's clear it again for our return. |
121 | // The GDT descriptor of the Host | 152 | // The GDT descriptor of the Host |
122 | // Points to the table after two "size" bytes | 153 | // Points to the table after two "size" bytes |
123 | movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx | 154 | movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx |
124 | // Clear the type field of "used" (byte 5, bit 2) | 155 | // Clear "used" from type field (byte 5, bit 2) |
125 | andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) | 156 | andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) |
126 | 157 | ||
127 | // Once our page table's switched, the Guest is live! | 158 | // Once our page table's switched, the Guest is live! |
@@ -131,7 +162,7 @@ ENTRY(switch_to_guest) | |||
131 | 162 | ||
132 | // The page table change did one tricky thing: | 163 | // The page table change did one tricky thing: |
133 | // The Guest's register page has been mapped | 164 | // The Guest's register page has been mapped |
134 | // Writable onto our %esp (stack) -- | 165 | // Writable under our %esp (stack) -- |
135 | // We can simply pop off all Guest regs. | 166 | // We can simply pop off all Guest regs. |
136 | popl %eax | 167 | popl %eax |
137 | popl %ebx | 168 | popl %ebx |
@@ -152,16 +183,15 @@ ENTRY(switch_to_guest) | |||
152 | addl $8, %esp | 183 | addl $8, %esp |
153 | 184 | ||
154 | // The last five stack slots hold return address | 185 | // The last five stack slots hold return address |
155 | // And everything needed to change privilege | 186 | // And everything needed to switch privilege |
156 | // Into the Guest privilege level of 1, | 187 | // From Switcher's level 0 to Guest's 1, |
157 | // And the stack where the Guest had last left it. | 188 | // And the stack where the Guest had last left it. |
158 | // Interrupts are turned back on: we are Guest. | 189 | // Interrupts are turned back on: we are Guest. |
159 | iret | 190 | iret |
160 | 191 | ||
161 | // There are two paths where we switch to the Host | 192 | // We treat two paths to switch back to the Host |
193 | // Yet both must save Guest state and restore Host | ||
162 | // So we put the routine in a macro. | 194 | // So we put the routine in a macro. |
163 | // We are on our way home, back to the Host | ||
164 | // Interrupted out of the Guest, we come here. | ||
165 | #define SWITCH_TO_HOST \ | 195 | #define SWITCH_TO_HOST \ |
166 | /* We save the Guest state: all registers first \ | 196 | /* We save the Guest state: all registers first \ |
167 | * Laid out just as "struct lguest_regs" defines */ \ | 197 | * Laid out just as "struct lguest_regs" defines */ \ |
@@ -194,7 +224,7 @@ ENTRY(switch_to_guest) | |||
194 | movl %esp, %eax; \ | 224 | movl %esp, %eax; \ |
195 | andl $(~(1 << PAGE_SHIFT - 1)), %eax; \ | 225 | andl $(~(1 << PAGE_SHIFT - 1)), %eax; \ |
196 | /* Save our trap number: the switch will obscure it \ | 226 | /* Save our trap number: the switch will obscure it \ |
197 | * (The Guest regs are not mapped here in the Host) \ | 227 | * (In the Host the Guest regs are not mapped here) \ |
198 | * %ebx holds it safe for deliver_to_host */ \ | 228 | * %ebx holds it safe for deliver_to_host */ \ |
199 | movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ | 229 | movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ |
200 | /* The Host GDT, IDT and stack! \ | 230 | /* The Host GDT, IDT and stack! \ |
@@ -210,9 +240,9 @@ ENTRY(switch_to_guest) | |||
210 | /* Switch to Host's GDT, IDT. */ \ | 240 | /* Switch to Host's GDT, IDT. */ \ |
211 | lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ | 241 | lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ |
212 | lidt LGUEST_PAGES_host_idt_desc(%eax); \ | 242 | lidt LGUEST_PAGES_host_idt_desc(%eax); \ |
213 | /* Restore the Host's stack where it's saved regs lie */ \ | 243 | /* Restore the Host's stack where its saved regs lie */ \ |
214 | movl LGUEST_PAGES_host_sp(%eax), %esp; \ | 244 | movl LGUEST_PAGES_host_sp(%eax), %esp; \ |
215 | /* Last the TSS: our Host is complete */ \ | 245 | /* Last the TSS: our Host is returned */ \ |
216 | movl $(GDT_ENTRY_TSS*8), %edx; \ | 246 | movl $(GDT_ENTRY_TSS*8), %edx; \ |
217 | ltr %dx; \ | 247 | ltr %dx; \ |
218 | /* Restore now the regs saved right at the first. */ \ | 248 | /* Restore now the regs saved right at the first. */ \ |
@@ -222,14 +252,15 @@ ENTRY(switch_to_guest) | |||
222 | popl %ds; \ | 252 | popl %ds; \ |
223 | popl %es | 253 | popl %es |
224 | 254 | ||
225 | // Here's where we come when the Guest has just trapped: | 255 | // The first path is trod when the Guest has trapped: |
226 | // (Which trap we'll see has been pushed on the stack). | 256 | // (Which trap it was has been pushed on the stack). |
227 | // We need only switch back, and the Host will decode | 257 | // We need only switch back, and the Host will decode |
228 | // Why we came home, and what needs to be done. | 258 | // Why we came home, and what needs to be done. |
229 | return_to_host: | 259 | return_to_host: |
230 | SWITCH_TO_HOST | 260 | SWITCH_TO_HOST |
231 | iret | 261 | iret |
232 | 262 | ||
263 | // We are lead to the second path like so: | ||
233 | // An interrupt, with some cause external | 264 | // An interrupt, with some cause external |
234 | // Has ajerked us rudely from the Guest's code | 265 | // Has ajerked us rudely from the Guest's code |
235 | // Again we must return home to the Host | 266 | // Again we must return home to the Host |
@@ -238,7 +269,7 @@ deliver_to_host: | |||
238 | // But now we must go home via that place | 269 | // But now we must go home via that place |
239 | // Where that interrupt was supposed to go | 270 | // Where that interrupt was supposed to go |
240 | // Had we not been ensconced, running the Guest. | 271 | // Had we not been ensconced, running the Guest. |
241 | // Here we see the cleverness of our stack: | 272 | // Here we see the trickness of run_guest_once(): |
242 | // The Host stack is formed like an interrupt | 273 | // The Host stack is formed like an interrupt |
243 | // With EIP, CS and EFLAGS layered. | 274 | // With EIP, CS and EFLAGS layered. |
244 | // Interrupt handlers end with "iret" | 275 | // Interrupt handlers end with "iret" |
@@ -263,7 +294,7 @@ deliver_to_host: | |||
263 | xorw %ax, %ax | 294 | xorw %ax, %ax |
264 | orl %eax, %edx | 295 | orl %eax, %edx |
265 | // Now the address of the handler's in %edx | 296 | // Now the address of the handler's in %edx |
266 | // We call it now: its "iret" takes us home. | 297 | // We call it now: its "iret" drops us home. |
267 | jmp *%edx | 298 | jmp *%edx |
268 | 299 | ||
269 | // Every interrupt can come to us here | 300 | // Every interrupt can come to us here |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index ac54f697c5..28c6ae095c 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -168,7 +168,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | |||
168 | return -ENOMEM; | 168 | return -ENOMEM; |
169 | } | 169 | } |
170 | 170 | ||
171 | sg_set_buf(&sg, cc->key, cc->key_size); | 171 | sg_init_one(&sg, cc->key, cc->key_size); |
172 | desc.tfm = hash_tfm; | 172 | desc.tfm = hash_tfm; |
173 | desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 173 | desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; |
174 | err = crypto_hash_digest(&desc, &sg, cc->key_size, salt); | 174 | err = crypto_hash_digest(&desc, &sg, cc->key_size, salt); |
@@ -351,14 +351,10 @@ static int crypt_convert(struct crypt_config *cc, | |||
351 | struct scatterlist sg_in, sg_out; | 351 | struct scatterlist sg_in, sg_out; |
352 | 352 | ||
353 | sg_init_table(&sg_in, 1); | 353 | sg_init_table(&sg_in, 1); |
354 | sg_set_page(&sg_in, bv_in->bv_page); | 354 | sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in); |
355 | sg_in.offset = bv_in->bv_offset + ctx->offset_in; | ||
356 | sg_in.length = 1 << SECTOR_SHIFT; | ||
357 | 355 | ||
358 | sg_init_table(&sg_out, 1); | 356 | sg_init_table(&sg_out, 1); |
359 | sg_set_page(&sg_out, bv_out->bv_page); | 357 | sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out); |
360 | sg_out.offset = bv_out->bv_offset + ctx->offset_out; | ||
361 | sg_out.length = 1 << SECTOR_SHIFT; | ||
362 | 358 | ||
363 | ctx->offset_in += sg_in.length; | 359 | ctx->offset_in += sg_in.length; |
364 | if (ctx->offset_in >= bv_in->bv_len) { | 360 | if (ctx->offset_in >= bv_in->bv_len) { |
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 2b1f8b4be0..cb034ead95 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -118,8 +118,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
118 | if (NULL == pg) | 118 | if (NULL == pg) |
119 | goto err; | 119 | goto err; |
120 | BUG_ON(PageHighMem(pg)); | 120 | BUG_ON(PageHighMem(pg)); |
121 | sg_set_page(&sglist[i], pg); | 121 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
122 | sglist[i].length = PAGE_SIZE; | ||
123 | } | 122 | } |
124 | return sglist; | 123 | return sglist; |
125 | 124 | ||
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index 912b424e52..460db03b0b 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c | |||
@@ -49,8 +49,6 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
49 | unsigned int len = (i == dma_page->page_count - 1) ? | 49 | unsigned int len = (i == dma_page->page_count - 1) ? |
50 | dma_page->tail : PAGE_SIZE - offset; | 50 | dma_page->tail : PAGE_SIZE - offset; |
51 | 51 | ||
52 | dma->SGlist[map_offset].length = len; | ||
53 | dma->SGlist[map_offset].offset = offset; | ||
54 | if (PageHighMem(dma->map[map_offset])) { | 52 | if (PageHighMem(dma->map[map_offset])) { |
55 | void *src; | 53 | void *src; |
56 | 54 | ||
@@ -63,10 +61,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
63 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); | 61 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); |
64 | kunmap_atomic(src, KM_BOUNCE_READ); | 62 | kunmap_atomic(src, KM_BOUNCE_READ); |
65 | local_irq_restore(flags); | 63 | local_irq_restore(flags); |
66 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); | 64 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset); |
67 | } | 65 | } |
68 | else { | 66 | else { |
69 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); | 67 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset); |
70 | } | 68 | } |
71 | offset = 0; | 69 | offset = 0; |
72 | map_offset++; | 70 | map_offset++; |
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 9ab94a749d..44ee408e14 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -67,8 +67,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
67 | if (NULL == pg) | 67 | if (NULL == pg) |
68 | goto err; | 68 | goto err; |
69 | BUG_ON(PageHighMem(pg)); | 69 | BUG_ON(PageHighMem(pg)); |
70 | sg_set_page(&sglist[i], pg); | 70 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
71 | sglist[i].length = PAGE_SIZE; | ||
72 | } | 71 | } |
73 | return sglist; | 72 | return sglist; |
74 | 73 | ||
@@ -95,16 +94,13 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
95 | if (PageHighMem(pages[0])) | 94 | if (PageHighMem(pages[0])) |
96 | /* DMA to highmem pages might not work */ | 95 | /* DMA to highmem pages might not work */ |
97 | goto highmem; | 96 | goto highmem; |
98 | sg_set_page(&sglist[0], pages[0]); | 97 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); |
99 | sglist[0].offset = offset; | ||
100 | sglist[0].length = PAGE_SIZE - offset; | ||
101 | for (i = 1; i < nr_pages; i++) { | 98 | for (i = 1; i < nr_pages; i++) { |
102 | if (NULL == pages[i]) | 99 | if (NULL == pages[i]) |
103 | goto nopage; | 100 | goto nopage; |
104 | if (PageHighMem(pages[i])) | 101 | if (PageHighMem(pages[i])) |
105 | goto highmem; | 102 | goto highmem; |
106 | sg_set_page(&sglist[i], pages[i]); | 103 | sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0); |
107 | sglist[i].length = PAGE_SIZE; | ||
108 | } | 104 | } |
109 | return sglist; | 105 | return sglist; |
110 | 106 | ||
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index d602ba6d54..682406168d 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -284,6 +284,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void) | |||
284 | return ERR_PTR(-ENOMEM); | 284 | return ERR_PTR(-ENOMEM); |
285 | 285 | ||
286 | INIT_LIST_HEAD(&ireq->queue); | 286 | INIT_LIST_HEAD(&ireq->queue); |
287 | sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS); | ||
287 | 288 | ||
288 | return ireq; | 289 | return ireq; |
289 | }; | 290 | }; |
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index bf4bc6adcf..7471d49909 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -267,15 +267,26 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, | |||
267 | 267 | ||
268 | int mmc_send_csd(struct mmc_card *card, u32 *csd) | 268 | int mmc_send_csd(struct mmc_card *card, u32 *csd) |
269 | { | 269 | { |
270 | int ret, i; | ||
271 | |||
270 | if (!mmc_host_is_spi(card->host)) | 272 | if (!mmc_host_is_spi(card->host)) |
271 | return mmc_send_cxd_native(card->host, card->rca << 16, | 273 | return mmc_send_cxd_native(card->host, card->rca << 16, |
272 | csd, MMC_SEND_CSD); | 274 | csd, MMC_SEND_CSD); |
273 | 275 | ||
274 | return mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); | 276 | ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); |
277 | if (ret) | ||
278 | return ret; | ||
279 | |||
280 | for (i = 0;i < 4;i++) | ||
281 | csd[i] = be32_to_cpu(csd[i]); | ||
282 | |||
283 | return 0; | ||
275 | } | 284 | } |
276 | 285 | ||
277 | int mmc_send_cid(struct mmc_host *host, u32 *cid) | 286 | int mmc_send_cid(struct mmc_host *host, u32 *cid) |
278 | { | 287 | { |
288 | int ret, i; | ||
289 | |||
279 | if (!mmc_host_is_spi(host)) { | 290 | if (!mmc_host_is_spi(host)) { |
280 | if (!host->card) | 291 | if (!host->card) |
281 | return -EINVAL; | 292 | return -EINVAL; |
@@ -283,7 +294,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) | |||
283 | cid, MMC_SEND_CID); | 294 | cid, MMC_SEND_CID); |
284 | } | 295 | } |
285 | 296 | ||
286 | return mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); | 297 | ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); |
298 | if (ret) | ||
299 | return ret; | ||
300 | |||
301 | for (i = 0;i < 4;i++) | ||
302 | cid[i] = be32_to_cpu(cid[i]); | ||
303 | |||
304 | return 0; | ||
287 | } | 305 | } |
288 | 306 | ||
289 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) | 307 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) |
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index ee4029a24e..a6dafe62b9 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
@@ -294,8 +294,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
294 | if (data.error) | 294 | if (data.error) |
295 | return data.error; | 295 | return data.error; |
296 | 296 | ||
297 | scr[0] = ntohl(scr[0]); | 297 | scr[0] = be32_to_cpu(scr[0]); |
298 | scr[1] = ntohl(scr[1]); | 298 | scr[1] = be32_to_cpu(scr[1]); |
299 | 299 | ||
300 | return 0; | 300 | return 0; |
301 | } | 301 | } |
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index bcbb6d247b..c3926eb3bf 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -40,13 +40,13 @@ | |||
40 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
43 | #include <linux/scatterlist.h> | ||
43 | 44 | ||
44 | #include <linux/mmc/host.h> | 45 | #include <linux/mmc/host.h> |
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include <asm/mach-au1x00/au1000.h> | 47 | #include <asm/mach-au1x00/au1000.h> |
47 | #include <asm/mach-au1x00/au1xxx_dbdma.h> | 48 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
48 | #include <asm/mach-au1x00/au1100_mmc.h> | 49 | #include <asm/mach-au1x00/au1100_mmc.h> |
49 | #include <asm/scatterlist.h> | ||
50 | 50 | ||
51 | #include <au1xxx.h> | 51 | #include <au1xxx.h> |
52 | #include "au1xmmc.h" | 52 | #include "au1xmmc.h" |
@@ -212,12 +212,12 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, | |||
212 | } | 212 | } |
213 | 213 | ||
214 | if (data) { | 214 | if (data) { |
215 | if (flags & MMC_DATA_READ) { | 215 | if (data->flags & MMC_DATA_READ) { |
216 | if (data->blocks > 1) | 216 | if (data->blocks > 1) |
217 | mmccmd |= SD_CMD_CT_4; | 217 | mmccmd |= SD_CMD_CT_4; |
218 | else | 218 | else |
219 | mmccmd |= SD_CMD_CT_2; | 219 | mmccmd |= SD_CMD_CT_2; |
220 | } else if (flags & MMC_DATA_WRITE) { | 220 | } else if (data->flags & MMC_DATA_WRITE) { |
221 | if (data->blocks > 1) | 221 | if (data->blocks > 1) |
222 | mmccmd |= SD_CMD_CT_3; | 222 | mmccmd |= SD_CMD_CT_3; |
223 | else | 223 | else |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 12c2d807c1..a6469218f1 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1165,6 +1165,23 @@ mmc_spi_detect_irq(int irq, void *mmc) | |||
1165 | return IRQ_HANDLED; | 1165 | return IRQ_HANDLED; |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | struct count_children { | ||
1169 | unsigned n; | ||
1170 | struct bus_type *bus; | ||
1171 | }; | ||
1172 | |||
1173 | static int maybe_count_child(struct device *dev, void *c) | ||
1174 | { | ||
1175 | struct count_children *ccp = c; | ||
1176 | |||
1177 | if (dev->bus == ccp->bus) { | ||
1178 | if (ccp->n) | ||
1179 | return -EBUSY; | ||
1180 | ccp->n++; | ||
1181 | } | ||
1182 | return 0; | ||
1183 | } | ||
1184 | |||
1168 | static int mmc_spi_probe(struct spi_device *spi) | 1185 | static int mmc_spi_probe(struct spi_device *spi) |
1169 | { | 1186 | { |
1170 | void *ones; | 1187 | void *ones; |
@@ -1188,33 +1205,30 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1188 | return status; | 1205 | return status; |
1189 | } | 1206 | } |
1190 | 1207 | ||
1191 | /* We can use the bus safely iff nobody else will interfere with | 1208 | /* We can use the bus safely iff nobody else will interfere with us. |
1192 | * us. That is, either we have the experimental exclusive access | 1209 | * Most commands consist of one SPI message to issue a command, then |
1193 | * primitives ... or else there's nobody to share it with. | 1210 | * several more to collect its response, then possibly more for data |
1211 | * transfer. Clocking access to other devices during that period will | ||
1212 | * corrupt the command execution. | ||
1213 | * | ||
1214 | * Until we have software primitives which guarantee non-interference, | ||
1215 | * we'll aim for a hardware-level guarantee. | ||
1216 | * | ||
1217 | * REVISIT we can't guarantee another device won't be added later... | ||
1194 | */ | 1218 | */ |
1195 | if (spi->master->num_chipselect > 1) { | 1219 | if (spi->master->num_chipselect > 1) { |
1196 | struct device *parent = spi->dev.parent; | 1220 | struct count_children cc; |
1197 | 1221 | ||
1198 | /* If there are multiple devices on this bus, we | 1222 | cc.n = 0; |
1199 | * can't proceed. | 1223 | cc.bus = spi->dev.bus; |
1200 | */ | 1224 | status = device_for_each_child(spi->dev.parent, &cc, |
1201 | spin_lock(&parent->klist_children.k_lock); | 1225 | maybe_count_child); |
1202 | if (parent->klist_children.k_list.next | ||
1203 | != parent->klist_children.k_list.prev) | ||
1204 | status = -EMLINK; | ||
1205 | else | ||
1206 | status = 0; | ||
1207 | spin_unlock(&parent->klist_children.k_lock); | ||
1208 | if (status < 0) { | 1226 | if (status < 0) { |
1209 | dev_err(&spi->dev, "can't share SPI bus\n"); | 1227 | dev_err(&spi->dev, "can't share SPI bus\n"); |
1210 | return status; | 1228 | return status; |
1211 | } | 1229 | } |
1212 | 1230 | ||
1213 | /* REVISIT we can't guarantee another device won't | 1231 | dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n"); |
1214 | * be added later. It's uncommon though ... for now, | ||
1215 | * work as if this is safe. | ||
1216 | */ | ||
1217 | dev_warn(&spi->dev, "ASSUMING unshared SPI bus!\n"); | ||
1218 | } | 1232 | } |
1219 | 1233 | ||
1220 | /* We need a supply of ones to transmit. This is the only time | 1234 | /* We need a supply of ones to transmit. This is the only time |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index d0eb0a2abf..95244a7e73 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -20,11 +20,11 @@ | |||
20 | #include <linux/mmc/host.h> | 20 | #include <linux/mmc/host.h> |
21 | #include <linux/amba/bus.h> | 21 | #include <linux/amba/bus.h> |
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/scatterlist.h> | ||
23 | 24 | ||
24 | #include <asm/cacheflush.h> | 25 | #include <asm/cacheflush.h> |
25 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <asm/scatterlist.h> | ||
28 | #include <asm/sizes.h> | 28 | #include <asm/sizes.h> |
29 | #include <asm/mach/mmc.h> | 29 | #include <asm/mach/mmc.h> |
30 | 30 | ||
@@ -167,7 +167,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, | |||
167 | * partially written to a page is properly coherent. | 167 | * partially written to a page is properly coherent. |
168 | */ | 168 | */ |
169 | if (host->sg_len && data->flags & MMC_DATA_READ) | 169 | if (host->sg_len && data->flags & MMC_DATA_READ) |
170 | flush_dcache_page(host->sg_ptr->page); | 170 | flush_dcache_page(sg_page(host->sg_ptr)); |
171 | } | 171 | } |
172 | if (status & MCI_DATAEND) { | 172 | if (status & MCI_DATAEND) { |
173 | mmci_stop_data(host); | 173 | mmci_stop_data(host); |
@@ -319,7 +319,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) | |||
319 | * page, ensure that the data cache is coherent. | 319 | * page, ensure that the data cache is coherent. |
320 | */ | 320 | */ |
321 | if (status & MCI_RXACTIVE) | 321 | if (status & MCI_RXACTIVE) |
322 | flush_dcache_page(host->sg_ptr->page); | 322 | flush_dcache_page(sg_page(host->sg_ptr)); |
323 | 323 | ||
324 | if (!mmci_next_sg(host)) | 324 | if (!mmci_next_sg(host)) |
325 | break; | 325 | break; |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 0601e01aa2..a25ee71998 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <asm/dma.h> | 30 | #include <asm/dma.h> |
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
32 | #include <asm/scatterlist.h> | ||
33 | #include <asm/sizes.h> | 32 | #include <asm/sizes.h> |
34 | 33 | ||
35 | #include <asm/arch/pxa-regs.h> | 34 | #include <asm/arch/pxa-regs.h> |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d7c5b94d8c..6b80bf77a4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -17,8 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/mmc/host.h> | 18 | #include <linux/mmc/host.h> |
19 | 19 | ||
20 | #include <asm/scatterlist.h> | ||
21 | |||
22 | #include "sdhci.h" | 20 | #include "sdhci.h" |
23 | 21 | ||
24 | #define DRIVER_NAME "sdhci" | 22 | #define DRIVER_NAME "sdhci" |
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index fa4c8c53cc..4d5f374218 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c | |||
@@ -33,10 +33,10 @@ | |||
33 | #include <linux/pnp.h> | 33 | #include <linux/pnp.h> |
34 | #include <linux/highmem.h> | 34 | #include <linux/highmem.h> |
35 | #include <linux/mmc/host.h> | 35 | #include <linux/mmc/host.h> |
36 | #include <linux/scatterlist.h> | ||
36 | 37 | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | #include <asm/dma.h> | 39 | #include <asm/dma.h> |
39 | #include <asm/scatterlist.h> | ||
40 | 40 | ||
41 | #include "wbsd.h" | 41 | #include "wbsd.h" |
42 | 42 | ||
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index d2499bb07c..473f78de4b 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -122,7 +122,8 @@ struct e1000_buffer { | |||
122 | u16 next_to_watch; | 122 | u16 next_to_watch; |
123 | }; | 123 | }; |
124 | /* RX */ | 124 | /* RX */ |
125 | struct page *page; | 125 | /* arrays of page information for packet split */ |
126 | struct e1000_ps_page *ps_pages; | ||
126 | }; | 127 | }; |
127 | 128 | ||
128 | }; | 129 | }; |
@@ -142,8 +143,6 @@ struct e1000_ring { | |||
142 | /* array of buffer information structs */ | 143 | /* array of buffer information structs */ |
143 | struct e1000_buffer *buffer_info; | 144 | struct e1000_buffer *buffer_info; |
144 | 145 | ||
145 | /* arrays of page information for packet split */ | ||
146 | struct e1000_ps_page *ps_pages; | ||
147 | struct sk_buff *rx_skb_top; | 146 | struct sk_buff *rx_skb_top; |
148 | 147 | ||
149 | struct e1000_queue_stats stats; | 148 | struct e1000_queue_stats stats; |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 033e124d1c..4fd2e23720 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -245,37 +245,36 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, | |||
245 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); | 245 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); |
246 | 246 | ||
247 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { | 247 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { |
248 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) | 248 | ps_page = &buffer_info->ps_pages[j]; |
249 | + j]; | 249 | if (j >= adapter->rx_ps_pages) { |
250 | if (j < adapter->rx_ps_pages) { | 250 | /* all unused desc entries get hw null ptr */ |
251 | rx_desc->read.buffer_addr[j+1] = ~0; | ||
252 | continue; | ||
253 | } | ||
254 | if (!ps_page->page) { | ||
255 | ps_page->page = alloc_page(GFP_ATOMIC); | ||
251 | if (!ps_page->page) { | 256 | if (!ps_page->page) { |
252 | ps_page->page = alloc_page(GFP_ATOMIC); | 257 | adapter->alloc_rx_buff_failed++; |
253 | if (!ps_page->page) { | 258 | goto no_buffers; |
254 | adapter->alloc_rx_buff_failed++; | 259 | } |
255 | goto no_buffers; | 260 | ps_page->dma = pci_map_page(pdev, |
256 | } | 261 | ps_page->page, |
257 | ps_page->dma = pci_map_page(pdev, | 262 | 0, PAGE_SIZE, |
258 | ps_page->page, | 263 | PCI_DMA_FROMDEVICE); |
259 | 0, PAGE_SIZE, | 264 | if (pci_dma_mapping_error(ps_page->dma)) { |
260 | PCI_DMA_FROMDEVICE); | 265 | dev_err(&adapter->pdev->dev, |
261 | if (pci_dma_mapping_error( | 266 | "RX DMA page map failed\n"); |
262 | ps_page->dma)) { | 267 | adapter->rx_dma_failed++; |
263 | dev_err(&adapter->pdev->dev, | 268 | goto no_buffers; |
264 | "RX DMA page map failed\n"); | ||
265 | adapter->rx_dma_failed++; | ||
266 | goto no_buffers; | ||
267 | } | ||
268 | } | 269 | } |
269 | /* | ||
270 | * Refresh the desc even if buffer_addrs | ||
271 | * didn't change because each write-back | ||
272 | * erases this info. | ||
273 | */ | ||
274 | rx_desc->read.buffer_addr[j+1] = | ||
275 | cpu_to_le64(ps_page->dma); | ||
276 | } else { | ||
277 | rx_desc->read.buffer_addr[j+1] = ~0; | ||
278 | } | 270 | } |
271 | /* | ||
272 | * Refresh the desc even if buffer_addrs | ||
273 | * didn't change because each write-back | ||
274 | * erases this info. | ||
275 | */ | ||
276 | rx_desc->read.buffer_addr[j+1] = | ||
277 | cpu_to_le64(ps_page->dma); | ||
279 | } | 278 | } |
280 | 279 | ||
281 | skb = netdev_alloc_skb(netdev, | 280 | skb = netdev_alloc_skb(netdev, |
@@ -334,94 +333,6 @@ no_buffers: | |||
334 | } | 333 | } |
335 | 334 | ||
336 | /** | 335 | /** |
337 | * e1000_alloc_rx_buffers_jumbo - Replace used jumbo receive buffers | ||
338 | * | ||
339 | * @adapter: address of board private structure | ||
340 | * @cleaned_count: number of buffers to allocate this pass | ||
341 | **/ | ||
342 | static void e1000_alloc_rx_buffers_jumbo(struct e1000_adapter *adapter, | ||
343 | int cleaned_count) | ||
344 | { | ||
345 | struct net_device *netdev = adapter->netdev; | ||
346 | struct pci_dev *pdev = adapter->pdev; | ||
347 | struct e1000_ring *rx_ring = adapter->rx_ring; | ||
348 | struct e1000_rx_desc *rx_desc; | ||
349 | struct e1000_buffer *buffer_info; | ||
350 | struct sk_buff *skb; | ||
351 | unsigned int i; | ||
352 | unsigned int bufsz = 256 - | ||
353 | 16 /*for skb_reserve */ - | ||
354 | NET_IP_ALIGN; | ||
355 | |||
356 | i = rx_ring->next_to_use; | ||
357 | buffer_info = &rx_ring->buffer_info[i]; | ||
358 | |||
359 | while (cleaned_count--) { | ||
360 | skb = buffer_info->skb; | ||
361 | if (skb) { | ||
362 | skb_trim(skb, 0); | ||
363 | goto check_page; | ||
364 | } | ||
365 | |||
366 | skb = netdev_alloc_skb(netdev, bufsz); | ||
367 | if (!skb) { | ||
368 | /* Better luck next round */ | ||
369 | adapter->alloc_rx_buff_failed++; | ||
370 | break; | ||
371 | } | ||
372 | |||
373 | /* Make buffer alignment 2 beyond a 16 byte boundary | ||
374 | * this will result in a 16 byte aligned IP header after | ||
375 | * the 14 byte MAC header is removed | ||
376 | */ | ||
377 | skb_reserve(skb, NET_IP_ALIGN); | ||
378 | |||
379 | buffer_info->skb = skb; | ||
380 | check_page: | ||
381 | /* allocate a new page if necessary */ | ||
382 | if (!buffer_info->page) { | ||
383 | buffer_info->page = alloc_page(GFP_ATOMIC); | ||
384 | if (!buffer_info->page) { | ||
385 | adapter->alloc_rx_buff_failed++; | ||
386 | break; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | if (!buffer_info->dma) | ||
391 | buffer_info->dma = pci_map_page(pdev, | ||
392 | buffer_info->page, 0, | ||
393 | PAGE_SIZE, | ||
394 | PCI_DMA_FROMDEVICE); | ||
395 | if (pci_dma_mapping_error(buffer_info->dma)) { | ||
396 | dev_err(&adapter->pdev->dev, "RX DMA page map failed\n"); | ||
397 | adapter->rx_dma_failed++; | ||
398 | break; | ||
399 | } | ||
400 | |||
401 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
402 | rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | ||
403 | |||
404 | i++; | ||
405 | if (i == rx_ring->count) | ||
406 | i = 0; | ||
407 | buffer_info = &rx_ring->buffer_info[i]; | ||
408 | } | ||
409 | |||
410 | if (rx_ring->next_to_use != i) { | ||
411 | rx_ring->next_to_use = i; | ||
412 | if (i-- == 0) | ||
413 | i = (rx_ring->count - 1); | ||
414 | |||
415 | /* Force memory writes to complete before letting h/w | ||
416 | * know there are new descriptors to fetch. (Only | ||
417 | * applicable for weak-ordered memory model archs, | ||
418 | * such as IA-64). */ | ||
419 | wmb(); | ||
420 | writel(i, adapter->hw.hw_addr + rx_ring->tail); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * e1000_clean_rx_irq - Send received data up the network stack; legacy | 336 | * e1000_clean_rx_irq - Send received data up the network stack; legacy |
426 | * @adapter: board private structure | 337 | * @adapter: board private structure |
427 | * | 338 | * |
@@ -495,10 +406,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
495 | goto next_desc; | 406 | goto next_desc; |
496 | } | 407 | } |
497 | 408 | ||
498 | /* adjust length to remove Ethernet CRC */ | ||
499 | length -= 4; | ||
500 | |||
501 | /* probably a little skewed due to removing CRC */ | ||
502 | total_rx_bytes += length; | 409 | total_rx_bytes += length; |
503 | total_rx_packets++; | 410 | total_rx_packets++; |
504 | 411 | ||
@@ -554,15 +461,6 @@ next_desc: | |||
554 | return cleaned; | 461 | return cleaned; |
555 | } | 462 | } |
556 | 463 | ||
557 | static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, | ||
558 | u16 length) | ||
559 | { | ||
560 | bi->page = NULL; | ||
561 | skb->len += length; | ||
562 | skb->data_len += length; | ||
563 | skb->truesize += length; | ||
564 | } | ||
565 | |||
566 | static void e1000_put_txbuf(struct e1000_adapter *adapter, | 464 | static void e1000_put_txbuf(struct e1000_adapter *adapter, |
567 | struct e1000_buffer *buffer_info) | 465 | struct e1000_buffer *buffer_info) |
568 | { | 466 | { |
@@ -699,174 +597,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
699 | } | 597 | } |
700 | 598 | ||
701 | /** | 599 | /** |
702 | * e1000_clean_rx_irq_jumbo - Send received data up the network stack; legacy | ||
703 | * @adapter: board private structure | ||
704 | * | ||
705 | * the return value indicates whether actual cleaning was done, there | ||
706 | * is no guarantee that everything was cleaned | ||
707 | **/ | ||
708 | static bool e1000_clean_rx_irq_jumbo(struct e1000_adapter *adapter, | ||
709 | int *work_done, int work_to_do) | ||
710 | { | ||
711 | struct net_device *netdev = adapter->netdev; | ||
712 | struct pci_dev *pdev = adapter->pdev; | ||
713 | struct e1000_ring *rx_ring = adapter->rx_ring; | ||
714 | struct e1000_rx_desc *rx_desc, *next_rxd; | ||
715 | struct e1000_buffer *buffer_info, *next_buffer; | ||
716 | u32 length; | ||
717 | unsigned int i; | ||
718 | int cleaned_count = 0; | ||
719 | bool cleaned = 0; | ||
720 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; | ||
721 | |||
722 | i = rx_ring->next_to_clean; | ||
723 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
724 | buffer_info = &rx_ring->buffer_info[i]; | ||
725 | |||
726 | while (rx_desc->status & E1000_RXD_STAT_DD) { | ||
727 | struct sk_buff *skb; | ||
728 | u8 status; | ||
729 | |||
730 | if (*work_done >= work_to_do) | ||
731 | break; | ||
732 | (*work_done)++; | ||
733 | |||
734 | status = rx_desc->status; | ||
735 | skb = buffer_info->skb; | ||
736 | buffer_info->skb = NULL; | ||
737 | |||
738 | i++; | ||
739 | if (i == rx_ring->count) | ||
740 | i = 0; | ||
741 | next_rxd = E1000_RX_DESC(*rx_ring, i); | ||
742 | prefetch(next_rxd); | ||
743 | |||
744 | next_buffer = &rx_ring->buffer_info[i]; | ||
745 | |||
746 | cleaned = 1; | ||
747 | cleaned_count++; | ||
748 | pci_unmap_page(pdev, | ||
749 | buffer_info->dma, | ||
750 | PAGE_SIZE, | ||
751 | PCI_DMA_FROMDEVICE); | ||
752 | buffer_info->dma = 0; | ||
753 | |||
754 | length = le16_to_cpu(rx_desc->length); | ||
755 | |||
756 | /* errors is only valid for DD + EOP descriptors */ | ||
757 | if ((status & E1000_RXD_STAT_EOP) && | ||
758 | (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { | ||
759 | /* recycle both page and skb */ | ||
760 | buffer_info->skb = skb; | ||
761 | /* an error means any chain goes out the window too */ | ||
762 | if (rx_ring->rx_skb_top) | ||
763 | dev_kfree_skb(rx_ring->rx_skb_top); | ||
764 | rx_ring->rx_skb_top = NULL; | ||
765 | goto next_desc; | ||
766 | } | ||
767 | |||
768 | #define rxtop rx_ring->rx_skb_top | ||
769 | if (!(status & E1000_RXD_STAT_EOP)) { | ||
770 | /* this descriptor is only the beginning (or middle) */ | ||
771 | if (!rxtop) { | ||
772 | /* this is the beginning of a chain */ | ||
773 | rxtop = skb; | ||
774 | skb_fill_page_desc(rxtop, 0, buffer_info->page, | ||
775 | 0, length); | ||
776 | } else { | ||
777 | /* this is the middle of a chain */ | ||
778 | skb_fill_page_desc(rxtop, | ||
779 | skb_shinfo(rxtop)->nr_frags, | ||
780 | buffer_info->page, 0, | ||
781 | length); | ||
782 | /* re-use the skb, only consumed the page */ | ||
783 | buffer_info->skb = skb; | ||
784 | } | ||
785 | e1000_consume_page(buffer_info, rxtop, length); | ||
786 | goto next_desc; | ||
787 | } else { | ||
788 | if (rxtop) { | ||
789 | /* end of the chain */ | ||
790 | skb_fill_page_desc(rxtop, | ||
791 | skb_shinfo(rxtop)->nr_frags, | ||
792 | buffer_info->page, 0, length); | ||
793 | /* re-use the current skb, we only consumed the | ||
794 | * page */ | ||
795 | buffer_info->skb = skb; | ||
796 | skb = rxtop; | ||
797 | rxtop = NULL; | ||
798 | e1000_consume_page(buffer_info, skb, length); | ||
799 | } else { | ||
800 | /* no chain, got EOP, this buf is the packet | ||
801 | * copybreak to save the put_page/alloc_page */ | ||
802 | if (length <= copybreak && | ||
803 | skb_tailroom(skb) >= length) { | ||
804 | u8 *vaddr; | ||
805 | vaddr = kmap_atomic(buffer_info->page, | ||
806 | KM_SKB_DATA_SOFTIRQ); | ||
807 | memcpy(skb_tail_pointer(skb), | ||
808 | vaddr, length); | ||
809 | kunmap_atomic(vaddr, | ||
810 | KM_SKB_DATA_SOFTIRQ); | ||
811 | /* re-use the page, so don't erase | ||
812 | * buffer_info->page */ | ||
813 | skb_put(skb, length); | ||
814 | } else { | ||
815 | skb_fill_page_desc(skb, 0, | ||
816 | buffer_info->page, 0, | ||
817 | length); | ||
818 | e1000_consume_page(buffer_info, skb, | ||
819 | length); | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | |||
824 | /* Receive Checksum Offload XXX recompute due to CRC strip? */ | ||
825 | e1000_rx_checksum(adapter, | ||
826 | (u32)(status) | | ||
827 | ((u32)(rx_desc->errors) << 24), | ||
828 | le16_to_cpu(rx_desc->csum), skb); | ||
829 | |||
830 | pskb_trim(skb, skb->len - 4); | ||
831 | |||
832 | /* probably a little skewed due to removing CRC */ | ||
833 | total_rx_bytes += skb->len; | ||
834 | total_rx_packets++; | ||
835 | |||
836 | /* eth type trans needs skb->data to point to something */ | ||
837 | if (!pskb_may_pull(skb, ETH_HLEN)) { | ||
838 | ndev_err(netdev, "__pskb_pull_tail failed.\n"); | ||
839 | dev_kfree_skb(skb); | ||
840 | goto next_desc; | ||
841 | } | ||
842 | |||
843 | e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special); | ||
844 | |||
845 | next_desc: | ||
846 | rx_desc->status = 0; | ||
847 | |||
848 | /* return some buffers to hardware, one at a time is too slow */ | ||
849 | if (cleaned_count >= E1000_RX_BUFFER_WRITE) { | ||
850 | adapter->alloc_rx_buf(adapter, cleaned_count); | ||
851 | cleaned_count = 0; | ||
852 | } | ||
853 | |||
854 | /* use prefetched values */ | ||
855 | rx_desc = next_rxd; | ||
856 | buffer_info = next_buffer; | ||
857 | } | ||
858 | rx_ring->next_to_clean = i; | ||
859 | |||
860 | cleaned_count = e1000_desc_unused(rx_ring); | ||
861 | if (cleaned_count) | ||
862 | adapter->alloc_rx_buf(adapter, cleaned_count); | ||
863 | |||
864 | adapter->total_rx_packets += total_rx_packets; | ||
865 | adapter->total_rx_bytes += total_rx_bytes; | ||
866 | return cleaned; | ||
867 | } | ||
868 | |||
869 | /** | ||
870 | * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split | 600 | * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split |
871 | * @adapter: board private structure | 601 | * @adapter: board private structure |
872 | * | 602 | * |
@@ -953,7 +683,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
953 | ((length + l1) <= adapter->rx_ps_bsize0)) { | 683 | ((length + l1) <= adapter->rx_ps_bsize0)) { |
954 | u8 *vaddr; | 684 | u8 *vaddr; |
955 | 685 | ||
956 | ps_page = &rx_ring->ps_pages[i * PS_PAGE_BUFFERS]; | 686 | ps_page = &buffer_info->ps_pages[0]; |
957 | 687 | ||
958 | /* there is no documentation about how to call | 688 | /* there is no documentation about how to call |
959 | * kmap_atomic, so we can't hold the mapping | 689 | * kmap_atomic, so we can't hold the mapping |
@@ -965,8 +695,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
965 | kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); | 695 | kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); |
966 | pci_dma_sync_single_for_device(pdev, ps_page->dma, | 696 | pci_dma_sync_single_for_device(pdev, ps_page->dma, |
967 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | 697 | PAGE_SIZE, PCI_DMA_FROMDEVICE); |
968 | /* remove the CRC */ | 698 | |
969 | l1 -= 4; | ||
970 | skb_put(skb, l1); | 699 | skb_put(skb, l1); |
971 | goto copydone; | 700 | goto copydone; |
972 | } /* if */ | 701 | } /* if */ |
@@ -977,7 +706,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
977 | if (!length) | 706 | if (!length) |
978 | break; | 707 | break; |
979 | 708 | ||
980 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + j]; | 709 | ps_page = &buffer_info->ps_pages[j]; |
981 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, | 710 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, |
982 | PCI_DMA_FROMDEVICE); | 711 | PCI_DMA_FROMDEVICE); |
983 | ps_page->dma = 0; | 712 | ps_page->dma = 0; |
@@ -988,10 +717,6 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
988 | skb->truesize += length; | 717 | skb->truesize += length; |
989 | } | 718 | } |
990 | 719 | ||
991 | /* strip the ethernet crc, problem is we're using pages now so | ||
992 | * this whole operation can get a little cpu intensive */ | ||
993 | pskb_trim(skb, skb->len - 4); | ||
994 | |||
995 | copydone: | 720 | copydone: |
996 | total_rx_bytes += skb->len; | 721 | total_rx_bytes += skb->len; |
997 | total_rx_packets++; | 722 | total_rx_packets++; |
@@ -1043,7 +768,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1043 | struct e1000_buffer *buffer_info; | 768 | struct e1000_buffer *buffer_info; |
1044 | struct e1000_ps_page *ps_page; | 769 | struct e1000_ps_page *ps_page; |
1045 | struct pci_dev *pdev = adapter->pdev; | 770 | struct pci_dev *pdev = adapter->pdev; |
1046 | unsigned long size; | ||
1047 | unsigned int i, j; | 771 | unsigned int i, j; |
1048 | 772 | ||
1049 | /* Free all the Rx ring sk_buffs */ | 773 | /* Free all the Rx ring sk_buffs */ |
@@ -1054,9 +778,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1054 | pci_unmap_single(pdev, buffer_info->dma, | 778 | pci_unmap_single(pdev, buffer_info->dma, |
1055 | adapter->rx_buffer_len, | 779 | adapter->rx_buffer_len, |
1056 | PCI_DMA_FROMDEVICE); | 780 | PCI_DMA_FROMDEVICE); |
1057 | else if (adapter->clean_rx == e1000_clean_rx_irq_jumbo) | ||
1058 | pci_unmap_page(pdev, buffer_info->dma, | ||
1059 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | ||
1060 | else if (adapter->clean_rx == e1000_clean_rx_irq_ps) | 781 | else if (adapter->clean_rx == e1000_clean_rx_irq_ps) |
1061 | pci_unmap_single(pdev, buffer_info->dma, | 782 | pci_unmap_single(pdev, buffer_info->dma, |
1062 | adapter->rx_ps_bsize0, | 783 | adapter->rx_ps_bsize0, |
@@ -1064,19 +785,13 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1064 | buffer_info->dma = 0; | 785 | buffer_info->dma = 0; |
1065 | } | 786 | } |
1066 | 787 | ||
1067 | if (buffer_info->page) { | ||
1068 | put_page(buffer_info->page); | ||
1069 | buffer_info->page = NULL; | ||
1070 | } | ||
1071 | |||
1072 | if (buffer_info->skb) { | 788 | if (buffer_info->skb) { |
1073 | dev_kfree_skb(buffer_info->skb); | 789 | dev_kfree_skb(buffer_info->skb); |
1074 | buffer_info->skb = NULL; | 790 | buffer_info->skb = NULL; |
1075 | } | 791 | } |
1076 | 792 | ||
1077 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { | 793 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { |
1078 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) | 794 | ps_page = &buffer_info->ps_pages[j]; |
1079 | + j]; | ||
1080 | if (!ps_page->page) | 795 | if (!ps_page->page) |
1081 | break; | 796 | break; |
1082 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, | 797 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, |
@@ -1093,12 +808,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1093 | rx_ring->rx_skb_top = NULL; | 808 | rx_ring->rx_skb_top = NULL; |
1094 | } | 809 | } |
1095 | 810 | ||
1096 | size = sizeof(struct e1000_buffer) * rx_ring->count; | ||
1097 | memset(rx_ring->buffer_info, 0, size); | ||
1098 | size = sizeof(struct e1000_ps_page) | ||
1099 | * (rx_ring->count * PS_PAGE_BUFFERS); | ||
1100 | memset(rx_ring->ps_pages, 0, size); | ||
1101 | |||
1102 | /* Zero out the descriptor ring */ | 811 | /* Zero out the descriptor ring */ |
1103 | memset(rx_ring->desc, 0, rx_ring->size); | 812 | memset(rx_ring->desc, 0, rx_ring->size); |
1104 | 813 | ||
@@ -1421,7 +1130,8 @@ err: | |||
1421 | int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | 1130 | int e1000e_setup_rx_resources(struct e1000_adapter *adapter) |
1422 | { | 1131 | { |
1423 | struct e1000_ring *rx_ring = adapter->rx_ring; | 1132 | struct e1000_ring *rx_ring = adapter->rx_ring; |
1424 | int size, desc_len, err = -ENOMEM; | 1133 | struct e1000_buffer *buffer_info; |
1134 | int i, size, desc_len, err = -ENOMEM; | ||
1425 | 1135 | ||
1426 | size = sizeof(struct e1000_buffer) * rx_ring->count; | 1136 | size = sizeof(struct e1000_buffer) * rx_ring->count; |
1427 | rx_ring->buffer_info = vmalloc(size); | 1137 | rx_ring->buffer_info = vmalloc(size); |
@@ -1429,11 +1139,14 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | |||
1429 | goto err; | 1139 | goto err; |
1430 | memset(rx_ring->buffer_info, 0, size); | 1140 | memset(rx_ring->buffer_info, 0, size); |
1431 | 1141 | ||
1432 | rx_ring->ps_pages = kcalloc(rx_ring->count * PS_PAGE_BUFFERS, | 1142 | for (i = 0; i < rx_ring->count; i++) { |
1433 | sizeof(struct e1000_ps_page), | 1143 | buffer_info = &rx_ring->buffer_info[i]; |
1434 | GFP_KERNEL); | 1144 | buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS, |
1435 | if (!rx_ring->ps_pages) | 1145 | sizeof(struct e1000_ps_page), |
1436 | goto err; | 1146 | GFP_KERNEL); |
1147 | if (!buffer_info->ps_pages) | ||
1148 | goto err_pages; | ||
1149 | } | ||
1437 | 1150 | ||
1438 | desc_len = sizeof(union e1000_rx_desc_packet_split); | 1151 | desc_len = sizeof(union e1000_rx_desc_packet_split); |
1439 | 1152 | ||
@@ -1443,16 +1156,21 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | |||
1443 | 1156 | ||
1444 | err = e1000_alloc_ring_dma(adapter, rx_ring); | 1157 | err = e1000_alloc_ring_dma(adapter, rx_ring); |
1445 | if (err) | 1158 | if (err) |
1446 | goto err; | 1159 | goto err_pages; |
1447 | 1160 | ||
1448 | rx_ring->next_to_clean = 0; | 1161 | rx_ring->next_to_clean = 0; |
1449 | rx_ring->next_to_use = 0; | 1162 | rx_ring->next_to_use = 0; |
1450 | rx_ring->rx_skb_top = NULL; | 1163 | rx_ring->rx_skb_top = NULL; |
1451 | 1164 | ||
1452 | return 0; | 1165 | return 0; |
1166 | |||
1167 | err_pages: | ||
1168 | for (i = 0; i < rx_ring->count; i++) { | ||
1169 | buffer_info = &rx_ring->buffer_info[i]; | ||
1170 | kfree(buffer_info->ps_pages); | ||
1171 | } | ||
1453 | err: | 1172 | err: |
1454 | vfree(rx_ring->buffer_info); | 1173 | vfree(rx_ring->buffer_info); |
1455 | kfree(rx_ring->ps_pages); | ||
1456 | ndev_err(adapter->netdev, | 1174 | ndev_err(adapter->netdev, |
1457 | "Unable to allocate memory for the transmit descriptor ring\n"); | 1175 | "Unable to allocate memory for the transmit descriptor ring\n"); |
1458 | return err; | 1176 | return err; |
@@ -1518,15 +1236,17 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter) | |||
1518 | { | 1236 | { |
1519 | struct pci_dev *pdev = adapter->pdev; | 1237 | struct pci_dev *pdev = adapter->pdev; |
1520 | struct e1000_ring *rx_ring = adapter->rx_ring; | 1238 | struct e1000_ring *rx_ring = adapter->rx_ring; |
1239 | int i; | ||
1521 | 1240 | ||
1522 | e1000_clean_rx_ring(adapter); | 1241 | e1000_clean_rx_ring(adapter); |
1523 | 1242 | ||
1243 | for (i = 0; i < rx_ring->count; i++) { | ||
1244 | kfree(rx_ring->buffer_info[i].ps_pages); | ||
1245 | } | ||
1246 | |||
1524 | vfree(rx_ring->buffer_info); | 1247 | vfree(rx_ring->buffer_info); |
1525 | rx_ring->buffer_info = NULL; | 1248 | rx_ring->buffer_info = NULL; |
1526 | 1249 | ||
1527 | kfree(rx_ring->ps_pages); | ||
1528 | rx_ring->ps_pages = NULL; | ||
1529 | |||
1530 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, | 1250 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, |
1531 | rx_ring->dma); | 1251 | rx_ring->dma); |
1532 | rx_ring->desc = NULL; | 1252 | rx_ring->desc = NULL; |
@@ -2032,9 +1752,11 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) | |||
2032 | 1752 | ||
2033 | ew32(RFCTL, rfctl); | 1753 | ew32(RFCTL, rfctl); |
2034 | 1754 | ||
2035 | /* disable the stripping of CRC because it breaks | 1755 | /* Enable Packet split descriptors */ |
2036 | * BMC firmware connected over SMBUS */ | 1756 | rctl |= E1000_RCTL_DTYP_PS; |
2037 | rctl |= E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */; | 1757 | |
1758 | /* Enable hardware CRC frame stripping */ | ||
1759 | rctl |= E1000_RCTL_SECRC; | ||
2038 | 1760 | ||
2039 | psrctl |= adapter->rx_ps_bsize0 >> | 1761 | psrctl |= adapter->rx_ps_bsize0 >> |
2040 | E1000_PSRCTL_BSIZE0_SHIFT; | 1762 | E1000_PSRCTL_BSIZE0_SHIFT; |
@@ -2077,11 +1799,6 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) | |||
2077 | sizeof(union e1000_rx_desc_packet_split); | 1799 | sizeof(union e1000_rx_desc_packet_split); |
2078 | adapter->clean_rx = e1000_clean_rx_irq_ps; | 1800 | adapter->clean_rx = e1000_clean_rx_irq_ps; |
2079 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; | 1801 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; |
2080 | } else if (adapter->netdev->mtu > ETH_FRAME_LEN + VLAN_HLEN + 4) { | ||
2081 | rdlen = rx_ring->count * | ||
2082 | sizeof(struct e1000_rx_desc); | ||
2083 | adapter->clean_rx = e1000_clean_rx_irq_jumbo; | ||
2084 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_jumbo; | ||
2085 | } else { | 1802 | } else { |
2086 | rdlen = rx_ring->count * | 1803 | rdlen = rx_ring->count * |
2087 | sizeof(struct e1000_rx_desc); | 1804 | sizeof(struct e1000_rx_desc); |
@@ -2326,8 +2043,11 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2326 | struct e1000_mac_info *mac = &adapter->hw.mac; | 2043 | struct e1000_mac_info *mac = &adapter->hw.mac; |
2327 | struct e1000_hw *hw = &adapter->hw; | 2044 | struct e1000_hw *hw = &adapter->hw; |
2328 | u32 tx_space, min_tx_space, min_rx_space; | 2045 | u32 tx_space, min_tx_space, min_rx_space; |
2046 | u32 pba; | ||
2329 | u16 hwm; | 2047 | u16 hwm; |
2330 | 2048 | ||
2049 | ew32(PBA, adapter->pba); | ||
2050 | |||
2331 | if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { | 2051 | if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { |
2332 | /* To maintain wire speed transmits, the Tx FIFO should be | 2052 | /* To maintain wire speed transmits, the Tx FIFO should be |
2333 | * large enough to accommodate two full transmit packets, | 2053 | * large enough to accommodate two full transmit packets, |
@@ -2335,11 +2055,11 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2335 | * the Rx FIFO should be large enough to accommodate at least | 2055 | * the Rx FIFO should be large enough to accommodate at least |
2336 | * one full receive packet and is similarly rounded up and | 2056 | * one full receive packet and is similarly rounded up and |
2337 | * expressed in KB. */ | 2057 | * expressed in KB. */ |
2338 | adapter->pba = er32(PBA); | 2058 | pba = er32(PBA); |
2339 | /* upper 16 bits has Tx packet buffer allocation size in KB */ | 2059 | /* upper 16 bits has Tx packet buffer allocation size in KB */ |
2340 | tx_space = adapter->pba >> 16; | 2060 | tx_space = pba >> 16; |
2341 | /* lower 16 bits has Rx packet buffer allocation size in KB */ | 2061 | /* lower 16 bits has Rx packet buffer allocation size in KB */ |
2342 | adapter->pba &= 0xffff; | 2062 | pba &= 0xffff; |
2343 | /* the tx fifo also stores 16 bytes of information about the tx | 2063 | /* the tx fifo also stores 16 bytes of information about the tx |
2344 | * but don't include ethernet FCS because hardware appends it */ | 2064 | * but don't include ethernet FCS because hardware appends it */ |
2345 | min_tx_space = (mac->max_frame_size + | 2065 | min_tx_space = (mac->max_frame_size + |
@@ -2355,20 +2075,21 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2355 | /* If current Tx allocation is less than the min Tx FIFO size, | 2075 | /* If current Tx allocation is less than the min Tx FIFO size, |
2356 | * and the min Tx FIFO size is less than the current Rx FIFO | 2076 | * and the min Tx FIFO size is less than the current Rx FIFO |
2357 | * allocation, take space away from current Rx allocation */ | 2077 | * allocation, take space away from current Rx allocation */ |
2358 | if (tx_space < min_tx_space && | 2078 | if ((tx_space < min_tx_space) && |
2359 | ((min_tx_space - tx_space) < adapter->pba)) { | 2079 | ((min_tx_space - tx_space) < pba)) { |
2360 | adapter->pba -= - (min_tx_space - tx_space); | 2080 | pba -= min_tx_space - tx_space; |
2361 | 2081 | ||
2362 | /* if short on rx space, rx wins and must trump tx | 2082 | /* if short on rx space, rx wins and must trump tx |
2363 | * adjustment or use Early Receive if available */ | 2083 | * adjustment or use Early Receive if available */ |
2364 | if ((adapter->pba < min_rx_space) && | 2084 | if ((pba < min_rx_space) && |
2365 | (!(adapter->flags & FLAG_HAS_ERT))) | 2085 | (!(adapter->flags & FLAG_HAS_ERT))) |
2366 | /* ERT enabled in e1000_configure_rx */ | 2086 | /* ERT enabled in e1000_configure_rx */ |
2367 | adapter->pba = min_rx_space; | 2087 | pba = min_rx_space; |
2368 | } | 2088 | } |
2089 | |||
2090 | ew32(PBA, pba); | ||
2369 | } | 2091 | } |
2370 | 2092 | ||
2371 | ew32(PBA, adapter->pba); | ||
2372 | 2093 | ||
2373 | /* flow control settings */ | 2094 | /* flow control settings */ |
2374 | /* The high water mark must be low enough to fit one full frame | 2095 | /* The high water mark must be low enough to fit one full frame |
@@ -3624,9 +3345,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3624 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN | 3345 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN |
3625 | * means we reserve 2 more, this pushes us to allocate from the next | 3346 | * means we reserve 2 more, this pushes us to allocate from the next |
3626 | * larger slab size. | 3347 | * larger slab size. |
3627 | * i.e. RXBUFFER_2048 --> size-4096 slab | 3348 | * i.e. RXBUFFER_2048 --> size-4096 slab */ |
3628 | * however with the new *_jumbo* routines, jumbo receives will use | ||
3629 | * fragmented skbs */ | ||
3630 | 3349 | ||
3631 | if (max_frame <= 256) | 3350 | if (max_frame <= 256) |
3632 | adapter->rx_buffer_len = 256; | 3351 | adapter->rx_buffer_len = 256; |
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index 4b4b74e47a..f78e5bf7cb 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | 41 | ||
42 | #define DRV_NAME "ehea" | 42 | #define DRV_NAME "ehea" |
43 | #define DRV_VERSION "EHEA_0079" | 43 | #define DRV_VERSION "EHEA_0080" |
44 | 44 | ||
45 | /* eHEA capability flags */ | 45 | /* eHEA capability flags */ |
46 | #define DLPAR_PORT_ADD_REM 1 | 46 | #define DLPAR_PORT_ADD_REM 1 |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 0a7e789255..f0319f1e8e 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -33,6 +33,9 @@ | |||
33 | #include <linux/if.h> | 33 | #include <linux/if.h> |
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/if_ether.h> | 35 | #include <linux/if_ether.h> |
36 | #include <linux/notifier.h> | ||
37 | #include <linux/reboot.h> | ||
38 | |||
36 | #include <net/ip.h> | 39 | #include <net/ip.h> |
37 | 40 | ||
38 | #include "ehea.h" | 41 | #include "ehea.h" |
@@ -3295,6 +3298,20 @@ static int __devexit ehea_remove(struct of_device *dev) | |||
3295 | return 0; | 3298 | return 0; |
3296 | } | 3299 | } |
3297 | 3300 | ||
3301 | static int ehea_reboot_notifier(struct notifier_block *nb, | ||
3302 | unsigned long action, void *unused) | ||
3303 | { | ||
3304 | if (action == SYS_RESTART) { | ||
3305 | ehea_info("Reboot: freeing all eHEA resources"); | ||
3306 | ibmebus_unregister_driver(&ehea_driver); | ||
3307 | } | ||
3308 | return NOTIFY_DONE; | ||
3309 | } | ||
3310 | |||
3311 | static struct notifier_block ehea_reboot_nb = { | ||
3312 | .notifier_call = ehea_reboot_notifier, | ||
3313 | }; | ||
3314 | |||
3298 | static int check_module_parm(void) | 3315 | static int check_module_parm(void) |
3299 | { | 3316 | { |
3300 | int ret = 0; | 3317 | int ret = 0; |
@@ -3351,6 +3368,8 @@ int __init ehea_module_init(void) | |||
3351 | if (ret) | 3368 | if (ret) |
3352 | goto out; | 3369 | goto out; |
3353 | 3370 | ||
3371 | register_reboot_notifier(&ehea_reboot_nb); | ||
3372 | |||
3354 | ret = ibmebus_register_driver(&ehea_driver); | 3373 | ret = ibmebus_register_driver(&ehea_driver); |
3355 | if (ret) { | 3374 | if (ret) { |
3356 | ehea_error("failed registering eHEA device driver on ebus"); | 3375 | ehea_error("failed registering eHEA device driver on ebus"); |
@@ -3362,6 +3381,7 @@ int __init ehea_module_init(void) | |||
3362 | if (ret) { | 3381 | if (ret) { |
3363 | ehea_error("failed to register capabilities attribute, ret=%d", | 3382 | ehea_error("failed to register capabilities attribute, ret=%d", |
3364 | ret); | 3383 | ret); |
3384 | unregister_reboot_notifier(&ehea_reboot_nb); | ||
3365 | ibmebus_unregister_driver(&ehea_driver); | 3385 | ibmebus_unregister_driver(&ehea_driver); |
3366 | goto out; | 3386 | goto out; |
3367 | } | 3387 | } |
@@ -3375,6 +3395,7 @@ static void __exit ehea_module_exit(void) | |||
3375 | flush_scheduled_work(); | 3395 | flush_scheduled_work(); |
3376 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); | 3396 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); |
3377 | ibmebus_unregister_driver(&ehea_driver); | 3397 | ibmebus_unregister_driver(&ehea_driver); |
3398 | unregister_reboot_notifier(&ehea_reboot_nb); | ||
3378 | ehea_destroy_busmap(); | 3399 | ehea_destroy_busmap(); |
3379 | } | 3400 | } |
3380 | 3401 | ||
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c index 4dbdfaaf37..a1e4508717 100644 --- a/drivers/net/irda/au1k_ir.c +++ b/drivers/net/irda/au1k_ir.c | |||
@@ -627,19 +627,16 @@ static int au1k_irda_rx(struct net_device *dev) | |||
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | void au1k_irda_interrupt(int irq, void *dev_id) | 630 | static irqreturn_t au1k_irda_interrupt(int dummy, void *dev_id) |
631 | { | 631 | { |
632 | struct net_device *dev = (struct net_device *) dev_id; | 632 | struct net_device *dev = dev_id; |
633 | |||
634 | if (dev == NULL) { | ||
635 | printk(KERN_ERR "%s: isr: null dev ptr\n", dev->name); | ||
636 | return; | ||
637 | } | ||
638 | 633 | ||
639 | writel(0, IR_INT_CLEAR); /* ack irda interrupts */ | 634 | writel(0, IR_INT_CLEAR); /* ack irda interrupts */ |
640 | 635 | ||
641 | au1k_irda_rx(dev); | 636 | au1k_irda_rx(dev); |
642 | au1k_tx_ack(dev); | 637 | au1k_tx_ack(dev); |
638 | |||
639 | return IRQ_HANDLED; | ||
643 | } | 640 | } |
644 | 641 | ||
645 | 642 | ||
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 662b8d1680..45f30a2974 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -284,7 +284,7 @@ static __net_exit void loopback_net_exit(struct net *net) | |||
284 | unregister_netdev(dev); | 284 | unregister_netdev(dev); |
285 | } | 285 | } |
286 | 286 | ||
287 | static struct pernet_operations __net_initdata loopback_net_ops = { | 287 | static struct pernet_operations loopback_net_ops = { |
288 | .init = loopback_net_init, | 288 | .init = loopback_net_init, |
289 | .exit = loopback_net_exit, | 289 | .exit = loopback_net_exit, |
290 | }; | 290 | }; |
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 887633b207..2a5bef6388 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
@@ -101,9 +101,7 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma | |||
101 | if (!page) | 101 | if (!page) |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | 103 | ||
104 | sg_set_page(mem, page); | 104 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
105 | mem->length = PAGE_SIZE << order; | ||
106 | mem->offset = 0; | ||
107 | return 0; | 105 | return 0; |
108 | } | 106 | } |
109 | 107 | ||
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index bcb0885011..b35d794495 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
@@ -68,7 +68,7 @@ MODULE_VERSION("1.0.2"); | |||
68 | static unsigned int | 68 | static unsigned int |
69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) | 69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) |
70 | { | 70 | { |
71 | sg_init_one(sg, address, length); | 71 | sg_set_buf(sg, address, length); |
72 | return length; | 72 | return length; |
73 | } | 73 | } |
74 | 74 | ||
@@ -140,6 +140,8 @@ static void get_new_key_from_sha(struct ppp_mppe_state * state) | |||
140 | struct scatterlist sg[4]; | 140 | struct scatterlist sg[4]; |
141 | unsigned int nbytes; | 141 | unsigned int nbytes; |
142 | 142 | ||
143 | sg_init_table(sg, 4); | ||
144 | |||
143 | nbytes = setup_sg(&sg[0], state->master_key, state->keylen); | 145 | nbytes = setup_sg(&sg[0], state->master_key, state->keylen); |
144 | nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, | 146 | nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, |
145 | sizeof(sha_pad->sha_pad1)); | 147 | sizeof(sha_pad->sha_pad1)); |
@@ -166,6 +168,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) | |||
166 | if (!initial_key) { | 168 | if (!initial_key) { |
167 | crypto_blkcipher_setkey(state->arc4, state->sha1_digest, | 169 | crypto_blkcipher_setkey(state->arc4, state->sha1_digest, |
168 | state->keylen); | 170 | state->keylen); |
171 | sg_init_table(sg_in, 1); | ||
172 | sg_init_table(sg_out, 1); | ||
169 | setup_sg(sg_in, state->sha1_digest, state->keylen); | 173 | setup_sg(sg_in, state->sha1_digest, state->keylen); |
170 | setup_sg(sg_out, state->session_key, state->keylen); | 174 | setup_sg(sg_out, state->session_key, state->keylen); |
171 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, | 175 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, |
@@ -421,6 +425,8 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, | |||
421 | isize -= 2; | 425 | isize -= 2; |
422 | 426 | ||
423 | /* Encrypt packet */ | 427 | /* Encrypt packet */ |
428 | sg_init_table(sg_in, 1); | ||
429 | sg_init_table(sg_out, 1); | ||
424 | setup_sg(sg_in, ibuf, isize); | 430 | setup_sg(sg_in, ibuf, isize); |
425 | setup_sg(sg_out, obuf, osize); | 431 | setup_sg(sg_out, obuf, osize); |
426 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { | 432 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { |
@@ -608,6 +614,8 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, | |||
608 | * Decrypt the first byte in order to check if it is | 614 | * Decrypt the first byte in order to check if it is |
609 | * a compressed or uncompressed protocol field. | 615 | * a compressed or uncompressed protocol field. |
610 | */ | 616 | */ |
617 | sg_init_table(sg_in, 1); | ||
618 | sg_init_table(sg_out, 1); | ||
611 | setup_sg(sg_in, ibuf, 1); | 619 | setup_sg(sg_in, ibuf, 1); |
612 | setup_sg(sg_out, obuf, 1); | 620 | setup_sg(sg_out, obuf, 1); |
613 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { | 621 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { |
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c index 19152f54ef..b822859c8d 100644 --- a/drivers/net/rrunner.c +++ b/drivers/net/rrunner.c | |||
@@ -79,12 +79,10 @@ static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen | |||
79 | */ | 79 | */ |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * These are checked at init time to see if they are at least 256KB | 82 | * sysctl_[wr]mem_max are checked at init time to see if they are at |
83 | * and increased to 256KB if they are not. This is done to avoid ending | 83 | * least 256KB and increased to 256KB if they are not. This is done to |
84 | * up with socket buffers smaller than the MTU size, | 84 | * avoid ending up with socket buffers smaller than the MTU size, |
85 | */ | 85 | */ |
86 | extern __u32 sysctl_wmem_max; | ||
87 | extern __u32 sysctl_rmem_max; | ||
88 | 86 | ||
89 | static int __devinit rr_init_one(struct pci_dev *pdev, | 87 | static int __devinit rr_init_one(struct pci_dev *pdev, |
90 | const struct pci_device_id *ent) | 88 | const struct pci_device_id *ent) |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 9d9ff76a9b..5058e60e57 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -2391,7 +2391,7 @@ out_requeue: | |||
2391 | if (b43_debug(dev, B43_DBG_PWORK_FAST)) | 2391 | if (b43_debug(dev, B43_DBG_PWORK_FAST)) |
2392 | delay = msecs_to_jiffies(50); | 2392 | delay = msecs_to_jiffies(50); |
2393 | else | 2393 | else |
2394 | delay = round_jiffies(HZ * 15); | 2394 | delay = round_jiffies_relative(HZ * 15); |
2395 | queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay); | 2395 | queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay); |
2396 | out: | 2396 | out: |
2397 | mutex_unlock(&wl->mutex); | 2397 | mutex_unlock(&wl->mutex); |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index d09479e816..f0e56dfc9e 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -2260,7 +2260,7 @@ out_requeue: | |||
2260 | if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST)) | 2260 | if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST)) |
2261 | delay = msecs_to_jiffies(50); | 2261 | delay = msecs_to_jiffies(50); |
2262 | else | 2262 | else |
2263 | delay = round_jiffies(HZ); | 2263 | delay = round_jiffies_relative(HZ); |
2264 | queue_delayed_work(dev->wl->hw->workqueue, | 2264 | queue_delayed_work(dev->wl->hw->workqueue, |
2265 | &dev->periodic_work, delay); | 2265 | &dev->periodic_work, delay); |
2266 | out: | 2266 | out: |
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index a6c7904de2..8d53d08b96 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -1769,7 +1769,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) | |||
1769 | if (priv->stop_rf_kill) { | 1769 | if (priv->stop_rf_kill) { |
1770 | priv->stop_rf_kill = 0; | 1770 | priv->stop_rf_kill = 0; |
1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1772 | round_jiffies(HZ)); | 1772 | round_jiffies_relative(HZ)); |
1773 | } | 1773 | } |
1774 | 1774 | ||
1775 | deferred = 1; | 1775 | deferred = 1; |
@@ -2086,7 +2086,8 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) | |||
2086 | /* Make sure the RF Kill check timer is running */ | 2086 | /* Make sure the RF Kill check timer is running */ |
2087 | priv->stop_rf_kill = 0; | 2087 | priv->stop_rf_kill = 0; |
2088 | cancel_delayed_work(&priv->rf_kill); | 2088 | cancel_delayed_work(&priv->rf_kill); |
2089 | queue_delayed_work(priv->workqueue, &priv->rf_kill, round_jiffies(HZ)); | 2089 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
2090 | round_jiffies_relative(HZ)); | ||
2090 | } | 2091 | } |
2091 | 2092 | ||
2092 | static void send_scan_event(void *data) | 2093 | static void send_scan_event(void *data) |
@@ -2123,7 +2124,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) | |||
2123 | if (!delayed_work_pending(&priv->scan_event_later)) | 2124 | if (!delayed_work_pending(&priv->scan_event_later)) |
2124 | queue_delayed_work(priv->workqueue, | 2125 | queue_delayed_work(priv->workqueue, |
2125 | &priv->scan_event_later, | 2126 | &priv->scan_event_later, |
2126 | round_jiffies(msecs_to_jiffies(4000))); | 2127 | round_jiffies_relative(msecs_to_jiffies(4000))); |
2127 | } else { | 2128 | } else { |
2128 | priv->user_requested_scan = 0; | 2129 | priv->user_requested_scan = 0; |
2129 | cancel_delayed_work(&priv->scan_event_later); | 2130 | cancel_delayed_work(&priv->scan_event_later); |
@@ -4242,7 +4243,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) | |||
4242 | priv->stop_rf_kill = 0; | 4243 | priv->stop_rf_kill = 0; |
4243 | cancel_delayed_work(&priv->rf_kill); | 4244 | cancel_delayed_work(&priv->rf_kill); |
4244 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 4245 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
4245 | round_jiffies(HZ)); | 4246 | round_jiffies_relative(HZ)); |
4246 | } else | 4247 | } else |
4247 | schedule_reset(priv); | 4248 | schedule_reset(priv); |
4248 | } | 4249 | } |
@@ -5981,7 +5982,7 @@ static void ipw2100_rf_kill(struct work_struct *work) | |||
5981 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); | 5982 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); |
5982 | if (!priv->stop_rf_kill) | 5983 | if (!priv->stop_rf_kill) |
5983 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 5984 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
5984 | round_jiffies(HZ)); | 5985 | round_jiffies_relative(HZ)); |
5985 | goto exit_unlock; | 5986 | goto exit_unlock; |
5986 | } | 5987 | } |
5987 | 5988 | ||
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e3c828401b..54f44e5473 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c | |||
@@ -1753,7 +1753,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) | |||
1753 | /* Make sure the RF_KILL check timer is running */ | 1753 | /* Make sure the RF_KILL check timer is running */ |
1754 | cancel_delayed_work(&priv->rf_kill); | 1754 | cancel_delayed_work(&priv->rf_kill); |
1755 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 1755 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1756 | round_jiffies(2 * HZ)); | 1756 | round_jiffies_relative(2 * HZ)); |
1757 | } else | 1757 | } else |
1758 | queue_work(priv->workqueue, &priv->up); | 1758 | queue_work(priv->workqueue, &priv->up); |
1759 | } | 1759 | } |
@@ -4364,7 +4364,7 @@ static void handle_scan_event(struct ipw_priv *priv) | |||
4364 | if (!priv->user_requested_scan) { | 4364 | if (!priv->user_requested_scan) { |
4365 | if (!delayed_work_pending(&priv->scan_event)) | 4365 | if (!delayed_work_pending(&priv->scan_event)) |
4366 | queue_delayed_work(priv->workqueue, &priv->scan_event, | 4366 | queue_delayed_work(priv->workqueue, &priv->scan_event, |
4367 | round_jiffies(msecs_to_jiffies(4000))); | 4367 | round_jiffies_relative(msecs_to_jiffies(4000))); |
4368 | } else { | 4368 | } else { |
4369 | union iwreq_data wrqu; | 4369 | union iwreq_data wrqu; |
4370 | 4370 | ||
@@ -4728,7 +4728,7 @@ static void ipw_rx_notification(struct ipw_priv *priv, | |||
4728 | && priv->status & STATUS_ASSOCIATED) | 4728 | && priv->status & STATUS_ASSOCIATED) |
4729 | queue_delayed_work(priv->workqueue, | 4729 | queue_delayed_work(priv->workqueue, |
4730 | &priv->request_scan, | 4730 | &priv->request_scan, |
4731 | round_jiffies(HZ)); | 4731 | round_jiffies_relative(HZ)); |
4732 | 4732 | ||
4733 | /* Send an empty event to user space. | 4733 | /* Send an empty event to user space. |
4734 | * We don't send the received data on the event because | 4734 | * We don't send the received data on the event because |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 557deebca1..891f90d2f0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -3232,9 +3232,7 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, | |||
3232 | tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, | 3232 | tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, |
3233 | rate_flags); | 3233 | rate_flags); |
3234 | 3234 | ||
3235 | if (ieee80211_is_probe_request(fc)) | 3235 | if (ieee80211_is_back_request(fc)) |
3236 | tx->tx_flags |= TX_CMD_FLG_TSF_MSK; | ||
3237 | else if (ieee80211_is_back_request(fc)) | ||
3238 | tx->tx_flags |= TX_CMD_FLG_ACK_MSK | | 3236 | tx->tx_flags |= TX_CMD_FLG_ACK_MSK | |
3239 | TX_CMD_FLG_IMM_BA_RSP_MASK; | 3237 | TX_CMD_FLG_IMM_BA_RSP_MASK; |
3240 | #ifdef CONFIG_IWLWIFI_HT | 3238 | #ifdef CONFIG_IWLWIFI_HT |
@@ -3872,7 +3870,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
3872 | */ | 3870 | */ |
3873 | case IEEE80211_STYPE_ASSOC_RESP: | 3871 | case IEEE80211_STYPE_ASSOC_RESP: |
3874 | case IEEE80211_STYPE_REASSOC_RESP: | 3872 | case IEEE80211_STYPE_REASSOC_RESP: |
3875 | if (network_packet && iwl_is_associated(priv)) { | 3873 | if (network_packet) { |
3876 | #ifdef CONFIG_IWLWIFI_HT | 3874 | #ifdef CONFIG_IWLWIFI_HT |
3877 | u8 *pos = NULL; | 3875 | u8 *pos = NULL; |
3878 | struct ieee802_11_elems elems; | 3876 | struct ieee802_11_elems elems; |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 83019d1d7c..4f22a7174c 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -6478,8 +6478,9 @@ static void iwl_bg_scan_check(struct work_struct *data) | |||
6478 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | 6478 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, |
6479 | "Scan completion watchdog resetting adapter (%dms)\n", | 6479 | "Scan completion watchdog resetting adapter (%dms)\n", |
6480 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | 6480 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); |
6481 | |||
6481 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 6482 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
6482 | queue_work(priv->workqueue, &priv->restart); | 6483 | iwl_send_scan_abort(priv); |
6483 | } | 6484 | } |
6484 | mutex_unlock(&priv->mutex); | 6485 | mutex_unlock(&priv->mutex); |
6485 | } | 6486 | } |
@@ -6575,7 +6576,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6575 | spin_unlock_irqrestore(&priv->lock, flags); | 6576 | spin_unlock_irqrestore(&priv->lock, flags); |
6576 | 6577 | ||
6577 | scan->suspend_time = 0; | 6578 | scan->suspend_time = 0; |
6578 | scan->max_out_time = cpu_to_le32(600 * 1024); | 6579 | scan->max_out_time = cpu_to_le32(200 * 1024); |
6579 | if (!interval) | 6580 | if (!interval) |
6580 | interval = suspend_time; | 6581 | interval = suspend_time; |
6581 | /* | 6582 | /* |
@@ -6605,7 +6606,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6605 | memcpy(scan->direct_scan[0].ssid, | 6606 | memcpy(scan->direct_scan[0].ssid, |
6606 | priv->direct_ssid, priv->direct_ssid_len); | 6607 | priv->direct_ssid, priv->direct_ssid_len); |
6607 | direct_mask = 1; | 6608 | direct_mask = 1; |
6608 | } else if (!iwl_is_associated(priv)) { | 6609 | } else if (!iwl_is_associated(priv) && priv->essid_len) { |
6609 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6610 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6610 | scan->direct_scan[0].len = priv->essid_len; | 6611 | scan->direct_scan[0].len = priv->essid_len; |
6611 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 6612 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |
@@ -6744,6 +6745,12 @@ static void iwl_bg_post_associate(struct work_struct *data) | |||
6744 | 6745 | ||
6745 | mutex_lock(&priv->mutex); | 6746 | mutex_lock(&priv->mutex); |
6746 | 6747 | ||
6748 | if (!priv->interface_id || !priv->is_open) { | ||
6749 | mutex_unlock(&priv->mutex); | ||
6750 | return; | ||
6751 | } | ||
6752 | iwl_scan_cancel_timeout(priv, 200); | ||
6753 | |||
6747 | conf = ieee80211_get_hw_conf(priv->hw); | 6754 | conf = ieee80211_get_hw_conf(priv->hw); |
6748 | 6755 | ||
6749 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 6756 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
@@ -6882,9 +6889,19 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) | |||
6882 | struct iwl_priv *priv = hw->priv; | 6889 | struct iwl_priv *priv = hw->priv; |
6883 | 6890 | ||
6884 | IWL_DEBUG_MAC80211("enter\n"); | 6891 | IWL_DEBUG_MAC80211("enter\n"); |
6892 | |||
6893 | |||
6894 | mutex_lock(&priv->mutex); | ||
6895 | /* stop mac, cancel any scan request and clear | ||
6896 | * RXON_FILTER_ASSOC_MSK BIT | ||
6897 | */ | ||
6885 | priv->is_open = 0; | 6898 | priv->is_open = 0; |
6886 | /*netif_stop_queue(dev); */ | 6899 | iwl_scan_cancel_timeout(priv, 100); |
6887 | flush_workqueue(priv->workqueue); | 6900 | cancel_delayed_work(&priv->post_associate); |
6901 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
6902 | iwl_commit_rxon(priv); | ||
6903 | mutex_unlock(&priv->mutex); | ||
6904 | |||
6888 | IWL_DEBUG_MAC80211("leave\n"); | 6905 | IWL_DEBUG_MAC80211("leave\n"); |
6889 | } | 6906 | } |
6890 | 6907 | ||
@@ -7169,8 +7186,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7169 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) | 7186 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) |
7170 | iwl_config_ap(priv); | 7187 | iwl_config_ap(priv); |
7171 | else { | 7188 | else { |
7172 | priv->staging_rxon.filter_flags |= | ||
7173 | RXON_FILTER_ASSOC_MSK; | ||
7174 | rc = iwl_commit_rxon(priv); | 7189 | rc = iwl_commit_rxon(priv); |
7175 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 7190 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
7176 | iwl_add_station(priv, | 7191 | iwl_add_station(priv, |
@@ -7178,6 +7193,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7178 | } | 7193 | } |
7179 | 7194 | ||
7180 | } else { | 7195 | } else { |
7196 | iwl_scan_cancel_timeout(priv, 100); | ||
7181 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7197 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
7182 | iwl_commit_rxon(priv); | 7198 | iwl_commit_rxon(priv); |
7183 | } | 7199 | } |
@@ -7217,6 +7233,12 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, | |||
7217 | IWL_DEBUG_MAC80211("enter\n"); | 7233 | IWL_DEBUG_MAC80211("enter\n"); |
7218 | 7234 | ||
7219 | mutex_lock(&priv->mutex); | 7235 | mutex_lock(&priv->mutex); |
7236 | |||
7237 | iwl_scan_cancel_timeout(priv, 100); | ||
7238 | cancel_delayed_work(&priv->post_associate); | ||
7239 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7240 | iwl_commit_rxon(priv); | ||
7241 | |||
7220 | if (priv->interface_id == conf->if_id) { | 7242 | if (priv->interface_id == conf->if_id) { |
7221 | priv->interface_id = 0; | 7243 | priv->interface_id = 0; |
7222 | memset(priv->bssid, 0, ETH_ALEN); | 7244 | memset(priv->bssid, 0, ETH_ALEN); |
@@ -7238,6 +7260,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7238 | 7260 | ||
7239 | IWL_DEBUG_MAC80211("enter\n"); | 7261 | IWL_DEBUG_MAC80211("enter\n"); |
7240 | 7262 | ||
7263 | mutex_lock(&priv->mutex); | ||
7241 | spin_lock_irqsave(&priv->lock, flags); | 7264 | spin_lock_irqsave(&priv->lock, flags); |
7242 | 7265 | ||
7243 | if (!iwl_is_ready_rf(priv)) { | 7266 | if (!iwl_is_ready_rf(priv)) { |
@@ -7268,7 +7291,8 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7268 | priv->direct_ssid_len = (u8) | 7291 | priv->direct_ssid_len = (u8) |
7269 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); | 7292 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); |
7270 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); | 7293 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); |
7271 | } | 7294 | } else |
7295 | priv->one_direct_scan = 0; | ||
7272 | 7296 | ||
7273 | rc = iwl_scan_initiate(priv); | 7297 | rc = iwl_scan_initiate(priv); |
7274 | 7298 | ||
@@ -7276,6 +7300,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7276 | 7300 | ||
7277 | out_unlock: | 7301 | out_unlock: |
7278 | spin_unlock_irqrestore(&priv->lock, flags); | 7302 | spin_unlock_irqrestore(&priv->lock, flags); |
7303 | mutex_unlock(&priv->mutex); | ||
7279 | 7304 | ||
7280 | return rc; | 7305 | return rc; |
7281 | } | 7306 | } |
@@ -7310,6 +7335,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
7310 | 7335 | ||
7311 | mutex_lock(&priv->mutex); | 7336 | mutex_lock(&priv->mutex); |
7312 | 7337 | ||
7338 | iwl_scan_cancel_timeout(priv, 100); | ||
7339 | |||
7313 | switch (cmd) { | 7340 | switch (cmd) { |
7314 | case SET_KEY: | 7341 | case SET_KEY: |
7315 | rc = iwl_update_sta_key_info(priv, key, sta_id); | 7342 | rc = iwl_update_sta_key_info(priv, key, sta_id); |
@@ -7479,8 +7506,18 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) | |||
7479 | 7506 | ||
7480 | spin_unlock_irqrestore(&priv->lock, flags); | 7507 | spin_unlock_irqrestore(&priv->lock, flags); |
7481 | 7508 | ||
7509 | /* we are restarting association process | ||
7510 | * clear RXON_FILTER_ASSOC_MSK bit | ||
7511 | */ | ||
7512 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | ||
7513 | iwl_scan_cancel_timeout(priv, 100); | ||
7514 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7515 | iwl_commit_rxon(priv); | ||
7516 | } | ||
7517 | |||
7482 | /* Per mac80211.h: This is only used in IBSS mode... */ | 7518 | /* Per mac80211.h: This is only used in IBSS mode... */ |
7483 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { | 7519 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { |
7520 | |||
7484 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); | 7521 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); |
7485 | mutex_unlock(&priv->mutex); | 7522 | mutex_unlock(&priv->mutex); |
7486 | return; | 7523 | return; |
@@ -8558,6 +8595,9 @@ static void iwl_pci_remove(struct pci_dev *pdev) | |||
8558 | iwl_rate_control_unregister(priv->hw); | 8595 | iwl_rate_control_unregister(priv->hw); |
8559 | } | 8596 | } |
8560 | 8597 | ||
8598 | /*netif_stop_queue(dev); */ | ||
8599 | flush_workqueue(priv->workqueue); | ||
8600 | |||
8561 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes | 8601 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes |
8562 | * priv->workqueue... so we can't take down the workqueue | 8602 | * priv->workqueue... so we can't take down the workqueue |
8563 | * until now... */ | 8603 | * until now... */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 5e1279263b..d60adcb9bd 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -6845,8 +6845,9 @@ static void iwl_bg_scan_check(struct work_struct *data) | |||
6845 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | 6845 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, |
6846 | "Scan completion watchdog resetting adapter (%dms)\n", | 6846 | "Scan completion watchdog resetting adapter (%dms)\n", |
6847 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | 6847 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); |
6848 | |||
6848 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 6849 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
6849 | queue_work(priv->workqueue, &priv->restart); | 6850 | iwl_send_scan_abort(priv); |
6850 | } | 6851 | } |
6851 | mutex_unlock(&priv->mutex); | 6852 | mutex_unlock(&priv->mutex); |
6852 | } | 6853 | } |
@@ -6942,7 +6943,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6942 | spin_unlock_irqrestore(&priv->lock, flags); | 6943 | spin_unlock_irqrestore(&priv->lock, flags); |
6943 | 6944 | ||
6944 | scan->suspend_time = 0; | 6945 | scan->suspend_time = 0; |
6945 | scan->max_out_time = cpu_to_le32(600 * 1024); | 6946 | scan->max_out_time = cpu_to_le32(200 * 1024); |
6946 | if (!interval) | 6947 | if (!interval) |
6947 | interval = suspend_time; | 6948 | interval = suspend_time; |
6948 | 6949 | ||
@@ -6965,7 +6966,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6965 | memcpy(scan->direct_scan[0].ssid, | 6966 | memcpy(scan->direct_scan[0].ssid, |
6966 | priv->direct_ssid, priv->direct_ssid_len); | 6967 | priv->direct_ssid, priv->direct_ssid_len); |
6967 | direct_mask = 1; | 6968 | direct_mask = 1; |
6968 | } else if (!iwl_is_associated(priv)) { | 6969 | } else if (!iwl_is_associated(priv) && priv->essid_len) { |
6969 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6970 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6970 | scan->direct_scan[0].len = priv->essid_len; | 6971 | scan->direct_scan[0].len = priv->essid_len; |
6971 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 6972 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |
@@ -7118,6 +7119,12 @@ static void iwl_bg_post_associate(struct work_struct *data) | |||
7118 | 7119 | ||
7119 | mutex_lock(&priv->mutex); | 7120 | mutex_lock(&priv->mutex); |
7120 | 7121 | ||
7122 | if (!priv->interface_id || !priv->is_open) { | ||
7123 | mutex_unlock(&priv->mutex); | ||
7124 | return; | ||
7125 | } | ||
7126 | iwl_scan_cancel_timeout(priv, 200); | ||
7127 | |||
7121 | conf = ieee80211_get_hw_conf(priv->hw); | 7128 | conf = ieee80211_get_hw_conf(priv->hw); |
7122 | 7129 | ||
7123 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7130 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
@@ -7271,9 +7278,19 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) | |||
7271 | struct iwl_priv *priv = hw->priv; | 7278 | struct iwl_priv *priv = hw->priv; |
7272 | 7279 | ||
7273 | IWL_DEBUG_MAC80211("enter\n"); | 7280 | IWL_DEBUG_MAC80211("enter\n"); |
7281 | |||
7282 | |||
7283 | mutex_lock(&priv->mutex); | ||
7284 | /* stop mac, cancel any scan request and clear | ||
7285 | * RXON_FILTER_ASSOC_MSK BIT | ||
7286 | */ | ||
7274 | priv->is_open = 0; | 7287 | priv->is_open = 0; |
7275 | /*netif_stop_queue(dev); */ | 7288 | iwl_scan_cancel_timeout(priv, 100); |
7276 | flush_workqueue(priv->workqueue); | 7289 | cancel_delayed_work(&priv->post_associate); |
7290 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7291 | iwl_commit_rxon(priv); | ||
7292 | mutex_unlock(&priv->mutex); | ||
7293 | |||
7277 | IWL_DEBUG_MAC80211("leave\n"); | 7294 | IWL_DEBUG_MAC80211("leave\n"); |
7278 | } | 7295 | } |
7279 | 7296 | ||
@@ -7573,8 +7590,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7573 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) | 7590 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) |
7574 | iwl_config_ap(priv); | 7591 | iwl_config_ap(priv); |
7575 | else { | 7592 | else { |
7576 | priv->staging_rxon.filter_flags |= | ||
7577 | RXON_FILTER_ASSOC_MSK; | ||
7578 | rc = iwl_commit_rxon(priv); | 7593 | rc = iwl_commit_rxon(priv); |
7579 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 7594 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
7580 | iwl_rxon_add_station( | 7595 | iwl_rxon_add_station( |
@@ -7582,6 +7597,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7582 | } | 7597 | } |
7583 | 7598 | ||
7584 | } else { | 7599 | } else { |
7600 | iwl_scan_cancel_timeout(priv, 100); | ||
7585 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7601 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
7586 | iwl_commit_rxon(priv); | 7602 | iwl_commit_rxon(priv); |
7587 | } | 7603 | } |
@@ -7621,6 +7637,12 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, | |||
7621 | IWL_DEBUG_MAC80211("enter\n"); | 7637 | IWL_DEBUG_MAC80211("enter\n"); |
7622 | 7638 | ||
7623 | mutex_lock(&priv->mutex); | 7639 | mutex_lock(&priv->mutex); |
7640 | |||
7641 | iwl_scan_cancel_timeout(priv, 100); | ||
7642 | cancel_delayed_work(&priv->post_associate); | ||
7643 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7644 | iwl_commit_rxon(priv); | ||
7645 | |||
7624 | if (priv->interface_id == conf->if_id) { | 7646 | if (priv->interface_id == conf->if_id) { |
7625 | priv->interface_id = 0; | 7647 | priv->interface_id = 0; |
7626 | memset(priv->bssid, 0, ETH_ALEN); | 7648 | memset(priv->bssid, 0, ETH_ALEN); |
@@ -7642,6 +7664,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7642 | 7664 | ||
7643 | IWL_DEBUG_MAC80211("enter\n"); | 7665 | IWL_DEBUG_MAC80211("enter\n"); |
7644 | 7666 | ||
7667 | mutex_lock(&priv->mutex); | ||
7645 | spin_lock_irqsave(&priv->lock, flags); | 7668 | spin_lock_irqsave(&priv->lock, flags); |
7646 | 7669 | ||
7647 | if (!iwl_is_ready_rf(priv)) { | 7670 | if (!iwl_is_ready_rf(priv)) { |
@@ -7672,7 +7695,8 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7672 | priv->direct_ssid_len = (u8) | 7695 | priv->direct_ssid_len = (u8) |
7673 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); | 7696 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); |
7674 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); | 7697 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); |
7675 | } | 7698 | } else |
7699 | priv->one_direct_scan = 0; | ||
7676 | 7700 | ||
7677 | rc = iwl_scan_initiate(priv); | 7701 | rc = iwl_scan_initiate(priv); |
7678 | 7702 | ||
@@ -7680,6 +7704,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7680 | 7704 | ||
7681 | out_unlock: | 7705 | out_unlock: |
7682 | spin_unlock_irqrestore(&priv->lock, flags); | 7706 | spin_unlock_irqrestore(&priv->lock, flags); |
7707 | mutex_unlock(&priv->mutex); | ||
7683 | 7708 | ||
7684 | return rc; | 7709 | return rc; |
7685 | } | 7710 | } |
@@ -7713,6 +7738,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
7713 | 7738 | ||
7714 | mutex_lock(&priv->mutex); | 7739 | mutex_lock(&priv->mutex); |
7715 | 7740 | ||
7741 | iwl_scan_cancel_timeout(priv, 100); | ||
7742 | |||
7716 | switch (cmd) { | 7743 | switch (cmd) { |
7717 | case SET_KEY: | 7744 | case SET_KEY: |
7718 | rc = iwl_update_sta_key_info(priv, key, sta_id); | 7745 | rc = iwl_update_sta_key_info(priv, key, sta_id); |
@@ -7903,8 +7930,18 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) | |||
7903 | 7930 | ||
7904 | spin_unlock_irqrestore(&priv->lock, flags); | 7931 | spin_unlock_irqrestore(&priv->lock, flags); |
7905 | 7932 | ||
7933 | /* we are restarting association process | ||
7934 | * clear RXON_FILTER_ASSOC_MSK bit | ||
7935 | */ | ||
7936 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | ||
7937 | iwl_scan_cancel_timeout(priv, 100); | ||
7938 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7939 | iwl_commit_rxon(priv); | ||
7940 | } | ||
7941 | |||
7906 | /* Per mac80211.h: This is only used in IBSS mode... */ | 7942 | /* Per mac80211.h: This is only used in IBSS mode... */ |
7907 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { | 7943 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { |
7944 | |||
7908 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); | 7945 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); |
7909 | mutex_unlock(&priv->mutex); | 7946 | mutex_unlock(&priv->mutex); |
7910 | return; | 7947 | return; |
@@ -9152,6 +9189,9 @@ static void iwl_pci_remove(struct pci_dev *pdev) | |||
9152 | iwl_rate_control_unregister(priv->hw); | 9189 | iwl_rate_control_unregister(priv->hw); |
9153 | } | 9190 | } |
9154 | 9191 | ||
9192 | /*netif_stop_queue(dev); */ | ||
9193 | flush_workqueue(priv->workqueue); | ||
9194 | |||
9155 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes | 9195 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes |
9156 | * priv->workqueue... so we can't take down the workqueue | 9196 | * priv->workqueue... so we can't take down the workqueue |
9157 | * until now... */ | 9197 | * until now... */ |
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 298faa9d3f..06d9bc0015 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h | |||
@@ -30,7 +30,7 @@ | |||
30 | * Interval defines | 30 | * Interval defines |
31 | * Both the link tuner as the rfkill will be called once per second. | 31 | * Both the link tuner as the rfkill will be called once per second. |
32 | */ | 32 | */ |
33 | #define LINK_TUNE_INTERVAL ( round_jiffies(HZ) ) | 33 | #define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) ) |
34 | #define RFKILL_POLL_INTERVAL ( 1000 ) | 34 | #define RFKILL_POLL_INTERVAL ( 1000 ) |
35 | 35 | ||
36 | /* | 36 | /* |
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c index de61c8fe64..e454ae83e9 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c | |||
@@ -433,6 +433,9 @@ static int rtl8187_start(struct ieee80211_hw *dev) | |||
433 | 433 | ||
434 | rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); | 434 | rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); |
435 | 435 | ||
436 | rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); | ||
437 | rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); | ||
438 | |||
436 | rtl8187_init_urbs(dev); | 439 | rtl8187_init_urbs(dev); |
437 | 440 | ||
438 | reg = RTL818X_RX_CONF_ONLYERLPKT | | 441 | reg = RTL818X_RX_CONF_ONLYERLPKT | |
@@ -582,32 +585,31 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id, | |||
582 | static void rtl8187_configure_filter(struct ieee80211_hw *dev, | 585 | static void rtl8187_configure_filter(struct ieee80211_hw *dev, |
583 | unsigned int changed_flags, | 586 | unsigned int changed_flags, |
584 | unsigned int *total_flags, | 587 | unsigned int *total_flags, |
585 | int mc_count, struct dev_addr_list *mc_list) | 588 | int mc_count, struct dev_addr_list *mclist) |
586 | { | 589 | { |
587 | struct rtl8187_priv *priv = dev->priv; | 590 | struct rtl8187_priv *priv = dev->priv; |
588 | 591 | ||
589 | *total_flags = 0; | ||
590 | |||
591 | if (changed_flags & FIF_ALLMULTI) | ||
592 | priv->rx_conf ^= RTL818X_RX_CONF_MULTICAST; | ||
593 | if (changed_flags & FIF_FCSFAIL) | 592 | if (changed_flags & FIF_FCSFAIL) |
594 | priv->rx_conf ^= RTL818X_RX_CONF_FCS; | 593 | priv->rx_conf ^= RTL818X_RX_CONF_FCS; |
595 | if (changed_flags & FIF_CONTROL) | 594 | if (changed_flags & FIF_CONTROL) |
596 | priv->rx_conf ^= RTL818X_RX_CONF_CTRL; | 595 | priv->rx_conf ^= RTL818X_RX_CONF_CTRL; |
597 | if (changed_flags & FIF_OTHER_BSS) | 596 | if (changed_flags & FIF_OTHER_BSS) |
598 | priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; | 597 | priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; |
599 | 598 | if (*total_flags & FIF_ALLMULTI || mc_count > 0) | |
600 | if (mc_count > 0) | ||
601 | priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; | 599 | priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; |
600 | else | ||
601 | priv->rx_conf &= ~RTL818X_RX_CONF_MULTICAST; | ||
602 | |||
603 | *total_flags = 0; | ||
602 | 604 | ||
603 | if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) | ||
604 | *total_flags |= FIF_ALLMULTI; | ||
605 | if (priv->rx_conf & RTL818X_RX_CONF_FCS) | 605 | if (priv->rx_conf & RTL818X_RX_CONF_FCS) |
606 | *total_flags |= FIF_FCSFAIL; | 606 | *total_flags |= FIF_FCSFAIL; |
607 | if (priv->rx_conf & RTL818X_RX_CONF_CTRL) | 607 | if (priv->rx_conf & RTL818X_RX_CONF_CTRL) |
608 | *total_flags |= FIF_CONTROL; | 608 | *total_flags |= FIF_CONTROL; |
609 | if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) | 609 | if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) |
610 | *total_flags |= FIF_OTHER_BSS; | 610 | *total_flags |= FIF_OTHER_BSS; |
611 | if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) | ||
612 | *total_flags |= FIF_ALLMULTI; | ||
611 | 613 | ||
612 | rtl818x_iowrite32_async(priv, &priv->map->RX_CONF, priv->rx_conf); | 614 | rtl818x_iowrite32_async(priv, &priv->map->RX_CONF, priv->rx_conf); |
613 | } | 615 | } |
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index fd5d0c1570..0011849901 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -562,8 +562,6 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
562 | sg_init_table(sg_list->sg, sg_list->count); | 562 | sg_init_table(sg_list->sg, sg_list->count); |
563 | 563 | ||
564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { | 564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { |
565 | sg->length = min(size, PAGE_SIZE); | ||
566 | sg->offset = 0; | ||
567 | address = (void *) get_zeroed_page(GFP_KERNEL); | 565 | address = (void *) get_zeroed_page(GFP_KERNEL); |
568 | if (address == NULL) { | 566 | if (address == NULL) { |
569 | sg_list->count = i; | 567 | sg_list->count = i; |
@@ -571,7 +569,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
571 | retval = -ENOMEM; | 569 | retval = -ENOMEM; |
572 | goto out; | 570 | goto out; |
573 | } | 571 | } |
574 | zfcp_address_to_sg(address, sg); | 572 | zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE)); |
575 | size -= sg->length; | 573 | size -= sg->length; |
576 | } | 574 | } |
577 | 575 | ||
@@ -1518,13 +1516,13 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool) | |||
1518 | return -ENOMEM; | 1516 | return -ENOMEM; |
1519 | 1517 | ||
1520 | memset(data, 0, sizeof(*data)); | 1518 | memset(data, 0, sizeof(*data)); |
1519 | sg_init_table(&data->req , 1); | ||
1520 | sg_init_table(&data->resp , 1); | ||
1521 | data->ct.req = &data->req; | 1521 | data->ct.req = &data->req; |
1522 | data->ct.resp = &data->resp; | 1522 | data->ct.resp = &data->resp; |
1523 | data->ct.req_count = data->ct.resp_count = 1; | 1523 | data->ct.req_count = data->ct.resp_count = 1; |
1524 | zfcp_address_to_sg(&data->ct_iu_req, &data->req); | 1524 | zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req)); |
1525 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); | 1525 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp)); |
1526 | data->req.length = sizeof(struct ct_iu_gid_pn_req); | ||
1527 | data->resp.length = sizeof(struct ct_iu_gid_pn_resp); | ||
1528 | 1526 | ||
1529 | *gid_pn = data; | 1527 | *gid_pn = data; |
1530 | return 0; | 1528 | return 0; |
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 326e7ee232..0754542978 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h | |||
@@ -74,8 +74,7 @@ zfcp_sg_to_address(struct scatterlist *list) | |||
74 | static inline void | 74 | static inline void |
75 | zfcp_address_to_sg(void *address, struct scatterlist *list) | 75 | zfcp_address_to_sg(void *address, struct scatterlist *list) |
76 | { | 76 | { |
77 | sg_set_page(list, virt_to_page(address)); | 77 | sg_set_buf(list, address, 0); |
78 | list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); | ||
79 | } | 78 | } |
80 | 79 | ||
81 | #define REQUEST_LIST_SIZE 128 | 80 | #define REQUEST_LIST_SIZE 128 |
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 9438d0b287..5552b755c0 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
@@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
322 | if (address == NULL) | 322 | if (address == NULL) |
323 | goto nomem; | 323 | goto nomem; |
324 | 324 | ||
325 | zfcp_address_to_sg(address, send_els->req); | 325 | zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc)); |
326 | address += PAGE_SIZE >> 1; | 326 | address += PAGE_SIZE >> 1; |
327 | zfcp_address_to_sg(address, send_els->resp); | 327 | zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc)); |
328 | send_els->req_count = send_els->resp_count = 1; | 328 | send_els->req_count = send_els->resp_count = 1; |
329 | 329 | ||
330 | send_els->adapter = adapter; | 330 | send_els->adapter = adapter; |
@@ -336,9 +336,6 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
336 | adisc = zfcp_sg_to_address(send_els->req); | 336 | adisc = zfcp_sg_to_address(send_els->req); |
337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; | 337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; |
338 | 338 | ||
339 | send_els->req->length = sizeof(struct zfcp_ls_adisc); | ||
340 | send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc); | ||
341 | |||
342 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports | 339 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports |
343 | without FC-AL-2 capability, so we don't set it */ | 340 | without FC-AL-2 capability, so we don't set it */ |
344 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); | 341 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); |
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index d1780980fb..a9680b5e8a 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c | |||
@@ -477,10 +477,9 @@ static void merge_contiguous_buffers(Scsi_Cmnd *cmd) | |||
477 | 477 | ||
478 | for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; | 478 | for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; |
479 | cmd->SCp.buffers_residual && | 479 | cmd->SCp.buffers_residual && |
480 | virt_to_phys(page_address(cmd->SCp.buffer[1].page) + | 480 | virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) { |
481 | cmd->SCp.buffer[1].offset) == endaddr;) { | ||
482 | MER_PRINTK("VTOP(%p) == %08lx -> merging\n", | 481 | MER_PRINTK("VTOP(%p) == %08lx -> merging\n", |
483 | page_address(cmd->SCp.buffer[1].page), endaddr); | 482 | page_address(sg_page(&cmd->SCp.buffer[1])), endaddr); |
484 | #if (NDEBUG & NDEBUG_MERGING) | 483 | #if (NDEBUG & NDEBUG_MERGING) |
485 | ++cnt; | 484 | ++cnt; |
486 | #endif | 485 | #endif |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 439b97a6a2..0841df01bc 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) | |||
2890 | return NULL; | 2890 | return NULL; |
2891 | } | 2891 | } |
2892 | 2892 | ||
2893 | sg_set_page(&scatterlist[i], page); | 2893 | sg_set_page(&scatterlist[i], page, 0, 0); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | return sglist; | 2896 | return sglist; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 6ce4109efd..4bcf916c21 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -79,9 +79,7 @@ static inline void | |||
79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) | 79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) |
80 | { | 80 | { |
81 | sg_init_table(&ibuf->sg, 1); | 81 | sg_init_table(&ibuf->sg, 1); |
82 | sg_set_page(&ibuf->sg, sg_page(sg)); | 82 | sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset); |
83 | ibuf->sg.offset = sg->offset; | ||
84 | ibuf->sg.length = sg->length; | ||
85 | /* | 83 | /* |
86 | * Fastpath: sg element fits into single page | 84 | * Fastpath: sg element fits into single page |
87 | */ | 85 | */ |
@@ -676,9 +674,8 @@ partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg, | |||
676 | { | 674 | { |
677 | struct scatterlist temp; | 675 | struct scatterlist temp; |
678 | 676 | ||
679 | memcpy(&temp, sg, sizeof(struct scatterlist)); | 677 | sg_init_table(&temp, 1); |
680 | temp.offset = offset; | 678 | sg_set_page(&temp, sg_page(sg), length, offset); |
681 | temp.length = length; | ||
682 | crypto_hash_update(desc, &temp, length); | 679 | crypto_hash_update(desc, &temp, length); |
683 | } | 680 | } |
684 | 681 | ||
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 1c5c4b68f2..4652ad2251 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5256,8 +5256,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5256 | 5256 | ||
5257 | STbuffer->sg[0].offset = 0; | 5257 | STbuffer->sg[0].offset = 0; |
5258 | if (page != NULL) { | 5258 | if (page != NULL) { |
5259 | sg_set_page(&STbuffer->sg[0], page); | 5259 | sg_set_page(&STbuffer->sg[0], page, b_size, 0); |
5260 | STbuffer->sg[0].length = b_size; | ||
5261 | STbuffer->b_data = page_address(page); | 5260 | STbuffer->b_data = page_address(page); |
5262 | break; | 5261 | break; |
5263 | } | 5262 | } |
@@ -5285,8 +5284,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5285 | normalize_buffer(STbuffer); | 5284 | normalize_buffer(STbuffer); |
5286 | return 0; | 5285 | return 0; |
5287 | } | 5286 | } |
5288 | sg_set_page(&STbuffer->sg[segs], page); | 5287 | sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0); |
5289 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; | ||
5290 | got += STbuffer->sg[segs].length; | 5288 | got += STbuffer->sg[segs].length; |
5291 | STbuffer->buffer_size = got; | 5289 | STbuffer->buffer_size = got; |
5292 | STbuffer->sg_segs = ++segs; | 5290 | STbuffer->sg_segs = ++segs; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index cc19710028..b5fa4f0913 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1717,16 +1717,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, | |||
1717 | goto out_unlock; */ | 1717 | goto out_unlock; */ |
1718 | } | 1718 | } |
1719 | 1719 | ||
1720 | sg_set_page(sgl, pages[0]); | 1720 | sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK); |
1721 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
1722 | if (nr_pages > 1) { | 1721 | if (nr_pages > 1) { |
1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 1722 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
1724 | count -= sgl[0].length; | 1723 | count -= sgl[0].length; |
1725 | for (i=1; i < nr_pages ; i++) { | 1724 | for (i=1; i < nr_pages ; i++) |
1726 | sg_set_page(&sgl[i], pages[i]); | 1725 | sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0); |
1727 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
1728 | count -= PAGE_SIZE; | ||
1729 | } | ||
1730 | } | 1726 | } |
1731 | else { | 1727 | else { |
1732 | sgl[0].length = count; | 1728 | sgl[0].length = count; |
@@ -1854,8 +1850,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1854 | scatter_elem_sz_prev = ret_sz; | 1850 | scatter_elem_sz_prev = ret_sz; |
1855 | } | 1851 | } |
1856 | } | 1852 | } |
1857 | sg_set_page(sg, p); | 1853 | sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0); |
1858 | sg->length = (ret_sz > num) ? num : ret_sz; | ||
1859 | 1854 | ||
1860 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " | 1855 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " |
1861 | "ret_sz=%d\n", k, num, ret_sz)); | 1856 | "ret_sz=%d\n", k, num, ret_sz)); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index ce69b9efc1..98dfd6ea20 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3797,13 +3797,11 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length) | |||
3797 | sg = &(STbp->sg[0]); | 3797 | sg = &(STbp->sg[0]); |
3798 | frp = STbp->frp; | 3798 | frp = STbp->frp; |
3799 | for (i=count=0; count < length; i++) { | 3799 | for (i=count=0; count < length; i++) { |
3800 | sg_set_page(&sg[i], frp[i].page); | ||
3801 | if (length - count > frp[i].length) | 3800 | if (length - count > frp[i].length) |
3802 | sg[i].length = frp[i].length; | 3801 | sg_set_page(&sg[i], frp[i].page, frp[i].length, 0); |
3803 | else | 3802 | else |
3804 | sg[i].length = length - count; | 3803 | sg_set_page(&sg[i], frp[i].page, length - count, 0); |
3805 | count += sg[i].length; | 3804 | count += sg[i].length; |
3806 | sg[i].offset = 0; | ||
3807 | } | 3805 | } |
3808 | STbp->sg_segs = i; | 3806 | STbp->sg_segs = i; |
3809 | STbp->frp_sg_current = length; | 3807 | STbp->frp_sg_current = length; |
@@ -4446,15 +4444,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa | |||
4446 | } | 4444 | } |
4447 | 4445 | ||
4448 | /* Populate the scatter/gather list */ | 4446 | /* Populate the scatter/gather list */ |
4449 | sg_set_page(&sgl[0], pages[0]); | 4447 | sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK); |
4450 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
4451 | if (nr_pages > 1) { | 4448 | if (nr_pages > 1) { |
4452 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 4449 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
4453 | count -= sgl[0].length; | 4450 | count -= sgl[0].length; |
4454 | for (i=1; i < nr_pages ; i++) { | 4451 | for (i=1; i < nr_pages ; i++) { |
4455 | sg_set_page(&sgl[i], pages[i]);; | 4452 | sg_set_page(&sgl[i], pages[i], |
4456 | sgl[i].offset = 0; | 4453 | count < PAGE_SIZE ? count : PAGE_SIZE, 0);; |
4457 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
4458 | count -= PAGE_SIZE; | 4454 | count -= PAGE_SIZE; |
4459 | } | 4455 | } |
4460 | } | 4456 | } |
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c index 80fb3f88af..1bc41907a0 100644 --- a/drivers/scsi/sun3x_esp.c +++ b/drivers/scsi/sun3x_esp.c | |||
@@ -332,8 +332,8 @@ static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
332 | struct scatterlist *sg = sp->SCp.buffer; | 332 | struct scatterlist *sg = sp->SCp.buffer; |
333 | 333 | ||
334 | while (sz >= 0) { | 334 | while (sz >= 0) { |
335 | sg[sz].dma_address = dvma_map((unsigned long)page_address(sg[sz].page) + | 335 | sg[sz].dma_address = dvma_map((unsigned long)sg_virt(&sg[sz]), |
336 | sg[sz].offset, sg[sz].length); | 336 | sg[sz].length); |
337 | sz--; | 337 | sz--; |
338 | } | 338 | } |
339 | sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); | 339 | sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 103189095c..3bb5d241dd 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1875,6 +1875,7 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1875 | int baud, int parity, int bits, int flow) | 1875 | int baud, int parity, int bits, int flow) |
1876 | { | 1876 | { |
1877 | struct ktermios termios; | 1877 | struct ktermios termios; |
1878 | static struct ktermios dummy; | ||
1878 | int i; | 1879 | int i; |
1879 | 1880 | ||
1880 | /* | 1881 | /* |
@@ -1920,7 +1921,7 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1920 | */ | 1921 | */ |
1921 | port->mctrl |= TIOCM_DTR; | 1922 | port->mctrl |= TIOCM_DTR; |
1922 | 1923 | ||
1923 | port->ops->set_termios(port, &termios, NULL); | 1924 | port->ops->set_termios(port, &termios, &dummy); |
1924 | co->cflag = termios.c_cflag; | 1925 | co->cflag = termios.c_cflag; |
1925 | 1926 | ||
1926 | return 0; | 1927 | return 0; |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 8bdaa157ff..eb4ac47612 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1641,7 +1641,13 @@ free_interfaces: | |||
1641 | intf->dev.bus_id, ret); | 1641 | intf->dev.bus_id, ret); |
1642 | continue; | 1642 | continue; |
1643 | } | 1643 | } |
1644 | usb_create_sysfs_intf_files (intf); | 1644 | |
1645 | /* The driver's probe method can call usb_set_interface(), | ||
1646 | * which would mean the interface's sysfs files are already | ||
1647 | * created. Just in case, we'll remove them first. | ||
1648 | */ | ||
1649 | usb_remove_sysfs_intf_files(intf); | ||
1650 | usb_create_sysfs_intf_files(intf); | ||
1645 | } | 1651 | } |
1646 | 1652 | ||
1647 | usb_autosuspend_device(dev); | 1653 | usb_autosuspend_device(dev); |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c20c03aaf0..d05ead2008 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -372,7 +372,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
372 | 372 | ||
373 | /* enforce simple/standard policy */ | 373 | /* enforce simple/standard policy */ |
374 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | | 374 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | |
375 | URB_NO_INTERRUPT | URB_DIR_MASK); | 375 | URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER); |
376 | switch (xfertype) { | 376 | switch (xfertype) { |
377 | case USB_ENDPOINT_XFER_BULK: | 377 | case USB_ENDPOINT_XFER_BULK: |
378 | if (is_out) | 378 | if (is_out) |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 1c80406025..c72e9620bf 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -3289,7 +3289,7 @@ static int udc_pci_probe( | |||
3289 | dev->chiprev = pdev->revision; | 3289 | dev->chiprev = pdev->revision; |
3290 | 3290 | ||
3291 | pci_set_master(pdev); | 3291 | pci_set_master(pdev); |
3292 | pci_set_mwi(pdev); | 3292 | pci_try_set_mwi(pdev); |
3293 | 3293 | ||
3294 | /* init dma pools */ | 3294 | /* init dma pools */ |
3295 | if (use_dma) { | 3295 | if (use_dma) { |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index c978d622fa..177e78ed24 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI | |||
156 | 156 | ||
157 | config USB_OHCI_HCD_SSB | 157 | config USB_OHCI_HCD_SSB |
158 | bool "OHCI support for Broadcom SSB OHCI core" | 158 | bool "OHCI support for Broadcom SSB OHCI core" |
159 | depends on USB_OHCI_HCD && SSB && EXPERIMENTAL | 159 | depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL |
160 | default n | 160 | default n |
161 | ---help--- | 161 | ---help--- |
162 | Support for the Sonics Silicon Backplane (SSB) attached | 162 | Support for the Sonics Silicon Backplane (SSB) attached |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 240c7f5075..704f33fdd2 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -80,7 +80,10 @@ static const char hcd_name [] = "ohci_hcd"; | |||
80 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); | 80 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); |
81 | static int ohci_init (struct ohci_hcd *ohci); | 81 | static int ohci_init (struct ohci_hcd *ohci); |
82 | static void ohci_stop (struct usb_hcd *hcd); | 82 | static void ohci_stop (struct usb_hcd *hcd); |
83 | |||
84 | #if defined(CONFIG_PM) || defined(CONFIG_PCI) | ||
83 | static int ohci_restart (struct ohci_hcd *ohci); | 85 | static int ohci_restart (struct ohci_hcd *ohci); |
86 | #endif | ||
84 | 87 | ||
85 | #include "ohci-hub.c" | 88 | #include "ohci-hub.c" |
86 | #include "ohci-dbg.c" | 89 | #include "ohci-dbg.c" |
@@ -396,7 +399,7 @@ static int check_ed(struct ohci_hcd *ohci, struct ed *ed) | |||
396 | */ | 399 | */ |
397 | static void unlink_watchdog_func(unsigned long _ohci) | 400 | static void unlink_watchdog_func(unsigned long _ohci) |
398 | { | 401 | { |
399 | long flags; | 402 | unsigned long flags; |
400 | unsigned max; | 403 | unsigned max; |
401 | unsigned seen_count = 0; | 404 | unsigned seen_count = 0; |
402 | unsigned i; | 405 | unsigned i; |
@@ -893,6 +896,8 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
893 | 896 | ||
894 | /*-------------------------------------------------------------------------*/ | 897 | /*-------------------------------------------------------------------------*/ |
895 | 898 | ||
899 | #if defined(CONFIG_PM) || defined(CONFIG_PCI) | ||
900 | |||
896 | /* must not be called from interrupt context */ | 901 | /* must not be called from interrupt context */ |
897 | static int ohci_restart (struct ohci_hcd *ohci) | 902 | static int ohci_restart (struct ohci_hcd *ohci) |
898 | { | 903 | { |
@@ -954,6 +959,8 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
954 | return 0; | 959 | return 0; |
955 | } | 960 | } |
956 | 961 | ||
962 | #endif | ||
963 | |||
957 | /*-------------------------------------------------------------------------*/ | 964 | /*-------------------------------------------------------------------------*/ |
958 | 965 | ||
959 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 966 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index e5d60d5b10..60379b17bb 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -1271,7 +1271,8 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1271 | } else if (qh->period != urb->interval) { | 1271 | } else if (qh->period != urb->interval) { |
1272 | return -EINVAL; /* Can't change the period */ | 1272 | return -EINVAL; /* Can't change the period */ |
1273 | 1273 | ||
1274 | } else { /* Pick up where the last URB leaves off */ | 1274 | } else { |
1275 | /* Find the next unused frame */ | ||
1275 | if (list_empty(&qh->queue)) { | 1276 | if (list_empty(&qh->queue)) { |
1276 | frame = qh->iso_frame; | 1277 | frame = qh->iso_frame; |
1277 | } else { | 1278 | } else { |
@@ -1283,10 +1284,18 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1283 | lurb->number_of_packets * | 1284 | lurb->number_of_packets * |
1284 | lurb->interval; | 1285 | lurb->interval; |
1285 | } | 1286 | } |
1286 | if (urb->transfer_flags & URB_ISO_ASAP) | 1287 | if (urb->transfer_flags & URB_ISO_ASAP) { |
1287 | urb->start_frame = frame; | 1288 | /* Skip some frames if necessary to insure |
1288 | else if (urb->start_frame != frame) | 1289 | * the start frame is in the future. |
1289 | return -EINVAL; | 1290 | */ |
1291 | uhci_get_current_frame_number(uhci); | ||
1292 | if (uhci_frame_before_eq(frame, uhci->frame_number)) { | ||
1293 | frame = uhci->frame_number + 1; | ||
1294 | frame += ((qh->phase - frame) & | ||
1295 | (qh->period - 1)); | ||
1296 | } | ||
1297 | } /* Otherwise pick up where the last URB leaves off */ | ||
1298 | urb->start_frame = frame; | ||
1290 | } | 1299 | } |
1291 | 1300 | ||
1292 | /* Make sure we won't have to go too far into the future */ | 1301 | /* Make sure we won't have to go too far into the future */ |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 2677fea147..1cd9e7eba9 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -399,7 +399,6 @@ static void cytherm_disconnect(struct usb_interface *interface) | |||
399 | struct usb_cytherm *dev; | 399 | struct usb_cytherm *dev; |
400 | 400 | ||
401 | dev = usb_get_intfdata (interface); | 401 | dev = usb_get_intfdata (interface); |
402 | usb_set_intfdata (interface, NULL); | ||
403 | 402 | ||
404 | device_remove_file(&interface->dev, &dev_attr_brightness); | 403 | device_remove_file(&interface->dev, &dev_attr_brightness); |
405 | device_remove_file(&interface->dev, &dev_attr_temp); | 404 | device_remove_file(&interface->dev, &dev_attr_temp); |
@@ -407,6 +406,9 @@ static void cytherm_disconnect(struct usb_interface *interface) | |||
407 | device_remove_file(&interface->dev, &dev_attr_port0); | 406 | device_remove_file(&interface->dev, &dev_attr_port0); |
408 | device_remove_file(&interface->dev, &dev_attr_port1); | 407 | device_remove_file(&interface->dev, &dev_attr_port1); |
409 | 408 | ||
409 | /* first remove the files, then NULL the pointer */ | ||
410 | usb_set_intfdata (interface, NULL); | ||
411 | |||
410 | usb_put_dev(dev->udev); | 412 | usb_put_dev(dev->udev); |
411 | 413 | ||
412 | kfree(dev); | 414 | kfree(dev); |
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index cd137577bb..4a09b87bdd 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -114,6 +114,10 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
114 | 114 | ||
115 | /* De-assert reset (let the CPU run) */ | 115 | /* De-assert reset (let the CPU run) */ |
116 | err = emi26_set_reset(dev,0); | 116 | err = emi26_set_reset(dev,0); |
117 | if (err < 0) { | ||
118 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | ||
119 | goto wraperr; | ||
120 | } | ||
117 | msleep(250); /* let device settle */ | 121 | msleep(250); /* let device settle */ |
118 | 122 | ||
119 | /* 2. We upload the FPGA firmware into the EMI | 123 | /* 2. We upload the FPGA firmware into the EMI |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 4758cc5cce..d136241592 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -123,6 +123,10 @@ static int emi62_load_firmware (struct usb_device *dev) | |||
123 | 123 | ||
124 | /* De-assert reset (let the CPU run) */ | 124 | /* De-assert reset (let the CPU run) */ |
125 | err = emi62_set_reset(dev,0); | 125 | err = emi62_set_reset(dev,0); |
126 | if (err < 0) { | ||
127 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | ||
128 | goto wraperr; | ||
129 | } | ||
126 | msleep(250); /* let device settle */ | 130 | msleep(250); /* let device settle */ |
127 | 131 | ||
128 | /* 2. We upload the FPGA firmware into the EMI | 132 | /* 2. We upload the FPGA firmware into the EMI |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index d3d8cd6ff1..148b7fe639 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -147,7 +147,7 @@ struct u132_target { | |||
147 | /* Structure to hold all of our device specific stuff*/ | 147 | /* Structure to hold all of our device specific stuff*/ |
148 | struct usb_ftdi { | 148 | struct usb_ftdi { |
149 | struct list_head ftdi_list; | 149 | struct list_head ftdi_list; |
150 | struct semaphore u132_lock; | 150 | struct mutex u132_lock; |
151 | int command_next; | 151 | int command_next; |
152 | int command_head; | 152 | int command_head; |
153 | struct u132_command command[COMMAND_SIZE]; | 153 | struct u132_command command[COMMAND_SIZE]; |
@@ -330,39 +330,39 @@ static int ftdi_elan_hcd_init(struct usb_ftdi *ftdi) | |||
330 | 330 | ||
331 | static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) | 331 | static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) |
332 | { | 332 | { |
333 | down(&ftdi->u132_lock); | 333 | mutex_lock(&ftdi->u132_lock); |
334 | while (ftdi->respond_next > ftdi->respond_head) { | 334 | while (ftdi->respond_next > ftdi->respond_head) { |
335 | struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & | 335 | struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & |
336 | ftdi->respond_head++]; | 336 | ftdi->respond_head++]; |
337 | *respond->result = -ESHUTDOWN; | 337 | *respond->result = -ESHUTDOWN; |
338 | *respond->value = 0; | 338 | *respond->value = 0; |
339 | complete(&respond->wait_completion); | 339 | complete(&respond->wait_completion); |
340 | } up(&ftdi->u132_lock); | 340 | } mutex_unlock(&ftdi->u132_lock); |
341 | } | 341 | } |
342 | 342 | ||
343 | static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) | 343 | static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) |
344 | { | 344 | { |
345 | int ed_number = 4; | 345 | int ed_number = 4; |
346 | down(&ftdi->u132_lock); | 346 | mutex_lock(&ftdi->u132_lock); |
347 | while (ed_number-- > 0) { | 347 | while (ed_number-- > 0) { |
348 | struct u132_target *target = &ftdi->target[ed_number]; | 348 | struct u132_target *target = &ftdi->target[ed_number]; |
349 | if (target->active == 1) { | 349 | if (target->active == 1) { |
350 | target->condition_code = TD_DEVNOTRESP; | 350 | target->condition_code = TD_DEVNOTRESP; |
351 | up(&ftdi->u132_lock); | 351 | mutex_unlock(&ftdi->u132_lock); |
352 | ftdi_elan_do_callback(ftdi, target, NULL, 0); | 352 | ftdi_elan_do_callback(ftdi, target, NULL, 0); |
353 | down(&ftdi->u132_lock); | 353 | mutex_lock(&ftdi->u132_lock); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | ftdi->recieved = 0; | 356 | ftdi->recieved = 0; |
357 | ftdi->expected = 4; | 357 | ftdi->expected = 4; |
358 | ftdi->ed_found = 0; | 358 | ftdi->ed_found = 0; |
359 | up(&ftdi->u132_lock); | 359 | mutex_unlock(&ftdi->u132_lock); |
360 | } | 360 | } |
361 | 361 | ||
362 | static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | 362 | static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) |
363 | { | 363 | { |
364 | int ed_number = 4; | 364 | int ed_number = 4; |
365 | down(&ftdi->u132_lock); | 365 | mutex_lock(&ftdi->u132_lock); |
366 | while (ed_number-- > 0) { | 366 | while (ed_number-- > 0) { |
367 | struct u132_target *target = &ftdi->target[ed_number]; | 367 | struct u132_target *target = &ftdi->target[ed_number]; |
368 | target->abandoning = 1; | 368 | target->abandoning = 1; |
@@ -382,9 +382,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
382 | ftdi->command_next += 1; | 382 | ftdi->command_next += 1; |
383 | ftdi_elan_kick_command_queue(ftdi); | 383 | ftdi_elan_kick_command_queue(ftdi); |
384 | } else { | 384 | } else { |
385 | up(&ftdi->u132_lock); | 385 | mutex_unlock(&ftdi->u132_lock); |
386 | msleep(100); | 386 | msleep(100); |
387 | down(&ftdi->u132_lock); | 387 | mutex_lock(&ftdi->u132_lock); |
388 | goto wait_1; | 388 | goto wait_1; |
389 | } | 389 | } |
390 | } | 390 | } |
@@ -404,9 +404,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
404 | ftdi->command_next += 1; | 404 | ftdi->command_next += 1; |
405 | ftdi_elan_kick_command_queue(ftdi); | 405 | ftdi_elan_kick_command_queue(ftdi); |
406 | } else { | 406 | } else { |
407 | up(&ftdi->u132_lock); | 407 | mutex_unlock(&ftdi->u132_lock); |
408 | msleep(100); | 408 | msleep(100); |
409 | down(&ftdi->u132_lock); | 409 | mutex_lock(&ftdi->u132_lock); |
410 | goto wait_2; | 410 | goto wait_2; |
411 | } | 411 | } |
412 | } | 412 | } |
@@ -414,13 +414,13 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
414 | ftdi->recieved = 0; | 414 | ftdi->recieved = 0; |
415 | ftdi->expected = 4; | 415 | ftdi->expected = 4; |
416 | ftdi->ed_found = 0; | 416 | ftdi->ed_found = 0; |
417 | up(&ftdi->u132_lock); | 417 | mutex_unlock(&ftdi->u132_lock); |
418 | } | 418 | } |
419 | 419 | ||
420 | static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | 420 | static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) |
421 | { | 421 | { |
422 | int ed_number = 4; | 422 | int ed_number = 4; |
423 | down(&ftdi->u132_lock); | 423 | mutex_lock(&ftdi->u132_lock); |
424 | while (ed_number-- > 0) { | 424 | while (ed_number-- > 0) { |
425 | struct u132_target *target = &ftdi->target[ed_number]; | 425 | struct u132_target *target = &ftdi->target[ed_number]; |
426 | target->abandoning = 1; | 426 | target->abandoning = 1; |
@@ -440,9 +440,9 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | |||
440 | ftdi->command_next += 1; | 440 | ftdi->command_next += 1; |
441 | ftdi_elan_kick_command_queue(ftdi); | 441 | ftdi_elan_kick_command_queue(ftdi); |
442 | } else { | 442 | } else { |
443 | up(&ftdi->u132_lock); | 443 | mutex_unlock(&ftdi->u132_lock); |
444 | msleep(100); | 444 | msleep(100); |
445 | down(&ftdi->u132_lock); | 445 | mutex_lock(&ftdi->u132_lock); |
446 | goto wait; | 446 | goto wait; |
447 | } | 447 | } |
448 | } | 448 | } |
@@ -450,7 +450,7 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | |||
450 | ftdi->recieved = 0; | 450 | ftdi->recieved = 0; |
451 | ftdi->expected = 4; | 451 | ftdi->expected = 4; |
452 | ftdi->ed_found = 0; | 452 | ftdi->ed_found = 0; |
453 | up(&ftdi->u132_lock); | 453 | mutex_unlock(&ftdi->u132_lock); |
454 | } | 454 | } |
455 | 455 | ||
456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) | 456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) |
@@ -886,14 +886,14 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
886 | char *b) | 886 | char *b) |
887 | { | 887 | { |
888 | int payload = (ed_length >> 0) & 0x07FF; | 888 | int payload = (ed_length >> 0) & 0x07FF; |
889 | down(&ftdi->u132_lock); | 889 | mutex_lock(&ftdi->u132_lock); |
890 | target->actual = 0; | 890 | target->actual = 0; |
891 | target->non_null = (ed_length >> 15) & 0x0001; | 891 | target->non_null = (ed_length >> 15) & 0x0001; |
892 | target->repeat_number = (ed_length >> 11) & 0x000F; | 892 | target->repeat_number = (ed_length >> 11) & 0x000F; |
893 | if (ed_type == 0x02) { | 893 | if (ed_type == 0x02) { |
894 | if (payload == 0 || target->abandoning > 0) { | 894 | if (payload == 0 || target->abandoning > 0) { |
895 | target->abandoning = 0; | 895 | target->abandoning = 0; |
896 | up(&ftdi->u132_lock); | 896 | mutex_unlock(&ftdi->u132_lock); |
897 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 897 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
898 | payload); | 898 | payload); |
899 | ftdi->recieved = 0; | 899 | ftdi->recieved = 0; |
@@ -903,13 +903,13 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
903 | } else { | 903 | } else { |
904 | ftdi->expected = 4 + payload; | 904 | ftdi->expected = 4 + payload; |
905 | ftdi->ed_found = 1; | 905 | ftdi->ed_found = 1; |
906 | up(&ftdi->u132_lock); | 906 | mutex_unlock(&ftdi->u132_lock); |
907 | return b; | 907 | return b; |
908 | } | 908 | } |
909 | } else if (ed_type == 0x03) { | 909 | } else if (ed_type == 0x03) { |
910 | if (payload == 0 || target->abandoning > 0) { | 910 | if (payload == 0 || target->abandoning > 0) { |
911 | target->abandoning = 0; | 911 | target->abandoning = 0; |
912 | up(&ftdi->u132_lock); | 912 | mutex_unlock(&ftdi->u132_lock); |
913 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 913 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
914 | payload); | 914 | payload); |
915 | ftdi->recieved = 0; | 915 | ftdi->recieved = 0; |
@@ -919,12 +919,12 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
919 | } else { | 919 | } else { |
920 | ftdi->expected = 4 + payload; | 920 | ftdi->expected = 4 + payload; |
921 | ftdi->ed_found = 1; | 921 | ftdi->ed_found = 1; |
922 | up(&ftdi->u132_lock); | 922 | mutex_unlock(&ftdi->u132_lock); |
923 | return b; | 923 | return b; |
924 | } | 924 | } |
925 | } else if (ed_type == 0x01) { | 925 | } else if (ed_type == 0x01) { |
926 | target->abandoning = 0; | 926 | target->abandoning = 0; |
927 | up(&ftdi->u132_lock); | 927 | mutex_unlock(&ftdi->u132_lock); |
928 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 928 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
929 | payload); | 929 | payload); |
930 | ftdi->recieved = 0; | 930 | ftdi->recieved = 0; |
@@ -933,7 +933,7 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
933 | return ftdi->response; | 933 | return ftdi->response; |
934 | } else { | 934 | } else { |
935 | target->abandoning = 0; | 935 | target->abandoning = 0; |
936 | up(&ftdi->u132_lock); | 936 | mutex_unlock(&ftdi->u132_lock); |
937 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 937 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
938 | payload); | 938 | payload); |
939 | ftdi->recieved = 0; | 939 | ftdi->recieved = 0; |
@@ -947,12 +947,12 @@ static char *have_ed_get_response(struct usb_ftdi *ftdi, | |||
947 | struct u132_target *target, u16 ed_length, int ed_number, int ed_type, | 947 | struct u132_target *target, u16 ed_length, int ed_number, int ed_type, |
948 | char *b) | 948 | char *b) |
949 | { | 949 | { |
950 | down(&ftdi->u132_lock); | 950 | mutex_lock(&ftdi->u132_lock); |
951 | target->condition_code = TD_DEVNOTRESP; | 951 | target->condition_code = TD_DEVNOTRESP; |
952 | target->actual = (ed_length >> 0) & 0x01FF; | 952 | target->actual = (ed_length >> 0) & 0x01FF; |
953 | target->non_null = (ed_length >> 15) & 0x0001; | 953 | target->non_null = (ed_length >> 15) & 0x0001; |
954 | target->repeat_number = (ed_length >> 11) & 0x000F; | 954 | target->repeat_number = (ed_length >> 11) & 0x000F; |
955 | up(&ftdi->u132_lock); | 955 | mutex_unlock(&ftdi->u132_lock); |
956 | if (target->active) | 956 | if (target->active) |
957 | ftdi_elan_do_callback(ftdi, target, NULL, 0); | 957 | ftdi_elan_do_callback(ftdi, target, NULL, 0); |
958 | target->abandoning = 0; | 958 | target->abandoning = 0; |
@@ -1278,7 +1278,7 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) | |||
1278 | return -ENODEV; | 1278 | return -ENODEV; |
1279 | } else { | 1279 | } else { |
1280 | int command_size; | 1280 | int command_size; |
1281 | down(&ftdi->u132_lock); | 1281 | mutex_lock(&ftdi->u132_lock); |
1282 | command_size = ftdi->command_next - ftdi->command_head; | 1282 | command_size = ftdi->command_next - ftdi->command_head; |
1283 | if (command_size < COMMAND_SIZE) { | 1283 | if (command_size < COMMAND_SIZE) { |
1284 | struct u132_command *command = &ftdi->command[ | 1284 | struct u132_command *command = &ftdi->command[ |
@@ -1292,10 +1292,10 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) | |||
1292 | command->buffer = &command->value; | 1292 | command->buffer = &command->value; |
1293 | ftdi->command_next += 1; | 1293 | ftdi->command_next += 1; |
1294 | ftdi_elan_kick_command_queue(ftdi); | 1294 | ftdi_elan_kick_command_queue(ftdi); |
1295 | up(&ftdi->u132_lock); | 1295 | mutex_unlock(&ftdi->u132_lock); |
1296 | return 0; | 1296 | return 0; |
1297 | } else { | 1297 | } else { |
1298 | up(&ftdi->u132_lock); | 1298 | mutex_unlock(&ftdi->u132_lock); |
1299 | msleep(100); | 1299 | msleep(100); |
1300 | goto wait; | 1300 | goto wait; |
1301 | } | 1301 | } |
@@ -1310,7 +1310,7 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, | |||
1310 | return -ENODEV; | 1310 | return -ENODEV; |
1311 | } else { | 1311 | } else { |
1312 | int command_size; | 1312 | int command_size; |
1313 | down(&ftdi->u132_lock); | 1313 | mutex_lock(&ftdi->u132_lock); |
1314 | command_size = ftdi->command_next - ftdi->command_head; | 1314 | command_size = ftdi->command_next - ftdi->command_head; |
1315 | if (command_size < COMMAND_SIZE) { | 1315 | if (command_size < COMMAND_SIZE) { |
1316 | struct u132_command *command = &ftdi->command[ | 1316 | struct u132_command *command = &ftdi->command[ |
@@ -1324,10 +1324,10 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, | |||
1324 | command->buffer = &command->value; | 1324 | command->buffer = &command->value; |
1325 | ftdi->command_next += 1; | 1325 | ftdi->command_next += 1; |
1326 | ftdi_elan_kick_command_queue(ftdi); | 1326 | ftdi_elan_kick_command_queue(ftdi); |
1327 | up(&ftdi->u132_lock); | 1327 | mutex_unlock(&ftdi->u132_lock); |
1328 | return 0; | 1328 | return 0; |
1329 | } else { | 1329 | } else { |
1330 | up(&ftdi->u132_lock); | 1330 | mutex_unlock(&ftdi->u132_lock); |
1331 | msleep(100); | 1331 | msleep(100); |
1332 | goto wait; | 1332 | goto wait; |
1333 | } | 1333 | } |
@@ -1342,7 +1342,7 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1342 | return -ENODEV; | 1342 | return -ENODEV; |
1343 | } else { | 1343 | } else { |
1344 | int command_size; | 1344 | int command_size; |
1345 | down(&ftdi->u132_lock); | 1345 | mutex_lock(&ftdi->u132_lock); |
1346 | command_size = ftdi->command_next - ftdi->command_head; | 1346 | command_size = ftdi->command_next - ftdi->command_head; |
1347 | if (command_size < COMMAND_SIZE) { | 1347 | if (command_size < COMMAND_SIZE) { |
1348 | struct u132_command *command = &ftdi->command[ | 1348 | struct u132_command *command = &ftdi->command[ |
@@ -1356,10 +1356,10 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1356 | command->buffer = &command->value; | 1356 | command->buffer = &command->value; |
1357 | ftdi->command_next += 1; | 1357 | ftdi->command_next += 1; |
1358 | ftdi_elan_kick_command_queue(ftdi); | 1358 | ftdi_elan_kick_command_queue(ftdi); |
1359 | up(&ftdi->u132_lock); | 1359 | mutex_unlock(&ftdi->u132_lock); |
1360 | return 0; | 1360 | return 0; |
1361 | } else { | 1361 | } else { |
1362 | up(&ftdi->u132_lock); | 1362 | mutex_unlock(&ftdi->u132_lock); |
1363 | msleep(100); | 1363 | msleep(100); |
1364 | goto wait; | 1364 | goto wait; |
1365 | } | 1365 | } |
@@ -1382,7 +1382,7 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) | |||
1382 | } else { | 1382 | } else { |
1383 | int command_size; | 1383 | int command_size; |
1384 | int respond_size; | 1384 | int respond_size; |
1385 | down(&ftdi->u132_lock); | 1385 | mutex_lock(&ftdi->u132_lock); |
1386 | command_size = ftdi->command_next - ftdi->command_head; | 1386 | command_size = ftdi->command_next - ftdi->command_head; |
1387 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1387 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1388 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1388 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1405,11 +1405,11 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) | |||
1405 | ftdi->command_next += 1; | 1405 | ftdi->command_next += 1; |
1406 | ftdi->respond_next += 1; | 1406 | ftdi->respond_next += 1; |
1407 | ftdi_elan_kick_command_queue(ftdi); | 1407 | ftdi_elan_kick_command_queue(ftdi); |
1408 | up(&ftdi->u132_lock); | 1408 | mutex_unlock(&ftdi->u132_lock); |
1409 | wait_for_completion(&respond->wait_completion); | 1409 | wait_for_completion(&respond->wait_completion); |
1410 | return result; | 1410 | return result; |
1411 | } else { | 1411 | } else { |
1412 | up(&ftdi->u132_lock); | 1412 | mutex_unlock(&ftdi->u132_lock); |
1413 | msleep(100); | 1413 | msleep(100); |
1414 | goto wait; | 1414 | goto wait; |
1415 | } | 1415 | } |
@@ -1425,7 +1425,7 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, | |||
1425 | } else { | 1425 | } else { |
1426 | int command_size; | 1426 | int command_size; |
1427 | int respond_size; | 1427 | int respond_size; |
1428 | down(&ftdi->u132_lock); | 1428 | mutex_lock(&ftdi->u132_lock); |
1429 | command_size = ftdi->command_next - ftdi->command_head; | 1429 | command_size = ftdi->command_next - ftdi->command_head; |
1430 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1430 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1431 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1431 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1449,11 +1449,11 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, | |||
1449 | ftdi->command_next += 1; | 1449 | ftdi->command_next += 1; |
1450 | ftdi->respond_next += 1; | 1450 | ftdi->respond_next += 1; |
1451 | ftdi_elan_kick_command_queue(ftdi); | 1451 | ftdi_elan_kick_command_queue(ftdi); |
1452 | up(&ftdi->u132_lock); | 1452 | mutex_unlock(&ftdi->u132_lock); |
1453 | wait_for_completion(&respond->wait_completion); | 1453 | wait_for_completion(&respond->wait_completion); |
1454 | return result; | 1454 | return result; |
1455 | } else { | 1455 | } else { |
1456 | up(&ftdi->u132_lock); | 1456 | mutex_unlock(&ftdi->u132_lock); |
1457 | msleep(100); | 1457 | msleep(100); |
1458 | goto wait; | 1458 | goto wait; |
1459 | } | 1459 | } |
@@ -1469,7 +1469,7 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1469 | } else { | 1469 | } else { |
1470 | int command_size; | 1470 | int command_size; |
1471 | int respond_size; | 1471 | int respond_size; |
1472 | down(&ftdi->u132_lock); | 1472 | mutex_lock(&ftdi->u132_lock); |
1473 | command_size = ftdi->command_next - ftdi->command_head; | 1473 | command_size = ftdi->command_next - ftdi->command_head; |
1474 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1474 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1475 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1475 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1493,11 +1493,11 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1493 | ftdi->command_next += 1; | 1493 | ftdi->command_next += 1; |
1494 | ftdi->respond_next += 1; | 1494 | ftdi->respond_next += 1; |
1495 | ftdi_elan_kick_command_queue(ftdi); | 1495 | ftdi_elan_kick_command_queue(ftdi); |
1496 | up(&ftdi->u132_lock); | 1496 | mutex_unlock(&ftdi->u132_lock); |
1497 | wait_for_completion(&respond->wait_completion); | 1497 | wait_for_completion(&respond->wait_completion); |
1498 | return result; | 1498 | return result; |
1499 | } else { | 1499 | } else { |
1500 | up(&ftdi->u132_lock); | 1500 | mutex_unlock(&ftdi->u132_lock); |
1501 | msleep(100); | 1501 | msleep(100); |
1502 | goto wait; | 1502 | goto wait; |
1503 | } | 1503 | } |
@@ -1529,7 +1529,7 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, | |||
1529 | return -ENODEV; | 1529 | return -ENODEV; |
1530 | } else { | 1530 | } else { |
1531 | int command_size; | 1531 | int command_size; |
1532 | down(&ftdi->u132_lock); | 1532 | mutex_lock(&ftdi->u132_lock); |
1533 | command_size = ftdi->command_next - ftdi->command_head; | 1533 | command_size = ftdi->command_next - ftdi->command_head; |
1534 | if (command_size < COMMAND_SIZE) { | 1534 | if (command_size < COMMAND_SIZE) { |
1535 | struct u132_target *target = &ftdi->target[ed]; | 1535 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1550,10 +1550,10 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, | |||
1550 | target->active = 1; | 1550 | target->active = 1; |
1551 | ftdi->command_next += 1; | 1551 | ftdi->command_next += 1; |
1552 | ftdi_elan_kick_command_queue(ftdi); | 1552 | ftdi_elan_kick_command_queue(ftdi); |
1553 | up(&ftdi->u132_lock); | 1553 | mutex_unlock(&ftdi->u132_lock); |
1554 | return 0; | 1554 | return 0; |
1555 | } else { | 1555 | } else { |
1556 | up(&ftdi->u132_lock); | 1556 | mutex_unlock(&ftdi->u132_lock); |
1557 | msleep(100); | 1557 | msleep(100); |
1558 | goto wait; | 1558 | goto wait; |
1559 | } | 1559 | } |
@@ -1586,7 +1586,7 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, | |||
1586 | return -ENODEV; | 1586 | return -ENODEV; |
1587 | } else { | 1587 | } else { |
1588 | int command_size; | 1588 | int command_size; |
1589 | down(&ftdi->u132_lock); | 1589 | mutex_lock(&ftdi->u132_lock); |
1590 | command_size = ftdi->command_next - ftdi->command_head; | 1590 | command_size = ftdi->command_next - ftdi->command_head; |
1591 | if (command_size < COMMAND_SIZE) { | 1591 | if (command_size < COMMAND_SIZE) { |
1592 | struct u132_target *target = &ftdi->target[ed]; | 1592 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1615,10 +1615,10 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, | |||
1615 | target->active = 1; | 1615 | target->active = 1; |
1616 | ftdi->command_next += 1; | 1616 | ftdi->command_next += 1; |
1617 | ftdi_elan_kick_command_queue(ftdi); | 1617 | ftdi_elan_kick_command_queue(ftdi); |
1618 | up(&ftdi->u132_lock); | 1618 | mutex_unlock(&ftdi->u132_lock); |
1619 | return 0; | 1619 | return 0; |
1620 | } else { | 1620 | } else { |
1621 | up(&ftdi->u132_lock); | 1621 | mutex_unlock(&ftdi->u132_lock); |
1622 | msleep(100); | 1622 | msleep(100); |
1623 | goto wait; | 1623 | goto wait; |
1624 | } | 1624 | } |
@@ -1651,7 +1651,7 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, | |||
1651 | return -ENODEV; | 1651 | return -ENODEV; |
1652 | } else { | 1652 | } else { |
1653 | int command_size; | 1653 | int command_size; |
1654 | down(&ftdi->u132_lock); | 1654 | mutex_lock(&ftdi->u132_lock); |
1655 | command_size = ftdi->command_next - ftdi->command_head; | 1655 | command_size = ftdi->command_next - ftdi->command_head; |
1656 | if (command_size < COMMAND_SIZE) { | 1656 | if (command_size < COMMAND_SIZE) { |
1657 | struct u132_target *target = &ftdi->target[ed]; | 1657 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1672,10 +1672,10 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, | |||
1672 | target->active = 1; | 1672 | target->active = 1; |
1673 | ftdi->command_next += 1; | 1673 | ftdi->command_next += 1; |
1674 | ftdi_elan_kick_command_queue(ftdi); | 1674 | ftdi_elan_kick_command_queue(ftdi); |
1675 | up(&ftdi->u132_lock); | 1675 | mutex_unlock(&ftdi->u132_lock); |
1676 | return 0; | 1676 | return 0; |
1677 | } else { | 1677 | } else { |
1678 | up(&ftdi->u132_lock); | 1678 | mutex_unlock(&ftdi->u132_lock); |
1679 | msleep(100); | 1679 | msleep(100); |
1680 | goto wait; | 1680 | goto wait; |
1681 | } | 1681 | } |
@@ -1708,7 +1708,7 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, | |||
1708 | return -ENODEV; | 1708 | return -ENODEV; |
1709 | } else { | 1709 | } else { |
1710 | int command_size; | 1710 | int command_size; |
1711 | down(&ftdi->u132_lock); | 1711 | mutex_lock(&ftdi->u132_lock); |
1712 | command_size = ftdi->command_next - ftdi->command_head; | 1712 | command_size = ftdi->command_next - ftdi->command_head; |
1713 | if (command_size < COMMAND_SIZE) { | 1713 | if (command_size < COMMAND_SIZE) { |
1714 | u8 *b; | 1714 | u8 *b; |
@@ -1751,10 +1751,10 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, | |||
1751 | target->active = 1; | 1751 | target->active = 1; |
1752 | ftdi->command_next += 1; | 1752 | ftdi->command_next += 1; |
1753 | ftdi_elan_kick_command_queue(ftdi); | 1753 | ftdi_elan_kick_command_queue(ftdi); |
1754 | up(&ftdi->u132_lock); | 1754 | mutex_unlock(&ftdi->u132_lock); |
1755 | return 0; | 1755 | return 0; |
1756 | } else { | 1756 | } else { |
1757 | up(&ftdi->u132_lock); | 1757 | mutex_unlock(&ftdi->u132_lock); |
1758 | msleep(100); | 1758 | msleep(100); |
1759 | goto wait; | 1759 | goto wait; |
1760 | } | 1760 | } |
@@ -1787,7 +1787,7 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, | |||
1787 | return -ENODEV; | 1787 | return -ENODEV; |
1788 | } else { | 1788 | } else { |
1789 | int command_size; | 1789 | int command_size; |
1790 | down(&ftdi->u132_lock); | 1790 | mutex_lock(&ftdi->u132_lock); |
1791 | command_size = ftdi->command_next - ftdi->command_head; | 1791 | command_size = ftdi->command_next - ftdi->command_head; |
1792 | if (command_size < COMMAND_SIZE) { | 1792 | if (command_size < COMMAND_SIZE) { |
1793 | int remaining_length = urb->transfer_buffer_length - | 1793 | int remaining_length = urb->transfer_buffer_length - |
@@ -1816,10 +1816,10 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, | |||
1816 | target->active = 1; | 1816 | target->active = 1; |
1817 | ftdi->command_next += 1; | 1817 | ftdi->command_next += 1; |
1818 | ftdi_elan_kick_command_queue(ftdi); | 1818 | ftdi_elan_kick_command_queue(ftdi); |
1819 | up(&ftdi->u132_lock); | 1819 | mutex_unlock(&ftdi->u132_lock); |
1820 | return 0; | 1820 | return 0; |
1821 | } else { | 1821 | } else { |
1822 | up(&ftdi->u132_lock); | 1822 | mutex_unlock(&ftdi->u132_lock); |
1823 | msleep(100); | 1823 | msleep(100); |
1824 | goto wait; | 1824 | goto wait; |
1825 | } | 1825 | } |
@@ -1849,9 +1849,9 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, | |||
1849 | return -ENODEV; | 1849 | return -ENODEV; |
1850 | } else { | 1850 | } else { |
1851 | struct u132_target *target = &ftdi->target[ed]; | 1851 | struct u132_target *target = &ftdi->target[ed]; |
1852 | down(&ftdi->u132_lock); | 1852 | mutex_lock(&ftdi->u132_lock); |
1853 | if (target->abandoning > 0) { | 1853 | if (target->abandoning > 0) { |
1854 | up(&ftdi->u132_lock); | 1854 | mutex_unlock(&ftdi->u132_lock); |
1855 | return 0; | 1855 | return 0; |
1856 | } else { | 1856 | } else { |
1857 | target->abandoning = 1; | 1857 | target->abandoning = 1; |
@@ -1873,13 +1873,13 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, | |||
1873 | ftdi->command_next += 1; | 1873 | ftdi->command_next += 1; |
1874 | ftdi_elan_kick_command_queue(ftdi); | 1874 | ftdi_elan_kick_command_queue(ftdi); |
1875 | } else { | 1875 | } else { |
1876 | up(&ftdi->u132_lock); | 1876 | mutex_unlock(&ftdi->u132_lock); |
1877 | msleep(100); | 1877 | msleep(100); |
1878 | down(&ftdi->u132_lock); | 1878 | mutex_lock(&ftdi->u132_lock); |
1879 | goto wait_1; | 1879 | goto wait_1; |
1880 | } | 1880 | } |
1881 | } | 1881 | } |
1882 | up(&ftdi->u132_lock); | 1882 | mutex_unlock(&ftdi->u132_lock); |
1883 | return 0; | 1883 | return 0; |
1884 | } | 1884 | } |
1885 | } | 1885 | } |
@@ -2793,7 +2793,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, | |||
2793 | init_MUTEX(&ftdi->sw_lock); | 2793 | init_MUTEX(&ftdi->sw_lock); |
2794 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); | 2794 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); |
2795 | ftdi->interface = interface; | 2795 | ftdi->interface = interface; |
2796 | init_MUTEX(&ftdi->u132_lock); | 2796 | mutex_init(&ftdi->u132_lock); |
2797 | ftdi->expected = 4; | 2797 | ftdi->expected = 4; |
2798 | iface_desc = interface->cur_altsetting; | 2798 | iface_desc = interface->cur_altsetting; |
2799 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 2799 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index e6fd024024..4bcf7fb4e5 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -66,6 +66,7 @@ static struct usb_device_id idmouse_table[] = { | |||
66 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) | 66 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) |
67 | 67 | ||
68 | MODULE_DEVICE_TABLE(usb, idmouse_table); | 68 | MODULE_DEVICE_TABLE(usb, idmouse_table); |
69 | static DEFINE_MUTEX(open_disc_mutex); | ||
69 | 70 | ||
70 | /* structure to hold all of our device specific stuff */ | 71 | /* structure to hold all of our device specific stuff */ |
71 | struct usb_idmouse { | 72 | struct usb_idmouse { |
@@ -80,7 +81,7 @@ struct usb_idmouse { | |||
80 | 81 | ||
81 | int open; /* if the port is open or not */ | 82 | int open; /* if the port is open or not */ |
82 | int present; /* if the device is not disconnected */ | 83 | int present; /* if the device is not disconnected */ |
83 | struct semaphore sem; /* locks this structure */ | 84 | struct mutex lock; /* locks this structure */ |
84 | 85 | ||
85 | }; | 86 | }; |
86 | 87 | ||
@@ -213,13 +214,17 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
213 | if (!interface) | 214 | if (!interface) |
214 | return -ENODEV; | 215 | return -ENODEV; |
215 | 216 | ||
217 | mutex_lock(&open_disc_mutex); | ||
216 | /* get the device information block from the interface */ | 218 | /* get the device information block from the interface */ |
217 | dev = usb_get_intfdata(interface); | 219 | dev = usb_get_intfdata(interface); |
218 | if (!dev) | 220 | if (!dev) { |
221 | mutex_unlock(&open_disc_mutex); | ||
219 | return -ENODEV; | 222 | return -ENODEV; |
223 | } | ||
220 | 224 | ||
221 | /* lock this device */ | 225 | /* lock this device */ |
222 | down(&dev->sem); | 226 | mutex_lock(&dev->lock); |
227 | mutex_unlock(&open_disc_mutex); | ||
223 | 228 | ||
224 | /* check if already open */ | 229 | /* check if already open */ |
225 | if (dev->open) { | 230 | if (dev->open) { |
@@ -245,7 +250,7 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
245 | error: | 250 | error: |
246 | 251 | ||
247 | /* unlock this device */ | 252 | /* unlock this device */ |
248 | up(&dev->sem); | 253 | mutex_unlock(&dev->lock); |
249 | return result; | 254 | return result; |
250 | } | 255 | } |
251 | 256 | ||
@@ -258,12 +263,14 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
258 | if (dev == NULL) | 263 | if (dev == NULL) |
259 | return -ENODEV; | 264 | return -ENODEV; |
260 | 265 | ||
266 | mutex_lock(&open_disc_mutex); | ||
261 | /* lock our device */ | 267 | /* lock our device */ |
262 | down(&dev->sem); | 268 | mutex_lock(&dev->lock); |
263 | 269 | ||
264 | /* are we really open? */ | 270 | /* are we really open? */ |
265 | if (dev->open <= 0) { | 271 | if (dev->open <= 0) { |
266 | up(&dev->sem); | 272 | mutex_unlock(&dev->lock); |
273 | mutex_unlock(&open_disc_mutex); | ||
267 | return -ENODEV; | 274 | return -ENODEV; |
268 | } | 275 | } |
269 | 276 | ||
@@ -271,10 +278,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
271 | 278 | ||
272 | if (!dev->present) { | 279 | if (!dev->present) { |
273 | /* the device was unplugged before the file was released */ | 280 | /* the device was unplugged before the file was released */ |
274 | up(&dev->sem); | 281 | mutex_unlock(&dev->lock); |
282 | mutex_unlock(&open_disc_mutex); | ||
275 | idmouse_delete(dev); | 283 | idmouse_delete(dev); |
276 | } else { | 284 | } else { |
277 | up(&dev->sem); | 285 | mutex_unlock(&dev->lock); |
286 | mutex_unlock(&open_disc_mutex); | ||
278 | } | 287 | } |
279 | return 0; | 288 | return 0; |
280 | } | 289 | } |
@@ -286,18 +295,18 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count | |||
286 | int result; | 295 | int result; |
287 | 296 | ||
288 | /* lock this object */ | 297 | /* lock this object */ |
289 | down(&dev->sem); | 298 | mutex_lock(&dev->lock); |
290 | 299 | ||
291 | /* verify that the device wasn't unplugged */ | 300 | /* verify that the device wasn't unplugged */ |
292 | if (!dev->present) { | 301 | if (!dev->present) { |
293 | up(&dev->sem); | 302 | mutex_unlock(&dev->lock); |
294 | return -ENODEV; | 303 | return -ENODEV; |
295 | } | 304 | } |
296 | 305 | ||
297 | result = simple_read_from_buffer(buffer, count, ppos, | 306 | result = simple_read_from_buffer(buffer, count, ppos, |
298 | dev->bulk_in_buffer, IMGSIZE); | 307 | dev->bulk_in_buffer, IMGSIZE); |
299 | /* unlock the device */ | 308 | /* unlock the device */ |
300 | up(&dev->sem); | 309 | mutex_unlock(&dev->lock); |
301 | return result; | 310 | return result; |
302 | } | 311 | } |
303 | 312 | ||
@@ -320,7 +329,7 @@ static int idmouse_probe(struct usb_interface *interface, | |||
320 | if (dev == NULL) | 329 | if (dev == NULL) |
321 | return -ENOMEM; | 330 | return -ENOMEM; |
322 | 331 | ||
323 | init_MUTEX(&dev->sem); | 332 | mutex_init(&dev->lock); |
324 | dev->udev = udev; | 333 | dev->udev = udev; |
325 | dev->interface = interface; | 334 | dev->interface = interface; |
326 | 335 | ||
@@ -372,24 +381,26 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
372 | 381 | ||
373 | /* get device structure */ | 382 | /* get device structure */ |
374 | dev = usb_get_intfdata(interface); | 383 | dev = usb_get_intfdata(interface); |
375 | usb_set_intfdata(interface, NULL); | ||
376 | 384 | ||
377 | /* give back our minor */ | 385 | /* give back our minor */ |
378 | usb_deregister_dev(interface, &idmouse_class); | 386 | usb_deregister_dev(interface, &idmouse_class); |
379 | 387 | ||
380 | /* lock it */ | 388 | mutex_lock(&open_disc_mutex); |
381 | down(&dev->sem); | 389 | usb_set_intfdata(interface, NULL); |
390 | /* lock the device */ | ||
391 | mutex_lock(&dev->lock); | ||
392 | mutex_unlock(&open_disc_mutex); | ||
382 | 393 | ||
383 | /* prevent device read, write and ioctl */ | 394 | /* prevent device read, write and ioctl */ |
384 | dev->present = 0; | 395 | dev->present = 0; |
385 | 396 | ||
386 | /* if the device is opened, idmouse_release will clean this up */ | 397 | /* if the device is opened, idmouse_release will clean this up */ |
387 | if (!dev->open) { | 398 | if (!dev->open) { |
388 | up(&dev->sem); | 399 | mutex_unlock(&dev->lock); |
389 | idmouse_delete(dev); | 400 | idmouse_delete(dev); |
390 | } else { | 401 | } else { |
391 | /* unlock */ | 402 | /* unlock */ |
392 | up(&dev->sem); | 403 | mutex_unlock(&dev->lock); |
393 | } | 404 | } |
394 | 405 | ||
395 | info("%s disconnected", DRIVER_DESC); | 406 | info("%s disconnected", DRIVER_DESC); |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index d372fbc4ef..764696ff1e 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -66,6 +66,7 @@ module_param(debug, bool, 0644); | |||
66 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); | 66 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); |
67 | 67 | ||
68 | static struct usb_driver iowarrior_driver; | 68 | static struct usb_driver iowarrior_driver; |
69 | static DEFINE_MUTEX(iowarrior_open_disc_lock); | ||
69 | 70 | ||
70 | /*--------------*/ | 71 | /*--------------*/ |
71 | /* data */ | 72 | /* data */ |
@@ -351,7 +352,7 @@ static ssize_t iowarrior_write(struct file *file, | |||
351 | 352 | ||
352 | mutex_lock(&dev->mutex); | 353 | mutex_lock(&dev->mutex); |
353 | /* verify that the device wasn't unplugged */ | 354 | /* verify that the device wasn't unplugged */ |
354 | if (dev == NULL || !dev->present) { | 355 | if (!dev->present) { |
355 | retval = -ENODEV; | 356 | retval = -ENODEV; |
356 | goto exit; | 357 | goto exit; |
357 | } | 358 | } |
@@ -608,11 +609,15 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
608 | return -ENODEV; | 609 | return -ENODEV; |
609 | } | 610 | } |
610 | 611 | ||
612 | mutex_lock(&iowarrior_open_disc_lock); | ||
611 | dev = usb_get_intfdata(interface); | 613 | dev = usb_get_intfdata(interface); |
612 | if (!dev) | 614 | if (!dev) { |
615 | mutex_unlock(&iowarrior_open_disc_lock); | ||
613 | return -ENODEV; | 616 | return -ENODEV; |
617 | } | ||
614 | 618 | ||
615 | mutex_lock(&dev->mutex); | 619 | mutex_lock(&dev->mutex); |
620 | mutex_unlock(&iowarrior_open_disc_lock); | ||
616 | 621 | ||
617 | /* Only one process can open each device, no sharing. */ | 622 | /* Only one process can open each device, no sharing. */ |
618 | if (dev->opened) { | 623 | if (dev->opened) { |
@@ -866,6 +871,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) | |||
866 | int minor; | 871 | int minor; |
867 | 872 | ||
868 | dev = usb_get_intfdata(interface); | 873 | dev = usb_get_intfdata(interface); |
874 | mutex_lock(&iowarrior_open_disc_lock); | ||
869 | usb_set_intfdata(interface, NULL); | 875 | usb_set_intfdata(interface, NULL); |
870 | 876 | ||
871 | minor = dev->minor; | 877 | minor = dev->minor; |
@@ -879,6 +885,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) | |||
879 | dev->present = 0; | 885 | dev->present = 0; |
880 | 886 | ||
881 | mutex_unlock(&dev->mutex); | 887 | mutex_unlock(&dev->mutex); |
888 | mutex_unlock(&iowarrior_open_disc_lock); | ||
882 | 889 | ||
883 | if (dev->opened) { | 890 | if (dev->opened) { |
884 | /* There is a process that holds a filedescriptor to the device , | 891 | /* There is a process that holds a filedescriptor to the device , |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 561970b889..aab320085e 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -198,6 +198,7 @@ static struct usb_device_id tower_table [] = { | |||
198 | }; | 198 | }; |
199 | 199 | ||
200 | MODULE_DEVICE_TABLE (usb, tower_table); | 200 | MODULE_DEVICE_TABLE (usb, tower_table); |
201 | static DEFINE_MUTEX(open_disc_mutex); | ||
201 | 202 | ||
202 | #define LEGO_USB_TOWER_MINOR_BASE 160 | 203 | #define LEGO_USB_TOWER_MINOR_BASE 160 |
203 | 204 | ||
@@ -350,25 +351,31 @@ static int tower_open (struct inode *inode, struct file *file) | |||
350 | goto exit; | 351 | goto exit; |
351 | } | 352 | } |
352 | 353 | ||
354 | mutex_lock(&open_disc_mutex); | ||
353 | dev = usb_get_intfdata(interface); | 355 | dev = usb_get_intfdata(interface); |
354 | 356 | ||
355 | if (!dev) { | 357 | if (!dev) { |
358 | mutex_unlock(&open_disc_mutex); | ||
356 | retval = -ENODEV; | 359 | retval = -ENODEV; |
357 | goto exit; | 360 | goto exit; |
358 | } | 361 | } |
359 | 362 | ||
360 | /* lock this device */ | 363 | /* lock this device */ |
361 | if (down_interruptible (&dev->sem)) { | 364 | if (down_interruptible (&dev->sem)) { |
365 | mutex_unlock(&open_disc_mutex); | ||
362 | retval = -ERESTARTSYS; | 366 | retval = -ERESTARTSYS; |
363 | goto exit; | 367 | goto exit; |
364 | } | 368 | } |
365 | 369 | ||
370 | |||
366 | /* allow opening only once */ | 371 | /* allow opening only once */ |
367 | if (dev->open_count) { | 372 | if (dev->open_count) { |
373 | mutex_unlock(&open_disc_mutex); | ||
368 | retval = -EBUSY; | 374 | retval = -EBUSY; |
369 | goto unlock_exit; | 375 | goto unlock_exit; |
370 | } | 376 | } |
371 | dev->open_count = 1; | 377 | dev->open_count = 1; |
378 | mutex_unlock(&open_disc_mutex); | ||
372 | 379 | ||
373 | /* reset the tower */ | 380 | /* reset the tower */ |
374 | result = usb_control_msg (dev->udev, | 381 | result = usb_control_msg (dev->udev, |
@@ -437,9 +444,10 @@ static int tower_release (struct inode *inode, struct file *file) | |||
437 | if (dev == NULL) { | 444 | if (dev == NULL) { |
438 | dbg(1, "%s: object is NULL", __FUNCTION__); | 445 | dbg(1, "%s: object is NULL", __FUNCTION__); |
439 | retval = -ENODEV; | 446 | retval = -ENODEV; |
440 | goto exit; | 447 | goto exit_nolock; |
441 | } | 448 | } |
442 | 449 | ||
450 | mutex_lock(&open_disc_mutex); | ||
443 | if (down_interruptible (&dev->sem)) { | 451 | if (down_interruptible (&dev->sem)) { |
444 | retval = -ERESTARTSYS; | 452 | retval = -ERESTARTSYS; |
445 | goto exit; | 453 | goto exit; |
@@ -468,6 +476,8 @@ unlock_exit: | |||
468 | up (&dev->sem); | 476 | up (&dev->sem); |
469 | 477 | ||
470 | exit: | 478 | exit: |
479 | mutex_unlock(&open_disc_mutex); | ||
480 | exit_nolock: | ||
471 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); | 481 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); |
472 | return retval; | 482 | return retval; |
473 | } | 483 | } |
@@ -989,6 +999,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
989 | dbg(2, "%s: enter", __FUNCTION__); | 999 | dbg(2, "%s: enter", __FUNCTION__); |
990 | 1000 | ||
991 | dev = usb_get_intfdata (interface); | 1001 | dev = usb_get_intfdata (interface); |
1002 | mutex_lock(&open_disc_mutex); | ||
992 | usb_set_intfdata (interface, NULL); | 1003 | usb_set_intfdata (interface, NULL); |
993 | 1004 | ||
994 | minor = dev->minor; | 1005 | minor = dev->minor; |
@@ -997,6 +1008,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
997 | usb_deregister_dev (interface, &tower_class); | 1008 | usb_deregister_dev (interface, &tower_class); |
998 | 1009 | ||
999 | down (&dev->sem); | 1010 | down (&dev->sem); |
1011 | mutex_unlock(&open_disc_mutex); | ||
1000 | 1012 | ||
1001 | /* if the device is not opened, then we clean up right now */ | 1013 | /* if the device is not opened, then we clean up right now */ |
1002 | if (!dev->open_count) { | 1014 | if (!dev->open_count) { |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 88f6abe736..330c18e390 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -118,10 +118,7 @@ ioctl_rio(struct inode *inode, struct file *file, unsigned int cmd, | |||
118 | 118 | ||
119 | mutex_lock(&(rio->lock)); | 119 | mutex_lock(&(rio->lock)); |
120 | /* Sanity check to make sure rio is connected, powered, etc */ | 120 | /* Sanity check to make sure rio is connected, powered, etc */ |
121 | if ( rio == NULL || | 121 | if (rio->present == 0 || rio->rio_dev == NULL) { |
122 | rio->present == 0 || | ||
123 | rio->rio_dev == NULL ) | ||
124 | { | ||
125 | retval = -ENODEV; | 122 | retval = -ENODEV; |
126 | goto err_out; | 123 | goto err_out; |
127 | } | 124 | } |
@@ -280,10 +277,7 @@ write_rio(struct file *file, const char __user *buffer, | |||
280 | if (intr) | 277 | if (intr) |
281 | return -EINTR; | 278 | return -EINTR; |
282 | /* Sanity check to make sure rio is connected, powered, etc */ | 279 | /* Sanity check to make sure rio is connected, powered, etc */ |
283 | if ( rio == NULL || | 280 | if (rio->present == 0 || rio->rio_dev == NULL) { |
284 | rio->present == 0 || | ||
285 | rio->rio_dev == NULL ) | ||
286 | { | ||
287 | mutex_unlock(&(rio->lock)); | 281 | mutex_unlock(&(rio->lock)); |
288 | return -ENODEV; | 282 | return -ENODEV; |
289 | } | 283 | } |
@@ -369,10 +363,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
369 | if (intr) | 363 | if (intr) |
370 | return -EINTR; | 364 | return -EINTR; |
371 | /* Sanity check to make sure rio is connected, powered, etc */ | 365 | /* Sanity check to make sure rio is connected, powered, etc */ |
372 | if ( rio == NULL || | 366 | if (rio->present == 0 || rio->rio_dev == NULL) { |
373 | rio->present == 0 || | ||
374 | rio->rio_dev == NULL ) | ||
375 | { | ||
376 | mutex_unlock(&(rio->lock)); | 367 | mutex_unlock(&(rio->lock)); |
377 | return -ENODEV; | 368 | return -ENODEV; |
378 | } | 369 | } |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 7198420327..20777d01db 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/mutex.h> | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
22 | 23 | ||
@@ -34,6 +35,8 @@ static struct usb_device_id id_table [] = { | |||
34 | }; | 35 | }; |
35 | MODULE_DEVICE_TABLE (usb, id_table); | 36 | MODULE_DEVICE_TABLE (usb, id_table); |
36 | 37 | ||
38 | static DEFINE_MUTEX(open_disc_mutex); | ||
39 | |||
37 | 40 | ||
38 | struct usb_lcd { | 41 | struct usb_lcd { |
39 | struct usb_device * udev; /* init: probe_lcd */ | 42 | struct usb_device * udev; /* init: probe_lcd */ |
@@ -79,12 +82,16 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
79 | return -ENODEV; | 82 | return -ENODEV; |
80 | } | 83 | } |
81 | 84 | ||
85 | mutex_lock(&open_disc_mutex); | ||
82 | dev = usb_get_intfdata(interface); | 86 | dev = usb_get_intfdata(interface); |
83 | if (!dev) | 87 | if (!dev) { |
88 | mutex_unlock(&open_disc_mutex); | ||
84 | return -ENODEV; | 89 | return -ENODEV; |
90 | } | ||
85 | 91 | ||
86 | /* increment our usage count for the device */ | 92 | /* increment our usage count for the device */ |
87 | kref_get(&dev->kref); | 93 | kref_get(&dev->kref); |
94 | mutex_unlock(&open_disc_mutex); | ||
88 | 95 | ||
89 | /* grab a power reference */ | 96 | /* grab a power reference */ |
90 | r = usb_autopm_get_interface(interface); | 97 | r = usb_autopm_get_interface(interface); |
@@ -393,8 +400,10 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
393 | struct usb_lcd *dev; | 400 | struct usb_lcd *dev; |
394 | int minor = interface->minor; | 401 | int minor = interface->minor; |
395 | 402 | ||
403 | mutex_lock(&open_disc_mutex); | ||
396 | dev = usb_get_intfdata(interface); | 404 | dev = usb_get_intfdata(interface); |
397 | usb_set_intfdata(interface, NULL); | 405 | usb_set_intfdata(interface, NULL); |
406 | mutex_unlock(&open_disc_mutex); | ||
398 | 407 | ||
399 | /* give back our minor */ | 408 | /* give back our minor */ |
400 | usb_deregister_dev(interface, &lcd_class); | 409 | usb_deregister_dev(interface, &lcd_class); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 2a8e537cb0..ddfee91800 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -161,7 +161,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
161 | { | 161 | { |
162 | struct usb_serial *serial = port->serial; | 162 | struct usb_serial *serial = port->serial; |
163 | struct ark3116_private *priv = usb_get_serial_port_data(port); | 163 | struct ark3116_private *priv = usb_get_serial_port_data(port); |
164 | unsigned int cflag = port->tty->termios->c_cflag; | 164 | struct ktermios *termios = port->tty->termios; |
165 | unsigned int cflag = termios->c_cflag; | ||
165 | unsigned long flags; | 166 | unsigned long flags; |
166 | int baud; | 167 | int baud; |
167 | int ark3116_baud; | 168 | int ark3116_baud; |
@@ -177,11 +178,14 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
177 | *(port->tty->termios) = tty_std_termios; | 178 | *(port->tty->termios) = tty_std_termios; |
178 | port->tty->termios->c_cflag = B9600 | CS8 | 179 | port->tty->termios->c_cflag = B9600 | CS8 |
179 | | CREAD | HUPCL | CLOCAL; | 180 | | CREAD | HUPCL | CLOCAL; |
181 | termios->c_ispeed = 9600; | ||
182 | termios->c_ospeed = 9600; | ||
180 | priv->termios_initialized = 1; | 183 | priv->termios_initialized = 1; |
181 | } | 184 | } |
182 | spin_unlock_irqrestore(&priv->lock, flags); | 185 | spin_unlock_irqrestore(&priv->lock, flags); |
183 | 186 | ||
184 | cflag = port->tty->termios->c_cflag; | 187 | cflag = termios->c_cflag; |
188 | termios->c_cflag &= ~(CMSPAR|CRTSCTS); | ||
185 | 189 | ||
186 | buf = kmalloc(1, GFP_KERNEL); | 190 | buf = kmalloc(1, GFP_KERNEL); |
187 | if (!buf) { | 191 | if (!buf) { |
@@ -254,9 +258,13 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
254 | case 115200: | 258 | case 115200: |
255 | case 230400: | 259 | case 230400: |
256 | case 460800: | 260 | case 460800: |
261 | /* Report the resulting rate back to the caller */ | ||
262 | tty_encode_baud_rate(port->tty, baud, baud); | ||
257 | break; | 263 | break; |
258 | /* set 9600 as default (if given baudrate is invalid for example) */ | 264 | /* set 9600 as default (if given baudrate is invalid for example) */ |
259 | default: | 265 | default: |
266 | tty_encode_baud_rate(port->tty, 9600, 9600); | ||
267 | case 0: | ||
260 | baud = 9600; | 268 | baud = 9600; |
261 | } | 269 | } |
262 | 270 | ||
@@ -302,6 +310,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
302 | /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ | 310 | /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ |
303 | 311 | ||
304 | kfree(buf); | 312 | kfree(buf); |
313 | |||
305 | return; | 314 | return; |
306 | } | 315 | } |
307 | 316 | ||
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 6b252ceb39..42582d49b6 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -272,9 +272,6 @@ static void ch341_set_termios(struct usb_serial_port *port, | |||
272 | 272 | ||
273 | dbg("ch341_set_termios()"); | 273 | dbg("ch341_set_termios()"); |
274 | 274 | ||
275 | if (!tty || !tty->termios) | ||
276 | return; | ||
277 | |||
278 | baud_rate = tty_get_baud_rate(tty); | 275 | baud_rate = tty_get_baud_rate(tty); |
279 | 276 | ||
280 | switch (baud_rate) { | 277 | switch (baud_rate) { |
@@ -299,6 +296,11 @@ static void ch341_set_termios(struct usb_serial_port *port, | |||
299 | * (cflag & PARENB) : parity {NONE, EVEN, ODD} | 296 | * (cflag & PARENB) : parity {NONE, EVEN, ODD} |
300 | * (cflag & CSTOPB) : stop bits [1, 2] | 297 | * (cflag & CSTOPB) : stop bits [1, 2] |
301 | */ | 298 | */ |
299 | |||
300 | /* Copy back the old hardware settings */ | ||
301 | tty_termios_copy_hw(tty->termios, old_termios); | ||
302 | /* And re-encode with the new baud */ | ||
303 | tty_encode_baud_rate(tty, baud_rate, baud_rate); | ||
302 | } | 304 | } |
303 | 305 | ||
304 | static struct usb_driver ch341_driver = { | 306 | static struct usb_driver ch341_driver = { |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 9386e216d6..0362654d3b 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -164,6 +164,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | if (serial->type->set_termios) { | 166 | if (serial->type->set_termios) { |
167 | struct ktermios dummy; | ||
167 | /* build up a fake tty structure so that the open call has something | 168 | /* build up a fake tty structure so that the open call has something |
168 | * to look at to get the cflag value */ | 169 | * to look at to get the cflag value */ |
169 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); | 170 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); |
@@ -177,12 +178,13 @@ static int usb_console_setup(struct console *co, char *options) | |||
177 | kfree (tty); | 178 | kfree (tty); |
178 | return -ENOMEM; | 179 | return -ENOMEM; |
179 | } | 180 | } |
181 | memset(&dummy, 0, sizeof(struct ktermios)); | ||
180 | termios->c_cflag = cflag; | 182 | termios->c_cflag = cflag; |
181 | tty->termios = termios; | 183 | tty->termios = termios; |
182 | port->tty = tty; | 184 | port->tty = tty; |
183 | 185 | ||
184 | /* set up the initial termios settings */ | 186 | /* set up the initial termios settings */ |
185 | serial->type->set_termios(port, NULL); | 187 | serial->type->set_termios(port, &dummy); |
186 | port->tty = NULL; | 188 | port->tty = NULL; |
187 | kfree (termios); | 189 | kfree (termios); |
188 | kfree (tty); | 190 | kfree (tty); |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index eb7df1835c..3a83cb4c4b 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -361,7 +361,6 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
361 | dbg("%s - no tty structures", __FUNCTION__); | 361 | dbg("%s - no tty structures", __FUNCTION__); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | cflag = port->tty->termios->c_cflag; | ||
365 | 364 | ||
366 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); | 365 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); |
367 | /* Convert to baudrate */ | 366 | /* Convert to baudrate */ |
@@ -369,40 +368,9 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
369 | baud = BAUD_RATE_GEN_FREQ / baud; | 368 | baud = BAUD_RATE_GEN_FREQ / baud; |
370 | 369 | ||
371 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 370 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
372 | cflag &= ~CBAUD; | 371 | |
373 | switch (baud) { | 372 | tty_encode_baud_rate(port->tty, baud, baud); |
374 | /* | 373 | cflag = port->tty->termios->c_cflag; |
375 | * The baud rates which are commented out below | ||
376 | * appear to be supported by the device | ||
377 | * but are non-standard | ||
378 | */ | ||
379 | case 600: cflag |= B600; break; | ||
380 | case 1200: cflag |= B1200; break; | ||
381 | case 1800: cflag |= B1800; break; | ||
382 | case 2400: cflag |= B2400; break; | ||
383 | case 4800: cflag |= B4800; break; | ||
384 | /*case 7200: cflag |= B7200; break;*/ | ||
385 | case 9600: cflag |= B9600; break; | ||
386 | /*case 14400: cflag |= B14400; break;*/ | ||
387 | case 19200: cflag |= B19200; break; | ||
388 | /*case 28800: cflag |= B28800; break;*/ | ||
389 | case 38400: cflag |= B38400; break; | ||
390 | /*case 55854: cflag |= B55054; break;*/ | ||
391 | case 57600: cflag |= B57600; break; | ||
392 | case 115200: cflag |= B115200; break; | ||
393 | /*case 127117: cflag |= B127117; break;*/ | ||
394 | case 230400: cflag |= B230400; break; | ||
395 | case 460800: cflag |= B460800; break; | ||
396 | case 921600: cflag |= B921600; break; | ||
397 | /*case 3686400: cflag |= B3686400; break;*/ | ||
398 | default: | ||
399 | dbg("%s - Baud rate is not supported, " | ||
400 | "using 9600 baud", __FUNCTION__); | ||
401 | cflag |= B9600; | ||
402 | cp2101_set_config_single(port, CP2101_BAUDRATE, | ||
403 | (BAUD_RATE_GEN_FREQ/9600)); | ||
404 | break; | ||
405 | } | ||
406 | 374 | ||
407 | cp2101_get_config(port, CP2101_BITS, &bits, 2); | 375 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
408 | cflag &= ~CSIZE; | 376 | cflag &= ~CSIZE; |
@@ -516,7 +484,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
516 | static void cp2101_set_termios (struct usb_serial_port *port, | 484 | static void cp2101_set_termios (struct usb_serial_port *port, |
517 | struct ktermios *old_termios) | 485 | struct ktermios *old_termios) |
518 | { | 486 | { |
519 | unsigned int cflag, old_cflag=0; | 487 | unsigned int cflag, old_cflag; |
520 | int baud=0, bits; | 488 | int baud=0, bits; |
521 | unsigned int modem_ctl[4]; | 489 | unsigned int modem_ctl[4]; |
522 | 490 | ||
@@ -526,6 +494,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
526 | dbg("%s - no tty structures", __FUNCTION__); | 494 | dbg("%s - no tty structures", __FUNCTION__); |
527 | return; | 495 | return; |
528 | } | 496 | } |
497 | port->tty->termios->c_cflag &= ~CMSPAR; | ||
498 | |||
529 | cflag = port->tty->termios->c_cflag; | 499 | cflag = port->tty->termios->c_cflag; |
530 | old_cflag = old_termios->c_cflag; | 500 | old_cflag = old_termios->c_cflag; |
531 | baud = tty_get_baud_rate(port->tty); | 501 | baud = tty_get_baud_rate(port->tty); |
@@ -563,11 +533,15 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
563 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, | 533 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, |
564 | baud); | 534 | baud); |
565 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, | 535 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, |
566 | (BAUD_RATE_GEN_FREQ / baud))) | 536 | (BAUD_RATE_GEN_FREQ / baud))) { |
567 | dev_err(&port->dev, "Baud rate requested not " | 537 | dev_err(&port->dev, "Baud rate requested not " |
568 | "supported by device\n"); | 538 | "supported by device\n"); |
539 | baud = tty_termios_baud_rate(old_termios); | ||
540 | } | ||
569 | } | 541 | } |
570 | } | 542 | } |
543 | /* Report back the resulting baud rate */ | ||
544 | tty_encode_baud_rate(port->tty, baud, baud); | ||
571 | 545 | ||
572 | /* If the number of data bits is to be updated */ | 546 | /* If the number of data bits is to be updated */ |
573 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 547 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index dab2e66d11..ae410c4678 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -973,6 +973,8 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
973 | } | 973 | } |
974 | } | 974 | } |
975 | /* set parity */ | 975 | /* set parity */ |
976 | tty->termios->c_cflag &= ~CMSPAR; | ||
977 | |||
976 | if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { | 978 | if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { |
977 | if (cflag&PARENB) { | 979 | if (cflag&PARENB) { |
978 | if (cflag&PARODD) | 980 | if (cflag&PARODD) |
@@ -1054,15 +1056,15 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | /* set output flow control */ | 1058 | /* set output flow control */ |
1057 | if ((iflag&IXON) != (old_iflag&IXON) | 1059 | if ((iflag & IXON) != (old_iflag & IXON) |
1058 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) { | 1060 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
1059 | arg = 0; | 1061 | arg = 0; |
1060 | if (iflag&IXON) | 1062 | if (iflag & IXON) |
1061 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1063 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1062 | else | 1064 | else |
1063 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1065 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1064 | 1066 | ||
1065 | if (cflag&CRTSCTS) { | 1067 | if (cflag & CRTSCTS) { |
1066 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1068 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; |
1067 | } else { | 1069 | } else { |
1068 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1070 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; |
@@ -1076,8 +1078,8 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1076 | } | 1078 | } |
1077 | 1079 | ||
1078 | /* set receive enable/disable */ | 1080 | /* set receive enable/disable */ |
1079 | if ((cflag&CREAD) != (old_cflag&CREAD)) { | 1081 | if ((cflag & CREAD) != (old_cflag & CREAD)) { |
1080 | if (cflag&CREAD) | 1082 | if (cflag & CREAD) |
1081 | arg = DIGI_ENABLE; | 1083 | arg = DIGI_ENABLE; |
1082 | else | 1084 | else |
1083 | arg = DIGI_DISABLE; | 1085 | arg = DIGI_DISABLE; |
@@ -1089,7 +1091,7 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1089 | } | 1091 | } |
1090 | if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) | 1092 | if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) |
1091 | dbg("digi_set_termios: write oob failed, ret=%d", ret); | 1093 | dbg("digi_set_termios: write oob failed, ret=%d", ret); |
1092 | 1094 | tty_encode_baud_rate(tty, baud, baud); | |
1093 | } | 1095 | } |
1094 | 1096 | ||
1095 | 1097 | ||
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 050fcc996f..a5c8e1e17e 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -449,14 +449,9 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign | |||
449 | 449 | ||
450 | static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 450 | static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
451 | { | 451 | { |
452 | 452 | struct ktermios *termios = port->tty->termios; | |
453 | dbg("%s - port %d", __FUNCTION__, port->number); | 453 | dbg("%s - port %d", __FUNCTION__, port->number); |
454 | 454 | ||
455 | if ((!port->tty) || (!port->tty->termios)) { | ||
456 | dbg("%s - no tty structures", __FUNCTION__); | ||
457 | return; | ||
458 | } | ||
459 | |||
460 | /* | 455 | /* |
461 | * The empeg-car player wants these particular tty settings. | 456 | * The empeg-car player wants these particular tty settings. |
462 | * You could, for example, change the baud rate, however the | 457 | * You could, for example, change the baud rate, however the |
@@ -466,7 +461,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
466 | * | 461 | * |
467 | * The default requirements for this device are: | 462 | * The default requirements for this device are: |
468 | */ | 463 | */ |
469 | port->tty->termios->c_iflag | 464 | termios->c_iflag |
470 | &= ~(IGNBRK /* disable ignore break */ | 465 | &= ~(IGNBRK /* disable ignore break */ |
471 | | BRKINT /* disable break causes interrupt */ | 466 | | BRKINT /* disable break causes interrupt */ |
472 | | PARMRK /* disable mark parity errors */ | 467 | | PARMRK /* disable mark parity errors */ |
@@ -476,24 +471,23 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
476 | | ICRNL /* disable translate CR to NL */ | 471 | | ICRNL /* disable translate CR to NL */ |
477 | | IXON); /* disable enable XON/XOFF flow control */ | 472 | | IXON); /* disable enable XON/XOFF flow control */ |
478 | 473 | ||
479 | port->tty->termios->c_oflag | 474 | termios->c_oflag |
480 | &= ~OPOST; /* disable postprocess output characters */ | 475 | &= ~OPOST; /* disable postprocess output characters */ |
481 | 476 | ||
482 | port->tty->termios->c_lflag | 477 | termios->c_lflag |
483 | &= ~(ECHO /* disable echo input characters */ | 478 | &= ~(ECHO /* disable echo input characters */ |
484 | | ECHONL /* disable echo new line */ | 479 | | ECHONL /* disable echo new line */ |
485 | | ICANON /* disable erase, kill, werase, and rprnt special characters */ | 480 | | ICANON /* disable erase, kill, werase, and rprnt special characters */ |
486 | | ISIG /* disable interrupt, quit, and suspend special characters */ | 481 | | ISIG /* disable interrupt, quit, and suspend special characters */ |
487 | | IEXTEN); /* disable non-POSIX special characters */ | 482 | | IEXTEN); /* disable non-POSIX special characters */ |
488 | 483 | ||
489 | port->tty->termios->c_cflag | 484 | termios->c_cflag |
490 | &= ~(CSIZE /* no size */ | 485 | &= ~(CSIZE /* no size */ |
491 | | PARENB /* disable parity bit */ | 486 | | PARENB /* disable parity bit */ |
492 | | CBAUD); /* clear current baud rate */ | 487 | | CBAUD); /* clear current baud rate */ |
493 | 488 | ||
494 | port->tty->termios->c_cflag | 489 | termios->c_cflag |
495 | |= (CS8 /* character size 8 bits */ | 490 | |= CS8; /* character size 8 bits */ |
496 | | B115200); /* baud rate 115200 */ | ||
497 | 491 | ||
498 | /* | 492 | /* |
499 | * Force low_latency on; otherwise the pushes are scheduled; | 493 | * Force low_latency on; otherwise the pushes are scheduled; |
@@ -501,8 +495,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
501 | * on the floor. We don't want to drop bytes on the floor. :) | 495 | * on the floor. We don't want to drop bytes on the floor. :) |
502 | */ | 496 | */ |
503 | port->tty->low_latency = 1; | 497 | port->tty->low_latency = 1; |
504 | 498 | tty_encode_baud_rate(port->tty, 115200, 115200); | |
505 | return; | ||
506 | } | 499 | } |
507 | 500 | ||
508 | 501 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8a8a6b9fb0..c40e77dccf 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -294,7 +294,7 @@ struct ftdi_private { | |||
294 | 294 | ||
295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ | 295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ |
296 | 296 | ||
297 | int force_baud; /* if non-zero, force the baud rate to this value */ | 297 | speed_t force_baud; /* if non-zero, force the baud rate to this value */ |
298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ | 298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ |
299 | 299 | ||
300 | spinlock_t tx_lock; /* spinlock for transmit state */ | 300 | spinlock_t tx_lock; /* spinlock for transmit state */ |
@@ -878,6 +878,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
878 | if (div_value == 0) { | 878 | if (div_value == 0) { |
879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); | 879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); |
880 | div_value = ftdi_sio_b9600; | 880 | div_value = ftdi_sio_b9600; |
881 | baud = 9600; | ||
881 | div_okay = 0; | 882 | div_okay = 0; |
882 | } | 883 | } |
883 | break; | 884 | break; |
@@ -886,6 +887,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
886 | div_value = ftdi_232am_baud_to_divisor(baud); | 887 | div_value = ftdi_232am_baud_to_divisor(baud); |
887 | } else { | 888 | } else { |
888 | dbg("%s - Baud rate too high!", __FUNCTION__); | 889 | dbg("%s - Baud rate too high!", __FUNCTION__); |
890 | baud = 9600; | ||
889 | div_value = ftdi_232am_baud_to_divisor(9600); | 891 | div_value = ftdi_232am_baud_to_divisor(9600); |
890 | div_okay = 0; | 892 | div_okay = 0; |
891 | } | 893 | } |
@@ -899,6 +901,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
899 | dbg("%s - Baud rate too high!", __FUNCTION__); | 901 | dbg("%s - Baud rate too high!", __FUNCTION__); |
900 | div_value = ftdi_232bm_baud_to_divisor(9600); | 902 | div_value = ftdi_232bm_baud_to_divisor(9600); |
901 | div_okay = 0; | 903 | div_okay = 0; |
904 | baud = 9600; | ||
902 | } | 905 | } |
903 | break; | 906 | break; |
904 | } /* priv->chip_type */ | 907 | } /* priv->chip_type */ |
@@ -909,6 +912,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
909 | ftdi_chip_name[priv->chip_type]); | 912 | ftdi_chip_name[priv->chip_type]); |
910 | } | 913 | } |
911 | 914 | ||
915 | tty_encode_baud_rate(port->tty, baud, baud); | ||
912 | return(div_value); | 916 | return(div_value); |
913 | } | 917 | } |
914 | 918 | ||
@@ -1263,7 +1267,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) | |||
1263 | 1267 | ||
1264 | priv->flags |= ASYNC_SPD_CUST; | 1268 | priv->flags |= ASYNC_SPD_CUST; |
1265 | priv->custom_divisor = 77; | 1269 | priv->custom_divisor = 77; |
1266 | priv->force_baud = B38400; | 1270 | priv->force_baud = 38400; |
1267 | } /* ftdi_USB_UIRT_setup */ | 1271 | } /* ftdi_USB_UIRT_setup */ |
1268 | 1272 | ||
1269 | /* Setup for the HE-TIRA1 device, which requires hardwired | 1273 | /* Setup for the HE-TIRA1 device, which requires hardwired |
@@ -1274,7 +1278,7 @@ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) | |||
1274 | 1278 | ||
1275 | priv->flags |= ASYNC_SPD_CUST; | 1279 | priv->flags |= ASYNC_SPD_CUST; |
1276 | priv->custom_divisor = 240; | 1280 | priv->custom_divisor = 240; |
1277 | priv->force_baud = B38400; | 1281 | priv->force_baud = 38400; |
1278 | priv->force_rtscts = 1; | 1282 | priv->force_rtscts = 1; |
1279 | } /* ftdi_HE_TIRA1_setup */ | 1283 | } /* ftdi_HE_TIRA1_setup */ |
1280 | 1284 | ||
@@ -1363,7 +1367,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1363 | 1367 | ||
1364 | /* ftdi_set_termios will send usb control messages */ | 1368 | /* ftdi_set_termios will send usb control messages */ |
1365 | if (port->tty) | 1369 | if (port->tty) |
1366 | ftdi_set_termios(port, NULL); | 1370 | ftdi_set_termios(port, port->tty->termios); |
1367 | 1371 | ||
1368 | /* FIXME: Flow control might be enabled, so it should be checked - | 1372 | /* FIXME: Flow control might be enabled, so it should be checked - |
1369 | we have no control of defaults! */ | 1373 | we have no control of defaults! */ |
@@ -1933,32 +1937,33 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) | |||
1933 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 1937 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
1934 | { /* ftdi_termios */ | 1938 | { /* ftdi_termios */ |
1935 | struct usb_device *dev = port->serial->dev; | 1939 | struct usb_device *dev = port->serial->dev; |
1936 | unsigned int cflag = port->tty->termios->c_cflag; | ||
1937 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1940 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1941 | struct ktermios *termios = port->tty->termios; | ||
1942 | unsigned int cflag = termios->c_cflag; | ||
1938 | __u16 urb_value; /* will hold the new flags */ | 1943 | __u16 urb_value; /* will hold the new flags */ |
1939 | char buf[1]; /* Perhaps I should dynamically alloc this? */ | 1944 | char buf[1]; /* Perhaps I should dynamically alloc this? */ |
1940 | 1945 | ||
1941 | // Added for xon/xoff support | 1946 | // Added for xon/xoff support |
1942 | unsigned int iflag = port->tty->termios->c_iflag; | 1947 | unsigned int iflag = termios->c_iflag; |
1943 | unsigned char vstop; | 1948 | unsigned char vstop; |
1944 | unsigned char vstart; | 1949 | unsigned char vstart; |
1945 | 1950 | ||
1946 | dbg("%s", __FUNCTION__); | 1951 | dbg("%s", __FUNCTION__); |
1947 | 1952 | ||
1948 | /* Force baud rate if this device requires it, unless it is set to B0. */ | 1953 | /* Force baud rate if this device requires it, unless it is set to B0. */ |
1949 | if (priv->force_baud && ((port->tty->termios->c_cflag & CBAUD) != B0)) { | 1954 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { |
1950 | dbg("%s: forcing baud rate for this device", __FUNCTION__); | 1955 | dbg("%s: forcing baud rate for this device", __FUNCTION__); |
1951 | port->tty->termios->c_cflag &= ~CBAUD; | 1956 | tty_encode_baud_rate(port->tty, priv->force_baud, |
1952 | port->tty->termios->c_cflag |= priv->force_baud; | 1957 | priv->force_baud); |
1953 | } | 1958 | } |
1954 | 1959 | ||
1955 | /* Force RTS-CTS if this device requires it. */ | 1960 | /* Force RTS-CTS if this device requires it. */ |
1956 | if (priv->force_rtscts) { | 1961 | if (priv->force_rtscts) { |
1957 | dbg("%s: forcing rtscts for this device", __FUNCTION__); | 1962 | dbg("%s: forcing rtscts for this device", __FUNCTION__); |
1958 | port->tty->termios->c_cflag |= CRTSCTS; | 1963 | termios->c_cflag |= CRTSCTS; |
1959 | } | 1964 | } |
1960 | 1965 | ||
1961 | cflag = port->tty->termios->c_cflag; | 1966 | cflag = termios->c_cflag; |
1962 | 1967 | ||
1963 | /* FIXME -For this cut I don't care if the line is really changing or | 1968 | /* FIXME -For this cut I don't care if the line is really changing or |
1964 | not - so just do the change regardless - should be able to | 1969 | not - so just do the change regardless - should be able to |
@@ -1969,6 +1974,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
1969 | 1974 | ||
1970 | /* Set number of data bits, parity, stop bits */ | 1975 | /* Set number of data bits, parity, stop bits */ |
1971 | 1976 | ||
1977 | termios->c_cflag &= ~CMSPAR; | ||
1978 | |||
1972 | urb_value = 0; | 1979 | urb_value = 0; |
1973 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : | 1980 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : |
1974 | FTDI_SIO_SET_DATA_STOP_BITS_1); | 1981 | FTDI_SIO_SET_DATA_STOP_BITS_1); |
@@ -2048,8 +2055,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2048 | // Set the vstart and vstop -- could have been done up above where | 2055 | // Set the vstart and vstop -- could have been done up above where |
2049 | // a lot of other dereferencing is done but that would be very | 2056 | // a lot of other dereferencing is done but that would be very |
2050 | // inefficient as vstart and vstop are not always needed | 2057 | // inefficient as vstart and vstop are not always needed |
2051 | vstart=port->tty->termios->c_cc[VSTART]; | 2058 | vstart = termios->c_cc[VSTART]; |
2052 | vstop=port->tty->termios->c_cc[VSTOP]; | 2059 | vstop = termios->c_cc[VSTOP]; |
2053 | urb_value=(vstop << 8) | (vstart); | 2060 | urb_value=(vstop << 8) | (vstart); |
2054 | 2061 | ||
2055 | if (usb_control_msg(dev, | 2062 | if (usb_control_msg(dev, |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 88a2c7dce3..9eb4a65ee4 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -208,14 +208,15 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
208 | 208 | ||
209 | /* only do something if we have a bulk out endpoint */ | 209 | /* only do something if we have a bulk out endpoint */ |
210 | if (serial->num_bulk_out) { | 210 | if (serial->num_bulk_out) { |
211 | spin_lock_bh(&port->lock); | 211 | unsigned long flags; |
212 | spin_lock_irqsave(&port->lock, flags); | ||
212 | if (port->write_urb_busy) { | 213 | if (port->write_urb_busy) { |
213 | spin_unlock_bh(&port->lock); | 214 | spin_unlock_irqrestore(&port->lock, flags); |
214 | dbg("%s - already writing", __FUNCTION__); | 215 | dbg("%s - already writing", __FUNCTION__); |
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
217 | port->write_urb_busy = 1; | 218 | port->write_urb_busy = 1; |
218 | spin_unlock_bh(&port->lock); | 219 | spin_unlock_irqrestore(&port->lock, flags); |
219 | 220 | ||
220 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; | 221 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; |
221 | 222 | ||
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 8dd3abc99d..a5d2e115e1 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -1503,22 +1503,16 @@ static void edge_unthrottle (struct usb_serial_port *port) | |||
1503 | *****************************************************************************/ | 1503 | *****************************************************************************/ |
1504 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 1504 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
1505 | { | 1505 | { |
1506 | /* FIXME: This function appears unused ?? */ | ||
1506 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1507 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1507 | struct tty_struct *tty = port->tty; | 1508 | struct tty_struct *tty = port->tty; |
1508 | unsigned int cflag; | 1509 | unsigned int cflag; |
1509 | 1510 | ||
1510 | if (!port->tty || !port->tty->termios) { | ||
1511 | dbg ("%s - no tty or termios", __FUNCTION__); | ||
1512 | return; | ||
1513 | } | ||
1514 | |||
1515 | cflag = tty->termios->c_cflag; | 1511 | cflag = tty->termios->c_cflag; |
1516 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | 1512 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, |
1517 | tty->termios->c_cflag, tty->termios->c_iflag); | 1513 | tty->termios->c_cflag, tty->termios->c_iflag); |
1518 | if (old_termios) { | 1514 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, |
1519 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | 1515 | old_termios->c_cflag, old_termios->c_iflag); |
1520 | old_termios->c_cflag, old_termios->c_iflag); | ||
1521 | } | ||
1522 | 1516 | ||
1523 | dbg("%s - port %d", __FUNCTION__, port->number); | 1517 | dbg("%s - port %d", __FUNCTION__, port->number); |
1524 | 1518 | ||
@@ -2653,7 +2647,11 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2653 | 2647 | ||
2654 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 2648 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
2655 | status = send_cmd_write_baud_rate (edge_port, baud); | 2649 | status = send_cmd_write_baud_rate (edge_port, baud); |
2656 | 2650 | if (status == -1) { | |
2651 | /* Speed change was not possible - put back the old speed */ | ||
2652 | baud = tty_termios_baud_rate(old_termios); | ||
2653 | tty_encode_baud_rate(tty, baud, baud); | ||
2654 | } | ||
2657 | return; | 2655 | return; |
2658 | } | 2656 | } |
2659 | 2657 | ||
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 5ab6a0c5ac..6b803ab985 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -504,11 +504,6 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
504 | 504 | ||
505 | dbg("%s - port %d", __FUNCTION__, port->number); | 505 | dbg("%s - port %d", __FUNCTION__, port->number); |
506 | 506 | ||
507 | if ((!port->tty) || (!port->tty->termios)) { | ||
508 | dbg("%s - no tty structures", __FUNCTION__); | ||
509 | return; | ||
510 | } | ||
511 | |||
512 | baud = tty_get_baud_rate(port->tty); | 507 | baud = tty_get_baud_rate(port->tty); |
513 | 508 | ||
514 | /* | 509 | /* |
@@ -531,8 +526,6 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
531 | default: | 526 | default: |
532 | ir_baud = SPEED_9600; | 527 | ir_baud = SPEED_9600; |
533 | baud = 9600; | 528 | baud = 9600; |
534 | /* And once the new tty stuff is all done we need to | ||
535 | call back to correct the baud bits */ | ||
536 | } | 529 | } |
537 | 530 | ||
538 | if (xbof == -1) | 531 | if (xbof == -1) |
@@ -562,6 +555,10 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
562 | result = usb_submit_urb (port->write_urb, GFP_KERNEL); | 555 | result = usb_submit_urb (port->write_urb, GFP_KERNEL); |
563 | if (result) | 556 | if (result) |
564 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); | 557 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); |
558 | |||
559 | /* Only speed changes are supported */ | ||
560 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
561 | tty_encode_baud_rate(port->tty, baud, baud); | ||
565 | } | 562 | } |
566 | 563 | ||
567 | 564 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index f2a6fce5de..6bfdba6a21 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -278,29 +278,35 @@ static void keyspan_set_termios (struct usb_serial_port *port, | |||
278 | struct keyspan_port_private *p_priv; | 278 | struct keyspan_port_private *p_priv; |
279 | const struct keyspan_device_details *d_details; | 279 | const struct keyspan_device_details *d_details; |
280 | unsigned int cflag; | 280 | unsigned int cflag; |
281 | struct tty_struct *tty = port->tty; | ||
281 | 282 | ||
282 | dbg("%s", __FUNCTION__); | 283 | dbg("%s", __FUNCTION__); |
283 | 284 | ||
284 | p_priv = usb_get_serial_port_data(port); | 285 | p_priv = usb_get_serial_port_data(port); |
285 | d_details = p_priv->device_details; | 286 | d_details = p_priv->device_details; |
286 | cflag = port->tty->termios->c_cflag; | 287 | cflag = tty->termios->c_cflag; |
287 | device_port = port->number - port->serial->minor; | 288 | device_port = port->number - port->serial->minor; |
288 | 289 | ||
289 | /* Baud rate calculation takes baud rate as an integer | 290 | /* Baud rate calculation takes baud rate as an integer |
290 | so other rates can be generated if desired. */ | 291 | so other rates can be generated if desired. */ |
291 | baud_rate = tty_get_baud_rate(port->tty); | 292 | baud_rate = tty_get_baud_rate(tty); |
292 | /* If no match or invalid, don't change */ | 293 | /* If no match or invalid, don't change */ |
293 | if (baud_rate >= 0 | 294 | if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, |
294 | && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, | ||
295 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { | 295 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { |
296 | /* FIXME - more to do here to ensure rate changes cleanly */ | 296 | /* FIXME - more to do here to ensure rate changes cleanly */ |
297 | /* FIXME - calcuate exact rate from divisor ? */ | ||
297 | p_priv->baud = baud_rate; | 298 | p_priv->baud = baud_rate; |
298 | } | 299 | } else |
300 | baud_rate = tty_termios_baud_rate(old_termios); | ||
299 | 301 | ||
302 | tty_encode_baud_rate(tty, baud_rate, baud_rate); | ||
300 | /* set CTS/RTS handshake etc. */ | 303 | /* set CTS/RTS handshake etc. */ |
301 | p_priv->cflag = cflag; | 304 | p_priv->cflag = cflag; |
302 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; | 305 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; |
303 | 306 | ||
307 | /* Mark/Space not supported */ | ||
308 | tty->termios->c_cflag &= ~CMSPAR; | ||
309 | |||
304 | keyspan_send_setup(port, 0); | 310 | keyspan_send_setup(port, 0); |
305 | } | 311 | } |
306 | 312 | ||
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 6f224195bd..aee450246b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -616,8 +616,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old | |||
616 | case 1200: | 616 | case 1200: |
617 | urb_val = SUSBCR_SBR_1200; | 617 | urb_val = SUSBCR_SBR_1200; |
618 | break; | 618 | break; |
619 | case 9600: | ||
620 | default: | 619 | default: |
620 | speed = 9600; | ||
621 | case 9600: | ||
621 | urb_val = SUSBCR_SBR_9600; | 622 | urb_val = SUSBCR_SBR_9600; |
622 | break; | 623 | break; |
623 | } | 624 | } |
@@ -641,6 +642,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old | |||
641 | urb_val |= SUSBCR_SPASB_NoParity; | 642 | urb_val |= SUSBCR_SPASB_NoParity; |
642 | strcat(settings, "No Parity"); | 643 | strcat(settings, "No Parity"); |
643 | } | 644 | } |
645 | port->tty->termios->c_cflag &= ~CMSPAR; | ||
646 | tty_encode_baud_rate(port->tty, speed, speed); | ||
644 | 647 | ||
645 | result = usb_control_msg( port->serial->dev, | 648 | result = usb_control_msg( port->serial->dev, |
646 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 649 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index f76480f145..a5ced7e08c 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1977,11 +1977,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, | |||
1977 | 1977 | ||
1978 | tty = mos7840_port->port->tty; | 1978 | tty = mos7840_port->port->tty; |
1979 | 1979 | ||
1980 | if ((!tty) || (!tty->termios)) { | ||
1981 | dbg("%s - no tty structures", __FUNCTION__); | ||
1982 | return; | ||
1983 | } | ||
1984 | |||
1985 | dbg("%s", "Entering .......... \n"); | 1980 | dbg("%s", "Entering .......... \n"); |
1986 | 1981 | ||
1987 | lData = LCR_BITS_8; | 1982 | lData = LCR_BITS_8; |
@@ -2151,11 +2146,6 @@ static void mos7840_set_termios(struct usb_serial_port *port, | |||
2151 | 2146 | ||
2152 | tty = port->tty; | 2147 | tty = port->tty; |
2153 | 2148 | ||
2154 | if (!port->tty || !port->tty->termios) { | ||
2155 | dbg("%s - no tty or termios", __FUNCTION__); | ||
2156 | return; | ||
2157 | } | ||
2158 | |||
2159 | if (!mos7840_port->open) { | 2149 | if (!mos7840_port->open) { |
2160 | dbg("%s - port not opened", __FUNCTION__); | 2150 | dbg("%s - port not opened", __FUNCTION__); |
2161 | return; | 2151 | return; |
@@ -2165,19 +2155,10 @@ static void mos7840_set_termios(struct usb_serial_port *port, | |||
2165 | 2155 | ||
2166 | cflag = tty->termios->c_cflag; | 2156 | cflag = tty->termios->c_cflag; |
2167 | 2157 | ||
2168 | if (!cflag) { | ||
2169 | dbg("%s %s\n", __FUNCTION__, "cflag is NULL"); | ||
2170 | return; | ||
2171 | } | ||
2172 | |||
2173 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | 2158 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, |
2174 | tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); | 2159 | tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); |
2175 | 2160 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | |
2176 | if (old_termios) { | 2161 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); |
2177 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | ||
2178 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); | ||
2179 | } | ||
2180 | |||
2181 | dbg("%s - port %d", __FUNCTION__, port->number); | 2162 | dbg("%s - port %d", __FUNCTION__, port->number); |
2182 | 2163 | ||
2183 | /* change the port settings to the new ones specified */ | 2164 | /* change the port settings to the new ones specified */ |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a18659e070..4590124cf8 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -172,6 +172,8 @@ static struct usb_device_id option_ids[] = { | |||
172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ | 172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ |
173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ | 173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ |
174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ | 174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ |
175 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4100) }, /* Novatel U727 */ | ||
176 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4400) }, /* Novatel MC950 */ | ||
175 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ | 177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ |
176 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 178 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 179 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
@@ -311,7 +313,8 @@ static void option_set_termios(struct usb_serial_port *port, | |||
311 | struct ktermios *old_termios) | 313 | struct ktermios *old_termios) |
312 | { | 314 | { |
313 | dbg("%s", __FUNCTION__); | 315 | dbg("%s", __FUNCTION__); |
314 | 316 | /* Doesn't support option setting */ | |
317 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
315 | option_send_setup(port); | 318 | option_send_setup(port); |
316 | } | 319 | } |
317 | 320 | ||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 1da57fd9ea..2cd3f1d4b6 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -56,6 +56,7 @@ static struct usb_device_id id_table [] = { | |||
56 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, | 56 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, |
57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, | 57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, |
58 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, | 58 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, |
59 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, | ||
59 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, | 60 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, |
60 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, | 61 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, |
61 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, | 62 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
@@ -470,16 +471,13 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
470 | 471 | ||
471 | dbg("%s - port %d", __FUNCTION__, port->number); | 472 | dbg("%s - port %d", __FUNCTION__, port->number); |
472 | 473 | ||
473 | if ((!port->tty) || (!port->tty->termios)) { | ||
474 | dbg("%s - no tty structures", __FUNCTION__); | ||
475 | return; | ||
476 | } | ||
477 | |||
478 | spin_lock_irqsave(&priv->lock, flags); | 474 | spin_lock_irqsave(&priv->lock, flags); |
479 | if (!priv->termios_initialized) { | 475 | if (!priv->termios_initialized) { |
480 | *(port->tty->termios) = tty_std_termios; | 476 | *(port->tty->termios) = tty_std_termios; |
481 | port->tty->termios->c_cflag = B9600 | CS8 | CREAD | | 477 | port->tty->termios->c_cflag = B9600 | CS8 | CREAD | |
482 | HUPCL | CLOCAL; | 478 | HUPCL | CLOCAL; |
479 | port->tty->termios->c_ispeed = 9600; | ||
480 | port->tty->termios->c_ospeed = 9600; | ||
483 | priv->termios_initialized = 1; | 481 | priv->termios_initialized = 1; |
484 | } | 482 | } |
485 | spin_unlock_irqrestore(&priv->lock, flags); | 483 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -596,6 +594,10 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
596 | dbg ("0x40:0x1:0x0:0x0 %d", i); | 594 | dbg ("0x40:0x1:0x0:0x0 %d", i); |
597 | } | 595 | } |
598 | 596 | ||
597 | /* FIXME: Need to read back resulting baud rate */ | ||
598 | if (baud) | ||
599 | tty_encode_baud_rate(port->tty, baud, baud); | ||
600 | |||
599 | kfree(buf); | 601 | kfree(buf); |
600 | } | 602 | } |
601 | 603 | ||
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index c39bace5cb..ed603e3dec 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #define IODATA_VENDOR_ID 0x04bb | 21 | #define IODATA_VENDOR_ID 0x04bb |
22 | #define IODATA_PRODUCT_ID 0x0a03 | 22 | #define IODATA_PRODUCT_ID 0x0a03 |
23 | #define IODATA_PRODUCT_ID_RSAQ5 0x0a0e | ||
23 | 24 | ||
24 | #define ELCOM_VENDOR_ID 0x056e | 25 | #define ELCOM_VENDOR_ID 0x056e |
25 | #define ELCOM_PRODUCT_ID 0x5003 | 26 | #define ELCOM_PRODUCT_ID 0x5003 |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 959b3e4e90..833f6e1e37 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -224,7 +224,7 @@ static void sierra_set_termios(struct usb_serial_port *port, | |||
224 | struct ktermios *old_termios) | 224 | struct ktermios *old_termios) |
225 | { | 225 | { |
226 | dbg("%s", __FUNCTION__); | 226 | dbg("%s", __FUNCTION__); |
227 | 227 | tty_termios_copy_hw(port->tty->termios, old_termios); | |
228 | sierra_send_setup(port); | 228 | sierra_send_setup(port); |
229 | } | 229 | } |
230 | 230 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 4b1bd7def4..497e29a700 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -429,6 +429,8 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) | |||
429 | /* pass on to the driver specific version of this function if it is available */ | 429 | /* pass on to the driver specific version of this function if it is available */ |
430 | if (port->serial->type->set_termios) | 430 | if (port->serial->type->set_termios) |
431 | port->serial->type->set_termios(port, old); | 431 | port->serial->type->set_termios(port, old); |
432 | else | ||
433 | tty_termios_copy_hw(tty->termios, old); | ||
432 | } | 434 | } |
433 | 435 | ||
434 | static void serial_break (struct tty_struct *tty, int break_state) | 436 | static void serial_break (struct tty_struct *tty, int break_state) |
@@ -1121,7 +1123,9 @@ int usb_serial_resume(struct usb_interface *intf) | |||
1121 | { | 1123 | { |
1122 | struct usb_serial *serial = usb_get_intfdata(intf); | 1124 | struct usb_serial *serial = usb_get_intfdata(intf); |
1123 | 1125 | ||
1124 | return serial->type->resume(serial); | 1126 | if (serial->type->resume) |
1127 | return serial->type->resume(serial); | ||
1128 | return 0; | ||
1125 | } | 1129 | } |
1126 | EXPORT_SYMBOL(usb_serial_resume); | 1130 | EXPORT_SYMBOL(usb_serial_resume); |
1127 | 1131 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index cc8b44c087..ee5dd8b5a7 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -885,16 +885,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un | |||
885 | static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) | 885 | static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) |
886 | { | 886 | { |
887 | dbg("%s -port %d", __FUNCTION__, port->number); | 887 | dbg("%s -port %d", __FUNCTION__, port->number); |
888 | |||
889 | if ((!port->tty) || (!port->tty->termios)) { | ||
890 | dbg("%s - no tty structures", __FUNCTION__); | ||
891 | goto exit; | ||
892 | } | ||
893 | |||
894 | firm_setup_port(port); | 888 | firm_setup_port(port); |
895 | |||
896 | exit: | ||
897 | return; | ||
898 | } | 889 | } |
899 | 890 | ||
900 | 891 | ||
@@ -1244,6 +1235,8 @@ static int firm_setup_port(struct usb_serial_port *port) { | |||
1244 | port_settings.baud = tty_get_baud_rate(port->tty); | 1235 | port_settings.baud = tty_get_baud_rate(port->tty); |
1245 | dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); | 1236 | dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); |
1246 | 1237 | ||
1238 | /* fixme: should set validated settings */ | ||
1239 | tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); | ||
1247 | /* handle any settings that aren't specified in the tty structure */ | 1240 | /* handle any settings that aren't specified in the tty structure */ |
1248 | port_settings.lloop = 0; | 1241 | port_settings.lloop = 0; |
1249 | 1242 | ||
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index fe2c4cd53f..7e53333be0 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -48,7 +48,6 @@ config USB_STORAGE_FREECOM | |||
48 | config USB_STORAGE_ISD200 | 48 | config USB_STORAGE_ISD200 |
49 | bool "ISD-200 USB/ATA Bridge support" | 49 | bool "ISD-200 USB/ATA Bridge support" |
50 | depends on USB_STORAGE | 50 | depends on USB_STORAGE |
51 | depends on BLK_DEV_IDE=y || BLK_DEV_IDE=USB_STORAGE | ||
52 | ---help--- | 51 | ---help--- |
53 | Say Y here if you want to use USB Mass Store devices based | 52 | Say Y here if you want to use USB Mass Store devices based |
54 | on the In-Systems Design ISD-200 USB/ATA bridge. | 53 | on the In-Systems Design ISD-200 USB/ATA bridge. |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 93a7724e16..49ba6c0ff1 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -977,6 +977,109 @@ static int isd200_manual_enum(struct us_data *us) | |||
977 | return(retStatus); | 977 | return(retStatus); |
978 | } | 978 | } |
979 | 979 | ||
980 | /* | ||
981 | * We are the last non IDE user of the legacy IDE ident structures | ||
982 | * and we thus want to keep a private copy of this function so the | ||
983 | * driver can be used without the obsolete drivers/ide layer | ||
984 | */ | ||
985 | |||
986 | static void isd200_fix_driveid (struct hd_driveid *id) | ||
987 | { | ||
988 | #ifndef __LITTLE_ENDIAN | ||
989 | # ifdef __BIG_ENDIAN | ||
990 | int i; | ||
991 | u16 *stringcast; | ||
992 | |||
993 | id->config = __le16_to_cpu(id->config); | ||
994 | id->cyls = __le16_to_cpu(id->cyls); | ||
995 | id->reserved2 = __le16_to_cpu(id->reserved2); | ||
996 | id->heads = __le16_to_cpu(id->heads); | ||
997 | id->track_bytes = __le16_to_cpu(id->track_bytes); | ||
998 | id->sector_bytes = __le16_to_cpu(id->sector_bytes); | ||
999 | id->sectors = __le16_to_cpu(id->sectors); | ||
1000 | id->vendor0 = __le16_to_cpu(id->vendor0); | ||
1001 | id->vendor1 = __le16_to_cpu(id->vendor1); | ||
1002 | id->vendor2 = __le16_to_cpu(id->vendor2); | ||
1003 | stringcast = (u16 *)&id->serial_no[0]; | ||
1004 | for (i = 0; i < (20/2); i++) | ||
1005 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1006 | id->buf_type = __le16_to_cpu(id->buf_type); | ||
1007 | id->buf_size = __le16_to_cpu(id->buf_size); | ||
1008 | id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); | ||
1009 | stringcast = (u16 *)&id->fw_rev[0]; | ||
1010 | for (i = 0; i < (8/2); i++) | ||
1011 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1012 | stringcast = (u16 *)&id->model[0]; | ||
1013 | for (i = 0; i < (40/2); i++) | ||
1014 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1015 | id->dword_io = __le16_to_cpu(id->dword_io); | ||
1016 | id->reserved50 = __le16_to_cpu(id->reserved50); | ||
1017 | id->field_valid = __le16_to_cpu(id->field_valid); | ||
1018 | id->cur_cyls = __le16_to_cpu(id->cur_cyls); | ||
1019 | id->cur_heads = __le16_to_cpu(id->cur_heads); | ||
1020 | id->cur_sectors = __le16_to_cpu(id->cur_sectors); | ||
1021 | id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); | ||
1022 | id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); | ||
1023 | id->lba_capacity = __le32_to_cpu(id->lba_capacity); | ||
1024 | id->dma_1word = __le16_to_cpu(id->dma_1word); | ||
1025 | id->dma_mword = __le16_to_cpu(id->dma_mword); | ||
1026 | id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); | ||
1027 | id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); | ||
1028 | id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); | ||
1029 | id->eide_pio = __le16_to_cpu(id->eide_pio); | ||
1030 | id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); | ||
1031 | for (i = 0; i < 2; ++i) | ||
1032 | id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); | ||
1033 | for (i = 0; i < 4; ++i) | ||
1034 | id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); | ||
1035 | id->queue_depth = __le16_to_cpu(id->queue_depth); | ||
1036 | for (i = 0; i < 4; ++i) | ||
1037 | id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); | ||
1038 | id->major_rev_num = __le16_to_cpu(id->major_rev_num); | ||
1039 | id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); | ||
1040 | id->command_set_1 = __le16_to_cpu(id->command_set_1); | ||
1041 | id->command_set_2 = __le16_to_cpu(id->command_set_2); | ||
1042 | id->cfsse = __le16_to_cpu(id->cfsse); | ||
1043 | id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); | ||
1044 | id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); | ||
1045 | id->csf_default = __le16_to_cpu(id->csf_default); | ||
1046 | id->dma_ultra = __le16_to_cpu(id->dma_ultra); | ||
1047 | id->trseuc = __le16_to_cpu(id->trseuc); | ||
1048 | id->trsEuc = __le16_to_cpu(id->trsEuc); | ||
1049 | id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); | ||
1050 | id->mprc = __le16_to_cpu(id->mprc); | ||
1051 | id->hw_config = __le16_to_cpu(id->hw_config); | ||
1052 | id->acoustic = __le16_to_cpu(id->acoustic); | ||
1053 | id->msrqs = __le16_to_cpu(id->msrqs); | ||
1054 | id->sxfert = __le16_to_cpu(id->sxfert); | ||
1055 | id->sal = __le16_to_cpu(id->sal); | ||
1056 | id->spg = __le32_to_cpu(id->spg); | ||
1057 | id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); | ||
1058 | for (i = 0; i < 22; i++) | ||
1059 | id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); | ||
1060 | id->last_lun = __le16_to_cpu(id->last_lun); | ||
1061 | id->word127 = __le16_to_cpu(id->word127); | ||
1062 | id->dlf = __le16_to_cpu(id->dlf); | ||
1063 | id->csfo = __le16_to_cpu(id->csfo); | ||
1064 | for (i = 0; i < 26; i++) | ||
1065 | id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); | ||
1066 | id->word156 = __le16_to_cpu(id->word156); | ||
1067 | for (i = 0; i < 3; i++) | ||
1068 | id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); | ||
1069 | id->cfa_power = __le16_to_cpu(id->cfa_power); | ||
1070 | for (i = 0; i < 14; i++) | ||
1071 | id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); | ||
1072 | for (i = 0; i < 31; i++) | ||
1073 | id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); | ||
1074 | for (i = 0; i < 48; i++) | ||
1075 | id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); | ||
1076 | id->integrity_word = __le16_to_cpu(id->integrity_word); | ||
1077 | # else | ||
1078 | # error "Please fix <asm/byteorder.h>" | ||
1079 | # endif | ||
1080 | #endif | ||
1081 | } | ||
1082 | |||
980 | 1083 | ||
981 | /************************************************************************** | 1084 | /************************************************************************** |
982 | * isd200_get_inquiry_data | 1085 | * isd200_get_inquiry_data |
@@ -1018,7 +1121,7 @@ static int isd200_get_inquiry_data( struct us_data *us ) | |||
1018 | int i; | 1121 | int i; |
1019 | __be16 *src; | 1122 | __be16 *src; |
1020 | __u16 *dest; | 1123 | __u16 *dest; |
1021 | ide_fix_driveid(id); | 1124 | isd200_fix_driveid(id); |
1022 | 1125 | ||
1023 | US_DEBUGP(" Identify Data Structure:\n"); | 1126 | US_DEBUGP(" Identify Data Structure:\n"); |
1024 | US_DEBUGP(" config = 0x%x\n", id->config); | 1127 | US_DEBUGP(" config = 0x%x\n", id->config); |
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index f99cb77e7b..f7e2d5add8 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -2509,8 +2509,7 @@ static int cirrusfb_zorro_register(struct zorro_dev *z, | |||
2509 | cinfo = info->par; | 2509 | cinfo = info->par; |
2510 | cinfo->btype = btype; | 2510 | cinfo->btype = btype; |
2511 | 2511 | ||
2512 | assert(z > 0); | 2512 | assert(z); |
2513 | assert(z2 >= 0); | ||
2514 | assert(btype != BT_NONE); | 2513 | assert(btype != BT_NONE); |
2515 | 2514 | ||
2516 | cinfo->zdev = z; | 2515 | cinfo->zdev = z; |