Netdev List
 help / color / mirror / Atom feed
* [PATCH 00/61] tree-wide: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-ide, alsa-devel, linux-iio, kernel-janitors, linux-fbdev,
	dri-devel, platform-driver-x86, Wolfram Sang, linux-mtd,
	linux-clk, ac100, devel, linux-samsung-soc, linux-rockchip,
	linux-serial, linux-input, linux-media, linux-pwm, linux-watchdog,
	linux-pm, linux-arm-msm, acpi4asus-user, greybus-dev,
	linux-mediatek, linux-tegra, linux-omap, linux-soc,
	linux-arm-kernel, linu

I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after <n> iterations by manually checking
samples):

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-	struct platform_device *pdev = to_platform_device(d);
|
-	struct platform_device *pdev;
	...
-	pdev = to_platform_device(d);
)
	<... when != pdev
-	&pdev->dev
+	d
	...>

	ptr =
-	platform_get_drvdata(pdev)
+	dev_get_drvdata(d)

	<... when != pdev
-	&pdev->dev
+	d
	...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c                        |  3 +-
 drivers/ata/pata_samsung_cf.c                      |  8 ++---
 drivers/auxdisplay/arm-charlcd.c                   |  6 ++--
 drivers/bus/brcmstb_gisb.c                         | 12 +++----
 drivers/clk/samsung/clk-s3c2410-dclk.c             |  6 ++--
 drivers/crypto/exynos-rng.c                        |  6 ++--
 drivers/crypto/picoxcell_crypto.c                  |  6 ++--
 drivers/dma/at_hdmac.c                             |  9 ++---
 drivers/dma/at_xdmac.c                             |  9 ++---
 drivers/dma/dw/platform.c                          |  6 ++--
 drivers/dma/fsldma.c                               |  6 ++--
 drivers/dma/idma64.c                               |  6 ++--
 drivers/dma/qcom/hidma.c                           |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c                  |  6 ++--
 drivers/dma/ste_dma40.c                            | 12 +++----
 drivers/dma/txx9dmac.c                             |  8 ++---
 drivers/gpio/gpio-dwapb.c                          |  6 ++--
 drivers/gpio/gpio-lynxpoint.c                      |  3 +-
 drivers/gpio/gpio-omap.c                           | 12 +++----
 drivers/gpio/gpio-tegra.c                          |  6 ++--
 drivers/gpio/gpio-zynq.c                           |  6 ++--
 drivers/gpu/drm/msm/adreno/adreno_device.c         |  6 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c           |  6 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c                 |  6 ++--
 drivers/gpu/drm/msm/msm_drv.c                      |  3 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ++++------
 drivers/gpu/drm/vc4/vc4_drv.c                      |  3 +-
 drivers/hid/hid-sensor-custom.c                    | 12 +++----
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  |  6 ++--
 .../iio/common/hid-sensors/hid-sensor-trigger.c    |  9 ++---
 drivers/input/keyboard/ep93xx_keypad.c             | 10 +++---
 drivers/input/keyboard/imx_keypad.c                | 10 +++---
 drivers/input/keyboard/lpc32xx-keys.c              |  6 ++--
 drivers/input/keyboard/matrix_keypad.c             | 10 +++---
 drivers/input/keyboard/omap4-keypad.c              | 10 +++---
 drivers/input/keyboard/pmic8xxx-keypad.c           |  6 ++--
 drivers/input/keyboard/pxa27x_keypad.c             | 10 +++---
 drivers/input/keyboard/samsung-keypad.c            | 12 +++----
 drivers/input/keyboard/snvs_pwrkey.c               | 10 +++---
 drivers/input/keyboard/spear-keyboard.c            | 10 +++---
 drivers/input/keyboard/st-keyscan.c                |  6 ++--
 drivers/input/keyboard/tegra-kbc.c                 | 10 +++---
 drivers/input/misc/max77693-haptic.c               |  6 ++--
 drivers/input/misc/max8997_haptic.c                |  3 +-
 drivers/input/misc/palmas-pwrbutton.c              |  6 ++--
 drivers/input/misc/regulator-haptic.c              |  6 ++--
 drivers/input/misc/twl4030-vibra.c                 |  3 +-
 drivers/input/misc/twl6040-vibra.c                 |  3 +-
 drivers/input/mouse/navpoint.c                     |  6 ++--
 drivers/input/touchscreen/imx6ul_tsc.c             |  6 ++--
 drivers/iommu/qcom_iommu.c                         |  6 ++--
 drivers/media/platform/am437x/am437x-vpfe.c        |  6 ++--
 drivers/media/platform/exynos4-is/media-dev.c      |  6 ++--
 drivers/media/platform/exynos4-is/mipi-csis.c      |  6 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  6 ++--
 drivers/mmc/host/davinci_mmc.c                     |  6 ++--
 drivers/mmc/host/sdhci-of-arasan.c                 |  6 ++--
 drivers/mmc/host/wmt-sdmmc.c                       |  6 ++--
 drivers/mtd/devices/docg3.c                        |  3 +-
 drivers/mtd/nand/onenand/samsung.c                 |  6 ++--
 drivers/net/dsa/bcm_sf2.c                          |  6 ++--
 drivers/net/dsa/qca8k.c                            |  6 ++--
 drivers/net/ethernet/cadence/macb_main.c           |  6 ++--
 drivers/net/ethernet/davicom/dm9000.c              |  6 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  3 +-
 drivers/net/ethernet/ti/cpsw.c                     |  6 ++--
 drivers/net/ethernet/ti/davinci_emac.c             |  6 ++--
 drivers/net/ethernet/wiznet/w5300.c                |  6 ++--
 drivers/perf/arm_spe_pmu.c                         |  6 ++--
 drivers/pinctrl/intel/pinctrl-baytrail.c           |  6 ++--
 drivers/pinctrl/intel/pinctrl-cherryview.c         |  6 ++--
 drivers/pinctrl/intel/pinctrl-intel.c              |  6 ++--
 drivers/pinctrl/pinctrl-amd.c                      |  6 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  6 ++--
 drivers/platform/x86/asus-laptop.c                 |  3 +-
 drivers/platform/x86/asus-wmi.c                    |  3 +-
 drivers/platform/x86/samsung-laptop.c              |  3 +-
 drivers/power/supply/gpio-charger.c                |  3 +-
 drivers/ptp/ptp_dte.c                              |  6 ++--
 drivers/pwm/pwm-atmel-tcb.c                        |  6 ++--
 drivers/pwm/pwm-rcar.c                             |  3 +-
 drivers/rtc/rtc-bq4802.c                           |  6 ++--
 drivers/rtc/rtc-ds1216.c                           |  6 ++--
 drivers/rtc/rtc-ds1511.c                           |  9 ++---
 drivers/rtc/rtc-ds1553.c                           | 15 +++-----
 drivers/rtc/rtc-ds1685.c                           | 21 ++++-------
 drivers/rtc/rtc-ds1742.c                           |  6 ++--
 drivers/rtc/rtc-lpc32xx.c                          | 16 ++++-----
 drivers/rtc/rtc-m48t59.c                           | 41 +++++++++-------------
 drivers/rtc/rtc-mv.c                               |  3 +-
 drivers/rtc/rtc-mxc.c                              | 21 ++++-------
 drivers/rtc/rtc-pcap.c                             | 15 +++-----
 drivers/rtc/rtc-sh.c                               | 15 +++-----
 drivers/rtc/rtc-stk17ta8.c                         | 15 +++-----
 drivers/rtc/rtc-test.c                             |  3 +-
 drivers/rtc/rtc-zynqmp.c                           | 10 +++---
 drivers/slimbus/qcom-ctrl.c                        |  6 ++--
 drivers/spi/spi-cadence.c                          |  6 ++--
 drivers/spi/spi-zynqmp-gqspi.c                     |  6 ++--
 drivers/staging/greybus/arche-platform.c           |  3 +-
 drivers/staging/iio/adc/ad7606_par.c               |  6 ++--
 drivers/staging/nvec/nvec.c                        |  6 ++--
 drivers/thermal/int340x_thermal/int3400_thermal.c  |  9 ++---
 drivers/thermal/rockchip_thermal.c                 |  8 ++---
 drivers/thermal/spear_thermal.c                    |  8 ++---
 drivers/thermal/st/st_thermal.c                    |  6 ++--
 drivers/thermal/zx2967_thermal.c                   |  6 ++--
 drivers/tty/serial/imx.c                           | 18 ++++------
 drivers/tty/serial/qcom_geni_serial.c              |  6 ++--
 drivers/tty/serial/st-asc.c                        |  6 ++--
 drivers/tty/serial/xilinx_uartps.c                 |  6 ++--
 drivers/uio/uio_fsl_elbc_gpcm.c                    |  6 ++--
 drivers/usb/mtu3/mtu3_plat.c                       |  6 ++--
 drivers/usb/phy/phy-am335x.c                       |  6 ++--
 drivers/video/fbdev/auo_k190x.c                    | 12 +++----
 .../fbdev/omap2/omapfb/displays/panel-dsi-cm.c     | 18 ++++------
 drivers/video/fbdev/sh_mobile_lcdcfb.c             |  6 ++--
 drivers/video/fbdev/sh_mobile_meram.c              |  6 ++--
 drivers/watchdog/cadence_wdt.c                     |  6 ++--
 drivers/watchdog/of_xilinx_wdt.c                   |  6 ++--
 drivers/watchdog/wdat_wdt.c                        |  6 ++--
 net/dsa/legacy.c                                   |  6 ++--
 sound/soc/atmel/atmel_ssc_dai.c                    |  6 ++--
 123 files changed, 319 insertions(+), 607 deletions(-)

-- 
2.11.0

^ permalink raw reply

* [PATCH 00/61] tree-wide: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-ide-u79uwXL29TY76Z2rM5mHXA,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-fbdev-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	platform-driver-x86-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-clk-u79uwXL29TY76Z2rM5mHXA,
	ac100-oU9gvf+ajcQ97yFScArB1dHuzzzSOjJt,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-media-u79uwXL29TY76Z2rM5mHXA,
	linux-pwm-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	greybus-dev-cunTk1MwBs8s++Sfvej+rw,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-soc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linu

I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after <n> iterations by manually checking
samples):

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-	struct platform_device *pdev = to_platform_device(d);
|
-	struct platform_device *pdev;
	...
-	pdev = to_platform_device(d);
)
	<... when != pdev
-	&pdev->dev
+	d
	...>

	ptr =
-	platform_get_drvdata(pdev)
+	dev_get_drvdata(d)

	<... when != pdev
-	&pdev->dev
+	d
	...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c                        |  3 +-
 drivers/ata/pata_samsung_cf.c                      |  8 ++---
 drivers/auxdisplay/arm-charlcd.c                   |  6 ++--
 drivers/bus/brcmstb_gisb.c                         | 12 +++----
 drivers/clk/samsung/clk-s3c2410-dclk.c             |  6 ++--
 drivers/crypto/exynos-rng.c                        |  6 ++--
 drivers/crypto/picoxcell_crypto.c                  |  6 ++--
 drivers/dma/at_hdmac.c                             |  9 ++---
 drivers/dma/at_xdmac.c                             |  9 ++---
 drivers/dma/dw/platform.c                          |  6 ++--
 drivers/dma/fsldma.c                               |  6 ++--
 drivers/dma/idma64.c                               |  6 ++--
 drivers/dma/qcom/hidma.c                           |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c                  |  6 ++--
 drivers/dma/ste_dma40.c                            | 12 +++----
 drivers/dma/txx9dmac.c                             |  8 ++---
 drivers/gpio/gpio-dwapb.c                          |  6 ++--
 drivers/gpio/gpio-lynxpoint.c                      |  3 +-
 drivers/gpio/gpio-omap.c                           | 12 +++----
 drivers/gpio/gpio-tegra.c                          |  6 ++--
 drivers/gpio/gpio-zynq.c                           |  6 ++--
 drivers/gpu/drm/msm/adreno/adreno_device.c         |  6 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c           |  6 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c                 |  6 ++--
 drivers/gpu/drm/msm/msm_drv.c                      |  3 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ++++------
 drivers/gpu/drm/vc4/vc4_drv.c                      |  3 +-
 drivers/hid/hid-sensor-custom.c                    | 12 +++----
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  |  6 ++--
 .../iio/common/hid-sensors/hid-sensor-trigger.c    |  9 ++---
 drivers/input/keyboard/ep93xx_keypad.c             | 10 +++---
 drivers/input/keyboard/imx_keypad.c                | 10 +++---
 drivers/input/keyboard/lpc32xx-keys.c              |  6 ++--
 drivers/input/keyboard/matrix_keypad.c             | 10 +++---
 drivers/input/keyboard/omap4-keypad.c              | 10 +++---
 drivers/input/keyboard/pmic8xxx-keypad.c           |  6 ++--
 drivers/input/keyboard/pxa27x_keypad.c             | 10 +++---
 drivers/input/keyboard/samsung-keypad.c            | 12 +++----
 drivers/input/keyboard/snvs_pwrkey.c               | 10 +++---
 drivers/input/keyboard/spear-keyboard.c            | 10 +++---
 drivers/input/keyboard/st-keyscan.c                |  6 ++--
 drivers/input/keyboard/tegra-kbc.c                 | 10 +++---
 drivers/input/misc/max77693-haptic.c               |  6 ++--
 drivers/input/misc/max8997_haptic.c                |  3 +-
 drivers/input/misc/palmas-pwrbutton.c              |  6 ++--
 drivers/input/misc/regulator-haptic.c              |  6 ++--
 drivers/input/misc/twl4030-vibra.c                 |  3 +-
 drivers/input/misc/twl6040-vibra.c                 |  3 +-
 drivers/input/mouse/navpoint.c                     |  6 ++--
 drivers/input/touchscreen/imx6ul_tsc.c             |  6 ++--
 drivers/iommu/qcom_iommu.c                         |  6 ++--
 drivers/media/platform/am437x/am437x-vpfe.c        |  6 ++--
 drivers/media/platform/exynos4-is/media-dev.c      |  6 ++--
 drivers/media/platform/exynos4-is/mipi-csis.c      |  6 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  6 ++--
 drivers/mmc/host/davinci_mmc.c                     |  6 ++--
 drivers/mmc/host/sdhci-of-arasan.c                 |  6 ++--
 drivers/mmc/host/wmt-sdmmc.c                       |  6 ++--
 drivers/mtd/devices/docg3.c                        |  3 +-
 drivers/mtd/nand/onenand/samsung.c                 |  6 ++--
 drivers/net/dsa/bcm_sf2.c                          |  6 ++--
 drivers/net/dsa/qca8k.c                            |  6 ++--
 drivers/net/ethernet/cadence/macb_main.c           |  6 ++--
 drivers/net/ethernet/davicom/dm9000.c              |  6 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  3 +-
 drivers/net/ethernet/ti/cpsw.c                     |  6 ++--
 drivers/net/ethernet/ti/davinci_emac.c             |  6 ++--
 drivers/net/ethernet/wiznet/w5300.c                |  6 ++--
 drivers/perf/arm_spe_pmu.c                         |  6 ++--
 drivers/pinctrl/intel/pinctrl-baytrail.c           |  6 ++--
 drivers/pinctrl/intel/pinctrl-cherryview.c         |  6 ++--
 drivers/pinctrl/intel/pinctrl-intel.c              |  6 ++--
 drivers/pinctrl/pinctrl-amd.c                      |  6 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  6 ++--
 drivers/platform/x86/asus-laptop.c                 |  3 +-
 drivers/platform/x86/asus-wmi.c                    |  3 +-
 drivers/platform/x86/samsung-laptop.c              |  3 +-
 drivers/power/supply/gpio-charger.c                |  3 +-
 drivers/ptp/ptp_dte.c                              |  6 ++--
 drivers/pwm/pwm-atmel-tcb.c                        |  6 ++--
 drivers/pwm/pwm-rcar.c                             |  3 +-
 drivers/rtc/rtc-bq4802.c                           |  6 ++--
 drivers/rtc/rtc-ds1216.c                           |  6 ++--
 drivers/rtc/rtc-ds1511.c                           |  9 ++---
 drivers/rtc/rtc-ds1553.c                           | 15 +++-----
 drivers/rtc/rtc-ds1685.c                           | 21 ++++-------
 drivers/rtc/rtc-ds1742.c                           |  6 ++--
 drivers/rtc/rtc-lpc32xx.c                          | 16 ++++-----
 drivers/rtc/rtc-m48t59.c                           | 41 +++++++++-------------
 drivers/rtc/rtc-mv.c                               |  3 +-
 drivers/rtc/rtc-mxc.c                              | 21 ++++-------
 drivers/rtc/rtc-pcap.c                             | 15 +++-----
 drivers/rtc/rtc-sh.c                               | 15 +++-----
 drivers/rtc/rtc-stk17ta8.c                         | 15 +++-----
 drivers/rtc/rtc-test.c                             |  3 +-
 drivers/rtc/rtc-zynqmp.c                           | 10 +++---
 drivers/slimbus/qcom-ctrl.c                        |  6 ++--
 drivers/spi/spi-cadence.c                          |  6 ++--
 drivers/spi/spi-zynqmp-gqspi.c                     |  6 ++--
 drivers/staging/greybus/arche-platform.c           |  3 +-
 drivers/staging/iio/adc/ad7606_par.c               |  6 ++--
 drivers/staging/nvec/nvec.c                        |  6 ++--
 drivers/thermal/int340x_thermal/int3400_thermal.c  |  9 ++---
 drivers/thermal/rockchip_thermal.c                 |  8 ++---
 drivers/thermal/spear_thermal.c                    |  8 ++---
 drivers/thermal/st/st_thermal.c                    |  6 ++--
 drivers/thermal/zx2967_thermal.c                   |  6 ++--
 drivers/tty/serial/imx.c                           | 18 ++++------
 drivers/tty/serial/qcom_geni_serial.c              |  6 ++--
 drivers/tty/serial/st-asc.c                        |  6 ++--
 drivers/tty/serial/xilinx_uartps.c                 |  6 ++--
 drivers/uio/uio_fsl_elbc_gpcm.c                    |  6 ++--
 drivers/usb/mtu3/mtu3_plat.c                       |  6 ++--
 drivers/usb/phy/phy-am335x.c                       |  6 ++--
 drivers/video/fbdev/auo_k190x.c                    | 12 +++----
 .../fbdev/omap2/omapfb/displays/panel-dsi-cm.c     | 18 ++++------
 drivers/video/fbdev/sh_mobile_lcdcfb.c             |  6 ++--
 drivers/video/fbdev/sh_mobile_meram.c              |  6 ++--
 drivers/watchdog/cadence_wdt.c                     |  6 ++--
 drivers/watchdog/of_xilinx_wdt.c                   |  6 ++--
 drivers/watchdog/wdat_wdt.c                        |  6 ++--
 net/dsa/legacy.c                                   |  6 ++--
 sound/soc/atmel/atmel_ssc_dai.c                    |  6 ++--
 123 files changed, 319 insertions(+), 607 deletions(-)

