iommu/fsl: Fix PAMU window size check.
is_power_of_2 requires an unsigned long parameter which would lead to truncation of 64 bit values on 32 bit architectures. __ffs also expects an unsigned long parameter thus won't work for 64 bit values on 32 bit architectures. Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com> Tested-by: Emil Medve <Emilian.Medve@Freescale.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
cd3de83f14
commit
d033f48f3a
2 changed files with 5 additions and 5 deletions
|
@ -170,10 +170,10 @@ int pamu_disable_liodn(int liodn)
|
||||||
static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
|
static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
|
||||||
{
|
{
|
||||||
/* Bug if not a power of 2 */
|
/* Bug if not a power of 2 */
|
||||||
BUG_ON(!is_power_of_2(addrspace_size));
|
BUG_ON((addrspace_size & (addrspace_size - 1)));
|
||||||
|
|
||||||
/* window size is 2^(WSE+1) bytes */
|
/* window size is 2^(WSE+1) bytes */
|
||||||
return __ffs(addrspace_size) - 1;
|
return fls64(addrspace_size) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Derive the PAACE window count encoding for the subwindow count */
|
/* Derive the PAACE window count encoding for the subwindow count */
|
||||||
|
@ -351,7 +351,7 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size,
|
||||||
struct paace *ppaace;
|
struct paace *ppaace;
|
||||||
unsigned long fspi;
|
unsigned long fspi;
|
||||||
|
|
||||||
if (!is_power_of_2(win_size) || win_size < PAMU_PAGE_SIZE) {
|
if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) {
|
||||||
pr_debug("window size too small or not a power of two %llx\n", win_size);
|
pr_debug("window size too small or not a power of two %llx\n", win_size);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin,
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_power_of_2(subwin_size) || subwin_size < PAMU_PAGE_SIZE) {
|
if ((subwin_size & (subwin_size - 1)) || subwin_size < PAMU_PAGE_SIZE) {
|
||||||
pr_debug("subwindow size out of range, or not a power of 2\n");
|
pr_debug("subwindow size out of range, or not a power of 2\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ static int check_size(u64 size, dma_addr_t iova)
|
||||||
* Size must be a power of two and at least be equal
|
* Size must be a power of two and at least be equal
|
||||||
* to PAMU page size.
|
* to PAMU page size.
|
||||||
*/
|
*/
|
||||||
if (!is_power_of_2(size) || size < PAMU_PAGE_SIZE) {
|
if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) {
|
||||||
pr_debug("%s: size too small or not a power of two\n", __func__);
|
pr_debug("%s: size too small or not a power of two\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue