From patchwork Tue Jun 14 02:16:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 9174831 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 D07C360573 for ; Tue, 14 Jun 2016 02:19:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C11F328111 for ; Tue, 14 Jun 2016 02:19:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5EFF281AA; Tue, 14 Jun 2016 02:19: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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 44E5F28111 for ; Tue, 14 Jun 2016 02:19:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCdva-0001Ph-0s; Tue, 14 Jun 2016 02:18:06 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCdvW-0001LN-NI for linux-arm-kernel@lists.infradead.org; Tue, 14 Jun 2016 02:18:03 +0000 Received: by mail-pa0-x229.google.com with SMTP id hl6so51293377pac.2 for ; Mon, 13 Jun 2016 19:17:40 -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; bh=FB+Wupqm0dgFJAI8HK9K9wuvP1gFlJXBi0ieo/ETIOk=; b=D7wnr6f+xOxtZM/qyV4kZ521Ea8c9YFtaZgkVNAuabttusFZuXqc3mpSeqSfXQkJ6f SWEUkJ/KisoLmElvKHG6SMdqYn52Foxptr8W0R2o8m5tispLKnF1JscbjQlEfKUZ2Qt2 kgI5FS+OAGjqXFTCZPodkOO6SJZMCjP29Xk2E= 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; bh=FB+Wupqm0dgFJAI8HK9K9wuvP1gFlJXBi0ieo/ETIOk=; b=Q6khYnKjmhQdglvIxjCV+TYRhYYAwL0YS169KG7q1cL3vJvofQy0KFo6jShG7j/zob d/Z8UBqlFAd0N+yo4087qjpFrZI83KKymPTydGF+QE1qJWWzj6hpcWx9g++ZtWdJu9h8 G2oCA6/m8bks76cW8JDqGk2b8YzICsaZ78mut+O3E+9vzRo5NxfkuudsVBi6NJtIClpF Az/7ezMfAUBhKbdfVXm6K4urdiLQY4blMpHUI3GFtyukKE5JK5bWY0DmRY8dEfM6FaSn KLn/TW4ctbX0LE1ZUMu4Zx1DIgBpA1o4SPhSXr7+7BDPgN/fUne2TT4a/qNOszaKfkqr 0XOA== X-Gm-Message-State: ALyK8tLaApMwhEUCV6C5uwTpCQunrDMv437YwKw423VaoR4i3suPO9ut6mcRJ2ij7bnKsDh2 X-Received: by 10.66.167.168 with SMTP id zp8mr24728498pab.20.1465870660344; Mon, 13 Jun 2016 19:17:40 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id e65sm40539086pfc.94.2016.06.13.19.17.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jun 2016 19:17:39 -0700 (PDT) From: Chunyan Zhang To: mathieu.poirier@linaro.org Subject: [PATCH] coresight-stm: support mmapping channel regions with mmio_addr Date: Tue, 14 Jun 2016 10:16:55 +0800 Message-Id: <1465870615-10215-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160613_191802_806949_8661B38B X-CRM114-Status: GOOD ( 11.92 ) 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: zhang.lyra@gmail.com, Al.Grant@arm.com, 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 CoreSight STM device allows direct mapping of the channel regions to userspace for zero-copy writing. To support this ability, the STM freamwork 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 start physical address of channel region which mmap operation needs to know. Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-stm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 73be58a..4e70478 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -109,6 +109,7 @@ module_param_named( */ struct channel_space { void __iomem *base; + phys_addr_t phys; unsigned long *guaranteed; }; @@ -356,6 +357,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 +779,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 +828,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))