openwrt/staging/blogic.git
6 years agostaging: mt7621-mmc: Remove unused field dma_addr of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:50 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field dma_addr of msdc_host

The dma_addr field of msdc_host is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field cmd_rsp_done of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:49 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field cmd_rsp_done of msdc_host

The cmd_rsp_done field of msdc_host is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field cmd_r1b_done in msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:48 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field cmd_r1b_done in msdc_host

The field cmd_r1b_done in msdc_host is unused, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field dma_left_size of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:46 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field dma_left_size of msdc_host

The dma_left_size field of msdc_host is never used, remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621:mmc: Remove unused field reserved from msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:45 +0000 (17:27 +0200)]
staging: mt7621:mmc: Remove unused field reserved from msdc_host

The reserved field of msdc_host is never used and msdc_host is also
never exposed to hardware, so remove that field.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field starttime from msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:44 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field starttime from msdc_host

The starttime field of msdc_host is never used, remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Change default transfer mode to DMA
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:43 +0000 (17:27 +0200)]
staging: mt7621-mmc: Change default transfer mode to DMA

The current default transfer is to use DMA or not depending on the
size of the data. The upstream driver mtk-sd uses DMA all times,
change the standard mode here to DMA for testing, if there are any
performance problems with DMA for small data sizes. If not, the option
for transfer mode should be removed in the future,

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Refactor msdc_init_gpd_bd
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:41 +0000 (17:27 +0200)]
staging: mt7621-mmc: Refactor msdc_init_gpd_bd

The msdc_init_gpd_bd function is currently hard to read, because of
old, commented out code and a while loop, where a for loop is much
easier to read. Refactor it to make the code more readable.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field xfersz from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:36 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field xfersz from msdc_dma

The xfersz field of msdc_dma is only set to host->xfer_size and this
is also available at the (few) positions, where dma.xfersz is used, so
it is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove flags from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:35 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove flags from msdc_dma

The flags of msdc_dma are set to a constant value, so block and dword
padding are disabled and checksum is enabled. By removing the field
the code is easier to read and the difference to the mtk-sd driver is
smaller.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused fields from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:34 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused fields from msdc_dma

The fields used_gpd|bd in struct msdc_dma are only set and reset, but
never used, so remove them. The other removed fields are never used,
so they were removed either.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Start cleanup of msdc_dma_config
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:33 +0000 (17:27 +0200)]
staging: mt7621-mmc: Start cleanup of msdc_dma_config

Currently the msdc_dma_config function has some variables, that are
not needed, uses the macro msdc_init_bd that is only used here and
does not use the for_each_sg iterator. That last fact could cause a
bug if the scatterlist is chained.

The function is changed to remove these things, but none of the
changes should change the behavior of it (despite the case of a linked
scatterlist).

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused function msdc_dma_dump
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:32 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused function msdc_dma_dump

The msdc_dma_dump function is disabled by a preprocessor macro, was
only used in the msdc_dma_setup function. The code also contains no
information about the device, it only dumps some memory for debug.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field burstsz from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:31 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field burstsz from msdc_dma

The burstsz field in msdc_dma is set to a constant value and later
only used two times, using the constant directly in that places allows
to remove the field and improves readability.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field data_offset from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:29 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field data_offset from msdc_hw

The data_offset field in msdc_hw is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Relax cpu while waiting for stable clock
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:28 +0000 (17:27 +0200)]
staging: mt7621-mmc: Relax cpu while waiting for stable clock

Current code just busy waits with nop for clock becoming stable,
relaxing the cpu here improves readability and portability and also
removes a unnecessary difference with the mtk-sd driver.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove code for not existent config
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:27 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove code for not existent config

The MT7621|7628_FPGA config flags are non existent in the tree, so
code guarded by this flags can be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Refactor and rename msdc_reset to msdc_reset_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:26 +0000 (17:27 +0200)]
staging: mt7621-mmc: Refactor and rename msdc_reset to msdc_reset_hw

