Lines Matching full:client

46 struct client {  struct
71 static inline void client_get(struct client *client) in client_get() argument
73 kref_get(&client->kref); in client_get()
78 struct client *client = container_of(kref, struct client, kref); in client_release() local
80 fw_device_put(client->device); in client_release()
81 kfree(client); in client_release()
84 static void client_put(struct client *client) in client_put() argument
86 kref_put(&client->kref, client_release); in client_put()
90 typedef void (*client_resource_release_fn_t)(struct client *,
101 struct client *client; member
125 struct client *client; member
126 /* Schedule work and access todo only with client->lock held. */
136 static void release_iso_resource(struct client *, struct client_resource *);
140 client_get(r->client); in schedule_iso_resource()
142 client_put(r->client); in schedule_iso_resource()
168 struct client *client; member
198 struct client *client; member
239 struct client *client; in fw_device_op_open() local
250 client = kzalloc(sizeof(*client), GFP_KERNEL); in fw_device_op_open()
251 if (client == NULL) { in fw_device_op_open()
256 client->device = device; in fw_device_op_open()
257 spin_lock_init(&client->lock); in fw_device_op_open()
258 idr_init(&client->resource_idr); in fw_device_op_open()
259 INIT_LIST_HEAD(&client->event_list); in fw_device_op_open()
260 init_waitqueue_head(&client->wait); in fw_device_op_open()
261 init_waitqueue_head(&client->tx_flush_wait); in fw_device_op_open()
262 INIT_LIST_HEAD(&client->phy_receiver_link); in fw_device_op_open()
263 INIT_LIST_HEAD(&client->link); in fw_device_op_open()
264 kref_init(&client->kref); in fw_device_op_open()
266 file->private_data = client; in fw_device_op_open()
271 static void queue_event(struct client *client, struct event *event, in queue_event() argument
281 spin_lock_irqsave(&client->lock, flags); in queue_event()
282 if (client->in_shutdown) in queue_event()
285 list_add_tail(&event->link, &client->event_list); in queue_event()
286 spin_unlock_irqrestore(&client->lock, flags); in queue_event()
288 wake_up_interruptible(&client->wait); in queue_event()
291 static int dequeue_event(struct client *client, in dequeue_event() argument
298 ret = wait_event_interruptible(client->wait, in dequeue_event()
299 !list_empty(&client->event_list) || in dequeue_event()
300 fw_device_is_shutdown(client->device)); in dequeue_event()
304 if (list_empty(&client->event_list) && in dequeue_event()
305 fw_device_is_shutdown(client->device)) in dequeue_event()
308 spin_lock_irq(&client->lock); in dequeue_event()
309 event = list_first_entry(&client->event_list, struct event, link); in dequeue_event()
311 spin_unlock_irq(&client->lock); in dequeue_event()
333 struct client *client = file->private_data; in fw_device_op_read() local
335 return dequeue_event(client, buffer, count); in fw_device_op_read()
339 struct client *client) in fill_bus_reset_event() argument
341 struct fw_card *card = client->device->card; in fill_bus_reset_event()
345 event->closure = client->bus_reset_closure; in fill_bus_reset_event()
347 event->generation = client->device->generation; in fill_bus_reset_event()
348 event->node_id = client->device->node_id; in fill_bus_reset_event()
358 void (*callback)(struct client *client)) in for_each_client() argument
360 struct client *c; in for_each_client()
375 static void queue_bus_reset_event(struct client *client) in queue_bus_reset_event() argument
383 fill_bus_reset_event(&e->reset, client); in queue_bus_reset_event()
385 queue_event(client, &e->event, in queue_bus_reset_event()
388 spin_lock_irq(&client->lock); in queue_bus_reset_event()
389 idr_for_each(&client->resource_idr, schedule_reallocations, client); in queue_bus_reset_event()
390 spin_unlock_irq(&client->lock); in queue_bus_reset_event()
398 static void wake_up_client(struct client *client) in wake_up_client() argument
400 wake_up_interruptible(&client->wait); in wake_up_client()
431 static int ioctl_get_info(struct client *client, union ioctl_arg *arg) in ioctl_get_info() argument
437 client->version = a->version; in ioctl_get_info()
439 a->card = client->device->card->index; in ioctl_get_info()
445 size_t have = client->device->config_rom_length * 4; in ioctl_get_info()
448 client->device->config_rom, min(want, have)); in ioctl_get_info()
450 a->rom_length = client->device->config_rom_length * 4; in ioctl_get_info()
457 mutex_lock(&client->device->client_list_mutex); in ioctl_get_info()
459 client->bus_reset_closure = a->bus_reset_closure; in ioctl_get_info()
461 fill_bus_reset_event(&bus_reset, client); in ioctl_get_info()
465 if (ret == 0 && list_empty(&client->link)) in ioctl_get_info()
466 list_add_tail(&client->link, &client->device->client_list); in ioctl_get_info()
468 mutex_unlock(&client->device->client_list_mutex); in ioctl_get_info()
473 static int add_client_resource(struct client *client, in add_client_resource() argument
482 spin_lock_irqsave(&client->lock, flags); in add_client_resource()
484 if (client->in_shutdown) in add_client_resource()
487 ret = idr_alloc(&client->resource_idr, resource, 0, 0, in add_client_resource()
491 client_get(client); in add_client_resource()
495 spin_unlock_irqrestore(&client->lock, flags); in add_client_resource()
502 static int release_client_resource(struct client *client, u32 handle, in release_client_resource() argument
508 spin_lock_irq(&client->lock); in release_client_resource()
509 if (client->in_shutdown) in release_client_resource()
512 resource = idr_find(&client->resource_idr, handle); in release_client_resource()
514 idr_remove(&client->resource_idr, handle); in release_client_resource()
515 spin_unlock_irq(&client->lock); in release_client_resource()
523 resource->release(client, resource); in release_client_resource()
525 client_put(client); in release_client_resource()
530 static void release_transaction(struct client *client, in release_transaction() argument
540 struct client *client = e->client; in complete_transaction() local
548 spin_lock_irqsave(&client->lock, flags); in complete_transaction()
549 idr_remove(&client->resource_idr, e->r.resource.handle); in complete_transaction()
550 if (client->in_shutdown) in complete_transaction()
551 wake_up(&client->tx_flush_wait); in complete_transaction()
552 spin_unlock_irqrestore(&client->lock, flags); in complete_transaction()
565 queue_event(client, &e->event, rsp, sizeof(*rsp), in complete_transaction()
568 queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, in complete_transaction()
572 client_put(client); in complete_transaction()
575 static int init_request(struct client *client, in init_request() argument
594 e->client = client; in init_request()
606 ret = add_client_resource(client, &e->r.resource, GFP_KERNEL); in init_request()
610 fw_send_request(client->device->card, &e->r.transaction, in init_request()
622 static int ioctl_send_request(struct client *client, union ioctl_arg *arg) in ioctl_send_request() argument
641 return init_request(client, &arg->send_request, client->device->node_id, in ioctl_send_request()
642 client->device->max_speed); in ioctl_send_request()
650 static void release_request(struct client *client, in release_request() argument
677 /* card may be different from handler->client->device->card */ in handle_request()
703 ret = add_client_resource(handler->client, &r->resource, GFP_ATOMIC); in handle_request()
707 if (handler->client->version < FW_CDEV_VERSION_EVENT_REQUEST2) { in handle_request()
736 queue_event(handler->client, &e->event, in handle_request()
751 static void release_address_handler(struct client *client, in release_address_handler() argument
761 static int ioctl_allocate(struct client *client, union ioctl_arg *arg) in ioctl_allocate() argument
773 if (client->version < FW_CDEV_VERSION_ALLOCATE_REGION_END) in ioctl_allocate()
782 r->client = client; in ioctl_allocate()
792 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_allocate()
794 release_address_handler(client, &r->resource); in ioctl_allocate()
802 static int ioctl_deallocate(struct client *client, union ioctl_arg *arg) in ioctl_deallocate() argument
804 return release_client_resource(client, arg->deallocate.handle, in ioctl_deallocate()
808 static int ioctl_send_response(struct client *client, union ioctl_arg *arg) in ioctl_send_response() argument
815 if (release_client_resource(client, a->handle, in ioctl_send_response()
842 static int ioctl_initiate_bus_reset(struct client *client, union ioctl_arg *arg) in ioctl_initiate_bus_reset() argument
844 fw_schedule_bus_reset(client->device->card, true, in ioctl_initiate_bus_reset()
849 static void release_descriptor(struct client *client, in release_descriptor() argument
859 static int ioctl_add_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_add_descriptor() argument
866 if (!client->device->is_local) in ioctl_add_descriptor()
891 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in ioctl_add_descriptor()
905 static int ioctl_remove_descriptor(struct client *client, union ioctl_arg *arg) in ioctl_remove_descriptor() argument
907 return release_client_resource(client, arg->remove_descriptor.handle, in ioctl_remove_descriptor()
914 struct client *client = data; in iso_callback() local
922 e->interrupt.closure = client->iso_closure; in iso_callback()
926 queue_event(client, &e->event, &e->interrupt, in iso_callback()
933 struct client *client = data; in iso_mc_callback() local
941 e->interrupt.closure = client->iso_closure; in iso_mc_callback()
942 e->interrupt.completed = fw_iso_buffer_lookup(&client->buffer, in iso_mc_callback()
944 queue_event(client, &e->event, &e->interrupt, in iso_mc_callback()
956 static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) in ioctl_create_iso_context() argument
992 context = fw_iso_context_create(client->device->card, a->type, in ioctl_create_iso_context()
993 a->channel, a->speed, a->header_size, cb, client); in ioctl_create_iso_context()
996 if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW) in ioctl_create_iso_context()
1000 spin_lock_irq(&client->lock); in ioctl_create_iso_context()
1001 if (client->iso_context != NULL) { in ioctl_create_iso_context()
1002 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1007 if (!client->buffer_is_mapped) { in ioctl_create_iso_context()
1008 ret = fw_iso_buffer_map_dma(&client->buffer, in ioctl_create_iso_context()
1009 client->device->card, in ioctl_create_iso_context()
1012 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1017 client->buffer_is_mapped = true; in ioctl_create_iso_context()
1019 client->iso_closure = a->closure; in ioctl_create_iso_context()
1020 client->iso_context = context; in ioctl_create_iso_context()
1021 spin_unlock_irq(&client->lock); in ioctl_create_iso_context()
1028 static int ioctl_set_iso_channels(struct client *client, union ioctl_arg *arg) in ioctl_set_iso_channels() argument
1031 struct fw_iso_context *ctx = client->iso_context; in ioctl_set_iso_channels()
1047 static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg) in ioctl_queue_iso() argument
1051 struct fw_iso_context *ctx = client->iso_context; in ioctl_queue_iso()
1072 payload = (unsigned long)a->data - client->vm_start; in ioctl_queue_iso()
1073 buffer_end = client->buffer.page_count << PAGE_SHIFT; in ioctl_queue_iso()
1074 if (a->data == 0 || client->buffer.pages == NULL || in ioctl_queue_iso()
1131 &client->buffer, payload)) in ioctl_queue_iso()
1142 a->data = client->vm_start + payload; in ioctl_queue_iso()
1147 static int ioctl_start_iso(struct client *client, union ioctl_arg *arg) in ioctl_start_iso() argument
1158 if (client->iso_context == NULL || a->handle != 0) in ioctl_start_iso()
1161 if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE && in ioctl_start_iso()
1165 return fw_iso_context_start(client->iso_context, in ioctl_start_iso()
1169 static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg) in ioctl_stop_iso() argument
1173 if (client->iso_context == NULL || a->handle != 0) in ioctl_stop_iso()
1176 return fw_iso_context_stop(client->iso_context); in ioctl_stop_iso()
1179 static int ioctl_flush_iso(struct client *client, union ioctl_arg *arg) in ioctl_flush_iso() argument
1183 if (client->iso_context == NULL || a->handle != 0) in ioctl_flush_iso()
1186 return fw_iso_context_flush_completions(client->iso_context); in ioctl_flush_iso()
1189 static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer2() argument
1192 struct fw_card *card = client->device->card; in ioctl_get_cycle_timer2()
1218 static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg) in ioctl_get_cycle_timer() argument
1224 ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2); in ioctl_get_cycle_timer()
1237 struct client *client = r->client; in iso_resource_work() local
1241 spin_lock_irq(&client->lock); in iso_resource_work()
1242 generation = client->device->generation; in iso_resource_work()
1247 client->device->card->reset_jiffies + HZ)) { in iso_resource_work()
1259 spin_unlock_irq(&client->lock); in iso_resource_work()
1266 fw_iso_resource_manage(client->device->card, generation, in iso_resource_work()
1282 spin_lock_irq(&client->lock); in iso_resource_work()
1284 * Transit from allocation to reallocation, except if the client in iso_resource_work()
1291 * idr and prepare for deletion, unless the client is shutting down. in iso_resource_work()
1294 !client->in_shutdown && in iso_resource_work()
1295 idr_remove(&client->resource_idr, r->resource.handle)) { in iso_resource_work()
1296 client_put(client); in iso_resource_work()
1299 spin_unlock_irq(&client->lock); in iso_resource_work()
1318 queue_event(client, &e->event, in iso_resource_work()
1328 client_put(client); in iso_resource_work()
1331 static void release_iso_resource(struct client *client, in release_iso_resource() argument
1337 spin_lock_irq(&client->lock); in release_iso_resource()
1340 spin_unlock_irq(&client->lock); in release_iso_resource()
1343 static int init_iso_resource(struct client *client, in init_iso_resource() argument
1363 r->client = client; in init_iso_resource()
1378 ret = add_client_resource(client, &r->resource, GFP_KERNEL); in init_iso_resource()
1397 static int ioctl_allocate_iso_resource(struct client *client, in ioctl_allocate_iso_resource() argument
1400 return init_iso_resource(client, in ioctl_allocate_iso_resource()
1404 static int ioctl_deallocate_iso_resource(struct client *client, in ioctl_deallocate_iso_resource() argument
1407 return release_client_resource(client, in ioctl_deallocate_iso_resource()
1411 static int ioctl_allocate_iso_resource_once(struct client *client, in ioctl_allocate_iso_resource_once() argument
1414 return init_iso_resource(client, in ioctl_allocate_iso_resource_once()
1418 static int ioctl_deallocate_iso_resource_once(struct client *client, in ioctl_deallocate_iso_resource_once() argument
1421 return init_iso_resource(client, in ioctl_deallocate_iso_resource_once()
1430 static int ioctl_get_speed(struct client *client, union ioctl_arg *arg) in ioctl_get_speed() argument
1432 return client->device->max_speed; in ioctl_get_speed()
1435 static int ioctl_send_broadcast_request(struct client *client, in ioctl_send_broadcast_request() argument
1452 return init_request(client, a, LOCAL_BUS | 0x3f, SCODE_100); in ioctl_send_broadcast_request()
1455 static int ioctl_send_stream_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_stream_packet() argument
1461 if (a->speed > client->device->card->link_speed || in ioctl_send_stream_packet()
1475 return init_request(client, &request, dest, a->speed); in ioctl_send_stream_packet()
1499 queue_event(e->client, &e->event, &e->phy_packet, in outbound_phy_packet_callback()
1501 client_put(e->client); in outbound_phy_packet_callback()
1504 static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg) in ioctl_send_phy_packet() argument
1507 struct fw_card *card = client->device->card; in ioctl_send_phy_packet()
1511 if (!client->device->is_local) in ioctl_send_phy_packet()
1518 client_get(client); in ioctl_send_phy_packet()
1519 e->client = client; in ioctl_send_phy_packet()
1537 static int ioctl_receive_phy_packets(struct client *client, union ioctl_arg *arg) in ioctl_receive_phy_packets() argument
1540 struct fw_card *card = client->device->card; in ioctl_receive_phy_packets()
1543 if (!client->device->is_local) in ioctl_receive_phy_packets()
1548 list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list); in ioctl_receive_phy_packets()
1549 client->phy_receiver_closure = a->closure; in ioctl_receive_phy_packets()
1558 struct client *client; in fw_cdev_handle_phy_packet() local
1564 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { in fw_cdev_handle_phy_packet()
1569 e->phy_packet.closure = client->phy_receiver_closure; in fw_cdev_handle_phy_packet()
1575 queue_event(client, &e->event, in fw_cdev_handle_phy_packet()
1582 static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = {
1610 static int dispatch_ioctl(struct client *client, in dispatch_ioctl() argument
1616 if (fw_device_is_shutdown(client->device)) in dispatch_ioctl()
1630 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); in dispatch_ioctl()
1649 struct client *client = file->private_data; in fw_device_op_mmap() local
1653 if (fw_device_is_shutdown(client->device)) in fw_device_op_mmap()
1657 if (client->buffer.pages != NULL) in fw_device_op_mmap()
1666 client->vm_start = vma->vm_start; in fw_device_op_mmap()
1672 ret = fw_iso_buffer_alloc(&client->buffer, page_count); in fw_device_op_mmap()
1676 spin_lock_irq(&client->lock); in fw_device_op_mmap()
1677 if (client->iso_context) { in fw_device_op_mmap()
1678 ret = fw_iso_buffer_map_dma(&client->buffer, in fw_device_op_mmap()
1679 client->device->card, in fw_device_op_mmap()
1680 iso_dma_direction(client->iso_context)); in fw_device_op_mmap()
1681 client->buffer_is_mapped = (ret == 0); in fw_device_op_mmap()
1683 spin_unlock_irq(&client->lock); in fw_device_op_mmap()
1687 ret = vm_map_pages_zero(vma, client->buffer.pages, in fw_device_op_mmap()
1688 client->buffer.page_count); in fw_device_op_mmap()
1694 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_mmap()
1705 static int has_outbound_transactions(struct client *client) in has_outbound_transactions() argument
1709 spin_lock_irq(&client->lock); in has_outbound_transactions()
1710 ret = idr_for_each(&client->resource_idr, in has_outbound_transactions()
1712 spin_unlock_irq(&client->lock); in has_outbound_transactions()
1720 struct client *client = data; in shutdown_resource() local
1722 resource->release(client, resource); in shutdown_resource()
1723 client_put(client); in shutdown_resource()
1730 struct client *client = file->private_data; in fw_device_op_release() local
1733 spin_lock_irq(&client->device->card->lock); in fw_device_op_release()
1734 list_del(&client->phy_receiver_link); in fw_device_op_release()
1735 spin_unlock_irq(&client->device->card->lock); in fw_device_op_release()
1737 mutex_lock(&client->device->client_list_mutex); in fw_device_op_release()
1738 list_del(&client->link); in fw_device_op_release()
1739 mutex_unlock(&client->device->client_list_mutex); in fw_device_op_release()
1741 if (client->iso_context) in fw_device_op_release()
1742 fw_iso_context_destroy(client->iso_context); in fw_device_op_release()
1744 if (client->buffer.pages) in fw_device_op_release()
1745 fw_iso_buffer_destroy(&client->buffer, client->device->card); in fw_device_op_release()
1747 /* Freeze client->resource_idr and client->event_list */ in fw_device_op_release()
1748 spin_lock_irq(&client->lock); in fw_device_op_release()
1749 client->in_shutdown = true; in fw_device_op_release()
1750 spin_unlock_irq(&client->lock); in fw_device_op_release()
1752 wait_event(client->tx_flush_wait, !has_outbound_transactions(client)); in fw_device_op_release()
1754 idr_for_each(&client->resource_idr, shutdown_resource, client); in fw_device_op_release()
1755 idr_destroy(&client->resource_idr); in fw_device_op_release()
1757 list_for_each_entry_safe(event, next_event, &client->event_list, link) in fw_device_op_release()
1760 client_put(client); in fw_device_op_release()
1767 struct client *client = file->private_data; in fw_device_op_poll() local
1770 poll_wait(file, &client->wait, pt); in fw_device_op_poll()
1772 if (fw_device_is_shutdown(client->device)) in fw_device_op_poll()
1774 if (!list_empty(&client->event_list)) in fw_device_op_poll()