]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: simplify channel map usage
authorShridhar Rasal <srasal@nvidia.com>
Tue, 24 Jun 2014 09:45:05 +0000 (15:15 +0530)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Wed, 25 Jun 2014 06:27:25 +0000 (23:27 -0700)
Use array instead list to hold all channels.
Remove unused references.

Bug 1526504

Change-Id: I49596238d38d5aa78ff32a59b8c0f2c116136a09
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/427651
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/host1x/host1x.h
drivers/video/tegra/host/nvhost_channel.c
drivers/video/tegra/host/nvhost_channel.h

index 083254cabb4350051b59d14f8b845f9a9edaa9ce..48d87882029f95ee598c42393803cc23af7f704f 100644 (file)
@@ -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;
index 98ee08579fc06cf0dc5a5349ac956975da62452d..c89478cf7072db8f42afdc0eac705ffd401231ad 100644 (file)
 /* 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;
 }
 
@@ -413,30 +404,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)
index baed282718a24d7684aac46bc6042452c49dcbff..9f165a380f4aa16e97ad04dc29324bc94aa80826 100644 (file)
@@ -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);