Lines Matching +full:host +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2010-2013, NVIDIA Corporation.
19 chlist->channels = kcalloc(num_channels, sizeof(struct host1x_channel), in host1x_channel_list_init()
21 if (!chlist->channels) in host1x_channel_list_init()
22 return -ENOMEM; in host1x_channel_list_init()
24 chlist->allocated_channels = bitmap_zalloc(num_channels, GFP_KERNEL); in host1x_channel_list_init()
25 if (!chlist->allocated_channels) { in host1x_channel_list_init()
26 kfree(chlist->channels); in host1x_channel_list_init()
27 return -ENOMEM; in host1x_channel_list_init()
30 mutex_init(&chlist->lock); in host1x_channel_list_init()
37 bitmap_free(chlist->allocated_channels); in host1x_channel_list_free()
38 kfree(chlist->channels); in host1x_channel_list_free()
43 struct host1x *host = dev_get_drvdata(job->channel->dev->parent); in host1x_job_submit() local
45 return host1x_hw_channel_submit(host, job); in host1x_job_submit()
51 kref_get(&channel->refcount); in host1x_channel_get()
58 * host1x_channel_get_index() - Attempt to get channel reference by index
59 * @host: Host1x device object
65 struct host1x_channel *host1x_channel_get_index(struct host1x *host, in host1x_channel_get_index() argument
68 struct host1x_channel *ch = &host->channel_list.channels[index]; in host1x_channel_get_index()
70 if (!kref_get_unless_zero(&ch->refcount)) in host1x_channel_get_index()
78 struct host1x *host = dev_get_drvdata(channel->dev->parent); in host1x_channel_stop() local
80 host1x_hw_cdma_stop(host, &channel->cdma); in host1x_channel_stop()
85 * host1x_channel_stop_all() - disable CDMA on allocated channels
86 * @host: host1x instance
90 void host1x_channel_stop_all(struct host1x *host) in host1x_channel_stop_all() argument
92 struct host1x_channel_list *chlist = &host->channel_list; in host1x_channel_stop_all()
95 mutex_lock(&chlist->lock); in host1x_channel_stop_all()
97 for_each_set_bit(bit, chlist->allocated_channels, host->info->nb_channels) in host1x_channel_stop_all()
98 host1x_channel_stop(&chlist->channels[bit]); in host1x_channel_stop_all()
100 mutex_unlock(&chlist->lock); in host1x_channel_stop_all()
107 struct host1x *host = dev_get_drvdata(channel->dev->parent); in release_channel() local
108 struct host1x_channel_list *chlist = &host->channel_list; in release_channel()
110 host1x_hw_cdma_stop(host, &channel->cdma); in release_channel()
111 host1x_cdma_deinit(&channel->cdma); in release_channel()
113 clear_bit(channel->id, chlist->allocated_channels); in release_channel()
118 kref_put(&channel->refcount, release_channel); in host1x_channel_put()
122 static struct host1x_channel *acquire_unused_channel(struct host1x *host) in acquire_unused_channel() argument
124 struct host1x_channel_list *chlist = &host->channel_list; in acquire_unused_channel()
125 unsigned int max_channels = host->info->nb_channels; in acquire_unused_channel()
128 mutex_lock(&chlist->lock); in acquire_unused_channel()
130 index = find_first_zero_bit(chlist->allocated_channels, max_channels); in acquire_unused_channel()
132 mutex_unlock(&chlist->lock); in acquire_unused_channel()
133 dev_err(host->dev, "failed to find free channel\n"); in acquire_unused_channel()
137 chlist->channels[index].id = index; in acquire_unused_channel()
139 set_bit(index, chlist->allocated_channels); in acquire_unused_channel()
141 mutex_unlock(&chlist->lock); in acquire_unused_channel()
143 return &chlist->channels[index]; in acquire_unused_channel()
147 * host1x_channel_request() - Allocate a channel
155 struct host1x *host = dev_get_drvdata(client->dev->parent); in host1x_channel_request() local
156 struct host1x_channel_list *chlist = &host->channel_list; in host1x_channel_request()
160 channel = acquire_unused_channel(host); in host1x_channel_request()
164 kref_init(&channel->refcount); in host1x_channel_request()
165 mutex_init(&channel->submitlock); in host1x_channel_request()
166 channel->client = client; in host1x_channel_request()
167 channel->dev = client->dev; in host1x_channel_request()
169 err = host1x_hw_channel_init(host, channel, channel->id); in host1x_channel_request()
173 err = host1x_cdma_init(&channel->cdma); in host1x_channel_request()
180 clear_bit(channel->id, chlist->allocated_channels); in host1x_channel_request()
182 dev_err(client->dev, "failed to initialize channel\n"); in host1x_channel_request()