From patchwork Wed Nov 2 18:00:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 9409553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDE65601C2 for ; Wed, 2 Nov 2016 17:02:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD5D92A492 for ; Wed, 2 Nov 2016 17:02:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A16632A49C; Wed, 2 Nov 2016 17:02:05 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 631EA2A492 for ; Wed, 2 Nov 2016 17:02:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1ytj-0002aH-GZ; Wed, 02 Nov 2016 17:00:23 +0000 Received: from mail-ve1eur01on0088.outbound.protection.outlook.com ([104.47.1.88] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1yte-0001k3-HF for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2016 17:00:19 +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; bh=w50bQrXOrK8zVH73lWVUItZ2fT2ILJETJUReMAE/kpw=; b=L0vrtMmgZN4p9Dagpk6AKWgoiryOHOPNpdeVDAfsISAV5JL3jBHxG677pX+CXQMFQlBDyvTUekQqQCHeZT0wFll5gsII/w4UdH0hHewFhfFLKBSs3R9KKQ/1V19Rhebka4M4dCVkDvTDBDANzS1IEOl2WPz9+quMxq8sGHYK4Tk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=frank.li@nxp.com; Received: from lizhi-Precision-Tower-5810.am.freescale.net (192.88.168.49) by DB4PR04MB265.eurprd04.prod.outlook.com (10.242.231.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Wed, 2 Nov 2016 16:59:46 +0000 From: Frank Li To: , Subject: [PATCH v2 1/2] ARM: imx: mmdc perf function support i.MX6QP Date: Wed, 2 Nov 2016 13:00:03 -0500 Message-ID: <1478109604-18323-1-git-send-email-Frank.Li@nxp.com> X-Mailer: git-send-email 2.5.2 MIME-Version: 1.0 X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: SN1PR12CA0002.namprd12.prod.outlook.com (10.162.96.140) To DB4PR04MB265.eurprd04.prod.outlook.com (10.242.231.20) X-MS-Office365-Filtering-Correlation-Id: b6764b01-d8f3-4c98-850d-08d40341aa99 X-Microsoft-Exchange-Diagnostics: 1; DB4PR04MB265; 2:ukVF8sTPXhCdtsP7hlJXJ9pFrk69QTlFVuELepYnW2gi44iCkOg453hPiiRWwRmX+ramVFCYZCrdutGWuUQt5KQ4c1j5PCai5UCQGqZ82rpTx/ize9qyRjWbebdiRoo4K2ZLnZjqrb1o3R4lC7iIiHx+kPTXhLXTnT6qlnMM1LdzedEdpf4i5G3V7Au8kw5ZJkf5KfGv4svZLxHP3Jgqdw==; 3:pJRTnx7an+La0o/ELuN5h36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iHkVXPv51JAKemUrdpFquwV6bngpGGcy2OoGnLiTZDnt/OTZ45lJlcpEA2w4i8PSnxoyNzuAxDOvfRp3qPz9JAtUCX0zNURoU4M8kDncYSw3HnrW19g8PjHpT1F1f/3bcu5XHUbv78p6K3UVlGx1tPM9nuJJzhf2xH8fg1M3F5RO5FJhEclwM3ZuSvdBrz5qEmAsZhQNk5GwAbGpNiU8eA==; 20:AsBJZZl09UX3H1Xwpr4RGZVWG3zx2skxdfciXB8l/W7tXr5hx6RpTXPF3nSwoKqtytQ/mDUefj2/w1pyz+8WzesP32gfiLTj28oPX+H2G4HQPXMcshXrydQQtC9kjeYPqnosyxwXHgcXjkgg7u/21i10lCqoP8VAxqmt52ybbCthdtrn7FCzALLKOM3ndzfeAv/eUq/hLAORn/c8Yrl9M7SHWHH2a+p0UsdKwFn7bylMAipBlCe5bGrM8LvDXSN2j24236rHMLAa7JWwfVlmrAKWc+ovKohbkZdKPbLuqevvOdnr/gHW0gNgbhQYuUawjbbgJ/rwlgEzbnFrpW6aI7kKBsTSVQ8OV3Z8y9gUo5vSKByrNaNH9ot1Wys/PnfBxPG3UIgTJoqOyNJAkOjOejyiJj96a/16OuNnXTwedmB+JGT0kWYGuR+omijBfEqRJc6IuduJ0m4JOLQhOULuaCXExHe5i0Z+jXtlG1CaFtke9JYoip7CMV31ji4RkWel X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(6045074)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6046074)(6072074); SRVR:DB4PR04MB265; BCL:0; PCL:0; RULEID:; SRVR:DB4PR04MB265; X-Microsoft-Exchange-Diagnostics: 1; DB4PR04MB265; 4:kQUnpK+ZkM2mNrka2sxmVi5kN72yKGNnhR2yyDRokssohiiiAeQ98oZ6CMjOmS6ak65aFdNWKjBsfgdgKFtMA43XvAqtvLYhqplRQkovTKKdedg8kUb6wB7FYJhyA86c3OLMWPkuj1SOliUChhsZTS9RRt81GfYtl10gtqcDSgE3vCcW9kcReKWYQzQTaTQN9uT4Z09R5CneutkifD3izcHOl/UaLvzmi0NV57syTBKSaPUd4w19upDJl9aO+CrfauH1EuzqMgPmQ8ia/d9IIxm/hyh+WWc6+lq7p2KercnQU86ys/hx2rbxwNvGbDAYvF7itJF+88DDPh7PoVAwnmiBITqJNZ8cHIm3hIfMeOf19/pUxKEWRPzjHUnNrYl2xePj10OSuoATQBfQN38LoULzMxvbzdoP/fQXn913pSWBtpq5+LGH9FcBLx4JYvDKfE0QG+uRIigyjXAScUSVunMpoNiAgQChEBwxLjeg8kQy6pG8QYpemqHIoQToJSqNIvUXL9ogrW2MsXkiTQzdkg== X-Forefront-PRVS: 0114FF88F6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(8676002)(50226002)(106356001)(19580395003)(4326007)(77096005)(19580405001)(5660300001)(50986999)(42186005)(2906002)(92566002)(189998001)(3846002)(5003940100001)(6116002)(5001770100001)(586003)(66066001)(47776003)(48376002)(50466002)(97736004)(101416001)(229853001)(6666003)(7846002)(86362001)(305945005)(81156014)(81166006)(7736002)(68736007)(36756003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR04MB265; H:lizhi-Precision-Tower-5810.am.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB4PR04MB265; 23:5ZZzJUn+cRasdUEBp2dXe28vQRD+5GwJSKWH4HEJDq?= =?us-ascii?Q?lBhwzDiJRFUqVwQHXD4ZELpLuOUE7HKPNhKjy3Mdo8qHBA6+qZfVUIROP4hE?= =?us-ascii?Q?bI40R1ffgo1Eh3kHTpv3fnEfDsQzifJC7eVz00jaL1CDvFckRxXewJ7kTJyD?= =?us-ascii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ycDaOQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB4PR04MB265; 6:K/5jzdMnw0UBAorzfMYlV73sWwrH4DiQtMtMNkrWV2gp1RZ1aqyR3yajiEhWLjEfNxKwTjsyXP1RyfZVvpumNDaCuxc2MqZZoNU5D+SG/pJRDUhaZHhm/peoGyDKOZqgwsKEtyyKaKQI/wKoItCwk7JEMewDGXv5BAf2cOmAlZHECF3liwA/oJz98xfRI443SbFKmZfcvH2iWgl6TnOff+la/768ilT0+/+rX1rDBq9xPj+Hui8/nqqHcT6YDLwQP6FjVpi1NmudcRFs7zI18ABd3WXr8lKqPaq+eXbEb9iju8J+d6kPOb8e7lTNrp2T307OdYFKd6jInzKbCN+bLhPl6SU9XZYLklvTWZla3buDkQphoOg2HSgxLf2uTadw; 5:mp1RuARhKMoIXE1qwbWmgLVAEGNUcV0nIDiLvRpQkI2UC7E2cWQAzUgopl4t+Cl/CaPbDVblPjjEHR7ByWm6cti3cuvahEXybr3o172+nXgz6Ti0BLx1zFGgxyR+T9xcKnUTVLkUJBp2RKUGRxmCcg==; 24:pCKBHx4C9Ozofes5v7eabGV6VHFF420unJ7weyjmoS30auyUFdpA+HGYQLzPPibv510Pv/yVyh5DaLUjbxoAfuGyoRrTsGO8a/qQkGsKpGM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB4PR04MB265; 7:R2o+qBvnCuvW1oFQSlVplZOzGUkvCO4oDGeatUGpHUhxJBXF3Fm3adf3DP8txDUUVLE2OPEtfADMY48VtZ9NGEsKlPoonscZYhtwNZHYXuqiMw0xO7/u6MzgJLjl2jH97ZrOOFOoYmObvi8SVRczWB1zZqkOJQ6Xcnj+2kIOw5zroniQ0ERZ6RUUL/Yv9PG5a5ApgUZGm5WTGQ6aEnGgvBGaGpMeJ0cklKfmZcb7ZHrtPIhaBxxKy15r9K83MhZoFJzFPNnUZfJlyDPp4c7d0y9EVXHPo52zXqlYkHtP9xOTLderutOU7kVKUYYhHJyyVrbHlECnb+uICma1OrlXzlmAtWkQ/KxNAzETCn6olgc= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2016 16:59:46.3310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR04MB265 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161102_100018_974331_2DEEA14F X-CRM114-Status: GOOD ( 11.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, peterz@infradead.org, Frank Li , linux-kernel@vger.kernel.org, acme@kernel.org, alexander.shishkin@linux.intel.com, mingo@redhat.com, lznuaa@gmail.com, linux-arm-kernel@lists.infradead.org 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 i.MX6QP added new reigster bit PROFILE_SEL in MADPCR0. need set it at perf start. Signed-off-by: Frank Li --- V1 to V2: remove fsl_mmdc_devtype arch/arm/mach-imx/mmdc.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c index d82d14c..032cbe0 100644 --- a/arch/arm/mach-imx/mmdc.c +++ b/arch/arm/mach-imx/mmdc.c @@ -44,6 +44,7 @@ #define DBG_RST 0x2 #define PRF_FRZ 0x4 #define CYC_OVF 0x8 +#define PROFILE_SEL 0x10 #define MMDC_MADPCR0 0x410 #define MMDC_MADPSR0 0x418 @@ -55,10 +56,29 @@ #define MMDC_NUM_COUNTERS 6 +#define FSL_MMDC_QUIRK_PROFILE_SEL 0x1 + #define to_mmdc_pmu(p) container_of(p, struct mmdc_pmu, pmu) static int ddr_type; +struct fsl_mmdc_devtype_data { + int driver_data; +}; + +static struct fsl_mmdc_devtype_data imx6q_data = { +}; + +static struct fsl_mmdc_devtype_data imx6qp_data = { + .driver_data = FSL_MMDC_QUIRK_PROFILE_SEL, +}; + +static const struct of_device_id imx_mmdc_dt_ids[] = { + { .compatible = "fsl,imx6q-mmdc", .data = (void *)&imx6q_data}, + { .compatible = "fsl,imx6qp-mmdc", .data = (void *)&imx6qp_data}, + { /* sentinel */ } +}; + #ifdef CONFIG_PERF_EVENTS static DEFINE_IDA(mmdc_ida); @@ -83,6 +103,7 @@ struct mmdc_pmu { struct device *dev; struct perf_event *mmdc_events[MMDC_NUM_COUNTERS]; struct hlist_node node; + struct fsl_mmdc_devtype_data *devtype_data; }; /* @@ -307,6 +328,7 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags) struct mmdc_pmu *pmu_mmdc = to_mmdc_pmu(event->pmu); struct hw_perf_event *hwc = &event->hw; void __iomem *mmdc_base, *reg; + int val; mmdc_base = pmu_mmdc->mmdc_base; reg = mmdc_base + MMDC_MADPCR0; @@ -321,7 +343,12 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags) local64_set(&hwc->prev_count, 0); writel(DBG_RST, reg); - writel(DBG_EN, reg); + + val = DBG_EN; + if (pmu_mmdc->devtype_data->driver_data & FSL_MMDC_QUIRK_PROFILE_SEL) + val |= PROFILE_SEL; + + writel(val, reg); } static int mmdc_pmu_event_add(struct perf_event *event, int flags) @@ -436,6 +463,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b char *name; int mmdc_num; int ret; + const struct of_device_id *of_id = + of_match_device(imx_mmdc_dt_ids, &pdev->dev); pmu_mmdc = kzalloc(sizeof(*pmu_mmdc), GFP_KERNEL); if (!pmu_mmdc) { @@ -450,6 +479,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "mmdc%d", mmdc_num); + pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data; + hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler; @@ -524,11 +555,6 @@ int imx_mmdc_get_ddr_type(void) return ddr_type; } -static const struct of_device_id imx_mmdc_dt_ids[] = { - { .compatible = "fsl,imx6q-mmdc", }, - { /* sentinel */ } -}; - static struct platform_driver imx_mmdc_driver = { .driver = { .name = "imx-mmdc",