Skip to content

Commit d2149b5

Browse files
author
Steve French
committed
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
2 parents 25741b3 + 346f7db commit d2149b5

File tree

16 files changed

+207
-44
lines changed

16 files changed

+207
-44
lines changed

Documentation/usb/error-codes.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ USB-specific:
4646

4747
-EMSGSIZE (a) endpoint maxpacket size is zero; it is not usable
4848
in the current interface altsetting.
49-
(b) ISO packet is biger than endpoint maxpacket
50-
(c) requested data transfer size is invalid (negative)
49+
(b) ISO packet is larger than the endpoint maxpacket.
50+
(c) requested data transfer length is invalid: negative
51+
or too large for the host controller.
5152

5253
-ENOSPC This request would overcommit the usb bandwidth reserved
5354
for periodic transfers (interrupt, isochronous).

drivers/char/drm/drm_context.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
432432

433433
if (ctx.handle != DRM_KERNEL_CONTEXT) {
434434
if (dev->driver->context_ctor)
435-
dev->driver->context_ctor(dev, ctx.handle);
435+
if (!dev->driver->context_ctor(dev, ctx.handle)) {
436+
DRM_DEBUG( "Running out of ctxs or memory.\n");
437+
return -ENOMEM;
438+
}
436439
}
437440

438441
ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST);

drivers/hwmon/w83792d.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static const u8 W83792D_REG_LEVELS[3][4] = {
193193
0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */
194194
};
195195

196+
#define W83792D_REG_GPIO_EN 0x1A
196197
#define W83792D_REG_CONFIG 0x40
197198
#define W83792D_REG_VID_FANDIV 0x47
198199
#define W83792D_REG_CHIPID 0x49
@@ -257,7 +258,7 @@ DIV_TO_REG(long val)
257258
{
258259
int i;
259260
val = SENSORS_LIMIT(val, 1, 128) >> 1;
260-
for (i = 0; i < 6; i++) {
261+
for (i = 0; i < 7; i++) {
261262
if (val == 0)
262263
break;
263264
val >>= 1;
@@ -1282,8 +1283,8 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
12821283
w83792d_init_client(new_client);
12831284

12841285
/* A few vars need to be filled upon startup */
1285-
for (i = 1; i <= 7; i++) {
1286-
data->fan_min[i - 1] = w83792d_read_value(new_client,
1286+
for (i = 0; i < 7; i++) {
1287+
data->fan_min[i] = w83792d_read_value(new_client,
12871288
W83792D_REG_FAN_MIN[i]);
12881289
}
12891290

@@ -1306,10 +1307,20 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
13061307
device_create_file_fan(new_client, 1);
13071308
device_create_file_fan(new_client, 2);
13081309
device_create_file_fan(new_client, 3);
1309-
device_create_file_fan(new_client, 4);
1310-
device_create_file_fan(new_client, 5);
1311-
device_create_file_fan(new_client, 6);
1312-
device_create_file_fan(new_client, 7);
1310+
1311+
/* Read GPIO enable register to check if pins for fan 4,5 are used as
1312+
GPIO */
1313+
val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN);
1314+
if (!(val1 & 0x40))
1315+
device_create_file_fan(new_client, 4);
1316+
if (!(val1 & 0x20))
1317+
device_create_file_fan(new_client, 5);
1318+
1319+
val1 = w83792d_read_value(new_client, W83792D_REG_PIN);
1320+
if (val1 & 0x40)
1321+
device_create_file_fan(new_client, 6);
1322+
if (val1 & 0x04)
1323+
device_create_file_fan(new_client, 7);
13131324

13141325
device_create_file_temp1(new_client); /* Temp1 */
13151326
device_create_file_temp_add(new_client, 2); /* Temp2 */

drivers/usb/atm/cxacru.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
787787
{ /* V = Conexant P = ADSL modem (Hasbani project) */
788788
USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
789789
},
790+
{ /* V = Conexant P = ADSL modem (Well PTI-800 */
791+
USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792+
},
790793
{ /* V = Conexant P = ADSL modem */
791794
USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
792795
},

drivers/usb/core/hcd-pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
219219
goto done;
220220
}
221221
}
222+
synchronize_irq(dev->irq);
222223

223224
/* FIXME until the generic PM interfaces change a lot more, this
224225
* can't use PCI D1 and D2 states. For example, the confusion
@@ -392,7 +393,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
392393

393394
dev->dev.power.power_state = PMSG_ON;
394395

395-
hcd->saw_irq = 0;
396+
clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
396397

397398
if (hcd->driver->resume) {
398399
retval = hcd->driver->resume(hcd);

drivers/usb/core/hcd.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,11 +1315,12 @@ static int hcd_unlink_urb (struct urb *urb, int status)
13151315
* finish unlinking the initial failed usb_set_address()
13161316
* or device descriptor fetch.
13171317
*/
1318-
if (!hcd->saw_irq && hcd->self.root_hub != urb->dev) {
1318+
if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags)
1319+
&& hcd->self.root_hub != urb->dev) {
13191320
dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
13201321
"Controller is probably using the wrong IRQ."
13211322
"\n");
1322-
hcd->saw_irq = 1;
1323+
set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
13231324
}
13241325

