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: 69957 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1825445qgf; Mon, 13 Jun 2016 19:17:45 -0700 (PDT) X-Received: by 10.98.158.206 with SMTP id f75mr787259pfk.164.1465870665095; Mon, 13 Jun 2016 19:17:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xs2si21164424pab.43.2016.06.13.19.17.44; Mon, 13 Jun 2016 19:17:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933218AbcFNCRn (ORCPT + 30 others); Mon, 13 Jun 2016 22:17:43 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:32928 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932916AbcFNCRl (ORCPT ); Mon, 13 Jun 2016 22:17:41 -0400 Received: by mail-pa0-f42.google.com with SMTP id b13so28910247pat.0 for ; Mon, 13 Jun 2016 19:17:41 -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=f+mgoasCajIt/ueAVFsZN5570ldmFnRh7yexep99TfiJ965/NhSpSZbMktvE/kQt6D kHxUATMUeggr3fS9pygT67v3zACz+PC07OZlQ+oUiK3FRZmv9CNLP+XNrOzij/e8Dlov tOjC304OvE249pJD0XtMQeUO6X2tusb4KNhEePGHRIgMTvuE/jG1OgizOCxt092luHbi n1v1llzK5ZauyFdN3fYtJ2Z8IdQLG5SrAd9CVy9PzQjpo/hmghagH/l13vNmNC6ma60S pIaYhv3ZEG+O7E+Ppeztgtn0nPAR9HZk9+dD/IOGb0vpZX536ycy7wgs/sYTPq3DrQ/M QeSA== X-Gm-Message-State: ALyK8tIM2NvttkaC4ovwkq7Bzt6WOeKqu4QS4SGcTnT8ilSLDT0eBNfH7FCS/HEixfj/EnkS 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 Cc: zhang.lyra@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Al.Grant@arm.com 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 1.9.1 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))