All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] fpga: zynq-fpga: Replacing BIT with BIN format
@ 2015-10-20 17:19 ` Moritz Fischer
  0 siblings, 0 replies; 8+ messages in thread
From: Moritz Fischer @ 2015-10-20 17:19 UTC (permalink / raw)
  To: atull
  Cc: michal.simek, soren.brinkmann, linux-arm-kernel, linux-kernel,
	joshc, gregkh, mike.looijmans, Moritz Fischer

Hi all,

I dropped the check of the firmware file entirely and let the hardware
figure out if there's no sync word in there.
As Mike suggested I tested with streaming random garbage files to the
device and the hardware dealt with it just fine.

Cheers,

    Moritz

Moritz Fischer (1):
  fpga: zynq-fpga: Change fw format to handle bin instead of bit.

 drivers/fpga/zynq-fpga.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

-- 
2.6.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] fpga: zynq-fpga: Replacing BIT with BIN format
@ 2015-10-20 17:19 ` Moritz Fischer
  0 siblings, 0 replies; 8+ messages in thread
From: Moritz Fischer @ 2015-10-20 17:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

I dropped the check of the firmware file entirely and let the hardware
figure out if there's no sync word in there.
As Mike suggested I tested with streaming random garbage files to the
device and the hardware dealt with it just fine.

Cheers,

    Moritz

Moritz Fischer (1):
  fpga: zynq-fpga: Change fw format to handle bin instead of bit.

 drivers/fpga/zynq-fpga.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

-- 
2.6.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
  2015-10-20 17:19 ` Moritz Fischer
@ 2015-10-20 17:19   ` Moritz Fischer
  -1 siblings, 0 replies; 8+ messages in thread
From: Moritz Fischer @ 2015-10-20 17:19 UTC (permalink / raw)
  To: atull
  Cc: michal.simek, soren.brinkmann, linux-arm-kernel, linux-kernel,
	joshc, gregkh, mike.looijmans, Moritz Fischer

This gets rid of the code to strip away the header and byteswap,
as well as the check for the sync word.

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
---
v2:
 - Removed early exit path in case synq seq is not found
---
 drivers/fpga/zynq-fpga.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
index 617d382..31db550 100644
--- a/drivers/fpga/zynq-fpga.c
+++ b/drivers/fpga/zynq-fpga.c
@@ -287,9 +287,9 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
 	struct zynq_fpga_priv *priv;
 	int err;
 	char *kbuf;
-	size_t i, in_count;
+	size_t in_count;
 	dma_addr_t dma_addr;
-	u32 transfer_length = 0;
+	u32 transfer_length;
 	u32 intr_status;
 
 	in_count = count;
@@ -301,26 +301,6 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
 
 	memcpy(kbuf, buf, count);
 
-	/* look for the sync word */
-	for (i = 0; i < count - 4; i++) {
-		if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) {
-			dev_dbg(priv->dev, "Found swapped sync word\n");
-			break;
-		}
-	}
-
-	/* remove the header, align the data on word boundary */
-	if (i != count - 4) {
-		count -= i;
-		memmove(kbuf, kbuf + i, count);
-	}
-
-	/* fixup endianness of the data */
-	for (i = 0; i < count; i += 4) {
-		u32 *p = (u32 *)&kbuf[i];
-		*p = swab32(*p);
-	}
-
 	/* enable clock */
 	err = clk_enable(priv->clk);
 	if (err)
-- 
2.6.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
@ 2015-10-20 17:19   ` Moritz Fischer
  0 siblings, 0 replies; 8+ messages in thread
From: Moritz Fischer @ 2015-10-20 17:19 UTC (permalink / raw)
  To: linux-arm-kernel

This gets rid of the code to strip away the header and byteswap,
as well as the check for the sync word.

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
---
v2:
 - Removed early exit path in case synq seq is not found
---
 drivers/fpga/zynq-fpga.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
index 617d382..31db550 100644
--- a/drivers/fpga/zynq-fpga.c
+++ b/drivers/fpga/zynq-fpga.c
@@ -287,9 +287,9 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
 	struct zynq_fpga_priv *priv;
 	int err;
 	char *kbuf;
-	size_t i, in_count;
+	size_t in_count;
 	dma_addr_t dma_addr;
-	u32 transfer_length = 0;
+	u32 transfer_length;
 	u32 intr_status;
 
 	in_count = count;
@@ -301,26 +301,6 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
 
 	memcpy(kbuf, buf, count);
 
-	/* look for the sync word */
-	for (i = 0; i < count - 4; i++) {
-		if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) {
-			dev_dbg(priv->dev, "Found swapped sync word\n");
-			break;
-		}
-	}
-
-	/* remove the header, align the data on word boundary */
-	if (i != count - 4) {
-		count -= i;
-		memmove(kbuf, kbuf + i, count);
-	}
-
-	/* fixup endianness of the data */
-	for (i = 0; i < count; i += 4) {
-		u32 *p = (u32 *)&kbuf[i];
-		*p = swab32(*p);
-	}
-
 	/* enable clock */
 	err = clk_enable(priv->clk);
 	if (err)
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
  2015-10-20 17:19   ` Moritz Fischer