In the current code the hardware reset is realised via a macro and
does only wait for a certain ammount of time for the controller to
come out of reset state, but it should wait until it IS out of reset
state. So it is refactored to improve this, it is also changed from a
macro to a function and renamed to msdc_reset_hw to match the mtk-sd
driver.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove power callbacks from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:25 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove power callbacks from msdc_hw

The ext_power_on|off fields of msdc_hw are never set, and only once
checked for not being zero, so they can just be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix null pointer deref if ext sdio irq enabled
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:24 +0000 (17:27 +0200)]
staging: mt7621-mmc: Fix null pointer deref if ext sdio irq enabled

The enable|disable_sdio_irq() fields of msdc_hw are never set, so when
they are called, they are null pointer. In case of the
MSDC_EXT_SDIO_IRQ flag set in msdc0_hw, this happens. But because
these fields are never set, they can simply be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field disable_cd_eirq
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:23 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field disable_cd_eirq

The disable_cd_eirq() field of msdc_hw is never set and only once
checked for being non zero, so it is deleted.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field enable_cd_eirq from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:22 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field enable_cd_eirq from msdc_hw

The enable_cd_eirq() field of msdc_hw is never set and only once
checked for not being zero, so it is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field get_cd_status from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:21 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field get_cd_status from msdc_hw

The get_cd_status() field of msdc_hw is never set and there is only
one check for it being non zero, so it is deleted.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused code from board.h
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:20 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused code from board.h

The board.h file contins lot of never used code, to clean up the
driver, this code is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-spi: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 17:37:32 +0000 (19:37 +0200)]
staging: mt7621-spi: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-pinctrl: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 17:35:29 +0000 (19:35 +0200)]
staging: mt7621-pinctrl: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-pci: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 16:40:11 +0000 (18:40 +0200)]
staging: mt7621-pci: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove redundant opcode check
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:25 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove redundant opcode check

The opcode check in msdc_command_start is redundant in case of
MMC_SET_RELATIVE_ADDR, this is 3 like SD_SEND_RELATIVE_ADDR, so the
second check can be removed.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix: copy_from_user() returns a positive value
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:24 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix: copy_from_user() returns a positive value

copy_from_user() returns a positive value in case of an error, to fix
this the check is turned around, also a better return value is chosen.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix debug file world writable
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:23 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix debug file world writable

Currently the debug file in proc fs is world writable, remove the
access for other.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove error message in debug
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:22 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove error message in debug

If the debug file in proc fs is not successfully created current code
prints an error message, this is removed. de is also not an error
pointer, so the IS_ERR() call leads to a static checker warning. The
unused return value of the msdc_debug_proc_init function is also removed.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove constant flag MSDC_HIGHSPEED
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:20 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove constant flag MSDC_HIGHSPEED

The MSDC_HIGHSPEED flag is always set and never unset, remove it to
clean up the code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused functions
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:19 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove unused functions

The functions msdc_eirq_cd and msdc_eirq_sdio are defined but never
used, so they are removed. This also fixes two compiler warnings:

drivers/staging/mt7621-mmc/sd.c:517:13: warning: ‘msdc_eirq_cd’ defined but
not used [-Wunused-function]
 static void msdc_eirq_cd(void *data)
             ^~~~~~~~~~~~
drivers/staging/mt7621-mmc/sd.c:507:13: warning: ‘msdc_eirq_sdio’ defined but
not used [-Wunused-function]
 static void msdc_eirq_sdio(void *data)

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused global: msdc_6575_host
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:18 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove unused global: msdc_6575_host

The mt6575_host variable is never used, only set and
exported. Removing it for code cleanup.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove constant flag
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:17 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove constant flag

The MSDC_SYS_SUSPEND flag is always set and is never unset. Removing
it cleans up the code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix power management by removing old api
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:16 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix power management by removing old api

The mmc_suspend|resume_host functions have been decrepated in the
3.11 [1] release and were completely removed in 3.13 [2]. Removing the
calls to this functions as it was done for other mmc host drivers
before the old api was removed (eg. [3]) fixes compile errors in this
driver while CONFIG_PM is enabled.

The rest of the removed code is simply dead, the MSDC_SYS_SUSPEND flag
is always set and will be removed in a later patch.

