From patchwork Thu Aug 1 20:16:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Pledge X-Patchwork-Id: 11071317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C4EE14DB for ; Thu, 1 Aug 2019 20:17:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BFA52875E for ; Thu, 1 Aug 2019 20:17:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 604A628767; Thu, 1 Aug 2019 20:17:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA7392875E for ; Thu, 1 Aug 2019 20:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To: References:Message-ID:Date:Subject:To:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=flON/DRNumm1DefAKghvXHmUoa+b9rGb3zMvt1teS0c=; b=XVD1R6RnYoosXe yBRTY9oviFD01sNE8opUhhRIBy40+Z1pTtZTp6veEa0yv/g5TE7yqr4UqSzwKudcP5C/5S+KGUzVl tPP4uLyF7Yj1N8UL2qWlZwu4wOuOjkBwilPzQ2Z/7id5Qw83Mg+jZtutubCU1NomtpVbl6AqvFplB OAs6Z6hPMXqIDPhu0TyvS+Ja8R6g6FjbgWaeFNp24f7rGMS6MC9p21xdxBP0iq02vsSNeAEXMIfZL nIBSJ/8MOPkHjccGl/4DeFJp23lxxt9i6cLM3vYdlqvEoxisooGhY1KxtyT9XpU19aLQUZavrWFPi UuXEo1AdBtSINPmqLoBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1htHVz-0004yN-Br; Thu, 01 Aug 2019 20:17:31 +0000 Received: from mail-eopbgr60075.outbound.protection.outlook.com ([40.107.6.75] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1htHVW-0004EZ-Hr for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2019 20:17:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=COMNkqqzs5CsKt/H7wpCMVjTTkVi14dr6AG3zti6O+Iiyn+PVb+XywUn8QTurHnNXqW1fw35k/0sa+9GNDNS6XfMO9XlTmWnkh0bjvLbvmNHpQv1GuryucqDIXwSq1K2/7DFmshyJulQwnF9T0NQoxqAlnbiPwmIC/2mj/IajmyKh3fVY+WU/5vOGbVDGE17bqieqYRb8QIv3mULkqgh+KBKeKwkzgQoNWyaOjABxHHnGSaQgN9G2w+fIWSlFqxt9AbVPeyxNS1MW0kxj1p7HXGi8gth3hul2hALIiv75uFTRh3GgNut4NIFLN1u8D3DyTa8ETfExaS10eY/RWEUvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3Rc8vExPXZwB8d4MZ9x7eOtOwLPlGtoP7wKctkSKqwI=; b=WtH0aP3OPGRC94SsYkQJzicX/cm8QtbGz6J71rfCM0iqvJLQGf5ENh8cKFQ+r2FmFw2noNiglBkjgkVASyceBX46SSyWuuV5u5VIgMW8AIczZE/Xk4qzHq1iTrHe+U/r0cinYr47Y3zT9hbFdtvYssVjDhCVnsAyPS4TiK+v33ZGN3xTV29uBBVbcZNIOpBiiiBET3CwPrfwq6YQO70lDr2liiTBPGMnghIL3uNdu7m3WdSFEjYVXniIpEj7TmwlWAJjA22ZqL8wvo3xHxWWNPd6VA/jsNi4pCvuMOoSob/l2tv9Qu/Qb9YIuzO2uBnOIXzzyk8j93rgpApwiTLR4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=nxp.com;dmarc=pass action=none header.from=nxp.com;dkim=pass header.d=nxp.com;arc=none 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=3Rc8vExPXZwB8d4MZ9x7eOtOwLPlGtoP7wKctkSKqwI=; b=dkzwf6ehWUSsFxnj5bVwLOBn9xNIvvwFDQSCIr31mq3P0HwGJXCgap/iCH6NB44zlN7LhYK1slpIHUgBrjrQcqRc/vepEx3ywBIYXvF95EM2p7viIOmrXbO+i8vfU+fvsTrjw5JeTV5UIguu5HLvfDHazL+55l/oxKiE2ubNUs0= Received: from VE1PR04MB6463.eurprd04.prod.outlook.com (20.179.233.20) by VE1PR04MB6656.eurprd04.prod.outlook.com (20.179.235.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.10; Thu, 1 Aug 2019 20:16:55 +0000 Received: from VE1PR04MB6463.eurprd04.prod.outlook.com ([fe80::8fc:e04c:fbb6:4f1f]) by VE1PR04MB6463.eurprd04.prod.outlook.com ([fe80::8fc:e04c:fbb6:4f1f%7]) with mapi id 15.20.2115.005; Thu, 1 Aug 2019 20:16:55 +0000 From: Roy Pledge To: "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Leo Li Subject: [PATCH v3 2/7] soc/fsl/qbman: Cleanup buffer pools if BMan was initialized prior to bootup Thread-Topic: [PATCH v3 2/7] soc/fsl/qbman: Cleanup buffer pools if BMan was initialized prior to bootup Thread-Index: AQHVSKYQDdAXIzwWDEO2MM4P3XgCBw== Date: Thu, 1 Aug 2019 20:16:55 +0000 Message-ID: <1564690599-29713-3-git-send-email-roy.pledge@nxp.com> References: <1564690599-29713-1-git-send-email-roy.pledge@nxp.com> In-Reply-To: <1564690599-29713-1-git-send-email-roy.pledge@nxp.com> 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: SN4PR0501CA0130.namprd05.prod.outlook.com (2603:10b6:803:42::47) 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: 38197fa7-df37-48c1-fe59-08d716bd32c9 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:VE1PR04MB6656; x-ms-traffictypediagnostic: VE1PR04MB6656: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:494; x-forefront-prvs: 01165471DB x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(136003)(376002)(396003)(366004)(199004)(189003)(386003)(6506007)(305945005)(7736002)(71200400001)(71190400001)(68736007)(14454004)(36756003)(54906003)(316002)(110136005)(6116002)(3846002)(486006)(186003)(66066001)(6436002)(256004)(26005)(2201001)(6636002)(3450700001)(44832011)(6486002)(102836004)(2906002)(446003)(476003)(2616005)(50226002)(64756008)(66446008)(66476007)(25786009)(81166006)(66946007)(52116002)(5660300002)(11346002)(76176011)(478600001)(66556008)(8676002)(86362001)(81156014)(8936002)(99286004)(6512007)(4326008)(2501003)(53936002)(43066004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6656; 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: Q3/DR5KhiU0n0aX2rXM4WagF1mgdLPXZQtkbNCGb56MN3TNdsEPnGzrS3q3QTS/2ZI1hiuRnW52+WPxJorOlFdPM0Em1RvZXGraqL/Yq6iLSgVWmB745yosP4aPu54wXTRBddfYTRrK9ymkAFtNjKS6vIY1mwJsZJBU1AuJMKkCzwltBZaqv5jUPaj0noBRPLz/ns5ea7RdjmjyrKZrOuWkzc9z4LLFzViYh/IprOEm7oKXkUAbXdFK920WNDjOADPDGNo5qRk9MHcepIPBCDAgZhy2a7LzQlE43LlnwqSZJu1y1z5SFo+5WKYqSbSlKoecpwtKDOJx8oa2yjqsej5Aw113vkDGdS6VRR6Q8v1DO99zJsa1cKcxbrL9hItVCw7U4zyWe75qKj57RB206vfv9lxcx/zqzdJGXNy/WGlc= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38197fa7-df37-48c1-fe59-08d716bd32c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Aug 2019 20:16:55.4822 (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: VE1PR04MB6656 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190801_131702_597889_74F26947 X-CRM114-Status: GOOD ( 16.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Roy Pledge Cc: Roy Pledge , Laurentiu Tudor , Madalin-cristian Bucur Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Clean the BMan buffer pools if the device had been initialized previously. This will ensure a consistent state if the kernel was soft restarted (kexec for example) Signed-off-by: Roy Pledge --- drivers/soc/fsl/qbman/bman.c | 17 +++++++++-------- drivers/soc/fsl/qbman/bman_ccsr.c | 10 ++++++++++ drivers/soc/fsl/qbman/bman_portal.c | 18 +++++++++++++++++- drivers/soc/fsl/qbman/bman_priv.h | 5 +++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c index f84ab59..f4fb527 100644 --- a/drivers/soc/fsl/qbman/bman.c +++ b/drivers/soc/fsl/qbman/bman.c @@ -635,30 +635,31 @@ int bman_p_irqsource_add(struct bman_portal *p, u32 bits) return 0; } -static int bm_shutdown_pool(u32 bpid) +int bm_shutdown_pool(u32 bpid) { + int err = 0; struct bm_mc_command *bm_cmd; union bm_mc_result *bm_res; + + struct bman_portal *p = get_affine_portal(); while (1) { - struct bman_portal *p = get_affine_portal(); /* Acquire buffers until empty */ bm_cmd = bm_mc_start(&p->p); bm_cmd->bpid = bpid; bm_mc_commit(&p->p, BM_MCC_VERB_CMD_ACQUIRE | 1); if (!bm_mc_result_timeout(&p->p, &bm_res)) { - put_affine_portal(); pr_crit("BMan Acquire Command timedout\n"); - return -ETIMEDOUT; + err = -ETIMEDOUT; + goto done; } if (!(bm_res->verb & BM_MCR_VERB_ACQUIRE_BUFCOUNT)) { - put_affine_portal(); /* Pool is empty */ - return 0; + goto done; } - put_affine_portal(); } - +done: + put_affine_portal(); return 0; } diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c index dc6d7e5..cb24a08 100644 --- a/drivers/soc/fsl/qbman/bman_ccsr.c +++ b/drivers/soc/fsl/qbman/bman_ccsr.c @@ -195,6 +195,16 @@ int bman_is_probed(void) } EXPORT_SYMBOL_GPL(bman_is_probed); +int bman_requires_cleanup(void) +{ + return __bman_requires_cleanup; +} + +void bman_done_cleanup(void) +{ + __bman_requires_cleanup = 0; +} + static int fsl_bman_probe(struct platform_device *pdev) { int ret, err_irq; diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c index c78cc69..cc06d95 100644 --- a/drivers/soc/fsl/qbman/bman_portal.c +++ b/drivers/soc/fsl/qbman/bman_portal.c @@ -100,7 +100,7 @@ static int bman_portal_probe(struct platform_device *pdev) struct device_node *node = dev->of_node; struct bm_portal_config *pcfg; struct resource *addr_phys[2]; - int irq, cpu, err; + int irq, cpu, err, i; err = bman_is_probed(); if (!err) @@ -181,6 +181,22 @@ static int bman_portal_probe(struct platform_device *pdev) if (!cpu_online(cpu)) bman_offline_cpu(cpu); + if (__bman_portals_probed == 1 && bman_requires_cleanup()) { + /* + * BMan wasn't reset prior to boot (Kexec for example) + * Empty all the buffer pools so they are in reset state + */ + for (i = 0; i < BM_POOL_MAX; i++) { + err = bm_shutdown_pool(i); + if (err) { + dev_err(dev, "Failed to shutdown bpool %d\n", + i); + goto err_portal_init; + } + } + bman_done_cleanup(); + } + return 0; err_portal_init: diff --git a/drivers/soc/fsl/qbman/bman_priv.h b/drivers/soc/fsl/qbman/bman_priv.h index 751ce90..aa3981e 100644 --- a/drivers/soc/fsl/qbman/bman_priv.h +++ b/drivers/soc/fsl/qbman/bman_priv.h @@ -76,3 +76,8 @@ int bman_p_irqsource_add(struct bman_portal *p, u32 bits); const struct bm_portal_config * bman_get_bm_portal_config(const struct bman_portal *portal); + +int bman_requires_cleanup(void); +void bman_done_cleanup(void); + +int bm_shutdown_pool(u32 bpid);