-- 
2.11.0

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply

* [PATCH 00/61] tree-wide: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-ide, alsa-devel, linux-iio, kernel-janitors, linux-fbdev,
	dri-devel, platform-driver-x86, Wolfram Sang, linux-mtd,
	linux-clk, ac100, devel, linux-samsung-soc, linux-rockchip,
	linux-serial, linux-input, linux-media, linux-pwm, linux-watchdog,
	linux-pm, linux-arm-msm, acpi4asus-user, greybus-dev,
	linux-mediatek, linux-tegra, linux-omap, linux-soc,
	linux-arm-kernel, linu

I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after <n> iterations by manually checking
samples):

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-	struct platform_device *pdev = to_platform_device(d);
|
-	struct platform_device *pdev;
	...
-	pdev = to_platform_device(d);
)
	<... when != pdev
-	&pdev->dev
+	d
	...>

	ptr =
-	platform_get_drvdata(pdev)
+	dev_get_drvdata(d)

	<... when != pdev
-	&pdev->dev
+	d
	...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c                        |  3 +-
 drivers/ata/pata_samsung_cf.c                      |  8 ++---
 drivers/auxdisplay/arm-charlcd.c                   |  6 ++--
 drivers/bus/brcmstb_gisb.c                         | 12 +++----
 drivers/clk/samsung/clk-s3c2410-dclk.c             |  6 ++--
 drivers/crypto/exynos-rng.c                        |  6 ++--
 drivers/crypto/picoxcell_crypto.c                  |  6 ++--
 drivers/dma/at_hdmac.c                             |  9 ++---
 drivers/dma/at_xdmac.c                             |  9 ++---
 drivers/dma/dw/platform.c                          |  6 ++--
 drivers/dma/fsldma.c                               |  6 ++--
 drivers/dma/idma64.c                               |  6 ++--
 drivers/dma/qcom/hidma.c                           |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c                  |  6 ++--
 drivers/dma/ste_dma40.c                            | 12 +++----
 drivers/dma/txx9dmac.c                             |  8 ++---
 drivers/gpio/gpio-dwapb.c                          |  6 ++--
 drivers/gpio/gpio-lynxpoint.c                      |  3 +-
 drivers/gpio/gpio-omap.c                           | 12 +++----
 drivers/gpio/gpio-tegra.c                          |  6 ++--
 drivers/gpio/gpio-zynq.c                           |  6 ++--
 drivers/gpu/drm/msm/adreno/adreno_device.c         |  6 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c           |  6 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c                 |  6 ++--
 drivers/gpu/drm/msm/msm_drv.c                      |  3 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ++++------
 drivers/gpu/drm/vc4/vc4_drv.c                      |  3 +-
 drivers/hid/hid-sensor-custom.c                    | 12 +++----
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  |  6 ++--
 .../iio/common/hid-sensors/hid-sensor-trigger.c    |  9 ++---
 drivers/input/keyboard/ep93xx_keypad.c             | 10 +++---
 drivers/input/keyboard/imx_keypad.c                | 10 +++---
 drivers/input/keyboard/lpc32xx-keys.c              |  6 ++--
 drivers/input/keyboard/matrix_keypad.c             | 10 +++---
 drivers/input/keyboard/omap4-keypad.c              | 10 +++---
 drivers/input/keyboard/pmic8xxx-keypad.c           |  6 ++--
 drivers/input/keyboard/pxa27x_keypad.c             | 10 +++---
 drivers/input/keyboard/samsung-keypad.c            | 12 +++----
 drivers/input/keyboard/snvs_pwrkey.c               | 10 +++---
 drivers/input/keyboard/spear-keyboard.c            | 10 +++---
 drivers/input/keyboard/st-keyscan.c                |  6 ++--
 drivers/input/keyboard/tegra-kbc.c                 | 10 +++---
 drivers/input/misc/max77693-haptic.c               |  6 ++--
 drivers/input/misc/max8997_haptic.c                |  3 +-
 drivers/input/misc/palmas-pwrbutton.c              |  6 ++--
 drivers/input/misc/regulator-haptic.c              |  6 ++--
 drivers/input/misc/twl4030-vibra.c                 |  3 +-
 drivers/input/misc/twl6040-vibra.c                 |  3 +-
 drivers/input/mouse/navpoint.c                     |  6 ++--
 drivers/input/touchscreen/imx6ul_tsc.c             |  6 ++--
 drivers/iommu/qcom_iommu.c                         |  6 ++--
 drivers/media/platform/am437x/am437x-vpfe.c        |  6 ++--
 drivers/media/platform/exynos4-is/media-dev.c      |  6 ++--
 drivers/media/platform/exynos4-is/mipi-csis.c      |  6 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  6 ++--
 drivers/mmc/host/davinci_mmc.c                     |  6 ++--
 drivers/mmc/host/sdhci-of-arasan.c                 |  6 ++--
 drivers/mmc/host/wmt-sdmmc.c                       |  6 ++--
 drivers/mtd/devices/docg3.c                        |  3 +-
 drivers/mtd/nand/onenand/samsung.c                 |  6 ++--
 drivers/net/dsa/bcm_sf2.c                          |  6 ++--
 drivers/net/dsa/qca8k.c                            |  6 ++--
 drivers/net/ethernet/cadence/macb_main.c           |  6 ++--
 drivers/net/ethernet/davicom/dm9000.c              |  6 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  3 +-
 drivers/net/ethernet/ti/cpsw.c                     |  6 ++--
 drivers/net/ethernet/ti/davinci_emac.c             |  6 ++--
 drivers/net/ethernet/wiznet/w5300.c                |  6 ++--
 drivers/perf/arm_spe_pmu.c                         |  6 ++--
 drivers/pinctrl/intel/pinctrl-baytrail.c           |  6 ++--
 drivers/pinctrl/intel/pinctrl-cherryview.c         |  6 ++--
 drivers/pinctrl/intel/pinctrl-intel.c              |  6 ++--
 drivers/pinctrl/pinctrl-amd.c                      |  6 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  6 ++--
 drivers/platform/x86/asus-laptop.c                 |  3 +-
 drivers/platform/x86/asus-wmi.c                    |  3 +-
 drivers/platform/x86/samsung-laptop.c              |  3 +-
 drivers/power/supply/gpio-charger.c                |  3 +-
 drivers/ptp/ptp_dte.c                              |  6 ++--
 drivers/pwm/pwm-atmel-tcb.c                        |  6 ++--
 drivers/pwm/pwm-rcar.c                             |  3 +-
 drivers/rtc/rtc-bq4802.c                           |  6 ++--
 drivers/rtc/rtc-ds1216.c                           |  6 ++--
 drivers/rtc/rtc-ds1511.c                           |  9 ++---
 drivers/rtc/rtc-ds1553.c                           | 15 +++-----
 drivers/rtc/rtc-ds1685.c                           | 21 ++++-------
 drivers/rtc/rtc-ds1742.c                           |  6 ++--
 drivers/rtc/rtc-lpc32xx.c                          | 16 ++++-----
 drivers/rtc/rtc-m48t59.c                           | 41 +++++++++-------------
 drivers/rtc/rtc-mv.c                               |  3 +-
 drivers/rtc/rtc-mxc.c                              | 21 ++++-------
 drivers/rtc/rtc-pcap.c                             | 15 +++-----
 drivers/rtc/rtc-sh.c                               | 15 +++-----
 drivers/rtc/rtc-stk17ta8.c                         | 15 +++-----
 drivers/rtc/rtc-test.c                             |  3 +-
 drivers/rtc/rtc-zynqmp.c                           | 10 +++---
 drivers/slimbus/qcom-ctrl.c                        |  6 ++--
 drivers/spi/spi-cadence.c                          |  6 ++--
 drivers/spi/spi-zynqmp-gqspi.c                     |  6 ++--
 drivers/staging/greybus/arche-platform.c           |  3 +-
 drivers/staging/iio/adc/ad7606_par.c               |  6 ++--
 drivers/staging/nvec/nvec.c                        |  6 ++--
 drivers/thermal/int340x_thermal/int3400_thermal.c  |  9 ++---
 drivers/thermal/rockchip_thermal.c                 |  8 ++---
 drivers/thermal/spear_thermal.c                    |  8 ++---
 drivers/thermal/st/st_thermal.c                    |  6 ++--
 drivers/thermal/zx2967_thermal.c                   |  6 ++--
 drivers/tty/serial/imx.c                           | 18 ++++------
 drivers/tty/serial/qcom_geni_serial.c              |  6 ++--
 drivers/tty/serial/st-asc.c                        |  6 ++--
 drivers/tty/serial/xilinx_uartps.c                 |  6 ++--
 drivers/uio/uio_fsl_elbc_gpcm.c                    |  6 ++--
 drivers/usb/mtu3/mtu3_plat.c                       |  6 ++--
 drivers/usb/phy/phy-am335x.c                       |  6 ++--
 drivers/video/fbdev/auo_k190x.c                    | 12 +++----
 .../fbdev/omap2/omapfb/displays/panel-dsi-cm.c     | 18 ++++------
 drivers/video/fbdev/sh_mobile_lcdcfb.c             |  6 ++--
 drivers/video/fbdev/sh_mobile_meram.c              |  6 ++--
 drivers/watchdog/cadence_wdt.c                     |  6 ++--
 drivers/watchdog/of_xilinx_wdt.c                   |  6 ++--
 drivers/watchdog/wdat_wdt.c                        |  6 ++--
 net/dsa/legacy.c                                   |  6 ++--
 sound/soc/atmel/atmel_ssc_dai.c                    |  6 ++--
 123 files changed, 319 insertions(+), 607 deletions(-)

-- 
2.11.0

^ permalink raw reply

* [PATCH 00/61] tree-wide: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-ide, alsa-devel, linux-iio, kernel-janitors, linux-fbdev,
	dri-devel, platform-driver-x86, Wolfram Sang, linux-mtd,
	linux-clk, ac100, devel, linux-samsung-soc, linux-rockchip,
	linux-serial, linux-input, linux-media, linux-pwm, linux-watchdog,
	linux-pm, linux-arm-msm, acpi4asus-user, greybus-dev,
	linux-mediatek, linux-tegra, linux-omap, linux-soc,
	linux-arm-kernel, linu

I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after <n> iterations by manually checking
samples):

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-	struct platform_device *pdev = to_platform_device(d);
|
-	struct platform_device *pdev;
	...
-	pdev = to_platform_device(d);
)
	<... when != pdev
-	&pdev->dev
+	d
	...>

	ptr =
-	platform_get_drvdata(pdev)
+	dev_get_drvdata(d)

	<... when != pdev
-	&pdev->dev
+	d
	...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c                        |  3 +-
 drivers/ata/pata_samsung_cf.c                      |  8 ++---
 drivers/auxdisplay/arm-charlcd.c                   |  6 ++--
 drivers/bus/brcmstb_gisb.c                         | 12 +++----
 drivers/clk/samsung/clk-s3c2410-dclk.c             |  6 ++--
 drivers/crypto/exynos-rng.c                        |  6 ++--
 drivers/crypto/picoxcell_crypto.c                  |  6 ++--
 drivers/dma/at_hdmac.c                             |  9 ++---
 drivers/dma/at_xdmac.c                             |  9 ++---
 drivers/dma/dw/platform.c                          |  6 ++--
 drivers/dma/fsldma.c                               |  6 ++--
 drivers/dma/idma64.c                               |  6 ++--
 drivers/dma/qcom/hidma.c                           |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c                  |  6 ++--
 drivers/dma/ste_dma40.c                            | 12 +++----
 drivers/dma/txx9dmac.c                             |  8 ++---
 drivers/gpio/gpio-dwapb.c                          |  6 ++--
 drivers/gpio/gpio-lynxpoint.c                      |  3 +-
 drivers/gpio/gpio-omap.c                           | 12 +++----
 drivers/gpio/gpio-tegra.c                          |  6 ++--
 drivers/gpio/gpio-zynq.c                           |  6 ++--
 drivers/gpu/drm/msm/adreno/adreno_device.c         |  6 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c           |  6 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c                 |  6 ++--
 drivers/gpu/drm/msm/msm_drv.c                      |  3 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ++++------
 drivers/gpu/drm/vc4/vc4_drv.c                      |  3 +-
 drivers/hid/hid-sensor-custom.c                    | 12 +++----
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  |  6 ++--
 .../iio/common/hid-sensors/hid-sensor-trigger.c    |  9 ++---
 drivers/input/keyboard/ep93xx_keypad.c             | 10 +++---
 drivers/input/keyboard/imx_keypad.c                | 10 +++---
 drivers/input/keyboard/lpc32xx-keys.c              |  6 ++--
 drivers/input/keyboard/matrix_keypad.c             | 10 +++---
 drivers/input/keyboard/omap4-keypad.c              | 10 +++---
 drivers/input/keyboard/pmic8xxx-keypad.c           |  6 ++--
 drivers/input/keyboard/pxa27x_keypad.c             | 10 +++---
 drivers/input/keyboard/samsung-keypad.c            | 12 +++----
 drivers/input/keyboard/snvs_pwrkey.c               | 10 +++---
 drivers/input/keyboard/spear-keyboard.c            | 10 +++---
 drivers/input/keyboard/st-keyscan.c                |  6 ++--
 drivers/input/keyboard/tegra-kbc.c                 | 10 +++---
 drivers/input/misc/max77693-haptic.c               |  6 ++--
 drivers/input/misc/max8997_haptic.c                |  3 +-
 drivers/input/misc/palmas-pwrbutton.c              |  6 ++--
 drivers/input/misc/regulator-haptic.c              |  6 ++--
 drivers/input/misc/twl4030-vibra.c                 |  3 +-
 drivers/input/misc/twl6040-vibra.c                 |  3 +-
 drivers/input/mouse/navpoint.c                     |  6 ++--
 drivers/input/touchscreen/imx6ul_tsc.c             |  6 ++--
 drivers/iommu/qcom_iommu.c                         |  6 ++--
 drivers/media/platform/am437x/am437x-vpfe.c        |  6 ++--
 drivers/media/platform/exynos4-is/media-dev.c      |  6 ++--
 drivers/media/platform/exynos4-is/mipi-csis.c      |  6 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  6 ++--
 drivers/mmc/host/davinci_mmc.c                     |  6 ++--
 drivers/mmc/host/sdhci-of-arasan.c                 |  6 ++--
 drivers/mmc/host/wmt-sdmmc.c                       |  6 ++--
 drivers/mtd/devices/docg3.c                        |  3 +-
 drivers/mtd/nand/onenand/samsung.c                 |  6 ++--
 drivers/net/dsa/bcm_sf2.c                          |  6 ++--
 drivers/net/dsa/qca8k.c                            |  6 ++--
 drivers/net/ethernet/cadence/macb_main.c           |  6 ++--
 drivers/net/ethernet/davicom/dm9000.c              |  6 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  3 +-
 drivers/net/ethernet/ti/cpsw.c                     |  6 ++--
 drivers/net/ethernet/ti/davinci_emac.c             |  6 ++--
 drivers/net/ethernet/wiznet/w5300.c                |  6 ++--
 drivers/perf/arm_spe_pmu.c                         |  6 ++--
 drivers/pinctrl/intel/pinctrl-baytrail.c           |  6 ++--
 drivers/pinctrl/intel/pinctrl-cherryview.c         |  6 ++--
 drivers/pinctrl/intel/pinctrl-intel.c              |  6 ++--
 drivers/pinctrl/pinctrl-amd.c                      |  6 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  6 ++--
 drivers/platform/x86/asus-laptop.c                 |  3 +-
 drivers/platform/x86/asus-wmi.c                    |  3 +-
 drivers/platform/x86/samsung-laptop.c              |  3 +-
 drivers/power/supply/gpio-charger.c                |  3 +-
 drivers/ptp/ptp_dte.c                              |  6 ++--
 drivers/pwm/pwm-atmel-tcb.c                        |  6 ++--
 drivers/pwm/pwm-rcar.c                             |  3 +-
 drivers/rtc/rtc-bq4802.c                           |  6 ++--
 drivers/rtc/rtc-ds1216.c                           |  6 ++--
 drivers/rtc/rtc-ds1511.c                           |  9 ++---
 drivers/rtc/rtc-ds1553.c                           | 15 +++-----
 drivers/rtc/rtc-ds1685.c                           | 21 ++++-------
 drivers/rtc/rtc-ds1742.c                           |  6 ++--
 drivers/rtc/rtc-lpc32xx.c                          | 16 ++++-----
 drivers/rtc/rtc-m48t59.c                           | 41 +++++++++-------------
 drivers/rtc/rtc-mv.c                               |  3 +-
 drivers/rtc/rtc-mxc.c                              | 21 ++++-------
 drivers/rtc/rtc-pcap.c                             | 15 +++-----
 drivers/rtc/rtc-sh.c                               | 15 +++-----
 drivers/rtc/rtc-stk17ta8.c                         | 15 +++-----
 drivers/rtc/rtc-test.c                             |  3 +-
 drivers/rtc/rtc-zynqmp.c                           | 10 +++---
 drivers/slimbus/qcom-ctrl.c                        |  6 ++--
 drivers/spi/spi-cadence.c                          |  6 ++--
 drivers/spi/spi-zynqmp-gqspi.c                     |  6 ++--
 drivers/staging/greybus/arche-platform.c           |  3 +-
 drivers/staging/iio/adc/ad7606_par.c               |  6 ++--
 drivers/staging/nvec/nvec.c                        |  6 ++--
 drivers/thermal/int340x_thermal/int3400_thermal.c  |  9 ++---
 drivers/thermal/rockchip_thermal.c                 |  8 ++---
 drivers/thermal/spear_thermal.c                    |  8 ++---
 drivers/thermal/st/st_thermal.c                    |  6 ++--
 drivers/thermal/zx2967_thermal.c                   |  6 ++--
 drivers/tty/serial/imx.c                           | 18 ++++------
 drivers/tty/serial/qcom_geni_serial.c              |  6 ++--
 drivers/tty/serial/st-asc.c                        |  6 ++--
 drivers/tty/serial/xilinx_uartps.c                 |  6 ++--
 drivers/uio/uio_fsl_elbc_gpcm.c                    |  6 ++--
 drivers/usb/mtu3/mtu3_plat.c                       |  6 ++--
 drivers/usb/phy/phy-am335x.c                       |  6 ++--
 drivers/video/fbdev/auo_k190x.c                    | 12 +++----
 .../fbdev/omap2/omapfb/displays/panel-dsi-cm.c     | 18 ++++------
 drivers/video/fbdev/sh_mobile_lcdcfb.c             |  6 ++--
 drivers/video/fbdev/sh_mobile_meram.c              |  6 ++--
 drivers/watchdog/cadence_wdt.c                     |  6 ++--
 drivers/watchdog/of_xilinx_wdt.c                   |  6 ++--
 drivers/watchdog/wdat_wdt.c                        |  6 ++--
 net/dsa/legacy.c                                   |  6 ++--
 sound/soc/atmel/atmel_ssc_dai.c                    |  6 ++--
 123 files changed, 319 insertions(+), 607 deletions(-)

-- 
2.11.0

^ permalink raw reply

* [PATCH net-next v2 2/4] net/smc: handle sockopt TCP_NODELAY
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20180419135655.3058-1-ubraun@linux.ibm.com>

From: Ursula Braun <ubraun@linux.vnet.ibm.com>

TCP sockopts set on the SMC socket must not interfere with the
CLC handshake on the internal CLC socket. Therefore, we defer some
of them till the CLC handshake has completed, like resetting
TCP_NODELAY.

While touching setsockopt, the TCP_FASTOPEN sockopts are
ignored, because SMC currently does not support Fast Open.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
---
 net/smc/af_smc.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 net/smc/smc.h    |   4 ++
 2 files changed, 123 insertions(+), 4 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 5f8046c62d90..297c2cb93b34 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -377,6 +377,24 @@ static void smc_link_save_peer_info(struct smc_link *link,
 	link->peer_mtu = clc->qp_mtu;
 }
 
+/* deferred setsockopt's not desired during clc handshake */
+static int smc_apply_deferred_sockopts(struct smc_sock *smc)
+{
+	struct smc_sock *opt_smc = smc;
+	int val, rc = 0;
+
+	if (smc->listen_smc)
+		opt_smc = smc->listen_smc;
+	if (opt_smc->deferred_nodelay_reset) {
+		val = 0;
+		rc = kernel_setsockopt(smc->clcsock, SOL_TCP, TCP_NODELAY,
+				       (char *)&val, sizeof(val));
+		if (!rc)
+			opt_smc->deferred_nodelay_reset = 0;
+	}
+	return rc;
+}
+
 /* setup for RDMA connection of client */
 static int smc_connect_rdma(struct smc_sock *smc)
 {
@@ -506,6 +524,7 @@ static int smc_connect_rdma(struct smc_sock *smc)
 	smc_tx_init(smc);
 
 out_connected:
+	rc = smc_apply_deferred_sockopts(smc);
 	smc_copy_sock_settings_to_clc(smc);
 	if (smc->sk.sk_state == SMC_INIT)
 		smc->sk.sk_state = SMC_ACTIVE;
@@ -908,6 +927,9 @@ static void smc_listen_work(struct work_struct *work)
 	mutex_unlock(&smc_create_lgr_pending);
 
 out_connected:
+	rc = smc_apply_deferred_sockopts(new_smc);
+	if (rc)
+		goto out_err;
 	sk_refcnt_debug_inc(newsmcsk);
 	if (newsmcsk->sk_state == SMC_INIT)
 		newsmcsk->sk_state = SMC_ACTIVE;
@@ -1280,23 +1302,111 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 {
 	struct sock *sk = sock->sk;
 	struct smc_sock *smc;
+	int val, rc = 0;
 
 	smc = smc_sk(sk);
+	if (smc->use_fallback || level != SOL_TCP)
+		goto clcsock;
+
+	/* level SOL_TCP */
+	switch (optname) {
+	case TCP_CONGESTION:
+	case TCP_ULP:
+		/* sockopts without integer value; do not apply to SMC */
+		goto clcsock;
+	default:
+		break;
+	}
+
+	if (optlen < sizeof(int))
+		return -EINVAL;
+	if (get_user(val, (int __user *)optval))
+		return -EFAULT;
+
+	lock_sock(sk);
+	switch (optname) {
+	case TCP_NODELAY:
+		if (sk->sk_state != SMC_INIT && sk->sk_state != SMC_LISTEN) {
+			release_sock(sk);
+			goto clcsock;
+		}
+		/* for the CLC-handshake TCP_NODELAY is desired;
+		 * in case of fallback to TCP, a nodelay reset is
+		 * triggered afterwards.
+		 */
+		if (val)
+			smc->deferred_nodelay_reset = 0;
+		else
+			smc->deferred_nodelay_reset = 1;
+		break;
+	case TCP_FASTOPEN:
+	case TCP_FASTOPEN_CONNECT:
+	case TCP_FASTOPEN_KEY:
+	case TCP_FASTOPEN_NO_COOKIE:
+		/* ignore these options; 3-way handshake shouldn't be
+		 * bypassed with SMC
+		 */
+		rc = -EOPNOTSUPP;
+		break;
+	default:
+		/* apply option to the CLC socket */
+		release_sock(sk);
+		goto clcsock;
+	}
+	release_sock(sk);
+	return rc;
 
+clcsock:
 	/* generic setsockopts reaching us here always apply to the
 	 * CLC socket
 	 */
-	return smc->clcsock->ops->setsockopt(smc->clcsock, level, optname,
-					     optval, optlen);
+	rc = smc->clcsock->ops->setsockopt(smc->clcsock, level, optname,
+					   optval, optlen);
+	if (smc->clcsock->sk->sk_err) {
+		sk->sk_err = smc->clcsock->sk->sk_err;
+		sk->sk_error_report(sk);
+	}
+	return rc;
 }
 
 static int smc_getsockopt(struct socket *sock, int level, int optname,
 			  char __user *optval, int __user *optlen)
 {
+	struct sock *sk = sock->sk;
 	struct smc_sock *smc;
+	int val, len;
 
-	smc = smc_sk(sock->sk);
-	/* socket options apply to the CLC socket */
+	smc = smc_sk(sk);
+
+	if (smc->use_fallback || level != SOL_TCP)
+		goto clcsock;
+
+	if (get_user(len, optlen))
+		return -EFAULT;
+	len = min_t(unsigned int, len, sizeof(int));
+	if (len < 0)
+		return -EINVAL;
+
+	/* level SOL_TCP */
+	switch (optname) {
+	case TCP_NODELAY:
+		if (smc->deferred_nodelay_reset)
+			val = 0;
+		else
+			goto clcsock;
+		break;
+	default:
+		goto clcsock;
+	}
+
+	if (put_user(len, optlen))
+		return -EFAULT;
+	if (copy_to_user(optval, &val, len))
+		return -EFAULT;
+	return 0;
+
+clcsock:
+	/* socket options applying to the CLC socket */
 	return smc->clcsock->ops->getsockopt(smc->clcsock, level, optname,
 					     optval, optlen);
 }
@@ -1387,6 +1497,7 @@ static int smc_create(struct net *net, struct socket *sock, int protocol,
 	int family = (protocol == SMCPROTO_SMC6) ? PF_INET6 : PF_INET;
 	struct smc_sock *smc;
 	struct sock *sk;
+	int val = 1;
 	int rc;
 
 	rc = -ESOCKTNOSUPPORT;
@@ -1412,6 +1523,10 @@ static int smc_create(struct net *net, struct socket *sock, int protocol,
 		sk_common_release(sk);
 		goto out;
 	}
+	/* clc handshake should run with disabled Nagle algorithm */
+	rc = kernel_setsockopt(smc->clcsock, SOL_TCP, TCP_NODELAY, (char *)&val,
+			       sizeof(val));
+	smc->deferred_nodelay_reset = 1; /* TCP_NODELAY is not the default */
 	smc->sk.sk_sndbuf = max(smc->clcsock->sk->sk_sndbuf, SMC_BUF_MIN_SIZE);
 	smc->sk.sk_rcvbuf = max(smc->clcsock->sk->sk_rcvbuf, SMC_BUF_MIN_SIZE);
 
diff --git a/net/smc/smc.h b/net/smc/smc.h
index e4829a2f46ba..6dfc1c90bed2 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -185,6 +185,10 @@ struct smc_sock {				/* smc sock container */
 						 * started, waiting for unsent
 						 * data to be sent
 						 */
+	u8			deferred_nodelay_reset : 1;
+						/* defer Nagle after CLC
+						 * handshake
+						 */
 };
 
 static inline struct smc_sock *smc_sk(const struct sock *sk)
-- 
2.13.5

^ permalink raw reply related

* [PATCH net-next v2 4/4] net/smc: handle sockopt TCP_DEFER_ACCEPT
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20180419135655.3058-1-ubraun@linux.ibm.com>

From: Ursula Braun <ubraun@linux.vnet.ibm.com>

TCP sockopt setting of TCP_DEFER_ACCEPT should just be applied
to the SMC socket, but not to the internal CLC socket.

If set, the accept is delayed till data is available.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
---
 net/smc/af_smc.c | 36 +++++++++++++++++++++++++++++++++++-
 net/smc/smc.h    |  4 ++++
 net/smc/smc_rx.c |  2 +-
 net/smc/smc_rx.h |  1 +
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 27d3aa8d0181..c5ece2b28179 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1098,9 +1098,29 @@ static int smc_accept(struct socket *sock, struct socket *new_sock,
 
 	if (!rc)
 		rc = sock_error(nsk);
+	release_sock(sk);
+	if (rc)
+		goto out;
+
+	if (lsmc->sockopt_defer_accept && !(flags & O_NONBLOCK)) {
+		/* wait till data arrives on the socket */
+		timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept *
+								MSEC_PER_SEC);
+		if (smc_sk(nsk)->use_fallback) {
+			struct sock *clcsk = smc_sk(nsk)->clcsock->sk;
+
+			lock_sock(clcsk);
+			if (skb_queue_empty(&clcsk->sk_receive_queue))
+				sk_wait_data(clcsk, &timeo, NULL);
+			release_sock(clcsk);
+		} else if (!atomic_read(&smc_sk(nsk)->conn.bytes_to_rcv)) {
+			lock_sock(nsk);
+			smc_rx_wait_data(smc_sk(nsk), &timeo);
+			release_sock(nsk);
+		}
+	}
 
 out:
-	release_sock(sk);
 	sock_put(sk); /* sock_hold above */
 	return rc;
 }
@@ -1367,6 +1387,14 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 		else
 			smc->deferred_cork_set = 0;
 		break;
+	case TCP_DEFER_ACCEPT:
+		if (sk->sk_state != SMC_INIT && sk->sk_state != SMC_LISTEN) {
+			release_sock(sk);
+			goto clcsock;
+		}
+		/* for the CLC-handshake TCP_DEFER_ACCEPT is not desired */
+		smc->sockopt_defer_accept = val;
+		break;
 	case TCP_FASTOPEN:
 	case TCP_FASTOPEN_CONNECT:
 	case TCP_FASTOPEN_KEY:
@@ -1429,6 +1457,12 @@ static int smc_getsockopt(struct socket *sock, int level, int optname,
 		else
 			goto clcsock;
 		break;
+	case TCP_DEFER_ACCEPT:
+		if (smc->sockopt_defer_accept)
+			val = smc->sockopt_defer_accept;
+		else
+			goto clcsock;
+		break;
 	default:
 		goto clcsock;
 	}
diff --git a/net/smc/smc.h b/net/smc/smc.h
index 38888da5a5ea..11f869d1f28a 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -180,6 +180,10 @@ struct smc_sock {				/* smc sock container */
 	struct list_head	accept_q;	/* sockets to be accepted */
 	spinlock_t		accept_q_lock;	/* protects accept_q */
 	bool			use_fallback;	/* fallback to tcp */
+	int			sockopt_defer_accept;
+						/* sockopt TCP_DEFER_ACCEPT
+						 * value
+						 */
 	u8			wait_close_tx_prepared : 1;
 						/* shutdown wr or close
 						 * started, waiting for unsent
diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
index eff4e0d0bb31..af851d8df1f8 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -51,7 +51,7 @@ static void smc_rx_data_ready(struct sock *sk)
  * 1 if at least 1 byte available in rcvbuf or if socket error/shutdown.
  * 0 otherwise (nothing in rcvbuf nor timeout, e.g. interrupted).
  */
-static int smc_rx_wait_data(struct smc_sock *smc, long *timeo)
+int smc_rx_wait_data(struct smc_sock *smc, long *timeo)
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 	struct smc_connection *conn = &smc->conn;
diff --git a/net/smc/smc_rx.h b/net/smc/smc_rx.h
index 3a32b59bf06c..0b75a6b470e6 100644
--- a/net/smc/smc_rx.h
+++ b/net/smc/smc_rx.h
@@ -20,5 +20,6 @@
 void smc_rx_init(struct smc_sock *smc);
 int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, size_t len,
 		   int flags);
+int smc_rx_wait_data(struct smc_sock *smc, long *timeo);
 
 #endif /* SMC_RX_H */
-- 
2.13.5

^ permalink raw reply related

* [PATCH net-next v2 3/4] net/smc: handle sockopt TCP_CORK
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20180419135655.3058-1-ubraun@linux.ibm.com>

From: Ursula Braun <ubraun@linux.vnet.ibm.com>

TCP sockopts must not interfere with the CLC handshake on the
CLC socket. Therefore, we defer some of them till the CLC
handshake has completed, like setting TCP_CORK.

For a corked SMC socket RDMA writes are deferred, if there is
still sufficient send buffer space available.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
---
 net/smc/af_smc.c | 36 +++++++++++++++++++++++++++++++++++-
 net/smc/smc.h    |  4 ++++
 net/smc/smc_tx.c | 16 +++++++++++++---
 net/smc/smc_tx.h |  8 ++++++++
 4 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 297c2cb93b34..27d3aa8d0181 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -389,8 +389,16 @@ static int smc_apply_deferred_sockopts(struct smc_sock *smc)
 		val = 0;
 		rc = kernel_setsockopt(smc->clcsock, SOL_TCP, TCP_NODELAY,
 				       (char *)&val, sizeof(val));
+		if (rc)
+			return rc;
+		opt_smc->deferred_nodelay_reset = 0;
+	}
+	if (opt_smc->deferred_cork_set) {
+		val = 1;
+		rc = kernel_setsockopt(smc->clcsock, SOL_TCP, TCP_CORK,
+				       (char *)&val, sizeof(val));
 		if (!rc)
-			opt_smc->deferred_nodelay_reset = 0;
+			opt_smc->deferred_cork_set = 0;
 	}
 	return rc;
 }
@@ -1327,6 +1335,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 	switch (optname) {
 	case TCP_NODELAY:
 		if (sk->sk_state != SMC_INIT && sk->sk_state != SMC_LISTEN) {
+			if (val && smc_tx_is_corked(smc))
+				mod_delayed_work(system_wq, &smc->conn.tx_work,
+						 0);
 			release_sock(sk);
 			goto clcsock;
 		}
@@ -1339,6 +1350,23 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 		else
 			smc->deferred_nodelay_reset = 1;
 		break;
+	case TCP_CORK:
+		if (sk->sk_state != SMC_INIT && sk->sk_state != SMC_LISTEN) {
+			if (!val)
+				mod_delayed_work(system_wq, &smc->conn.tx_work,
+						 0);
+			release_sock(sk);
+			goto clcsock;
+		}
+		/* for the CLC-handshake TCP_CORK is not desired;
+		 * in case of fallback to TCP, cork setting is
+		 * triggered afterwards.
+		 */
+		if (val)
+			smc->deferred_cork_set = 1;
+		else
+			smc->deferred_cork_set = 0;
+		break;
 	case TCP_FASTOPEN:
 	case TCP_FASTOPEN_CONNECT:
 	case TCP_FASTOPEN_KEY:
@@ -1395,6 +1423,12 @@ static int smc_getsockopt(struct socket *sock, int level, int optname,
 		else
 			goto clcsock;
 		break;
+	case TCP_CORK:
+		if (smc->deferred_cork_set)
+			val = 1;
+		else
+			goto clcsock;
+		break;
 	default:
 		goto clcsock;
 	}
diff --git a/net/smc/smc.h b/net/smc/smc.h
index 6dfc1c90bed2..38888da5a5ea 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -189,6 +189,10 @@ struct smc_sock {				/* smc sock container */
 						/* defer Nagle after CLC
 						 * handshake
 						 */
+	u8			deferred_cork_set : 1;
+						/* defer corking after CLC
+						 * handshake
+						 */
 };
 
 static inline struct smc_sock *smc_sk(const struct sock *sk)
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 72f004c9c9b1..a31377bb400b 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -26,6 +26,7 @@
 #include "smc_tx.h"
 
 #define SMC_TX_WORK_DELAY	HZ
+#define SMC_TX_CORK_DELAY	(HZ >> 2)	/* 250 ms */
 
 /***************************** sndbuf producer *******************************/
 
@@ -209,7 +210,16 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
 		/* since we just produced more new data into sndbuf,
 		 * trigger sndbuf consumer: RDMA write into peer RMBE and CDC
 		 */
-		smc_tx_sndbuf_nonempty(conn);
+		if ((msg->msg_flags & MSG_MORE || smc_tx_is_corked(smc)) &&
+		    (atomic_read(&conn->sndbuf_space) >
+						(conn->sndbuf_size >> 1)))
+			/* for a corked socket defer the RDMA writes if there
+			 * is still sufficient sndbuf_space available
+			 */
+			schedule_delayed_work(&conn->tx_work,
+					      SMC_TX_CORK_DELAY);
+		else
+			smc_tx_sndbuf_nonempty(conn);
 	} /* while (msg_data_left(msg)) */
 
 	return send_done;
@@ -409,8 +419,8 @@ int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
 			}
 			rc = 0;
 			if (conn->alert_token_local) /* connection healthy */
-				schedule_delayed_work(&conn->tx_work,
-						      SMC_TX_WORK_DELAY);
+				mod_delayed_work(system_wq, &conn->tx_work,
+						 SMC_TX_WORK_DELAY);
 		}
 		goto out_unlock;
 	}
diff --git a/net/smc/smc_tx.h b/net/smc/smc_tx.h
index 78255964fa4d..e5f4188b4bdb 100644
--- a/net/smc/smc_tx.h
+++ b/net/smc/smc_tx.h
@@ -14,6 +14,7 @@
 
 #include <linux/socket.h>
 #include <linux/types.h>
+#include <net/tcp.h>
 
 #include "smc.h"
 #include "smc_cdc.h"
@@ -27,6 +28,13 @@ static inline int smc_tx_prepared_sends(struct smc_connection *conn)
 	return smc_curs_diff(conn->sndbuf_size, &sent, &prep);
 }
 
+static inline bool smc_tx_is_corked(struct smc_sock *smc)
+{
+	struct tcp_sock *tp = tcp_sk(smc->clcsock->sk);
+
+	return (tp->nonagle & TCP_NAGLE_CORK) ? true : false;
+}
+
 void smc_tx_init(struct smc_sock *smc);
 int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len);
 int smc_tx_sndbuf_nonempty(struct smc_connection *conn);
-- 
2.13.5

^ permalink raw reply related

* [PATCH net 1/1] net/smc: fix shutdown in state SMC_LISTEN
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, stephen,
	ubraun
In-Reply-To: <20180419135640.2907-1-ubraun@linux.ibm.com>

From: Ursula Braun <ubraun@linux.vnet.ibm.com>

Calling shutdown with SHUT_RD and SHUT_RDWR for a listening SMC socket
crashes, because
   commit 127f49705823 ("net/smc: release clcsock from tcp_listen_worker")
releases the internal clcsock in smc_close_active() and sets smc->clcsock
to NULL.
For SHUT_RD the smc_close_active() call is removed.
For SHUT_RDWR the kernel_sock_shutdown() call is omitted, since the
clcsock is already released.

Fixes: 127f49705823 ("net/smc: release clcsock from tcp_listen_worker")
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
---
 net/smc/af_smc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 5f8046c62d90..f5d4b69dbabc 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1259,14 +1259,12 @@ static int smc_shutdown(struct socket *sock, int how)
 		rc = smc_close_shutdown_write(smc);
 		break;
 	case SHUT_RD:
-		if (sk->sk_state == SMC_LISTEN)
-			rc = smc_close_active(smc);
-		else
-			rc = 0;
-			/* nothing more to do because peer is not involved */
+		rc = 0;
+		/* nothing more to do because peer is not involved */
 		break;
 	}
-	rc1 = kernel_sock_shutdown(smc->clcsock, how);
+	if (smc->clcsock)
+		rc1 = kernel_sock_shutdown(smc->clcsock, how);
 	/* map sock_shutdown_cmd constants to sk_shutdown value range */
 	sk->sk_shutdown |= how + 1;
 
-- 
2.13.5

^ permalink raw reply related

* [PATCH net-next v2 1/4] net/smc: fix structure size
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20180419135655.3058-1-ubraun@linux.ibm.com>

From: Karsten Graul <kgraul@linux.vnet.ibm.com>

The struct smc_cdc_msg must be defined as packed so the
size is 44 bytes.
And change the structure size check so sizeof is checked.

Signed-off-by: Karsten Graul <kgraul@linux.vnet.ibm.com>
---
 net/smc/smc_cdc.c | 2 +-
 net/smc/smc_cdc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
