From patchwork Mon Dec 10 16:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 10721755 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 EE9F615A6 for ; Mon, 10 Dec 2018 16:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0282A797 for ; Mon, 10 Dec 2018 16:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEF242A7A0; Mon, 10 Dec 2018 16:51:02 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 649502A79B for ; Mon, 10 Dec 2018 16:51:02 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8J9/KRJTbAq9UT/YO+TKWtm8il9G00tExfRSmiUDEuU=; b=lt60rCyzujjTdL w0yNdGPzjFHyB7Il0SqyiCx++UNGurZ2tuH3W388WdQFF1D3hgQdSQbq+13H8p+BPYr7x3PL6T8Kv iQkfBP7bSk2QhQktK04hYGBjBwUQ4gnUY2YDcwwbSZ6Kq/YuLoBidC3OXf0+518xRlj2qgvEARxHZ jOUh/mBsFGN0alb/fBVKUycuQN41EhRU77miA0kLvCsZcia+OQUQUW63mq2ls92x3w2Nm0xmVFs2I 0DAGU6oQTuaeVfM82KPCAdk5wHYmErhJmEofw9krQYm0EfqIUkTtJTDuh0yvBDEwsQxTIRht1h1Bt kBuOGQC/9sdYERD3kR7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlf-0001X3-0s; Mon, 10 Dec 2018 16:50:51 +0000 Received: from mail-eopbgr70042.outbound.protection.outlook.com ([40.107.7.42] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlO-0001DI-DK for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 16:50:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tqFbx0VKhtoVm8BZ24rAMcG9MKLHBqjn6R5imZMoAHY=; b=YeFx17FUSshdPD383Jaif7PRWIvBy/obqYUTbTu7UptVas4fi0ZsHhIR36CdH1ILguzqy7r7RbPtLJb6wIQMvCwhp2hRTOAbDhx9lFBsf1LsP6v3zWEj9oJzZEiFDIdf6jbknA6RsgZf9vQAMAZjUhAnv+J9p27yXVOfWKMydEs= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB2750.eurprd04.prod.outlook.com (10.175.22.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Mon, 10 Dec 2018 16:50:17 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86%11]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 16:50:17 +0000 From: Ioana Ciornei To: Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" Subject: [PATCH 1/5] soc: fsl: dpio: perform DPIO Reset on Probe Thread-Topic: [PATCH 1/5] soc: fsl: dpio: perform DPIO Reset on Probe Thread-Index: AQHUkKhtevHApK9oQ0WMI/6A2CJhog== Date: Mon, 10 Dec 2018 16:50:17 +0000 Message-ID: <1544460591-14888-2-git-send-email-ioana.ciornei@nxp.com> References: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0145.eurprd08.prod.outlook.com (2603:10a6:800:d5::23) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB2750; 6:BLCHQUurPNQBqpJm7yWrNdoasG7Qvo16kXYEUZH//gukJEe7pG6ItEhPbsSKiqqdmaq8sGG+P23yi0hTU8g0gQxepDjmxX1Atz+OI/pYvDliquiXiTmVOsto34P9Wj9mY+HR7rk5bzP6sZWSCXGnCU4EMyw+QQ5blwD9jBrgSl3O3DzIbdeWaN+Q23fMOWBKXyyjC02wWesx5RFScaVi0F7E5rohNWmIhqMejOsiqIkuyLgpjQ4LE1lsvMqMP+YqMjKtsKWOG5hYhdQwqa97Aojfd2k849cx9h/APXJXEUyvQebQgpIG5eGJxJEQF1UsbRvNeKIoZKOs8/NCI0orDZgRz9cnrGRz4sw16fSBkrCH0Nkw6+NXcsS6QbMJ0worVVWcJqXi/ZQkLO6zU54tswtDzvXVyTZk6U7+6SZwZeKfjS/qZh2hiMCke2AeoMHSuNry9+FC8sfvrby/WHpBoQ==; 5:nvZ4xHiGfDRCNq7Do8HtJWwtLFblvEuUB3LTsLcE3yEygUAnmmXcRQLfSLnnImhhNkRTbbNzTnmy/t7iHCAM454mFrpJFp20dWDqAwPgQued0DdCKYd+RHhD0AqcKkCmk5NBuwb4xpWn2Vw7Kpy3Va2ccc+DI6lQghRcjRK0/M4=; 7:haXgMINTQI3J9LqLVeqzWfD7/ge6EIx4zZTWwEu13pSTHJYpbVIcSzebMCD3wuqDbTDinBCxEeCwTS040b+oq+gzwX3Jm0irh7gOz/oCg2RbcmMue+RQKhzIltwCJq2AXmK3dWPwEK34WRfiGJRgLg== x-ms-office365-filtering-correlation-id: 34502e75-4133-4a73-3c9d-08d65ebf904b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB2750; x-ms-traffictypediagnostic: VI1PR0402MB2750: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB2750; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB2750; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(186003)(2501003)(11346002)(44832011)(53936002)(2616005)(71190400001)(476003)(2201001)(3846002)(6116002)(71200400001)(66066001)(486006)(305945005)(7736002)(86362001)(68736007)(36756003)(6436002)(81156014)(14444005)(316002)(110136005)(8936002)(14454004)(81166006)(478600001)(446003)(256004)(54906003)(25786009)(8676002)(6486002)(99286004)(76176011)(102836004)(106356001)(26005)(105586002)(386003)(2906002)(97736004)(5660300001)(6506007)(52116002)(6512007)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2750; H:VI1PR0402MB2800.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-microsoft-antispam-message-info: 1zda0kHoEMTdQwN0chTwjG3jnd6bZcb3N7ZMX0jk5qJd3+q1kveIlBtZDEraromTOKLpmMIENhYk7MhNdZayjMhVkMG+wIQ7T9jwzHVUIEOHSgwM6T1lYf8nke/wOxFrOpqOBnqQRIdWxQfiGfNJoFVsRNF5bIqmjJSLxe9bpUdMttfQaikLb8aNxORF4f9C/03I3XqnPyILIE9yanEcQDd4nojKXh8DKDf2GaLmZmS0CGF7Bi6l9LHPfE2KYT+x9BOgWG2p2axeJCF5gY0zfEIfs4jgX8GwjDBUZnHTu22vqSxBstFJEDatATaULTBG spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34502e75-4133-4a73-3c9d-08d65ebf904b X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 16:50:17.4830 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2750 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_085034_451318_6C44458F X-CRM114-Status: GOOD ( 16.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Pledge , Ioana Ciocoi Radulescu , Horia Geanta , Laurentiu Tudor 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 From: Roy Pledge Invoke a DPIO reset command when a DPIO device is probed. This will ensure the QBMan portal is in the state the driver expects. Signed-off-by: Roy Pledge --- drivers/soc/fsl/dpio/dpio-cmd.h | 1 + drivers/soc/fsl/dpio/dpio-driver.c | 7 +++++++ drivers/soc/fsl/dpio/dpio.c | 23 +++++++++++++++++++++++ drivers/soc/fsl/dpio/dpio.h | 4 ++++ 4 files changed, 35 insertions(+) diff --git a/drivers/soc/fsl/dpio/dpio-cmd.h b/drivers/soc/fsl/dpio/dpio-cmd.h index ab8f82e..5814d2f 100644 --- a/drivers/soc/fsl/dpio/dpio-cmd.h +++ b/drivers/soc/fsl/dpio/dpio-cmd.h @@ -25,6 +25,7 @@ #define DPIO_CMDID_ENABLE DPIO_CMD(0x002) #define DPIO_CMDID_DISABLE DPIO_CMD(0x003) #define DPIO_CMDID_GET_ATTR DPIO_CMD(0x004) +#define DPIO_CMDID_RESET DPIO_CMD(0x005) struct dpio_cmd_open { __le32 dpio_id; diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c index 832175c..38ee9db 100644 --- a/drivers/soc/fsl/dpio/dpio-driver.c +++ b/drivers/soc/fsl/dpio/dpio-driver.c @@ -110,6 +110,12 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) goto err_open; } + err = dpio_reset(dpio_dev->mc_io, 0, dpio_dev->mc_handle); + if (err) { + dev_err(dev, "dpio_reset() failed\n"); + goto err_reset; + } + err = dpio_get_attributes(dpio_dev->mc_io, 0, dpio_dev->mc_handle, &dpio_attrs); if (err) { @@ -192,6 +198,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) err_allocate_irqs: dpio_disable(dpio_dev->mc_io, 0, dpio_dev->mc_handle); err_get_attr: +err_reset: dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle); err_open: fsl_mc_portal_free(dpio_dev->mc_io); diff --git a/drivers/soc/fsl/dpio/dpio.c b/drivers/soc/fsl/dpio/dpio.c index ff37c80..521bc69 100644 --- a/drivers/soc/fsl/dpio/dpio.c +++ b/drivers/soc/fsl/dpio/dpio.c @@ -196,3 +196,26 @@ int dpio_get_api_version(struct fsl_mc_io *mc_io, return 0; } + +/** + * dpio_reset() - Reset the DPIO, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_reset(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token) +{ + struct fsl_mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} diff --git a/drivers/soc/fsl/dpio/dpio.h b/drivers/soc/fsl/dpio/dpio.h index 49194c8..b2ac4ba 100644 --- a/drivers/soc/fsl/dpio/dpio.h +++ b/drivers/soc/fsl/dpio/dpio.h @@ -80,4 +80,8 @@ int dpio_get_api_version(struct fsl_mc_io *mc_io, u16 *major_ver, u16 *minor_ver); +int dpio_reset(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + #endif /* __FSL_DPIO_H */ From patchwork Mon Dec 10 16:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 10721761 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 0C4C915A6 for ; Mon, 10 Dec 2018 16:51:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC03B2A79B for ; Mon, 10 Dec 2018 16:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD2D02A7C4; Mon, 10 Dec 2018 16:51:35 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 6E4AC2A79B for ; Mon, 10 Dec 2018 16:51:35 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lWDBmU1mgg/qfP3nX8i9s+6k4xOrqCgiSHjiXXTFWIg=; b=M5W36Ck1oUMFRh BqQ0okqghGN2Z2F1qNGZ5UTd7YZfMZUl5QQ+ic0Cf/DSQLr3ib028FKoHRKCHiUcIHwGgg7Qp+IQ7 qNJxwhpSp0CeGQ6gHx6fDsQZkjFKehg3dcx5AD8IHnXEenwnBvqNzJjt1ltOh+h6Ciaso4FYgcxxY OmkVZSX6iU2Zdu9hC4HVzSLUfYHyEDcN6UIXfasrXwHK3WJF2Ap79jmH+iUje65H8DIsu2K4LZpYR 2rTbw6H+fxs465+M3Tk4nQWS3ETiHCLL8VQE/CiGZj6La/bzuggWuOFyUrPTrgE1LN01g4XARQQQ9 EfurYxy+cub8EhAsyMVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOmJ-0002EA-3w; Mon, 10 Dec 2018 16:51:31 +0000 Received: from mail-eopbgr70042.outbound.protection.outlook.com ([40.107.7.42] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlQ-0001DI-9R for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 16:50:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uazf8naZk5aPwtlvmSe5ucZ8KOiXXDPWqm2M/iSonck=; b=FYS4BgjSEJgrxAwZfVAaB2tl5y8iXsAio/Huc5w/fWSDhXbgsonuGlyu8WvX0Bu/ApDZhKh+HxaPPY1aknM7ZaqKKU1DMvyIJmxJzeEfeGlIjWu7VeQT268MUloASAN/C1F6mwf2RZTenpe47wrd+0kA6FSwNLLdumg43P/1Qfs= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB2750.eurprd04.prod.outlook.com (10.175.22.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Mon, 10 Dec 2018 16:50:18 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86%11]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 16:50:18 +0000 From: Ioana Ciornei To: Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" Subject: [PATCH 2/5] soc: fsl: dpio: keep a per dpio device MC portal Thread-Topic: [PATCH 2/5] soc: fsl: dpio: keep a per dpio device MC portal Thread-Index: AQHUkKhuMhaQRRe3ZUGzxuFMu3rz6g== Date: Mon, 10 Dec 2018 16:50:17 +0000 Message-ID: <1544460591-14888-3-git-send-email-ioana.ciornei@nxp.com> References: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0145.eurprd08.prod.outlook.com (2603:10a6:800:d5::23) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB2750; 6:lgmrMLo2/fj4pnEwyE+EV2/oo5L6Lp/60xPpud2kFXlABuGoIXnHPvcu7Ulg2IY6onq2dO+9idFoq0vGUnvxzcohfy4huZru7gv33m6v0PtVrdB5LqV1YYzk+16XrwDP9O65PjnN7wxzT2PZIVQdo40IGAlDHtmcSFhif2Lzyt2ia2SFhmck4S4ycALoKFb3mIhARurVnxKjZpFOAGoJn6P9BkexGNrq5wsvre1V57oHIayoe+hiEwjz1q/JA90rH+u4XpxUyp49m5XzbOd+3qo1+1iN4IaZju9mFi8Um0vqPollo4ByHKouJsHWib6YvmAPC5QVVQYVpjq8/QpRPaPR0vpi3YzKNP5QLqEN7B4ha/3pepJAJmfJTbeR4+z2D8ReAF6nVNW4EfUOZ9gd67+BEYn85WEeMPb5a+z5rQuUwCluJB0xnaZMxroDQLmd/gtdGjsbiCLqGMmGUsYyJg==; 5:sveKB59Vo9q0lagXDJedocv8TCaV/pBNiqmH79TiLvzPfRlT4ZmRwKDVhnDLkS3L4x5PIkHxFVatrdl6Tr56P9D1IgYG+JLeRxPyRYE2f/kDSV8Qr5xhSXDWWtQlzQY31CeKPrJJFnx2Pd/Wjc4ZbvuLnVOJ+L+n3abBlgWuMnM=; 7:bRxOWLp2b6sktUr+32/fUhvY80fdRNuErn7ManTFfZDQvge6W/nH8PHibZNGulkeF28pDPyk5wxNQC0e6lcY6PS4gsxdD6xa0ZStXV/nzCxKFOSLAcfyPXibAmaXoVnbLFuPfWV82OdK5VItr8YYcg== x-ms-office365-filtering-correlation-id: 9208904b-6254-4d63-cccc-08d65ebf909a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB2750; x-ms-traffictypediagnostic: VI1PR0402MB2750: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB2750; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB2750; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(186003)(2501003)(11346002)(44832011)(53936002)(2616005)(71190400001)(476003)(2201001)(3846002)(6116002)(71200400001)(66066001)(486006)(305945005)(7736002)(86362001)(68736007)(36756003)(6436002)(81156014)(14444005)(316002)(110136005)(8936002)(14454004)(81166006)(478600001)(446003)(256004)(54906003)(25786009)(8676002)(6486002)(99286004)(76176011)(102836004)(106356001)(26005)(105586002)(386003)(2906002)(97736004)(5660300001)(6506007)(52116002)(6512007)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2750; H:VI1PR0402MB2800.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-microsoft-antispam-message-info: DFfIfij0DMBdQFJSFIRKAW90F0wWM7KUelLGoNLVqO52OdcZtTR45NL9j/NM6T8kOYWiHD5cJdxQCCR2K/+mYPq9fVMRLAs1zYf0dQyzNq2aFQqPB55Zx5fjHccFBQ/SkxbF1Hw0THAhCtHlp52PG5BFcaQO4//mfvk0NbLr2N1alBWftIjnvyUeEnOZsfa5TTPTQ1HU+bnO3rhaWRFBggXIRTF4Y18Aq6lzpRwvK+oyCdrSVtVTzhmVdIcVj9Uaa6FZ/N/gRZyP/CfE/sZ5iubyeRLroX3WWcv7i1Y8w6NWNsSMTRzPssBZjXnl62q0 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9208904b-6254-4d63-cccc-08d65ebf909a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 16:50:18.0014 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2750 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_085036_754549_D9124452 X-CRM114-Status: GOOD ( 14.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Pledge , Ioana Ciornei , Ioana Ciocoi Radulescu , Horia Geanta , Laurentiu Tudor 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 At the moment, the dpio-driver allocates an MC portal at probe time and frees it right after usage. The same thing happens on the remove path. This behavior could lead to scenarios where an MC portal is available for use at probing but not longer free on the remove path which could lead to unproper unbind of resources. Change the driver's behavior in such a way that an MC portal is allocated at probe and kept until the DPIO device is removed. This will ensure that at any time after a DPIO device was successfully probed, all its dependencies will be met. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/dpio/dpio-driver.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c index 38ee9db..5286723 100644 --- a/drivers/soc/fsl/dpio/dpio-driver.c +++ b/drivers/soc/fsl/dpio/dpio-driver.c @@ -187,7 +187,6 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) dev_dbg(dev, " receives_notifications = %d\n", desc.receives_notifications); dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle); - fsl_mc_portal_free(dpio_dev->mc_io); return 0; @@ -229,12 +228,6 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev) cpu = dpaa2_io_get_cpu(priv->io); cpumask_set_cpu(cpu, cpus_unused_mask); - err = fsl_mc_portal_allocate(dpio_dev, 0, &dpio_dev->mc_io); - if (err) { - dev_err(dev, "MC portal allocation failed\n"); - goto err_mcportal; - } - err = dpio_open(dpio_dev->mc_io, 0, dpio_dev->obj_desc.id, &dpio_dev->mc_handle); if (err) { @@ -252,7 +245,7 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev) err_open: fsl_mc_portal_free(dpio_dev->mc_io); -err_mcportal: + return err; } From patchwork Mon Dec 10 16:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 10721763 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 80AE415A6 for ; Mon, 10 Dec 2018 16:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D9D02A79B for ; Mon, 10 Dec 2018 16:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 612C42A7C4; Mon, 10 Dec 2018 16:51:53 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 EA09C2A79B for ; Mon, 10 Dec 2018 16:51:52 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bexbcutL70djxAYoXrxCvyr5vRPS7BiSQpgIn3C1Bzg=; b=HYKZ/XueCwtH68 h4YLSSPk398KE1nARrBX9u1YCWqlI4ihBZL7S7ThW9zi/NnJFfZPuehM5vvSgZ0mQwnmsdGdQBY0S uWfCFpMdH42Dp6msVHzsOLafR9GOIcOLYWYPOMq4uFYs0VM1V5BJAvE3qeHGhBNOar7Zd8IVjDrBM touzZKO9sDRrPFYiF5XDOn3ZB+Joz0AykULmbdo2BbkBpXK7I29h6TUWxJ7sDWoMFaIayvMv+Bp1Y B10r8SfwOM++55QN2rUP/S4vXABN9Ka8yy2tpJN6IVeXOBzJwrg+zfXNfNw5jUn7Snr7/q1B8Dsic 0mDsFq+zhz4GCPeLlL4Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOmY-0002TE-1Z; Mon, 10 Dec 2018 16:51:46 +0000 Received: from mail-eopbgr70042.outbound.protection.outlook.com ([40.107.7.42] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlV-0001DI-9d for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 16:50:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EkoVm4kdfVirtVH/yGa+3tlpcU6sozT1IqFzresa29Y=; b=F2ams2C860ZwJIVokdLg4xFVPrFZ3GWXurTDu3d4P/v/SUOQHBIUeJ5mWMV9bG2xvdqO65F2cJ3WY+IqW55ms1nT5+xdnCzx/9yYPow1WUlCeIffFxDTlajOoRTIlUgU0u8U7RgdENoxttxtoMF1iocPqHcwtYrHl1Bs+ZOwCVM= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB2750.eurprd04.prod.outlook.com (10.175.22.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Mon, 10 Dec 2018 16:50:18 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86%11]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 16:50:18 +0000 From: Ioana Ciornei To: Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" Subject: [PATCH 3/5] soc: fsl: dpio: store a backpointer to the device backing the dpaa2_io Thread-Topic: [PATCH 3/5] soc: fsl: dpio: store a backpointer to the device backing the dpaa2_io Thread-Index: AQHUkKhuPbioaeRTqk6l3vGVtHGdEQ== Date: Mon, 10 Dec 2018 16:50:18 +0000 Message-ID: <1544460591-14888-4-git-send-email-ioana.ciornei@nxp.com> References: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0145.eurprd08.prod.outlook.com (2603:10a6:800:d5::23) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB2750; 6:YuqWesw23NWIktvpE9yUzX9lx3Pngq7hGnLggyQCukWDy/3eTLfyi4mNtYTu1h/V5jLIRrBEPUy9J4PfnEBhbiN7FB3sJl9u/w0mR0o4S96EHUn3Ei8BTl6aIKxcg/d2cneLIoBNq/LsGGhDXRz0BJ89b01EfCKvsOtq73sxHpqMnJsKKxpnYMUNa1AKztI1baQxfBrfQFt2oOPPTlPRxxG49h9rYeGkBerEcu0+UJqoI+cYkKnWwT2dVtqNF4uPeaiGcovSyXwWHqv8kgTN8im7DhHdXNAvlDM+CWX+uCoKGG57tIO3/ghi51oDxo9wZIcFPwUps+YUwMh6Ij7TX/5+kLkoI4XhN9ePWLN0VTV1gcX1+ddyOF35erScnZmQDFID5AelGgtlIjCs8JZNAz43qQGU2qBpYymHPRGU2vVJ35areVojqdVm6oehjMfO7wQlZXqSd077juPEYipmcQ==; 5:uK6x+awDndB2QdTNvIJgtb/L5wvwt3Bpjjg3xoHNgzMZ/KrtOoYyVahPQSawgdS34Cx7NUkHAfwLSnjidWwfGwrI7K46dcvSqTdLNYh5/gt2l8n6fgQ3hh2oeYmGYKzcs98oUFr/EAKhTUm2i8K0Tu2UOCZNu6vfq6HfzJQNPDE=; 7:0lwV7v2TLoheqBtkMyixowWmCsbTWDiBi0rHtF2LOh8rJqYX5bFpO/Od/EysNTiWu/sfCUS9RLXSscyIr063e0lFsFNjyRlxYONR8P+Zjmf/azLWR+68BLtYXBCeXxhcsILb/v9r8Z2LatgBauu5bQ== x-ms-office365-filtering-correlation-id: 9a0aab9d-4f14-43e1-4b5b-08d65ebf90e9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB2750; x-ms-traffictypediagnostic: VI1PR0402MB2750: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB2750; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB2750; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(186003)(2501003)(11346002)(44832011)(53936002)(2616005)(71190400001)(476003)(2201001)(3846002)(6116002)(71200400001)(66066001)(486006)(305945005)(7736002)(86362001)(68736007)(36756003)(6436002)(81156014)(14444005)(316002)(110136005)(8936002)(14454004)(81166006)(478600001)(446003)(256004)(54906003)(25786009)(8676002)(6486002)(99286004)(76176011)(102836004)(106356001)(26005)(105586002)(386003)(2906002)(97736004)(5660300001)(6506007)(52116002)(6512007)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2750; H:VI1PR0402MB2800.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-microsoft-antispam-message-info: 84cCxDaWfNA7x3wSHCXcqE5SFohgaauoYNwpJzO49gDMi+hYQkJHxrkr5KRix/gwhGNr0X0sQSeXe2s0Qt0mndrfnI3NXTt7LqQ2AXVPT83ClMhMIYM12iGqXWRlUvsiR4CLboyzUQNDXufAwhJ7upXghODmknrCFFunZqGugmHT5y1A9G3CwmUQCP8WlkrMmuDXWU7rUL/Nxzg7odkJLQoeMC1lgstGB1PAY1D3hf+dyZa8V0u2/HWIxSUJdvwdTck53QIJtoYcvWuszL+J+qwT2y0xyr2Hi0NmGu6ClxRjBTLxF2ZGBpwyfbm6C6UR spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a0aab9d-4f14-43e1-4b5b-08d65ebf90e9 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 16:50:18.5088 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2750 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_085042_063122_591E253D X-CRM114-Status: GOOD ( 16.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Pledge , Ioana Ciornei , Ioana Ciocoi Radulescu , Horia Geanta , Laurentiu Tudor 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 Add a new field in the dpaa2_io structure to hold a backpointer to the actual DPIO device. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/dpio/dpio-driver.c | 2 +- drivers/soc/fsl/dpio/dpio-service.c | 7 ++++++- include/soc/fsl/dpaa2-io.h | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c index 5286723..2d4af32 100644 --- a/drivers/soc/fsl/dpio/dpio-driver.c +++ b/drivers/soc/fsl/dpio/dpio-driver.c @@ -176,7 +176,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) if (err) goto err_register_dpio_irq; - priv->io = dpaa2_io_create(&desc); + priv->io = dpaa2_io_create(&desc, dev); if (!priv->io) { dev_err(dev, "dpaa2_io_create failed\n"); err = -ENOMEM; diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 5583d28..87e01710 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -27,6 +27,7 @@ struct dpaa2_io { /* protect notifications list */ spinlock_t lock_notifications; struct list_head notifications; + struct device *dev; }; struct dpaa2_io_store { @@ -98,13 +99,15 @@ struct dpaa2_io *dpaa2_io_service_select(int cpu) /** * dpaa2_io_create() - create a dpaa2_io object. * @desc: the dpaa2_io descriptor + * @dev: the actual DPIO device * * Activates a "struct dpaa2_io" corresponding to the given config of an actual * DPIO object. * * Return a valid dpaa2_io object for success, or NULL for failure. */ -struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc) +struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, + struct device *dev) { struct dpaa2_io *obj = kmalloc(sizeof(*obj), GFP_KERNEL); @@ -146,6 +149,8 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc) dpio_by_cpu[desc->cpu] = obj; spin_unlock(&dpio_list_lock); + obj->dev = dev; + return obj; } diff --git a/include/soc/fsl/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h index e11eed1..5b5ba26 100644 --- a/include/soc/fsl/dpaa2-io.h +++ b/include/soc/fsl/dpaa2-io.h @@ -57,7 +57,8 @@ struct dpaa2_io_desc { u32 qman_version; }; -struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc); +struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, + struct device *dev); void dpaa2_io_down(struct dpaa2_io *d); From patchwork Mon Dec 10 16:50:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 10721757 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 C92B615A6 for ; Mon, 10 Dec 2018 16:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4EA62A797 for ; Mon, 10 Dec 2018 16:51:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A906D2A7BE; Mon, 10 Dec 2018 16:51:04 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 129492A797 for ; Mon, 10 Dec 2018 16:51:04 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hcg3lgkn3i2kPIxhc0NGF8v7sba7AYvUiQZv6fSfyCo=; b=iaI3jwGmBpg+H1 LJk014W+Y/8gGuVM/xkntfn9fNfqUdg+6XLAH/TAJplA5YCzcOEiwQQ37TX8XBKMKPBzw3mkAJfCV fj52WdNG2ucSrUMeqQSCWLT8ishb2OPSCv+5jlWm7nUZpnhdX3FT2ZadzsABquiWy1U0yofpZFv0x NCDoCKiaHHOCl1y96uplOzzR2J8onmZI1/7BibrP4E427drh8s76CmR8zn2QIjzxsK2kfFXan2pby 4qK0rBt0sLplG/oer48NUsNLufm1LRg8NpoQrOd/YpOBHo9OqVIHdqVcX8yUYpGpoaL2uZAuGUwg0 C1ZpfNEwpF0y1mJi429Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlp-0001ie-98; Mon, 10 Dec 2018 16:51:01 +0000 Received: from mail-ve1eur02on0625.outbound.protection.outlook.com ([2a01:111:f400:fe06::625] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlO-0001Dg-2J for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 16:50:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8IhNVAJZhi6ZBQEWabR5aMQ+BIUVeziK0nRpNiLlpaI=; b=rTz4lyMfFw2oAsYXsLdNz8FGxIPUO8xqHZWYxhbnGTY0Q6+Cj9G8NW3FqTszuXe/LP+/dSq8ZUwHFFG8H2XiRuTnOuUHCKfKAQNQL4suY8M7u8MPmiizP//6nVm3VF8asaoSgG/xheSPgdhXK4ntsmKpMkPJUS1cOKAbk7REvw4= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB3904.eurprd04.prod.outlook.com (52.134.17.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.19; Mon, 10 Dec 2018 16:50:19 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86%11]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 16:50:19 +0000 From: Ioana Ciornei To: Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" Subject: [PATCH 4/5] soc: fsl: dpio: add a device_link at dpaa2_io_service_register Thread-Topic: [PATCH 4/5] soc: fsl: dpio: add a device_link at dpaa2_io_service_register Thread-Index: AQHUkKhuw2zDRH3/CkaLKonxEHQ5VQ== Date: Mon, 10 Dec 2018 16:50:19 +0000 Message-ID: <1544460591-14888-5-git-send-email-ioana.ciornei@nxp.com> References: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0145.eurprd08.prod.outlook.com (2603:10a6:800:d5::23) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB3904; 6:MtDewYFj1c7dpPMgYLUBoQyJYIEs1z+5DeiPNAPzPI59/IlsqtRGvRc054Ny85FIa1K/Rw0yC3kspmoV+y/Zg5Kkl24Rj5dNCAHJMoRtmUbn8k+lrM6LUJ3wFx6z21FkVX8x9iSGaJdsLabpGI9JymbMYCFFJnulIXbYjZkNe0s+bh/KACkjo+Vx0KEMNYMIA4s1hXD0Gh5WwsmnJ/IYxu2f90sf78j4om/6bwZzFc1XFjlr8xykgUwglvEehNlSN7ExvPCR9Ti3Js3c3jL26WiUcYE7G52NFXJFfWtnLWzm1E7PFPU28D/4YC1W+TEAxaVlU9Baqq3V+ZzWj+ziQbk/7sAjb3R5ir52z9UC7nxwWdo9XgiOntbbsll5E2Ac5S0nnP/j+mqBJKhB6bWwJ15Rh/ynqyIrLtLGUSD6CFPKUJGSLI+Q3TRJPbD8AHEEo1ZJe9Td+GDTxJaWeZt3tA==; 5:JLRICbUdx73X8EvMa1KA5otfIaPA4jjdWjGNZJAYVWtn1Jc0XyULDfM2j21ryH7mbCE/uJKco+88hZucO7ahNitw1n+DH9hYroppNPNuMsIQoDi8FwvIrR8O7ghtfOjcxPesmWl7b1kivbLf8QZhHcro0w1stn/qv+0z204s5kg=; 7:8W/SgKfQZwyJaFsqSBQioGJIZhAhcKGLK4Tgu6t7PPP3bjY0rLiD1zV8MxjeMacrqRyovmuvFj13wM//givFMJolOkLoA675YjKRr8A95jtgz/U/DcwF1eXZhp/dIbYViTkaJvSINEdzAaT+dZ+qag== x-ms-office365-filtering-correlation-id: 6a5ebb7d-2ef1-4c44-0671-08d65ebf9137 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3904; x-ms-traffictypediagnostic: VI1PR0402MB3904: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB3904; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3904; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(396003)(39860400002)(136003)(199004)(189003)(6486002)(5024004)(4326008)(14444005)(44832011)(386003)(6506007)(486006)(316002)(68736007)(256004)(446003)(11346002)(52116002)(6436002)(2616005)(186003)(8676002)(8936002)(2906002)(26005)(81156014)(81166006)(97736004)(5660300001)(3846002)(478600001)(36756003)(14454004)(6116002)(2501003)(2201001)(25786009)(71190400001)(71200400001)(106356001)(105586002)(53936002)(305945005)(6512007)(76176011)(476003)(102836004)(54906003)(99286004)(7736002)(86362001)(110136005)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3904; H:VI1PR0402MB2800.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-microsoft-antispam-message-info: ELfDYjRMzhNaAhn5Ql+/6c6iTXX0mQ1tOElUdHzgYNKKXtYo5oUMb9W7wXHDtFQtUi4acOLNU+4Bx3xGx3xFIQ8StQQEOeh55/HFSATrPPbyE65gxlalJJ1GelVdvyf+DiawrtGWNaN+NxIsFZKesDng5cpx4uAh2p94Fc+gLPw1Pv72Jol0+B5nDxUc5M+N90Z1PALm9BqYFM1DdV3rFRwI/ybmmUGnV4Ya3GDFZyZCyi5pZOC1BxT71xbtxf3MzFjXAqjBphbjUhYreRcUJ+kU8T9+FI3E+7dvCZu9YkIBNBw1/VqWhciCkUUb+2gy spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a5ebb7d-2ef1-4c44-0671-08d65ebf9137 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 16:50:19.1143 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3904 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_085034_106267_96A171FD X-CRM114-Status: GOOD ( 19.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Pledge , Ioana Ciornei , Ioana Ciocoi Radulescu , Horia Geanta , Laurentiu Tudor 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 Automatically add a device link between the actual device requesting the dpaa2_io_service_register and the underlying dpaa2_io used. This link will ensure that when a DPIO device, which is indirectly used by other devices, is unbound any consumer devices will be also unbound from their drivers. For example, any DPNI, bound to the dpaa2-eth driver, which is using DPIO devices will be unbound before its supplier device. Also, add a new parameter to the dpaa2_io_service_[de]register functions to specify the requesting device (ie the consumer). Signed-off-by: Ioana Ciornei Reviewed-by: Horia Geantă Reviewed-by: Ioana Radulescu --- drivers/crypto/caam/caamalg_qi2.c | 6 +++--- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 9 +++++---- drivers/soc/fsl/dpio/dpio-service.c | 16 ++++++++++++++-- include/soc/fsl/dpaa2-io.h | 6 ++++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c index 7d8ac02..3167539 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -4371,7 +4371,7 @@ static int __cold dpaa2_dpseci_dpio_setup(struct dpaa2_caam_priv *priv) nctx->cb = dpaa2_caam_fqdan_cb; /* Register notification callbacks */ - err = dpaa2_io_service_register(NULL, nctx); + err = dpaa2_io_service_register(NULL, nctx, dev); if (unlikely(err)) { dev_dbg(dev, "No affine DPIO for cpu %d\n", cpu); nctx->cb = NULL; @@ -4404,7 +4404,7 @@ static int __cold dpaa2_dpseci_dpio_setup(struct dpaa2_caam_priv *priv) ppriv = per_cpu_ptr(priv->ppriv, cpu); if (!ppriv->nctx.cb) break; - dpaa2_io_service_deregister(NULL, &ppriv->nctx); + dpaa2_io_service_deregister(NULL, &ppriv->nctx, dev); } for_each_online_cpu(cpu) { @@ -4424,7 +4424,7 @@ static void __cold dpaa2_dpseci_dpio_free(struct dpaa2_caam_priv *priv) for_each_online_cpu(cpu) { ppriv = per_cpu_ptr(priv->ppriv, cpu); - dpaa2_io_service_deregister(NULL, &ppriv->nctx); + dpaa2_io_service_deregister(NULL, &ppriv->nctx, priv->dev); dpaa2_io_store_destroy(ppriv->store); if (++i == priv->num_pairs) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 04d5c44..e8790f9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -1570,7 +1570,7 @@ static int setup_dpio(struct dpaa2_eth_priv *priv) /* Register the new context */ channel->dpio = dpaa2_io_service_select(i); - err = dpaa2_io_service_register(channel->dpio, nctx); + err = dpaa2_io_service_register(channel->dpio, nctx, dev); if (err) { dev_dbg(dev, "No affine DPIO for cpu %d\n", i); /* If no affine DPIO for this core, there's probably @@ -1610,7 +1610,7 @@ static int setup_dpio(struct dpaa2_eth_priv *priv) return 0; err_set_cdan: - dpaa2_io_service_deregister(channel->dpio, nctx); + dpaa2_io_service_deregister(channel->dpio, nctx, dev); err_service_reg: free_channel(priv, channel); err_alloc_ch: @@ -1630,13 +1630,14 @@ static int setup_dpio(struct dpaa2_eth_priv *priv) static void free_dpio(struct dpaa2_eth_priv *priv) { - int i; + struct device *dev = priv->net_dev->dev.parent; struct dpaa2_eth_channel *ch; + int i; /* deregister CDAN notifications and free channels */ for (i = 0; i < priv->num_channels; i++) { ch = priv->channel[i]; - dpaa2_io_service_deregister(ch->dpio, &ch->nctx); + dpaa2_io_service_deregister(ch->dpio, &ch->nctx, dev); free_channel(priv, ch); } } diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 87e01710..01b24ac 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -237,6 +237,7 @@ int dpaa2_io_get_cpu(struct dpaa2_io *d) * notifications on the given DPIO service. * @d: the given DPIO service. * @ctx: the notification context. + * @dev: the device that requests the register * * The caller should make the MC command to attach a DPAA2 object to * a DPIO after this function completes successfully. In that way: @@ -251,14 +252,20 @@ int dpaa2_io_get_cpu(struct dpaa2_io *d) * Return 0 for success, or -ENODEV for failure. */ int dpaa2_io_service_register(struct dpaa2_io *d, - struct dpaa2_io_notification_ctx *ctx) + struct dpaa2_io_notification_ctx *ctx, + struct device *dev) { + struct device_link *link; unsigned long irqflags; d = service_select_by_cpu(d, ctx->desired_cpu); if (!d) return -ENODEV; + link = device_link_add(dev, d->dev, DL_FLAG_AUTOREMOVE_CONSUMER); + if (!link) + return -EINVAL; + ctx->dpio_id = d->dpio_desc.dpio_id; ctx->qman64 = (u64)(uintptr_t)ctx; ctx->dpio_private = d; @@ -279,12 +286,14 @@ int dpaa2_io_service_register(struct dpaa2_io *d, * dpaa2_io_service_deregister - The opposite of 'register'. * @service: the given DPIO service. * @ctx: the notification context. + * @dev: the device that requests to be deregistered * * This function should be called only after sending the MC command to * to detach the notification-producing device from the DPIO. */ void dpaa2_io_service_deregister(struct dpaa2_io *service, - struct dpaa2_io_notification_ctx *ctx) + struct dpaa2_io_notification_ctx *ctx, + struct device *dev) { struct dpaa2_io *d = ctx->dpio_private; unsigned long irqflags; @@ -295,6 +304,9 @@ void dpaa2_io_service_deregister(struct dpaa2_io *service, spin_lock_irqsave(&d->lock_notifications, irqflags); list_del(&ctx->node); spin_unlock_irqrestore(&d->lock_notifications, irqflags); + + if (dev) + device_link_remove(dev, d->dev); } EXPORT_SYMBOL_GPL(dpaa2_io_service_deregister); diff --git a/include/soc/fsl/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h index 5b5ba26..850e46d 100644 --- a/include/soc/fsl/dpaa2-io.h +++ b/include/soc/fsl/dpaa2-io.h @@ -94,9 +94,11 @@ struct dpaa2_io_notification_ctx { int dpaa2_io_get_cpu(struct dpaa2_io *d); int dpaa2_io_service_register(struct dpaa2_io *service, - struct dpaa2_io_notification_ctx *ctx); + struct dpaa2_io_notification_ctx *ctx, + struct device *dev); void dpaa2_io_service_deregister(struct dpaa2_io *service, - struct dpaa2_io_notification_ctx *ctx); + struct dpaa2_io_notification_ctx *ctx, + struct device *dev); int dpaa2_io_service_rearm(struct dpaa2_io *service, struct dpaa2_io_notification_ctx *ctx); From patchwork Mon Dec 10 16:50:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 10721759 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 4C73D15A6 for ; Mon, 10 Dec 2018 16:51:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 399872A79B for ; Mon, 10 Dec 2018 16:51:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D1A22A7C4; Mon, 10 Dec 2018 16:51:26 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 B34C12A79B for ; Mon, 10 Dec 2018 16:51:25 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q9BlZONbLX6pH6iBTYdhwKa3H/zhu0KG5ls20Qki2Hg=; b=AYHULFeVKIxRHq kSovaLoN+g/Ba3TuCACOcfmMX9bikJhM56dQnEWPGzHbIan+sWnm6mG4vOtmsFaAPpBn3D7udFbr+ KgQf1l7gHbo0cRpa9eYEHoJhQsAzC9DI+9hhbkoE97TF4uE5d+UfI8PAKOn4d/fROIUHobWF/cpmK 6b2W/+tXSD2oYDQd2R/z7yMz2PMFVyMk2mqRhaSDvbpaahbitfABj7XT8n7n2Sal4qkHpsy/YKPLW Kth/mXvr2xc5grkCl17s2WIu7Nj1MC9gROBGbgKTWDieHTTTlwLSvCIeL8b9GF+eqn0tXcX0sUhyR MxFC/25wCGF7K0/phFgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOm4-00020V-SP; Mon, 10 Dec 2018 16:51:16 +0000 Received: from mail-ve1eur02on0625.outbound.protection.outlook.com ([2a01:111:f400:fe06::625] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWOlQ-0001Dg-Ei for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 16:50:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Eekk/hODSmEyVFTefw+PC/EebCzi+MUBuWJqXlCBTkM=; b=Bp3WrXgbSaiJccX1BFdOSAlVGEFG4MQhJ6LZpK5+0V/CpyXg4KwSRQc5EODIkgd9UHF1HSdj0NG+U6DgPDeMaMvuzKz2WMKCXcUObosaTHBNKNa6jP6uaCcu1OX7g6g4mwssFaVtgXh9gDaLO7oOaHuK0UULF24g0+k4rwT40C8= Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com (10.172.255.18) by VI1PR0402MB3904.eurprd04.prod.outlook.com (52.134.17.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.19; Mon, 10 Dec 2018 16:50:20 +0000 Received: from VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86]) by VI1PR0402MB2800.eurprd04.prod.outlook.com ([fe80::d9a8:33a8:4241:be86%11]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 16:50:20 +0000 From: Ioana Ciornei To: Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" Subject: [PATCH 5/5] bus: fsl-mc: automatically add a device_link on fsl_mc_[portal,object]_allocate Thread-Topic: [PATCH 5/5] bus: fsl-mc: automatically add a device_link on fsl_mc_[portal,object]_allocate Thread-Index: AQHUkKhvHkf6CgsRQ0WduTjo1m5H8A== Date: Mon, 10 Dec 2018 16:50:19 +0000 Message-ID: <1544460591-14888-6-git-send-email-ioana.ciornei@nxp.com> References: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> In-Reply-To: <1544460591-14888-1-git-send-email-ioana.ciornei@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0145.eurprd08.prod.outlook.com (2603:10a6:800:d5::23) To VI1PR0402MB2800.eurprd04.prod.outlook.com (2603:10a6:800:ad::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ioana.ciornei@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB3904; 6:ybVO453he2/cOv+/69YpAvHjoqrZWhjXIpwA8iQKkI/j8+KBoms1fnMuEm53MCE5VY/m3JFpe3MxoAAs5AqhXdwSt46vGsjsG5XXnQsa0HgDHxr6A7VZqV9nKcI6lgeNexkb6ieF+R3kzQXmLA+cBS6odceW3I8ubNcaCufuYR6eR0JD/j/gFivFpZALgq7/nOH2RwFQlXVHjVMPryiAikwLMDgQXwNACDOedJqnDql7omdzg5o7LilLC1ZHE7jAntyW4RIBzT1FefL3vh5b83LTGrbbsQZgkaKgD9N4DmFdHQTpD5QhbudoYaE9PvG2FODY6K14Ni3XaEONi0kIJWrR4qMzFsnIMxxa5lrsQyx7qFeVPWIsboVzyyAsoo6bI31wg75Ij8srJwgEjgpGlWjbl/E11SO7loAEX9Op2swlBse5vkoIlxQSASDR7MJuJxVBNPGRoeQZ4+aobf1H0w==; 5:jMG4fStHCyN8I8e5m20J/5QHa4rQn0L0VaZN/BRkbepInrwMYYRYR7iyDrQ7YbPo2HLuT9QIDyHC9vE0X+xxvBGLvbDZwjxWKc82sAbXVBhhSfIBQ54T+z+NfzKhggcNzYjFTtQJQazlbqE4Qf/X2TAEi777bnZgSaXd+O0GL8o=; 7:oIQIVmbwez5dMQ7zCPI3X5pTr2G3cvjjy8HFRzDqhUI3IKVKEDZbr1cEvKtFsdhBUgTRZIj14eoiABjHu2N/nScwkE8XqMqWS2qA+U5J8qDgPAtTV9WFTpaF8OPiQiJE1pkYVdPUmatr2fW8S4X5uA== x-ms-office365-filtering-correlation-id: b3a6d845-1591-4b4f-dc1e-08d65ebf9195 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3904; x-ms-traffictypediagnostic: VI1PR0402MB3904: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB3904; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3904; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(396003)(39860400002)(136003)(199004)(189003)(6486002)(4326008)(14444005)(44832011)(386003)(6506007)(486006)(316002)(68736007)(256004)(446003)(11346002)(52116002)(6436002)(2616005)(186003)(8676002)(8936002)(2906002)(26005)(81156014)(81166006)(97736004)(5660300001)(3846002)(478600001)(36756003)(14454004)(6116002)(2501003)(2201001)(25786009)(71190400001)(71200400001)(106356001)(105586002)(53936002)(305945005)(6512007)(76176011)(476003)(102836004)(54906003)(99286004)(7736002)(86362001)(110136005)(66066001)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3904; H:VI1PR0402MB2800.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-microsoft-antispam-message-info: /wj2eVPb4Rv5/sd/8SXCfzVhp9Nn7IPB76ivDQmAJuEq3bP3njQ7tUOxC9QeIaloiVkHF0w9jAQfEmgWJEbCQzAamsBGEp6GlCQlkr4aE01Wbjpe+GvQnnY5jaQNS7IwY0GWOv1C1bsvvAsvweKPVWm6RvY6QE94vVtFu5iH3aNzCYtVqP9AsAZVFeOq7aRuaT+LwZSWuRWwZmswPiTnY4lUyvr12muWnfY/0UtfLZ/1KHGJshp2s01ZlMkiSppe4aZ9atj6gO2sfqxhwYw+j+menepRVOsR/5UB/nzglmeLPf0zrJLR/6frq7I5um8O spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3a6d845-1591-4b4f-dc1e-08d65ebf9195 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 16:50:19.7118 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3904 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_085036_709159_6F2B126E X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Pledge , Ioana Ciornei , Ioana Ciocoi Radulescu , Horia Geanta , Laurentiu Tudor 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 Allocatable devices can be acquired by drivers on the fsl-mc bus using the fsl_mc_portal_allocate or fsl_mc_object_allocate functions. Add a device link between the consumer device and the supplier device so that proper resource management is achieved. Also, adding a link between these devices ensures that a proper unbind order is respected (ie before the supplier device is unbound from its respective driver all consumer devices will be notified and unbound first). Signed-off-by: Ioana Ciornei --- drivers/bus/fsl-mc/fsl-mc-allocator.c | 11 +++++++++++ drivers/bus/fsl-mc/mc-io.c | 13 +++++++++++++ include/linux/fsl/mc.h | 1 + 3 files changed, 25 insertions(+) diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c index e906ecfe..8ad7724 100644 --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c @@ -295,6 +295,14 @@ int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev, if (!mc_adev) goto error; + mc_adev->consumer_link = device_link_add(&mc_dev->dev, + &mc_adev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER); + if (!mc_adev->consumer_link) { + error = -EINVAL; + goto error; + } + *new_mc_adev = mc_adev; return 0; error: @@ -321,6 +329,9 @@ void fsl_mc_object_free(struct fsl_mc_device *mc_adev) return; fsl_mc_resource_free(resource); + + device_link_del(mc_adev->consumer_link); + mc_adev->consumer_link = NULL; } EXPORT_SYMBOL_GPL(fsl_mc_object_free); diff --git a/drivers/bus/fsl-mc/mc-io.c b/drivers/bus/fsl-mc/mc-io.c index 7226cfc..3ae574a 100644 --- a/drivers/bus/fsl-mc/mc-io.c +++ b/drivers/bus/fsl-mc/mc-io.c @@ -209,9 +209,19 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev, if (error < 0) goto error_cleanup_resource; + dpmcp_dev->consumer_link = device_link_add(&mc_dev->dev, + &dpmcp_dev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER); + if (!dpmcp_dev->consumer_link) { + error = -EINVAL; + goto error_cleanup_mc_io; + } + *new_mc_io = mc_io; return 0; +error_cleanup_mc_io: + fsl_destroy_mc_io(mc_io); error_cleanup_resource: fsl_mc_resource_free(resource); return error; @@ -244,6 +254,9 @@ void fsl_mc_portal_free(struct fsl_mc_io *mc_io) fsl_destroy_mc_io(mc_io); fsl_mc_resource_free(resource); + + device_link_del(dpmcp_dev->consumer_link); + dpmcp_dev->consumer_link = NULL; } EXPORT_SYMBOL_GPL(fsl_mc_portal_free); diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index 9d3f668..0c4f9805 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -193,6 +193,7 @@ struct fsl_mc_device { struct resource *regions; struct fsl_mc_device_irq **irqs; struct fsl_mc_resource *resource; + struct device_link *consumer_link; }; #define to_fsl_mc_device(_dev) \