summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorShridhar Rasal <srasal@nvidia.com>2014-06-24 15:15:05 +0530
committerWinnie Hsu <whsu@nvidia.com>2014-10-17 10:55:56 -0700
commit8ea724b67e4366615059a83dfe28d3f49c48d25f (patch)
treefbf9c38ba931a05bba9c6aa54e56e8f2b392a861 /drivers
parent8c4516e9b2e8261ad7486717cc722a7a8f35a75e (diff)
video: tegra: host: simplify channel map usage
Use array instead list to hold all channels. Remove unused references. Bug 1526504 Change-Id: I49596238d38d5aa78ff32a59b8c0f2c116136a09 (cherry picked from commit 93d7a5f52d3f3aad28187aed15877994d8781cbc) Signed-off-by: Shridhar Rasal <srasal@nvidia.com> Reviewed-on: http://git-master/r/496478 Reviewed-on: http://git-master/r/538722 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Shreshtha Sahu <ssahu@nvidia.com> Tested-by: Shreshtha Sahu <ssahu@nvidia.com> Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/tegra/host/host1x/host1x.h3
-rw-r--r--drivers/video/tegra/host/nvhost_channel.c78
-rw-r--r--drivers/video/tegra/host/nvhost_channel.h8
3 files changed, 29 insertions, 60 deletions
diff --git a/drivers/video/tegra/host/host1x/host1x.h b/drivers/video/tegra/host/host1x/host1x.h
index d779116ee8f2..13b974a8c2e5 100644
--- a/drivers/video/tegra/host/host1x/host1x.h
+++ b/drivers/video/tegra/host/host1x/host1x.h
@@ -56,11 +56,10 @@ struct nvhost_master {
struct nvhost_capability_node *caps_nodes;
struct mutex timeout_mutex;
- struct nvhost_channel chlist; /* channel list */
+ struct nvhost_channel **chlist; /* channel list */
struct mutex chlist_mutex; /* mutex for channel list */
unsigned long allocated_channels;
unsigned long next_free_ch;
- int cnt_alloc_channels;
};
extern struct nvhost_master *nvhost;
diff --git a/drivers/video/tegra/host/nvhost_channel.c b/drivers/video/tegra/host/nvhost_channel.c
index 683865aa8558..3e7455509f96 100644
--- a/drivers/video/tegra/host/nvhost_channel.c
+++ b/drivers/video/tegra/host/nvhost_channel.c
@@ -35,14 +35,18 @@
/* Constructor for the host1x device list */
int nvhost_channel_list_init(struct nvhost_master *host)
{
- INIT_LIST_HEAD(&host->chlist.list);
- mutex_init(&host->chlist_mutex);
-
if (host->info.nb_channels > BITS_PER_LONG) {
WARN(1, "host1x hardware has more channels than supported\n");
return -ENOSYS;
}
+ host->chlist = kzalloc(host->info.nb_channels *
+ sizeof(struct nvhost_channel *), GFP_KERNEL);
+ if (host->chlist == NULL)
+ return -ENOMEM;
+
+ mutex_init(&host->chlist_mutex);
+
return 0;
}
@@ -50,44 +54,32 @@ int nvhost_channel_list_init(struct nvhost_master *host)
int nvhost_alloc_channels(struct nvhost_master *host)
{
int max_channels = host->info.nb_channels;
- int i;
+ int i, err = 0;
struct nvhost_channel *ch;
- nvhost_channel_list_init(host);
- mutex_lock(&host->chlist_mutex);
+ err = nvhost_channel_list_init(host);
+ if (err) {
+ dev_err(&host->dev->dev, "failed to init channel list\n");
+ return err;
+ }
+ mutex_lock(&host->chlist_mutex);
for (i = 0; i < max_channels; i++) {
- ch = nvhost_alloc_channel_internal(i, max_channels,
- &host->cnt_alloc_channels);
+ ch = nvhost_alloc_channel_internal(i, max_channels);
if (!ch) {
+ dev_err(&host->dev->dev, "failed to alloc channels\n");
mutex_unlock(&host->chlist_mutex);
return -ENOMEM;
}
+ host->chlist[i] = ch;
ch->dev = NULL;
ch->chid = NVHOST_INVALID_CHANNEL;
-
- list_add_tail(&ch->list, &host->chlist.list);
}
mutex_unlock(&host->chlist_mutex);
return 0;
}
-/* Return N'th channel from list */
-struct nvhost_channel *nvhost_return_node(struct nvhost_master *host,
- int index)
-{
- int i = 0;
- struct nvhost_channel *ch = NULL;
-
- list_for_each_entry(ch, &host->chlist.list, list) {
- if (i == index)
- return ch;
- i++;
- }
- return NULL;
-}
-
/* return any one of assigned channel from device
* This API can be used to check if any channel assigned to device
*/
@@ -261,7 +253,7 @@ int nvhost_channel_map(struct nvhost_device_data *pdata,
}
/* Get channel from list and map to device */
- ch = nvhost_return_node(host, index);
+ ch = host->chlist[index];
if (!ch) {
dev_err(&host->dev->dev, "%s: No channel is free\n", __func__);
mutex_unlock(&host->chlist_mutex);
@@ -319,14 +311,13 @@ int nvhost_channel_map(struct nvhost_device_data *pdata,
/* Free channel memory and list */
int nvhost_channel_list_free(struct nvhost_master *host)
{
- struct nvhost_channel *ch = NULL;
+ int i;
- list_for_each_entry(ch, &host->chlist.list, list) {
- list_del(&ch->list);
- kfree(ch);
- }
+ for (i = 0; i < host->info.nb_channels; i++)
+ kfree(host->chlist[i]);
dev_info(&host->dev->dev, "channel list free'd\n");
+
return 0;
}
@@ -412,30 +403,15 @@ int nvhost_channel_suspend(struct nvhost_channel *ch)
}
struct nvhost_channel *nvhost_alloc_channel_internal(int chindex,
- int max_channels, int *current_channel_count)
+ int max_channels)
{
struct nvhost_channel *ch = NULL;
- if ( (chindex > max_channels) ||
- ( (*current_channel_count + 1) > max_channels) )
- return NULL;
- else {
- ch = kzalloc(sizeof(*ch), GFP_KERNEL);
- if (ch == NULL)
- return NULL;
- else {
- ch->chid = *current_channel_count;
- (*current_channel_count)++;
- return ch;
- }
- }
-}
+ ch = kzalloc(sizeof(*ch), GFP_KERNEL);
+ if (ch)
+ ch->chid = chindex;
-void nvhost_free_channel_internal(struct nvhost_channel *ch,
- int *current_channel_count)
-{
- kfree(ch);
- (*current_channel_count)--;
+ return ch;
}
int nvhost_channel_save_context(struct nvhost_channel *ch)
diff --git a/drivers/video/tegra/host/nvhost_channel.h b/drivers/video/tegra/host/nvhost_channel.h
index baed282718a2..9f165a380f4a 100644
--- a/drivers/video/tegra/host/nvhost_channel.h
+++ b/drivers/video/tegra/host/nvhost_channel.h
@@ -50,7 +50,6 @@ struct nvhost_channel {
atomic_t refcount;
int chid;
int dev_chid;
- u32 syncpt_id;
struct mutex reflock;
struct mutex submitlock;
void __iomem *aperture;
@@ -64,8 +63,6 @@ struct nvhost_channel {
* now just keep it here */
struct nvhost_as *as;
- struct list_head list;
-
/* error notificatiers used channel submit timeout */
struct dma_buf *error_notifier_ref;
struct nvhost_notification *error_notifier;
@@ -97,10 +94,7 @@ int nvhost_channel_read_reg(struct nvhost_channel *channel,
u32 offset, u32 *value);
struct nvhost_channel *nvhost_alloc_channel_internal(int chindex,
- int max_channels, int *current_channel_count);
-
-void nvhost_free_channel_internal(struct nvhost_channel *ch,
- int *current_channel_count);
+ int max_channels);
int nvhost_channel_save_context(struct nvhost_channel *ch);
void nvhost_channel_init_gather_filter(struct nvhost_channel *ch);