index b42395d24cba..42ad57365eca 100644
--- a/net/smc/smc_cdc.c
+++ b/net/smc/smc_cdc.c
@@ -82,7 +82,7 @@ static inline void smc_cdc_add_pending_send(struct smc_connection *conn,
 		sizeof(struct smc_cdc_msg) > SMC_WR_BUF_SIZE,
 		"must increase SMC_WR_BUF_SIZE to at least sizeof(struct smc_cdc_msg)");
 	BUILD_BUG_ON_MSG(
-		offsetof(struct smc_cdc_msg, reserved) > SMC_WR_TX_SIZE,
+		sizeof(struct smc_cdc_msg) != SMC_WR_TX_SIZE,
 		"must adapt SMC_WR_TX_SIZE to sizeof(struct smc_cdc_msg); if not all smc_wr upper layer protocols use the same message size any more, must start to set link->wr_tx_sges[i].length on each individual smc_wr_tx_send()");
 	BUILD_BUG_ON_MSG(
 		sizeof(struct smc_cdc_tx_pend) > SMC_WR_TX_PEND_PRIV_SIZE,
diff --git a/net/smc/smc_cdc.h b/net/smc/smc_cdc.h
index ab240b37ad11..d2012fd22100 100644
--- a/net/smc/smc_cdc.h
+++ b/net/smc/smc_cdc.h
@@ -48,7 +48,7 @@ struct smc_cdc_msg {
 	struct smc_cdc_producer_flags	prod_flags;
 	struct smc_cdc_conn_state_flags	conn_state_flags;
 	u8				reserved[18];
-} __aligned(8);
+} __packed;					/* format defined in RFC7609 */
 
 static inline bool smc_cdc_rxed_any_close(struct smc_connection *conn)
 {
-- 
2.13.5

^ permalink raw reply related

* [PATCH net-next v2 0/4] net/smc: fixes from 2018-05-17 - v2
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun

From: Ursula Braun <ursula.braun@linux.vnet.ibm.com>

Dave,

thanks for your feedback and pointing out the kernel_setsockopt()
problem(s) in patch 2/4. Here is now version 2 of the patch series
with patches 2-4 implementing sockopts that require special
handling in SMC.

Version 2 changes of Patch 2/4 (and 3/4):
   * return error -EOPNOTSUPP for TCP_FASTOPEN sockopts
   * fix a kernel_setsockopt() usage bug by switching parameter
     variable from type "u8" to "int"
   * add return code validation when calling kernel_setsockopt()
   * propagate a setsockopt error on the internal CLC socket
     to the SMC socket.

Regards, Ursula

Karsten Graul (1):
  net/smc: fix structure size

Ursula Braun (3):
  net/smc: handle sockopt TCP_NODELAY
  net/smc: handle sockopt TCP_CORK
  net/smc: handle sockopt TCP_DEFER_ACCEPT

 net/smc/af_smc.c  | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 net/smc/smc.h     |  12 ++++
 net/smc/smc_cdc.c |   2 +-
 net/smc/smc_cdc.h |   2 +-
 net/smc/smc_rx.c  |   2 +-
 net/smc/smc_rx.h  |   1 +
 net/smc/smc_tx.c  |  16 ++++-
 net/smc/smc_tx.h  |   8 +++
 8 files changed, 225 insertions(+), 11 deletions(-)

-- 
2.13.5

^ permalink raw reply

* [PATCH net 0/1] net/smc: shutdown fix
From: Ursula Braun @ 2018-04-19 13:56 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, stephen,
	ubraun

From: Ursula Braun <ubraun@linux.vnet.ibm.com>

Dave,

Stephen Hemminger reported this problem recently:
   https://bugzilla.kernel.org/show_bug.cgi?id=199429

This patch fixes the problem and is a candidate for -stable.

Thanks, Ursula

Ursula Braun (1):
  net/smc: fix shutdown in state SMC_LISTEN

 net/smc/af_smc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

-- 
2.13.5

^ permalink raw reply

* Re: [PATCH net-next 2/2] udp: implement and use per cpu rx skbs cache
From: Eric Dumazet @ 2018-04-19 13:47 UTC (permalink / raw)
  To: Paolo Abeni, Eric Dumazet, netdev; +Cc: David S. Miller
In-Reply-To: <1524123637.3160.16.camel@redhat.com>



On 04/19/2018 12:40 AM, Paolo Abeni wrote:
> Hi,
> 
> On Wed, 2018-04-18 at 12:21 -0700, Eric Dumazet wrote:
>>
>> On 04/18/2018 10:15 AM, Paolo Abeni wrote:
>> is not appealing to me :/
>>>
>>> Thank you for the feedback.
>>> Sorry for not being clear about it, but knotd is using SO_REUSEPORT and
>>> the above tests are leveraging it.
>>>
>>> That 5% is on top of that 300%.
>>
>> Then there is something wrong.
>>
>> Adding copies should not increase performance.
> 
> The skb and data are copied into the UDP skb cache only if the socket
> is under memory pressure, and that happens if and only if the receiver
> is slower than the BH/IP receive path.

Which is going to happen under attack.

Bimodal behavior is dangerous for system stability..

> 
> The copy slows down the RX path - which was dropping packets - and
> makes the udp_recvmsg() considerably faster, as consuming skb becomes
> almost a no-op.
> 
> AFAICS, this is similar to the strategy you used in:
> 
> ommit c8c8b127091b758f5768f906bcdeeb88bc9951ca
> Author: Eric Dumazet <edumazet@google.com>
> Date:   Wed Dec 7 09:19:33 2016 -0800
> 
>     udp: under rx pressure, try to condense skbs
> 
> with the difference that with the UDP skb cache there is an hard limit
> to the amount of memory the BH is allowed to copy.
>

Very different strategy really.

We do not copy 500 bytes per skb :/

and the total amount of memory is tunable (socket rcvbuf)
instead of hard coded in the kernel :/

 
>> If it does, there is certainly another way, reaching 10% instead of 5%
> 
> I benchmarked vs a DNS server to test and verify that we get measurable
> benefits in real life scenario. The measured performance gain for the
> RX path with reasonable configurations is ~20%.

Then we probably can make +40% without copies.



> 
> Any suggestions for better results are more than welcome!


Yes, remote skb freeing. I mentioned this idea to Jesper and Tariq in Seoul (netdev conference)

Not tied to UDP, but a generic solution.

You are adding more and more code only that only helps in some benchmarks really.

UDP stack is becoming a very complex beast, while heavy duty UDP servers have alternatives,
and can not cope with arbitrary flood anyway.

^ permalink raw reply

* Re: [PATCH] net: deal wrong skb and failure ret from __tcp_retransmit_skb
From: Eric Dumazet @ 2018-04-19 13:40 UTC (permalink / raw)
  To: Liu, Changcheng, davem, kuznet, yoshfuji; +Cc: netdev, akpm
In-Reply-To: <20180419112653.GA108857@sofia>



On 04/19/2018 04:26 AM, Liu, Changcheng wrote:
> Hit below panic due to skb is NULL, WARN wrong skb first.
> if __tcp_retransmit_skb return failure e.g. -EAGAIN, it
> needn't do further action in tcp_retransmit_skb.
> 
> gdb vmlinux
> Reading symbols from vmlinux...done.
> (gdb) p &((struct tcp_skb_cb *) \
> &(((struct sk_buff *)0)->cb[0]))->tcp_gso_segs
> $1 = (u16 *) 0x30 <irq_stack_union+48>
> 
> [ 9040.917533] BUG: unable to handle kernel NULL pointer dereference at 0000000000000030
> [ 9040.926279] IP: tcp_retransmit_skb+0x5c/0xc0
> [ 9040.931043] PGD 0 P4D 0
> [ 9040.933865] Oops: 0000 [#1] PREEMPT SMP PTI
> [ 9040.972151] RIP: 0010:tcp_retransmit_skb+0x5c/0xc0
> [ 9040.977496] RSP: 0018:ffff8802bec83e40 EFLAGS: 00010202
> [ 9041.062527] Call Trace:
> [ 9041.065250]  <IRQ>
> [ 9041.067489]  tcp_retransmit_timer+0x481/0x820
> [ 9041.077697]  tcp_write_timer_handler+0xe9/0x230
> [ 9041.082751]  tcp_write_timer+0x75/0x80
> [ 9041.086932]  call_timer_fn+0x29/0x150
> [ 9041.091018]  run_timer_softirq+0x411/0x460
> [ 9041.105017]  __do_softirq+0x115/0x311
> [ 9041.109103]  irq_exit+0xb0/0xc0
> [ 9041.112605]  smp_apic_timer_interrupt+0x67/0x140
> 
> Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
> 

On which kernel have you seen this problem ?

In networking, we want patches with a 'Fixes:' tag to clearly identify which patch
added a regression.


Anyway your patch comes too late I guess

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=bffd168c3fc5cc7d2bad4c668fa90e7a9010db4b

^ permalink raw reply

* Re: [PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
From: Cornelia Huck @ 2018-04-19 13:26 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Mikulas Patocka, Eric Dumazet, David Miller,
	Thomas Huth, Jason Wang, virtualization, netdev
In-Reply-To: <1524115776-334953-3-git-send-email-mst@redhat.com>

On Thu, 19 Apr 2018 08:30:49 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> Programming vids (adding or removing them) still passes
> guest-endian values in the DMA buffer. That's wrong
> if guest is big-endian and when virtio 1 is enabled.
> 
> Note: this is on top of a previous patch:
> 	virtio_net: split out ctrl buffer
> 
> Fixes: 9465a7a6f ("virtio_net: enable v1.0 support")
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/net/virtio_net.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Ouch. Have you seen any bug reports for that?

^ permalink raw reply

* Re: [PATCH v3 13/20] mmc: Remove depends on HAS_DMA in case of platform dependency
From: Ulf Hansson @ 2018-04-19 13:17 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Wolfram Sang,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-fpga-u79uwXL29TY76Z2rM5mHXA,
	linux-remoteproc-u79uwXL29TY76Z2rM5mHXA,
	Linux Fbdev development list, Bjorn Andersson, Eric Anholt,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux1394-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Christoph Hellwig, Stefan Wahren, Boris Brezillon, Herbert Xu,
	Richard Weinberger, Jassi Brar, Marek Vasut,
	linux-serial-u79uwXL29TY76Z2rM5mHXA, Matias Bjorling,
	linux-media-u79uwXL29TY76Z2rM5mHXA, Ohad Ben-Cohen, driverdevel,
	Alan Tull
In-Reply-To: <1523987360-18760-14-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>

On 17 April 2018 at 19:49, Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> wrote:
> Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
> symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
> In most cases this other symbol is an architecture or platform specific
> symbol, or PCI.
>
> Generic symbols and drivers without platform dependencies keep their
> dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
> cannot work anyway.
>
> This simplifies the dependencies, and allows to improve compile-testing.
>
> Signed-off-by: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
> Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Acked-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
> Acked-by: Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Thanks, applied for next!

Kind regrds
Uffe

> ---
> v3:
>   - Add Acked-by,
>   - Rebase to v4.17-rc1,
>
> v2:
>   - Add Reviewed-by, Acked-by,
>   - Drop RFC state,
>   - Split per subsystem.
> ---
>  drivers/mmc/host/Kconfig | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 9589f9c9046f14b1..3978d0418958bf6b 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -358,7 +358,6 @@ config MMC_MESON_MX_SDIO
>         tristate "Amlogic Meson6/Meson8/Meson8b SD/MMC Host Controller support"
>         depends on ARCH_MESON || COMPILE_TEST
>         depends on COMMON_CLK
> -       depends on HAS_DMA
>         depends on OF
>         help
>           This selects support for the SD/MMC Host Controller on
> @@ -401,7 +400,6 @@ config MMC_OMAP
>
>  config MMC_OMAP_HS
>         tristate "TI OMAP High Speed Multimedia Card Interface support"
> -       depends on HAS_DMA
>         depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
>         help
>           This selects the TI OMAP High Speed Multimedia card Interface.
> @@ -511,7 +509,6 @@ config MMC_DAVINCI
>
>  config MMC_GOLDFISH
>         tristate "goldfish qemu Multimedia Card Interface support"
> -       depends on HAS_DMA
>         depends on GOLDFISH || COMPILE_TEST
>         help
>           This selects the Goldfish Multimedia card Interface emulation
> @@ -605,7 +602,7 @@ config MMC_SDHI
>
>  config MMC_SDHI_SYS_DMAC
>         tristate "DMA for SDHI SD/SDIO controllers using SYS-DMAC"
> -       depends on MMC_SDHI && HAS_DMA
> +       depends on MMC_SDHI
>         default MMC_SDHI if (SUPERH || ARM)
>         help
>           This provides DMA support for SDHI SD/SDIO controllers
> @@ -615,7 +612,7 @@ config MMC_SDHI_SYS_DMAC
>  config MMC_SDHI_INTERNAL_DMAC
>         tristate "DMA for SDHI SD/SDIO controllers using on-chip bus mastering"
>         depends on ARM64 || COMPILE_TEST
> -       depends on MMC_SDHI && HAS_DMA
> +       depends on MMC_SDHI
>         default MMC_SDHI if ARM64
>         help
>           This provides DMA support for SDHI SD/SDIO controllers
> @@ -669,7 +666,6 @@ config MMC_CAVIUM_THUNDERX
>
>  config MMC_DW
>         tristate "Synopsys DesignWare Memory Card Interface"
> -       depends on HAS_DMA
>         depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
>         help
>           This selects support for the Synopsys DesignWare Mobile Storage IP
> @@ -748,7 +744,6 @@ config MMC_DW_ZX
>
>  config MMC_SH_MMCIF
>         tristate "SuperH Internal MMCIF support"
> -       depends on HAS_DMA
>         depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
>         help
>           This selects the MMC Host Interface controller (MMCIF) found in various
> @@ -868,7 +863,6 @@ config MMC_TOSHIBA_PCI
>  config MMC_BCM2835
>         tristate "Broadcom BCM2835 SDHOST MMC Controller support"
>         depends on ARCH_BCM2835 || COMPILE_TEST
> -       depends on HAS_DMA
>         help
>           This selects the BCM2835 SDHOST MMC controller. If you have
>           a BCM2835 platform with SD or MMC devices, say Y or M here.
> --
> 2.7.4
>

^ permalink raw reply

* BUG: unable to handle kernel NULL pointer dereference in netlink_getsockbyportid
From: Jean-Baptiste Theou @ 2018-04-19 13:13 UTC (permalink / raw)
  To: davem, gregkh, Jason, johannes, edumazet, netdev

Hi,

syzkaller found a null pointer in read_pnet on 4.4.128 (Latest LTS).
Unfortunately I don't have a repo code for now. Will post and test
on the top of the tree if available.

Due to my testing env (Android), cannot run Linus top of the tree.

Could be related to https://www.spinics.net/lists/netdev/msg473130.html,
even if the fact that the null pointer is in read_pnet seems to indicate
a memory corruption more than an actual null pointer.

Please let me know if I can provide more information.

Thanks a lot,

==================================================================
BUG: KASAN: null-ptr-deref on address 0000000000000030
Read of size 8 by task syz-executor/4540
CPU: 0 PID: 4540 Comm: syz-executor Not tainted 4.4.128-perf+ #10
Hardware name: Essential Mata EVT4_F (DT)
Call trace:
[<ffffffa8e3a8c8a4>] dump_backtrace+0x0/0x27c arch/arm64/kernel/traps.c:108
[<ffffffa8e3a8cb3c>] show_stack+0x1c/0x24 arch/arm64/kernel/traps.c:231
[<ffffffa8e3f07140>] __dump_stack lib/dump_stack.c:15 [inline]
[<ffffffa8e3f07140>] dump_stack+0xb8/0xec lib/dump_stack.c:51
[<ffffffa8e3c78f24>] kasan_report_error mm/kasan/report.c:285 [inline]
[<ffffffa8e3c78f24>] kasan_report+0x118/0x4e8 mm/kasan/report.c:310
[<ffffffa8e3c77c7c>] check_memory_region_inline mm/kasan/kasan.c:292 [inline]
[<ffffffa8e3c77c7c>] __asan_load8+0x78/0x80 mm/kasan/kasan.c:724
[<ffffffa8e4d7a77c>] read_pnet include/net/net_namespace.h:266 [inline]
[<ffffffa8e4d7a77c>] sock_net include/net/sock.h:2233 [inline]
[<ffffffa8e4d7a77c>] netlink_getsockbyportid net/netlink/af_netlink.c:1085 [inline]
[<ffffffa8e4d7a77c>] netlink_unicast+0xbc/0x348 net/netlink/af_netlink.c:1270
[<ffffffa8e4d7b254>] netlink_ack+0x204/0x224 net/netlink/af_netlink.c:2305
[<ffffffa8e4d82120>] nfnetlink_rcv_batch net/netfilter/nfnetlink.c:319 [inline]
[<ffffffa8e4d82120>] nfnetlink_rcv+0x3cc/0x718 net/netfilter/nfnetlink.c:477
[<ffffffa8e4d7a904>] netlink_unicast_kernel net/netlink/af_netlink.c:1250 [inline]
[<ffffffa8e4d7a904>] netlink_unicast+0x244/0x348 net/netlink/af_netlink.c:1276
[<ffffffa8e4d7b024>] netlink_sendmsg+0x520/0x54c net/netlink/af_netlink.c:1830
[<ffffffa8e4ce9c10>] sock_sendmsg_nosec net/socket.c:638 [inline]
[<ffffffa8e4ce9c10>] sock_sendmsg+0x70/0x9c net/socket.c:648
[<ffffffa8e4cec984>] ___sys_sendmsg+0x330/0x414 net/socket.c:2008
[<ffffffa8e4cee684>] __sys_sendmsg+0x60/0xb4 net/socket.c:2042
[<ffffffa8e4cee710>] SYSC_sendmsg net/socket.c:2053 [inline]
[<ffffffa8e4cee710>] SyS_sendmsg+0x38/0x50 net/socket.c:2049
[<ffffffa8e3a83270>] el0_svc_naked+0x24/0x28
==================================================================
-----------[ cut here ]-----------
Kernel BUG at ffffffa8e4d7a77c [verbose debug info unavailable]
Internal error: Oops - BUG: 96000005 1 PREEMPT SMP
Modules linked in:
CPU: 0 PID: 4540 Comm: syz-executor Tainted: G B 4.4.128-perf+ #10
Hardware name: Essential Mata EVT4_F (DT)
task: ffffffdc5c326200 ti: ffffffdc47d80000 task.ti: ffffffdc47d80000
PC is at read_pnet include/net/net_namespace.h:266 [inline]
PC is at sock_net include/net/sock.h:2233 [inline]
PC is at netlink_getsockbyportid net/netlink/af_netlink.c:1085 [inline]
PC is at netlink_unicast+0xbc/0x348 net/netlink/af_netlink.c:1270
LR is at read_pnet include/net/net_namespace.h:266 [inline]
LR is at sock_net include/net/sock.h:2233 [inline]
LR is at netlink_getsockbyportid net/netlink/af_netlink.c:1085 [inline]
LR is at netlink_unicast+0xbc/0x348 net/netlink/af_netlink.c:1270
pc : [<ffffffa8e4d7a77c>] lr : [<ffffffa8e4d7a77c>] pstate: 60400145
sp : ffffffdc47d83910
x29: ffffffdc47d83910 x28: 00000000000002a8
x27: 0000000000000148 x26: 0000000000000030
x25: 00000000000000f0 x24: ffffffdc47d83980
x23: ffffffa8e5e06000 x22: 0000000000000000
x21: 00000000000011bb x20: ffffffdc6f6ab7c0
x19: 0000000000000000 x18: 0000007fca8a87ff
x17: 0000000000000000 x16: ffffffa8e3b70a70
x15: 000000000000000a x14: 3d3d3d3d3d3d3d3d
x13: 3d3d3d3d3d3d3d3d x12: 3d3d3d3d3d3d3d3d
x11: 3d3d3d3d3d3d3d3d x10: 3d3d3d3d3d3d3d3d
x9 : ffffff8b9296b007 x8 : ffffffa8e3e2a764
x7 : ffffffa8e5e4df08 x6 : 000000000000003c
x5 : 0000000000000000 x4 : ffffff8b88fb0000
x3 : ffffffa8e506c818 x2 : dfffff9000000000
x1 : 77d7e7890cbc6c61 x0 : 77d7e7890cbc6c61
\x0aPC: 0xffffffa8e4d7a73c:
a73c 97ffe9e3 aa0003f4 350000b8 97b8f916 910762c0 97bbf52d f940eed3 910203b8
a75c 97b8f911 9100c2da 910522db 910aa2dc f81f0f13 97b8f90c aa1a03e0 97bbf523
a77c f9401ad3 aa1b03e0 97bbf4de 394526c1 aa1303e0 2a1503e2 97fff341 aa0003f3
a79c b40003a0 97b8f900 91004a60 97bbf46f 39404a60 53001c00 7100041f 540002e1
\x0aLR: 0xffffffa8e4d7a73c:
a73c 97ffe9e3 aa0003f4 350000b8 97b8f916 910762c0 97bbf52d f940eed3 910203b8
a75c 97b8f911 9100c2da 910522db 910aa2dc f81f0f13 97b8f90c aa1a03e0 97bbf523
a77c f9401ad3 aa1b03e0 97bbf4de 394526c1 aa1303e0 2a1503e2 97fff341 aa0003f3
a79c b40003a0 97b8f900 91004a60 97bbf46f 39404a60 53001c00 7100041f 540002e1
\x0aSP: 0xffffffdc47d838d0:
38d0 e4d7a77c ffffffa8 47d83910 ffffffdc e4d7a77c ffffffa8 60400145 00000000
38f0 00000000 00000000 0cbc6c61 77d7e789 00000000 00000080 e4d7a77c ffffffa8
3910 47d83990 ffffffdc e4d7b254 ffffffa8 00000000 00000000 7adcc814 ffffffdc
3930 7adc9f80 ffffffdc 6f6ab680 ffffffdc 6f6ab6a8 ffffffdc 6f6ab7c0 ffffffdc

Process syz-executor (pid: 4540, stack limit = 0xffffffdc47d80028)
Call trace:
Exception stack(0xffffffdc47d83710 to 0xffffffdc47d83840)
3700: 0000000000000000 0000008000000000
3720: 00000000830c5000 ffffffa8e4d7a77c 0000000060400145 0000000000000025
3740: 00000000000000f0 ffffffa8e3ab275c 0000000000000005 ffffffdc47d80000
3760: ffffffa8e5e06000 0000000000000000 0000000000000008 0000000000000000
3780: ffffffdc47d83810 ffffffdc47d83810 ffffffdc47d837d0 00000000ffffffc8
37a0: 0000000000000008 ffffffdc47d83810 ffffffdc47d83810 ffffffdc47d837d0
37c0: 00000000ffffffc8 77d7e7890cbc6c61 0000000000000000 77d7e7890cbc6c61
37e0: 77d7e7890cbc6c61 77d7e7890cbc6c61 dfffff9000000000 ffffffa8e506c818
3800: ffffff8b88fb0000 0000000000000000 000000000000003c ffffffa8e5e4df08
3820: ffffffa8e3e2a764 ffffff8b9296b007 3d3d3d3d3d3d3d3d 3d3d3d3d3d3d3d3d
[<ffffffa8e4d7a77c>] read_pnet include/net/net_namespace.h:266 [inline]
[<ffffffa8e4d7a77c>] sock_net include/net/sock.h:2233 [inline]
[<ffffffa8e4d7a77c>] netlink_getsockbyportid net/netlink/af_netlink.c:1085 [inline]
[<ffffffa8e4d7a77c>] netlink_unicast+0xbc/0x348 net/netlink/af_netlink.c:1270
[<ffffffa8e4d7b254>] netlink_ack+0x204/0x224 net/netlink/af_netlink.c:2305
[<ffffffa8e4d82120>] nfnetlink_rcv_batch net/netfilter/nfnetlink.c:319 [inline]
[<ffffffa8e4d82120>] nfnetlink_rcv+0x3cc/0x718 net/netfilter/nfnetlink.c:477
[<ffffffa8e4d7a904>] netlink_unicast_kernel net/netlink/af_netlink.c:1250 [inline]
[<ffffffa8e4d7a904>] netlink_unicast+0x244/0x348 net/netlink/af_netlink.c:1276
[<ffffffa8e4d7b024>] netlink_sendmsg+0x520/0x54c net/netlink/af_netlink.c:1830
[<ffffffa8e4ce9c10>] sock_sendmsg_nosec net/socket.c:638 [inline]
[<ffffffa8e4ce9c10>] sock_sendmsg+0x70/0x9c net/socket.c:648
[<ffffffa8e4cec984>] ___sys_sendmsg+0x330/0x414 net/socket.c:2008
[<ffffffa8e4cee684>] __sys_sendmsg+0x60/0xb4 net/socket.c:2042
[<ffffffa8e4cee710>] SYSC_sendmsg net/socket.c:2053 [inline]
[<ffffffa8e4cee710>] SyS_sendmsg+0x38/0x50 net/socket.c:2049
[<ffffffa8e3a83270>] el0_svc_naked+0x24/0x28
Code: f81f0f13 97b8f90c aa1a03e0 97bbf523 (f9401ad3)

^ permalink raw reply

* Re: [RFC PATCH ghak32 V2 12/13] audit: NETFILTER_PKT: record each container ID associated with a netNS
From: Paul Moore @ 2018-04-19 13:13 UTC (permalink / raw)
  To: Richard Guy Briggs
  Cc: simo-H+wXaHxf7aLQT0dZR+AlfA, jlayton-H+wXaHxf7aLQT0dZR+AlfA,
	carlos-H+wXaHxf7aLQT0dZR+AlfA, linux-api-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, LKML,
	Eric Paris, dhowells-H+wXaHxf7aLQT0dZR+AlfA,
	Linux-Audit Mailing List, ebiederm-aS9lmoZGLiVWk0Htik3J/w,
	luto-DgEjT+Ai2ygdnm+yROfE0A, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn
In-Reply-To: <20180419124550.7uknp4oebvwoo67s-bcJWsdo4jJjeVoXN4CMphl7TgLCtbB0G@public.gmane.org>

On Thu, Apr 19, 2018 at 8:45 AM, Richard Guy Briggs <rgb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> On 2018-04-18 22:10, Paul Moore wrote:
>> On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs <rgb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>> > Add container ID auxiliary record(s) to NETFILTER_PKT event standalone
>> > records.  Iterate through all potential container IDs associated with a
>> > network namespace.
>> >
>> > Signed-off-by: Richard Guy Briggs <rgb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> > ---
>> >  kernel/audit.c           |  1 +
>> >  kernel/auditsc.c         |  2 ++
>> >  net/netfilter/xt_AUDIT.c | 15 ++++++++++++++-
>> >  3 files changed, 17 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/kernel/audit.c b/kernel/audit.c
>> > index 08662b4..3c77e47 100644
>> > --- a/kernel/audit.c
>> > +++ b/kernel/audit.c
>> > @@ -2102,6 +2102,7 @@ int audit_log_container_info(struct audit_context *context,
>> >         audit_log_end(ab);
>> >         return 0;
>> >  }
>> > +EXPORT_SYMBOL(audit_log_container_info);
>> >
>> >  void audit_log_key(struct audit_buffer *ab, char *key)
>> >  {
>> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
>> > index 208da962..af68d01 100644
>> > --- a/kernel/auditsc.c
>> > +++ b/kernel/auditsc.c
>> > @@ -975,6 +975,7 @@ struct audit_context *audit_alloc_local(void)
>> >         context->in_syscall = 1;
>> >         return context;
>> >  }
>> > +EXPORT_SYMBOL(audit_alloc_local);
>> >
>> >  inline void audit_free_context(struct audit_context *context)
>> >  {
>> > @@ -989,6 +990,7 @@ inline void audit_free_context(struct audit_context *context)
>> >         audit_proctitle_free(context);
>> >         kfree(context);
>> >  }
>> > +EXPORT_SYMBOL(audit_free_context);
>> >
>> >  static int audit_log_pid_context(struct audit_context *context, pid_t pid,
>> >                                  kuid_t auid, kuid_t uid, unsigned int sessionid,
>> > diff --git a/net/netfilter/xt_AUDIT.c b/net/netfilter/xt_AUDIT.c
>> > index c502419..edaa456 100644
>> > --- a/net/netfilter/xt_AUDIT.c
>> > +++ b/net/netfilter/xt_AUDIT.c
>> > @@ -71,10 +71,14 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb)
>> >  {
>> >         struct audit_buffer *ab;
>> >         int fam = -1;
>> > +       struct audit_context *context = audit_alloc_local();
>> > +       struct audit_containerid *cont;
>> > +       int i = 0;
>> > +       struct net *net;
>> >
>> >         if (audit_enabled == 0)
>> >                 goto errout;
>>
>> Do I need to say it?  I probably should ... the allocation should
>> happen after the audit_enabled check.
>
> Already fixed in V3 in my tree a couple of weeks ago...

... which you never posted, at least not anywhere I've seen.  Which
effectively means I wasted a good chunk of time reviewing this code
late last night.  Awesome.

> More timely review please?

More patience on your part?

>> > -       ab = audit_log_start(NULL, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
>> > +       ab = audit_log_start(context, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
>> >         if (ab == NULL)
>> >                 goto errout;
>> >
>> > @@ -104,7 +108,16 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb)
>> >
>> >         audit_log_end(ab);
>> >
>> > +       net = sock_net(NETLINK_CB(skb).sk);
>> > +       list_for_each_entry(cont, &net->audit_containerid, list) {
>> > +               char buf[14];
>> > +
>> > +               sprintf(buf, "net%u", i++);
>> > +               audit_log_container_info(context, buf, cont->id);
>> > +       }
>>
>> It seems like this could (should?) be hidden inside an audit function,
>> e.g. audit_log_net_containers() or something like that.
>
> Perhaps...  It was open-coded since at this point there are no other
> users.  That'll make this tidier though.

If the code was all contained within a single subsystem them I would
generally agree that open coding is preferable, but since we are
crossing a subsystem boundary I think it would be preferable to
abstract away the details into a separate function.

This will probably also be necessary once you change to using the
audit_net/net_generic mechanism.

-- 
paul moore
www.paul-moore.com

^ permalink raw reply

* Re: [PATCH 26/39] rtc/proc: switch to proc_create_single_data
From: Alexandre Belloni @ 2018-04-19 13:10 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-rtc, Alessandro Zummo, jfs-discussion, devel, linux-scsi,
	Corey Minyard, linux-ide, Greg Kroah-Hartman, linux-kernel,
	linux-afs, linux-acpi, netdev, netfilter-devel, Alexander Viro,
	Jiri Slaby, Andrew Morton, linux-ext4, Alexey Dobriyan,
	megaraidlinux.pdl, drbd-dev
In-Reply-To: <20180419124140.9309-27-hch@lst.de>

On 19/04/2018 14:41:27+0200, Christoph Hellwig wrote:
> And stop trying to get a reference on the submodule, procfs code deals
> with release after and unloaded module and thus removed proc entry.
> 

Are you sure about that? The rtc module is not the one adding the procfs
file so I'm not sure how the procfs code can handle it.

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/rtc/rtc-proc.c | 33 ++-------------------------------
>  1 file changed, 2 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
> index 31e7e23cc5be..a9dd9218fae2 100644
> --- a/drivers/rtc/rtc-proc.c
> +++ b/drivers/rtc/rtc-proc.c
> @@ -107,40 +107,11 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
>  	return 0;
>  }
>  
> -static int rtc_proc_open(struct inode *inode, struct file *file)
> -{
> -	int ret;
> -	struct rtc_device *rtc = PDE_DATA(inode);
> -
> -	if (!try_module_get(rtc->owner))
> -		return -ENODEV;
> -
> -	ret = single_open(file, rtc_proc_show, rtc);
> -	if (ret)
> -		module_put(rtc->owner);
> -	return ret;
> -}
> -
> -static int rtc_proc_release(struct inode *inode, struct file *file)
> -{
> -	int res = single_release(inode, file);
> -	struct rtc_device *rtc = PDE_DATA(inode);
> -
> -	module_put(rtc->owner);
> -	return res;
> -}
> -
> -static const struct file_operations rtc_proc_fops = {
> -	.open		= rtc_proc_open,
> -	.read		= seq_read,
> -	.llseek		= seq_lseek,
> -	.release	= rtc_proc_release,
> -};
> -
>  void rtc_proc_add_device(struct rtc_device *rtc)
>  {
>  	if (is_rtc_hctosys(rtc))
> -		proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc);
> +		proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
> +				rtc);
>  }
>  
>  void rtc_proc_del_device(struct rtc_device *rtc)
> -- 
> 2.17.0
> 

-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH 20/39] afs: simplify procfs code
From: David Howells @ 2018-04-19 13:00 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dhowells, Andrew Morton, Alexander Viro, linux-rtc,
	Alessandro Zummo, Alexandre Belloni, devel, linux-kernel,
	linux-scsi, Corey Minyard, linux-ide, Greg Kroah-Hartman,
	jfs-discussion, linux-afs, linux-acpi, netdev, netfilter-devel,
	Jiri Slaby, linux-ext4, Alexey Dobriyan, megaraidlinux.pdl,
	drbd-dev
In-Reply-To: <20180419124140.9309-21-hch@lst.de>

Christoph Hellwig <hch@lst.de> wrote:

> Use remove_proc_subtree to remove the whole subtree on cleanup, and
> unwind the registration loop into individual calls.  Switch to use
> proc_create_seq where applicable.

Note that this is likely going to clash with my patch to net-namespace all of
the afs proc files:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?h=mount-context&id=f60c26c827c073583107ebf19d87bc5c0e71c3d2

If it helps, I should be able to disentangle this from the mount-api changes
since the subsequent patch connects the dots to propagate the network
namespace over automount using the new fs_context to do it.

David

^ permalink raw reply

* Re: [RFC PATCH ghak32 V2 09/13] audit: add containerid support for config/feature/user records
From: Paul Moore @ 2018-04-19 12:59 UTC (permalink / raw)
  To: Richard Guy Briggs
  Cc: cgroups, containers, linux-api, Linux-Audit Mailing List,
	linux-fsdevel, LKML, netdev, ebiederm, luto, jlayton, carlos,
	dhowells, viro, simo, Eric Paris, serge
In-Reply-To: <20180419123109.ab7gsnwrbtog4tbf@madcap2.tricolour.ca>

On Thu, Apr 19, 2018 at 8:31 AM, Richard Guy Briggs <rgb@redhat.com> wrote:
> On 2018-04-18 21:27, Paul Moore wrote:
>> On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs <rgb@redhat.com> wrote:
>> > Add container ID auxiliary records to configuration change, feature set change
>> > and user generated standalone records.
>> >
>> > Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
>> > ---
>> >  kernel/audit.c       | 50 ++++++++++++++++++++++++++++++++++++++++----------
>> >  kernel/auditfilter.c |  5 ++++-
>> >  2 files changed, 44 insertions(+), 11 deletions(-)
>> >
>> > diff --git a/kernel/audit.c b/kernel/audit.c
>> > index b238be5..08662b4 100644
>> > --- a/kernel/audit.c
>> > +++ b/kernel/audit.c
>> > @@ -400,8 +400,9 @@ static int audit_log_config_change(char *function_name, u32 new, u32 old,
>> >  {
>> >         struct audit_buffer *ab;
>> >         int rc = 0;
>> > +       struct audit_context *context = audit_alloc_local();
>>
>> We should be able to use current->audit_context here right?  If we
>> can't for every caller, perhaps we pass an audit_context as an
>> argument and only allocate a local context when the passed
>> audit_context is NULL.
>>
>> Also, if you're not comfortable always using current, just pass the
>> audit_context as you do with audit_log_common_recv_msg().
>
> As mentioned in the tree/watch/mark patch, this is all obsoleted by
> making the AUDIT_CONFIG_CHANGE record a SYSCALL auxiliary record.

You've known about my desire to connect records for quite some time.

> This review would have been more helpful a month and a half ago.

If you really want to sink to that level of discussion, better quality
patches from you would have been helpful too, that is the one of the
main reasons why it takes so long to review your code.  Let's keep the
commentary focused on the code, discussions like this aren't likely to
be helpful to anyone.

-- 
paul moore
www.paul-moore.com

^ permalink raw reply

* Re: [PATCH bpf-next v3 8/8] bpf: add documentation for eBPF helpers (58-64)
From: Jesper Dangaard Brouer @ 2018-04-19 12:58 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: daniel, ast, netdev, oss-drivers, linux-doc, linux-man,
	John Fastabend, brouer
In-Reply-To: <62931080-6f69-3877-7a84-0df5be5754e6@netronome.com>

On Thu, 19 Apr 2018 13:44:41 +0100
Quentin Monnet <quentin.monnet@netronome.com> wrote:

> 2018-04-18 17:43 UTC+0200 ~ Jesper Dangaard Brouer <brouer@redhat.com>
> > On Wed, 18 Apr 2018 15:09:41 +0100
> > Quentin Monnet <quentin.monnet@netronome.com> wrote:
> >   
> >> 2018-04-18 15:34 UTC+0200 ~ Jesper Dangaard Brouer <brouer@redhat.com>  
> >>> On Tue, 17 Apr 2018 15:34:38 +0100
> >>> Quentin Monnet <quentin.monnet@netronome.com> wrote:
> >>>     
> >>>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> >>>> index 350459c583de..3d329538498f 100644
> >>>> --- a/include/uapi/linux/bpf.h
> >>>> +++ b/include/uapi/linux/bpf.h
> >>>> @@ -1276,6 +1276,50 @@ union bpf_attr {
> >>>>   * 	Return
> >>>>   * 		0 on success, or a negative error in case of failure.
> >>>>   *
> >>>> + * int bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags)
> >>>> + * 	Description
> >>>> + * 		Redirect the packet to the endpoint referenced by *map* at
> >>>> + * 		index *key*. Depending on its type, his *map* can contain    
> >>>                                                     ^^^
> >>>
> >>> "his" -> "this"    
> >>
> >> Thanks!
> >>  
> >>>> + * 		references to net devices (for forwarding packets through other
> >>>> + * 		ports), or to CPUs (for redirecting XDP frames to another CPU;
> >>>> + * 		but this is only implemented for native XDP (with driver
> >>>> + * 		support) as of this writing).
> >>>> + *
> >>>> + * 		All values for *flags* are reserved for future usage, and must
> >>>> + * 		be left at zero.
> >>>> + * 	Return
> >>>> + * 		**XDP_REDIRECT** on success, or **XDP_ABORT** on error.
> >>>> + *    
> >>>
> >>> "XDP_ABORT" -> "XDP_ABORTED"    
> >>
> >> Ouch. And I did the same for bpf_redirect(). Thanks for the catch.
> >>  
> >>>
> >>> I don't know if it's worth mentioning in the doc/man-page; that for XDP
> >>> using bpf_redirect_map() is a HUGE performance advantage, compared to
> >>> the bpf_redirect() call ?    
> >>
> >> It seems worth to me. How would you simply explain the reason for this
> >> difference?  
> > 
> > The basic reason is "bulking effect", as devmap avoids the NIC
> > tailptr/doorbell update on every packet... how to write that in a doc
> > format?
> > 
> > I wrote about why XDP_REDIRECT with maps are smart here:
> >  http://vger.kernel.org/netconf2017_files/XDP_devel_update_NetConf2017_Seoul.pdf
> > 
> > Using maps for redirect, hopefully makes XDP_REDIRECT the last driver
> > XDP action code we need.  As new types of redirect can be introduced
> > without driver changes. See that AF_XDP also uses a map.
> > 
> > It is more subtle, but maps also function as a sorting step. Imagine
> > your XDP program need to redirect out different interfaces (or CPUs in
> > cpumap case), and packets arrive intermixed.  Packets get sorted into
> > the different map indexes, and the xdp_do_flush_map() will trigger the
> > flush operation.
> > 
> > 
> > Happened to have an i40e NIC benchmark setup, and ran a single flow pktgen test.
> > 
> > Results with 'xdp_redirect_map'
> >  13589297 pps (13,589,297) 
> > 
> > Results with 'xdp_redirect' NOT using devmap:
> >   7567575 pps (7,567,575)
> > 
> > Just to point out the performance benefit of devmap...  
> 
> 
> Thanks for those details! This is an impressive change in performance
> indeed.
> 
> I think I will just keep it simple for the documentation. I will add the
> following for bpf_redirect_map():
> 
>     When used to redirect packets to net devices, this helper
>     provides a high performance increase over **bpf_redirect**\ ().
>     This is due to various implementation details of the underlying
>     mechanisms, one of which is the fact that **bpf_redirect_map**\ ()
>     tries to send packet as a "bulk" to the device.
> 
> And also append the following to bpf_redirect():
> 
>     The same effect can be attained with the more generic
>     **bpf_redirect_map**\ (), which requires specific maps
>     to be used but offers better performance.

This sounds good to me! :-)

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

^ permalink raw reply

* [PATCH net-next 2/2] qed* : Add new TLV to request PF to update MAC in bulletin board
From: Shahed Shaikh @ 2018-04-19 12:50 UTC (permalink / raw)
  To: davem; +Cc: netdev, Ariel.Elior, Dept-EngEverestLinuxL2
In-Reply-To: <20180419125012.20503-1-shahed.shaikh@cavium.com>

There may be a need for VF driver to request PF to explicitly update its
bulletin with a MAC address.
e.g. When user assigns a MAC address to VF while VF is still down,
and PF's bulletin board contains different MAC address, in this case,
when VF's interface is brought up, it gets loaded with MAC address from
bulletin board which is not desirable.

To handle this corner case, we need a new TLV to request PF to update
its bulletin board with suggested MAC.

This request will be honored only for trusted VFs.

Signed-off-by: Shahed Shaikh <shahed.shaikh@cavium.com>
---
 drivers/net/ethernet/qlogic/qed/qed_l2.c       | 19 +++++++++++++
 drivers/net/ethernet/qlogic/qed/qed_sriov.c    | 37 ++++++++++++++++++++++++++
 drivers/net/ethernet/qlogic/qed/qed_vf.c       | 29 ++++++++++++++++++++
 drivers/net/ethernet/qlogic/qed/qed_vf.h       | 21 +++++++++++++++
 drivers/net/ethernet/qlogic/qede/qede_filter.c |  4 +++
 include/linux/qed/qed_eth_if.h                 |  1 +
 6 files changed, 111 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index e874504..8b1b7e8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -2850,6 +2850,24 @@ static int qed_fp_cqe_completion(struct qed_dev *dev,
 				      cqe);
 }
 
+static int qed_req_bulletin_update_mac(struct qed_dev *cdev, u8 *mac)
+{
+	int i, ret;
+
+	if (IS_PF(cdev))
+		return 0;
+
+	for_each_hwfn(cdev, i) {
+		struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
+
+		ret = qed_vf_pf_bulletin_update_mac(p_hwfn, mac);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_QED_SRIOV
 extern const struct qed_iov_hv_ops qed_iov_ops_pass;
 #endif
@@ -2887,6 +2905,7 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
 	.ntuple_filter_config = &qed_ntuple_arfs_filter_config,
 	.configure_arfs_searcher = &qed_configure_arfs_searcher,
 	.get_coalesce = &qed_get_coalesce,
+	.req_bulletin_update_mac = &qed_req_bulletin_update_mac,
 };
 
 const struct qed_eth_ops *qed_get_eth_ops(void)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index 77376fd..f01bf52 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -3820,6 +3820,40 @@ static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
 		__qed_vf_get_link_caps(p_hwfn, p_caps, p_bulletin);
 }
 
+static int
+qed_iov_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
+				  struct qed_ptt *p_ptt,
+				  struct qed_vf_info *p_vf)
+{
+	struct qed_bulletin_content *p_bulletin = p_vf->bulletin.p_virt;
+	struct qed_iov_vf_mbx *mbx = &p_vf->vf_mbx;
+	struct vfpf_bulletin_update_mac_tlv *p_req;
+	u8 status = PFVF_STATUS_SUCCESS;
+	int rc = 0;
+
+	if (!p_vf->p_vf_info.is_trusted_configured) {
+		DP_VERBOSE(p_hwfn,
+			   QED_MSG_IOV,
+			   "Blocking bulletin update request from untrusted VF[%d]\n",
+			   p_vf->abs_vf_id);
+		status = PFVF_STATUS_NOT_SUPPORTED;
+		rc = -EINVAL;
+		goto send_status;
+	}
+
+	p_req = &mbx->req_virt->bulletin_update_mac;
+	ether_addr_copy(p_bulletin->mac, p_req->mac);
+	DP_VERBOSE(p_hwfn, QED_MSG_IOV,
+		   "Updated bulletin of VF[%d] with requested MAC[%pM]\n",
+		   p_vf->abs_vf_id, p_req->mac);
+
+send_status:
+	qed_iov_prepare_resp(p_hwfn, p_ptt, p_vf,
+			     CHANNEL_TLV_BULLETIN_UPDATE_MAC,
+			     sizeof(struct pfvf_def_resp_tlv), status);
+	return rc;
+}
+
 static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
 				    struct qed_ptt *p_ptt, int vfid)
 {
@@ -3899,6 +3933,9 @@ static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
 		case CHANNEL_TLV_COALESCE_READ:
 			qed_iov_vf_pf_get_coalesce(p_hwfn, p_ptt, p_vf);
 			break;
+		case CHANNEL_TLV_BULLETIN_UPDATE_MAC:
+			qed_iov_vf_pf_bulletin_update_mac(p_hwfn, p_ptt, p_vf);
+			break;
 		}
 	} else if (qed_iov_tlv_supported(mbx->first_tlv.tl.type)) {
 		DP_VERBOSE(p_hwfn, QED_MSG_IOV,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 91b5e9f..2d7fcd6 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -1375,6 +1375,35 @@ int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
 }
 
 int
+qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
+			      u8 *p_mac)
+{
+	struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
+	struct vfpf_bulletin_update_mac_tlv *p_req;
+	struct pfvf_def_resp_tlv *p_resp;
+	int rc;
+
+	if (!p_mac)
+		return -EINVAL;
+
+	/* clear mailbox and prep header tlv */
+	p_req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_BULLETIN_UPDATE_MAC,
+			       sizeof(*p_req));
+	ether_addr_copy(p_req->mac, p_mac);
+	DP_VERBOSE(p_hwfn, QED_MSG_IOV,
+		   "Requesting bulletin update for MAC[%pM]\n", p_mac);
+
+	/* add list termination tlv */
+	qed_add_tlv(p_hwfn, &p_iov->offset, CHANNEL_TLV_LIST_END,
+		    sizeof(struct channel_list_end_tlv));
+
+	p_resp = &p_iov->pf2vf_reply->default_resp;
+	rc = qed_send_msg2pf(p_hwfn, &p_resp->hdr.status, sizeof(*p_resp));
+	qed_vf_pf_req_end(p_hwfn, rc);
+	return rc;
+}
+
+int
 qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
 		       u16 rx_coal, u16 tx_coal, struct qed_queue_cid *p_cid)
 {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.h b/drivers/net/ethernet/qlogic/qed/qed_vf.h
index 97d44df..4f05d5e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.h
@@ -518,6 +518,12 @@ struct pfvf_read_coal_resp_tlv {
 	u8 padding[6];
 };
 
+struct vfpf_bulletin_update_mac_tlv {
+	struct vfpf_first_tlv first_tlv;
+	u8 mac[ETH_ALEN];
+	u8 padding[2];
+};
+
 union vfpf_tlvs {
 	struct vfpf_first_tlv first_tlv;
 	struct vfpf_acquire_tlv acquire;
@@ -532,6 +538,7 @@ union vfpf_tlvs {
 	struct vfpf_update_tunn_param_tlv tunn_param_update;
 	struct vfpf_update_coalesce update_coalesce;
 	struct vfpf_read_coal_req_tlv read_coal_req;
+	struct vfpf_bulletin_update_mac_tlv bulletin_update_mac;
 	struct tlv_buffer_size tlv_buf_size;
 };
 
@@ -650,6 +657,7 @@ enum {
 	CHANNEL_TLV_COALESCE_UPDATE,
 	CHANNEL_TLV_QID,
 	CHANNEL_TLV_COALESCE_READ,
+	CHANNEL_TLV_BULLETIN_UPDATE_MAC,
 	CHANNEL_TLV_MAX,
 
 	/* Required for iterating over vport-update tlvs.
@@ -1042,6 +1050,13 @@ int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
 				  struct qed_tunnel_info *p_tunn);
 
 u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
+/**
+ * @brief - Ask PF to update the MAC address in it's bulletin board
+ *
+ * @param p_mac - mac address to be updated in bulletin board
+ */
+int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn, u8 *p_mac);
+
 #else
 static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
 					  struct qed_mcp_link_params *params)
@@ -1228,6 +1243,12 @@ static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
 	return -EINVAL;
 }
 