13251326
urb->status = status;
@@ -1649,13 +1650,15 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
16491650
struct usb_hcd *hcd = __hcd;
16501651
int start = hcd->state;
16511652

1652-
if (start == HC_STATE_HALT)
1653+
if (unlikely(start == HC_STATE_HALT ||
1654+
!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
16531655
return IRQ_NONE;
16541656
if (hcd->driver->irq (hcd, r) == IRQ_NONE)
16551657
return IRQ_NONE;
16561658

1657-
hcd->saw_irq = 1;
1658-
if (hcd->state == HC_STATE_HALT)
1659+
set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1660+
1661+
if (unlikely(hcd->state == HC_STATE_HALT))
16591662
usb_hc_died (hcd);
16601663
return IRQ_HANDLED;
16611664
}
@@ -1768,6 +1771,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
17681771

17691772
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
17701773

1774+
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1775+
17711776
/* till now HC has been in an indeterminate state ... */
17721777
if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) {
17731778
dev_err(hcd->self.controller, "can't reset\n");

drivers/usb/core/hcd.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */
7272
* hardware info/state
7373
*/
7474
const struct hc_driver *driver; /* hw-specific hooks */
75-
unsigned saw_irq : 1;
75+
76+
/* Flags that need to be manipulated atomically */
77+
unsigned long flags;
78+
#define HCD_FLAG_HW_ACCESSIBLE 0x00000001
79+
#define HCD_FLAG_SAW_IRQ 0x00000002
80+
7681
unsigned can_wakeup:1; /* hw supports wakeup? */
7782
unsigned remote_wakeup:1;/* sw should use wakeup? */
7883
unsigned rh_registered:1;/* is root hub registered? */

drivers/usb/host/ehci-pci.c

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
121121
return 0;
122122
}
123123

124-
/* called by khubd or root hub (re)init threads; leaves HC in halt state */
125-
static int ehci_pci_reset(struct usb_hcd *hcd)
124+
/* called during probe() after chip reset completes */
125+
static int ehci_pci_setup(struct usb_hcd *hcd)
126126
{
127127
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
128128
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
@@ -141,6 +141,11 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
141141
if (retval)
142142
return retval;
143143

144+
/* data structure init */
145+
retval = ehci_init(hcd);
146+
if (retval)
147+
return retval;
148+
144149
/* NOTE: only the parts below this line are PCI-specific */
145150

146151
switch (pdev->vendor) {
@@ -154,7 +159,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
154159
/* AMD8111 EHCI doesn't work, according to AMD errata */
155160
if (pdev->device == 0x7463) {
156161
ehci_info(ehci, "ignoring AMD8111 (errata)\n");
157-
return -EIO;
162+
retval = -EIO;
163+
goto done;
158164
}
159165
break;
160166
case PCI_VENDOR_ID_NVIDIA:
@@ -207,9 +213,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
207213
/* REVISIT: per-port wake capability (PCI 0x62) currently unused */
208214

209215
retval = ehci_pci_reinit(ehci, pdev);
210-
211-
/* finish init */
212-
return ehci_init(hcd);
216+
done:
217+
return retval;
213218
}
214219

215220
/*-------------------------------------------------------------------------*/
@@ -228,14 +233,36 @@ static int ehci_pci_reset(struct usb_hcd *hcd)
228233
static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
229234
{
230235
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
236+
unsigned long flags;
237+
int rc = 0;
231238

232239
if (time_before(jiffies, ehci->next_statechange))
233240
msleep(10);
234241

242+
/* Root hub was already suspended. Disable irq emission and
243+
* mark HW unaccessible, bail out if RH has been resumed. Use
244+
* the spinlock to properly synchronize with possible pending
245+
* RH suspend or resume activity.
246+
*
247+
* This is still racy as hcd->state is manipulated outside of
248+
* any locks =P But that will be a different fix.
249+
*/
250+
spin_lock_irqsave (&ehci->lock, flags);
251+
if (hcd->state != HC_STATE_SUSPENDED) {
252+
rc = -EINVAL;
253+
goto bail;
254+
}
255+
writel (0, &ehci->regs->intr_enable);
256+
(void)readl(&ehci->regs->intr_enable);
257+
258+
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
259+
bail:
260+
spin_unlock_irqrestore (&ehci->lock, flags);
261+
235262
// could save FLADJ in case of Vaux power loss
236263
// ... we'd only use it to handle clock skew
237264

238-
return 0;
265+
return rc;
239266
}
240267

241268
static int ehci_pci_resume(struct usb_hcd *hcd)
@@ -251,6 +278,9 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
251278
if (time_before(jiffies, ehci->next_statechange))
252279
msleep(100);
253280

281+
/* Mark hardware accessible again as we are out of D3 state by now */
282+
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
283+
254284
/* If CF is clear, we lost PCI Vaux power and need to restart. */
255285
if (readl(&ehci->regs->configured_flag) != FLAG_CF)
256286
goto restart;
@@ -319,7 +349,7 @@ static const struct hc_driver ehci_pci_hc_driver = {
319349
/*
320350
* basic lifecycle operations
321351
*/
322-
.reset = ehci_pci_reset,
352+
.reset = ehci_pci_setup,
323353
.start = ehci_run,
324354
#ifdef CONFIG_PM
325355
.suspend = ehci_pci_suspend,

drivers/usb/host/ehci-q.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ submit_async (
912912
int epnum;
913913
unsigned long flags;
914914
struct ehci_qh *qh = NULL;
915+
int rc = 0;
915916

916917
qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list);
917918
epnum = ep->desc.bEndpointAddress;
@@ -926,21 +927,28 @@ submit_async (
926927
#endif
927928

928929
spin_lock_irqsave (&ehci->lock, flags);
930+
if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
931+
&ehci_to_hcd(ehci)->flags))) {
932+
rc = -ESHUTDOWN;
933+
goto done;
934+
}
935+
929936
qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);
937+
if (unlikely(qh == NULL)) {
938+
rc = -ENOMEM;
939+
goto done;
940+
}
930941

