19 Jun, 2020

1 commit

  • Using clang's scan-build/view this issue was flagged in fpga-mgr.c

    drivers/fpga/fpga-mgr.c:585:3: warning: Value stored to 'ret' is never read [deadcode.DeadStores]
    ret = id;

    Signed-off-by: Tom Rix
    Signed-off-by: Moritz Fischer

    Tom Rix
     

30 Jul, 2019

1 commit

  • Introduce wrappers for {bus/driver/class}_find_device() to
    locate devices by its of_node.

    Cc: Maarten Lankhorst
    Cc: Maxime Ripard
    Cc: dri-devel@lists.freedesktop.org
    Cc: David Airlie
    Cc: Daniel Vetter
    Cc: devicetree@vger.kernel.org
    Cc: Florian Fainelli
    Cc: Frank Rowand
    Cc: Heiko Stuebner
    Cc: Liam Girdwood
    Cc: linux-i2c@vger.kernel.org
    Cc: linux-rockchip@lists.infradead.org
    Cc: linux-spi@vger.kernel.org
    Cc: Mathieu Poirier
    Cc: Rob Herring
    Cc: Srinivas Kandagatla
    Cc: Takashi Iwai
    Cc: Alan Tull
    Cc: linux-fpga@vger.kernel.org
    Cc: Peter Rosin
    Cc: Florian Fainelli
    Cc: Heiner Kallweit
    Cc: "David S. Miller"
    Cc: Andrew Lunn
    Cc: Liam Girdwood
    Cc: "Rafael J. Wysocki"
    Cc: Thor Thayer
    Cc: Jiri Slaby
    Cc: Andrew Lunn
    Cc: Peter Rosin
    Signed-off-by: Suzuki K Poulose
    Acked-by: Lee Jones
    Acked-by: Wolfram Sang # I2C part
    Acked-by: Moritz Fischer # For FPGA part
    Acked-by: Mark Brown
    Link: https://lore.kernel.org/r/20190723221838.12024-3-suzuki.poulose@arm.com
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     

16 Oct, 2018

1 commit

  • Add devm_fpga_mgr_create() which is the managed
    version of fpga_mgr_create().

    Change current FPGA manager drivers to use
    devm_fpga_mgr_create()

    Signed-off-by: Alan Tull
    Suggested-by: Federico Vaga
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

15 Jul, 2018

1 commit

  • This patch adds status sysfs interface for fpga manager, it's a
    read only interface which allows user to get fpga manager status,
    including full/partial reconfiguration error and other status
    information. It adds a status callback to fpga_manager_ops too,
    allows each fpga_manager driver to define its own method to
    collect latest status from hardware.

    The following sysfs file is created:
    * /sys/class/fpga_manager//status
    Return status of fpga manager, including reconfiguration errors.

    Signed-off-by: Wu Hao
    Acked-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Wu Hao
     

26 May, 2018

4 commits

  • The following functions also free the struct. Add that
    fact to the function documentation.
    - fpga_mgr_free
    - fpga_bridge_free
    - fpga_region_free

    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • Clean up the kernel-doc documentation in fpga-mgr.c and fix the
    following warnings when documentation is built:

    ./drivers/fpga/fpga-mgr.c:252: warning: Function parameter or member
    'info' not described in 'fpga_mgr_buf_load'

    ./drivers/fpga/fpga-mgr.c:252: warning: Excess function parameter
    'flags' description in 'fpga_mgr_buf_load'

    Signed-off-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • Replace GPLv2 boilerplate with SPDX in FPGA code that came from me or
    from Altera.

    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • Change fpga_mgr_register to not set or use drvdata. This supports
    the case where a PCIe device has more than one manager.

    Add fpga_mgr_create/free functions. Change fpga_mgr_register and
    fpga_mgr_unregister functions to take the mgr struct as their only
    parameter.

    struct fpga_manager *fpga_mgr_create(struct device *dev,
    const char *name,
    const struct fpga_manager_ops *mops,
    void *priv);
    void fpga_mgr_free(struct fpga_manager *mgr);
    int fpga_mgr_register(struct fpga_manager *mgr);
    void fpga_mgr_unregister(struct fpga_manager *mgr);

    Update the drivers that call fpga_mgr_register with the new API.

    Signed-off-by: Alan Tull
    [Moritz: Fixup whitespace issue]
    Reported-by: Jiuyue Ma
    Signed-off-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

28 Nov, 2017

4 commits

  • Notice that mgr = to_fpga_manager(dev); expands to:

    mgr = container_of(dev, struct fpga_manager, dev);

    and container_of is never null, so this null check is
    unnecessary.

    Addresses-Coverity-ID: 1397916
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Gustavo A. R. Silva
     
  • Make it easy to add attributes to low level FPGA drivers the right
    way. Add attribute groups pointers to structures that are used when
    registering a manager, bridge, or group. When the low level driver
    registers, set the device attribute group. The attributes are
    created in device_add.

    Signed-off-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • Previously when the user gets a FPGA manager, it was locked
    and nobody else could use it for programming.

    This commit makes it straightforward to save a reference to an
    FPGA manager and only lock it when programming the FPGA.

    Add functions that get an FPGA manager's mutex for exclusive use:
    * fpga_mgr_lock
    * fpga_mgr_unlock

    The following functions no longer lock an FPGA manager's mutex:
    * of_fpga_mgr_get
    * fpga_mgr_get
    * fpga_mgr_put

    Signed-off-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • fpga-mgr has three methods for programming FPGAs, depending on
    whether the image is in a scatter gather list, a contiguous
    buffer, or a firmware file. This makes it difficult to write
    upper layers as the caller has to assume whether the FPGA image
    is in a sg table, as a single buffer, or a firmware file.
    This commit moves these parameters to struct fpga_image_info
    and adds a single function for programming fpgas.

    New functions:
    * fpga_mgr_load - given fpga manager and struct fpga_image_info,
    program the fpga.

    * fpga_image_info_alloc - alloc a struct fpga_image_info.

    * fpga_image_info_free - free a struct fpga_image_info.

    These three functions are unexported:
    * fpga_mgr_buf_load_sg
    * fpga_mgr_buf_load
    * fpga_mgr_firmware_load

    Also use devm_kstrdup to copy firmware_name so we aren't making
    assumptions about where it comes from when allocing/freeing the
    struct fpga_image_info.

    API documentation has been updated and a new document for
    FPGA region has been added.

    Signed-off-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

17 Mar, 2017

1 commit

  • Fix up these sparse warnings:

    drivers/fpga/fpga-mgr.c:189:21: warning: symbol '__fpga_mgr_get' was not declared. Should it be static?
    drivers/fpga/fpga-bridge.c:30:12: warning: symbol 'bridge_list_lock' was not declared. Should it be static?

    Signed-off-by: Dinh Nguyen
    Acked-by: Moritz Fischer
    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Dinh Nguyen
     

10 Feb, 2017

1 commit

  • Requiring contiguous kernel memory is not a good idea, this is a limited
    resource and allocation can fail under normal work loads.

    This introduces a .write_sg op that supporting drivers can provide
    to DMA directly from dis-contiguous memory and a new entry point
    fpga_mgr_buf_load_sg that users can call to directly provide page
    lists.

    The full matrix of compatibility is provided, either the linear or sg
    interface can be used by the user with a driver supporting either
    interface.

    A notable change for drivers is that the .write op can now be called
    multiple times.

    Signed-off-by: Jason Gunthorpe
    Acked-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Jason Gunthorpe
     

30 Nov, 2016

