linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Simek <monstr@monstr.eu>
To: Alan Tull <atull@altera.com>
Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Michal Simek <michal.simek@xilinx.com>,
	linux-kernel@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dinh Nguyen <dinguyen@altera.com>,
	Philip Balister <philip@balister.org>,
	Alessandro Rubini <rubini@gnudd.com>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Cesar Eduardo Barros <cesarb@cesarb.net>,
	Joe Perches <joe@perches.com>,
	"David S. Miller" <davem@davemloft.net>,
	Stephen Warren <swarren@nvidia.com>,
	Arnd Bergmann <arnd@arndb.de>,
	David Brown <davidb@codeaurora.org>,
	Dom Cobley <popcornmix@gmail.com>
Subject: Re: [RFC PATCH] fpga: Introduce new fpga subsystem
Date: Thu, 19 Sep 2013 12:55:16 +0200	[thread overview]
Message-ID: <523AD814.1060406@monstr.eu> (raw)
In-Reply-To: <1379539063.31417.23.camel@atx-linux-37>

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

Hi Alan,

On 09/18/2013 11:17 PM, Alan Tull wrote:
> On Wed, 2013-09-18 at 14:32 -0600, Jason Gunthorpe wrote:
>> On Wed, Sep 18, 2013 at 03:15:17PM -0400, Jason Cooper wrote:
>>
>>> + Jason Gunthorpe
>>
>> Thanks, looks interesting, we could possibly use this interface if it 
>> met our needs..
>>  
>>> On Wed, Sep 18, 2013 at 05:56:39PM +0200, Michal Simek wrote:
>>>> This new subsystem should unify all fpga drivers which
>>>> do the same things. Load configuration data to fpga
>>>> or another programmable logic through common interface.
>>>> It doesn't matter if it is MMIO device, gpio bitbanging,
>>>> etc. connection. The point is to have the same
>>>> inteface for these drivers.
>>
>> So, we have many years of in-field experience with this and this API
>> doesn't really match what we do.
>>
>> Here are the steps we perform, from userspace:
>>  - Ask kernel to place FPGA into reset and prepare for programming
>>    * Kernel can return an error (eg FPGA failed to erase, etc)
>>    * this is the PROG_N low -> DONE high, PROG_N high -> INIT_N high
>>      sequencing on Xilinx chips
>>  - Ask kernel to load a bitstream.
>>    * Userspace locats the bitstream file to load, and the mmaps it.
>>    * Userspace passes the entire file in a single write() call to the
>>      kernel which streams it over the configuration bus
>>    * The kernel can report an erro rhere (eg Xilinx can report CRC
>>    error)
>>  - Ask the kernel to verify that configuration is complete. 
>>    * On Xilinx this wait for done to go high
>>  - Ask the kernel to release the configuration bus (tristate
>>    all drivers) (or sometimes we have to drive the bus low,
>>    it depends on the bitfile, user space knows what to do)
>>
>> It is very important that userspace know exactly which step fails
>> because the resolution is different. We use this in a manufacturing
>> setting, so failures are expected and need quick root cause
>> determination.
>>
>> You could probably address that need by very clearly defining a
>> variety of errno values for the various cases. However, it would be a
>> disaster if every driver did something a little different :|
>>
>> Using request_firmware exclusively is not useful for us. We
>> format the bitfile with a header that contains our internal tracking
>> information. Sometimes we need to bitswap the bitfile. Our userspace
>> handles all of this and can pass a bitfile in memory to write().
>>
>> request_firmware would be horrible to use :)
>>
>> Our API uses a binary sysfs attribute to stream the FPGA data, you
>> might want to consider that.
>>
>> Regards,
>> Jason
> 
> The firmware approach is interesting.  It might be less flexible
> compared with my original code (see link to git below) that this is
> based on.  The original code created a devnode like /dev/fpga0 and a raw
> bitstream could be loaded by doing 'cat bitstream > /dev/fpga0'.  Or
> some other userspace app could write the /dev/fpga0 to handle any
> headers that needed to be added to the bitstream.

We are using char device driver for our devcfg device and hwicap too
but this firmware interface is not far from that.
As Jason mentioned we can use binary sysfs attributes and you should
get the same functionality for userspace.


> This code also creates a set of files under /sys for each separate fpga.
> I.e. checking status by looking at /sys/class/fpga/fpag0/status.  It
> would be pretty small changes to control reseting the fpga by adding a
> 'reset' file there also (added first to the framework, and an interface
> into the low level fpga manager driver).

Status is just there and for my zynq devcfg driver I do export some status
bits.

