From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg KH <greg@kroah.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>,
Chunyan Zhang <zhang.chunyan@linaro.org>,
laurent.fert@intel.com, yann.fouassier@intel.com,
linux-kernel@vger.kernel.org,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [QUEUED v0 14/19] stm class: Use driver's packet callback's return value
Date: Fri, 5 Feb 2016 18:35:23 +0200 [thread overview]
Message-ID: <1454690128-21994-15-git-send-email-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <1454690128-21994-1-git-send-email-alexander.shishkin@linux.intel.com>
STM drivers provide a callback to generate/send individual STP packets;
it also tells the stm core how many bytes of payload it has consumed.
However, we would also need to use the negative space of this return
value to communicate errors that occur during the packet generation,
in which case the stm core will have to take appropriate action.
For now, we need to account for the possibility that the stm driver may
not support certain combinations of packet type/flags, in which case
it is expected to signal an error.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
drivers/hwtracing/stm/core.c | 19 ++++++++++++-------
include/linux/stm.h | 7 +++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index cdec240bd6..385db65994 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -380,8 +380,8 @@ static int stm_file_assign(struct stm_file *stmf, char *id, unsigned int width)
return ret;
}
-static void stm_write(struct stm_data *data, unsigned int master,
- unsigned int channel, const char *buf, size_t count)
+static ssize_t stm_write(struct stm_data *data, unsigned int master,
+ unsigned int channel, const char *buf, size_t count)
{
unsigned int flags = STP_PACKET_TIMESTAMPED;
const unsigned char *p = buf, nil = 0;
@@ -393,9 +393,14 @@ static void stm_write(struct stm_data *data, unsigned int master,
sz = data->packet(data, master, channel, STP_PACKET_DATA, flags,
sz, p);
flags = 0;
+
+ if (sz < 0)
+ break;
}
data->packet(data, master, channel, STP_PACKET_FLAG, 0, 0, &nil);
+
+ return pos;
}
static ssize_t stm_char_write(struct file *file, const char __user *buf,
@@ -433,8 +438,8 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
return -EFAULT;
}
- stm_write(stm->data, stmf->output.master, stmf->output.channel, kbuf,
- count);
+ count = stm_write(stm->data, stmf->output.master, stmf->output.channel,
+ kbuf, count);
kfree(kbuf);
@@ -996,9 +1001,9 @@ int stm_source_write(struct stm_source_data *data, unsigned int chan,
stm = srcu_dereference(src->link, &stm_source_srcu);
if (stm)
- stm_write(stm->data, src->output.master,
- src->output.channel + chan,
- buf, count);
+ count = stm_write(stm->data, src->output.master,
+ src->output.channel + chan,
+ buf, count);
else
count = -ENODEV;
diff --git a/include/linux/stm.h b/include/linux/stm.h
index 9d0083d364..ab8ceca4f5 100644
--- a/include/linux/stm.h
+++ b/include/linux/stm.h
@@ -67,6 +67,13 @@ struct stm_device;
* description. That is, the lowest master that can be allocated to software
* writers is @sw_start and data from this writer will appear is @sw_start
* master in the STP stream.
+ *
+ * The @packet callback should adhere to the following rules:
+ * 1) it must return the number of bytes it consumed from the payload;
+ * 2) therefore, if it sent a packet that does not have payload (like FLAG),
+ * it must return zero;
+ * 3) if it does not support the requested packet type/flag combination,
+ * it must return -ENOTSUPP.
*/
struct stm_data {
const char *name;
--
2.7.0
next prev parent reply other threads:[~2016-02-05 16:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 16:35 [QUEUED v0 00/19] stm class/intel_th: Patches in my queue Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 01/19] stm class: Hide STM-specific options if STM is disabled Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 02/19] intel_th: INTEL_TH should depend on HAS_DMA Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 03/19] stm class: Select CONFIG_SRCU Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 04/19] stm class: Fix locking in unbinding policy path Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 05/19] stm class: Fix link list locking Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 06/19] stm class: Fix an off-by-one in master array allocation Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 07/19] stm class: Prevent user-controllable allocations Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 08/19] intel_th: pci: Add Apollo Lake SOC support Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 09/19] intel_th: pci: Add Broxton " Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 10/19] stm class: Use a signed return type for stm_find_master_chan Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 11/19] intel_th: Depend on HAS_IOMEM Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 12/19] intel_th: gth: Remove commented-out code Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 13/19] intel_th: Update scratchpad bits according to enabled output activity Alexander Shishkin
2016-02-05 16:35 ` Alexander Shishkin [this message]
2016-02-05 16:35 ` [QUEUED v0 15/19] intel_th: sth: Sanitize packet callback's return values Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 16/19] stm class: Support devices with multiple instances Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 17/19] stm class: dummy_stm: Create multiple devices Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 18/19] intel_th: Set root device's drvdata early Alexander Shishkin
2016-02-05 16:35 ` [QUEUED v0 19/19] intel_th: Use real device index in the node names Alexander Shishkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454690128-21994-15-git-send-email-alexander.shishkin@linux.intel.com \
--to=alexander.shishkin@linux.intel.com \
--cc=greg@kroah.com \
--cc=laurent.fert@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=yann.fouassier@intel.com \
--cc=zhang.chunyan@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®