931942
/* Control/bulk operations through TTs don't need scheduling,
932943
* the HC and TT handle it when the TT has a buffer ready.
933944
*/
934-
if (likely (qh != NULL)) {
935-
if (likely (qh->qh_state == QH_STATE_IDLE))
936-
qh_link_async (ehci, qh_get (qh));
937-
}
945+
if (likely (qh->qh_state == QH_STATE_IDLE))
946+
qh_link_async (ehci, qh_get (qh));
947+
done:
938948
spin_unlock_irqrestore (&ehci->lock, flags);
939-
if (unlikely (qh == NULL)) {
949+
if (unlikely (qh == NULL))
940950
qtd_list_free (ehci, urb, qtd_list);
941-
return -ENOMEM;
942-
}
943-
return 0;
951+
return rc;
944952
}
945953

946954
/*-------------------------------------------------------------------------*/

drivers/usb/host/ehci-sched.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ static int intr_submit (
602602

603603
spin_lock_irqsave (&ehci->lock, flags);
604604

605+
if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
606+
&ehci_to_hcd(ehci)->flags))) {
607+
status = -ESHUTDOWN;
608+
goto done;
609+
}
610+
605611
/* get qh and force any scheduling errors */
606612
INIT_LIST_HEAD (&empty);
607613
qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,7 +1462,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
14561462

14571463
/* schedule ... need to lock */
14581464
spin_lock_irqsave (&ehci->lock, flags);
1459-
status = iso_stream_schedule (ehci, urb, stream);
1465+
if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1466+
&ehci_to_hcd(ehci)->flags)))
1467+
status = -ESHUTDOWN;
1468+
else
1469+
status = iso_stream_schedule (ehci, urb, stream);
14601470
if (likely (status == 0))
14611471
itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
14621472
spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1815,7 +1825,11 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
18151825

18161826
/* schedule ... need to lock */
18171827
spin_lock_irqsave (&ehci->lock, flags);
1818-
status = iso_stream_schedule (ehci, urb, stream);
1828+
if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1829+
&ehci_to_hcd(ehci)->flags)))
1830+
status = -ESHUTDOWN;
1831+
else
1832+
status = iso_stream_schedule (ehci, urb, stream);
18191833
if (status == 0)
18201834
sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
18211835
spin_unlock_irqrestore (&ehci->lock, flags);

drivers/usb/host/ohci-hcd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
/*-------------------------------------------------------------------------*/
117117

118-
// #define OHCI_VERBOSE_DEBUG /* not always helpful */
118+
#undef OHCI_VERBOSE_DEBUG /* not always helpful */
119119

120120
/* For initializing controller (mask in an HCFS mode too) */
121121
#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
@@ -253,6 +253,10 @@ static int ohci_urb_enqueue (
253253
spin_lock_irqsave (&ohci->lock, flags);
254254

255255
/* don't submit to a dead HC */
256+
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
257+
retval = -ENODEV;
258+
goto fail;
259+
}
256260
if (!HC_IS_RUNNING(hcd->state)) {
257261
retval = -ENODEV;
258262
goto fail;

0 commit comments

Comments
 (0)