From: Nava kishore Manne <nava.kishore.manne@amd.com>
To: <mdf@kernel.org>, <hao.wu@intel.com>, <yilun.xu@intel.com>,
<trix@redhat.com>, <michal.simek@xilinx.com>,
<linux-fpga@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] fpga: zynqmp: Make word align the configuration data
Date: Tue, 14 Mar 2023 15:12:22 +0530 [thread overview]
Message-ID: <20230314094222.66916-1-nava.kishore.manne@amd.com> (raw)
To avoid unwanted copies at firmware(PMUFW) this patch provides a fix
to align programmable logic(PL) configuration data if the data is not
word-aligned. To align the configuration data this patch adds a few
padding bytes and these additional padding bytes will not create any
functional impact on the PL configuration.
Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
---
drivers/fpga/zynqmp-fpga.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index c60f20949c47..70a12dc6e15c 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -15,6 +15,9 @@
/* Constant Definitions */
#define IXR_FPGA_DONE_MASK BIT(3)
+#define DUMMY_PAD_BYTE 0xFF
+#define FPGA_WORD_SIZE 4
+
/**
* struct zynqmp_fpga_priv - Private data structure
* @dev: Device data structure
@@ -41,18 +44,26 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
const char *buf, size_t size)
{
struct zynqmp_fpga_priv *priv;
+ int word_align, ret, index;
dma_addr_t dma_addr;
u32 eemi_flags = 0;
char *kbuf;
- int ret;
priv = mgr->priv;
+ word_align = size % FPGA_WORD_SIZE;
+ if (word_align)
+ word_align = FPGA_WORD_SIZE - word_align;
+
+ size = size + word_align;
kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr, GFP_KERNEL);
if (!kbuf)
return -ENOMEM;
- memcpy(kbuf, buf, size);
+ for (index = 0; index < word_align; index++)
+ kbuf[index] = DUMMY_PAD_BYTE;
+
+ memcpy(&kbuf[index], buf, size - index);
wmb(); /* ensure all writes are done before initiate FW call */
--
2.25.1
next reply other threads:[~2023-03-14 9:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 9:42 Nava kishore Manne [this message]
2023-03-18 9:25 ` [PATCH] fpga: zynqmp: Make word align the configuration data Xu Yilun
2023-03-28 9:33 ` Manne, Nava kishore
2023-04-01 15:43 ` 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=20230314094222.66916-1-nava.kishore.manne@amd.com \
--to=nava.kishore.manne@amd.com \
--cc=hao.wu@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=michal.simek@xilinx.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).