From patchwork Thu Aug 25 21:18:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9299963 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 005F5607F0 for ; Thu, 25 Aug 2016 21:21:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E564D293DF for ; Thu, 25 Aug 2016 21:21:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D982F293E1; Thu, 25 Aug 2016 21:21:55 +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=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 3EEF9293DF for ; Thu, 25 Aug 2016 21:21:55 +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 1bd24M-0006k5-8c; Thu, 25 Aug 2016 21:20:14 +0000 Received: from mail-it0-x22c.google.com ([2607:f8b0:4001:c0b::22c]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd23t-0006JR-RL for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2016 21:19:47 +0000 Received: by mail-it0-x22c.google.com with SMTP id n128so113428871ith.1 for ; Thu, 25 Aug 2016 14:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=szxnQQzmUfqEn71KEP8krUsSMQGOc2xgLbEUEoS8zug=; b=XIi7/zKFN8es67FdObQjPm+sZqo0LGMc4t2JuT3hmjuIrphtPIME+yJGt2P2vnrCeR fxkh2FoQOu4oCHOq3pCyrP8CezLM6UqaGb62nxG5nX85xlo39vIYTeiCHh8HugZm8Cgm 8/nOl2+/2pNWUZCPd1B+IYfocfbkhaEjm1G8s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=szxnQQzmUfqEn71KEP8krUsSMQGOc2xgLbEUEoS8zug=; b=luYaBdXBROvCV4o3WwSd1a/JPGnE3QiB1iccQE0h1woAMkgVH5lsouHC10QQtdnm15 TXq/cMnmIeQEjdy43jq4VtTLmZE2fxfhxYgcrthfRgweUU3cyhHddofkghhrWMjhE/fw If9YeeaSbrPLzqvnC8Ccysl2HAZy3NXCjZ8LEOzZgqr/sZ1DLHiBdohdaCCPIrwJBbzg usipJfgh9weI+lCN/ckfPBnPhhRKgRecV3dCcYBUl0jqkRQw1cDMB1d8uze98R/QYFYT HDEHsW109sI6SnPqLc0tQ2wXgXCoiS5/rDoJYgX1OeLn2R6vZWgAO+cTaxK5cLYR8VhJ oxUg== X-Gm-Message-State: AEkoouu1Tqoe6dzyf0KGfPCFhI3WvNEHG8h7KAQBvZQ4qAsX2OhQb+Q+90z1d1+MTkDd3sim X-Received: by 10.107.20.206 with SMTP id 197mr14096942iou.103.1472159965717; Thu, 25 Aug 2016 14:19:25 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o5sm14506120ith.20.2016.08.25.14.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 14:19:25 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 02/28] coresight-stm: support mmapping channel regions with mmio_addr Date: Thu, 25 Aug 2016 15:18:52 -0600 Message-Id: <1472159958-5981-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472159958-5981-1-git-send-email-mathieu.poirier@linaro.org> References: <1472159958-5981-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160825_141946_011645_CCA740B5 X-CRM114-Status: GOOD ( 12.70 ) 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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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: Chunyan Zhang CoreSight STM device allows direct mapping of the channel regions to userspace for zero-copy writing. To support this ability, the STM framework has provided a hook 'mmio_addr', this patch just implemented this hook for CoreSight STM. This patch also added an item into 'channel_space' to save the physical base address of channel region which mmap operation needs to know. Signed-off-by: Chunyan Zhang Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-stm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 73be58a11e4f..482c8bb27f87 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -105,10 +105,12 @@ module_param_named( /** * struct channel_space - central management entity for extended ports * @base: memory mapped base address where channels start. + * @phys: physical base address of channel region. * @guaraneed: is the channel delivery guaranteed. */ struct channel_space { void __iomem *base; + phys_addr_t phys; unsigned long *guaranteed; }; @@ -356,6 +358,23 @@ static void stm_generic_unlink(struct stm_data *stm_data, stm_disable(drvdata->csdev); } +static phys_addr_t +stm_mmio_addr(struct stm_data *stm_data, unsigned int master, + unsigned int channel, unsigned int nr_chans) +{ + struct stm_drvdata *drvdata = container_of(stm_data, + struct stm_drvdata, stm); + phys_addr_t addr; + + addr = drvdata->chs.phys + channel * BYTES_PER_CHANNEL; + + if (offset_in_page(addr) || + offset_in_page(nr_chans * BYTES_PER_CHANNEL)) + return 0; + + return addr; +} + static long stm_generic_set_options(struct stm_data *stm_data, unsigned int master, unsigned int channel, @@ -761,7 +780,9 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata) drvdata->stm.sw_end = 1; drvdata->stm.hw_override = true; drvdata->stm.sw_nchannels = drvdata->numsp; + drvdata->stm.sw_mmiosz = BYTES_PER_CHANNEL; drvdata->stm.packet = stm_generic_packet; + drvdata->stm.mmio_addr = stm_mmio_addr; drvdata->stm.link = stm_generic_link; drvdata->stm.unlink = stm_generic_unlink; drvdata->stm.set_options = stm_generic_set_options; @@ -808,6 +829,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) ret = stm_get_resource_byname(np, "stm-stimulus-base", &ch_res); if (ret) return ret; + drvdata->chs.phys = ch_res.start; base = devm_ioremap_resource(dev, &ch_res); if (IS_ERR(base))