• Home
  • Raw
  • Download

Lines Matching refs:client

58 struct client {  struct
83 static inline void client_get(struct client *client) in client_get() argument
85 kref_get(&client->kref); in client_get()
90 struct client *client = container_of(kref, struct client, kref); in client_release() local
92 fw_device_put(client->device); in client_release()
93 kfree(client); in client_release()
96 static void client_put(struct client *client) in client_put() argument
98 kref_put(&client->kref, client_release); in client_put()
102 typedef void (*client_resource_release_fn_t)(struct client *,
113 struct client *client; member
137 struct client *client; member
148 static void release_iso_resource(struct client *, struct client_resource *);
152 client_get(r->client); in schedule_iso_resource()
154 client_put(r->client); in schedule_iso_resource()
180 struct client *client; member
210 struct client *client; member
251 struct client *client; in fw_device_op_open() local
262 client = kzalloc(sizeof(*client), GFP_KERNEL); in fw_device_op_open()
263 if (client == NULL) { in fw_device_op_open()
268 client->device = device; in fw_device_op_open()
269 spin_lock_init(&client->lock); in fw_device_op_open()
270 idr_init(&client->resource_idr); in fw_device_op_open()
271 INIT_LIST_HEAD(&client->event_list); in fw_device_op_open()
272 init_waitqueue_head(&client->wait); in fw_device_op_open()
273 init_waitqueue_head(&client->tx_flush_wait); in fw_device_op_open()
274 INIT_LIST_HEAD(&client->phy_receiver_link); in fw_device_op_open()
275 INIT_LIST_HEAD(&client->link); in fw_device_op_open()
276 kref_init(&client->kref); in fw_device_op_open()
278 file->private_data = client; in fw_device_op_open()
283 static void queue_event(struct client *client, struct event *event, in queue_event() argument
293 spin_lock_irqsave(&client->lock, flags); in queue_event()
294 if (client->in_shutdown) in queue_event()
297 list_add_tail(&event->link, &client->event_list); in queue_event()
298 spin_unlock_irqrestore(&client->lock, flags); in queue_event()
300 wake_up_interruptible(&client->wait); in queue_event()
303 static int dequeue_event(struct client *client, in dequeue_event() argument
310 ret = wait_event_interruptible(client->wait, in dequeue_event()
311 !list_empty(&client->event_list) || in dequeue_event()
312 fw_device_is_shutdown(client->device)); in dequeue_event()
316 if (list_empty(&client->event_list) && in dequeue_event()
317 fw_device_is_shutdown(client->device)) in dequeue_event()
320 spin_lock_irq(&client->lock); in dequeue_event()
321 event = list_first_entry(&client->event_list, struct event, link); in dequeue_event()
323 spin_unlock_irq(&client->lock); in dequeue_event()
345 struct client *client = file->private_data; in fw_device_op_read() local
347 return dequeue_event(client, buffer, count); in fw_device_op_read()
351 struct client *client) in fill_bus_reset_event() argument
353 struct fw_card *card = client->device->card; in fill_bus_reset_event()
357 event->closure = client->bus_reset_closure; in fill_bus_reset_event()
359 event->generation = client->device->generation; in fill_bus_reset_event()
360 event->node_id = client->device->node_id; in fill_bus_reset_event()
370 void (*callback)(struct client *client)) in for_each_client() argument
372 struct client *c; in for_each_client()
387 static void queue_bus_reset_event(struct client *client) in queue_bus_reset_event() argument
395 fill_bus_reset_event(&e->reset, client); in queue_bus_reset_event()
397 queue_event(client, &e->event, in queue_bus_reset_event()
400 spin_lock_irq(&client->lock); in queue_bus_reset_event()
401 idr_for_each(&client->resource_idr, schedule_reallocations, client); in queue_bus_reset_event()
402 spin_unlock_irq(&client->lock); in queue_bus_reset_event()
410 static void wake_up_client(struct client *client) in wake_up_client() argument
412 wake_up_interruptible(&client->wait); in wake_up_client()
443 static int ioctl_get_info(struct client *client, union ioctl_arg *arg) in ioctl_get_info() argument
449 client->version = a->version; in ioctl_get_info()
451 a->card = client->device->card->index; in ioctl_get_info()
457 size_t have = client->device->config_rom_length * 4; in ioctl_get_info()
460 client->device->config_rom, min(want, have)); in ioctl_get_info()
462 a->rom_length = client->device->config_rom_length * 4; in ioctl_get_info()
469 mutex_lock(&client->device->client_list_mutex); in ioctl_get_info()
471 client->bus_reset_closure = a->bus_reset_closure; in ioctl_get_info()
473 fill_bus_reset_event(&bus_reset, client); in ioctl_get_info()
477 if (ret == 0 && list_empty(&client->link)) in ioctl_get_info()
478 list_add_tail(&client->link, &client->device->client_list); in ioctl_get_info()
480 mutex_unlock(&client->device->client_list_mutex); in ioctl_get_info()
485 static int add_client_resource(struct client *client, in add_client_resource() argument
494 spin_lock_irqsave(&client->lock, flags); in add_client_resource()
496 if (client->in_shutdown) in add_client_resource()
499 ret = idr_alloc(&client->resource_idr, resource, 0, 0, in add_client_resource()
503 client_get(client); in add_client_resource()
507 spin_unlock_irqrestore(&client->lock, flags); in add_client_resource()
514 static int release_client_resource(struct client *client, u32 handle, in release_client_resource() argument
520 spin_lock_irq(&client->lock); in release_client_resource()
521 if (client->in_shutdown) in release_client_resource()
524 resource = idr_find(&client->resource_idr, handle); in release_client_resource()
526 idr_remove(&client->resource_idr, handle); in release_client_resource()
527 spin_unlock_irq(&client->lock); in release_client_resource()
535 resource->release(client, resource); in release_client_resource()
537 client_put(client); in release_client_resource()
542 static void release_transaction(struct client *client, in release_transaction() argument
552 struct client *client = e->client; in complete_transaction() local
560 spin_lock_irqsave(&client->lock, flags); in complete_transaction()
561 idr_remove(&client->resource_idr, e->r.resource.handle); in complete_transaction()
562 if (client->in_shutdown) in complete_transaction()
563 wake_up(&client->tx_flush_wait); in complete_transaction()
564 spin_unlock_irqrestore(&client->lock, flags); in complete_transaction()
577 queue_event(client, &e->event, rsp, sizeof(*rsp), in complete_transaction()
580 queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, in complete_transaction()
584 client_put(client); in complete_transaction()
587 static int init_request(struct client *client, in init_request() argument
606 e->client = client; in init_request()
618 ret = add_client_resource(client, &e->r.resource, GFP_KERNEL); in init_request()
622 fw_send_request(client->device->card, &e->r.transaction, in init_request()
634 static int ioctl_send_request(struct client *client, union ioctl_arg *arg) in ioctl_send_request() argument
653 return init_request(client, &arg->send_request, client->device->node_id, in ioctl_send_request()
654 client->device->max_speed); in ioctl_send_request()
662 static void release_request(struct client *client, in release_request() argument
715 ret = add_client_resource(handler->client, &r->resource, GFP_ATOMIC); in handle_request()
719 if (handler->client->version < FW_CDEV_VERSION_EVENT_REQUEST2) { in handle_request()
748 queue_event(handler->client, &e->event, in handle_request()
763 static void release_address_handler(struct client *client, in release_address_handler() argument
773 static int ioctl_allocate(struct client *client, union ioctl_arg *arg) in ioctl_allocate() argument
785 if (client->version < FW_CDEV_VERSION_ALLOCATE_REGION_END) in ioctl_allocate()
794 r->client = client; in ioctl_allocate()
804 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_allocate()
806 release_address_handler(client, &r->resource); in ioctl_allocate()
814 static int ioctl_deallocate(struct client *client, union ioctl_arg *arg) in ioctl_deallocate() argument
816 return release_client_resource(client, arg->deallocate.handle, in ioctl_deallocate()
820 static int ioctl_send_response(struct client *client, union ioctl_arg *arg) in ioctl_send_response() argument
827 if (release_client_resource(client, a->handle, in ioctl_send_response()
854 static int ioctl_initiate_bus_reset(struct client *client, union ioctl_arg *arg) in ioctl_initiate_bus_reset() argument
856 fw_schedule_bus_reset(client->device->card, true, in ioctl_initiate_bus_reset()
861 static void release_descriptor(struct client *client, in release_descriptor() argument
871 static int ioctl_add_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_add_descriptor() argument
878 if (!client->device->is_local) in ioctl_add_descriptor()
903 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_add_descriptor()
917 static int ioctl_remove_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_remove_descriptor() argument
919 return release_client_resource(client, arg->remove_descriptor.handle, in ioctl_remove_descriptor()
926 struct client *client = data; in iso_callback() local
934 e->interrupt.closure = client->iso_closure; in iso_callback()
938 queue_event(client, &e->event, &e->interrupt, in iso_callback()
945 struct client *client = data; in iso_mc_callback() local
953 e->interrupt.closure = client->iso_closure; in iso_mc_callback()
954 e->interrupt.completed = fw_iso_buffer_lookup(&client->buffer, in iso_mc_callback()
956 queue_event(client, &e->event, &e->interrupt, in iso_mc_callback()
968 static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) in ioctl_create_iso_context() argument
1004 context = fw_iso_context_create(client->device->card, a->type, in ioctl_create_iso_context()
1005 a->channel, a->speed, a->header_size, cb, client); in ioctl_create_iso_context()
1010 spin_lock_irq(&client->lock); in ioctl_create_iso_context()
1011 if (client->iso_context != NULL) { in ioctl_create_iso_context()
1012 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1017 if (!client->buffer_is_mapped) { in ioctl_create_iso_context()
1018 ret = fw_iso_buffer_map_dma(&client->buffer, in ioctl_create_iso_context()
1019 client->device->card, in ioctl_create_iso_context()
1022 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1027 client->buffer_is_mapped = true; in ioctl_create_iso_context()
1029 client->iso_closure = a->closure; in ioctl_create_iso_context()
1030 client->iso_context = context; in ioctl_create_iso_context()
1031 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1038 static int ioctl_set_iso_channels(struct client *client, union ioctl_arg *arg) in ioctl_set_iso_channels() argument
1041 struct fw_iso_context *ctx = client->iso_context; in ioctl_set_iso_channels()
1057 static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg) in ioctl_queue_iso() argument
1061 struct fw_iso_context *ctx = client->iso_context; in ioctl_queue_iso()
1082 payload = (unsigned long)a->data - client->vm_start; in ioctl_queue_iso()
1083 buffer_end = client->buffer.page_count << PAGE_SHIFT; in ioctl_queue_iso()
1084 if (a->data == 0 || client->buffer.pages == NULL || in ioctl_queue_iso()
1143 &client->buffer, payload)) in ioctl_queue_iso()
1154 a->data = client->vm_start + payload; in ioctl_queue_iso()
1159 static int ioctl_start_iso(struct client *client, union ioctl_arg *arg) in ioctl_start_iso() argument
1170 if (client->iso_context == NULL || a->handle != 0) in ioctl_start_iso()
1173 if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE && in ioctl_start_iso()
1177 return fw_iso_context_start(client->iso_context, in ioctl_start_iso()
1181 static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg) in ioctl_stop_iso() argument
1185 if (client->iso_context == NULL || a->handle != 0) in ioctl_stop_iso()
1188 return fw_iso_context_stop(client->iso_context); in ioctl_stop_iso()
1191 static int ioctl_flush_iso(struct client *client, union ioctl_arg *arg) in ioctl_flush_iso() argument
1195 if (client->iso_context == NULL || a->handle != 0) in ioctl_flush_iso()
1198 return fw_iso_context_flush_completions(client->iso_context); in ioctl_flush_iso()
1201 static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer2() argument
1204 struct fw_card *card = client->device->card; in ioctl_get_cycle_timer2()
1230 static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer() argument
1236 ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2); in ioctl_get_cycle_timer()
1249 struct client *client = r->client; in iso_resource_work() local
1253 spin_lock_irq(&client->lock); in iso_resource_work()
1254 generation = client->device->generation; in iso_resource_work()
1259 client->device->card->reset_jiffies + HZ)) { in iso_resource_work()
1271 spin_unlock_irq(&client->lock); in iso_resource_work()
1278 fw_iso_resource_manage(client->device->card, generation, in iso_resource_work()
1294 spin_lock_irq(&client->lock); in iso_resource_work()
1306 !client->in_shutdown && in iso_resource_work()
1307 idr_find(&client->resource_idr, r->resource.handle)) { in iso_resource_work()
1308 idr_remove(&client->resource_idr, r->resource.handle); in iso_resource_work()
1309 client_put(client); in iso_resource_work()
1312 spin_unlock_irq(&client->lock); in iso_resource_work()
1331 queue_event(client, &e->event, in iso_resource_work()
1341 client_put(client); in iso_resource_work()
1344 static void release_iso_resource(struct client *client, in release_iso_resource() argument
1350 spin_lock_irq(&client->lock); in release_iso_resource()
1353 spin_unlock_irq(&client->lock); in release_iso_resource()
1356 static int init_iso_resource(struct client *client, in init_iso_resource() argument
1376 r->client = client; in init_iso_resource()
1391 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in init_iso_resource()
1410 static int ioctl_allocate_iso_resource(struct client *client, in ioctl_allocate_iso_resource() argument
1413 return init_iso_resource(client, in ioctl_allocate_iso_resource()
1417 static int ioctl_deallocate_iso_resource(struct client *client, in ioctl_deallocate_iso_resource() argument
1420 return release_client_resource(client, in ioctl_deallocate_iso_resource()
1424 static int ioctl_allocate_iso_resource_once(struct client *client, in ioctl_allocate_iso_resource_once() argument
1427 return init_iso_resource(client, in ioctl_allocate_iso_resource_once()
1431 static int ioctl_deallocate_iso_resource_once(struct client *client, in ioctl_deallocate_iso_resource_once() argument
1434 return init_iso_resource(client, in ioctl_deallocate_iso_resource_once()
1443 static int ioctl_get_speed(struct client *client, union ioctl_arg *arg) in ioctl_get_speed() argument
1445 return client->device->max_speed; in ioctl_get_speed()
1448 static int ioctl_send_broadcast_request(struct client *client, in ioctl_send_broadcast_request() argument
1465 return init_request(client, a, LOCAL_BUS | 0x3f, SCODE_100); in ioctl_send_broadcast_request()
1468 static int ioctl_send_stream_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_stream_packet() argument
1474 if (a->speed > client->device->card->link_speed || in ioctl_send_stream_packet()
1488 return init_request(client, &request, dest, a->speed); in ioctl_send_stream_packet()
1512 queue_event(e->client, &e->event, &e->phy_packet, in outbound_phy_packet_callback()
1514 client_put(e->client); in outbound_phy_packet_callback()
1517 static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_phy_packet() argument
1520 struct fw_card *card = client->device->card; in ioctl_send_phy_packet()
1524 if (!client->device->is_local) in ioctl_send_phy_packet()
1531 client_get(client); in ioctl_send_phy_packet()
1532 e->client = client; in ioctl_send_phy_packet()
1550 static int ioctl_receive_phy_packets(struct client *client, union ioctl_arg *arg) in ioctl_receive_phy_packets() argument
1553 struct fw_card *card = client->device->card; in ioctl_receive_phy_packets()
1556 if (!client->device->is_local) in ioctl_receive_phy_packets()
1561 list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list); in ioctl_receive_phy_packets()
1562 client->phy_receiver_closure = a->closure; in ioctl_receive_phy_packets()
1571 struct client *client; in fw_cdev_handle_phy_packet() local
1577 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { in fw_cdev_handle_phy_packet()
1582 e->phy_packet.closure = client->phy_receiver_closure; in fw_cdev_handle_phy_packet()
1588 queue_event(client, &e->event, in fw_cdev_handle_phy_packet()
1595 static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = {
1623 static int dispatch_ioctl(struct client *client, in dispatch_ioctl() argument
1629 if (fw_device_is_shutdown(client->device)) in dispatch_ioctl()
1644 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); in dispatch_ioctl()
1671 struct client *client = file->private_data; in fw_device_op_mmap() local
1675 if (fw_device_is_shutdown(client->device)) in fw_device_op_mmap()
1679 if (client->buffer.pages != NULL) in fw_device_op_mmap()
1688 client->vm_start = vma->vm_start; in fw_device_op_mmap()
1694 ret = fw_iso_buffer_alloc(&client->buffer, page_count); in fw_device_op_mmap()
1698 spin_lock_irq(&client->lock); in fw_device_op_mmap()
1699 if (client->iso_context) { in fw_device_op_mmap()
1700 ret = fw_iso_buffer_map_dma(&client->buffer, in fw_device_op_mmap()
1701 client->device->card, in fw_device_op_mmap()
1702 iso_dma_direction(client->iso_context)); in fw_device_op_mmap()
1703 client->buffer_is_mapped = (ret == 0); in fw_device_op_mmap()
1705 spin_unlock_irq(&client->lock); in fw_device_op_mmap()
1709 ret = fw_iso_buffer_map_vma(&client->buffer, vma); in fw_device_op_mmap()
1715 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_mmap()
1726 static int has_outbound_transactions(struct client *client) in has_outbound_transactions() argument
1730 spin_lock_irq(&client->lock); in has_outbound_transactions()
1731 ret = idr_for_each(&client->resource_idr, in has_outbound_transactions()
1733 spin_unlock_irq(&client->lock); in has_outbound_transactions()
1741 struct client *client = data; in shutdown_resource() local
1743 resource->release(client, resource); in shutdown_resource()
1744 client_put(client); in shutdown_resource()
1751 struct client *client = file->private_data; in fw_device_op_release() local
1754 spin_lock_irq(&client->device->card->lock); in fw_device_op_release()
1755 list_del(&client->phy_receiver_link); in fw_device_op_release()
1756 spin_unlock_irq(&client->device->card->lock); in fw_device_op_release()
1758 mutex_lock(&client->device->client_list_mutex); in fw_device_op_release()
1759 list_del(&client->link); in fw_device_op_release()
1760 mutex_unlock(&client->device->client_list_mutex); in fw_device_op_release()
1762 if (client->iso_context) in fw_device_op_release()
1763 fw_iso_context_destroy(client->iso_context); in fw_device_op_release()
1765 if (client->buffer.pages) in fw_device_op_release()
1766 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_release()
1769 spin_lock_irq(&client->lock); in fw_device_op_release()
1770 client->in_shutdown = true; in fw_device_op_release()
1771 spin_unlock_irq(&client->lock); in fw_device_op_release()
1773 wait_event(client->tx_flush_wait, !has_outbound_transactions(client)); in fw_device_op_release()
1775 idr_for_each(&client->resource_idr, shutdown_resource, client); in fw_device_op_release()
1776 idr_destroy(&client->resource_idr); in fw_device_op_release()
1778 list_for_each_entry_safe(event, next_event, &client->event_list, link) in fw_device_op_release()
1781 client_put(client); in fw_device_op_release()
1788 struct client *client = file->private_data; in fw_device_op_poll() local
1791 poll_wait(file, &client->wait, pt); in fw_device_op_poll()
1793 if (fw_device_is_shutdown(client->device)) in fw_device_op_poll()
1795 if (!list_empty(&client->event_list)) in fw_device_op_poll()