@ 2015-10-21  6:46     ` Michal Simek
  -1 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2015-10-21  6:46 UTC (permalink / raw)
  To: Moritz Fischer, atull
  Cc: michal.simek, soren.brinkmann, linux-arm-kernel, linux-kernel,
	joshc, gregkh, mike.looijmans

On 10/20/2015 07:19 PM, Moritz Fischer wrote:
> This gets rid of the code to strip away the header and byteswap,
> as well as the check for the sync word.
> 
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> ---
> v2:
>  - Removed early exit path in case synq seq is not found
> ---
>  drivers/fpga/zynq-fpga.c | 24 ++----------------------
>  1 file changed, 2 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
> index 617d382..31db550 100644
> --- a/drivers/fpga/zynq-fpga.c
> +++ b/drivers/fpga/zynq-fpga.c
> @@ -287,9 +287,9 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
>  	struct zynq_fpga_priv *priv;
>  	int err;
>  	char *kbuf;
> -	size_t i, in_count;
> +	size_t in_count;
>  	dma_addr_t dma_addr;
> -	u32 transfer_length = 0;
> +	u32 transfer_length;
>  	u32 intr_status;
>  
>  	in_count = count;
> @@ -301,26 +301,6 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
>  
>  	memcpy(kbuf, buf, count);
>  
> -	/* look for the sync word */
> -	for (i = 0; i < count - 4; i++) {
> -		if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) {
> -			dev_dbg(priv->dev, "Found swapped sync word\n");
> -			break;
> -		}
> -	}
> -
> -	/* remove the header, align the data on word boundary */
> -	if (i != count - 4) {
> -		count -= i;
> -		memmove(kbuf, kbuf + i, count);
> -	}
> -
> -	/* fixup endianness of the data */
> -	for (i = 0; i < count; i += 4) {
> -		u32 *p = (u32 *)&kbuf[i];
> -		*p = swab32(*p);
> -	}
> -
>  	/* enable clock */
>  	err = clk_enable(priv->clk);
>  	if (err)
> 

Looks good.
Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
@ 2015-10-21  6:46     ` Michal Simek
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2015-10-21  6:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/20/2015 07:19 PM, Moritz Fischer wrote:
> This gets rid of the code to strip away the header and byteswap,
> as well as the check for the sync word.
> 
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> ---
> v2:
>  - Removed early exit path in case synq seq is not found
> ---
>  drivers/fpga/zynq-fpga.c | 24 ++----------------------
>  1 file changed, 2 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
> index 617d382..31db550 100644
> --- a/drivers/fpga/zynq-fpga.c
> +++ b/drivers/fpga/zynq-fpga.c
> @@ -287,9 +287,9 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
>  	struct zynq_fpga_priv *priv;
>  	int err;
>  	char *kbuf;
> -	size_t i, in_count;
> +	size_t in_count;
>  	dma_addr_t dma_addr;
> -	u32 transfer_length = 0;
> +	u32 transfer_length;
>  	u32 intr_status;
>  
>  	in_count = count;
> @@ -301,26 +301,6 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr,
>  
>  	memcpy(kbuf, buf, count);
>  
> -	/* look for the sync word */
> -	for (i = 0; i < count - 4; i++) {
> -		if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) {
> -			dev_dbg(priv->dev, "Found swapped sync word\n");
> -			break;
> -		}
> -	}
> -
> -	/* remove the header, align the data on word boundary */
> -	if (i != count - 4) {
> -		count -= i;
> -		memmove(kbuf, kbuf + i, count);
> -	}
> -
> -	/* fixup endianness of the data */
> -	for (i = 0; i < count; i += 4) {
> -		u32 *p = (u32 *)&kbuf[i];
> -		*p = swab32(*p);
> -	}
> -
>  	/* enable clock */
>  	err = clk_enable(priv->clk);
>  	if (err)
> 

Looks good.
Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
  2015-10-20 17:19   ` Moritz Fischer
@ 2015-10-21 10:32     ` Josh Cartwright
  -1 siblings, 0 replies; 8+ messages in thread
From: Josh Cartwright @ 2015-10-21 10:32 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: atull, michal.simek, soren.brinkmann, linux-arm-kernel,
	linux-kernel, gregkh, mike.looijmans

On Tue, Oct 20, 2015 at 10:19:56AM -0700, Moritz Fischer wrote:
> This gets rid of the code to strip away the header and byteswap,
> as well as the check for the sync word.
> 
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>

Simpler is better.

Reviewed-by: Josh Cartwright <joshc@ni.com>

  Josh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit.
@ 2015-10-21 10:32     ` Josh Cartwright
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Cartwright @ 2015-10-21 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 20, 2015 at 10:19:56AM -0700, Moritz Fischer wrote:
> This gets rid of the code to strip away the header and byteswap,
> as well as the check for the sync word.
> 
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>

Simpler is better.

Reviewed-by: Josh Cartwright <joshc@ni.com>

  Josh

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-21 10:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 17:19 [PATCHv2] fpga: zynq-fpga: Replacing BIT with BIN format Moritz Fischer
2015-10-20 17:19 ` Moritz Fischer
2015-10-20 17:19 ` [PATCHv2] fpga: zynq-fpga: Change fw format to handle bin instead of bit Moritz Fischer
2015-10-20 17:19   ` Moritz Fischer
2015-10-21  6:46   ` Michal Simek
2015-10-21  6:46     ` Michal Simek
2015-10-21 10:32   ` Josh Cartwright
2015-10-21 10:32     ` Josh Cartwright

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.