Commit Graph

32 Commits

Author SHA1 Message Date
Thomas Gleixner 2874c5fd28 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 3029 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:32 -07:00
Ding Xiang a71bcc1b09 vme: remove unneeded kfree
put_device will call vme_dev_release to free vdev, kfree is
unnecessary here.

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-14 15:25:57 +02:00
Jia-Ju Bai 97784615ed vme: Fix a possible sleep-in-atomic bug in vme_tsi148
The driver may sleep under a spinlock.
The function call path is:
tsi148_master_write \ tsi148_master_read (acquire the spinlock)
  vme_register_error_handler
    kmalloc(GFP_KERNEL) --> may sleep

To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.

This bug is found by my static analysis tool(DSAC) and checked by my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-18 15:59:18 +01:00
Martyn Welch f13d1a8a80 VME: Return -EBUSY when DMA list in use
The VME subsystem currently returns -EBUSY when trying to free a DMA
resource that is busy, but returns -EINVAL when trying to free a DMA list
that is in use. Switch to returning -EBUSY when trying to free a DMA list
that is in use for consistency and correctness.

Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-08 14:26:50 +01:00
Greg Kroah-Hartman ad146e37d2 VME Subsystem changes for master v4.14-rc4:
- Corrections across the VME subsystem to better align with the preferred
    kernel coding style.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJZ4SrIAAoJEE12cGh4ILCUrx0QAKnbzriglz5v8WqKcH7Z0IRT
 d6+3hRsot7TvEKbcsDU0dql3njI1LM1owPXsIEaFCmx1mP2D+1MFp7IuxEfNdiFo
 rO2gmvXvfv4nyaW/LYCu/7aiC/R+0f1RSj9K6e+jc0o31VGL6EG+mBN+XZ6G5PV0
 RCVz87BBtulU4zt/tbKpKmpJucbVAToUoAhnU3mIU/rDy/U9zuzfepzkGmtRzoid
 fCSrC87Me+Wq++1b3FOQpAKR3pd9eLqevMRwOe5c8JBD1qy4KyeQPVq44beGf3uy
 bWDTYGkn4NiVlJQEJQfnXbvFxo7zuuqUO9fBNsTbvaVzwiyoAq6u4vZZRqMQghL+
 GG5lskyUZCqlOOdjy8HyNGYiHelELgnU0YaJk3/vl5kjsfpApuAkHBH9X7ztFPQi
 t0QrqkX3/cYhI2AmBoddR6cEEBvZN23rjhe2zReln+Aq5Se7k5DZnogVWkM9QwDD
 agnhAB3LhOYoxeDKfDtbVieV6//UdOQtsmadgeOihfZ5AWxel+Jh0w4dv2xrjqpS
 8Xwt1AtUPG+h+OAmUpTgrWDs1osV1eHBQ7MtuVosB1ofn5vdinTXEalqPEHQCOU8
 Ab5R4qEm9srEsoMZ8GCr8d6irDU5w/Uk39KHOKycz9g1+o7jexSDHJ9xbePrOSR9
 +r7NuSYReExa8XBNUyO1
 =gprQ
 -----END PGP SIGNATURE-----

Merge tag 'vme-next-4.14-rc4' of https://gitlab.collabora.com/martyn/linux into char-misc-next

Martyn writes:

VME Subsystem changes for master v4.14-rc4:

 - Corrections across the VME subsystem to better align with the preferred
   kernel coding style.
2017-10-20 15:24:34 +02:00
Markus Elfring 8af70cd9d6 vme: Return directly in two functions
Return directly without using an intermediate local variable
in these functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
2017-10-13 21:32:01 +01:00
Markus Elfring 61282c0498 vme: Adjust 48 checks for null pointers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
2017-10-13 21:32:01 +01:00
Markus Elfring a384b2cc13 vme: Move an assignment in vme_new_dma_list()
Assign a pointer to a data structure member without using an intermediate
local variable.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
2017-10-13 21:32:01 +01:00
Markus Elfring 1ff0a19ce1 vme: Improve 11 size determinations
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
2017-10-13 21:32:00 +01:00
Markus Elfring 94eefcc1cb vme: Delete 11 error messages for a failed memory allocation
Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
2017-10-13 21:32:00 +01:00
Dan Carpenter bd14798650 vme: Fix integer overflow checking in vme_check_window()
The controversial part of this patch is that I've changed it so we now
prevent integer overflows for VME_USER types and before we didn't.  I
view it as kernel-hardening.  I looked at a couple places that used
VME_USER types and they seemed pretty suspicious so I'm pretty sure
preventing overflows here is a good idea.

The most common problem which this function is for cases like VME_A16
where we don't put an upper bound on "size" so you could have "size" set
to U64_MAX and a valid vme_base would overflow the "vme_base + size"
into the valid range as well.

In the VME_A64 case, the integer overflow checking doesn't work because
"U64_MAX + 1" has an integer overflow and it's just a complicated way of
saying zero.  That VME_A64 case is sort of interesting as well because
there is a VME_A64_MAX define which is set to "U64_MAX + 1".  The
compiler will never let anyone use it since it can't be stored in a u64
variable...  With my patch it's now limited to just U64_MAX.

Anyway, I put one integer overflow check at the start of the function
and deleted all existing checks.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-04 10:30:53 +02:00
Martyn Welch b5bc980a49 docs: Add kernel-doc comments to VME driver API
Add kernel-doc comments to the VME driver API and structures. This
documentation will be integrated into the RST documentation in a later
patch.

Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-17 15:10:49 +09:00
Stefano Babic 9797484ba8 VME: restore bus_remove function causing incomplete module unload
Commit 050c3d52cc ("vme: make core
vme support explicitly non-modular") dropped the remove function
because it appeared as if it was for removal of the bus, which is
not supported.

However, vme_bus_remove() is called when a VME device is removed
from the bus and not when the bus is removed; as it calls the VME
device driver's cleanup function.  Without this function, the
remove() in the VME device driver is never called and VME device
drivers cannot be reloaded again.

Here we restore the remove function that was deleted in that
commit, and the reference to the function in the bus structure.

Fixes: 050c3d52cc ("vme: make core vme support explicitly non-modular")
Cc: Manohar Vanga <manohar.vanga@gmail.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: stable <stable@vger.kernel.org> # 4.9
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-25 11:41:44 +01:00
Martyn Welch 6ad37567b6 vme: vme_get_size potentially returning incorrect value on failure
The function vme_get_size returns the size of the window to the caller,
however it doesn't check the return value of the call to vme_master_get.

Return 0 on failure rather than anything else.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-28 08:25:18 -04:00
Paul Gortmaker 050c3d52cc vme: make core vme support explicitly non-modular
The Kconfig currently controlling compilation of this code is:

drivers/vme/Kconfig:menuconfig VME_BUS
drivers/vme/Kconfig:    bool "VME bridge support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We replace module.h and moduleparam.h (unused) with init.h and also
export.h ; the latter since this file does export some syms.

Since this is a struct bus_type and not a platform_driver, we don't
have any ".suppress_bind_attrs" to be concerned about when we
drop the ".remove" code from this file.

Since module_init was not in use by this code, the init ordering
remains unchanged with this commit.

Cc: Manohar Vanga <manohar.vanga@gmail.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 13:20:16 +02:00
Aaron Sierra fa54b32680 vme: change LM callback argument to void pointer
Make the location monitor callback function prototype more useful by
changing the argument from an integer to a void pointer.

All VME bridge drivers were simply passing the location monitor index
(e.g. 0-3) as the argument to these callbacks. It is much more useful
to pass back a pointer to data that the callback-registering driver
cares about.

There appear to be no in-kernel callers of vme_lm_attach (or
vme_lme_request for that matter), so this change only affects the VME
subsystem and bridge drivers.

This has been tested with Tsi148 hardware, but the CA91Cx42 changes
have only been compiled.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 13:20:15 +02:00
Aaron Sierra 326071b3c9 vme: add vme_init_bridge for common bridge init
Consolidate vme_bridge structure setup that every bridge was required
to do itself. This came about because .irq_mtx is only used within the
VME core, but was required to be setup externally.

This returns the structure passed in to support shorthand like this:

    bridge = vme_init_bridge(&priv->bridge);

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-05-01 14:00:00 -07:00
Aaron Sierra f56c3d4f54 vme: trivial spelling and capitalization fixes
Fix a typo in the spurious interrupt warning and consistently capitalize
VME, PCI, and DMA acronyms.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-05-01 14:00:00 -07:00
Dmitry Kalinkin 448535a350 vme: print unhandled VME access errors
This will enable error messages for accesses done through mmap.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:50:57 +01:00
Dmitry Kalinkin 0b04966257 vme: change bus error handling scheme
The current VME bus error handler adds errors to the bridge error list.
vme_master_{read,write} then traverses that list to look for relevant
errors.

Such scheme didn't work well for accesses going through vme_master_mmap
because they would also allocate a vme_bus_error, but have no way to do
vme_clear_errors call to free that memory.

This changes the error handling process to be other way around: now
vme_master_{read,write} defines a window in VME address space that will
catch possible errors.  VME bus error interrupt only traverses these
windows and marks those that had errors in them.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:50:57 +01:00
Dmitry Kalinkin 472f16f33c vme: include address space in error filtering
Also changes vme_bus_error_handler to take generic address modifier code
instead of raw contents of a device-specific attribute register.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:50:57 +01:00
Dmitry Kalinkin e2c6393fda vme: move tsi148 error handling into VME subsystem
Error handling code found in tsi148 is not device specific. In fact it
already relies on shared vme_bus_error struct and vme_bridge.vme_errors
field. The other bridge driver could reuse this code if it is shared.

This introduces a slight behavior change: vme error message won't be
triggered in a rare case when err_chk=1 and kmalloc fails.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:50:57 +01:00
Dmitry Kalinkin ef73f886b5 vme: export vme_check_window()
Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-12 17:26:57 -07:00
Dmitry Kalinkin e7fd80cbb4 vme: check for A64 overflow in vme_check_window()
Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-12 17:26:57 -07:00
Dmitry Kalinkin c74a804f11 staging: vme: mmap() support for vme_user
We also make sure that user won't be able to reconfigure the window while it is
mmap'ed.

Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Martyn Welch <martyn.welch@ge.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-06 17:03:22 -08:00
Julia Lawall c1038307c4 vme: fix misspelling of current function in string
Replace a misspelled function name by %s and then __func__.

This is the get function, not the set function, as was indicated by the
string.

This was done using Coccinelle, including the use of Levenshtein distance,
as proposed by Rasmus Villemoes.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-12 05:04:12 -08:00
Aaron Sierra c326cc023e vme: Convert VME core to register as a subsystem
Previously, VME bridge support was treated as any other driver (using
module_init() macro), but if VME bridge and vme_user (staging) drivers
were compiled into the kernel, then vme_user would attempt to register
itself before the VME core support had been loaded. This would result
in a kernel panic.

The load order of these built-in drivers is based on the order in which
drivers/staging/vme and driver/vme are compiled.

This patch changes the VME core driver to use the subsys_initcall()
macro which ensures that it is loaded before all other VME drivers
regardless of the order in which they are compiled.

Tested-by: Aaron Sierra <asierra@xes-inc.com>
Signed-off-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-17 17:06:19 -08:00
Martyn Welch d7729f0fc4 VME: Rename vme_slot_get to avoid confusion with reference counting
Traditionally the "get" functions increment the reference count of the
object that is returned, which does not happen with vme_slot_get. The
function vme_slot_get returns the physical VME slot associated with a
particular struct vme_dev. Rename vme_slot_num to avoid any confusion.

Signed-off-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-03 11:15:58 -08:00
Martyn Welch 978f47d643 VME: Provide access to VME bus enumeration and fix vme_user match function
The match function for vme_user is completely wrong. It will blindly bind
against the first VME slot on each bus (at this point that would be just the
first bus as the driver can only handle one bus).

The original intention (before some major subsystem changes) was that the
driver bind against the slot to which the bridge was attached in the VME
system and to the bus(es) provided via the "bus" module parameter.

To do this cleanly (i.e. without poking arround in the subsystems internal
stuctures) a functionality has been added to provide access to the bus
enumeration.

Signed-off-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-03 11:15:58 -08:00
Martyn Welch fd5c256140 vme: Free DMA resource allocation structure
There is a memory leak in the function vme_dma_free(). The resource
structure allocated in vme_dma_request() needs to be free'd in
vme_dma_free().

Reported-by: De Roo, Steven <steven.deroo@arcelormittal.com>
Signed-off-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 12:54:08 -07:00
Emilio G. Cota def1820d25 vme: add missing put_device() after device_register() fails
put_device() must be called after device_register() fails,
since device_register() always initializes the refcount
on the device structure.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-14 09:24:14 -08:00
Greg Kroah-Hartman db3b9e990e Staging: VME: move VME drivers out of staging
This moves the VME core, VME board drivers, and VME bridge drivers out
of the drivers/staging/vme/ area to drivers/vme/.

The VME device drivers have not moved out yet due to some API questions
they are still working through, that should happen soon, hopefully.

Cc: Martyn Welch <martyn.welch@ge.com>
Cc: Manohar Vanga <manohar.vanga@cern.ch>
Cc: Vincent Bossier <vincent.bossier@gmail.com>
Cc: "Emilio G. Cota" <cota@braap.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-26 12:34:58 -07:00