[PATCH] media: atomisp: Remove unused ISP vmem load/store functions

From: Avishek Chaulagain

Date: Sun Nov 22 2026 - 02:46:03 EST


From: Abhishek Chaulagain <chaulagainavishek14@xxxxxxxxx>

isp_vmem_load(), isp_vmem_store(), isp_vmem_2d_load() and
isp_vmem_2d_store() are the only external functions provided by
vmem.c, and none of them has a caller anywhere in the tree. Every
other function in the file (load_vector()/store_vector() and the
hive_sim_wide pack/unpack helpers) exists solely to implement those
four, so the whole translation unit is dead.

Remove vmem.c along with its Makefile entry and the four prototypes
in vmem_local.h. The t_vmem_elem/t_svmem_elem typedefs and the
VMEM_ARRAY/SVMEM_ARRAY macros in that header are used elsewhere and
are kept.

Signed-off-by: Abhishek Chaulagain <chaulagainavishek14@xxxxxxxxx>
---
drivers/staging/media/atomisp/Makefile | 1 -
.../pci/hive_isp_css_common/host/vmem.c | 275 ------------------
.../pci/hive_isp_css_common/host/vmem_local.h | 32 --
3 files changed, 308 deletions(-)
delete mode 100644 drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c

diff --git a/drivers/staging/media/atomisp/Makefile b/drivers/staging/media/atomisp/Makefile
index 1d0fbe220..3b2dad720 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -146,7 +146,6 @@ atomisp-objs += \
pci/hive_isp_css_common/host/mmu.o \
pci/hive_isp_css_common/host/sp.o \
pci/hive_isp_css_common/host/timed_ctrl.o \
- pci/hive_isp_css_common/host/vmem.o \
pci/hive_isp_css_shared/host/tag.o \
pci/system_local.o \
pci/runtime/isys/src/ibuf_ctrl_rmgr.o \
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
deleted file mode 100644
index 1c5c50406..000000000
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
+++ /dev/null
@@ -1,275 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2010 - 2016, Intel Corporation.
- */
-
-#include "isp.h"
-#include "vmem.h"
-#include "vmem_local.h"
-
-#if !defined(HRT_MEMORY_ACCESS)
-#include "ia_css_device_access.h"
-#endif
-#include "assert_support.h"
-
-typedef unsigned long long hive_uedge;
-typedef hive_uedge *hive_wide;
-
-/* Copied from SDK: sim_semantics.c */
-
-/* subword bits move like this: MSB[____xxxx____]LSB -> MSB[00000000xxxx]LSB */
-static inline hive_uedge
-subword(hive_uedge w, unsigned int start, unsigned int end)
-{
- return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start;
-}
-
-/* inverse subword bits move like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */
-static inline hive_uedge
-inv_subword(hive_uedge w, unsigned int start, unsigned int end)
-{
- return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | ((1ULL << start) - 1));
-}
-
-#define uedge_bits (8 * sizeof(hive_uedge))
-#define move_lower_bits(target, target_bit, src, src_bit) move_subword(target, target_bit, src, 0, src_bit)
-#define move_upper_bits(target, target_bit, src, src_bit) move_subword(target, target_bit, src, src_bit, uedge_bits)
-#define move_word(target, target_bit, src) move_subword(target, target_bit, src, 0, uedge_bits)
-
-static void
-move_subword(
- hive_uedge *target,
- unsigned int target_bit,
- hive_uedge src,
- unsigned int src_start,
- unsigned int src_end)
-{
- unsigned int start_elem = target_bit / uedge_bits;
- unsigned int start_bit = target_bit % uedge_bits;
- unsigned int subword_width = src_end - src_start;
-
- hive_uedge src_subword = subword(src, src_start, src_end);
-
- if (subword_width + start_bit > uedge_bits) { /* overlap */
- hive_uedge old_val1;
- hive_uedge old_val0 = inv_subword(target[start_elem], start_bit, uedge_bits);
-
- target[start_elem] = old_val0 | (src_subword << start_bit);
- old_val1 = inv_subword(target[start_elem + 1], 0,
- subword_width + start_bit - uedge_bits);
- target[start_elem + 1] = old_val1 | (src_subword >> (uedge_bits - start_bit));
- } else {
- hive_uedge old_val = inv_subword(target[start_elem], start_bit,
- start_bit + subword_width);
-
- target[start_elem] = old_val | (src_subword << start_bit);
- }
-}
-
-static void
-hive_sim_wide_unpack(
- hive_wide vector,
- hive_wide elem,
- hive_uint elem_bits,
- hive_uint index)
-{
- /* pointers into wide_type: */
- unsigned int start_elem = (elem_bits * index) / uedge_bits;
- unsigned int start_bit = (elem_bits * index) % uedge_bits;
- unsigned int end_elem = (elem_bits * (index + 1) - 1) / uedge_bits;
- unsigned int end_bit = ((elem_bits * (index + 1) - 1) % uedge_bits) + 1;
-
- if (elem_bits == uedge_bits) {
- /* easy case for speedup: */
- elem[0] = vector[index];
- } else if (start_elem == end_elem) {
- /* only one (<=64 bits) element needs to be (partly) copied: */
- move_subword(elem, 0, vector[start_elem], start_bit, end_bit);
- } else {
- /* general case: handles edge spanning cases (includes >64bit elements) */
- unsigned int bits_written = 0;
- unsigned int i;
-
- move_upper_bits(elem, bits_written, vector[start_elem], start_bit);
- bits_written += (64 - start_bit);
- for (i = start_elem + 1; i < end_elem; i++) {
- move_word(elem, bits_written, vector[i]);
- bits_written += uedge_bits;
- }
- move_lower_bits(elem, bits_written, vector[end_elem], end_bit);
- }
-}
-
-static void
-hive_sim_wide_pack(
- hive_wide vector,
- hive_wide elem,
- hive_uint elem_bits,
- hive_uint index)
-{
- /* pointers into wide_type: */
- unsigned int start_elem = (elem_bits * index) / uedge_bits;
-
- /* easy case for speedup: */
- if (elem_bits == uedge_bits) {
- vector[start_elem] = elem[0];
- } else if (elem_bits > uedge_bits) {
- unsigned int bits_to_write = elem_bits;
- unsigned int start_bit = elem_bits * index;
- unsigned int i = 0;
-
- for (; bits_to_write > uedge_bits;
- bits_to_write -= uedge_bits, i++, start_bit += uedge_bits) {
- move_word(vector, start_bit, elem[i]);
- }
- move_lower_bits(vector, start_bit, elem[i], bits_to_write);
- } else {
- /* only one element needs to be (partly) copied: */
- move_lower_bits(vector, elem_bits * index, elem[0], elem_bits);
- }
-}
-
-static void load_vector(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from)
-{
- unsigned int i;
- hive_uedge *data;
- unsigned int size = sizeof(short) * ISP_NWAY;
-
- VMEM_ARRAY(v, 2 * ISP_NWAY); /* Need 2 vectors to work around vmem hss bug */
- assert(ISP_BAMEM_BASE[ID] != (hrt_address) - 1);
-#if !defined(HRT_MEMORY_ACCESS)
- ia_css_device_load(ISP_BAMEM_BASE[ID] + (unsigned long)from, &v[0][0], size);
-#else
- hrt_master_port_load(ISP_BAMEM_BASE[ID] + (unsigned long)from, &v[0][0], size);
-#endif
- data = (hive_uedge *)v;
- for (i = 0; i < ISP_NWAY; i++) {
- hive_uedge elem = 0;
-
- hive_sim_wide_unpack(data, &elem, ISP_VEC_ELEMBITS, i);
- to[i] = elem;
- }
- udelay(1); /* Spend at least 1 cycles per vector */
-}
-
-static void store_vector(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from)
-{
- unsigned int i;
- unsigned int size = sizeof(short) * ISP_NWAY;
-
- VMEM_ARRAY(v, 2 * ISP_NWAY); /* Need 2 vectors to work around vmem hss bug */
- //load_vector (&v[1][0], &to[ISP_NWAY]); /* Fetch the next vector, since it will be overwritten. */
- hive_uedge *data = (hive_uedge *)v;
-
- for (i = 0; i < ISP_NWAY; i++)
- hive_sim_wide_pack(data, (hive_wide)&from[i], ISP_VEC_ELEMBITS, i);
-
- assert(ISP_BAMEM_BASE[ID] != (hrt_address) - 1);
-#if !defined(HRT_MEMORY_ACCESS)
- ia_css_device_store(ISP_BAMEM_BASE[ID] + (unsigned long)to, &v, size);
-#else
- //hrt_mem_store (ISP, VMEM, (unsigned)to, &v, siz); /* This will overwrite the next vector as well */
- hrt_master_port_store(ISP_BAMEM_BASE[ID] + (unsigned long)to, &v, size);
-#endif
- udelay(1); /* Spend at least 1 cycles per vector */
-}
-
-void isp_vmem_load(
- const isp_ID_t ID,
- const t_vmem_elem *from,
- t_vmem_elem *to,
- unsigned int elems) /* In t_vmem_elem */
-{
- unsigned int c;
- const t_vmem_elem *vp = from;
-
- assert(ID < N_ISP_ID);
- assert((unsigned long)from % ISP_VEC_ALIGN == 0);
- assert(elems % ISP_NWAY == 0);
- for (c = 0; c < elems; c += ISP_NWAY) {
- load_vector(ID, &to[c], vp);
- vp = (t_vmem_elem *)((char *)vp + ISP_VEC_ALIGN);
- }
-}
-
-void isp_vmem_store(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from,
- unsigned int elems) /* In t_vmem_elem */
-{
- unsigned int c;
- t_vmem_elem *vp = to;
-
- assert(ID < N_ISP_ID);
- assert((unsigned long)to % ISP_VEC_ALIGN == 0);
- assert(elems % ISP_NWAY == 0);
- for (c = 0; c < elems; c += ISP_NWAY) {
- store_vector(ID, vp, &from[c]);
- vp = (t_vmem_elem *)((char *)vp + ISP_VEC_ALIGN);
- }
-}
-
-void isp_vmem_2d_load(
- const isp_ID_t ID,
- const t_vmem_elem *from,
- t_vmem_elem *to,
- unsigned int height,
- unsigned int width,
- unsigned int stride_to, /* In t_vmem_elem */
-
- unsigned stride_from /* In t_vmem_elem */)
-{
- unsigned int h;
-
- assert(ID < N_ISP_ID);
- assert((unsigned long)from % ISP_VEC_ALIGN == 0);
- assert(width % ISP_NWAY == 0);
- assert(stride_from % ISP_NWAY == 0);
- for (h = 0; h < height; h++) {
- unsigned int c;
- const t_vmem_elem *vp = from;
-
- for (c = 0; c < width; c += ISP_NWAY) {
- load_vector(ID, &to[stride_to * h + c], vp);
- vp = (t_vmem_elem *)((char *)vp + ISP_VEC_ALIGN);
- }
- from = (const t_vmem_elem *)((const char *)from + stride_from / ISP_NWAY *
- ISP_VEC_ALIGN);
- }
-}
-
-void isp_vmem_2d_store(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from,
- unsigned int height,
- unsigned int width,
- unsigned int stride_to, /* In t_vmem_elem */
-
- unsigned stride_from /* In t_vmem_elem */)
-{
- unsigned int h;
-
- assert(ID < N_ISP_ID);
- assert((unsigned long)to % ISP_VEC_ALIGN == 0);
- assert(width % ISP_NWAY == 0);
- assert(stride_to % ISP_NWAY == 0);
- for (h = 0; h < height; h++) {
- unsigned int c;
- t_vmem_elem *vp = to;
-
- for (c = 0; c < width; c += ISP_NWAY) {
- store_vector(ID, vp, &from[stride_from * h + c]);
- vp = (t_vmem_elem *)((char *)vp + ISP_VEC_ALIGN);
- }
- to = (t_vmem_elem *)((char *)to + stride_to / ISP_NWAY * ISP_VEC_ALIGN);
- }
-}
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem_local.h b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem_local.h
index 0163d31cd..3af34c9bd 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem_local.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem_local.h
@@ -16,36 +16,4 @@ typedef s16 t_svmem_elem;
#define VMEM_ARRAY(x, s) t_vmem_elem x[(s) / ISP_NWAY][ISP_NWAY]
#define SVMEM_ARRAY(x, s) t_svmem_elem x[(s) / ISP_NWAY][ISP_NWAY]

-void isp_vmem_load(
- const isp_ID_t ID,
- const t_vmem_elem *from,
- t_vmem_elem *to,
- unsigned int elems); /* In t_vmem_elem */
-
-void isp_vmem_store(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from,
- unsigned int elems); /* In t_vmem_elem */
-
-void isp_vmem_2d_load(
- const isp_ID_t ID,
- const t_vmem_elem *from,
- t_vmem_elem *to,
- unsigned int height,
- unsigned int width,
- unsigned int stride_to, /* In t_vmem_elem */
-
- unsigned stride_from /* In t_vmem_elem */);
-
-void isp_vmem_2d_store(
- const isp_ID_t ID,
- t_vmem_elem *to,
- const t_vmem_elem *from,
- unsigned int height,
- unsigned int width,
- unsigned int stride_to, /* In t_vmem_elem */
-
- unsigned stride_from /* In t_vmem_elem */);
-
#endif /* __VMEM_LOCAL_H_INCLUDED__ */
--
2.43.0