All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Cc: linux-fpga@vger.kernel.org,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Moritz Fischer" <mdf@kernel.org>, "Wu Hao" <hao.wu@intel.com>,
	"Tom Rix" <trix@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-kernel@vger.kernel.org, system@metrotek.ru
Subject: Re: [PATCH v4 1/3] fpga: microchip-spi: move SPI I/O buffers out of stack
Date: Fri, 30 Dec 2022 15:30:59 +0800	[thread overview]
Message-ID: <Y66Ts4SIYBE8QFF8@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20221229104604.2496-2-i.bornyakov@metrotek.ru>

On 2022-12-29 at 13:46:02 +0300, Ivan Bornyakov wrote:
> As spi-summary doc says:
>  > I/O buffers use the usual Linux rules, and must be DMA-safe.
>  > You'd normally allocate them from the heap or free page pool.
>  > Don't use the stack, or anything that's declared "static".
> 
> Replace spi_write() with spi_write_then_read(), which is dma-safe for
> on-stack buffers. Use allocated buffers for transfers used in

How about "Use cacheline aligned buffers for ..."

> spi_sync_transfer().
> 
> Although everything works OK with stack-located I/O buffers, better
> follow the doc to be safe.
> 
> Fixes: 5f8d4a900830 ("fpga: microchip-spi: add Microchip MPF FPGA manager")
> Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> ---
>  drivers/fpga/microchip-spi.c | 93 ++++++++++++++++++------------------
>  1 file changed, 47 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c
> index 7436976ea904..e72fedd93a27 100644
> --- a/drivers/fpga/microchip-spi.c
> +++ b/drivers/fpga/microchip-spi.c
> @@ -42,46 +42,55 @@
>  struct mpf_priv {
>  	struct spi_device *spi;
>  	bool program_mode;
> +	u8 tx __aligned(ARCH_KMALLOC_MINALIGN);
> +	u8 rx __aligned(ARCH_KMALLOC_MINALIGN);

If the 2 buffers are used synchronously by dma, they could share a
cacheline. Just separate them from other members should be OK, like:

	u8 tx __aligned(ARCH_KMALLOC_MINALIGN);
	u8 rx;

>  };
>  

  reply	other threads:[~2022-12-30  7:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29 10:46 [PATCH v4 0/3] Reliability improvements for Microchip MPF FPGA manager Ivan Bornyakov
2022-12-29 10:46 ` [PATCH v4 1/3] fpga: microchip-spi: move SPI I/O buffers out of stack Ivan Bornyakov
2022-12-30  7:30   ` Xu Yilun [this message]
2022-12-29 10:46 ` [PATCH v4 2/3] fpga: microchip-spi: rewrite status polling in a time measurable way Ivan Bornyakov
2022-12-30  7:43   ` Xu Yilun
2022-12-29 10:46 ` [PATCH v4 3/3] fpga: microchip-spi: separate data frame write routine Ivan Bornyakov
2022-12-30  7:51   ` Xu Yilun

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=Y66Ts4SIYBE8QFF8@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@intel.com \
    --cc=conor.dooley@microchip.com \
    --cc=hao.wu@intel.com \
    --cc=i.bornyakov@metrotek.ru \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=system@metrotek.ru \
    --cc=trix@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.