Lines Matching +full:lock +full:- +full:status

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
4 * Copyright (C) 2015-2016 Nobuo Iwata
13 /* Hardening for Spectre-v1 */
24 * hs 0000 004 000 00000000 000003 1-2.3
26 * ss 0008 004 000 00000000 000004 2-3.4
31 * /sys/devices/platform/vhci_hcd.0/status and in debug output.
42 port, vdev->ud.status); in port_show_vhci()
45 port, vdev->ud.status); in port_show_vhci()
47 if (vdev->ud.status == VDEV_ST_USED) { in port_show_vhci()
49 vdev->speed, vdev->devid); in port_show_vhci()
51 vdev->ud.sockfd, in port_show_vhci()
52 dev_name(&vdev->udev->dev)); in port_show_vhci()
56 *out += sprintf(*out, "000000 0-0"); in port_show_vhci()
62 /* Sysfs entry to show port status */
74 usbip_dbg_vhci_sysfs("show status error\n"); in status_show_vhci()
80 vhci = vhci_hcd->vhci; in status_show_vhci()
82 spin_lock_irqsave(&vhci->lock, flags); in status_show_vhci()
85 struct vhci_device *vdev = &vhci->vhci_hcd_hs->vdev[i]; in status_show_vhci()
87 spin_lock(&vdev->ud.lock); in status_show_vhci()
90 spin_unlock(&vdev->ud.lock); in status_show_vhci()
94 struct vhci_device *vdev = &vhci->vhci_hcd_ss->vdev[i]; in status_show_vhci()
96 spin_lock(&vdev->ud.lock); in status_show_vhci()
99 spin_unlock(&vdev->ud.lock); in status_show_vhci()
102 spin_unlock_irqrestore(&vhci->lock, flags); in status_show_vhci()
104 return out - s; in status_show_vhci()
116 out += sprintf(out, "000 00000000 0000000000000000 0-0"); in status_show_not_ready()
124 out += sprintf(out, "000 00000000 0000000000000000 0-0"); in status_show_not_ready()
127 return out - s; in status_show_not_ready()
156 pdev_nr = status_name_to_id(attr->attr.name); in status_show()
162 return out - s; in status_show()
175 return out - s; in nports_show()
182 struct vhci_device *vdev = &vhci_hcd->vdev[rhport]; in vhci_port_disconnect()
183 struct vhci *vhci = vhci_hcd->vhci; in vhci_port_disconnect()
188 mutex_lock(&vdev->ud.sysfs_lock); in vhci_port_disconnect()
190 /* lock */ in vhci_port_disconnect()
191 spin_lock_irqsave(&vhci->lock, flags); in vhci_port_disconnect()
192 spin_lock(&vdev->ud.lock); in vhci_port_disconnect()
194 if (vdev->ud.status == VDEV_ST_NULL) { in vhci_port_disconnect()
195 pr_err("not connected %d\n", vdev->ud.status); in vhci_port_disconnect()
198 spin_unlock(&vdev->ud.lock); in vhci_port_disconnect()
199 spin_unlock_irqrestore(&vhci->lock, flags); in vhci_port_disconnect()
200 mutex_unlock(&vdev->ud.sysfs_lock); in vhci_port_disconnect()
202 return -EINVAL; in vhci_port_disconnect()
206 spin_unlock(&vdev->ud.lock); in vhci_port_disconnect()
207 spin_unlock_irqrestore(&vhci->lock, flags); in vhci_port_disconnect()
209 usbip_event_add(&vdev->ud, VDEV_EVENT_DOWN); in vhci_port_disconnect()
211 mutex_unlock(&vdev->ud.sysfs_lock); in vhci_port_disconnect()
242 return -EINVAL; in detach_store()
248 return -EINVAL; in detach_store()
253 return -EAGAIN; in detach_store()
259 vhci_hcd = hcd_to_vhci_hcd(hcd)->vhci->vhci_hcd_ss; in detach_store()
261 vhci_hcd = hcd_to_vhci_hcd(hcd)->vhci->vhci_hcd_hs; in detach_store()
265 return -EINVAL; in detach_store()
303 * A remote device is virtually attached to the root-hub port of @rhport with
331 return -EINVAL; in attach_store()
342 return -EINVAL; in attach_store()
347 return -EAGAIN; in attach_store()
351 vhci = vhci_hcd->vhci; in attach_store()
354 vdev = &vhci->vhci_hcd_ss->vdev[rhport]; in attach_store()
356 vdev = &vhci->vhci_hcd_hs->vdev[rhport]; in attach_store()
358 mutex_lock(&vdev->ud.sysfs_lock); in attach_store()
364 err = -EINVAL; in attach_store()
367 if (socket->type != SOCK_STREAM) { in attach_store()
368 dev_err(dev, "Expecting SOCK_STREAM - found %d", in attach_store()
369 socket->type); in attach_store()
371 err = -EINVAL; in attach_store()
376 tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx"); in attach_store()
379 err = -EINVAL; in attach_store()
382 tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx"); in attach_store()
386 err = -EINVAL; in attach_store()
394 /* now begin lock until setting vdev status set */ in attach_store()
395 spin_lock_irqsave(&vhci->lock, flags); in attach_store()
396 spin_lock(&vdev->ud.lock); in attach_store()
398 if (vdev->ud.status != VDEV_ST_NULL) { in attach_store()
399 /* end of the lock */ in attach_store()
400 spin_unlock(&vdev->ud.lock); in attach_store()
401 spin_unlock_irqrestore(&vhci->lock, flags); in attach_store()
412 err = -EBUSY; in attach_store()
421 vdev->devid = devid; in attach_store()
422 vdev->speed = speed; in attach_store()
423 vdev->ud.sockfd = sockfd; in attach_store()
424 vdev->ud.tcp_socket = socket; in attach_store()
425 vdev->ud.tcp_rx = tcp_rx; in attach_store()
426 vdev->ud.tcp_tx = tcp_tx; in attach_store()
427 vdev->ud.status = VDEV_ST_NOTASSIGNED; in attach_store()
428 usbip_kcov_handle_init(&vdev->ud); in attach_store()
430 spin_unlock(&vdev->ud.lock); in attach_store()
431 spin_unlock_irqrestore(&vhci->lock, flags); in attach_store()
432 /* end the lock */ in attach_store()
434 wake_up_process(vdev->ud.tcp_rx); in attach_store()
435 wake_up_process(vdev->ud.tcp_tx); in attach_store()
441 mutex_unlock(&vdev->ud.sysfs_lock); in attach_store()
446 mutex_unlock(&vdev->ud.sysfs_lock); in attach_store()
462 struct status_attr *status; in set_status_attr() local
464 status = status_attrs + id; in set_status_attr()
466 strcpy(status->name, "status"); in set_status_attr()
468 snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id); in set_status_attr()
469 status->attr.attr.name = status->name; in set_status_attr()
470 status->attr.attr.mode = S_IRUGO; in set_status_attr()
471 status->attr.show = status_show; in set_status_attr()
472 sysfs_attr_init(&status->attr.attr); in set_status_attr()
482 return -ENOMEM; in init_status_attrs()
507 return -ENOMEM; in vhci_init_attr_group()
519 *(attrs + i + 4) = &((status_attrs + i)->attr.attr); in vhci_init_attr_group()