[1] commit 986892ca78ee ("mmc: core: Initiate suspend|resume from mmc bus instead of mmc host")
[2] commit 3c0d22e8180b ("mmc: core: Remove deprecated mmc_suspend|resume_host APIs")
[3] commit 1e63d4854202 ("mmc: au1xmmc: Move away from using deprecated APIs")

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove duplicate defines
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:43 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove duplicate defines

Remove defines that are both in board.h and sd.c from sd.c, this file
already includes board.h

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix requesting of irq
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:42 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix requesting of irq

The request of the irq line is not correctly handled by the current
code, platform_get_irq may fail and if the irq is requested via
devm_request_irq, its release is automatically done.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix dma_alloc_coherent should get device as first param
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:41 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix dma_alloc_coherent should get device as first param

The dma_alloc_coherent (and also dma_free_coherent) should get the
device, the dma memory is allocated for as the first parameter.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove dead codepath from probe function
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:40 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove dead codepath from probe function

The probe function contains lots of code, that is never used, because
the fields it checks for in the msdc_hw structure are never
initialized. Removing them should be safe.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix different caps for different devices
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:39 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix different caps for different devices

Current code saves the need for polling in a global variable, that
leeds to problems, when the driver should handle multiple devices with
different capabilities. By looking up the capability in the mmc_host
capabilities, they now have per device scope.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unnecessary field from struct msdc_hw
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:38 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove unnecessary field from struct msdc_hw

Remove the unnecessary field data_pins from msdc_hw, later this
information should be taken from the device tree.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unnecessary setting of dev.platform_data
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:37 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove unnecessary setting of dev.platform_data

In the probe function, pdev->dev.platform_data is set to &msdc0_hw,
but the only get access to that is also in the probe function. So that
assignment is removed. The msdc0_hw structure is still available to the
driver as part of the msdc_host structure.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix bug on dma_alloc_coherent fail
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:36 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix bug on dma_alloc_coherent fail

In case of dma_alloc_coherent failing the current code just called
BUG_ON. By adding error handling for that case this can be avoided.
This also fixes a memory leek in case of a fail later on in the probe
function.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix unmatched release_mem_regin
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:35 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix unmatched release_mem_regin

Current code calls release_mem_regin on driver remove without
requesting it explicit first. The region is only requested via
devm_ioremap_resource and that releases it automatically. Removing the
release_mem_region calls fixes this.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove code checking for old kernel versions
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:34 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove code checking for old kernel versions

Remove code, that is checking for old kernel versions, leaving only
the case for current versions.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix memory leek in case of error in probe
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:33 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix memory leek in case of error in probe

If the base address is not successfully obtained in the probe
function, then the mmc_host struct is not freed. Adding an exit for
that case fixes the bug.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Refactor suspend, resume
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:32 +0000 (22:15 +0200)]
staging: mt7621-mmc: Refactor suspend, resume

Refactor msdc_drv_{suspend, resume} by adding a new function
msdc_drv_pm, that cleans up the code and removes double code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Cleanup function mt_msdc_init
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:31 +0000 (22:15 +0200)]
staging: mt7621-mmc: Cleanup function mt_msdc_init

Cleanup the mt_msdc_init function, remove excceding printk.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused datastructures
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:30 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove unused datastructures

Remove unused datastructures and comments referring to their former use.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove code for different soc types
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:29 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove code for different soc types

Remove code that is intended for soc other then the mt7621 because
this driver is only for that soc. This also removes some conditions.
However the remaining code is also at the wrong place, it just selects
the mode of the pins, this is a job for pinctl not for the sdxc driver.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove code guarded by nonexistent config option
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:28 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove code guarded by nonexistent config option

Remove a piece of code that is guarded by a config option, that is
nonexistent, the function it calls is also nonexistent.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Replace seq_printf with seq_puts where possible
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:27 +0000 (22:15 +0200)]
staging: mt7621-mmc: Replace seq_printf with seq_puts where possible

