Skip to content

Commit 4bc732b

Browse files
committed
Merge tag 'soc_fsl-7.0-2' of https://git.kernel.org/pub/scm/linux/kernel/git/chleroy/linux into arm/fixes
FSL SOC Fixes for 7.0 - Fix a race condition in Freescale Queue and Buffer Manager. - Fix a trivial error verification in CPM1 * tag 'soc_fsl-7.0-2' of https://git.kernel.org/pub/scm/linux/kernel/git/chleroy/linux: soc: fsl: cpm1: qmc: Fix error check for devm_ioremap_resource() in qmc_qe_init_resources() soc: fsl: qbman: fix race condition in qman_destroy_fq Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents b69d481 + 3f4e403 commit 4bc732b

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

drivers/soc/fsl/qbman/qman.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,18 +1827,38 @@ EXPORT_SYMBOL(qman_create_fq);
18271827

18281828
void qman_destroy_fq(struct qman_fq *fq)
18291829
{
1830+
int leaked;
1831+
18301832
/*
18311833
* We don't need to lock the FQ as it is a pre-condition that the FQ be
18321834
* quiesced. Instead, run some checks.
18331835
*/
18341836
switch (fq->state) {
18351837
case qman_fq_state_parked:
18361838
case qman_fq_state_oos:
1837-
if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID))
1838-
qman_release_fqid(fq->fqid);
1839+
/*
1840+
* There's a race condition here on releasing the fqid,
1841+
* setting the fq_table to NULL, and freeing the fqid.
1842+
* To prevent it, this order should be respected:
1843+
*/
1844+
if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID)) {
1845+
leaked = qman_shutdown_fq(fq->fqid);
1846+
if (leaked)
1847+
pr_debug("FQID %d leaked\n", fq->fqid);
1848+
}
18391849

18401850
DPAA_ASSERT(fq_table[fq->idx]);
18411851
fq_table[fq->idx] = NULL;
1852+
1853+
if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID) && !leaked) {
1854+
/*
1855+
* fq_table[fq->idx] should be set to null before
1856+
* freeing fq->fqid otherwise it could by allocated by
1857+
* qman_alloc_fqid() while still being !NULL
1858+
*/
1859+
smp_wmb();
1860+
gen_pool_free(qm_fqalloc, fq->fqid | DPAA_GENALLOC_OFF, 1);
1861+
}
18421862
return;
18431863
default:
18441864
break;

drivers/soc/fsl/qe/qmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,8 +1790,8 @@ static int qmc_qe_init_resources(struct qmc *qmc, struct platform_device *pdev)
17901790
return -EINVAL;
17911791
qmc->dpram_offset = res->start - qe_muram_dma(qe_muram_addr(0));
17921792
qmc->dpram = devm_ioremap_resource(qmc->dev, res);
1793-
if (IS_ERR(qmc->scc_pram))
1794-
return PTR_ERR(qmc->scc_pram);
1793+
if (IS_ERR(qmc->dpram))
1794+
return PTR_ERR(qmc->dpram);
17951795

17961796
return 0;
17971797
}

0 commit comments

Comments
 (0)