driver inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10043 ---------------------------------------------------------------------- L3 cache lock hardware restricts lock address to be aligned with the size, the driver gurantees this by using alloc_contig_pages. The size user applies may be arbitrary number but the driver will align the size up to PAGE_SIZE, causing checks of alignment of raw cache lock size and the address to fail. Fix this by change the size into actual allocated memory size and remove unnecessary checks of alignment. Signed-off-by: Yushan Wang <wangyushan12@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/soc/hisilicon/hisi_soc_l3c.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_soc_l3c.c b/drivers/soc/hisilicon/hisi_soc_l3c.c index 0aec6766b34b..8be404da6282 100644 --- a/drivers/soc/hisilicon/hisi_soc_l3c.c +++ b/drivers/soc/hisilicon/hisi_soc_l3c.c @@ -229,8 +229,16 @@ static int hisi_soc_l3c_do_lock(struct hisi_soc_comp *l3c_comp, int regset; u32 ctrl; - if (soc_l3c->max_lock_num == 1 && addr % size != 0) - return -EINVAL; + /* + * Quirk: L3C instance has only one available lock region requires lock + * region address to be aligned to its size. + * + * This is already guranteed by alloc_contig_pages, since we allocate + * minimum power-of-2 pages that fits the size. Make all allocated + * memory get locked to fulfill hardware's requirement. + */ + if (soc_l3c->max_lock_num == 1) + size = (1 << get_order(size)) * PAGE_SIZE; if (size < soc_l3c->min_lock_size) return -EINVAL; -- 2.33.0