Replace seq_printf with seq_puts when the string is const.
Fix checkpatch warning: PREFER_SEQ_PUTS

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove redundant driver owner assignment
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:26 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove redundant driver owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix style of braces
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:25 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix style of braces

Fix checkpatch errors, warnings, checks about braces:
BRACES, ELSE_AFTER_BRACE, OPEN_BRACE

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove global initialise to 0
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:24 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove global initialise to 0

Fix checkpatch error: GLOBAL_INITIALISERS

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix trailing statements
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:23 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix trailing statements

Fix checkpatch error: TRAILING_STATEMENTS

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unnecessary typedefs
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:22 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove unnecessary typedefs

Fixes checkpatch warning: NEW_TYPEDEFS

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix Pointer Location
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:21 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix Pointer Location

Fix checkpatch error: POINTER_LOCATION

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix spacing
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:20 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix spacing

Fixes checkpatch errors, warnings, checks:
SPACING, LEADING_SPACE, LINE_SPACING

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix indent for sd.c
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:19 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix indent for sd.c

This fixes the indentaions in the file sd.c

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix indent for mt6575_sd.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:18 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix indent for mt6575_sd.h

This fixes the indentaions in the file mt7621_sd.h

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix indent for dbg.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:17 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix indent for dbg.h

This fixes the indentaions in the file dbg.h

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix indent for board.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:16 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix indent for board.h

This fixes the indentaions in the file board.h

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix indent for dbg.c
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:15 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix indent for dbg.c

This fixes the indentaions in the file dbg.c

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove whitespace errors in sd.c
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:14 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove whitespace errors in sd.c

The whitespace errors in the file sd.c are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove whitespace errors in mt6575_sd.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:13 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove whitespace errors in mt6575_sd.h

The whitespace errors in the file mt6575_sd.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove whitespace errors in dbg.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:12 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove whitespace errors in dbg.h

The whitespace errors in the file dbg.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove whitespace errors in dbg.c
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:11 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove whitespace errors in dbg.c

The whitespace errors in the file dbg.c are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove whitespace errors in board.h
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:10 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove whitespace errors in board.h

The whitespace errors in the file board.h are fixed by using the
cleanfile script. Indentations with whitespaces are not changed
in this patch.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: prefer unsigned int to bare unsigned
Sergio Paracuellos [Mon, 2 Apr 2018 05:23:12 +0000 (07:23 +0200)]
staging: mt7621-gpio: prefer unsigned int to bare unsigned

This commit replaces some bare unsigned definitions in some
function parameters in favour of 'unsigned int' which is
preferred.

This also fix checkpatch warnings about this.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-pci: Hack 2 more PCI interrupts for gnubee1
NeilBrown [Mon, 2 Apr 2018 00:20:15 +0000 (10:20 +1000)]
staging: mt7621-pci: Hack 2 more PCI interrupts for gnubee1

The mt7621-pci support 3 pci devices and has 3 interrupts.
Each of these need to be enabled by the same sort of hack to
map hwirq number to virq number.
This is a hack which will go as soon as I understand how this is
supposed to work.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-eth: Fix sparse warning in ethtool.c
Chris Coffey [Thu, 29 Mar 2018 12:47:45 +0000 (13:47 +0100)]
staging: mt7621-eth: Fix sparse warning in ethtool.c

This fixes the following sparse warning:

drivers/staging/mt7621-eth/ethtool.c:213:6: warning: symbol
'mtk_set_ethtool_ops' was not declared. Should it be static?

Signed-off-by: Chris Coffey <cmc@babblebit.net>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vt6655: remove unnecessary line breaks in function definition.
Danilo Alves [Sat, 7 Apr 2018 14:55:15 +0000 (11:55 -0300)]
staging: vt6655: remove unnecessary line breaks in function definition.

This patch corrects the function definition style of CARDvSafeResetRx.
Issue found by checkpatch.

CHECK: Lines should not end with a '('

Signed-off-by: Danilo Alves <daniloalves@riseup.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vt6655: add handling memory leak on vnt_start()
Ji-Hun Kim [Thu, 5 Apr 2018 07:09:20 +0000 (16:09 +0900)]
staging: vt6655: add handling memory leak on vnt_start()

There was no code for handling memory leaks of device_init_rings() and
request_irq(). It needs to free allocated memory in the device_init_rings()
, when request_irq() would be failed. Add freeing sequences of irq and
device init rings.

Signed-off-by: Ji-Hun Kim <ji_hun.kim@samsung.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vt6655: check for memory allocation failures
Ji-Hun Kim [Thu, 5 Apr 2018 07:09:19 +0000 (16:09 +0900)]
staging: vt6655: check for memory allocation failures

There are no null pointer checking on rd_info and td_info values which
are allocated by kzalloc. It has potential null pointer dereferencing
issues. Implement error handling code on device_init_rd*, device_init_td*
and vnt_start for the allocation failures.

Signed-off-by: Ji-Hun Kim <ji_hun.kim@samsung.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: add container_of_safe()
NeilBrown [Thu, 29 Mar 2018 04:26:48 +0000 (15:26 +1100)]
staging: lustre: add container_of_safe()

Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
    surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: rearrange placement of CPU partition management code.
NeilBrown [Mon, 16 Apr 2018 00:42:37 +0000 (10:42 +1000)]
staging: lustre: rearrange placement of CPU partition management code.

Currently the code for cpu-partition tables lives in various places.
The non-SMP code is partly in libcfs/libcfs_cpu.h as static inlines,
and partly in lnet/libcfs/libcfs_cpu.c - some of the functions are
tiny and could well be inlines.

The SMP code is all in lnet/libcfs/linux/linux-cpu.c.

This patch moves all the trivial non-SMP functions into
libcfs_cpu.h as inlines, and all the SMP functions into libcfs_cpu.c
with the non-trival !SMP code.

Now when you go looking for some function, it is easier to find both
versions together when neither is trivial.

There is no code change here - just code movement.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: remove include/linux/libcfs/linux/linux-cpu.h
NeilBrown [Mon, 16 Apr 2018 00:42:37 +0000 (10:42 +1000)]
staging: lustre: remove include/linux/libcfs/linux/linux-cpu.h

This include file contains definitions used when CONFIG_SMP
is in effect.  Other includes contain corresponding definitions
for when it isn't.
This can be hard to follow, so move the definitions to the one place.

As HAVE_LIBCFS_CPT is defined precisely when CONFIG_SMP, we discard
that macro and just use CONFIG_SMP when needed.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: convert osc_quota hash to rhashtable
NeilBrown [Wed, 11 Apr 2018 21:54:48 +0000 (07:54 +1000)]
staging: lustre: convert osc_quota hash to rhashtable

As this is indexed by an integer, an extensible array
or extensible bitmap would be better.
If/when xarray lands, we should change to use that.

For now, just a simple conversion to rhashtable.

When removing an entry, we need to hold rcu_read_lock()
across the lookup and remove in case we race with another thread
performing a removal.  This means we need to use call_rcu()
to free the quota info so we need an rcu_head in there, which
unfortunately doubles the size of the structure.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: convert obd uuid hash to rhashtable
NeilBrown [Wed, 11 Apr 2018 21:54:48 +0000 (07:54 +1000)]
staging: lustre: convert obd uuid hash to rhashtable

The rhashtable data type is a perfect fit for the
export uuid hash table, so use that instead of
cfs_hash (which will eventually be removed).

As rhashtable supports lookups and insertions in atomic
context, there is no need to drop a spinlock while
inserting a new entry, which simplifies code quite a bit.

As there are no simple lookups on this hash table (only
insertions which might fail and take a spinlock), there is
no need to use rcu to free the exports.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: convert lov_pool to use rhashtable
NeilBrown [Wed, 11 Apr 2018 21:54:48 +0000 (07:54 +1000)]
staging: lustre: convert lov_pool to use rhashtable

The pools hashtable can be implemented using
the rhashtable implementation in lib.
This has the benefit that lookups are lock-free.

We need to use kfree_rcu() to free a pool so
that a lookup racing with a deletion will not access
freed memory.