root@petalinux:~# cat /sys/class/fpga/fpga0/status
partial_bitstream_status: 0
prog_done_status: 1
dbg_lock_status: 0
seu_lock_status: 0
aes_en_lock_status: 0
aes_status: 0
seu_status: 0
spniden_status: 1
spiden_status: 1
niden_status: 1
dbgen_status: 1
dap_en_status: 7

Originally these values are single device attribute but I need to confirm
exact usage for them. It means in this RFC I probably miss any standard
channel how to change end driver behaviour and probably there should be one more
hook for that.

> I am trying this out with my low level fpga manager driver.  I'm very
> curious about your approach and I am wondering whether the firmware
> approach will work for us or not.

I believe so.

> Will this framework handle more than one fpga at a time?

I didn't tried that because I don't have any suitable hw for this on my desk
but I there shouldn't be any problem in that.

> Is there some way a per-device userspace helper can be added that can
> handle adding the headers?  Such that different fpga types get different
> helpers?

What do you exactly mean by that? Any example what do you want to achieve?

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  parent reply	other threads:[~2013-09-19 10:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 15:56 [RFC PATCH 0/1] FPGA subsystem core Michal Simek
2013-09-18 15:56 ` [RFC PATCH] fpga: Introduce new fpga subsystem Michal Simek
2013-09-18 16:11   ` Joe Perches
2013-09-19 10:01     ` Michal Simek
2013-09-19 16:26       ` Alan Tull
2013-09-18 19:02   ` Dinh Nguyen
2013-09-19 11:53     ` Michal Simek
2013-09-18 19:15   ` Jason Cooper
2013-09-18 20:32     ` Jason Gunthorpe
2013-09-18 21:17       ` Alan Tull
2013-09-19 10:08         ` Pavel Machek
2013-09-19 11:02           ` Michal Simek
2013-09-20 20:55             ` Alan Tull
2013-09-24 15:55               ` Alan Tull
2013-09-24 15:58                 ` Michal Simek
2013-09-24 16:22                   ` Alan Tull
2013-09-24 22:18                     ` Greg Kroah-Hartman
2013-09-25 13:55                       ` Yves Vandervennet
2013-09-25 14:51                         ` Michal Simek
2013-09-25 18:50                       ` Alan Tull
2013-09-24 22:54           ` H. Peter Anvin
2013-09-25 10:41             ` Michal Simek
2013-09-25 12:00             ` Pavel Machek
2013-09-25 14:27               ` Philip Balister
2013-09-25 14:43                 ` Michal Simek
2013-09-25 19:21                   ` Alan Tull
2013-09-19 10:55         ` Michal Simek [this message]
2013-09-19 11:17           ` Pavel Machek
2013-09-19 11:22             ` Michal Simek
2013-09-19 12:52               ` /sys rules " Pavel Machek
2013-09-19 14:06                 ` Greg KH
2013-09-19 14:10                   ` Michal Simek
2013-09-19 14:18                     ` Greg KH
2013-09-19 15:14                       ` Alan Tull
2013-09-19 14:20                     ` Jason Cooper
2013-09-19 14:37                       ` Greg KH
2013-09-19 22:48                         ` Pavel Machek
     [not found]           ` <CADuitaA3PLaOgmqXzfMdMDaXg7G6bT-DufjcuhtWfvaoWRj__Q@mail.gmail.com>
2013-09-19 15:14             ` Michal Simek
2013-09-19 15:18           ` Yves Vandervennet
2013-09-19 17:28             ` Jason Gunthorpe
2013-09-23 13:10               ` Michal Simek
2013-09-23 17:10                 ` Jason Gunthorpe
2013-09-25 10:48                   ` Michal Simek
2013-09-23 13:02             ` Michal Simek
2013-09-19 10:03       ` Pavel Machek
2013-09-19 10:45       ` Michal Simek
2013-09-27 13:31       ` Michal Simek
2013-09-30 17:12         ` Jason Gunthorpe
2013-10-01 15:59           ` Michal Simek
2013-09-18 23:45   ` Ryan Mallon
2013-09-19 11:37     ` Michal Simek

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=523AD814.1060406@monstr.eu \
    --to=monstr@monstr.eu \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=atull@altera.com \
    --cc=cesarb@cesarb.net \
    --cc=davem@davemloft.net \
    --cc=davidb@codeaurora.org \
    --cc=dinguyen@altera.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jason@lakedaemon.net \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=michal.simek@xilinx.com \
    --cc=pavel@ucw.cz \
    --cc=philip@balister.org \
    --cc=popcornmix@gmail.com \
    --cc=rubini@gnudd.com \
    --cc=swarren@nvidia.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).