Lines Matching refs:device
154 static struct dma_chan *dev_to_dma_chan(struct device *dev) in dev_to_dma_chan()
158 chan_dev = container_of(dev, typeof(*chan_dev), device); in dev_to_dma_chan()
162 static ssize_t memcpy_count_show(struct device *dev, in memcpy_count_show()
184 static ssize_t bytes_transferred_show(struct device *dev, in bytes_transferred_show()
206 static ssize_t in_use_show(struct device *dev, struct device_attribute *attr, in in_use_show()
232 static void chan_dev_release(struct device *dev) in chan_dev_release()
236 chan_dev = container_of(dev, typeof(*chan_dev), device); in chan_dev_release()
304 int node = dev_to_node(chan->device->dev); in dma_chan_is_local()
322 struct dma_device *device; in min_chan() local
327 list_for_each_entry(device, &dma_device_list, global_node) { in min_chan()
328 if (!dma_has_cap(cap, device->cap_mask) || in min_chan()
329 dma_has_cap(DMA_PRIVATE, device->cap_mask)) in min_chan()
331 list_for_each_entry(chan, &device->channels, device_node) { in min_chan()
364 struct dma_device *device; in dma_channel_rebalance() local
373 list_for_each_entry(device, &dma_device_list, global_node) { in dma_channel_rebalance()
374 if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dma_channel_rebalance()
376 list_for_each_entry(chan, &device->channels, device_node) in dma_channel_rebalance()
392 static int dma_device_satisfies_mask(struct dma_device *device, in dma_device_satisfies_mask() argument
397 bitmap_and(has.bits, want->bits, device->cap_mask.bits, in dma_device_satisfies_mask()
404 return chan->device->owner; in dma_chan_to_owner()
425 struct dma_device *device = container_of(ref, struct dma_device, ref); in dma_device_release() local
427 list_del_rcu(&device->global_node); in dma_device_release()
430 if (device->device_release) in dma_device_release()
431 device->device_release(device); in dma_device_release()
434 static void dma_device_put(struct dma_device *device) in dma_device_put() argument
437 kref_put(&device->ref, dma_device_release); in dma_device_put()
461 ret = kref_get_unless_zero(&chan->device->ref); in dma_chan_get()
468 if (chan->device->device_alloc_chan_resources) { in dma_chan_get()
469 ret = chan->device->device_alloc_chan_resources(chan); in dma_chan_get()
476 if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask)) in dma_chan_get()
482 dma_device_put(chan->device); in dma_chan_get()
503 if (!chan->client_count && chan->device->device_free_chan_resources) { in dma_chan_put()
506 chan->device->device_free_chan_resources(chan); in dma_chan_put()
516 dma_device_put(chan->device); in dma_chan_put()
529 dev_err(chan->device->dev, "%s: timeout!\n", __func__); in dma_sync_wait()
556 struct dma_device *device; in dma_issue_pending_all() local
560 list_for_each_entry_rcu(device, &dma_device_list, global_node) { in dma_issue_pending_all()
561 if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dma_issue_pending_all()
563 list_for_each_entry(chan, &device->channels, device_node) in dma_issue_pending_all()
565 device->device_issue_pending(chan); in dma_issue_pending_all()
573 struct dma_device *device; in dma_get_slave_caps() local
578 device = chan->device; in dma_get_slave_caps()
581 if (!(test_bit(DMA_SLAVE, device->cap_mask.bits) || in dma_get_slave_caps()
582 test_bit(DMA_CYCLIC, device->cap_mask.bits))) in dma_get_slave_caps()
590 if (!device->directions) in dma_get_slave_caps()
593 caps->src_addr_widths = device->src_addr_widths; in dma_get_slave_caps()
594 caps->dst_addr_widths = device->dst_addr_widths; in dma_get_slave_caps()
595 caps->directions = device->directions; in dma_get_slave_caps()
596 caps->min_burst = device->min_burst; in dma_get_slave_caps()
597 caps->max_burst = device->max_burst; in dma_get_slave_caps()
598 caps->max_sg_burst = device->max_sg_burst; in dma_get_slave_caps()
599 caps->residue_granularity = device->residue_granularity; in dma_get_slave_caps()
600 caps->descriptor_reuse = device->descriptor_reuse; in dma_get_slave_caps()
601 caps->cmd_pause = !!device->device_pause; in dma_get_slave_caps()
602 caps->cmd_resume = !!device->device_resume; in dma_get_slave_caps()
603 caps->cmd_terminate = !!device->device_terminate_all; in dma_get_slave_caps()
612 if (device->device_caps) in dma_get_slave_caps()
613 device->device_caps(chan, caps); in dma_get_slave_caps()
656 static struct dma_chan *find_candidate(struct dma_device *device, in find_candidate() argument
660 struct dma_chan *chan = private_candidate(mask, device, fn, fn_param); in find_candidate()
669 dma_cap_set(DMA_PRIVATE, device->cap_mask); in find_candidate()
670 device->privatecnt++; in find_candidate()
675 dev_dbg(device->dev, "%s: %s module removed\n", in find_candidate()
677 list_del_rcu(&device->global_node); in find_candidate()
679 dev_dbg(device->dev, in find_candidate()
683 if (--device->privatecnt == 0) in find_candidate()
684 dma_cap_clear(DMA_PRIVATE, device->cap_mask); in find_candidate()
705 struct dma_device *device = chan->device; in dma_get_slave_channel() local
707 dma_cap_set(DMA_PRIVATE, device->cap_mask); in dma_get_slave_channel()
708 device->privatecnt++; in dma_get_slave_channel()
711 dev_dbg(chan->device->dev, in dma_get_slave_channel()
715 if (--device->privatecnt == 0) in dma_get_slave_channel()
716 dma_cap_clear(DMA_PRIVATE, device->cap_mask); in dma_get_slave_channel()
728 struct dma_chan *dma_get_any_slave_channel(struct dma_device *device) in dma_get_any_slave_channel() argument
739 chan = find_candidate(device, &mask, NULL, NULL); in dma_get_any_slave_channel()
760 struct dma_device *device, *_d; in __dma_request_channel() local
765 list_for_each_entry_safe(device, _d, &dma_device_list, global_node) { in __dma_request_channel()
767 if (np && device->dev->of_node && np != device->dev->of_node) in __dma_request_channel()
770 chan = find_candidate(device, mask, fn, fn_param); in __dma_request_channel()
787 static const struct dma_slave_map *dma_filter_match(struct dma_device *device, in dma_filter_match() argument
789 struct device *dev) in dma_filter_match()
793 if (!device->filter.mapcnt) in dma_filter_match()
796 for (i = 0; i < device->filter.mapcnt; i++) { in dma_filter_match()
797 const struct dma_slave_map *map = &device->filter.map[i]; in dma_filter_match()
814 struct dma_chan *dma_request_chan(struct device *dev, const char *name) in dma_request_chan()
867 if (sysfs_create_link(&chan->dev->device.kobj, &dev->kobj, in dma_request_chan()
870 if (sysfs_create_link(&dev->kobj, &chan->dev->device.kobj, chan->name)) in dma_request_chan()
911 if (--chan->device->privatecnt == 0) in dma_release_channel()
912 dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask); in dma_release_channel()
915 sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME); in dma_release_channel()
935 struct dma_device *device, *_d; in dmaengine_get() local
943 list_for_each_entry_safe(device, _d, &dma_device_list, global_node) { in dmaengine_get()
944 if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dmaengine_get()
946 list_for_each_entry(chan, &device->channels, device_node) { in dmaengine_get()
950 list_del_rcu(&device->global_node); in dmaengine_get()
953 dev_dbg(chan->device->dev, in dmaengine_get()
974 struct dma_device *device, *_d; in dmaengine_put() local
981 list_for_each_entry_safe(device, _d, &dma_device_list, global_node) { in dmaengine_put()
982 if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dmaengine_put()
984 list_for_each_entry(chan, &device->channels, device_node) in dmaengine_put()
991 static bool device_has_all_tx_types(struct dma_device *device) in device_has_all_tx_types() argument
998 if (!dma_has_cap(DMA_INTERRUPT, device->cap_mask)) in device_has_all_tx_types()
1003 if (!dma_has_cap(DMA_MEMCPY, device->cap_mask)) in device_has_all_tx_types()
1008 if (!dma_has_cap(DMA_XOR, device->cap_mask)) in device_has_all_tx_types()
1012 if (!dma_has_cap(DMA_XOR_VAL, device->cap_mask)) in device_has_all_tx_types()
1018 if (!dma_has_cap(DMA_PQ, device->cap_mask)) in device_has_all_tx_types()
1022 if (!dma_has_cap(DMA_PQ_VAL, device->cap_mask)) in device_has_all_tx_types()
1030 static int get_dma_id(struct dma_device *device) in get_dma_id() argument
1036 device->dev_id = rc; in get_dma_id()
1040 static int __dma_async_device_channel_register(struct dma_device *device, in __dma_async_device_channel_register() argument
1058 mutex_lock(&device->chan_mutex); in __dma_async_device_channel_register()
1059 chan->chan_id = ida_alloc(&device->chan_ida, GFP_KERNEL); in __dma_async_device_channel_register()
1060 mutex_unlock(&device->chan_mutex); in __dma_async_device_channel_register()
1068 chan->dev->device.class = &dma_devclass; in __dma_async_device_channel_register()
1069 chan->dev->device.parent = device->dev; in __dma_async_device_channel_register()
1071 chan->dev->dev_id = device->dev_id; in __dma_async_device_channel_register()
1072 dev_set_name(&chan->dev->device, "dma%dchan%d", in __dma_async_device_channel_register()
1073 device->dev_id, chan->chan_id); in __dma_async_device_channel_register()
1074 rc = device_register(&chan->dev->device); in __dma_async_device_channel_register()
1078 device->chancnt++; in __dma_async_device_channel_register()
1083 mutex_lock(&device->chan_mutex); in __dma_async_device_channel_register()
1084 ida_free(&device->chan_ida, chan->chan_id); in __dma_async_device_channel_register()
1085 mutex_unlock(&device->chan_mutex); in __dma_async_device_channel_register()
1094 int dma_async_device_channel_register(struct dma_device *device, in dma_async_device_channel_register() argument
1099 rc = __dma_async_device_channel_register(device, chan); in dma_async_device_channel_register()
1108 static void __dma_async_device_channel_unregister(struct dma_device *device, in __dma_async_device_channel_unregister() argument
1114 WARN_ONCE(!device->device_release && chan->client_count, in __dma_async_device_channel_unregister()
1118 device->chancnt--; in __dma_async_device_channel_unregister()
1121 mutex_lock(&device->chan_mutex); in __dma_async_device_channel_unregister()
1122 ida_free(&device->chan_ida, chan->chan_id); in __dma_async_device_channel_unregister()
1123 mutex_unlock(&device->chan_mutex); in __dma_async_device_channel_unregister()
1124 device_unregister(&chan->dev->device); in __dma_async_device_channel_unregister()
1128 void dma_async_device_channel_unregister(struct dma_device *device, in dma_async_device_channel_unregister() argument
1131 __dma_async_device_channel_unregister(device, chan); in dma_async_device_channel_unregister()
1144 int dma_async_device_register(struct dma_device *device) in dma_async_device_register() argument
1149 if (!device) in dma_async_device_register()
1153 if (!device->dev) { in dma_async_device_register()
1158 device->owner = device->dev->driver->owner; in dma_async_device_register()
1160 if (dma_has_cap(DMA_MEMCPY, device->cap_mask) && !device->device_prep_dma_memcpy) { in dma_async_device_register()
1161 dev_err(device->dev, in dma_async_device_register()
1167 if (dma_has_cap(DMA_XOR, device->cap_mask) && !device->device_prep_dma_xor) { in dma_async_device_register()
1168 dev_err(device->dev, in dma_async_device_register()
1174 if (dma_has_cap(DMA_XOR_VAL, device->cap_mask) && !device->device_prep_dma_xor_val) { in dma_async_device_register()
1175 dev_err(device->dev, in dma_async_device_register()
1181 if (dma_has_cap(DMA_PQ, device->cap_mask) && !device->device_prep_dma_pq) { in dma_async_device_register()
1182 dev_err(device->dev, in dma_async_device_register()
1188 if (dma_has_cap(DMA_PQ_VAL, device->cap_mask) && !device->device_prep_dma_pq_val) { in dma_async_device_register()
1189 dev_err(device->dev, in dma_async_device_register()
1195 if (dma_has_cap(DMA_MEMSET, device->cap_mask) && !device->device_prep_dma_memset) { in dma_async_device_register()
1196 dev_err(device->dev, in dma_async_device_register()
1202 if (dma_has_cap(DMA_INTERRUPT, device->cap_mask) && !device->device_prep_dma_interrupt) { in dma_async_device_register()
1203 dev_err(device->dev, in dma_async_device_register()
1209 if (dma_has_cap(DMA_CYCLIC, device->cap_mask) && !device->device_prep_dma_cyclic) { in dma_async_device_register()
1210 dev_err(device->dev, in dma_async_device_register()
1216 if (dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && !device->device_prep_interleaved_dma) { in dma_async_device_register()
1217 dev_err(device->dev, in dma_async_device_register()
1224 if (!device->device_tx_status) { in dma_async_device_register()
1225 dev_err(device->dev, "Device tx_status is not defined\n"); in dma_async_device_register()
1230 if (!device->device_issue_pending) { in dma_async_device_register()
1231 dev_err(device->dev, "Device issue_pending is not defined\n"); in dma_async_device_register()
1235 if (!device->device_release) in dma_async_device_register()
1236 dev_dbg(device->dev, in dma_async_device_register()
1239 kref_init(&device->ref); in dma_async_device_register()
1244 if (device_has_all_tx_types(device)) in dma_async_device_register()
1245 dma_cap_set(DMA_ASYNC_TX, device->cap_mask); in dma_async_device_register()
1247 rc = get_dma_id(device); in dma_async_device_register()
1251 mutex_init(&device->chan_mutex); in dma_async_device_register()
1252 ida_init(&device->chan_ida); in dma_async_device_register()
1255 list_for_each_entry(chan, &device->channels, device_node) { in dma_async_device_register()
1256 rc = __dma_async_device_channel_register(device, chan); in dma_async_device_register()
1263 if (dmaengine_ref_count && !dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dma_async_device_register()
1264 list_for_each_entry(chan, &device->channels, device_node) { in dma_async_device_register()
1278 list_add_tail_rcu(&device->global_node, &dma_device_list); in dma_async_device_register()
1279 if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) in dma_async_device_register()
1280 device->privatecnt++; /* Always private */ in dma_async_device_register()
1284 dmaengine_debug_register(device); in dma_async_device_register()
1290 if (!device->chancnt) { in dma_async_device_register()
1291 ida_free(&dma_ida, device->dev_id); in dma_async_device_register()
1295 list_for_each_entry(chan, &device->channels, device_node) { in dma_async_device_register()
1301 device_unregister(&chan->dev->device); in dma_async_device_register()
1315 void dma_async_device_unregister(struct dma_device *device) in dma_async_device_unregister() argument
1319 dmaengine_debug_unregister(device); in dma_async_device_unregister()
1321 list_for_each_entry_safe(chan, n, &device->channels, device_node) in dma_async_device_unregister()
1322 __dma_async_device_channel_unregister(device, chan); in dma_async_device_unregister()
1329 dma_cap_set(DMA_PRIVATE, device->cap_mask); in dma_async_device_unregister()
1331 ida_free(&dma_ida, device->dev_id); in dma_async_device_unregister()
1332 dma_device_put(device); in dma_async_device_unregister()
1337 static void dmam_device_release(struct device *dev, void *res) in dmam_device_release()
1339 struct dma_device *device; in dmam_device_release() local
1341 device = *(struct dma_device **)res; in dmam_device_release()
1342 dma_async_device_unregister(device); in dmam_device_release()
1351 int dmaenginem_async_device_register(struct dma_device *device) in dmaenginem_async_device_register() argument
1360 ret = dma_async_device_register(device); in dmaenginem_async_device_register()
1362 *(struct dma_device **)p = device; in dmaenginem_async_device_register()
1363 devres_add(device->dev, p); in dmaenginem_async_device_register()
1413 struct device *dev = unmap->dev; in dmaengine_unmap()
1484 dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags) in dmaengine_get_unmap_data()
1598 dev_err(tx->chan->device->dev, in dma_wait_for_async_tx()
1646 chan->device->device_issue_pending(chan); in dma_run_dependencies()