rhashtable has no combined lookup-and-delete interface,
but as the lookup is lockless and the chains are short,
this brings little cost.  Even if a lookup finds a pool,
we must be prepared for the delete to fail to find it,
as we might race with another thread doing a delete.

We use atomic_inc_not_zero() after finding a pool in the
hash table and if that fails, we must have raced with a
deletion, so we treat the lookup as a failure.

Use hashlen_string() rather than a hand-crafted hash
function.
Note that the pool_name, and the search key, are
guaranteed to be nul terminated.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: ptlrpc: convert conn_hash to rhashtable
NeilBrown [Wed, 11 Apr 2018 21:54:48 +0000 (07:54 +1000)]
staging: lustre: ptlrpc: convert conn_hash to rhashtable

Linux has a resizeable hashtable implementation in lib,
so we should use that instead of having one in libcfs.

This patch converts the ptlrpc conn_hash to use rhashtable.
In the process we gain lockless lookup.

As connections are never deleted until the hash table is destroyed,
there is no need to count the reference in the hash table.  There
is also no need to enable automatic_shrinking.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: remove libcfs/linux/libcfs.h
NeilBrown [Mon, 16 Apr 2018 00:42:37 +0000 (10:42 +1000)]
staging: lustre: remove libcfs/linux/libcfs.h

This include file is only included in one place,
and only contains a list of other include directives.
So just move all those to the place where this file
is included, and discard the file.

One include directive uses a local name ("linux-cpu.h"), so
that needs to be given a proper path.

Probably many of these should be remove from here, and moved to
just the files that need them.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: move stack-check macros to libcfs_debug.h
NeilBrown [Mon, 16 Apr 2018 00:42:37 +0000 (10:42 +1000)]
staging: lustre: move stack-check macros to libcfs_debug.h

CDEBUG_STACK() and CHECK_STACK() are macros to help with
debugging, so move them from
   drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
to
   drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h

This seems a more fitting location, and is a step towards
removing linux/libcfs.h and simplifying the include file structure.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: correct removexattr detection
James Simmons [Mon, 16 Apr 2018 04:15:10 +0000 (00:15 -0400)]
staging: lustre: llite: correct removexattr detection

In ll_xattr_set_common() detect the removexattr() case correctly by
testing for a NULL value as well as XATTR_REPLACE.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10787
Reviewed-on: https://review.whamcloud.com/
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: use xattr_handler name for ACLs
John L. Hammond [Mon, 16 Apr 2018 04:15:09 +0000 (00:15 -0400)]
staging: lustre: llite: use xattr_handler name for ACLs

If struct xattr_handler has a name member then use it (rather than
prefix) for the ACL xattrs. This avoids a bug where ACL operations
failed for some kernels.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10785
Reviewed-on: https://review.whamcloud.com/
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: style changes in xattr.c
James Simmons [Mon, 16 Apr 2018 04:15:07 +0000 (00:15 -0400)]
staging: lustre: llite: style changes in xattr.c

Small style changes to match more the kernel code standard
and it make it more readable.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: cleanup xattr code comments
James Simmons [Mon, 16 Apr 2018 04:15:06 +0000 (00:15 -0400)]
staging: lustre: llite: cleanup xattr code comments

Add proper punctuation to the comments. Change buf_size to size
for comment in ll_listxattr() since buf_size doesn't exit which
will confuse someone reading the code.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: use proper types in the xattr code
James Simmons [Mon, 16 Apr 2018 04:15:05 +0000 (00:15 -0400)]
staging: lustre: llite: use proper types in the xattr code

Convert __uXX types to uXX types since this is kernel code.
The function ll_lov_user_md_size() returns ssize_t so change
lum_size from int to ssize_t.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: cleanup posix acl xattr code
James Simmons [Mon, 16 Apr 2018 04:15:04 +0000 (00:15 -0400)]
staging: lustre: llite: cleanup posix acl xattr code

Having an extra ifdef makes the code harder to read. For the case
of ll_xattr_get_common() we have a variable initialized at the
start of the function but it is only used in XATTR_ACL_ACCESS_T
code block. Lets move that variable to that location since its
only used there and make the code look cleaner.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: record in stats attempted removal of lma/link xattr
James Simmons [Mon, 16 Apr 2018 04:15:03 +0000 (00:15 -0400)]
staging: lustre: llite: record in stats attempted removal of lma/link xattr

Keep track of attempted deletions as well as changing of the
lma/link xattrs.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: remove newline in fullname strings
James Simmons [Mon, 16 Apr 2018 04:15:02 +0000 (00:15 -0400)]
staging: lustre: llite: remove newline in fullname strings

In creating the full name of a xattr a new line was added that
was seen by the remote MDS server which confused it. Remove the
newline.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: fix invalid size test in ll_setstripe_ea()
James Simmons [Mon, 16 Apr 2018 04:15:01 +0000 (00:15 -0400)]
staging: lustre: llite: fix invalid size test in ll_setstripe_ea()

The size check at the start of ll_setstripe_ea() is only
valid for a directory. Move that check to the section of
code handling the S_ISDIR case.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: eat -EEXIST on setting trusted.lov
Bobi Jam [Mon, 16 Apr 2018 04:15:00 +0000 (00:15 -0400)]
staging: lustre: llite: eat -EEXIST on setting trusted.lov

Tools like rsync, tar, cp may copy and restore the xattrs on a file.
The client previously ignored the setting of trusted.lov/lustre.lov
if the layout had already been specified, to avoid causing these
tools to fail for no reason.

For PFL files we still need to silently eat -EEXIST on setting these
attributes to avoid problems.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9484
Reviewed-on: https://review.whamcloud.com/27126
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: return from ll_adjust_lum() if lump is NULL
Bobi Jam [Mon, 16 Apr 2018 04:14:59 +0000 (00:14 -0400)]
staging: lustre: llite: return from ll_adjust_lum() if lump is NULL

No need to check several times if lump is NULL. Just test once and
return 0 if NULL.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9484
Reviewed-on: https://review.whamcloud.com/27126
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: break up ll_setstripe_ea function
Bobi Jam [Mon, 16 Apr 2018 04:14:58 +0000 (00:14 -0400)]
staging: lustre: llite: break up ll_setstripe_ea function

Place all the handling of information of trusted.lov that
is not stripe related into the new function ll_adjust_lum().
Now ll_setstripe_ea() only handles striping information.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9484
Reviewed-on: https://review.whamcloud.com/27126
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: add simple comment about lustre.lov xattrs
Niu Yawei [Mon, 16 Apr 2018 04:14:57 +0000 (00:14 -0400)]
staging: lustre: llite: add simple comment about lustre.lov xattrs

Simple comment added to ll_xattr_set.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8998
Reviewed-on: https://review.whamcloud.com/24851
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: refactor lustre.lov xattr handling
Niu Yawei [Mon, 16 Apr 2018 04:14:56 +0000 (00:14 -0400)]
staging: lustre: llite: refactor lustre.lov xattr handling

The function ll_xattr_set() contains special code to handle
the lustre specific xattr lustre.lov. Move all this code to
a new function ll_setstripe_ea().

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8998
Reviewed-on: https://review.whamcloud.com/24851
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: lustre: llite: Remove filtering of seclabel xattr
Robin Humble [Mon, 16 Apr 2018 04:14:55 +0000 (00:14 -0400)]
staging: lustre: llite: Remove filtering of seclabel xattr

The security.capability xattr is used to implement File
Capabilities in recent Linux versions. Capabilities are a
fine grained approach to granting executables elevated
privileges. eg. /bin/ping can have capabilities
cap_net_admin, cap_net_raw+ep instead of being setuid root.

This xattr has long been filtered out by llite, initially for
stability reasons (b15587), and later over performance
concerns as this xattr is read for every file with eg.
'ls --color'. Since LU-2869 xattr's are cached on clients,
alleviating most performance concerns.

Removing llite's filtering of the security.capability xattr
enables using Lustre as a root filesystem, which is used on
some large clusters.

Signed-off-by: Robin Humble <plaguedbypenguins@gmail.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9562
Reviewed-on: https://review.whamcloud.com/27292
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>