• Home
  • Raw
  • Download

Lines Matching refs:client

59 struct client {  struct
84 static inline void client_get(struct client *client) in client_get() argument
86 kref_get(&client->kref); in client_get()
91 struct client *client = container_of(kref, struct client, kref); in client_release() local
93 fw_device_put(client->device); in client_release()
94 kfree(client); in client_release()
97 static void client_put(struct client *client) in client_put() argument
99 kref_put(&client->kref, client_release); in client_put()
103 typedef void (*client_resource_release_fn_t)(struct client *,
114 struct client *client; member
138 struct client *client; member
149 static void release_iso_resource(struct client *, struct client_resource *);
153 client_get(r->client); in schedule_iso_resource()
155 client_put(r->client); in schedule_iso_resource()
181 struct client *client; member
211 struct client *client; member
252 struct client *client; in fw_device_op_open() local
263 client = kzalloc(sizeof(*client), GFP_KERNEL); in fw_device_op_open()
264 if (client == NULL) { in fw_device_op_open()
269 client->device = device; in fw_device_op_open()
270 spin_lock_init(&client->lock); in fw_device_op_open()
271 idr_init(&client->resource_idr); in fw_device_op_open()
272 INIT_LIST_HEAD(&client->event_list); in fw_device_op_open()
273 init_waitqueue_head(&client->wait); in fw_device_op_open()
274 init_waitqueue_head(&client->tx_flush_wait); in fw_device_op_open()
275 INIT_LIST_HEAD(&client->phy_receiver_link); in fw_device_op_open()
276 INIT_LIST_HEAD(&client->link); in fw_device_op_open()
277 kref_init(&client->kref); in fw_device_op_open()
279 file->private_data = client; in fw_device_op_open()
284 static void queue_event(struct client *client, struct event *event, in queue_event() argument
294 spin_lock_irqsave(&client->lock, flags); in queue_event()
295 if (client->in_shutdown) in queue_event()
298 list_add_tail(&event->link, &client->event_list); in queue_event()
299 spin_unlock_irqrestore(&client->lock, flags); in queue_event()
301 wake_up_interruptible(&client->wait); in queue_event()
304 static int dequeue_event(struct client *client, in dequeue_event() argument
311 ret = wait_event_interruptible(client->wait, in dequeue_event()
312 !list_empty(&client->event_list) || in dequeue_event()
313 fw_device_is_shutdown(client->device)); in dequeue_event()
317 if (list_empty(&client->event_list) && in dequeue_event()
318 fw_device_is_shutdown(client->device)) in dequeue_event()
321 spin_lock_irq(&client->lock); in dequeue_event()
322 event = list_first_entry(&client->event_list, struct event, link); in dequeue_event()
324 spin_unlock_irq(&client->lock); in dequeue_event()
346 struct client *client = file->private_data; in fw_device_op_read() local
348 return dequeue_event(client, buffer, count); in fw_device_op_read()
352 struct client *client) in fill_bus_reset_event() argument
354 struct fw_card *card = client->device->card; in fill_bus_reset_event()
358 event->closure = client->bus_reset_closure; in fill_bus_reset_event()
360 event->generation = client->device->generation; in fill_bus_reset_event()
361 event->node_id = client->device->node_id; in fill_bus_reset_event()
371 void (*callback)(struct client *client)) in for_each_client() argument
373 struct client *c; in for_each_client()
388 static void queue_bus_reset_event(struct client *client) in queue_bus_reset_event() argument
396 fill_bus_reset_event(&e->reset, client); in queue_bus_reset_event()
398 queue_event(client, &e->event, in queue_bus_reset_event()
401 spin_lock_irq(&client->lock); in queue_bus_reset_event()
402 idr_for_each(&client->resource_idr, schedule_reallocations, client); in queue_bus_reset_event()
403 spin_unlock_irq(&client->lock); in queue_bus_reset_event()
411 static void wake_up_client(struct client *client) in wake_up_client() argument
413 wake_up_interruptible(&client->wait); in wake_up_client()
444 static int ioctl_get_info(struct client *client, union ioctl_arg *arg) in ioctl_get_info() argument
450 client->version = a->version; in ioctl_get_info()
452 a->card = client->device->card->index; in ioctl_get_info()
458 size_t have = client->device->config_rom_length * 4; in ioctl_get_info()
461 client->device->config_rom, min(want, have)); in ioctl_get_info()
463 a->rom_length = client->device->config_rom_length * 4; in ioctl_get_info()
470 mutex_lock(&client->device->client_list_mutex); in ioctl_get_info()
472 client->bus_reset_closure = a->bus_reset_closure; in ioctl_get_info()
474 fill_bus_reset_event(&bus_reset, client); in ioctl_get_info()
478 if (ret == 0 && list_empty(&client->link)) in ioctl_get_info()
479 list_add_tail(&client->link, &client->device->client_list); in ioctl_get_info()
481 mutex_unlock(&client->device->client_list_mutex); in ioctl_get_info()
486 static int add_client_resource(struct client *client, in add_client_resource() argument
495 spin_lock_irqsave(&client->lock, flags); in add_client_resource()
497 if (client->in_shutdown) in add_client_resource()
500 ret = idr_alloc(&client->resource_idr, resource, 0, 0, in add_client_resource()
504 client_get(client); in add_client_resource()
508 spin_unlock_irqrestore(&client->lock, flags); in add_client_resource()
515 static int release_client_resource(struct client *client, u32 handle, in release_client_resource() argument
521 spin_lock_irq(&client->lock); in release_client_resource()
522 if (client->in_shutdown) in release_client_resource()
525 resource = idr_find(&client->resource_idr, handle); in release_client_resource()
527 idr_remove(&client->resource_idr, handle); in release_client_resource()
528 spin_unlock_irq(&client->lock); in release_client_resource()
536 resource->release(client, resource); in release_client_resource()
538 client_put(client); in release_client_resource()
543 static void release_transaction(struct client *client, in release_transaction() argument
553 struct client *client = e->client; in complete_transaction() local
561 spin_lock_irqsave(&client->lock, flags); in complete_transaction()
562 idr_remove(&client->resource_idr, e->r.resource.handle); in complete_transaction()
563 if (client->in_shutdown) in complete_transaction()
564 wake_up(&client->tx_flush_wait); in complete_transaction()
565 spin_unlock_irqrestore(&client->lock, flags); in complete_transaction()
578 queue_event(client, &e->event, rsp, sizeof(*rsp), in complete_transaction()
581 queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, in complete_transaction()
585 client_put(client); in complete_transaction()
588 static int init_request(struct client *client, in init_request() argument
607 e->client = client; in init_request()
619 ret = add_client_resource(client, &e->r.resource, GFP_KERNEL); in init_request()
623 fw_send_request(client->device->card, &e->r.transaction, in init_request()
635 static int ioctl_send_request(struct client *client, union ioctl_arg *arg) in ioctl_send_request() argument
654 return init_request(client, &arg->send_request, client->device->node_id, in ioctl_send_request()
655 client->device->max_speed); in ioctl_send_request()
663 static void release_request(struct client *client, in release_request() argument
716 ret = add_client_resource(handler->client, &r->resource, GFP_ATOMIC); in handle_request()
720 if (handler->client->version < FW_CDEV_VERSION_EVENT_REQUEST2) { in handle_request()
749 queue_event(handler->client, &e->event, in handle_request()
764 static void release_address_handler(struct client *client, in release_address_handler() argument
774 static int ioctl_allocate(struct client *client, union ioctl_arg *arg) in ioctl_allocate() argument
786 if (client->version < FW_CDEV_VERSION_ALLOCATE_REGION_END) in ioctl_allocate()
795 r->client = client; in ioctl_allocate()
805 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_allocate()
807 release_address_handler(client, &r->resource); in ioctl_allocate()
815 static int ioctl_deallocate(struct client *client, union ioctl_arg *arg) in ioctl_deallocate() argument
817 return release_client_resource(client, arg->deallocate.handle, in ioctl_deallocate()
821 static int ioctl_send_response(struct client *client, union ioctl_arg *arg) in ioctl_send_response() argument
828 if (release_client_resource(client, a->handle, in ioctl_send_response()
855 static int ioctl_initiate_bus_reset(struct client *client, union ioctl_arg *arg) in ioctl_initiate_bus_reset() argument
857 fw_schedule_bus_reset(client->device->card, true, in ioctl_initiate_bus_reset()
862 static void release_descriptor(struct client *client, in release_descriptor() argument
872 static int ioctl_add_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_add_descriptor() argument
879 if (!client->device->is_local) in ioctl_add_descriptor()
904 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_add_descriptor()
918 static int ioctl_remove_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_remove_descriptor() argument
920 return release_client_resource(client, arg->remove_descriptor.handle, in ioctl_remove_descriptor()
927 struct client *client = data; in iso_callback() local
935 e->interrupt.closure = client->iso_closure; in iso_callback()
939 queue_event(client, &e->event, &e->interrupt, in iso_callback()
946 struct client *client = data; in iso_mc_callback() local
954 e->interrupt.closure = client->iso_closure; in iso_mc_callback()
955 e->interrupt.completed = fw_iso_buffer_lookup(&client->buffer, in iso_mc_callback()
957 queue_event(client, &e->event, &e->interrupt, in iso_mc_callback()
969 static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) in ioctl_create_iso_context() argument
1005 context = fw_iso_context_create(client->device->card, a->type, in ioctl_create_iso_context()
1006 a->channel, a->speed, a->header_size, cb, client); in ioctl_create_iso_context()
1009 if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW) in ioctl_create_iso_context()
1013 spin_lock_irq(&client->lock); in ioctl_create_iso_context()
1014 if (client->iso_context != NULL) { in ioctl_create_iso_context()
1015 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1020 if (!client->buffer_is_mapped) { in ioctl_create_iso_context()
1021 ret = fw_iso_buffer_map_dma(&client->buffer, in ioctl_create_iso_context()
1022 client->device->card, in ioctl_create_iso_context()
1025 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1030 client->buffer_is_mapped = true; in ioctl_create_iso_context()
1032 client->iso_closure = a->closure; in ioctl_create_iso_context()
1033 client->iso_context = context; in ioctl_create_iso_context()
1034 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1041 static int ioctl_set_iso_channels(struct client *client, union ioctl_arg *arg) in ioctl_set_iso_channels() argument
1044 struct fw_iso_context *ctx = client->iso_context; in ioctl_set_iso_channels()
1060 static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg) in ioctl_queue_iso() argument
1064 struct fw_iso_context *ctx = client->iso_context; in ioctl_queue_iso()
1085 payload = (unsigned long)a->data - client->vm_start; in ioctl_queue_iso()
1086 buffer_end = client->buffer.page_count << PAGE_SHIFT; in ioctl_queue_iso()
1087 if (a->data == 0 || client->buffer.pages == NULL || in ioctl_queue_iso()
1146 &client->buffer, payload)) in ioctl_queue_iso()
1157 a->data = client->vm_start + payload; in ioctl_queue_iso()
1162 static int ioctl_start_iso(struct client *client, union ioctl_arg *arg) in ioctl_start_iso() argument
1173 if (client->iso_context == NULL || a->handle != 0) in ioctl_start_iso()
1176 if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE && in ioctl_start_iso()
1180 return fw_iso_context_start(client->iso_context, in ioctl_start_iso()
1184 static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg) in ioctl_stop_iso() argument
1188 if (client->iso_context == NULL || a->handle != 0) in ioctl_stop_iso()
1191 return fw_iso_context_stop(client->iso_context); in ioctl_stop_iso()
1194 static int ioctl_flush_iso(struct client *client, union ioctl_arg *arg) in ioctl_flush_iso() argument
1198 if (client->iso_context == NULL || a->handle != 0) in ioctl_flush_iso()
1201 return fw_iso_context_flush_completions(client->iso_context); in ioctl_flush_iso()
1204 static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer2() argument
1207 struct fw_card *card = client->device->card; in ioctl_get_cycle_timer2()
1233 static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer() argument
1239 ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2); in ioctl_get_cycle_timer()
1252 struct client *client = r->client; in iso_resource_work() local
1256 spin_lock_irq(&client->lock); in iso_resource_work()
1257 generation = client->device->generation; in iso_resource_work()
1262 client->device->card->reset_jiffies + HZ)) { in iso_resource_work()
1274 spin_unlock_irq(&client->lock); in iso_resource_work()
1281 fw_iso_resource_manage(client->device->card, generation, in iso_resource_work()
1297 spin_lock_irq(&client->lock); in iso_resource_work()
1309 !client->in_shutdown && in iso_resource_work()
1310 idr_remove(&client->resource_idr, r->resource.handle)) { in iso_resource_work()
1311 client_put(client); in iso_resource_work()
1314 spin_unlock_irq(&client->lock); in iso_resource_work()
1333 queue_event(client, &e->event, in iso_resource_work()
1343 client_put(client); in iso_resource_work()
1346 static void release_iso_resource(struct client *client, in release_iso_resource() argument
1352 spin_lock_irq(&client->lock); in release_iso_resource()
1355 spin_unlock_irq(&client->lock); in release_iso_resource()
1358 static int init_iso_resource(struct client *client, in init_iso_resource() argument
1378 r->client = client; in init_iso_resource()
1393 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in init_iso_resource()
1412 static int ioctl_allocate_iso_resource(struct client *client, in ioctl_allocate_iso_resource() argument
1415 return init_iso_resource(client, in ioctl_allocate_iso_resource()
1419 static int ioctl_deallocate_iso_resource(struct client *client, in ioctl_deallocate_iso_resource() argument
1422 return release_client_resource(client, in ioctl_deallocate_iso_resource()
1426 static int ioctl_allocate_iso_resource_once(struct client *client, in ioctl_allocate_iso_resource_once() argument
1429 return init_iso_resource(client, in ioctl_allocate_iso_resource_once()
1433 static int ioctl_deallocate_iso_resource_once(struct client *client, in ioctl_deallocate_iso_resource_once() argument
1436 return init_iso_resource(client, in ioctl_deallocate_iso_resource_once()
1445 static int ioctl_get_speed(struct client *client, union ioctl_arg *arg) in ioctl_get_speed() argument
1447 return client->device->max_speed; in ioctl_get_speed()
1450 static int ioctl_send_broadcast_request(struct client *client, in ioctl_send_broadcast_request() argument
1467 return init_request(client, a, LOCAL_BUS | 0x3f, SCODE_100); in ioctl_send_broadcast_request()
1470 static int ioctl_send_stream_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_stream_packet() argument
1476 if (a->speed > client->device->card->link_speed || in ioctl_send_stream_packet()
1490 return init_request(client, &request, dest, a->speed); in ioctl_send_stream_packet()
1514 queue_event(e->client, &e->event, &e->phy_packet, in outbound_phy_packet_callback()
1516 client_put(e->client); in outbound_phy_packet_callback()
1519 static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_phy_packet() argument
1522 struct fw_card *card = client->device->card; in ioctl_send_phy_packet()
1526 if (!client->device->is_local) in ioctl_send_phy_packet()
1533 client_get(client); in ioctl_send_phy_packet()
1534 e->client = client; in ioctl_send_phy_packet()
1552 static int ioctl_receive_phy_packets(struct client *client, union ioctl_arg *arg) in ioctl_receive_phy_packets() argument
1555 struct fw_card *card = client->device->card; in ioctl_receive_phy_packets()
1558 if (!client->device->is_local) in ioctl_receive_phy_packets()
1563 list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list); in ioctl_receive_phy_packets()
1564 client->phy_receiver_closure = a->closure; in ioctl_receive_phy_packets()
1573 struct client *client; in fw_cdev_handle_phy_packet() local
1579 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { in fw_cdev_handle_phy_packet()
1584 e->phy_packet.closure = client->phy_receiver_closure; in fw_cdev_handle_phy_packet()
1590 queue_event(client, &e->event, in fw_cdev_handle_phy_packet()
1597 static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = {
1625 static int dispatch_ioctl(struct client *client, in dispatch_ioctl() argument
1631 if (fw_device_is_shutdown(client->device)) in dispatch_ioctl()
1645 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); in dispatch_ioctl()
1672 struct client *client = file->private_data; in fw_device_op_mmap() local
1676 if (fw_device_is_shutdown(client->device)) in fw_device_op_mmap()
1680 if (client->buffer.pages != NULL) in fw_device_op_mmap()
1689 client->vm_start = vma->vm_start; in fw_device_op_mmap()
1695 ret = fw_iso_buffer_alloc(&client->buffer, page_count); in fw_device_op_mmap()
1699 spin_lock_irq(&client->lock); in fw_device_op_mmap()
1700 if (client->iso_context) { in fw_device_op_mmap()
1701 ret = fw_iso_buffer_map_dma(&client->buffer, in fw_device_op_mmap()
1702 client->device->card, in fw_device_op_mmap()
1703 iso_dma_direction(client->iso_context)); in fw_device_op_mmap()
1704 client->buffer_is_mapped = (ret == 0); in fw_device_op_mmap()
1706 spin_unlock_irq(&client->lock); in fw_device_op_mmap()
1710 ret = fw_iso_buffer_map_vma(&client->buffer, vma); in fw_device_op_mmap()
1716 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_mmap()
1727 static int has_outbound_transactions(struct client *client) in has_outbound_transactions() argument
1731 spin_lock_irq(&client->lock); in has_outbound_transactions()
1732 ret = idr_for_each(&client->resource_idr, in has_outbound_transactions()
1734 spin_unlock_irq(&client->lock); in has_outbound_transactions()
1742 struct client *client = data; in shutdown_resource() local
1744 resource->release(client, resource); in shutdown_resource()
1745 client_put(client); in shutdown_resource()
1752 struct client *client = file->private_data; in fw_device_op_release() local
1755 spin_lock_irq(&client->device->card->lock); in fw_device_op_release()
1756 list_del(&client->phy_receiver_link); in fw_device_op_release()
1757 spin_unlock_irq(&client->device->card->lock); in fw_device_op_release()
1759 mutex_lock(&client->device->client_list_mutex); in fw_device_op_release()
1760 list_del(&client->link); in fw_device_op_release()
1761 mutex_unlock(&client->device->client_list_mutex); in fw_device_op_release()
1763 if (client->iso_context) in fw_device_op_release()
1764 fw_iso_context_destroy(client->iso_context); in fw_device_op_release()
1766 if (client->buffer.pages) in fw_device_op_release()
1767 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_release()
1770 spin_lock_irq(&client->lock); in fw_device_op_release()
1771 client->in_shutdown = true; in fw_device_op_release()
1772 spin_unlock_irq(&client->lock); in fw_device_op_release()
1774 wait_event(client->tx_flush_wait, !has_outbound_transactions(client)); in fw_device_op_release()
1776 idr_for_each(&client->resource_idr, shutdown_resource, client); in fw_device_op_release()
1777 idr_destroy(&client->resource_idr); in fw_device_op_release()
1779 list_for_each_entry_safe(event, next_event, &client->event_list, link) in fw_device_op_release()
1782 client_put(client); in fw_device_op_release()
1789 struct client *client = file->private_data; in fw_device_op_poll() local
1792 poll_wait(file, &client->wait, pt); in fw_device_op_poll()
1794 if (fw_device_is_shutdown(client->device)) in fw_device_op_poll()
1796 if (!list_empty(&client->event_list)) in fw_device_op_poll()