Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1343505ybi; Wed, 3 Jul 2019 14:00:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPGhucNRtVA/Lox62DYo41tpaTS6sNwkuyU6pN+ZfQ3DOwYrFWB6budADPwY8po3A24Ms4 X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr14827322pjr.92.1562187618775; Wed, 03 Jul 2019 14:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562187618; cv=none; d=google.com; s=arc-20160816; b=l9srXjp5N5IB8uaR1ioVxWUcWlhERhqgtsF1bvA6LGdw30Onhhd3hsTo1WS0Q+GfFc syMDOtDjLS8UWNd7tXCkLbzu3iOWyfbibg2AtW2CdjjakWPC7jpejN/TodcA3GnlhrhT c6mCvu4S17pG5Mcc2tC3Ww/0RGHtV+ZBGUCacBJ6nETtTlCwdHkU35JTsXYNNaO3Tbgh cZ0Y6asFC4x5L4wkL3vAPVlkLLeQJK0PXodfvSSEtj22CLhcHPEMvZUTAgNUDO7njAeZ xrH9ih4PXgkkF5cUUURDNOhdihZPGFcG2vY/W/zl8nK6ITRNPiQGyHu3PQBdxm+8BzkI 7jGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:reply-to:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=FvsWJrvejOHxRClN3xZ1gkKefbbL+X6CPpVlIbOXHYc=; b=WVyKblgrqMNGmLfq4hYsa1Lt1JucljuDedeWCsOb+a1ec4RtJXSA5isILcZk6V/0oN XT/AZ3eiuCSQflUs7RrlsG+5QHKvt+UEVLj1049wE0dO/yNzrW8hnFdGKTIAyT6tqF11 W/DFgz3rhwzZP/VlswXM58vHzg1Cu9BO0yaxN0hJWVw/GnwcnBCLJgIdyTp1sAXiIr8l 9MmXzEiuoOh7EYymQV4RT/qh9YQvqHbhQZvkG/0aoat46sbAshaN/0HNKZtwhb4Rl2HB kXtUHQInYewP13R7pKT0e2qLMzp+10jLIke10uKtFd+JV3Q7F3OEZTG4209NuG6m+Y5t aatA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GTJzXA6i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si3346004pgv.266.2019.07.03.14.00.03; Wed, 03 Jul 2019 14:00:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GTJzXA6i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbfGCU7g (ORCPT + 99 others); Wed, 3 Jul 2019 16:59:36 -0400 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49]:60289 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727280AbfGCU7c (ORCPT ); Wed, 3 Jul 2019 16:59:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FvsWJrvejOHxRClN3xZ1gkKefbbL+X6CPpVlIbOXHYc=; b=GTJzXA6ir3gFOEEfmpkarS4nFiqdXecrfHwOfYRCOCvcP9yI8Vie68AbRw9+OlB7M50RGW+dII71bALretx7HWkzW2DYb7BvniftqsBUDktYTVG2du/pK5xtMWsaEH0pqfhd9uhJPqHd7X4Ybx+rnGrlELuNCfEQoEFj0imLJrE= Received: from VE1PR04MB6463.eurprd04.prod.outlook.com (20.179.233.20) by VE1PR04MB6592.eurprd04.prod.outlook.com (20.179.234.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.17; Wed, 3 Jul 2019 20:59:30 +0000 Received: from VE1PR04MB6463.eurprd04.prod.outlook.com ([fe80::a5ca:7c9c:6b18:eb0a]) by VE1PR04MB6463.eurprd04.prod.outlook.com ([fe80::a5ca:7c9c:6b18:eb0a%6]) with mapi id 15.20.2032.019; Wed, 3 Jul 2019 20:59:30 +0000 From: Roy Pledge To: "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Leo Li CC: Roy Pledge Subject: [PATCH v2 3/7] soc/fsl/qbman: Cleanup QMan queues if device was already initialized Thread-Topic: [PATCH v2 3/7] soc/fsl/qbman: Cleanup QMan queues if device was already initialized Thread-Index: AQHVMeI1E8Yqep3QnkaAT4Gy8a4rQg== Date: Wed, 3 Jul 2019 20:59:30 +0000 Message-ID: <1562187548-32261-4-git-send-email-roy.pledge@nxp.com> References: <1562187548-32261-1-git-send-email-roy.pledge@nxp.com> In-Reply-To: <1562187548-32261-1-git-send-email-roy.pledge@nxp.com> Reply-To: Roy Pledge Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: SN6PR15CA0005.namprd15.prod.outlook.com (2603:10b6:805:16::18) To VE1PR04MB6463.eurprd04.prod.outlook.com (2603:10a6:803:11d::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=roy.pledge@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [72.142.119.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc1c4512-6da9-4399-df53-08d6fff95779 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:VE1PR04MB6592; x-ms-traffictypediagnostic: VE1PR04MB6592: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2150; x-forefront-prvs: 00872B689F x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(376002)(396003)(39860400002)(366004)(136003)(199004)(189003)(2616005)(6636002)(52116002)(2201001)(446003)(86362001)(476003)(7736002)(11346002)(110136005)(44832011)(3450700001)(256004)(6486002)(478600001)(5660300002)(305945005)(486006)(99286004)(14454004)(316002)(43066004)(66446008)(66946007)(73956011)(6512007)(8936002)(50226002)(81166006)(81156014)(3846002)(26005)(6116002)(71200400001)(186003)(71190400001)(2501003)(68736007)(64756008)(53936002)(386003)(66066001)(25786009)(8676002)(102836004)(76176011)(66556008)(6506007)(2906002)(66476007)(36756003)(4326008)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR04MB6592;H:VE1PR04MB6463.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: dRiOS99F3NK1mL8s5JFdD178voaZR/v23tvnZ3N+aQoDbJgsylRiYpUY7JT845GgiYHbSW1YR625ai9SEB+8C50ercoBEymX4gqFQGQxPa5jEMEkiAkz0spaCtSJS8ppjA628ap4AUSxMsZuzZlaZ2QvXjKqo5o+kUEFK9FWEnu48DJhAfrd9BBhHSVDqBoQ2ICVsXsVWCwcrk33cJGj9tJTK1s1zCSY/GuinnNCAiOLt5EdnRRdn83Uw870nTTrOu0zf2u1y62urEiQoerOLebTSkZc6JRn5xCQ50NkG1jUKSQv2b0TnHQPBItQf4Gsn9MRNyFFRdLerjEwkDYWBqduf72QTtAa4TwtjEMUgsnM7ZIsnBynmHuokFXQqc2iBvm01v5DbSpQ11ev7Zpmqk5enN9zU6DLI3DQlTJ6qP4= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc1c4512-6da9-4399-df53-08d6fff95779 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2019 20:59:30.2326 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: roy.pledge@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6592 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Roy Pledge --- drivers/soc/fsl/qbman/qman.c | 4 ++-- drivers/soc/fsl/qbman/qman_ccsr.c | 13 ++++++++++++- drivers/soc/fsl/qbman/qman_portal.c | 18 +++++++++++++++++- drivers/soc/fsl/qbman/qman_priv.h | 7 +++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index 636f83f..f10f77d 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -2581,7 +2581,7 @@ static int _qm_dqrr_consume_and_match(struct qm_porta= l *p, u32 fqid, int s, #define qm_dqrr_drain_nomatch(p) \ _qm_dqrr_consume_and_match(p, 0, 0, false) =20 -static int qman_shutdown_fq(u32 fqid) +int qman_shutdown_fq(u32 fqid) { struct qman_portal *p; struct device *dev; @@ -2754,7 +2754,7 @@ static int qman_shutdown_fq(u32 fqid) =20 DPAA_ASSERT((mcr->verb & QM_MCR_VERB_MASK) =3D=3D QM_MCR_VERB_ALTER_OOS); - if (mcr->result) { + if (mcr->result !=3D QM_MCR_RESULT_OK) { dev_err(dev, "OOS fail: FQ 0x%x (0x%x)\n", fqid, mcr->result); ret =3D -EIO; diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman= _ccsr.c index 39f6fc1..fcf77e0 100644 --- a/drivers/soc/fsl/qbman/qman_ccsr.c +++ b/drivers/soc/fsl/qbman/qman_ccsr.c @@ -483,7 +483,7 @@ RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman= _pfdr); =20 #endif =20 -static unsigned int qm_get_fqid_maxcnt(void) +unsigned int qm_get_fqid_maxcnt(void) { return fqd_sz / 64; } @@ -728,6 +728,17 @@ int qman_is_probed(void) } EXPORT_SYMBOL_GPL(qman_is_probed); =20 +int qman_requires_cleanup(void) +{ + return __qman_requires_cleanup; +} + +void qman_done_cleanup(void) +{ + __qman_requires_cleanup =3D 0; +} + + static int fsl_qman_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qm= an_portal.c index 75717bc..153727c 100644 --- a/drivers/soc/fsl/qbman/qman_portal.c +++ b/drivers/soc/fsl/qbman/qman_portal.c @@ -233,7 +233,7 @@ static int qman_portal_probe(struct platform_device *pd= ev) struct device_node *node =3D dev->of_node; struct qm_portal_config *pcfg; struct resource *addr_phys[2]; - int irq, cpu, err; + int irq, cpu, err, i; u32 val; =20 err =3D qman_is_probed(); @@ -328,6 +328,22 @@ static int qman_portal_probe(struct platform_device *p= dev) if (!cpu_online(cpu)) qman_offline_cpu(cpu); =20 + if (__qman_portals_probed =3D=3D 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 =3D 0; i < qm_get_fqid_maxcnt(); i++) { + err =3D 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; =20 err_portal_init: diff --git a/drivers/soc/fsl/qbman/qman_priv.h b/drivers/soc/fsl/qbman/qman= _priv.h index 0451571..a8a35fe 100644 --- a/drivers/soc/fsl/qbman/qman_priv.h +++ b/drivers/soc/fsl/qbman/qman_priv.h @@ -272,3 +272,10 @@ extern struct qman_portal *affine_portals[NR_CPUS]; extern struct qman_portal *qman_dma_portal; const struct qm_portal_config *qman_get_qm_portal_config( 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); --=20 2.7.4