+static inline int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
+						u8 *p_mac)
+{
+	return -EINVAL;
+}
+
 static inline u32
 qed_vf_hw_bar_size(struct qed_hwfn  *p_hwfn,
 		   enum BAR_ID bar_id)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 8094f03..43569b1 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1160,6 +1160,10 @@ int qede_set_mac_addr(struct net_device *ndev, void *p)
 	if (edev->state != QEDE_STATE_OPEN) {
 		DP_VERBOSE(edev, NETIF_MSG_IFDOWN,
 			   "The device is currently down\n");
+		/* Ask PF to explicitly update a copy in bulletin board */
+		if (IS_VF(edev) && edev->ops->req_bulletin_update_mac)
+			edev->ops->req_bulletin_update_mac(edev->cdev,
+							   ndev->dev_addr);
 		goto out;
 	}
 
diff --git a/include/linux/qed/qed_eth_if.h b/include/linux/qed/qed_eth_if.h
index 147d08c..7f9756f 100644
--- a/include/linux/qed/qed_eth_if.h
+++ b/include/linux/qed/qed_eth_if.h
@@ -352,6 +352,7 @@ struct qed_eth_ops {
 	int (*configure_arfs_searcher)(struct qed_dev *cdev,
 				       enum qed_filter_config_mode mode);
 	int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
+	int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
 };
 
 const struct qed_eth_ops *qed_get_eth_ops(void);
