public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [QUEUED v20180920 05/16] stm class: Add a helper for writing data packets
Date: Thu, 27 Sep 2018 11:07:48 -0600	[thread overview]
Message-ID: <20180927170748.GC7481@xps15> (raw)
In-Reply-To: <20180920124553.56978-6-alexander.shishkin@linux.intel.com>

On Thu, Sep 20, 2018 at 03:45:42PM +0300, Alexander Shishkin wrote:
> Add a helper to write a sequence of bytes as STP data packets. This
> is used by protocol drivers to output their metadata, as well as the
> actual data payload.
> 
> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> ---
>  drivers/hwtracing/stm/core.c | 50 ++++++++++++++++++++++++++----------
>  drivers/hwtracing/stm/stm.h  |  3 +++
>  2 files changed, 40 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index c869a30661ac..9ed2f06deb47 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -564,27 +564,51 @@ stm_assign_first_policy(struct stm_device *stm, struct stm_output *output,
>  	return err;
>  }
>  
> -static ssize_t notrace stm_write(struct stm_data *data, unsigned int master,
> -			  unsigned int channel, const char *buf, size_t count)
> +/**
> + * stm_data_write() - send the given payload as data packets
> + * @data:	stm driver's data
> + * @m:		STP master
> + * @c:		STP channel
> + * @ts_first:	timestamp the first packet
> + * @buf:	data payload buffer
> + * @count:	data payload size
> + */
> +ssize_t notrace stm_data_write(struct stm_data *data, unsigned int m,
> +			       unsigned int c, bool ts_first, const void *buf,
> +			       size_t count)
>  {
> -	unsigned int flags = STP_PACKET_TIMESTAMPED;
> -	const unsigned char *p = buf, nil = 0;
> -	size_t pos;
> +	unsigned int flags = ts_first ? STP_PACKET_TIMESTAMPED : 0;
>  	ssize_t sz;
> +	size_t pos;
>  
> -	for (pos = 0, p = buf; count > pos; pos += sz, p += sz) {
> +	for (pos = 0, sz = 0; pos < count; pos += sz) {
>  		sz = min_t(unsigned int, count - pos, 8);
> -		sz = data->packet(data, master, channel, STP_PACKET_DATA, flags,
> -				  sz, p);
> -		flags = 0;
> -
> -		if (sz < 0)
> +		sz = data->packet(data, m, c, STP_PACKET_DATA, flags, sz,
> +				  &((u8 *)buf)[pos]);
> +		if (sz <= 0)
>  			break;
> +
> +		if (ts_first) {
> +			flags = 0;
> +			ts_first = false;
> +		}
>  	}
>  
> -	data->packet(data, master, channel, STP_PACKET_FLAG, 0, 0, &nil);
> +	return sz < 0 ? sz : pos;
> +}
> +EXPORT_SYMBOL_GPL(stm_data_write);
> +
> +static ssize_t notrace stm_write(struct stm_data *data, unsigned int master,
> +			  unsigned int channel, const char *buf, size_t count)
> +{
> +	ssize_t sz;
> +
> +	sz = stm_data_write(data, master, channel, true, buf, count);
> +	if (sz > 0)
> +		data->packet(data, master, channel, STP_PACKET_FLAG, 0, 0,
> +			     buf);

The original code the payload of a flag packet was '0' while in this patch
changes it to be anything.  Some external tooling could be very confused.

>  
> -	return pos;
> +	return sz;
>  }
>  
>  static ssize_t stm_char_write(struct file *file, const char __user *buf,
> diff --git a/drivers/hwtracing/stm/stm.h b/drivers/hwtracing/stm/stm.h
> index 921ebd9fd3bd..753d83acb7ae 100644
> --- a/drivers/hwtracing/stm/stm.h
> +++ b/drivers/hwtracing/stm/stm.h
> @@ -111,5 +111,8 @@ int stm_lookup_protocol(const char *name,
>  			const struct stm_protocol_driver **pdrv,
>  			const struct config_item_type **type);
>  void stm_put_protocol(const struct stm_protocol_driver *pdrv);
> +ssize_t stm_data_write(struct stm_data *data, unsigned int m,
> +		       unsigned int c, bool ts_first, const void *buf,
> +		       size_t count);
>  
>  #endif /* _STM_STM_H_ */
> -- 
> 2.18.0
> 

  reply	other threads:[~2018-09-27 17:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 12:45 [QUEUED v20180920 00/16] stm class/intel_th: Queued updates for v4.20 Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 01/16] stm class: Rework policy node fallback Alexander Shishkin
2018-09-27 16:31   ` Mathieu Poirier
2018-09-20 12:45 ` [QUEUED v20180920 02/16] stm class: Clarify configfs root type/operations names Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 03/16] stm class: Clean up stp_configfs_init Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 04/16] stm class: Introduce framing protocol drivers Alexander Shishkin
2018-09-27 16:46   ` Mathieu Poirier
2018-10-03 13:03     ` Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 05/16] stm class: Add a helper for writing data packets Alexander Shishkin
2018-09-27 17:07   ` Mathieu Poirier [this message]
2018-10-03 12:58     ` Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 06/16] stm class: Factor out default framing protocol Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 07/16] stm class: Switch over to the protocol driver Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 08/16] stm class: Add MIPI SyS-T protocol support Alexander Shishkin
2018-09-27 17:08   ` Mathieu Poirier
2018-09-20 12:45 ` [QUEUED v20180920 09/16] stm class: p_sys-t: Add support for CLOCKSYNC packets Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 10/16] stm class: p_sys-t: Document the configfs interface Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 11/16] stm class: Document the MIPI SyS-T protocol usage Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 12/16] intel_th: SPDX-ify the documentation Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 13/16] stm class: " Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 14/16] stm class: heartbeat: Fix whitespace Alexander Shishkin
2018-09-20 12:45 ` [QUEUED v20180920 15/16] lib: Add memcat_p(): paste 2 pointer arrays together Alexander Shishkin
2018-09-20 13:00   ` Greg Kroah-Hartman
2018-09-21 16:56   ` Andy Shevchenko
2018-09-20 12:45 ` [QUEUED v20180920 16/16] stm class: Use memcat_p() Alexander Shishkin
2018-09-27 17:18 ` [QUEUED v20180920 00/16] stm class/intel_th: Queued updates for v4.20 Mathieu Poirier
2018-10-03 12:52   ` 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=20180927170748.GC7481@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.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