devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: Michal Simek <michal.simek@xilinx.com>,
	Moritz Fischer <moritz.fischer@ettus.com>,
	Josh Cartwright <joshc@ni.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	"Russell King" <linux@arm.linux.org.uk>,
	"pawel.moll@arm.com" <pawel.moll@arm.com>,
	ijc+devicetree@hellion.org.uk,
	"Alan Tull" <atull@opensource.altera.com>,
	"Greg KH" <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	"Sören Brinkmann" <soren.brinkmann@xilinx.com>,
	"Kumar Gala" <galak@codeaurora.org>,
	"dinguyen@opensource.altera.com" <dinguyen@opensource.altera.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/3] fpga manager: Adding FPGA Manager support for Xilinx Zynq 7000
Date: Mon, 12 Oct 2015 14:22:36 +0200	[thread overview]
Message-ID: <561BA60C.6010106@topic.nl> (raw)
In-Reply-To: <561B9687.1070103@xilinx.com>

On 12-10-15 13:16, Michal Simek wrote:
>
>>>> +static int zynq_fpga_ops_write(struct fpga_manager *mgr,
>>>> +                            const char *buf, size_t count)
>>>> +{
>>>> +     struct zynq_fpga_priv *priv;
>>>> +     int err;
>>>> +     char *kbuf;
>>>> +     size_t i, in_count;
>>>> +     dma_addr_t dma_addr;
>>>> +     u32 transfer_length = 0;
>>>> +     bool endian_swap = false;
>>>> +
>>>> +     in_count = count;
>>>> +     priv = mgr->priv;
>>>> +
>>>> +     kbuf = dma_alloc_coherent(priv->dev, count, &dma_addr, GFP_KERNEL);
>>>> +     if (!kbuf)
>>>> +             return -ENOMEM;
>>>> +
>>>> +     memcpy(kbuf, buf, count);
>>>> +
>>>> +     /* look for the sync word */
>>>> +     for (i = 0; i < count - 4; i++) {
>>>> +             if (memcmp(kbuf + i, "\x66\x55\x99\xAA", 4) == 0) {
>>>> +                     dev_dbg(priv->dev, "Found normal sync word\n");
>>>> +                     endian_swap = false;
>>>> +                     break;
>>>> +             }
>
> This is bin format
>
>>>> +             if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) {
>>>> +                     dev_dbg(priv->dev, "Found swapped sync word\n");
>>>> +                     endian_swap = true;
>>>> +                     break;
>>>> +             }
>
> This is bit format from header
>
>>>> +     }
>>>
>>> How much control do we have over mandating the format of firmware at
>>> this point?  It'd be swell if we could just mandate a specific
>>> endianness, and leave this munging to usermode.
>>
>> That's a good question. Personally I do only care about one of both,
>> but that's just because I get to decide for my targets...
>> Opinions from the Xilinx guys?
>
> Don't know full history about this but in past bitstream in BIT format
> was used. Which is header (partially decoding in u-boot for example)
> with data.
> On zynq native format is BIN which is format without header and data is
> swapped.
> This code just detects which format is used. If BIT, header is skipped
> and data is swapped to BIN format.
>
> Back to origin question if this is something what can be handled from
> user space. And answer is - yes it can be handled there.
> But based on my experience it is very useful to be able to handle BIT
> because it is built by tools by default.
> Also with BIN format you are loosing record what this data bitstream
> targets. Header in BIT gives you at least some ideas.

People should stop using "cat" to program the FPGA and use a userspace tool 
instead. I've already released such tools under GPL, so anyone can pick up on 
it and extend it as required.

The header for the "bit" format is completely ignored (you can't even use it 
to determine if the bitstream is compatible with the current device) so 
there's no point in carrying it around. On the zynq, doing the "swap" in 
userspace was measurably faster than having the driver handle it, and that was 
even without using NEON instructions for byte swapping.

I admit that being able to do "cat static.bit > /dev/xdevcfg" has had its 
uses. But it's not something that belongs in mainline Linux.

Probably one of the key reasons that the "bit" format is still popular is that 
getting the Vivado tools to create a proper "bin" that will actually work on 
the Zynq is about as easy as nailing jelly to a tree. We've been using a 
simple Python script to do the bit->bin conversion for that reason.

Using the "bin" format in the driver keeps it simple and singular. Userspace 
tools can add whatever wrappers and headers they feel appropriate to it, these 
checks don't belong in the driver since they will be application specific. For 
example, some users would want to verify that a partial bitstream actually 
matches the static part that's currently in the FPGA.

Mike.


Kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
Telefax: +31 (0) 499 33 69 70
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail






_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2015-10-12 12:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 22:45 [PATCH 0/3] Adding Xilinx Zynq 7000 FPGA Manager driver Moritz Fischer
2015-10-08 22:45 ` [PATCH 1/3] doc: dt: fpga: Added Documentation for Xilinx Zynq FPGA manager Moritz Fischer
2015-10-09 16:04   ` Josh Cartwright
2015-10-12  9:31     ` Michal Simek
2015-10-12 20:41       ` Moritz Fischer
2015-10-12 16:33   ` Sören Brinkmann
2015-10-12 21:24     ` Moritz Fischer
2015-10-08 22:45 ` [PATCH 2/3] dts: Updated devicetree bindings for Zynq 7000 platform Moritz Fischer
2015-10-12  9:32   ` Michal Simek
2015-10-14  2:50     ` Moritz Fischer
     [not found]       ` <CAAtXAHfRt-6+Hs=DTUDg1_2vxHo213ut_DWgH8Uq2xMuRp+e_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-14  7:03         ` Michal Simek
     [not found]   ` <1444344307-22509-3-git-send-email-moritz.fischer-+aYTwkv1SeIAvxtiuMwx3w@public.gmane.org>
2015-10-12 16:19     ` Sören Brinkmann
2015-10-08 22:45 ` [PATCH 3/3] fpga manager: Adding FPGA Manager support for Xilinx Zynq 7000 Moritz Fischer
     [not found]   ` <1444344307-22509-4-git-send-email-moritz.fischer-+aYTwkv1SeIAvxtiuMwx3w@public.gmane.org>
2015-10-09 16:33     ` Josh Cartwright
2015-10-09 17:17       ` Moritz Fischer
2015-10-12 11:16         ` Michal Simek
2015-10-12 12:22           ` Mike Looijmans [this message]
     [not found]             ` <561BA60C.6010106-Oq418RWZeHk@public.gmane.org>
2015-10-12 12:38               ` Michal Simek
2015-10-13  5:33                 ` Mike Looijmans
     [not found]                   ` <561C979B.6040201-Oq418RWZeHk@public.gmane.org>
2015-10-13 12:52                     ` Michal Simek
2015-10-09 18:09   ` atull
2015-10-09 18:16     ` Greg KH
2015-10-09 18:23       ` atull
2015-10-12  2:22     ` Moritz Fischer

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=561BA60C.6010106@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=atull@opensource.altera.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=joshc@ni.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=michal.simek@xilinx.com \
    --cc=moritz.fischer@ettus.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=soren.brinkmann@xilinx.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 NNTP newsgroup(s).