-- 
2.7.4

^ permalink raw reply related

* [PATCH net-next 1/2] qed* : use trust mode to allow VF to override forced MAC
From: Shahed Shaikh @ 2018-04-19 12:50 UTC (permalink / raw)
  To: davem; +Cc: netdev, Ariel.Elior, Dept-EngEverestLinuxL2
In-Reply-To: <20180419125012.20503-1-shahed.shaikh@cavium.com>

As per existing behavior, when PF sets a MAC address for a VF
(also called as forced MAC), VF is not allowed to change its
MAC address afterwards.
This puts the limitation on few use cases such as bonding of VFs,
where bonding driver asks VF to change its MAC address.

This patch uses a VF trust mode to allow VF to change its MAC address
in spite PF has set a forced MAC for that VF.

Signed-off-by: Shahed Shaikh <shahed.shaikh@cavium.com>
---
 drivers/net/ethernet/qlogic/qed/qed_sriov.c    | 210 +++++++++++++++++++++++--
 drivers/net/ethernet/qlogic/qede/qede_filter.c |   3 +-
 2 files changed, 195 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index 5acb91b..77376fd 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -48,7 +48,7 @@ static int qed_sriov_eqe_event(struct qed_hwfn *p_hwfn,
 			       u8 opcode,
 			       __le16 echo,
 			       union event_ring_data *data, u8 fw_return_code);
