Commit c5501aa9 authored by Roy Pledge's avatar Roy Pledge Committed by Li Yang

soc/fsl/qbman: Cleanup QMan queues if device was already initialized

If the QMan device was previously initialized make sure all the
frame queues are out of service once all the portals are probed.
This handles the case where the kernel is restarted without the
SoC being reset (kexec for example)
Signed-off-by: default avatarRoy Pledge <roy.pledge@nxp.com>
Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
parent 0505d00c
...@@ -2581,7 +2581,7 @@ static int _qm_dqrr_consume_and_match(struct qm_portal *p, u32 fqid, int s, ...@@ -2581,7 +2581,7 @@ static int _qm_dqrr_consume_and_match(struct qm_portal *p, u32 fqid, int s,
#define qm_dqrr_drain_nomatch(p) \ #define qm_dqrr_drain_nomatch(p) \
_qm_dqrr_consume_and_match(p, 0, 0, false) _qm_dqrr_consume_and_match(p, 0, 0, false)
static int qman_shutdown_fq(u32 fqid) int qman_shutdown_fq(u32 fqid)
{ {
struct qman_portal *p; struct qman_portal *p;
struct device *dev; struct device *dev;
...@@ -2754,7 +2754,7 @@ static int qman_shutdown_fq(u32 fqid) ...@@ -2754,7 +2754,7 @@ static int qman_shutdown_fq(u32 fqid)
DPAA_ASSERT((mcr->verb & QM_MCR_VERB_MASK) == DPAA_ASSERT((mcr->verb & QM_MCR_VERB_MASK) ==
QM_MCR_VERB_ALTER_OOS); QM_MCR_VERB_ALTER_OOS);
if (mcr->result) { if (mcr->result != QM_MCR_RESULT_OK) {
dev_err(dev, "OOS fail: FQ 0x%x (0x%x)\n", dev_err(dev, "OOS fail: FQ 0x%x (0x%x)\n",
fqid, mcr->result); fqid, mcr->result);
ret = -EIO; ret = -EIO;
......
...@@ -492,7 +492,7 @@ RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr); ...@@ -492,7 +492,7 @@ RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);
#endif #endif
static unsigned int qm_get_fqid_maxcnt(void) unsigned int qm_get_fqid_maxcnt(void)
{ {
return fqd_sz / 64; return fqd_sz / 64;
} }
...@@ -737,6 +737,17 @@ int qman_is_probed(void) ...@@ -737,6 +737,17 @@ int qman_is_probed(void)
} }
EXPORT_SYMBOL_GPL(qman_is_probed); EXPORT_SYMBOL_GPL(qman_is_probed);
int qman_requires_cleanup(void)
{
return __qman_requires_cleanup;
}
void qman_done_cleanup(void)
{
__qman_requires_cleanup = 0;
}
static int fsl_qman_probe(struct platform_device *pdev) static int fsl_qman_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
......
...@@ -233,7 +233,7 @@ static int qman_portal_probe(struct platform_device *pdev) ...@@ -233,7 +233,7 @@ static int qman_portal_probe(struct platform_device *pdev)
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
struct qm_portal_config *pcfg; struct qm_portal_config *pcfg;
struct resource *addr_phys[2]; struct resource *addr_phys[2];
int irq, cpu, err; int irq, cpu, err, i;
u32 val; u32 val;
err = qman_is_probed(); err = qman_is_probed();
...@@ -323,6 +323,22 @@ static int qman_portal_probe(struct platform_device *pdev) ...@@ -323,6 +323,22 @@ static int qman_portal_probe(struct platform_device *pdev)
if (!cpu_online(cpu)) if (!cpu_online(cpu))
qman_offline_cpu(cpu); qman_offline_cpu(cpu);
if (__qman_portals_probed == 1 && qman_requires_cleanup()) {
/*
* QMan wasn't reset prior to boot (Kexec for example)
* Empty all the frame queues so they are in reset state
*/
for (i = 0; i < qm_get_fqid_maxcnt(); i++) {
err = qman_shutdown_fq(i);
if (err) {
dev_err(dev, "Failed to shutdown frame queue %d\n",
i);
goto err_portal_init;
}
}
qman_done_cleanup();
}
return 0; return 0;
err_portal_init: err_portal_init:
......
...@@ -272,3 +272,10 @@ extern struct qman_portal *affine_portals[NR_CPUS]; ...@@ -272,3 +272,10 @@ extern struct qman_portal *affine_portals[NR_CPUS];
extern struct qman_portal *qman_dma_portal; extern struct qman_portal *qman_dma_portal;
const struct qm_portal_config *qman_get_qm_portal_config( const struct qm_portal_config *qman_get_qm_portal_config(
struct qman_portal *portal); struct qman_portal *portal);
unsigned int qm_get_fqid_maxcnt(void);
int qman_shutdown_fq(u32 fqid);
int qman_requires_cleanup(void);
void qman_done_cleanup(void);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment