PD#143509: osd_rdma: used pre-alloc memory instead kzalloc in osd_rdma_irq

Change-Id: I96516094aefe3bb78d6e5f891657d1e7ac55e632
Signed-off-by: Pengcheng Chen <pengcheng.chen@amlogic.com>
This commit is contained in:
Pengcheng Chen
2017-05-08 14:18:01 +08:00
parent d0edbbb9f4
commit 2053b82865

View File

@@ -58,6 +58,7 @@ int rdma_reset_tigger_flag;
#endif
#define RDMA_TABLE_INTERNAL_COUNT 512
#define RDMA_TEMP_TBL_SIZE (8 * RDMA_TABLE_INTERNAL_COUNT)
static DEFINE_SPINLOCK(rdma_lock);
static struct rdma_table_item *rdma_table;
@@ -82,6 +83,7 @@ static unsigned int second_rdma_irq;
#endif
static int osd_rdma_handle = -1;
static struct rdma_table_item *rdma_temp_tbl;
static int osd_rdma_init(void);
@@ -106,7 +108,6 @@ static inline void osd_rdma_mem_cpy(struct rdma_table_item *dst,
static inline void reset_rdma_table(void)
{
struct rdma_table_item *temp_tbl = NULL;
struct rdma_table_item request_item;
unsigned long flags;
u32 old_count;
@@ -128,10 +129,17 @@ static inline void reset_rdma_table(void)
u32 val, mask;
int iret;
if (item_count > 2)
temp_tbl = kzalloc(
sizeof(struct rdma_table_item)
* item_count, GFP_ATOMIC);
if ((item_count * (sizeof(struct rdma_table_item))) >
RDMA_TEMP_TBL_SIZE) {
pr_info("more memory: allocate(%x), expect(%lx)\n",
(unsigned int) RDMA_TEMP_TBL_SIZE,
sizeof(struct rdma_table_item) *
item_count);
WARN_ON(1);
}
memset(rdma_temp_tbl, 0,
(sizeof(struct rdma_table_item) * item_count));
end_addr = osd_reg_read(END_ADDR) + 1;
if (end_addr > table_paddr)
old_count = (end_addr - table_paddr) >> 3;
@@ -141,7 +149,7 @@ static inline void reset_rdma_table(void)
for (i = (int)(item_count - 1);
i >= 0; i--) {
if (!temp_tbl)
if (!rdma_temp_tbl)
break;
if (rdma_table[i].addr ==
OSD_RDMA_FLAG_REG)
@@ -157,7 +165,7 @@ static inline void reset_rdma_table(void)
rdma_table[i].addr;
request_item.val = val;
osd_rdma_mem_cpy(
&temp_tbl[j], &request_item, 8);
&rdma_temp_tbl[j], &request_item, 8);
j++;
pr_debug(
"recovery -- 0x%04x:0x%08x, mask:0x%08x\n",
@@ -170,7 +178,7 @@ static inline void reset_rdma_table(void)
request_item.val =
rdma_table[i].val;
osd_rdma_mem_cpy(
&temp_tbl[j], &request_item, 8);
&rdma_temp_tbl[j], &request_item, 8);
j++;
pr_debug(
"recovery -- 0x%04x:0x%08x, mask:0x%08x\n",
@@ -186,10 +194,10 @@ static inline void reset_rdma_table(void)
for (i = 0; i < j; i++) {
osd_rdma_mem_cpy(
&rdma_table[1 + i],
&temp_tbl[j - i - 1], 8);
&rdma_temp_tbl[j - i - 1], 8);
update_recovery_item(
temp_tbl[j - i - 1].addr,
temp_tbl[j - i - 1].val);
rdma_temp_tbl[j - i - 1].addr,
rdma_temp_tbl[j - i - 1].val);
}
item_count = j + 2;
osd_rdma_mem_cpy(rdma_table, &reset_item[0], 8);
@@ -197,7 +205,6 @@ static inline void reset_rdma_table(void)
&reset_item[1], 8);
osd_reg_write(END_ADDR,
(table_paddr + item_count * 8 - 1));
kfree(temp_tbl);
}
spin_unlock_irqrestore(&rdma_lock, flags);
}
@@ -1003,6 +1010,11 @@ static int osd_rdma_init(void)
/* osd_log_err("osd rdma init error!\n"); */
return -1;
}
rdma_temp_tbl = kmalloc(RDMA_TEMP_TBL_SIZE, GFP_KERNEL);
if (!rdma_temp_tbl) {
/* osd_log_err("osd rdma alloc temp_tbl error!\n"); */
goto error2;
}
osd_rdma_dev->release = osd_rdma_release;
dev_set_name(osd_rdma_dev, "osd-rdma-dev");
dev_set_drvdata(osd_rdma_dev, osd_rdma_dev);
@@ -1076,7 +1088,9 @@ error2:
device_unregister(osd_rdma_dev);
error1:
kfree(osd_rdma_dev);
kfree(rdma_temp_tbl);
osd_rdma_dev = NULL;
rdma_temp_tbl = NULL;
return -1;
}
@@ -1087,6 +1101,8 @@ int osd_rdma_uninit(void)
device_unregister(osd_rdma_dev);
kfree(osd_rdma_dev);
osd_rdma_dev = NULL;
kfree(rdma_temp_tbl);
rdma_temp_tbl = NULL;
osd_rdma_init_flag = false;
}
return 0;