-
+static int qed_iov_bulletin_set_mac(struct qed_hwfn *p_hwfn, u8 *mac, int vfid);
 
 static u8 qed_vf_calculate_legacy(struct qed_vf_info *p_vf)
 {
@@ -1790,7 +1790,8 @@ static int qed_iov_configure_vport_forced(struct qed_hwfn *p_hwfn,
 	if (!p_vf->vport_instance)
 		return -EINVAL;
 
-	if (events & BIT(MAC_ADDR_FORCED)) {
+	if ((events & BIT(MAC_ADDR_FORCED)) ||
+	    p_vf->p_vf_info.is_trusted_configured) {
 		/* Since there's no way [currently] of removing the MAC,
 		 * we can always assume this means we need to force it.
 		 */
@@ -1809,8 +1810,12 @@ static int qed_iov_configure_vport_forced(struct qed_hwfn *p_hwfn,
 				  "PF failed to configure MAC for VF\n");
 			return rc;
 		}
-
-		p_vf->configured_features |= 1 << MAC_ADDR_FORCED;
+		if (p_vf->p_vf_info.is_trusted_configured)
+			p_vf->configured_features |=
+				BIT(VFPF_BULLETIN_MAC_ADDR);
+		else
+			p_vf->configured_features |=
+				BIT(MAC_ADDR_FORCED);
 	}
 
 	if (events & BIT(VLAN_ADDR_FORCED)) {
@@ -3170,6 +3175,10 @@ static int qed_iov_vf_update_mac_shadow(struct qed_hwfn *p_hwfn,
 	if (p_vf->bulletin.p_virt->valid_bitmap & BIT(MAC_ADDR_FORCED))
 		return 0;
 
+	/* Don't keep track of shadow copy since we don't intend to restore. */
+	if (p_vf->p_vf_info.is_trusted_configured)
+		return 0;
+
 	/* First remove entries and then add new ones */
 	if (p_params->opcode == QED_FILTER_REMOVE) {
 		for (i = 0; i < QED_ETH_VF_NUM_MAC_FILTERS; i++) {
@@ -3244,9 +3253,17 @@ static int qed_iov_chk_ucast(struct qed_hwfn *hwfn,
 
 	/* No real decision to make; Store the configured MAC */
 	if (params->type == QED_FILTER_MAC ||
-	    params->type == QED_FILTER_MAC_VLAN)
+	    params->type == QED_FILTER_MAC_VLAN) {
 		ether_addr_copy(vf->mac, params->mac);
 
+		if (vf->is_trusted_configured) {
+			qed_iov_bulletin_set_mac(hwfn, vf->mac, vfid);
+
+			/* Update and post bulleitin again */
+			qed_schedule_iov(hwfn, QED_IOV_WQ_BULLETIN_UPDATE_FLAG);
+		}
+	}
+
 	return 0;
 }
 
@@ -4081,16 +4098,60 @@ static void qed_iov_bulletin_set_forced_mac(struct qed_hwfn *p_hwfn,
 		return;
 	}
 
-	feature = 1 << MAC_ADDR_FORCED;
+	if (vf_info->p_vf_info.is_trusted_configured) {
+		feature = BIT(VFPF_BULLETIN_MAC_ADDR);
+		/* Trust mode will disable Forced MAC */
+		vf_info->bulletin.p_virt->valid_bitmap &=
+			~BIT(MAC_ADDR_FORCED);
+	} else {
+		feature = BIT(MAC_ADDR_FORCED);
+		/* Forced MAC will disable MAC_ADDR */
+		vf_info->bulletin.p_virt->valid_bitmap &=
+			~BIT(VFPF_BULLETIN_MAC_ADDR);
+	}
+
 	memcpy(vf_info->bulletin.p_virt->mac, mac, ETH_ALEN);
 
 	vf_info->bulletin.p_virt->valid_bitmap |= feature;
-	/* Forced MAC will disable MAC_ADDR */
-	vf_info->bulletin.p_virt->valid_bitmap &= ~BIT(VFPF_BULLETIN_MAC_ADDR);
 
 	qed_iov_configure_vport_forced(p_hwfn, vf_info, feature);
 }
 
+static int qed_iov_bulletin_set_mac(struct qed_hwfn *p_hwfn, u8 *mac, int vfid)
+{
+	struct qed_vf_info *vf_info;
+	u64 feature;
+
+	vf_info = qed_iov_get_vf_info(p_hwfn, (u16)vfid, true);
+	if (!vf_info) {
+		DP_NOTICE(p_hwfn->cdev, "Can not set MAC, invalid vfid [%d]\n",
+			  vfid);
+		return -EINVAL;
+	}
+
+	if (vf_info->b_malicious) {
+		DP_NOTICE(p_hwfn->cdev, "Can't set MAC to malicious VF [%d]\n",
+			  vfid);
+		return -EINVAL;
+	}
+
+	if (vf_info->bulletin.p_virt->valid_bitmap & BIT(MAC_ADDR_FORCED)) {
+		DP_VERBOSE(p_hwfn, QED_MSG_IOV,
+			   "Can not set MAC, Forced MAC is configured\n");
+		return -EINVAL;
+	}
+
+	feature = BIT(VFPF_BULLETIN_MAC_ADDR);
+	ether_addr_copy(vf_info->bulletin.p_virt->mac, mac);
+
+	vf_info->bulletin.p_virt->valid_bitmap |= feature;
+
+	if (vf_info->p_vf_info.is_trusted_configured)
+		qed_iov_configure_vport_forced(p_hwfn, vf_info, feature);
+
+	return 0;
+}
+
 static void qed_iov_bulletin_set_forced_vlan(struct qed_hwfn *p_hwfn,
 					     u16 pvid, int vfid)
 {
@@ -4204,6 +4265,21 @@ static int qed_iov_spoofchk_set(struct qed_hwfn *p_hwfn, int vfid, bool val)
 	return rc;
 }
 
+static u8 *qed_iov_bulletin_get_mac(struct qed_hwfn *p_hwfn, u16 rel_vf_id)
+{
+	struct qed_vf_info *p_vf;
+
+	p_vf = qed_iov_get_vf_info(p_hwfn, rel_vf_id, true);
+	if (!p_vf || !p_vf->bulletin.p_virt)
+		return NULL;
+
+	if (!(p_vf->bulletin.p_virt->valid_bitmap &
+	      BIT(VFPF_BULLETIN_MAC_ADDR)))
+		return NULL;
+
+	return p_vf->bulletin.p_virt->mac;
+}
+
 static u8 *qed_iov_bulletin_get_forced_mac(struct qed_hwfn *p_hwfn,
 					   u16 rel_vf_id)
 {
@@ -4493,8 +4569,12 @@ static int qed_sriov_pf_set_mac(struct qed_dev *cdev, u8 *mac, int vfid)
 		if (!vf_info)
 			continue;
 
-		/* Set the forced MAC, and schedule the IOV task */
-		ether_addr_copy(vf_info->forced_mac, mac);
+		/* Set the MAC, and schedule the IOV task */
+		if (vf_info->is_trusted_configured)
+			ether_addr_copy(vf_info->mac, mac);
+		else
+			ether_addr_copy(vf_info->forced_mac, mac);
+
 		qed_schedule_iov(hwfn, QED_IOV_WQ_SET_UNICAST_FILTER_FLAG);
 	}
 
@@ -4802,6 +4882,33 @@ static void qed_handle_vf_msg(struct qed_hwfn *hwfn)
 	qed_ptt_release(hwfn, ptt);
 }
 
+static bool qed_pf_validate_req_vf_mac(struct qed_hwfn *hwfn,
+				       u8 *mac,
+				       struct qed_public_vf_info *info)
+{
+	if (info->is_trusted_configured) {
+		if (is_valid_ether_addr(info->mac) &&
+		    (!mac || !ether_addr_equal(mac, info->mac)))
+			return true;
+	} else {
+		if (is_valid_ether_addr(info->forced_mac) &&
+		    (!mac || !ether_addr_equal(mac, info->forced_mac)))
+			return true;
+	}
+
+	return false;
+}
+
+static void qed_set_bulletin_mac(struct qed_hwfn *hwfn,
+				 struct qed_public_vf_info *info,
+				 int vfid)
+{
+	if (info->is_trusted_configured)
+		qed_iov_bulletin_set_mac(hwfn, info->mac, vfid);
+	else
+		qed_iov_bulletin_set_forced_mac(hwfn, info->forced_mac, vfid);
+}
+
 static void qed_handle_pf_set_vf_unicast(struct qed_hwfn *hwfn)
 {
 	int i;
@@ -4816,18 +4923,20 @@ static void qed_handle_pf_set_vf_unicast(struct qed_hwfn *hwfn)
 			continue;
 
 		/* Update data on bulletin board */
-		mac = qed_iov_bulletin_get_forced_mac(hwfn, i);
-		if (is_valid_ether_addr(info->forced_mac) &&
-		    (!mac || !ether_addr_equal(mac, info->forced_mac))) {
+		if (info->is_trusted_configured)
+			mac = qed_iov_bulletin_get_mac(hwfn, i);
+		else
+			mac = qed_iov_bulletin_get_forced_mac(hwfn, i);
+
+		if (qed_pf_validate_req_vf_mac(hwfn, mac, info)) {
 			DP_VERBOSE(hwfn,
 				   QED_MSG_IOV,
 				   "Handling PF setting of VF MAC to VF 0x%02x [Abs 0x%02x]\n",
 				   i,
 				   hwfn->cdev->p_iov_info->first_vf_in_pf + i);
 
-			/* Update bulletin board with forced MAC */
-			qed_iov_bulletin_set_forced_mac(hwfn,
-							info->forced_mac, i);
+			/* Update bulletin board with MAC */
+			qed_set_bulletin_mac(hwfn, info, i);
 			update = true;
 		}
 
@@ -4867,6 +4976,72 @@ static void qed_handle_bulletin_post(struct qed_hwfn *hwfn)
 	qed_ptt_release(hwfn, ptt);
 }
 
+static void qed_update_mac_for_vf_trust_change(struct qed_hwfn *hwfn, int vf_id)
+{
+	struct qed_public_vf_info *vf_info;
+	struct qed_vf_info *vf;
+	u8 *force_mac;
+	int i;
+
+	vf_info = qed_iov_get_public_vf_info(hwfn, vf_id, true);
+	vf = qed_iov_get_vf_info(hwfn, vf_id, true);
+
+	if (!vf_info || !vf)
+		return;
+
+	/* Force MAC converted to generic MAC in case of VF trust on */
+	if (vf_info->is_trusted_configured &&
+	    (vf->bulletin.p_virt->valid_bitmap & BIT(MAC_ADDR_FORCED))) {
+		force_mac = qed_iov_bulletin_get_forced_mac(hwfn, vf_id);
+
+		if (force_mac) {
+			/* Clear existing shadow copy of MAC to have a clean
+			 * slate.
+			 */
+			for (i = 0; i < QED_ETH_VF_NUM_MAC_FILTERS; i++) {
+				if (ether_addr_equal(vf->shadow_config.macs[i],
+						     vf_info->mac)) {
+					memset(vf->shadow_config.macs[i], 0,
+					       ETH_ALEN);
+					DP_VERBOSE(hwfn, QED_MSG_IOV,
+						   "Shadow MAC %pM removed for VF 0x%02x, VF trust mode is ON\n",
+						    vf_info->mac, vf_id);
+					break;
+				}
+			}
+
+			ether_addr_copy(vf_info->mac, force_mac);
+			memset(vf_info->forced_mac, 0, ETH_ALEN);
+			vf->bulletin.p_virt->valid_bitmap &=
+					~BIT(MAC_ADDR_FORCED);
+			qed_schedule_iov(hwfn, QED_IOV_WQ_BULLETIN_UPDATE_FLAG);
+		}
+	}
+
+	/* Update shadow copy with VF MAC when trust mode is turned off */
+	if (!vf_info->is_trusted_configured) {
+		u8 empty_mac[ETH_ALEN];
+
+		memset(empty_mac, 0, ETH_ALEN);
+		for (i = 0; i < QED_ETH_VF_NUM_MAC_FILTERS; i++) {
+			if (ether_addr_equal(vf->shadow_config.macs[i],
+					     empty_mac)) {
+				ether_addr_copy(vf->shadow_config.macs[i],
+						vf_info->mac);
+				DP_VERBOSE(hwfn, QED_MSG_IOV,
+					   "Shadow is updated with %pM for VF 0x%02x, VF trust mode is OFF\n",
+					    vf_info->mac, vf_id);
+				break;
+			}
+		}
+		/* Clear bulletin when trust mode is turned off,
+		 * to have a clean slate for next (normal) operations.
+		 */
+		qed_iov_bulletin_set_mac(hwfn, empty_mac, vf_id);
+		qed_schedule_iov(hwfn, QED_IOV_WQ_BULLETIN_UPDATE_FLAG);
+	}
+}
+
 static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
 {
 	struct qed_sp_vport_update_params params;
@@ -4890,6 +5065,9 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
 			continue;
 		vf_info->is_trusted_configured = vf_info->is_trusted_request;
 
+		/* Handle forced MAC mode */
+		qed_update_mac_for_vf_trust_change(hwfn, i);
+
 		/* Validate that the VF has a configured vport */
 		vf = qed_iov_get_vf_info(hwfn, i, true);
 		if (!vf->vport_instance)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 6687e04..8094f03 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -550,8 +550,7 @@ void qede_force_mac(void *dev, u8 *mac, bool forced)
 
 	__qede_lock(edev);
 
-	/* MAC hints take effect only if we haven't set one already */
-	if (is_valid_ether_addr(edev->ndev->dev_addr) && !forced) {
+	if (!is_valid_ether_addr(mac)) {
 		__qede_unlock(edev);
 		return;
 	}
-- 
2.7.4

^ permalink raw reply related

* [bisected] Stack overflow after fs: "switch the IO-triggering parts of umount to fs_pin" (was net namespaces kernel stack overflow)
From: Kirill Tkhai @ 2018-04-19 12:50 UTC (permalink / raw)
  To: Alexander Aring, Al Viro, linux-kernel; +Cc: netdev, Jamal Hadi Salim
In-Reply-To: <ef45eb94-4480-0683-ccc0-eb1efaf7e96c@virtuozzo.com>

Hi, Al,

commit 87b95ce0964c016ede92763be9c164e49f1019e9 is the first after which the below test crashes the kernel:

    Author: Al Viro <viro@zeniv.linux.org.uk>
    Date:   Sat Jan 10 19:01:08 2015 -0500

    switch the IO-triggering parts of umount to fs_pin
    
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

$modprobe dummy

$while true
 do
     mkdir /var/run/netns
     touch /var/run/netns/init_net
     mount --bind /proc/1/ns/net /var/run/netns/init_net

     ip netns add foo
     ip netns exec foo ip link add dummy0 type dummy
     ip netns delete foo
done

[   22.058349] ip (3249) used greatest stack depth: 8 bytes left
[   22.182195] BUG: unable to handle kernel paging request at 000000035bb1f080
[   22.183065] IP: [<ffffffff810718e4>] kick_process+0x34/0x80
[   22.183065] PGD 0 
[   22.183065] Thread overran stack, or stack corrupted
[   22.183065] Oops: 0000 [#1] PREEMPT SMP 
[   22.183065] CPU: 1 PID: 3255 Comm: ip Not tainted 3.19.0-rc5+ #111
[   22.183065] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.1-1 04/01/2014
[   22.183065] task: ffff88007c475100 ti: ffff88007b3cc000 task.ti: ffff88007b3cc000
[   22.183065] RIP: 0010:[<ffffffff810718e4>]  [<ffffffff810718e4>] kick_process+0x34/0x80
[   22.183065] RSP: 0018:ffff88007b3cfcf8  EFLAGS: 00010293
[   22.183065] RAX: 0000000000012900 RBX: ffff88007c475100 RCX: ffff88007b20e7b8
[   22.183065] RDX: 000000007b3cc028 RSI: ffffffff819b05f8 RDI: ffffffff819cb999
[   22.183065] RBP: ffff88007b3cfd08 R08: ffffffff81cbf688 R09: ffff88007d3d0810
[   22.183065] R10: ffff88007fc933c8 R11: 0000000000000000 R12: 000000007b3cc028
[   22.183065] R13: ffff88007c475100 R14: 0000000000000000 R15: 00007fff7793a448
[   22.183065] FS:  00007fc987546700(0000) GS:ffff88007fc80000(0000) knlGS:0000000000000000
[   22.183065] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[   22.183065] CR2: 000000035bb1f080 CR3: 0000000001c11000 CR4: 00000000000006e0
[   22.183065] Stack:
[   22.183065]  ffff88007c3b67b8 ffff88007b3cfd98 ffff88007b3cfd18 ffffffff81066b05
[   22.183065]  ffff88007b3cfd38 ffffffff81176f4c ffff88007b3cfd48 ffff88007c3b68a0
[   22.183065]  ffff88007b3cfd48 ffffffff8117777f ffff88007b3cfd68 ffffffff81177a49
[   22.183065] Call Trace:
[   22.183065]  [<ffffffff81066b05>] task_work_add+0x45/0x60
[   22.183065]  [<ffffffff81176f4c>] mntput_no_expire+0xdc/0x150
[   22.183065]  [<ffffffff8117777f>] mntput+0x1f/0x30
[   22.183065]  [<ffffffff81177a49>] drop_mountpoint+0x29/0x30
[   22.183065]  [<ffffffff81188df6>] pin_kill+0x66/0xf0
[   22.183065]  [<ffffffff81082c60>] ? __wake_up_common+0x90/0x90
[   22.183065]  [<ffffffff81188ed9>] group_pin_kill+0x19/0x40
[   22.183065]  [<ffffffff811761d8>] namespace_unlock+0x58/0x60
[   22.183065]  [<ffffffff81178cae>] drop_collected_mounts+0x4e/0x60
[   22.183065]  [<ffffffff8117a3ed>] put_mnt_ns+0x2d/0x50
[   22.183065]  [<ffffffff81068b0a>] free_nsproxy+0x1a/0x80
[   22.183065]  [<ffffffff81068c68>] switch_task_namespaces+0x58/0x70
[   22.183065]  [<ffffffff81068c8b>] exit_task_namespaces+0xb/0x10
[   22.183065]  [<ffffffff8104eb57>] do_exit+0x2c7/0xc00
[   22.183065]  [<ffffffff8104f50a>] do_group_exit+0x3a/0xa0
[   22.183065]  [<ffffffff8104f57f>] SyS_exit_group+0xf/0x10
[   22.183065]  [<ffffffff817ad092>] system_call_fastpath+0x12/0x17

Kirill

On 19.04.2018 01:08, Kirill Tkhai wrote:
> Hi, Alexander!
> 
> On 18.04.2018 22:45, Alexander Aring wrote:
>> I currently can crash my net/master kernel by execute the following script:
>>
>> --- snip
>>
>> modprobe dummy
>>
>> #mkdir /var/run/netns
>> #touch /var/run/netns/init_net
>> #mount --bind /proc/1/ns/net /var/run/netns/init_net
>>
>> while true
>> do
>>     mkdir /var/run/netns
>>     touch /var/run/netns/init_net
>>     mount --bind /proc/1/ns/net /var/run/netns/init_net
>>
>>     ip netns add foo
>>     ip netns exec foo ip link add dummy0 type dummy
>>     ip netns delete foo
>> done
> 
> Fast answer is the best, so I tried your test on my not-for-work computer.
> There is old kernel without asynchronous pernet operations:
> 
> $uname -a
> Linux localhost.localdomain 4.15.0-2-amd64 #1 SMP Debian 4.15.11-1 (2018-03-20) x86_64 GNU/Linux
> 
> After approximately 15 seconds of your test execution it died :(
> (Hopefully, I executed it in "init 1" with all partitions RO as usual).
> 
> There is no serial console, so I can't say that the first stack is exactly
> the same as you see. But it crashed. So, it seems, the problem have been
> existing long ago.
> 
> Have you tried to reproduce it in older kernels or to bisect the problem commit?
> Or maybe it doesn't reproduce on old kernels in your environment?
> 
>> --- snap
>>
>> After max ~1 minute the kernel will crash.
>> Doing my hack of saving init_net outside the loop it will run fine...
>> So the mount bind is necessary.
>>
>> The last message which I see is:
>>
>> BUG: stack guard page was hit at 00000000f0751759 (stack is
>> 0000000069363195..0000000073ddc474)
>> kernel stack overflow (double-fault): 0000 [#1] SMP PTI
>> Modules linked in:
>> CPU: 0 PID: 13917 Comm: ip Not tainted 4.16.0-11878-gef9d066f6808 #32
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
>> RIP: 0010:validate_chain.isra.23+0x44/0xc40
>> RSP: 0018:ffffc900002cbff8 EFLAGS: 00010002
>> RAX: 0000000000040000 RBX: 0e58b88e1d4d15da RCX: 0e58b88e1d4d15da
>> RDX: 0000000000000000 RSI: ffff8802b25ee2a0 RDI: ffff8802b25edb00
>> RBP: 0e58b88e1d4d15da R08: 0000000000000000 R09: 0000000000000004
>> R10: ffffc900002cc050 R11: ffff8802b1054be8 R12: 0000000000000001
>> R13: ffff8802b25ee268 R14: ffff8802b25edb00 R15: 0000000000000000
>> FS:  0000000000000000(0000) GS:ffff8802bfc00000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: ffffc900002cbfe8 CR3: 0000000002024000 CR4: 00000000000006f0
>> Call Trace:
>>  ? get_max_files+0x10/0x10
>>  __lock_acquire+0x332/0x710
>>  lock_acquire+0x67/0xb0
>>  ? lockref_put_or_lock+0x9/0x30
>>  ? dput.part.7+0x17/0x2d0
>>  _raw_spin_lock+0x2b/0x60
>>  ? lockref_put_or_lock+0x9/0x30
>>  lockref_put_or_lock+0x9/0x30
>>  dput.part.7+0x1ec/0x2d0
>>  drop_mountpoint+0x10/0x40
>>  pin_kill+0x9b/0x3a0
>>  ? wait_woken+0x90/0x90
>>  ? mnt_pin_kill+0x2d/0x100
>>  mnt_pin_kill+0x2d/0x100
>>  cleanup_mnt+0x66/0x70
>>  pin_kill+0x9b/0x3a0
>>  ? wait_woken+0x90/0x90
>>  ? mnt_pin_kill+0x2d/0x100
>>  mnt_pin_kill+0x2d/0x100
>>  cleanup_mnt+0x66/0x70
>> ...
>>
>> I guess maybe it has something to do with recently switching to
>> migrate per-net ops to async.
>>
>> - Alex
> 
> Kirill
> 

^ permalink raw reply

* [PATCH net-next 0/2] qed* : Use trust mode to override forced MAC
From: Shahed Shaikh @ 2018-04-19 12:50 UTC (permalink / raw)
  To: davem; +Cc: netdev, Ariel.Elior, Dept-EngEverestLinuxL2

Hi Dave,

This patchset adds a support to override forced MAC (MAC set by PF for a VF)
when trust mode is enabled using
#ip link set dev <pf> vf <vf id> trust on

First patch adds a real change to use .ndo_set_vf_trust to override forced MAC
and allow user to change VFs from VF interface itself.

Second patch takes care of a corner case, where MAC change from VF won't
take effect when VF interface is down, by introducing a new TLV
(a way to send message from VF to PF) to give a hint to PF to update
its bulletin board.

Please apply this series to net-next.

Thanks,
Shahed

Shahed Shaikh (2):
  qed* : use trust mode to allow VF to override forced MAC
  qed* : Add new TLV to request PF to update MAC in bulletin board

 drivers/net/ethernet/qlogic/qed/qed_l2.c       |  19 ++
 drivers/net/ethernet/qlogic/qed/qed_sriov.c    | 247 +++++++++++++++++++++++--
 drivers/net/ethernet/qlogic/qed/qed_vf.c       |  29 +++
 drivers/net/ethernet/qlogic/qed/qed_vf.h       |  21 +++
 drivers/net/ethernet/qlogic/qede/qede_filter.c |   7 +-
 include/linux/qed/qed_eth_if.h                 |   1 +
 6 files changed, 306 insertions(+), 18 deletions(-)

-- 
2.7.4

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox