Skip to content

Commit 76ed9b7

Browse files
mkumardvinodkoul
authored andcommitted
dmaengine: tegra210-adma: check for adma max page
Have additional check for max channel page during the probe to cover if any offset overshoot happens due to wrong DT configuration. Fixes: 68811c9 ("dmaengine: tegra210-adma: Support channel page") Cc: [email protected] Signed-off-by: Mohan Kumar D <[email protected]> Reviewed-by: Jon Hunter <[email protected]> Acked-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 1798745 commit 76ed9b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/dma/tegra210-adma.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ struct tegra_adma;
8383
* @nr_channels: Number of DMA channels available.
8484
* @ch_fifo_size_mask: Mask for FIFO size field.
8585
* @sreq_index_offset: Slave channel index offset.
86+
* @max_page: Maximum ADMA Channel Page.
8687
* @has_outstanding_reqs: If DMA channel can have outstanding requests.
88+
* @set_global_pg_config: Global page programming.
8789
*/
8890
struct tegra_adma_chip_data {
8991
unsigned int (*adma_get_burst_config)(unsigned int burst_size);
@@ -99,6 +101,7 @@ struct tegra_adma_chip_data {
99101
unsigned int nr_channels;
100102
unsigned int ch_fifo_size_mask;
101103
unsigned int sreq_index_offset;
104+
unsigned int max_page;
102105
bool has_outstanding_reqs;
103106
void (*set_global_pg_config)(struct tegra_adma *tdma);
104107
};
@@ -854,6 +857,7 @@ static const struct tegra_adma_chip_data tegra210_chip_data = {
854857
.nr_channels = 22,
855858
.ch_fifo_size_mask = 0xf,
856859
.sreq_index_offset = 2,
860+
.max_page = 0,
857861
.has_outstanding_reqs = false,
858862
.set_global_pg_config = NULL,
859863
};
@@ -871,6 +875,7 @@ static const struct tegra_adma_chip_data tegra186_chip_data = {
871875
.nr_channels = 32,
872876
.ch_fifo_size_mask = 0x1f,
873877
.sreq_index_offset = 4,
878+
.max_page = 4,
874879
.has_outstanding_reqs = true,
875880
.set_global_pg_config = tegra186_adma_global_page_config,
876881
};
@@ -921,7 +926,7 @@ static int tegra_adma_probe(struct platform_device *pdev)
921926
page_offset = res_page->start - res_base->start;
922927
page_no = div_u64(page_offset, cdata->ch_base_offset);
923928

924-
if (WARN_ON(page_no == 0))
929+
if (WARN_ON(page_no == 0 || page_no > cdata->max_page))
925930
return -EINVAL;
926931

927932
tdma->ch_page_no = lower_32_bits(page_no) - 1;

0 commit comments

Comments
 (0)