Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Valentin Longchamp
	<valentin.longchamp-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
Cc: Linux SPI <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Mark Marshall
	<markmarshall14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] spi/fsl-espi: fix rx_buf in fsl_espi_cmd_trans()/fsl_espi_rw_trans()
Date: Fri, 16 May 2014 20:07:23 +0100	[thread overview]
Message-ID: <20140516190723.GT22111@sirena.org.uk> (raw)
In-Reply-To: <1400251581-26617-1-git-send-email-valentin.longchamp-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

On Fri, May 16, 2014 at 04:46:21PM +0200, Valentin Longchamp wrote:

> By default for every espi transfer, the rx_buf is placed right after the
> tx_buf. This can lead to a buffer overflow when the size of both the TX
> and RX data cumulated is higher than the allocated 64K buffer for the
> transfer (this is the case when sending for instance a read command and
> reading 64K back, please see:
> http://article.gmane.org/gmane.linux.drivers.mtd/53411 )
> 
> This gets fixed by always setting the RX buffer pointer at the begining
> of the transfer buffer.

This still doesn't seem safe - we're now going to be DMAing to and from
the same buffer at the same time (and doubtless mapping it twice...).
Would it not be safer to allocate separate rx and tx buffers?  Indeed
can we not use the core DMA mapping support to avoid the need to copy at
all (it will construct scatterlists in PAGE_SIZE chunks)?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-05-16 19:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 14:46 [PATCH] spi/fsl-espi: fix rx_buf in fsl_espi_cmd_trans()/fsl_espi_rw_trans() Valentin Longchamp
     [not found] ` <1400251581-26617-1-git-send-email-valentin.longchamp-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2014-05-16 19:07   ` Mark Brown [this message]
     [not found]     ` <20140516190723.GT22111-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-19 15:30       ` Valentin Longchamp
     [not found]         ` <537A2390.4070203-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2014-05-19 16:22           ` Mark Brown
     [not found]             ` <20140519162200.GD12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-20 15:07               ` Valentin Longchamp
2014-05-26 15:57   ` Mark Brown

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=20140516190723.GT22111@sirena.org.uk \
    --to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=markmarshall14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=valentin.longchamp-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.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