Skip to content

Commit 0cb1d9c

Browse files
arndbmchehab
authored andcommitted
media: verisilicon: change confusingly named relaxed register access
The register abstraction has wrappers around both the normal writel() and its writel_relaxed() counterpart, but this has led to a lot of users ending up with the relaxed version. There is sometimes a need to intentionally pick the relaxed accessor for performance critical functions, but I noticed that each hantro_reg_write() call also contains a non-relaxed readl(), which is typically much more expensive than a writel, so there is little benefit here but an added risk of missing a serialization against DMA. To make this behave like other interfaces, use the normal accessor by default and only provide the relaxed version as an alternative for performance critical code. hantro_postproc.c is the only place that used both the relaxed and normal writel, but this does not seem cricital either, so change it all to the normal ones. [hverkuil: fix function prototype alignment] Signed-off-by: Arnd Bergmann <arnd@arndb.de> Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 7ee8acd commit 0cb1d9c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

drivers/media/platform/verisilicon/hantro.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,14 @@ static __always_inline void hantro_reg_write(struct hantro_dev *vpu,
441441
const struct hantro_reg *reg,
442442
u32 val)
443443
{
444-
vdpu_write_relaxed(vpu, vdpu_read_mask(vpu, reg, val), reg->base);
444+
vdpu_write(vpu, vdpu_read_mask(vpu, reg, val), reg->base);
445445
}
446446

447-
static __always_inline void hantro_reg_write_s(struct hantro_dev *vpu,
448-
const struct hantro_reg *reg,
449-
u32 val)
447+
static __always_inline void hantro_reg_write_relaxed(struct hantro_dev *vpu,
448+
const struct hantro_reg *reg,
449+
u32 val)
450450
{
451-
vdpu_write(vpu, vdpu_read_mask(vpu, reg, val), reg->base);
451+
vdpu_write_relaxed(vpu, vdpu_read_mask(vpu, reg, val), reg->base);
452452
}
453453

454454
void *hantro_get_ctrl(struct hantro_ctx *ctx, u32 id);

drivers/media/platform/verisilicon/hantro_postproc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
val); \
2222
}
2323

24-
#define HANTRO_PP_REG_WRITE_S(vpu, reg_name, val) \
24+
#define HANTRO_PP_REG_WRITE_RELAXED(vpu, reg_name, val) \
2525
{ \
26-
hantro_reg_write_s(vpu, \
27-
&hantro_g1_postproc_regs.reg_name, \
28-
val); \
26+
hantro_reg_write_relaxed(vpu, \
27+
&hantro_g1_postproc_regs.reg_name, \
28+
val); \
2929
}
3030

3131
#define VPU_PP_IN_YUYV 0x0
@@ -72,7 +72,7 @@ static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
7272
dma_addr_t dst_dma;
7373

7474
/* Turn on pipeline mode. Must be done first. */
75-
HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x1);
75+
HANTRO_PP_REG_WRITE(vpu, pipeline_en, 0x1);
7676

7777
src_pp_fmt = VPU_PP_IN_NV12;
7878

@@ -242,7 +242,7 @@ static void hantro_postproc_g1_disable(struct hantro_ctx *ctx)
242242
{
243243
struct hantro_dev *vpu = ctx->dev;
244244

245-
HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x0);
245+
HANTRO_PP_REG_WRITE(vpu, pipeline_en, 0x0);
246246
}
247247

248248
static void hantro_postproc_g2_disable(struct hantro_ctx *ctx)

0 commit comments

Comments
 (0)