Skip to contentSkip to conversation

staging: media: atomisp: cleanup pci/hmm/ code

PATCH Superseded Nikolay Kulikov 2 participants 9 messages Aug 12 – Aug 13

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover staging: media: atomisp: cleanup pci/hmm/ code

This series removes unused functions and replaces obscure variable-checking macros with clear conditional statements.

Changes in v3:
- Split the last patch into two (inlining macros and removing the file).
- Replace variable initialization with assignment, followed immediately by a check.
Changes in v2:
- Squashed the function removals in pci/hmm/hmm.c and pci/hmm/hmm_bo.c into a single commit.
- Add commits to cleanup macros from include/hmm/hmm_common.h, as suggested by Andy Shevchenko.

Nikolay Kulikov (5):
staging: media: atomisp: remove unused functions from pci/hmm/
staging: media: atomisp: inline macros for checking the bo/bodev
pointer
staging: media: atomisp: inline the check_bo_status_*() macros
staging: media: atomisp: inline the var_equal_return*() macros
staging: media: atomisp: remove hmm/hmm_common.h file

 .../staging/media/atomisp/include/hmm/hmm.h   |  17 --
 .../media/atomisp/include/hmm/hmm_bo.h        |  46 ----
 .../media/atomisp/include/hmm/hmm_common.h    |  60 -----
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  41 ---
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 246 ++++++++----------
 5 files changed, 112 insertions(+), 298 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/include/hmm/hmm_common.h
Signature · 1 line
2.55.0
#1 lore raw

PATCH v3 1/5 staging: media: atomisp: remove unused functions from pci/hmm/

These functions are declared and defined but are not called anywhere.

---
 .../staging/media/atomisp/include/hmm/hmm.h   | 16 ---
 .../media/atomisp/include/hmm/hmm_bo.h        | 19 ----
 drivers/staging/media/atomisp/pci/hmm/hmm.c   | 41 --------
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 97 -------------------
 4 files changed, 173 deletions(-)
drivers/staging/media/atomisp/include/hmm/hmm.h +0 -16
index a7aef27f54de..6bda02b9ff85 100644
@@ -32,12 +32,6 @@ void hmm_free(ia_css_ptr ptr);
 int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
 int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes);
 int hmm_set(ia_css_ptr virt, int c, unsigned int bytes);
-int hmm_flush(ia_css_ptr virt, unsigned int bytes);
-
-/*
- * get kernel memory physical address from ISP virtual address.
- */
-phys_addr_t hmm_virt_to_phys(ia_css_ptr virt);
 
 /*
  * map ISP memory starts with virt to kernel virtual address
@@ -55,16 +49,6 @@ void hmm_vunmap(ia_css_ptr virt);
  */
 void hmm_flush_vmap(ia_css_ptr virt);
 
-/*
- * map ISP memory starts with virt to specific vma.
- *
- * used for mmap operation.
- *
- * virt must be the start address of ISP memory (return by hmm_alloc),
- * do not pass any other address.
- */
-int hmm_mmap(struct vm_area_struct *vma, ia_css_ptr virt);
-
 extern struct hmm_bo_device bo_device;
 
 #endif
drivers/staging/media/atomisp/include/hmm/hmm_bo.h +0 -19
index e09ac29ac43d..ba3c582a0f89 100644
@@ -205,7 +205,6 @@ int hmm_bo_page_allocated(struct hmm_buffer_object *bo);
  */
 int hmm_bo_bind(struct hmm_buffer_object *bo);
 void hmm_bo_unbind(struct hmm_buffer_object *bo);
-int hmm_bo_binded(struct hmm_buffer_object *bo);
 
 /*
  * vmap buffer object's pages to contiguous kernel virtual address.
@@ -224,17 +223,6 @@ void hmm_bo_flush_vmap(struct hmm_buffer_object *bo);
  */
 void hmm_bo_vunmap(struct hmm_buffer_object *bo);
 
-/*
- * mmap the bo's physical pages to specific vma.
- *
- * vma's address space size must be the same as bo's size,
- * otherwise it will return -EINVAL.
- *
- * vma->vm_flags will be set to (VM_RESERVED | VM_IO).
- */
-int hmm_bo_mmap(struct vm_area_struct *vma,
-		struct hmm_buffer_object *bo);
-
 /*
  * find the buffer object by its virtual address vaddr.
  * return NULL if no such buffer object found.
@@ -251,11 +239,4 @@ struct hmm_buffer_object *hmm_bo_device_search_start(
 struct hmm_buffer_object *hmm_bo_device_search_in_range(
     struct hmm_bo_device *bdev, ia_css_ptr vaddr);
 
-/*
- * find the buffer object with kernel virtual address vaddr.
- * return NULL if no such buffer object found.
- */
-struct hmm_buffer_object *hmm_bo_device_search_vmap_start(
-    struct hmm_bo_device *bdev, const void *vaddr);
-
 #endif
drivers/staging/media/atomisp/pci/hmm/hmm.c +0 -41

53 lines not on this page · raw message

drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +0 -97

112 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

PATCH v3 2/5 staging: media: atomisp: inline macros for checking the bo/bodev pointer

In reply to Nikolay Kulikov

These macros perform a pointer check. Replace it with direct conditional expressions to simplify the code.

---
 .../media/atomisp/include/hmm/hmm_bo.h        |  14 ---
 .../media/atomisp/include/hmm/hmm_common.h    |   6 -
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 112 ++++++++++++++----
 3 files changed, 88 insertions(+), 44 deletions(-)
drivers/staging/media/atomisp/include/hmm/hmm_bo.h +0 -14
index ba3c582a0f89..e974ab5ca2fc 100644
@@ -19,14 +19,6 @@
 #include "hmm/hmm_common.h"
 #include "ia_css_types.h"
 
-#define	check_bodev_null_return(bdev, exp)	\
-		check_null_return(bdev, exp, \
-			"NULL hmm_bo_device.\n")
-
-#define	check_bodev_null_return_void(bdev)	\
-		check_null_return_void(bdev, \
-			"NULL hmm_bo_device.\n")
-
 #define	check_bo_status_yes_goto(bo, _status, label) \
 	var_not_equal_goto((bo->status & (_status)), (_status), \
 			label, \
@@ -48,12 +40,6 @@
 #define	kref_to_hmm_bo(kref_ptr)	\
 	list_entry((kref_ptr), struct hmm_buffer_object, kref)
 
-#define	check_bo_null_return(bo, exp)	\
-	check_null_return(bo, exp, "NULL hmm buffer object.\n")
-
-#define	check_bo_null_return_void(bo)	\
-	check_null_return_void(bo, "NULL hmm buffer object.\n")
-
 #define	ISP_VM_START	0x0
 #define	ISP_VM_SIZE	(0x7FFFFFFF)	/* 2G address space */
 #define	ISP_PTR_NULL	NULL
drivers/staging/media/atomisp/include/hmm/hmm_common.h +0 -6
index b251e96cc19d..f215130e5e17 100644
@@ -51,10 +51,4 @@
 		} \
 	} while (0)
 
-#define	check_null_return(ptr, exp, fmt, arg ...)	\
-		var_equal_return(ptr, NULL, exp, fmt, ## arg)
-
-#define	check_null_return_void(ptr, fmt, arg ...)	\
-		var_equal_return_void(ptr, NULL, fmt, ## arg)
-
 #endif
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +88 -24

236 lines not on this page · raw message

Signature · 1 line
2.55.0
#3 lore raw

PATCH v3 3/5 staging: media: atomisp: inline the check_bo_status_*() macros

In reply to Nikolay Kulikov

These macros check a bit in the bo->status field. Replace them with conditional expressions to make the code clearer.

---
 .../media/atomisp/include/hmm/hmm_bo.h        | 12 --------
 .../media/atomisp/include/hmm/hmm_common.h    | 18 -----------
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 30 ++++++++++++-------
 3 files changed, 20 insertions(+), 40 deletions(-)
drivers/staging/media/atomisp/include/hmm/hmm_bo.h +0 -12
index e974ab5ca2fc..69cf490bd88c 100644
@@ -19,18 +19,6 @@
 #include "hmm/hmm_common.h"
 #include "ia_css_types.h"
 
-#define	check_bo_status_yes_goto(bo, _status, label) \
-	var_not_equal_goto((bo->status & (_status)), (_status), \
-			label, \
-			"HMM buffer status not contain %s.\n", \
-			#_status)
-
-#define	check_bo_status_no_goto(bo, _status, label) \
-	var_equal_goto((bo->status & (_status)), (_status), \
-			label, \
-			"HMM buffer status contains %s.\n", \
-			#_status)
-
 #define rbtree_node_to_hmm_bo(root_node)	\
 	container_of((root_node), struct hmm_buffer_object, node)
 
drivers/staging/media/atomisp/include/hmm/hmm_common.h +0 -18
index f215130e5e17..c406fe8b1345 100644
@@ -33,22 +33,4 @@
 		} \
 	} while (0)
 
-#define	var_equal_goto(var1, var2, label, fmt, arg ...)	\
-	do { \
-		if ((var1) == (var2)) { \
-			dev_err(atomisp_dev, \
-			fmt, ## arg); \
-			goto label;\
-		} \
-	} while (0)
-
-#define	var_not_equal_goto(var1, var2, label, fmt, arg ...)	\
-	do { \
-		if ((var1) != (var2)) { \
-			dev_err(atomisp_dev, \
-			fmt, ## arg); \
-			goto label;\
-		} \
-	} while (0)
-
 #endif
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +20 -10
index ecd920e49488..dbda4394a239 100644
@@ -687,7 +687,10 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
 	}
 
 	mutex_lock(&bo->mutex);
-	check_bo_status_no_goto(bo, HMM_BO_PAGE_ALLOCED, status_err);
+	if (bo->status & HMM_BO_PAGE_ALLOCED) {
+		dev_err(atomisp_dev, "HMM buffer status contains HMM_BO_PAGE_ALLOCED.\n");
+		goto status_err;
+	}
 
 	bo->pages = kzalloc_objs(struct page *, bo->pgnr);
 	if (unlikely(!bo->pages)) {
@@ -738,7 +741,10 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo)
 
 	mutex_lock(&bo->mutex);
 
-	check_bo_status_yes_goto(bo, HMM_BO_PAGE_ALLOCED, status_err2);
+	if (!(bo->status & HMM_BO_PAGE_ALLOCED)) {
+		dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED.\n");
+		goto status_err2;
+	}
 
 	/* clear the flag anyway. */
 	bo->status &= (~HMM_BO_PAGE_ALLOCED);
@@ -788,11 +794,15 @@ int hmm_bo_bind(struct hmm_buffer_object *bo)
 
 	mutex_lock(&bo->mutex);
 
-	check_bo_status_yes_goto(bo,
-				 HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED,
-				 status_err1);
+	if (!(bo->status & (HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED))) {
+		dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED.\n");
+		goto status_err1;
+	}
 
-	check_bo_status_no_goto(bo, HMM_BO_BINDED, status_err2);
+	if (bo->status & HMM_BO_BINDED) {
+		dev_err(atomisp_dev, "HMM buffer status contains HMM_BO_BINDED.\n");
+		goto status_err2;
+	}
 
 	bdev = bo->bdev;
 
@@ -868,10 +878,10 @@ void hmm_bo_unbind(struct hmm_buffer_object *bo)
 
 	mutex_lock(&bo->mutex);
 
-	check_bo_status_yes_goto(bo,
-				 HMM_BO_PAGE_ALLOCED |
-				 HMM_BO_ALLOCED |
-				 HMM_BO_BINDED, status_err);
+	if (!(bo->status & (HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED | HMM_BO_BINDED))) {
+		dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED | HMM_BO_BINDED.\n");
+		goto status_err;
+	}
 
 	bdev = bo->bdev;
 
Signature · 1 line
2.55.0
#4 lore raw

PATCH v3 4/5 staging: media: atomisp: inline the var_equal_return*() macros

In reply to Nikolay Kulikov

These macros check the passed variables for equality, hiding the 'if' and 'return' statements; replace them with a standard conditional to simplify the code.

---
 .../media/atomisp/include/hmm/hmm_common.h    | 20 -------------------
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    |  6 ++++--
 2 files changed, 4 insertions(+), 22 deletions(-)
drivers/staging/media/atomisp/include/hmm/hmm_common.h +0 -20
index c406fe8b1345..029620347302 100644
@@ -12,25 +12,5 @@
 
 #define	HMM_BO_NAME	"HMM"
 
-/*
- * some common use micros
- */
-#define	var_equal_return(var1, var2, exp, fmt, arg ...)	\
-	do { \
-		if ((var1) == (var2)) { \
-			dev_err(atomisp_dev, \
-			fmt, ## arg); \
-			return exp;\
-		} \
-	} while (0)
-
-#define	var_equal_return_void(var1, var2, fmt, arg ...)	\
-	do { \
-		if ((var1) == (var2)) { \
-			dev_err(atomisp_dev, \
-			fmt, ## arg); \
-			return;\
-		} \
-	} while (0)
 
 #endif
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +4 -2
index dbda4394a239..89e56ce07444 100644
@@ -396,8 +396,10 @@ struct hmm_buffer_object *hmm_bo_alloc(struct hmm_bo_device *bdev,
 	}
 
 	root = &bdev->free_rbtree;
-	var_equal_return(hmm_bo_device_inited(bdev), 0, NULL,
-			 "hmm_bo_device not inited yet.\n");
+	if (!hmm_bo_device_inited(bdev)) {
+		dev_err(atomisp_dev, "hmm_bo_device not inited yet.\n");
+		return NULL;
+	}
 
 	if (pgnr == 0) {
 		dev_err(atomisp_dev, "0 size buffer is not allowed.\n");
Signature · 1 line
2.55.0
#5 lore raw

PATCH v3 5/5 staging: media: atomisp: remove hmm/hmm_common.h file

In reply to Nikolay Kulikov

Now this file contains nothing, and we can remove it and all the "#include" directives.

---
 drivers/staging/media/atomisp/include/hmm/hmm.h  |  1 -
 .../staging/media/atomisp/include/hmm/hmm_bo.h   |  1 -
 .../media/atomisp/include/hmm/hmm_common.h       | 16 ----------------
 drivers/staging/media/atomisp/pci/hmm/hmm_bo.c   |  1 -
 4 files changed, 19 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/include/hmm/hmm_common.h
drivers/staging/media/atomisp/include/hmm/hmm.h +0 -1
index 6bda02b9ff85..be92a9c9046f 100644
@@ -15,7 +15,6 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 
-#include "hmm_common.h"
 #include "hmm/hmm_bo.h"
 #include "ia_css_types.h"
 
drivers/staging/media/atomisp/include/hmm/hmm_bo.h +0 -1
index 69cf490bd88c..2a19e3b2c1f9 100644
@@ -16,7 +16,6 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include "mmu/isp_mmu.h"
-#include "hmm/hmm_common.h"
 #include "ia_css_types.h"
 
 #define rbtree_node_to_hmm_bo(root_node)	\
drivers/staging/media/atomisp/include/hmm/hmm_common.h deleted +0 -16
deleted file mode 100644
index 029620347302..000000000000
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
- */
-
-#ifndef	__HMM_BO_COMMON_H__
-#define	__HMM_BO_COMMON_H__
-
-#define	HMM_BO_NAME	"HMM"
-
-
-#endif
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +0 -1
index 89e56ce07444..ce0c8b2717a4 100644
@@ -30,7 +30,6 @@
 #include <asm/set_memory.h>
 
 #include "atomisp_internal.h"
-#include "hmm/hmm_common.h"
 #include "hmm/hmm_bo.h"
 
 static int __bo_init(struct hmm_bo_device *bdev, struct hmm_buffer_object *bo,
Signature · 1 line
2.55.0
#6 lore raw
In reply to Nikolay Kulikov
Quoted 2 lines · Nikolay Kulikov

This series removes unused functions and replaces obscure variable-checking macros with clear conditional statements.

I believe I gave tags to some patches in v2. I don't see either. What's going on?

Quoted 10 lines

Changes in v3:
- Split the last patch into two (inlining macros and removing the file).
- Replace variable initialization with assignment, followed immediately by a check.
Changes in v2:
- Squashed the function removals in pci/hmm/hmm.c and pci/hmm/hmm_bo.c into a single commit.
- Add commits to cleanup macros from include/hmm/hmm_common.h, as suggested by Andy Shevchenko.

Also two process hints:
- add --base when prepare patches
- add links (URLs to lore.kernel.org) for the previous versions.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Nikolay Kulikov

This series removes unused functions and replaces obscure variable-checking macros with clear conditional statements.

I believe I gave tags to some patches in v2. I don't see either. What's going on?

For _this_ time, please reply yourself to the patches I already tagged with my Rb tags placed on a dedicated line.

Quoted 11 lines
Quoted 10 lines

Changes in v3:
- Split the last patch into two (inlining macros and removing the file).
- Replace variable initialization with assignment, followed immediately by a check.
Changes in v2:
- Squashed the function removals in pci/hmm/hmm.c and pci/hmm/hmm_bo.c into a single commit.
- Add commits to cleanup macros from include/hmm/hmm_common.h, as suggested by Andy Shevchenko.

Quoted 3 lines

Also two process hints:
- add --base when prepare patches
- add links (URLs to lore.kernel.org) for the previous versions.

Same here, just reply to your cover letter with these URLs, and for this time just refer what the base was in a free form.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
Quoted 22 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Nikolay Kulikov

This series removes unused functions and replaces obscure variable-checking macros with clear conditional statements.

I believe I gave tags to some patches in v2. I don't see either. What's going on?

For _this_ time, please reply yourself to the patches I already tagged with my Rb tags placed on a dedicated line.

Quoted 11 lines
Quoted 10 lines

Changes in v3:
- Split the last patch into two (inlining macros and removing the file).
- Replace variable initialization with assignment, followed immediately by a check.
Changes in v2:
- Squashed the function removals in pci/hmm/hmm.c and pci/hmm/hmm_bo.c into a single commit.
- Add commits to cleanup macros from include/hmm/hmm_common.h, as suggested by Andy Shevchenko.

Quoted 6 lines
Quoted 3 lines

Also two process hints:
- add --base when prepare patches
- add links (URLs to lore.kernel.org) for the previous versions.

Same here, just reply to your cover letter with these URLs, and for this time just refer what the base was in a free form.

Sorry, I think I should have used b4 from the start. I will send the new version with all the fixes.

Thanks,
Nikolay