staging: gasket: Fix dev_addr truncation on 32-bit arch

The extended address bit is at position 63 (c.f. apex_driver.c:60). The
device address will thus not fit in a ulong on 32-bit ARM systems.
Use u64 instead.

[toddpoynor@google.com: more fixups, fix debug printk param order]
Bug: 137378503
Signed-off-by: Waqar Hameed <waqarh@axis.com>
Change-Id: If801b2b97d88c1329f3a359507e265837150571c
This commit is contained in:
Waqar Hameed
2019-07-15 19:22:58 -07:00
committed by Leonid Lobachev
parent e2505d92c7
commit be43ad6a89
3 changed files with 19 additions and 18 deletions

View File

@@ -81,8 +81,8 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev)
{
int i;
int pack_shift;
ulong mask;
ulong value;
u64 mask;
u64 value;
struct gasket_interrupt_data *interrupt_data =
gasket_dev->interrupt_data;

View File

@@ -725,11 +725,11 @@ static inline bool gasket_addr_is_simple(struct gasket_page_table *pg_tbl,
* Extended page 1000, offset 511:
* Input (0, 1000, 511), Output 0x8003E81FF
*/
static ulong gasket_components_to_dev_address(struct gasket_page_table *pg_tbl,
static u64 gasket_components_to_dev_address(struct gasket_page_table *pg_tbl,
int is_simple, uint page_index,
uint offset)
{
ulong dev_addr = (page_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
u64 dev_addr = (page_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
return is_simple ? dev_addr : (pg_tbl->extended_flag | dev_addr);
}
@@ -791,8 +791,8 @@ static bool gasket_is_extended_dev_addr_bad(struct gasket_page_table *pg_tbl,
/* check if the device address is out of bound */
addr = dev_addr & ~((pg_tbl)->extended_flag);
if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) {
dev_err(pg_tbl->device, "device address out of bounds: 0x%llx\n",
dev_addr);
dev_err(pg_tbl->device,
"device address out of bounds: 0x%llx\n", dev_addr);
return true;
}
@@ -853,7 +853,7 @@ static void gasket_page_table_unmap_nolock(struct gasket_page_table *pg_tbl,
* If there is an error, no pages are mapped.
*/
static int gasket_map_simple_pages(struct gasket_page_table *pg_tbl,
ulong host_addr, ulong dev_addr,
ulong host_addr, u64 dev_addr,
uint num_pages, u32 flags)
{
int ret;
@@ -863,7 +863,8 @@ static int gasket_map_simple_pages(struct gasket_page_table *pg_tbl,
if (ret) {
dev_err(pg_tbl->device,
"page table slots %u (@ 0x%llx) to %u are not available\n",
slot_idx, dev_addr, slot_idx + num_pages - 1);
slot_idx, (long long unsigned int)dev_addr,
slot_idx + num_pages - 1);
return ret;
}
@@ -999,11 +1000,11 @@ static int gasket_alloc_extended_entries(struct gasket_page_table *pg_tbl,
* If there is an error, no pages are mapped.
*/
static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl,
ulong host_addr, ulong dev_addr,
ulong host_addr, u64 dev_addr,
uint num_pages, u32 flags)
{
int ret;
ulong dev_addr_end;
u64 dev_addr_end;
uint slot_idx, remain, len;
struct gasket_page_table_entry *pte;
u64 __iomem *slot_base;
@@ -1012,11 +1013,11 @@ static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl,
if (ret) {
dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1;
dev_err(pg_tbl->device,
"page table slots (%lu,%llu) (@ 0x%lx) to (%lu,%lu) are "
"not available\n",
"page table slots (%lu,%lu) (@ 0x%llx) to (%lu,%lu) "
"are not available\n",
gasket_extended_lvl0_page_idx(pg_tbl, dev_addr),
dev_addr,
gasket_extended_lvl1_page_idx(pg_tbl, dev_addr),
(long long unsigned int)dev_addr,
gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end),
gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end));
return ret;
@@ -1067,7 +1068,7 @@ static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl,
* The page table mutex is held for the entire operation.
*/
int gasket_page_table_map(struct gasket_page_table *pg_tbl, ulong host_addr,
ulong dev_addr, uint num_pages, u32 flags)
u64 dev_addr, uint num_pages, u32 flags)
{
int ret;
@@ -1194,7 +1195,7 @@ fail:
/* See gasket_page_table.h for description. */
bool gasket_page_table_are_addrs_bad(
struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr,
struct gasket_page_table *pg_tbl, ulong host_addr, u64 dev_addr,
ulong bytes)
{
if (host_addr & (PAGE_SIZE - 1)) {
@@ -1352,7 +1353,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
gasket_dev->page_table[index]->coherent_pages[j].paddr =
handle + j * PAGE_SIZE;
gasket_dev->page_table[index]->coherent_pages[j].kernel_virt =
(dma_addr_t)mem + j * PAGE_SIZE;
(ulong)mem + j * PAGE_SIZE;
}
return 0;

View File

@@ -97,7 +97,7 @@ int gasket_page_table_partition(struct gasket_page_table *page_table,
* If there is an error, no pages are mapped.
*/
int gasket_page_table_map(struct gasket_page_table *page_table, ulong host_addr,
ulong dev_addr, uint num_pages, u32 flags);
u64 dev_addr, uint num_pages, u32 flags);
/*
* Un-map host pages from device memory.
@@ -165,7 +165,7 @@ int gasket_page_table_lookup_page(struct gasket_page_table *page_table,
* Returns true if the mapping is bad, false otherwise.
*/
bool gasket_page_table_are_addrs_bad(struct gasket_page_table *page_table,
ulong host_addr, ulong dev_addr,
ulong host_addr, u64 dev_addr,
ulong bytes);
/*