Kaynağa Gözat

msm: camera: sync: Restructure sync device structure

Currently sync_device structure size allocated is nearly 424kb
which is leading to more than accepted page size order.
Sync table row which is array of 2048 is accounting
nearly 90% of total size of sync_device. To fix this
sync_table_row is made pointer based and allocated memory.

CRs-Fixed: 3558545
Change-Id: I0c8093c91ac7fec9f52613012b139192b827b8d9
Signed-off-by: Shravya Samala <[email protected]>
Shravya Samala 1 yıl önce
ebeveyn
işleme
011cc16eb5

+ 9 - 0
drivers/cam_sync/cam_sync.c

@@ -2777,6 +2777,13 @@ static int cam_sync_component_bind(struct device *dev,
 	if (!sync_dev)
 		return -ENOMEM;
 
+	sync_dev->sync_table = vzalloc(sizeof(struct sync_table_row) * CAM_SYNC_MAX_OBJS);
+	if (!sync_dev->sync_table) {
+		CAM_ERR(CAM_SYNC, "Mem Allocation failed for sync table");
+		kfree(sync_dev);
+		return -ENOMEM;
+	}
+
 	mutex_init(&sync_dev->table_lock);
 	spin_lock_init(&sync_dev->cam_sync_eventq_lock);
 
@@ -2878,6 +2885,7 @@ mcinit_fail:
 	video_unregister_device(sync_dev->vdev);
 	video_device_release(sync_dev->vdev);
 vdev_fail:
+	vfree(sync_dev->sync_table);
 	mutex_destroy(&sync_dev->table_lock);
 	kfree(sync_dev);
 	return rc;
@@ -2903,6 +2911,7 @@ static void cam_sync_component_unbind(struct device *dev,
 	for (i = 0; i < CAM_SYNC_MAX_OBJS; i++)
 		spin_lock_init(&sync_dev->row_spinlocks[i]);
 
+	vfree(sync_dev->sync_table);
 	kfree(sync_dev);
 	sync_dev = NULL;
 }

+ 2 - 2
drivers/cam_sync/cam_sync_private.h

@@ -345,7 +345,7 @@ struct cam_signalable_info {
  *
  * @vdev            : Video device
  * @v4l2_dev        : V4L2 device
- * @sync_table      : Table of all sync objects
+ * @sync_table      : Table of all sync objects allocated when driver initializes
  * @row_spinlocks   : Spinlock array, one for each row in the table
  * @table_lock      : Mutex used to lock the table
  * @open_cnt        : Count of file open calls made on the sync driver
@@ -360,7 +360,7 @@ struct cam_signalable_info {
 struct sync_device {
 	struct video_device *vdev;
 	struct v4l2_device v4l2_dev;
-	struct sync_table_row sync_table[CAM_SYNC_MAX_OBJS];
+	struct sync_table_row *sync_table;
 	spinlock_t row_spinlocks[CAM_SYNC_MAX_OBJS];
 	struct mutex table_lock;
 	int open_cnt;