From patchwork Tue Oct 30 20:30:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Pledge X-Patchwork-Id: 10661501 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 8CE2913A4 for ; Tue, 30 Oct 2018 20:31:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B3DD2AAA0 for ; Tue, 30 Oct 2018 20:31:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E7B02AAC2; Tue, 30 Oct 2018 20:31:08 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 E4F352AAA0 for ; Tue, 30 Oct 2018 20:31:07 +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=yGn29Xn9RmWWtHLyPtefu6F5dGQKjvcG+yqVpJK3MNY=; b=aKQLU/NSPR1HDx qJ7CVN0+McLezEih8bwAuREhxdRnlhJp+joonViXWl9n4pmCl5aN7kglkHe8vaYo049X4IoGFArqY QaQdazYFTNR7WKxV3inzQXNln9AfNQDu3UnVez32yVQuBB1x35RZh13Nlv7QYabLcsoGeYJbBmnwC ahxN7iLJmOOol79dc5b/GeyrPS53TbnDGcBcnEDsdS6k4n0XqU305QkHll80JvJ6BRbrtO6dqu9fE dhDokeLr7LeR0lRNsxF0eJLjTXpaXE6raVDJNNaQR/L2eE/4+MDrPZtCXz5SKcp2slz09Hw1puP8a XF0v272rD+ZLLsdca4ZA==; 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 1gHafL-0007NZ-4P; Tue, 30 Oct 2018 20:31:07 +0000 Received: from mail-db5eur01on062e.outbound.protection.outlook.com ([2a01:111:f400:fe02::62e] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHaf6-00077e-Gu for linux-arm-kernel@lists.infradead.org; Tue, 30 Oct 2018 20:30:53 +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=BNI7VbNHrZYR45mvOaU4FWpC0qp3ozEtl01AmDOwS/U=; b=u6yl2iygBojwLxsmDQ3TP0TUH5A6XwEwvorLtE+K9SpQ87M+lKQ8jliKJVxmqPFD+tbPjty/ipCB5U+VTbpm2ZjOCDfGrorKfkrKAm8suJPrjCRJHrO6jf8RgMmwm9HtRwkaMHmZ3UR8spwQIYuBBZXq1FlW4YFrzr/TpCl918Q= Received: from DB6PR0402MB2727.eurprd04.prod.outlook.com (10.172.245.17) by DB6PR0402MB2920.eurprd04.prod.outlook.com (10.172.248.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.19; Tue, 30 Oct 2018 20:30:37 +0000 Received: from DB6PR0402MB2727.eurprd04.prod.outlook.com ([fe80::e012:b6c0:4c6c:c314]) by DB6PR0402MB2727.eurprd04.prod.outlook.com ([fe80::e012:b6c0:4c6c:c314%4]) with mapi id 15.20.1273.027; Tue, 30 Oct 2018 20:30:37 +0000 From: Roy Pledge To: "stuyoder@gmail.com" , Laurentiu Tudor , Leo Li , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH v1 1/2] bus: mc-bus: Add support for mapping shareable portals Thread-Topic: [PATCH v1 1/2] bus: mc-bus: Add support for mapping shareable portals Thread-Index: AQHUcI9qH+mPzbXUkkeH/d/lTd6AeA== Date: Tue, 30 Oct 2018 20:30:37 +0000 Message-ID: <1540931418-10697-2-git-send-email-roy.pledge@nxp.com> References: <1540931418-10697-1-git-send-email-roy.pledge@nxp.com> In-Reply-To: <1540931418-10697-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: BYAPR02CA0026.namprd02.prod.outlook.com (2603:10b6:a02:ee::39) To DB6PR0402MB2727.eurprd04.prod.outlook.com (2603:10a6:4:94::17) 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-microsoft-exchange-diagnostics: 1; DB6PR0402MB2920; 6:zYbms865/5iMCcKYVjUqyjR9/yvtH4fEFabmbEaZPKHMPOgCKp5yjn4FFtDmkOfeMwg3vCajdyRaMt1a0ZqQ3C/PwZjQVM9mqsgVzB9Q3h4lpwCCIuI5oj0t0GUEvEbjhg6cQ82Twt8k+0g3jUej+AZUOqoelL4f5a4EbOrkxMya4D2aVmOFCoWx3sOrMEEoMZFtGsT2Hy8IH3/O5IY7Q5Zs7sGE1eG3dRlh7KKElYUJFWxPqXLZ3NMtZbE6dLQGcaZ9utS+z9Xt6qkLq/UUXJ2amOq08yG1R8b97Jx+uKtFEpGPRrZpUd3lfEetY8Ha37XQzBWbdQqK5puUcxJ26lEDrtHU/w+pgRt7BZt2I47b8DK5+1NfE4Np11pMxejexkFB0OKtOnM+WwkFV19C5Nl8q0kTXLg/sPJ0onorntBBntC/0m4jhau8V8BW8w0I1HYqus6FdeuWDevqUApw6g==; 5:qKCL3J2ECDh+x9jYrpzHeK1JwUpHdG7KY1vdlLX8mgDsRFxQK4nWzj8Cr61z/8QronQazKdVEap31d9e1X5Ne6P5hZ1SNySvq4QQG+C4ya3kT/DI4TtQ4G27eHNFOqI7Tu6lBQ9kDdtjyC6cbuFVg6sZlX/u1tjf6OIp6eVHpks=; 7:cPvL6pGyKA/17hGq2KO81CQfwtUNS+heStpTc1wLNlBVwTrjHpYM2qMMIA64B8oSIZ5v0FxYMjQsdvJ4Sw53yK0e3h1OQsoYsobmFFRc83eCkCgzESx7DOI0JHq4TAmBpE1gQR4OyCPnWODcP1upww== x-ms-office365-filtering-correlation-id: 788f035f-3c5e-4c13-35e5-08d63ea68cf9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB6PR0402MB2920; x-ms-traffictypediagnostic: DB6PR0402MB2920: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227817650892897)(275809806118684)(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:DB6PR0402MB2920; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0402MB2920; x-forefront-prvs: 08417837C5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(39860400002)(396003)(346002)(199004)(189003)(43066004)(7736002)(81156014)(8676002)(99286004)(3450700001)(6486002)(81166006)(2501003)(76176011)(68736007)(6436002)(97736004)(8936002)(2900100001)(102836004)(305945005)(14454004)(71190400001)(105586002)(53936002)(478600001)(6512007)(52116002)(5250100002)(6506007)(386003)(36756003)(106356001)(71200400001)(186003)(5660300001)(3846002)(50226002)(2616005)(11346002)(446003)(256004)(54906003)(486006)(14444005)(476003)(110136005)(86362001)(44832011)(66066001)(25786009)(575784001)(316002)(4326008)(26005)(2201001)(39060400002)(2906002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0402MB2920; H:DB6PR0402MB2727.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: 9fcp3n3ceJA//8J6BNBFmZM/sEolSRAwGrVk2UZCs6uIsq+b81cDJ9pAnTRXcTxBwShFusR+YNWdDFqCK//TY/2+Hw1xZYjkNG8o9tkgtwH2pK9E99VRwKOdzY7qAUeEsWLSsLdV/lZFqaf52EgVM1VOLlfQkGVP/soX/T9fH8gHd1cSK6ANInzCVndSVLAH7AuxbvHkYw0d4b61RthVWKFa4Si0rOd0mO7OcPgzKPEg037VCAkPSFd6p2G6z+P0sg0Heh9vveUMf/Vgyg2b3xVJsernRvmPeDVvSTjFuZQZZVbfu7w2kedtOuehn2Y1OZYljB5ElbRu8hlQeJqBSF/vgkE2d1iwsBvy755T7tg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 788f035f-3c5e-4c13-35e5-08d63ea68cf9 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2018 20:30:37.4613 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0402MB2920 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181030_133052_561903_732551C4 X-CRM114-Status: GOOD ( 19.31 ) 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: , Reply-To: Roy Pledge Cc: Roy Pledge , Youri Querry 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 Starting with v5 of NXP QBMan devices the hardware supports using regular cacheable/shareable memory as the backing store for the portals. This patch adds support for the new portal mode by switching to use the DPRC get object region v2 command which returns both a base address and offset for the portal memory. The new portal region is identified as shareable through the addition of a new flag. Signed-off-by: Roy Pledge --- drivers/bus/fsl-mc/dprc.c | 3 ++- drivers/bus/fsl-mc/fsl-mc-bus.c | 14 ++++++++++++-- drivers/bus/fsl-mc/fsl-mc-private.h | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c index 1c3f621..bde856d 100644 --- a/drivers/bus/fsl-mc/dprc.c +++ b/drivers/bus/fsl-mc/dprc.c @@ -461,8 +461,9 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io, /* retrieve response parameters */ rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params; - region_desc->base_offset = le64_to_cpu(rsp_params->base_addr); + region_desc->base_offset = le64_to_cpu(rsp_params->base_offset); region_desc->size = le32_to_cpu(rsp_params->size); + region_desc->base_address = le64_to_cpu(rsp_params->base_addr); return 0; } diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index f0404c6..25ad422 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -487,10 +487,18 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, "dprc_get_obj_region() failed: %d\n", error); goto error_cleanup_regions; } - - error = translate_mc_addr(mc_dev, mc_region_type, + /* Older MC only returned region offset and no base address + * If base address is in the region_desc use it otherwise + * revert to old mechanism + */ + if (region_desc.base_address) + regions[i].start = region_desc.base_address + + region_desc.base_offset; + else + error = translate_mc_addr(mc_dev, mc_region_type, region_desc.base_offset, ®ions[i].start); + if (error < 0) { dev_err(parent_dev, "Invalid MC offset: %#x (for %s.%d\'s region %d)\n", @@ -504,6 +512,8 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, regions[i].flags = IORESOURCE_IO; if (region_desc.flags & DPRC_REGION_CACHEABLE) regions[i].flags |= IORESOURCE_CACHEABLE; + if (region_desc.flags & DPRC_REGION_SHAREABLE) + regions[i].flags |= IORESOURCE_MEM; } mc_dev->regions = regions; diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h b/drivers/bus/fsl-mc/fsl-mc-private.h index ea11b4f..28e40d1 100644 --- a/drivers/bus/fsl-mc/fsl-mc-private.h +++ b/drivers/bus/fsl-mc/fsl-mc-private.h @@ -79,9 +79,11 @@ int dpmcp_reset(struct fsl_mc_io *mc_io, /* DPRC command versioning */ #define DPRC_CMD_BASE_VERSION 1 +#define DPRC_CMD_2ND_VERSION 2 #define DPRC_CMD_ID_OFFSET 4 #define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION) +#define DPRC_CMD_V2(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION) /* DPRC command IDs */ #define DPRC_CMDID_CLOSE DPRC_CMD(0x800) @@ -99,7 +101,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io, #define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830) #define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159) #define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) -#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) +#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD_V2(0x15E) #define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F) struct dprc_cmd_open { @@ -199,9 +201,15 @@ struct dprc_rsp_get_obj_region { /* response word 0 */ __le64 pad; /* response word 1 */ - __le64 base_addr; + __le64 base_offset; /* response word 2 */ __le32 size; + u8 pad2[3]; + /* response word 3 */ + __le32 flags; + __le32 pad3; + /* response word 4 */ + __le64 base_addr; }; struct dprc_cmd_set_obj_irq { @@ -334,6 +342,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io, /* Region flags */ /* Cacheable - Indicates that region should be mapped as cacheable */ #define DPRC_REGION_CACHEABLE 0x00000001 +#define DPRC_REGION_SHAREABLE 0x00000002 /** * enum dprc_region_type - Region type @@ -342,7 +351,8 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io, */ enum dprc_region_type { DPRC_REGION_TYPE_MC_PORTAL, - DPRC_REGION_TYPE_QBMAN_PORTAL + DPRC_REGION_TYPE_QBMAN_PORTAL, + DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL }; /** @@ -360,6 +370,7 @@ struct dprc_region_desc { u32 size; u32 flags; enum dprc_region_type type; + u64 base_address; }; int dprc_get_obj_region(struct fsl_mc_io *mc_io,