1 commit

  • This interface was designed for streaming, but write_init's buf
    argument has an unclear purpose. Define it to be the first bytes
    of the bitstream. Each driver gets to set how many bytes (at most)
    it wants to see. Short bitstreams will be passed through as-is, while
    long ones will be truncated.

    The intent is to allow drivers to peek at the header before the transfer
    actually starts.

    Signed-off-by: Jason Gunthorpe
    Acked-by: Alan Tull

    Jason Gunthorpe
     

11 Nov, 2016

2 commits

  • This patch adds a minor change in the FPGA Manager API
    to hold information that is specific to an FPGA image
    file. This change is expected to bring little, if any,
    pain. The socfpga and zynq drivers are fixed up in
    this patch.

    An FPGA image file will have particulars that affect how the
    image is programmed to the FPGA. One example is that
    current 'flags' currently has one bit which shows whether the
    FPGA image was built for full reconfiguration or partial
    reconfiguration. Another example is timeout values for
    enabling or disabling the bridges in the FPGA. As the
    complexity of the FPGA design increases, the bridges in the
    FPGA may take longer times to enable or disable.

    This patch adds a new 'struct fpga_image_info', moves the
    current 'u32 flags' to it. Two other image-specific u32's
    are added for the bridge enable/disable timeouts. The FPGA
    Manager API functions are changed, replacing the 'u32 flag'
    parameter with a pointer to struct fpga_image_info.
    Subsequent patches fix the existing low level FPGA manager
    drivers.

    Signed-off-by: Alan Tull
    Acked-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • The intent is to provide a non-DT method of getting
    ahold of a FPGA manager to do some FPGA programming.

    This patch refactors of_fpga_mgr_get() to reuse most of it
    while adding a new method fpga_mgr_get() for getting a
    pointer to a fpga manager struct, given the device.

    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

25 Nov, 2015

2 commits

  • If fpga_mgr_buf_load() fails, the firmware resource previously allocated
    by request_firmware() is leaked. Fix it by calling release_firmware()
    regardless of the return value of fpga_mgr_buf_load().

    Found by the Coverity scanner (CID 1339653).

    Fixes: 6a8c3be7ec8e ("add FPGA manager core")
    Signed-off-by: Tobias Klauser
    Acked-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Tobias Klauser
     
  • Remove implementation of 'label' DT binding.

    Signed-off-by: Alan Tull
    Reviewed-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

24 Oct, 2015

2 commits

  • Remove unnecessary null pointer checks. We want the caller of
    these functions to do their own pointer checks. Add some
    comments to document this.

    Signed-off-by: Alan Tull
    Reviewed-by: Moritz Fischer
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     
  • Ensure device and driver lifetime from of_fpga_mgr_get() to
    fpga_mgr_put().

    * Don't put_device() in of_fpga_mgr_get, do it in fpga_mgr_put().
    (still do put_device if there is an error).
    * Do module_get on the low level driver.
    * Don't need to module_get(THIS_MODULE) since we won't be allowed
    to unload the fpga manager core without unloading low level
    driver first.
    * Remove unnedessary null check for node pointer.

    Signed-off-by: Alan Tull
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull
     

08 Oct, 2015

1 commit

  • API to support programming FPGA's.

    The following functions are exported as GPL:
    * fpga_mgr_buf_load
    Load fpga from image in buffer

    * fpga_mgr_firmware_load
    Request firmware and load it to the FPGA.

    * fpga_mgr_register
    * fpga_mgr_unregister
    FPGA device drivers can be added by calling
    fpga_mgr_register() to register a set of
    fpga_manager_ops to do device specific stuff.

    * of_fpga_mgr_get
    * fpga_mgr_put
    Get/put a reference to a fpga manager.

    The following sysfs files are created:
    * /sys/class/fpga_manager//name
    Name of low level driver.

    * /sys/class/fpga_manager//state
    State of fpga manager

    Signed-off-by: Alan Tull
    Acked-by: Michal Simek
    Signed-off-by: Greg Kroah-Hartman

    Alan Tull