Skip to content

Commit 6e9c5c8

Browse files
Wolfram Sangvinodkoul
authored andcommitted
dmaengine: sh: rz-dmac: handle configs where one address is zero
Configs like the ones coming from the MMC subsystem will have either 'src' or 'dst' zeroed, resulting in an unknown bus width. This will bail out on the RZ DMA driver because of the sanity check for a valid bus width. Reorder the code, so that the check will only be applied when the corresponding address is non-zero. Fixes: 5000d37 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Biju Das <biju.das.jz@bp.renesas.com> Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://lore.kernel.org/r/20241007110200.43166-6-wsa+renesas@sang-engineering.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 9852d85 commit 6e9c5c8

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

drivers/dma/sh/rz-dmac.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -601,22 +601,25 @@ static int rz_dmac_config(struct dma_chan *chan,
601601
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
602602
u32 val;
603603

604-
channel->src_per_address = config->src_addr;
605604
channel->dst_per_address = config->dst_addr;
606-
607-
val = rz_dmac_ds_to_val_mapping(config->dst_addr_width);
608-
if (val == CHCFG_DS_INVALID)
609-
return -EINVAL;
610-
611605
channel->chcfg &= ~CHCFG_FILL_DDS_MASK;
612-
channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val);
606+
if (channel->dst_per_address) {
607+
val = rz_dmac_ds_to_val_mapping(config->dst_addr_width);
608+
if (val == CHCFG_DS_INVALID)
609+
return -EINVAL;
613610

614-
val = rz_dmac_ds_to_val_mapping(config->src_addr_width);
615-
if (val == CHCFG_DS_INVALID)
616-
return -EINVAL;
611+
channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val);
612+
}
617613

614+
channel->src_per_address = config->src_addr;
618615
channel->chcfg &= ~CHCFG_FILL_SDS_MASK;
619-
channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val);
616+
if (channel->src_per_address) {
617+
val = rz_dmac_ds_to_val_mapping(config->src_addr_width);
618+
if (val == CHCFG_DS_INVALID)
619+
return -EINVAL;
620+
621+
channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val);
622+
}
620623

621624
return 0;
622625
}

0 commit comments

Comments
 (0)