Applied "ASoC: Intel: boards: Add bdw-rt5677 machine driver" to the asoc tree

2016-09-24 Thread Mark Brown
The patch

   ASoC: Intel: boards: Add bdw-rt5677 machine driver

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 2d995e5dc283adbfbf9c1eb81bf35ca7af2d22a6 Mon Sep 17 00:00:00 2001
From: John Keeping 
Date: Wed, 24 Aug 2016 22:06:36 +0100
Subject: [PATCH] ASoC: Intel: boards: Add bdw-rt5677 machine driver

This is used by the Chromebook Pixel 2015.

Signed-off-by: Ben Zhang 
Signed-off-by: Dylan Reid 
[j...@metanate.com:
 - forward-port driver from Chromium OS 3.14 tree to master
 - remove wake on voice function that isn't supported by upstream rt5677
   driver
 - remote owner assignment in platform_driver (Evan McClain)
 - convert to devm_snd_soc_register_card (Evan McClain)
 - add a full copyright header based on module license and Chromium OS
   Git history
]
Signed-off-by: John Keeping 
Tested-by: Genki Marshall 
Tested-by: Tom Rini 
Signed-off-by: Mark Brown 
---
 sound/soc/intel/Kconfig |  11 ++
 sound/soc/intel/boards/Makefile |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 
 sound/soc/intel/common/sst-acpi.c   |   1 +
 4 files changed, 361 insertions(+)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index fc6e78050a79..26eb5a0a5575 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -121,6 +121,17 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
  This adds audio driver for Intel Baytrail platform based boards
  with the MAX98090 audio codec.
 
+config SND_SOC_INTEL_BDW_RT5677_MACH
+   tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
+   depends on X86_INTEL_LPSS && GPIOLIB && I2C && DW_DMAC
+   depends on DW_DMAC_CORE=y
+   select SND_SOC_INTEL_SST
+   select SND_SOC_INTEL_HASWELL
+   select SND_SOC_RT5677
+   help
+ This adds support for Intel Broadwell platform based boards with
+ the RT5677 audio codec.
+
 config SND_SOC_INTEL_BROADWELL_MACH
tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
depends on X86_INTEL_LPSS && I2C && DW_DMAC && \
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index dac03a06bfd8..5639f10774e6 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -1,6 +1,7 @@
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
+snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += 
snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += 
snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
+obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
diff --git a/sound/soc/intel/boards/bdw-rt5677.c 
b/sound/soc/intel/boards/bdw-rt5677.c
new file mode 100644
index ..547e6705bf6d
--- /dev/null
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -0,0 +1,347 @@
+/*
+ * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
+ *
+ * Copyright (c) 2014, The Chromium OS Authors.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the 

Applied "ASoC: Intel: boards: Add bdw-rt5677 machine driver" to the asoc tree

2016-09-24 Thread Mark Brown
The patch

   ASoC: Intel: boards: Add bdw-rt5677 machine driver

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 2d995e5dc283adbfbf9c1eb81bf35ca7af2d22a6 Mon Sep 17 00:00:00 2001
From: John Keeping 
Date: Wed, 24 Aug 2016 22:06:36 +0100
Subject: [PATCH] ASoC: Intel: boards: Add bdw-rt5677 machine driver

This is used by the Chromebook Pixel 2015.

Signed-off-by: Ben Zhang 
Signed-off-by: Dylan Reid 
[j...@metanate.com:
 - forward-port driver from Chromium OS 3.14 tree to master
 - remove wake on voice function that isn't supported by upstream rt5677
   driver
 - remote owner assignment in platform_driver (Evan McClain)
 - convert to devm_snd_soc_register_card (Evan McClain)
 - add a full copyright header based on module license and Chromium OS
   Git history
]
Signed-off-by: John Keeping 
Tested-by: Genki Marshall 
Tested-by: Tom Rini 
Signed-off-by: Mark Brown 
---
 sound/soc/intel/Kconfig |  11 ++
 sound/soc/intel/boards/Makefile |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 
 sound/soc/intel/common/sst-acpi.c   |   1 +
 4 files changed, 361 insertions(+)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index fc6e78050a79..26eb5a0a5575 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -121,6 +121,17 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
  This adds audio driver for Intel Baytrail platform based boards
  with the MAX98090 audio codec.
 
+config SND_SOC_INTEL_BDW_RT5677_MACH
+   tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
+   depends on X86_INTEL_LPSS && GPIOLIB && I2C && DW_DMAC
+   depends on DW_DMAC_CORE=y
+   select SND_SOC_INTEL_SST
+   select SND_SOC_INTEL_HASWELL
+   select SND_SOC_RT5677
+   help
+ This adds support for Intel Broadwell platform based boards with
+ the RT5677 audio codec.
+
 config SND_SOC_INTEL_BROADWELL_MACH
tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
depends on X86_INTEL_LPSS && I2C && DW_DMAC && \
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index dac03a06bfd8..5639f10774e6 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -1,6 +1,7 @@
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
+snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += 
snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += 
snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
+obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
diff --git a/sound/soc/intel/boards/bdw-rt5677.c 
b/sound/soc/intel/boards/bdw-rt5677.c
new file mode 100644
index ..547e6705bf6d
--- /dev/null
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -0,0 +1,347 @@
+/*
+ * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
+ *
+ * Copyright (c) 2014, The Chromium OS Authors.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *

Applied "ASoC: rt5677: Add ACPI support" to the asoc tree

2016-09-24 Thread Mark Brown
The patch

   ASoC: rt5677: Add ACPI support

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 89128534f925711eea1653c264683b7d14a46530 Mon Sep 17 00:00:00 2001
From: John Keeping 
Date: Wed, 24 Aug 2016 22:06:35 +0100
Subject: [PATCH] ASoC: rt5677: Add ACPI support

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, but
does not use the standard DT property names so add a new function to
parse the codec properties from these ACPI properties.

Also, the GPIOs are only available by index, so we need to register a
mapping to allow machine drivers to access the GPIOs by name.

Signed-off-by: John Keeping 
Tested-by: Tom Rini 
Signed-off-by: Mark Brown 
---
 sound/soc/codecs/rt5677.c | 53 ++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index da9483c1c6fb..0e7aba1af881 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,15 @@
 
 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
 
+/* GPIO indexes defined by ACPI */
+enum {
+   RT5677_GPIO_PLUG_DET= 0,
+   RT5677_GPIO_MIC_PRESENT_L   = 1,
+   RT5677_GPIO_HOTWORD_DET_L   = 2,
+   RT5677_GPIO_DSP_INT = 3,
+   RT5677_GPIO_HP_AMP_SHDN_L   = 4,
+};
+
 static const struct regmap_range_cfg rt5677_ranges[] = {
{
.name = "PR",
@@ -5018,10 +5028,47 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
{ "rt5677", RT5677 },
{ "rt5676", RT5676 },
+   { "RT5677CE:00", RT5677 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
 
+static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 
0, false };
+static const struct acpi_gpio_params mic_present_gpio = { 
RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const struct acpi_gpio_params headphone_enable_gpio = { 
RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
+
+static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
+   { "plug-det-gpios", _det_gpio, 1 },
+   { "mic-present-gpios", _present_gpio, 1 },
+   { "headphone-enable-gpios", _enable_gpio, 1 },
+   { NULL },
+};
+
+static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
+   struct device *dev)
+{
+   int ret;
+   u32 val;
+
+   ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+   bdw_rt5677_gpios);
+   if (ret)
+   dev_warn(dev, "Failed to add driver gpios\n");
+
+   if (!device_property_read_u32(dev, "DCLK", ))
+   rt5677->pdata.dmic2_clk_pin = val;
+
+   rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1");
+   rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");
+   rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1");
+   rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2");
+   rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3");
+
+   device_property_read_u32(dev, "JD1", >pdata.jd1_gpio);
+   device_property_read_u32(dev, "JD2", >pdata.jd2_gpio);
+   device_property_read_u32(dev, "JD3", >pdata.jd3_gpio);
+}
+
 static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
struct device *dev)
 {
@@ -5127,8 +5174,12 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
 
if (pdata)
rt5677->pdata = *pdata;
-   else
+   else if (i2c->dev.of_node)
rt5677_read_device_properties(rt5677, >dev);
+   else if (ACPI_HANDLE(>dev))
+   rt5677_read_acpi_properties(rt5677, >dev);
+   else
+   return -EINVAL;
 
/* pow-ldo2 and reset are optional. The codec pins may be statically
 * connected on the board without gpios. If the gpio device property
-- 
2.9.3



Applied "ASoC: rt5677: Add ACPI support" to the asoc tree

2016-09-24 Thread Mark Brown
The patch

   ASoC: rt5677: Add ACPI support

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 89128534f925711eea1653c264683b7d14a46530 Mon Sep 17 00:00:00 2001
From: John Keeping 
Date: Wed, 24 Aug 2016 22:06:35 +0100
Subject: [PATCH] ASoC: rt5677: Add ACPI support

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, but
does not use the standard DT property names so add a new function to
parse the codec properties from these ACPI properties.

Also, the GPIOs are only available by index, so we need to register a
mapping to allow machine drivers to access the GPIOs by name.

Signed-off-by: John Keeping 
Tested-by: Tom Rini 
Signed-off-by: Mark Brown 
---
 sound/soc/codecs/rt5677.c | 53 ++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index da9483c1c6fb..0e7aba1af881 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,15 @@
 
 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
 
+/* GPIO indexes defined by ACPI */
+enum {
+   RT5677_GPIO_PLUG_DET= 0,
+   RT5677_GPIO_MIC_PRESENT_L   = 1,
+   RT5677_GPIO_HOTWORD_DET_L   = 2,
+   RT5677_GPIO_DSP_INT = 3,
+   RT5677_GPIO_HP_AMP_SHDN_L   = 4,
+};
+
 static const struct regmap_range_cfg rt5677_ranges[] = {
{
.name = "PR",
@@ -5018,10 +5028,47 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
{ "rt5677", RT5677 },
{ "rt5676", RT5676 },
+   { "RT5677CE:00", RT5677 },
{ }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
 
+static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 
0, false };
+static const struct acpi_gpio_params mic_present_gpio = { 
RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const struct acpi_gpio_params headphone_enable_gpio = { 
RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
+
+static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
+   { "plug-det-gpios", _det_gpio, 1 },
+   { "mic-present-gpios", _present_gpio, 1 },
+   { "headphone-enable-gpios", _enable_gpio, 1 },
+   { NULL },
+};
+
+static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
+   struct device *dev)
+{
+   int ret;
+   u32 val;
+
+   ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+   bdw_rt5677_gpios);
+   if (ret)
+   dev_warn(dev, "Failed to add driver gpios\n");
+
+   if (!device_property_read_u32(dev, "DCLK", ))
+   rt5677->pdata.dmic2_clk_pin = val;
+
+   rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1");
+   rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");
+   rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1");
+   rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2");
+   rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3");
+
+   device_property_read_u32(dev, "JD1", >pdata.jd1_gpio);
+   device_property_read_u32(dev, "JD2", >pdata.jd2_gpio);
+   device_property_read_u32(dev, "JD3", >pdata.jd3_gpio);
+}
+
 static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
struct device *dev)
 {
@@ -5127,8 +5174,12 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
 
if (pdata)
rt5677->pdata = *pdata;
-   else
+   else if (i2c->dev.of_node)
rt5677_read_device_properties(rt5677, >dev);
+   else if (ACPI_HANDLE(>dev))
+   rt5677_read_acpi_properties(rt5677, >dev);
+   else
+   return -EINVAL;
 
/* pow-ldo2 and reset are optional. The codec pins may be statically
 * connected on the board without gpios. If the gpio device property
-- 
2.9.3



[PATCH 3/3] megaraid_sas: clean function declarations in megaraid_sas_base.c up

2016-09-24 Thread Baoyou Xie
We get 8 warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_fusion.c:281:1: warning: no previous 
prototype for 'megasas_free_cmds_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:714:1: warning: no previous 
prototype for 'megasas_ioc_init_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:1038:1: warning: no previous 
prototype for 'megasas_get_map_info' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:1061:1: warning: no previous 
prototype for 'megasas_sync_map_info' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:2599:1: warning: no previous 
prototype for 'megasas_release_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:2833:7: warning: no previous 
prototype for 'megasas_reset_reply_desc' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:3354:5: warning: no previous 
prototype for 'megasas_check_mpio_paths' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:3664:6: warning: no previous 
prototype for 'megasas_fusion_ocr_wq' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/scsi/megaraid/megaraid_sas_base.c, but should be
declared in a header file. thus can be recognized in other file.

So this patch moves the declarations into
drivers/scsi/megaraid/megaraid_sas.h.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas.h  | 15 ++-
 drivers/scsi/megaraid/megaraid_sas_base.c | 14 --
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index d1a6ea5..aad81c6 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2398,5 +2398,18 @@ void megasas_sriov_heartbeat_handler(unsigned long 
instance_addr);
 
 void megasas_free_cmds(struct megasas_instance *instance);
 int megasas_alloc_cmds(struct megasas_instance *instance);
-
+void
+megasas_free_cmds_fusion(struct megasas_instance *instance);
+int
+megasas_ioc_init_fusion(struct megasas_instance *instance);
+u8
+megasas_get_map_info(struct megasas_instance *instance);
+int
+megasas_sync_map_info(struct megasas_instance *instance);
+void
+megasas_release_fusion(struct megasas_instance *instance);
+void megasas_reset_reply_desc(struct megasas_instance *instance);
+int megasas_check_mpio_paths(struct megasas_instance *instance,
+struct scsi_cmnd *scmd);
+void megasas_fusion_ocr_wq(struct work_struct *work);
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 1b033da..73f4e27 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -189,25 +189,11 @@ u32
 megasas_build_and_issue_cmd(struct megasas_instance *instance,
struct scsi_cmnd *scmd);
 static void megasas_complete_cmd_dpc(unsigned long instance_addr);
-void
-megasas_release_fusion(struct megasas_instance *instance);
-int
-megasas_ioc_init_fusion(struct megasas_instance *instance);
-void
-megasas_free_cmds_fusion(struct megasas_instance *instance);
-u8
-megasas_get_map_info(struct megasas_instance *instance);
-int
-megasas_sync_map_info(struct megasas_instance *instance);
 int
 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
int seconds);
-void megasas_reset_reply_desc(struct megasas_instance *instance);
-void megasas_fusion_ocr_wq(struct work_struct *work);
 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance,
 int initial);
-int megasas_check_mpio_paths(struct megasas_instance *instance,
-struct scsi_cmnd *scmd);
 
 static int
 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
-- 
2.7.4



[PATCH 3/3] megaraid_sas: clean function declarations in megaraid_sas_base.c up

2016-09-24 Thread Baoyou Xie
We get 8 warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_fusion.c:281:1: warning: no previous 
prototype for 'megasas_free_cmds_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:714:1: warning: no previous 
prototype for 'megasas_ioc_init_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:1038:1: warning: no previous 
prototype for 'megasas_get_map_info' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:1061:1: warning: no previous 
prototype for 'megasas_sync_map_info' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:2599:1: warning: no previous 
prototype for 'megasas_release_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:2833:7: warning: no previous 
prototype for 'megasas_reset_reply_desc' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:3354:5: warning: no previous 
prototype for 'megasas_check_mpio_paths' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:3664:6: warning: no previous 
prototype for 'megasas_fusion_ocr_wq' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/scsi/megaraid/megaraid_sas_base.c, but should be
declared in a header file. thus can be recognized in other file.

So this patch moves the declarations into
drivers/scsi/megaraid/megaraid_sas.h.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas.h  | 15 ++-
 drivers/scsi/megaraid/megaraid_sas_base.c | 14 --
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index d1a6ea5..aad81c6 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2398,5 +2398,18 @@ void megasas_sriov_heartbeat_handler(unsigned long 
instance_addr);
 
 void megasas_free_cmds(struct megasas_instance *instance);
 int megasas_alloc_cmds(struct megasas_instance *instance);
-
+void
+megasas_free_cmds_fusion(struct megasas_instance *instance);
+int
+megasas_ioc_init_fusion(struct megasas_instance *instance);
+u8
+megasas_get_map_info(struct megasas_instance *instance);
+int
+megasas_sync_map_info(struct megasas_instance *instance);
+void
+megasas_release_fusion(struct megasas_instance *instance);
+void megasas_reset_reply_desc(struct megasas_instance *instance);
+int megasas_check_mpio_paths(struct megasas_instance *instance,
+struct scsi_cmnd *scmd);
+void megasas_fusion_ocr_wq(struct work_struct *work);
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 1b033da..73f4e27 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -189,25 +189,11 @@ u32
 megasas_build_and_issue_cmd(struct megasas_instance *instance,
struct scsi_cmnd *scmd);
 static void megasas_complete_cmd_dpc(unsigned long instance_addr);
-void
-megasas_release_fusion(struct megasas_instance *instance);
-int
-megasas_ioc_init_fusion(struct megasas_instance *instance);
-void
-megasas_free_cmds_fusion(struct megasas_instance *instance);
-u8
-megasas_get_map_info(struct megasas_instance *instance);
-int
-megasas_sync_map_info(struct megasas_instance *instance);
 int
 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
int seconds);
-void megasas_reset_reply_desc(struct megasas_instance *instance);
-void megasas_fusion_ocr_wq(struct work_struct *work);
 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance,
 int initial);
-int megasas_check_mpio_paths(struct megasas_instance *instance,
-struct scsi_cmnd *scmd);
 
 static int
 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
-- 
2.7.4



[PATCH 2/3] megaraid_sas: clean function declarations in megaraid_sas_fusion.c up

2016-09-24 Thread Baoyou Xie
We get 10 warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_base.c:226:21: warning: no previous 
prototype for 'megasas_get_cmd' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:252:1: warning: no previous 
declaration for 'megasas_return_cmd' [-Wmissing-declarations]
drivers/scsi/megaraid/megaraid_sas_base.c:998:1: warning: no previous prototype 
for 'megasas_issue_polled' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:1936:6: warning: no previous 
prototype for 'megaraid_sas_kill_hba' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:1965:1: warning: no previous 
prototype for 'megasas_check_and_restore_queue_depth' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2043:6: warning: no previous 
prototype for 'megasas_start_timer' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2366:5: warning: no previous 
prototype for 'megasas_sriov_start_heartbeat' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2436:6: warning: no previous 
prototype for 'megasas_sriov_heartbeat_handler' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:3878:6: warning: no previous 
prototype for 'megasas_free_cmds' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:3915:5: warning: no previous 
prototype for 'megasas_alloc_cmds' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/scsi/megaraid/megaraid_sas_fusion.c, but should be
declared in a header file. thus can be recognized in other file.

So this patch moves the declarations into
drivers/scsi/megaraid/megaraid_sas.h.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas.h| 19 +++
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 15 ---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index ca86c88..d1a6ea5 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2380,4 +2380,23 @@ void megasas_update_sdev_properties(struct scsi_device 
*sdev);
 int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
 int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
 int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
+struct megasas_cmd *megasas_get_cmd(struct megasas_instance *instance);
+void
+megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd);
+int
+megasas_issue_polled(struct megasas_instance *instance,
+struct megasas_cmd *cmd);
+void megaraid_sas_kill_hba(struct megasas_instance *instance);
+void
+megasas_check_and_restore_queue_depth(struct megasas_instance *instance);
+void megasas_start_timer(struct megasas_instance *instance,
+struct timer_list *timer,
+void *fn, unsigned long interval);
+int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
+ int initial);
+void megasas_sriov_heartbeat_handler(unsigned long instance_addr);
+
+void megasas_free_cmds(struct megasas_instance *instance);
+int megasas_alloc_cmds(struct megasas_instance *instance);
+
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index e7b77e1..6210922 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -59,9 +59,6 @@
 #include "megaraid_sas.h"
 
 
-extern void megasas_free_cmds(struct megasas_instance *instance);
-extern struct megasas_cmd *megasas_get_cmd(struct megasas_instance
-  *instance);
 extern void
 megasas_complete_cmd(struct megasas_instance *instance,
 struct megasas_cmd *cmd, u8 alt_status);
@@ -69,24 +66,12 @@ int
 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
  int seconds);
 
-void
-megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd);
-int megasas_alloc_cmds(struct megasas_instance *instance);
 int
 megasas_clear_intr_fusion(struct megasas_register_set __iomem *regs);
-int
-megasas_issue_polled(struct megasas_instance *instance,
-struct megasas_cmd *cmd);
-void
-megasas_check_and_restore_queue_depth(struct megasas_instance *instance);
 
 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
-void megaraid_sas_kill_hba(struct megasas_instance *instance);
 
 extern u32 megasas_dbg_lvl;
-void megasas_sriov_heartbeat_handler(unsigned long instance_addr);
-int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
- int initial);
 void megasas_start_timer(struct megasas_instance *instance,
struct timer_list *timer,
 void *fn, unsigned long interval);
-- 

[PATCH 2/3] megaraid_sas: clean function declarations in megaraid_sas_fusion.c up

2016-09-24 Thread Baoyou Xie
We get 10 warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_base.c:226:21: warning: no previous 
prototype for 'megasas_get_cmd' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:252:1: warning: no previous 
declaration for 'megasas_return_cmd' [-Wmissing-declarations]
drivers/scsi/megaraid/megaraid_sas_base.c:998:1: warning: no previous prototype 
for 'megasas_issue_polled' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:1936:6: warning: no previous 
prototype for 'megaraid_sas_kill_hba' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:1965:1: warning: no previous 
prototype for 'megasas_check_and_restore_queue_depth' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2043:6: warning: no previous 
prototype for 'megasas_start_timer' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2366:5: warning: no previous 
prototype for 'megasas_sriov_start_heartbeat' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:2436:6: warning: no previous 
prototype for 'megasas_sriov_heartbeat_handler' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:3878:6: warning: no previous 
prototype for 'megasas_free_cmds' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_base.c:3915:5: warning: no previous 
prototype for 'megasas_alloc_cmds' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/scsi/megaraid/megaraid_sas_fusion.c, but should be
declared in a header file. thus can be recognized in other file.

So this patch moves the declarations into
drivers/scsi/megaraid/megaraid_sas.h.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas.h| 19 +++
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 15 ---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index ca86c88..d1a6ea5 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2380,4 +2380,23 @@ void megasas_update_sdev_properties(struct scsi_device 
*sdev);
 int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
 int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
 int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
+struct megasas_cmd *megasas_get_cmd(struct megasas_instance *instance);
+void
+megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd);
+int
+megasas_issue_polled(struct megasas_instance *instance,
+struct megasas_cmd *cmd);
+void megaraid_sas_kill_hba(struct megasas_instance *instance);
+void
+megasas_check_and_restore_queue_depth(struct megasas_instance *instance);
+void megasas_start_timer(struct megasas_instance *instance,
+struct timer_list *timer,
+void *fn, unsigned long interval);
+int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
+ int initial);
+void megasas_sriov_heartbeat_handler(unsigned long instance_addr);
+
+void megasas_free_cmds(struct megasas_instance *instance);
+int megasas_alloc_cmds(struct megasas_instance *instance);
+
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index e7b77e1..6210922 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -59,9 +59,6 @@
 #include "megaraid_sas.h"
 
 
-extern void megasas_free_cmds(struct megasas_instance *instance);
-extern struct megasas_cmd *megasas_get_cmd(struct megasas_instance
-  *instance);
 extern void
 megasas_complete_cmd(struct megasas_instance *instance,
 struct megasas_cmd *cmd, u8 alt_status);
@@ -69,24 +66,12 @@ int
 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
  int seconds);
 
-void
-megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd);
-int megasas_alloc_cmds(struct megasas_instance *instance);
 int
 megasas_clear_intr_fusion(struct megasas_register_set __iomem *regs);
-int
-megasas_issue_polled(struct megasas_instance *instance,
-struct megasas_cmd *cmd);
-void
-megasas_check_and_restore_queue_depth(struct megasas_instance *instance);
 
 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
-void megaraid_sas_kill_hba(struct megasas_instance *instance);
 
 extern u32 megasas_dbg_lvl;
-void megasas_sriov_heartbeat_handler(unsigned long instance_addr);
-int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
- int initial);
 void megasas_start_timer(struct megasas_instance *instance,
struct timer_list *timer,
 void *fn, unsigned long interval);
-- 
2.7.4



[PATCH 1/3] megaraid_sas: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_fp.c:94:5: warning: no previous prototype 
for 'mega_mod64' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:112:5: warning: no previous prototype 
for 'mega_div64_32' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:177:6: warning: no previous prototype 
for 'MR_PopulateDrvRaidMap' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:315:5: warning: no previous prototype 
for 'MR_GetSpanBlock' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:451:5: warning: no previous prototype 
for 'mr_spanset_get_span_block' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:692:4: warning: no previous prototype 
for 'get_arm' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:815:4: warning: no previous prototype 
for 'MR_GetPhyParams' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:1293:4: warning: no previous prototype 
for 'megasas_get_best_arm_pd' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:106:1: warning: no previous 
prototype for 'megasas_enable_intr_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:127:1: warning: no previous 
prototype for 'megasas_disable_intr_fusion' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   |  6 ++--
 drivers/scsi/megaraid/megaraid_sas_fp.c | 30 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 52 +++--
 3 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index c236c4d..1b033da 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -209,7 +209,7 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
 int megasas_check_mpio_paths(struct megasas_instance *instance,
 struct scsi_cmnd *scmd);
 
-int
+static int
 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
instance->instancet->fire_cmd(instance,
@@ -2057,7 +2057,7 @@ megasas_internal_reset_defer_cmds(struct megasas_instance 
*instance);
 static void
 process_fw_state_change_wq(struct work_struct *work);
 
-void megasas_do_ocr(struct megasas_instance *instance)
+static void megasas_do_ocr(struct megasas_instance *instance)
 {
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
@@ -3981,7 +3981,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
  * Return 0 for only Fusion adapter, if driver load/unload is not in progress
  * or FW is not under OCR.
  */
-inline int
+static inline int
 dcmd_timeout_ocr_possible(struct megasas_instance *instance) {
 
if (!instance->ctrl_context)
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index e413113..d22bb59 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -91,7 +91,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance 
*instance, u32 ld,
 static u64 get_row_from_strip(struct megasas_instance *instance, u32 ld,
u64 strip, struct MR_DRV_RAID_MAP_ALL *map);
 
-u32 mega_mod64(u64 dividend, u32 divisor)
+static u32 mega_mod64(u64 dividend, u32 divisor)
 {
u64 d;
u32 remainder;
@@ -109,7 +109,7 @@ u32 mega_mod64(u64 dividend, u32 divisor)
  *
  * @return quotient
  **/
-u64 mega_div64_32(uint64_t dividend, uint32_t divisor)
+static u64 mega_div64_32(uint64_t dividend, uint32_t divisor)
 {
u32 remainder;
u64 d;
@@ -174,7 +174,7 @@ static struct MR_LD_SPAN *MR_LdSpanPtrGet(u32 ld, u32 span,
 /*
  * This function will Populate Driver Map using firmware raid map
  */
-void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
+static void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
 {
struct fusion_context *fusion = instance->ctrl_context;
struct MR_FW_RAID_MAP_ALL *fw_map_old= NULL;
@@ -312,8 +312,8 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
return 1;
 }
 
-u32 MR_GetSpanBlock(u32 ld, u64 row, u64 *span_blk,
-   struct MR_DRV_RAID_MAP_ALL *map)
+static u32 MR_GetSpanBlock(u32 ld, u64 row, u64 *span_blk,
+  struct MR_DRV_RAID_MAP_ALL *map)
 {
struct MR_SPAN_BLOCK_INFO *pSpanBlock = MR_LdSpanInfoGet(ld, map);
struct MR_QUAD_ELEMENT*quad;
@@ -448,8 +448,10 @@ static int getSpanInfo(struct MR_DRV_RAID_MAP_ALL *map,
 *div_error- Devide error code.
 */
 
-u32 

[PATCH 1/3] megaraid_sas: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/megaraid/megaraid_sas_fp.c:94:5: warning: no previous prototype 
for 'mega_mod64' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:112:5: warning: no previous prototype 
for 'mega_div64_32' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:177:6: warning: no previous prototype 
for 'MR_PopulateDrvRaidMap' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:315:5: warning: no previous prototype 
for 'MR_GetSpanBlock' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:451:5: warning: no previous prototype 
for 'mr_spanset_get_span_block' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:692:4: warning: no previous prototype 
for 'get_arm' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:815:4: warning: no previous prototype 
for 'MR_GetPhyParams' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fp.c:1293:4: warning: no previous prototype 
for 'megasas_get_best_arm_pd' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:106:1: warning: no previous 
prototype for 'megasas_enable_intr_fusion' [-Wmissing-prototypes]
drivers/scsi/megaraid/megaraid_sas_fusion.c:127:1: warning: no previous 
prototype for 'megasas_disable_intr_fusion' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   |  6 ++--
 drivers/scsi/megaraid/megaraid_sas_fp.c | 30 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 52 +++--
 3 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index c236c4d..1b033da 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -209,7 +209,7 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
 int megasas_check_mpio_paths(struct megasas_instance *instance,
 struct scsi_cmnd *scmd);
 
-int
+static int
 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
instance->instancet->fire_cmd(instance,
@@ -2057,7 +2057,7 @@ megasas_internal_reset_defer_cmds(struct megasas_instance 
*instance);
 static void
 process_fw_state_change_wq(struct work_struct *work);
 
-void megasas_do_ocr(struct megasas_instance *instance)
+static void megasas_do_ocr(struct megasas_instance *instance)
 {
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
@@ -3981,7 +3981,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
  * Return 0 for only Fusion adapter, if driver load/unload is not in progress
  * or FW is not under OCR.
  */
-inline int
+static inline int
 dcmd_timeout_ocr_possible(struct megasas_instance *instance) {
 
if (!instance->ctrl_context)
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index e413113..d22bb59 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -91,7 +91,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance 
*instance, u32 ld,
 static u64 get_row_from_strip(struct megasas_instance *instance, u32 ld,
u64 strip, struct MR_DRV_RAID_MAP_ALL *map);
 
-u32 mega_mod64(u64 dividend, u32 divisor)
+static u32 mega_mod64(u64 dividend, u32 divisor)
 {
u64 d;
u32 remainder;
@@ -109,7 +109,7 @@ u32 mega_mod64(u64 dividend, u32 divisor)
  *
  * @return quotient
  **/
-u64 mega_div64_32(uint64_t dividend, uint32_t divisor)
+static u64 mega_div64_32(uint64_t dividend, uint32_t divisor)
 {
u32 remainder;
u64 d;
@@ -174,7 +174,7 @@ static struct MR_LD_SPAN *MR_LdSpanPtrGet(u32 ld, u32 span,
 /*
  * This function will Populate Driver Map using firmware raid map
  */
-void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
+static void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
 {
struct fusion_context *fusion = instance->ctrl_context;
struct MR_FW_RAID_MAP_ALL *fw_map_old= NULL;
@@ -312,8 +312,8 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
return 1;
 }
 
-u32 MR_GetSpanBlock(u32 ld, u64 row, u64 *span_blk,
-   struct MR_DRV_RAID_MAP_ALL *map)
+static u32 MR_GetSpanBlock(u32 ld, u64 row, u64 *span_blk,
+  struct MR_DRV_RAID_MAP_ALL *map)
 {
struct MR_SPAN_BLOCK_INFO *pSpanBlock = MR_LdSpanInfoGet(ld, map);
struct MR_QUAD_ELEMENT*quad;
@@ -448,8 +448,10 @@ static int getSpanInfo(struct MR_DRV_RAID_MAP_ALL *map,
 *div_error- Devide error code.
 */
 
-u32 

[PATCH] [SCSI] mvsas: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/mvsas/mv_sas.c:77:18: warning: no previous prototype for 
'mvs_find_dev_mvi' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:105:5: warning: no previous prototype for 
'mvs_find_dev_phyno' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1161:20: warning: no previous prototype for 
'mvs_alloc_dev' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1178:6: warning: no previous prototype for 
'mvs_free_dev' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1188:5: warning: no previous prototype for 
'mvs_dev_found_notify' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1244:6: warning: no previous prototype for 
'mvs_dev_gone_notify' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1614:6: warning: no previous prototype for 
'mvs_set_sense' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1653:6: warning: no previous prototype for 
'mvs_fill_ssp_resp_iu' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_64xx.c:139:6: warning: no previous prototype for 
'mvs_64xx_clear_srs_irq' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_64xx.c:566:6: warning: no previous prototype for 
'mvs_64xx_make_prd' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/mvsas/mv_64xx.c | 19 ++-
 drivers/scsi/mvsas/mv_94xx.c | 41 +
 drivers/scsi/mvsas/mv_sas.c  | 16 
 3 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_64xx.c b/drivers/scsi/mvsas/mv_64xx.c
index 8bb0699..b757d38 100644
--- a/drivers/scsi/mvsas/mv_64xx.c
+++ b/drivers/scsi/mvsas/mv_64xx.c
@@ -136,7 +136,8 @@ static void mvs_64xx_phy_reset(struct mvs_info *mvi, u32 
phy_id, int hard)
}
 }
 
-void mvs_64xx_clear_srs_irq(struct mvs_info *mvi, u8 reg_set, u8 clear_all)
+static void
+mvs_64xx_clear_srs_irq(struct mvs_info *mvi, u8 reg_set, u8 clear_all)
 {
void __iomem *regs = mvi->regs;
u32 tmp;
@@ -563,7 +564,7 @@ static u8 mvs_64xx_assign_reg_set(struct mvs_info *mvi, u8 
*tfs)
return MVS_ID_NOT_MAPPED;
 }
 
-void mvs_64xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
+static void mvs_64xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
 {
int i;
struct scatterlist *sg;
@@ -633,7 +634,7 @@ static void mvs_64xx_phy_work_around(struct mvs_info *mvi, 
int i)
mvs_write_port_vsr_data(mvi, i, tmp);
 }
 
-void mvs_64xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
+static void mvs_64xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
struct sas_phy_linkrates *rates)
 {
u32 lrmin = 0, lrmax = 0;
@@ -668,20 +669,20 @@ static void mvs_64xx_clear_active_cmds(struct mvs_info 
*mvi)
 }
 
 
-u32 mvs_64xx_spi_read_data(struct mvs_info *mvi)
+static u32 mvs_64xx_spi_read_data(struct mvs_info *mvi)
 {
void __iomem *regs = mvi->regs_ex;
return ior32(SPI_DATA_REG_64XX);
 }
 
-void mvs_64xx_spi_write_data(struct mvs_info *mvi, u32 data)
+static void mvs_64xx_spi_write_data(struct mvs_info *mvi, u32 data)
 {
void __iomem *regs = mvi->regs_ex;
 iow32(SPI_DATA_REG_64XX, data);
 }
 
 
-int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
+static int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
u32  *dwCmd,
u8   cmd,
u8   read,
@@ -705,7 +706,7 @@ int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
 }
 
 
-int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
+static int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
 {
void __iomem *regs = mvi->regs_ex;
int retry;
@@ -720,7 +721,7 @@ int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
return 0;
 }
 
-int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
+static int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
 {
void __iomem *regs = mvi->regs_ex;
u32 i, dwTmp;
@@ -735,7 +736,7 @@ int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 
timeout)
return -1;
 }
 
-void mvs_64xx_fix_dma(struct mvs_info *mvi, u32 phy_mask,
+static void mvs_64xx_fix_dma(struct mvs_info *mvi, u32 phy_mask,
int buf_len, int from, void *prd)
 {
int i;
diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c
index f6fc4a7..4c57d9a 100644
--- a/drivers/scsi/mvsas/mv_94xx.c
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -48,8 +48,8 @@ static void mvs_94xx_detect_porttype(struct mvs_info *mvi, 
int i)
}
 }
 
-void set_phy_tuning(struct mvs_info *mvi, int phy_id,
-   struct phy_tuning phy_tuning)
+static void set_phy_tuning(struct mvs_info *mvi, int phy_id,
+  

[PATCH] [SCSI] mvsas: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/mvsas/mv_sas.c:77:18: warning: no previous prototype for 
'mvs_find_dev_mvi' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:105:5: warning: no previous prototype for 
'mvs_find_dev_phyno' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1161:20: warning: no previous prototype for 
'mvs_alloc_dev' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1178:6: warning: no previous prototype for 
'mvs_free_dev' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1188:5: warning: no previous prototype for 
'mvs_dev_found_notify' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1244:6: warning: no previous prototype for 
'mvs_dev_gone_notify' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1614:6: warning: no previous prototype for 
'mvs_set_sense' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_sas.c:1653:6: warning: no previous prototype for 
'mvs_fill_ssp_resp_iu' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_64xx.c:139:6: warning: no previous prototype for 
'mvs_64xx_clear_srs_irq' [-Wmissing-prototypes]
drivers/scsi/mvsas/mv_64xx.c:566:6: warning: no previous prototype for 
'mvs_64xx_make_prd' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/mvsas/mv_64xx.c | 19 ++-
 drivers/scsi/mvsas/mv_94xx.c | 41 +
 drivers/scsi/mvsas/mv_sas.c  | 16 
 3 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_64xx.c b/drivers/scsi/mvsas/mv_64xx.c
index 8bb0699..b757d38 100644
--- a/drivers/scsi/mvsas/mv_64xx.c
+++ b/drivers/scsi/mvsas/mv_64xx.c
@@ -136,7 +136,8 @@ static void mvs_64xx_phy_reset(struct mvs_info *mvi, u32 
phy_id, int hard)
}
 }
 
-void mvs_64xx_clear_srs_irq(struct mvs_info *mvi, u8 reg_set, u8 clear_all)
+static void
+mvs_64xx_clear_srs_irq(struct mvs_info *mvi, u8 reg_set, u8 clear_all)
 {
void __iomem *regs = mvi->regs;
u32 tmp;
@@ -563,7 +564,7 @@ static u8 mvs_64xx_assign_reg_set(struct mvs_info *mvi, u8 
*tfs)
return MVS_ID_NOT_MAPPED;
 }
 
-void mvs_64xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
+static void mvs_64xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
 {
int i;
struct scatterlist *sg;
@@ -633,7 +634,7 @@ static void mvs_64xx_phy_work_around(struct mvs_info *mvi, 
int i)
mvs_write_port_vsr_data(mvi, i, tmp);
 }
 
-void mvs_64xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
+static void mvs_64xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
struct sas_phy_linkrates *rates)
 {
u32 lrmin = 0, lrmax = 0;
@@ -668,20 +669,20 @@ static void mvs_64xx_clear_active_cmds(struct mvs_info 
*mvi)
 }
 
 
-u32 mvs_64xx_spi_read_data(struct mvs_info *mvi)
+static u32 mvs_64xx_spi_read_data(struct mvs_info *mvi)
 {
void __iomem *regs = mvi->regs_ex;
return ior32(SPI_DATA_REG_64XX);
 }
 
-void mvs_64xx_spi_write_data(struct mvs_info *mvi, u32 data)
+static void mvs_64xx_spi_write_data(struct mvs_info *mvi, u32 data)
 {
void __iomem *regs = mvi->regs_ex;
 iow32(SPI_DATA_REG_64XX, data);
 }
 
 
-int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
+static int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
u32  *dwCmd,
u8   cmd,
u8   read,
@@ -705,7 +706,7 @@ int mvs_64xx_spi_buildcmd(struct mvs_info *mvi,
 }
 
 
-int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
+static int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
 {
void __iomem *regs = mvi->regs_ex;
int retry;
@@ -720,7 +721,7 @@ int mvs_64xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
return 0;
 }
 
-int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
+static int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
 {
void __iomem *regs = mvi->regs_ex;
u32 i, dwTmp;
@@ -735,7 +736,7 @@ int mvs_64xx_spi_waitdataready(struct mvs_info *mvi, u32 
timeout)
return -1;
 }
 
-void mvs_64xx_fix_dma(struct mvs_info *mvi, u32 phy_mask,
+static void mvs_64xx_fix_dma(struct mvs_info *mvi, u32 phy_mask,
int buf_len, int from, void *prd)
 {
int i;
diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c
index f6fc4a7..4c57d9a 100644
--- a/drivers/scsi/mvsas/mv_94xx.c
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -48,8 +48,8 @@ static void mvs_94xx_detect_porttype(struct mvs_info *mvi, 
int i)
}
 }
 
-void set_phy_tuning(struct mvs_info *mvi, int phy_id,
-   struct phy_tuning phy_tuning)
+static void set_phy_tuning(struct mvs_info *mvi, int phy_id,
+  struct phy_tuning 

[PATCH] lpfc: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/lpfc/lpfc_sli.c:5693:1: warning: no previous prototype for 
'lpfc_set_features' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_sli.c:8972:1: warning: no previous prototype for 
'lpfc_sli_calc_ring' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4621:1: warning: no previous prototype for 
'lpfc_rdp_res_link_service' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4633:1: warning: no previous prototype for 
'lpfc_rdp_res_sfp_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4698:1: warning: no previous prototype for 
'lpfc_rdp_res_link_error' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4727:1: warning: no previous prototype for 
'lpfc_rdp_res_bbc_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4752:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_temp_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4780:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_voltage_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4809:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_txbias_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4838:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_txpower_desc' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/lpfc/lpfc_ct.c   | 82 +--
 drivers/scsi/lpfc/lpfc_els.c  | 34 +-
 drivers/scsi/lpfc/lpfc_mbox.c |  4 +--
 drivers/scsi/lpfc/lpfc_sli.c  |  4 +--
 4 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 63e48d4..4ac03b1 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1535,7 +1535,7 @@ lpfc_fdmi_num_disc_check(struct lpfc_vport *vport)
 }
 
 /* Routines for all individual HBA attributes */
-int
+static int
 lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def 
*ad)
 {
struct lpfc_fdmi_attr_entry *ae;
@@ -1551,7 +1551,7 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct 
lpfc_fdmi_attr_def *ad)
ad->AttrType = cpu_to_be16(RHBA_NODENAME);
return size;
 }
-int
+static int
 lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_def *ad)
 {
@@ -1573,7 +1573,7 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
 {
struct lpfc_hba *phba = vport->phba;
@@ -1594,7 +1594,7 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct 
lpfc_fdmi_attr_def *ad)
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
 struct lpfc_fdmi_attr_def *ad)
 {
@@ -1615,7 +1615,7 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1637,7 +1637,7 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1669,7 +1669,7 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_def *ad)
 {
@@ -1690,7 +1690,7 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1715,7 +1715,7 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1736,7 +1736,7 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
  struct lpfc_fdmi_attr_def *ad)
 {
@@ -1759,7 +1759,7 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
  struct lpfc_fdmi_attr_def *ad)
 {
@@ -1775,7 +1775,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,
 struct lpfc_fdmi_attr_def *ad)
 {
@@ -1794,7 +1794,7 @@ 

[PATCH] lpfc: mark symbols static where possible

2016-09-24 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/scsi/lpfc/lpfc_sli.c:5693:1: warning: no previous prototype for 
'lpfc_set_features' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_sli.c:8972:1: warning: no previous prototype for 
'lpfc_sli_calc_ring' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4621:1: warning: no previous prototype for 
'lpfc_rdp_res_link_service' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4633:1: warning: no previous prototype for 
'lpfc_rdp_res_sfp_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4698:1: warning: no previous prototype for 
'lpfc_rdp_res_link_error' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4727:1: warning: no previous prototype for 
'lpfc_rdp_res_bbc_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4752:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_temp_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4780:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_voltage_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4809:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_txbias_desc' [-Wmissing-prototypes]
drivers/scsi/lpfc/lpfc_els.c:4838:1: warning: no previous prototype for 
'lpfc_rdp_res_oed_txpower_desc' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/scsi/lpfc/lpfc_ct.c   | 82 +--
 drivers/scsi/lpfc/lpfc_els.c  | 34 +-
 drivers/scsi/lpfc/lpfc_mbox.c |  4 +--
 drivers/scsi/lpfc/lpfc_sli.c  |  4 +--
 4 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 63e48d4..4ac03b1 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1535,7 +1535,7 @@ lpfc_fdmi_num_disc_check(struct lpfc_vport *vport)
 }
 
 /* Routines for all individual HBA attributes */
-int
+static int
 lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def 
*ad)
 {
struct lpfc_fdmi_attr_entry *ae;
@@ -1551,7 +1551,7 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct 
lpfc_fdmi_attr_def *ad)
ad->AttrType = cpu_to_be16(RHBA_NODENAME);
return size;
 }
-int
+static int
 lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_def *ad)
 {
@@ -1573,7 +1573,7 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
 {
struct lpfc_hba *phba = vport->phba;
@@ -1594,7 +1594,7 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct 
lpfc_fdmi_attr_def *ad)
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
 struct lpfc_fdmi_attr_def *ad)
 {
@@ -1615,7 +1615,7 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1637,7 +1637,7 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1669,7 +1669,7 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_def *ad)
 {
@@ -1690,7 +1690,7 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1715,7 +1715,7 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
   struct lpfc_fdmi_attr_def *ad)
 {
@@ -1736,7 +1736,7 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
  struct lpfc_fdmi_attr_def *ad)
 {
@@ -1759,7 +1759,7 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
  struct lpfc_fdmi_attr_def *ad)
 {
@@ -1775,7 +1775,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
return size;
 }
 
-int
+static int
 lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,
 struct lpfc_fdmi_attr_def *ad)
 {
@@ -1794,7 +1794,7 @@ lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport 

Re: [PATCH][V2] mlxsw: spectrum: remove redundant check if err is zero

2016-09-24 Thread Ido Schimmel
On Sat, Sep 24, 2016 at 06:03:38PM -0700, Colin King wrote:
> From: Colin Ian King 
> 
> There is an earlier check and return if err is non-zero, so
> the check to see if it is zero is redundant in every iteration
> of the loop and hence the check can be removed.
> 
> Signed-off-by: Colin Ian King 

The subject and commit message are wrong. I think you copy-pasted them
from an earlier patch.

> ---
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
> b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> index 2a61617..1073673 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> @@ -117,11 +117,11 @@ static int validate_filter(struct net_device *dev,
>   return 0;
>  }
>  
> -static unsigned int get_filter_steerq(struct net_device *dev,
> -   struct ch_filter_specification *fs)
> +static int get_filter_steerq(struct net_device *dev,
> +  struct ch_filter_specification *fs)
>  {
>   struct adapter *adapter = netdev2adap(dev);
> - unsigned int iq;
> + int iq;
>  
>   /* If the user has requested steering matching Ingress Packets
>* to a specific Queue Set, we need to make sure it's in range
> @@ -443,10 +443,10 @@ int __cxgb4_set_filter(struct net_device *dev, int 
> filter_id,
>  struct filter_ctx *ctx)
>  {
>   struct adapter *adapter = netdev2adap(dev);
> - unsigned int max_fidx, fidx, iq;
> + unsigned int max_fidx, fidx;
>   struct filter_entry *f;
>   u32 iconf;
> - int ret;
> + int iq, ret;
>  
>   max_fidx = adapter->tids.nftids;
>   if (filter_id != (max_fidx + adapter->tids.nsftids - 1) &&
> -- 
> 2.9.3
> 


Re: [PATCH][V2] mlxsw: spectrum: remove redundant check if err is zero

2016-09-24 Thread Ido Schimmel
On Sat, Sep 24, 2016 at 06:03:38PM -0700, Colin King wrote:
> From: Colin Ian King 
> 
> There is an earlier check and return if err is non-zero, so
> the check to see if it is zero is redundant in every iteration
> of the loop and hence the check can be removed.
> 
> Signed-off-by: Colin Ian King 

The subject and commit message are wrong. I think you copy-pasted them
from an earlier patch.

> ---
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
> b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> index 2a61617..1073673 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> @@ -117,11 +117,11 @@ static int validate_filter(struct net_device *dev,
>   return 0;
>  }
>  
> -static unsigned int get_filter_steerq(struct net_device *dev,
> -   struct ch_filter_specification *fs)
> +static int get_filter_steerq(struct net_device *dev,
> +  struct ch_filter_specification *fs)
>  {
>   struct adapter *adapter = netdev2adap(dev);
> - unsigned int iq;
> + int iq;
>  
>   /* If the user has requested steering matching Ingress Packets
>* to a specific Queue Set, we need to make sure it's in range
> @@ -443,10 +443,10 @@ int __cxgb4_set_filter(struct net_device *dev, int 
> filter_id,
>  struct filter_ctx *ctx)
>  {
>   struct adapter *adapter = netdev2adap(dev);
> - unsigned int max_fidx, fidx, iq;
> + unsigned int max_fidx, fidx;
>   struct filter_entry *f;
>   u32 iconf;
> - int ret;
> + int iq, ret;
>  
>   max_fidx = adapter->tids.nftids;
>   if (filter_id != (max_fidx + adapter->tids.nsftids - 1) &&
> -- 
> 2.9.3
> 


Re: [v6,2/2] QE: remove PPCisms for QE

2016-09-24 Thread Scott Wood
On Sat, Sep 24, 2016 at 11:14:11PM -0500, Scott Wood wrote:
> On Fri, Sep 23, 2016 at 10:20:32AM +0800, Zhao Qiang wrote:
> > QE was supported on PowerPC, and dependent on PPC,
> > Now it is supported on other platforms. so remove PPCisms.
> > 
> > Signed-off-by: Zhao Qiang 
> > ---
> > Changes for v2:
> > - na
> > Changes for v3:
> > - add NO_IRQ
> > Changes for v4:
> > - modify spin_event_timeout to opencoded timeout loop
> > - remove NO_IRQ
> > - modify virq_to_hw to opencoed code
> > Changes for v5:
> > - modify commit msg
> > - modify depends of QUICC_ENGINE
> > - add kerneldoc header for qe_issue_cmd
> > Changes for v6:
> > - add dependency on FSL_SOC and PPC32 for drivers
> >   depending on QUICC_ENGING but not available on ARM
> > 
> >  drivers/irqchip/qe_ic.c| 28 +++-
> >  drivers/net/ethernet/freescale/Kconfig | 10 ++---
> >  drivers/soc/fsl/qe/Kconfig |  2 +-
> >  drivers/soc/fsl/qe/qe.c| 80 
> > --
> >  drivers/soc/fsl/qe/qe_io.c | 42 --
> >  drivers/soc/fsl/qe/qe_tdm.c|  8 ++--
> >  drivers/soc/fsl/qe/ucc.c   | 10 ++---
> >  drivers/soc/fsl/qe/ucc_fast.c  | 68 ++---
> >  drivers/tty/serial/Kconfig |  2 +-
> >  drivers/usb/gadget/udc/Kconfig |  2 +-
> >  drivers/usb/host/Kconfig   |  2 +-
> >  include/soc/fsl/qe/qe.h|  1 -
> >  include/soc/fsl/qe/qe_ic.h | 12 ++---
> >  13 files changed, 141 insertions(+), 126 deletions(-)
> 
> I assume this means you'll be updating
> http://patchwork.ozlabs.org/patch/654473/
> to be based on top of this...

Apparently that assumption was wrong, since I now see that you're
patching drivers/irqchip/qe_ic.c rather than drivers/soc/fsl/qe/qe_ic.c. 
Please keep the drivers/irqchip stuff separate and send to the
appropriate maintainers.

-Scott


Re: [v6,2/2] QE: remove PPCisms for QE

2016-09-24 Thread Scott Wood
On Sat, Sep 24, 2016 at 11:14:11PM -0500, Scott Wood wrote:
> On Fri, Sep 23, 2016 at 10:20:32AM +0800, Zhao Qiang wrote:
> > QE was supported on PowerPC, and dependent on PPC,
> > Now it is supported on other platforms. so remove PPCisms.
> > 
> > Signed-off-by: Zhao Qiang 
> > ---
> > Changes for v2:
> > - na
> > Changes for v3:
> > - add NO_IRQ
> > Changes for v4:
> > - modify spin_event_timeout to opencoded timeout loop
> > - remove NO_IRQ
> > - modify virq_to_hw to opencoed code
> > Changes for v5:
> > - modify commit msg
> > - modify depends of QUICC_ENGINE
> > - add kerneldoc header for qe_issue_cmd
> > Changes for v6:
> > - add dependency on FSL_SOC and PPC32 for drivers
> >   depending on QUICC_ENGING but not available on ARM
> > 
> >  drivers/irqchip/qe_ic.c| 28 +++-
> >  drivers/net/ethernet/freescale/Kconfig | 10 ++---
> >  drivers/soc/fsl/qe/Kconfig |  2 +-
> >  drivers/soc/fsl/qe/qe.c| 80 
> > --
> >  drivers/soc/fsl/qe/qe_io.c | 42 --
> >  drivers/soc/fsl/qe/qe_tdm.c|  8 ++--
> >  drivers/soc/fsl/qe/ucc.c   | 10 ++---
> >  drivers/soc/fsl/qe/ucc_fast.c  | 68 ++---
> >  drivers/tty/serial/Kconfig |  2 +-
> >  drivers/usb/gadget/udc/Kconfig |  2 +-
> >  drivers/usb/host/Kconfig   |  2 +-
> >  include/soc/fsl/qe/qe.h|  1 -
> >  include/soc/fsl/qe/qe_ic.h | 12 ++---
> >  13 files changed, 141 insertions(+), 126 deletions(-)
> 
> I assume this means you'll be updating
> http://patchwork.ozlabs.org/patch/654473/
> to be based on top of this...

Apparently that assumption was wrong, since I now see that you're
patching drivers/irqchip/qe_ic.c rather than drivers/soc/fsl/qe/qe_ic.c. 
Please keep the drivers/irqchip stuff separate and send to the
appropriate maintainers.

-Scott


Re: [v6,2/2] QE: remove PPCisms for QE

2016-09-24 Thread Scott Wood
On Fri, Sep 23, 2016 at 10:20:32AM +0800, Zhao Qiang wrote:
> QE was supported on PowerPC, and dependent on PPC,
> Now it is supported on other platforms. so remove PPCisms.
> 
> Signed-off-by: Zhao Qiang 
> ---
> Changes for v2:
>   - na
> Changes for v3:
>   - add NO_IRQ
> Changes for v4:
>   - modify spin_event_timeout to opencoded timeout loop
>   - remove NO_IRQ
>   - modify virq_to_hw to opencoed code
> Changes for v5:
>   - modify commit msg
>   - modify depends of QUICC_ENGINE
>   - add kerneldoc header for qe_issue_cmd
> Changes for v6:
>   - add dependency on FSL_SOC and PPC32 for drivers
> depending on QUICC_ENGING but not available on ARM
> 
>  drivers/irqchip/qe_ic.c| 28 +++-
>  drivers/net/ethernet/freescale/Kconfig | 10 ++---
>  drivers/soc/fsl/qe/Kconfig |  2 +-
>  drivers/soc/fsl/qe/qe.c| 80 
> --
>  drivers/soc/fsl/qe/qe_io.c | 42 --
>  drivers/soc/fsl/qe/qe_tdm.c|  8 ++--
>  drivers/soc/fsl/qe/ucc.c   | 10 ++---
>  drivers/soc/fsl/qe/ucc_fast.c  | 68 ++---
>  drivers/tty/serial/Kconfig |  2 +-
>  drivers/usb/gadget/udc/Kconfig |  2 +-
>  drivers/usb/host/Kconfig   |  2 +-
>  include/soc/fsl/qe/qe.h|  1 -
>  include/soc/fsl/qe/qe_ic.h | 12 ++---
>  13 files changed, 141 insertions(+), 126 deletions(-)

I assume this means you'll be updating
http://patchwork.ozlabs.org/patch/654473/
to be based on top of this...

-Scott


Re: [v6,2/2] QE: remove PPCisms for QE

2016-09-24 Thread Scott Wood
On Fri, Sep 23, 2016 at 10:20:32AM +0800, Zhao Qiang wrote:
> QE was supported on PowerPC, and dependent on PPC,
> Now it is supported on other platforms. so remove PPCisms.
> 
> Signed-off-by: Zhao Qiang 
> ---
> Changes for v2:
>   - na
> Changes for v3:
>   - add NO_IRQ
> Changes for v4:
>   - modify spin_event_timeout to opencoded timeout loop
>   - remove NO_IRQ
>   - modify virq_to_hw to opencoed code
> Changes for v5:
>   - modify commit msg
>   - modify depends of QUICC_ENGINE
>   - add kerneldoc header for qe_issue_cmd
> Changes for v6:
>   - add dependency on FSL_SOC and PPC32 for drivers
> depending on QUICC_ENGING but not available on ARM
> 
>  drivers/irqchip/qe_ic.c| 28 +++-
>  drivers/net/ethernet/freescale/Kconfig | 10 ++---
>  drivers/soc/fsl/qe/Kconfig |  2 +-
>  drivers/soc/fsl/qe/qe.c| 80 
> --
>  drivers/soc/fsl/qe/qe_io.c | 42 --
>  drivers/soc/fsl/qe/qe_tdm.c|  8 ++--
>  drivers/soc/fsl/qe/ucc.c   | 10 ++---
>  drivers/soc/fsl/qe/ucc_fast.c  | 68 ++---
>  drivers/tty/serial/Kconfig |  2 +-
>  drivers/usb/gadget/udc/Kconfig |  2 +-
>  drivers/usb/host/Kconfig   |  2 +-
>  include/soc/fsl/qe/qe.h|  1 -
>  include/soc/fsl/qe/qe_ic.h | 12 ++---
>  13 files changed, 141 insertions(+), 126 deletions(-)

I assume this means you'll be updating
http://patchwork.ozlabs.org/patch/654473/
to be based on top of this...

-Scott


[PATCH][v11] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen Yu
On some platforms, there is occasional panic triggered when trying to
resume from hibernation, a typical panic looks like:

"BUG: unable to handle kernel paging request at 880085894000
IP: [] load_image_lzo+0x8c2/0xe70"

Investigation carried out by Lee Chun-Yi shows that this is because
e820 map has been changed by BIOS across hibernation, and one
of the page frames from suspend kernel is right located in restore
kernel's unmapped region, so panic comes out when accessing unmapped
kernel address.

In order to expose this issue earlier, the md5 hash of e820 map
is passed from suspend kernel to restore kernel, and the restore
kernel will terminate the resume process once it finds the md5
hash are not the same.

As the format of image header has been modified, the magic number
should also be adjusted as kernels with the same RESTORE_MAGIC have
to use the same header format and interpret all of the fields in
it in the same way.

If the suspend kernel is built without md5 support, and the restore
kernel has md5 support, then the latter will bypass the check process.
Vice versa the restore kernel will bypass the check if it does not
support md5 operation.

Note:
1. Without this patch applied, it is possible that BIOS has
   provided an inconsistent memory map, but the resume kernel is still
   able to restore the image anyway(e.g, E820_RAM region is the superset
   of the previous one), although the system might be unstable. So this
   patch tries to treat any inconsistent e820 as illegal.

2. Another case is, this patch replies on comparing the e820_saved, but
   currently the e820_save might not be strictly the same across
   hibernation, even if BIOS has provided consistent e820 map - In
   theory mptable might modify the BIOS-provided e820_saved dynamically
   in early_reserve_e820_mpc_new, which would allocate a buffer from
   E820_RAM, and marks it from E820_RAM to E820_RESERVED).
   This is a potential and rare case we need to deal with in OS in
   the future.

Suggested-by: Pavel Machek 
Suggested-by: Rafael J. Wysocki 
Cc: Rafael J. Wysocki 
Cc: Pavel Machek 
Cc: Lee Chun-Yi 
Cc: Borislav Petkov 
Acked-by: Pavel Machek 
Signed-off-by: Chen Yu 
---
v11:
 - Remove the extra local variable e820_mismatch.
v10:
 - Remove the newly introduced Boolean flag and check
   the existence of md5 hash by comparing it with zero.
   If the suspend kernel is built without md5 support,
   and the restore kernel has md5 support, then the latter
   will bypass the check process. Vice versa the restore
   kernel will bypass the check if it does not support md5
   operation even if the suspend kernel has one.
v9:
 - Only do the md5 check when CONFIG_CRYPTO_MD5 is built in.
   Change the image head magic number.
   Remove CONFIG_HIBERNATION_CHECK_E820 and make the md5 check
   mandatory.
   Introduce e820_digest_available to indicate whether we should
   check the md5 hash.
   And some other modifications.
v8:
 - Panic the system once the e820 is found to be inconsistent
   during resume.
   Fix the md5 hash len from 128 bytes to 16 bytes.
v7:
 - Use md5 hash to compare the e820 map.
v6:
 - Fix some compiling errors reported by 0day/LKP, adjust
   Kconfig/variable namings.
v5:
 - Rewrite this patch to just warn user of the broken BIOS
   when panic.
v4:
 - Add __attribute__ ((unused)) for swsusp_page_is_valid,
   to eliminate the warnning of:
   'swsusp_page_is_valid' defined but not used
   on non-x86 platforms.

v3:
 - Adjust the logic to exclude the end_pfn boundary in pfn_mapped
   when invoking mark_valid_pages, because the end_pfn is not
   a mapped page frame, we should not regard it as a valid page.

   Move the sanity check of valid pages to a early stage in resuming
   process(moved to mark_unsafe_pages), in this way, we can avoid
   unnecessarily accessing these invalid pages in later stage(yes,
   move to the original position Joey once introduced in:
   Commit 84c91b7ae07c ("PM / hibernate: avoid unsafe pages in e820
   reserved regions")

   With v3 patch applied, I did 30 cycles on my problematic platform,
   no panic triggered anymore(50% reproducible before patched, by
   plugging/unplugging memory peripheral during hibernation), and it
   just warns of invalid pages.

v2:
 - According to Ingo's suggestion, rewrite this patch.

   New version just checks each page frame according to pfn_mapped array.
   So that we do not need to touch existing code related to
   E820_RESERVED_KERN. And this method can naturely guarantee
   that the system before/after hibernation do not need to be of
   the same memory size on x86_64.
---
 arch/x86/power/hibernate_64.c | 92 ++-
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 9634557..d81b1af 100644

[PATCH][v11] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen Yu
On some platforms, there is occasional panic triggered when trying to
resume from hibernation, a typical panic looks like:

"BUG: unable to handle kernel paging request at 880085894000
IP: [] load_image_lzo+0x8c2/0xe70"

Investigation carried out by Lee Chun-Yi shows that this is because
e820 map has been changed by BIOS across hibernation, and one
of the page frames from suspend kernel is right located in restore
kernel's unmapped region, so panic comes out when accessing unmapped
kernel address.

In order to expose this issue earlier, the md5 hash of e820 map
is passed from suspend kernel to restore kernel, and the restore
kernel will terminate the resume process once it finds the md5
hash are not the same.

As the format of image header has been modified, the magic number
should also be adjusted as kernels with the same RESTORE_MAGIC have
to use the same header format and interpret all of the fields in
it in the same way.

If the suspend kernel is built without md5 support, and the restore
kernel has md5 support, then the latter will bypass the check process.
Vice versa the restore kernel will bypass the check if it does not
support md5 operation.

Note:
1. Without this patch applied, it is possible that BIOS has
   provided an inconsistent memory map, but the resume kernel is still
   able to restore the image anyway(e.g, E820_RAM region is the superset
   of the previous one), although the system might be unstable. So this
   patch tries to treat any inconsistent e820 as illegal.

2. Another case is, this patch replies on comparing the e820_saved, but
   currently the e820_save might not be strictly the same across
   hibernation, even if BIOS has provided consistent e820 map - In
   theory mptable might modify the BIOS-provided e820_saved dynamically
   in early_reserve_e820_mpc_new, which would allocate a buffer from
   E820_RAM, and marks it from E820_RAM to E820_RESERVED).
   This is a potential and rare case we need to deal with in OS in
   the future.

Suggested-by: Pavel Machek 
Suggested-by: Rafael J. Wysocki 
Cc: Rafael J. Wysocki 
Cc: Pavel Machek 
Cc: Lee Chun-Yi 
Cc: Borislav Petkov 
Acked-by: Pavel Machek 
Signed-off-by: Chen Yu 
---
v11:
 - Remove the extra local variable e820_mismatch.
v10:
 - Remove the newly introduced Boolean flag and check
   the existence of md5 hash by comparing it with zero.
   If the suspend kernel is built without md5 support,
   and the restore kernel has md5 support, then the latter
   will bypass the check process. Vice versa the restore
   kernel will bypass the check if it does not support md5
   operation even if the suspend kernel has one.
v9:
 - Only do the md5 check when CONFIG_CRYPTO_MD5 is built in.
   Change the image head magic number.
   Remove CONFIG_HIBERNATION_CHECK_E820 and make the md5 check
   mandatory.
   Introduce e820_digest_available to indicate whether we should
   check the md5 hash.
   And some other modifications.
v8:
 - Panic the system once the e820 is found to be inconsistent
   during resume.
   Fix the md5 hash len from 128 bytes to 16 bytes.
v7:
 - Use md5 hash to compare the e820 map.
v6:
 - Fix some compiling errors reported by 0day/LKP, adjust
   Kconfig/variable namings.
v5:
 - Rewrite this patch to just warn user of the broken BIOS
   when panic.
v4:
 - Add __attribute__ ((unused)) for swsusp_page_is_valid,
   to eliminate the warnning of:
   'swsusp_page_is_valid' defined but not used
   on non-x86 platforms.

v3:
 - Adjust the logic to exclude the end_pfn boundary in pfn_mapped
   when invoking mark_valid_pages, because the end_pfn is not
   a mapped page frame, we should not regard it as a valid page.

   Move the sanity check of valid pages to a early stage in resuming
   process(moved to mark_unsafe_pages), in this way, we can avoid
   unnecessarily accessing these invalid pages in later stage(yes,
   move to the original position Joey once introduced in:
   Commit 84c91b7ae07c ("PM / hibernate: avoid unsafe pages in e820
   reserved regions")

   With v3 patch applied, I did 30 cycles on my problematic platform,
   no panic triggered anymore(50% reproducible before patched, by
   plugging/unplugging memory peripheral during hibernation), and it
   just warns of invalid pages.

v2:
 - According to Ingo's suggestion, rewrite this patch.

   New version just checks each page frame according to pfn_mapped array.
   So that we do not need to touch existing code related to
   E820_RESERVED_KERN. And this method can naturely guarantee
   that the system before/after hibernation do not need to be of
   the same memory size on x86_64.
---
 arch/x86/power/hibernate_64.c | 92 ++-
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 9634557..d81b1af 100644
--- a/arch/x86/power/hibernate_64.c
+++ b/arch/x86/power/hibernate_64.c
@@ -11,6 +11,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+

Re: RK3288 USB Issues

2016-09-24 Thread ayaka



On 09/25/2016 04:10 AM, Norbert Lange wrote:

Hello,

did you try without your patches, to see if you can reproduce the problem?
I can fix my issues if I disable usb autosuspend

To narrow down the causes I can think of:
*) Some hardware issue only on my side -> please try to reproduce it
with an unpached kernel

Of course it does. Without those patch it won't work.

*) Some other stuff I modified -> gonna try a clean kernel with just
your patches (hopefully will find time on sunday

Of course I did that. You could check my kernel repository at github
https://github.com/hizukiayaka/linux-kernel/tree/firefly-rk3288-reload-next


*) Maybe some different kernel config options -> mine are
multi_v7_defconfig with a few modules added
Not sure with that defconfig, even I didn't know whether you enabled the 
USB module


Kind regards,
Norbert

2016-09-24 20:53 GMT+02:00 ayaka :

On 09/23/2016 03:10 PM, Norbert Lange wrote:

Hi,

I wanted to reply to the Linux mailing List (your patch thread), I
dont know exactly where since the addresses are blanked out.
Just tell me where I should move this discussion.

The board can use both USB peripherals (haven`t tested the OTG Port).
The issue starts if the board has *no* USB peripherals attached
(either booting without any USB peripherals, or disconnecting all
peripherals).

I have checked my patches with kernel next-20160923, I didn't meet your
problem. The firefly RK3288 release board works fine.


*Then* I cant connect a single peripheral, just getting read errors.
I may not match your situation, there is always a usb hub at firefly 
board, unless I would remove that chip, there is always a USB peripheral 
device there.

Seems like something is getting powered down if no USB peripheral is
connected, and can`t start up again.

Kind regard,
Norbert

2016-09-23 2:48 GMT+02:00 Ayaka :


從我的 iPad 傳送


Norbert Lange  於 2016年9月23日 上午7:37 寫道:

Hello Randi,
I am Randy
sorry for stalking you, but I have a problem with the USB Ports on

You have better CC to Linux-use as well

RK3288 and Heiko pointed me to your patch [1].

Firefly RK3288
Linux Kernel 4.8rc3 with multi_v7_defconfig and some additional
modules and mali drm driver
Your patch v7 applied [2]

[1] https://irclog.whitequark.org/linux-rockchip/2016-09-20
[2] https://www.spinics.net/lists/linux-usb/msg146496.html

I can easily reproduce the issue, if no USB Device is connected then
attaching USB Devices will produce Read Errors.
The only way around that is to always leave one device connected.


So the board could only connect to use one usb peripheral device?

# plug in an USB Stick
Sep 10 23:05:19 hipase2firefly kernel: usb 1-1: reset high-speed USB
device numb
Sep 10 23:05:24 hipase2firefly kernel: usb 1-1: device descriptor
read/64, error
Sep 10 23:05:40 hipase2firefly kernel: usb 1-1: device descriptor
read/64, error
Sep 10 23:05:42 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:43 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:44 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:44 hipase2firefly kernel: usb 1-1: USB disconnect, device
number 2
Sep 10 23:05:45 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:47 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:48 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:49 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:49 hipase2firefly kernel: usb usb1-port1: unable to
enumerate USB d

# reset without disconnecting USB
# connecting a second USB Device (Logitech Receiver)

Sep 10 23:03:14 hipase2firefly kernel: usb 1-1.4: new full-speed USB
device numb
Sep 10 23:03:14 hipase2firefly mtp-probe[2207]: checking bus 1, device
4: "/sys/
Sep 10 23:03:14 hipase2firefly mtp-probe[2207]: bus: 1, device: 4 was
not an MTP
Sep 10 23:03:14 hipase2firefly kernel: logitech-djreceiver
0003:046D:C52B.0003:
Sep 10 23:03:14 hipase2firefly kernel: input: Logitech K400 as
/devices/platform
Sep 10 23:03:14 hipase2firefly kernel: logitech-hidpp-device
0003:046D:4024.0004

# disconnectin 1 USB Device
Sep 10 23:04:00 hipase2firefly kernel: usb 1-1.4: USB disconnect, device
number

#reconnecting the same device
Sep 10 23:05:49 hipase2firefly kernel: usb 1-1.4: new full-speed USB
device numb
Sep 10 23:05:49 hipase2firefly kernel: logitech-djreceiver
0003:046D:C52B.0007:
Sep 10 23:05:49 hipase2firefly mtp-probe[2276]: checking bus 1, device
5: "/sys/
Sep 10 23:05:49 hipase2firefly mtp-probe[2276]: bus: 1, device: 5 was
not an MTP
Sep 10 23:05:49 hipase2firefly kernel: input: Logitech K400 as
/devices/platform
Sep 10 23:05:49 hipase2firefly kernel: logitech-hidpp-device
0003:046D:4024.0008

# disconnecting both USB Devices
Sep 10 23:06:45 hipase2firefly kernel: usb 1-1.4: USB disconnect, device
number
Sep 10 23:06:49 hipase2firefly kernel: usb 

Re: RK3288 USB Issues

2016-09-24 Thread ayaka



On 09/25/2016 04:10 AM, Norbert Lange wrote:

Hello,

did you try without your patches, to see if you can reproduce the problem?
I can fix my issues if I disable usb autosuspend

To narrow down the causes I can think of:
*) Some hardware issue only on my side -> please try to reproduce it
with an unpached kernel

Of course it does. Without those patch it won't work.

*) Some other stuff I modified -> gonna try a clean kernel with just
your patches (hopefully will find time on sunday

Of course I did that. You could check my kernel repository at github
https://github.com/hizukiayaka/linux-kernel/tree/firefly-rk3288-reload-next


*) Maybe some different kernel config options -> mine are
multi_v7_defconfig with a few modules added
Not sure with that defconfig, even I didn't know whether you enabled the 
USB module


Kind regards,
Norbert

2016-09-24 20:53 GMT+02:00 ayaka :

On 09/23/2016 03:10 PM, Norbert Lange wrote:

Hi,

I wanted to reply to the Linux mailing List (your patch thread), I
dont know exactly where since the addresses are blanked out.
Just tell me where I should move this discussion.

The board can use both USB peripherals (haven`t tested the OTG Port).
The issue starts if the board has *no* USB peripherals attached
(either booting without any USB peripherals, or disconnecting all
peripherals).

I have checked my patches with kernel next-20160923, I didn't meet your
problem. The firefly RK3288 release board works fine.


*Then* I cant connect a single peripheral, just getting read errors.
I may not match your situation, there is always a usb hub at firefly 
board, unless I would remove that chip, there is always a USB peripheral 
device there.

Seems like something is getting powered down if no USB peripheral is
connected, and can`t start up again.

Kind regard,
Norbert

2016-09-23 2:48 GMT+02:00 Ayaka :


從我的 iPad 傳送


Norbert Lange  於 2016年9月23日 上午7:37 寫道:

Hello Randi,
I am Randy
sorry for stalking you, but I have a problem with the USB Ports on

You have better CC to Linux-use as well

RK3288 and Heiko pointed me to your patch [1].

Firefly RK3288
Linux Kernel 4.8rc3 with multi_v7_defconfig and some additional
modules and mali drm driver
Your patch v7 applied [2]

[1] https://irclog.whitequark.org/linux-rockchip/2016-09-20
[2] https://www.spinics.net/lists/linux-usb/msg146496.html

I can easily reproduce the issue, if no USB Device is connected then
attaching USB Devices will produce Read Errors.
The only way around that is to always leave one device connected.


So the board could only connect to use one usb peripheral device?

# plug in an USB Stick
Sep 10 23:05:19 hipase2firefly kernel: usb 1-1: reset high-speed USB
device numb
Sep 10 23:05:24 hipase2firefly kernel: usb 1-1: device descriptor
read/64, error
Sep 10 23:05:40 hipase2firefly kernel: usb 1-1: device descriptor
read/64, error
Sep 10 23:05:42 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:43 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:44 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:44 hipase2firefly kernel: usb 1-1: USB disconnect, device
number 2
Sep 10 23:05:45 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:47 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:48 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:49 hipase2firefly kernel: usb usb1-port1: Cannot enable.
Maybe the
Sep 10 23:05:49 hipase2firefly kernel: usb usb1-port1: unable to
enumerate USB d

# reset without disconnecting USB
# connecting a second USB Device (Logitech Receiver)

Sep 10 23:03:14 hipase2firefly kernel: usb 1-1.4: new full-speed USB
device numb
Sep 10 23:03:14 hipase2firefly mtp-probe[2207]: checking bus 1, device
4: "/sys/
Sep 10 23:03:14 hipase2firefly mtp-probe[2207]: bus: 1, device: 4 was
not an MTP
Sep 10 23:03:14 hipase2firefly kernel: logitech-djreceiver
0003:046D:C52B.0003:
Sep 10 23:03:14 hipase2firefly kernel: input: Logitech K400 as
/devices/platform
Sep 10 23:03:14 hipase2firefly kernel: logitech-hidpp-device
0003:046D:4024.0004

# disconnectin 1 USB Device
Sep 10 23:04:00 hipase2firefly kernel: usb 1-1.4: USB disconnect, device
number

#reconnecting the same device
Sep 10 23:05:49 hipase2firefly kernel: usb 1-1.4: new full-speed USB
device numb
Sep 10 23:05:49 hipase2firefly kernel: logitech-djreceiver
0003:046D:C52B.0007:
Sep 10 23:05:49 hipase2firefly mtp-probe[2276]: checking bus 1, device
5: "/sys/
Sep 10 23:05:49 hipase2firefly mtp-probe[2276]: bus: 1, device: 5 was
not an MTP
Sep 10 23:05:49 hipase2firefly kernel: input: Logitech K400 as
/devices/platform
Sep 10 23:05:49 hipase2firefly kernel: logitech-hidpp-device
0003:046D:4024.0008

# disconnecting both USB Devices
Sep 10 23:06:45 hipase2firefly kernel: usb 1-1.4: USB disconnect, device
number
Sep 10 23:06:49 hipase2firefly kernel: usb 1-1.1: USB disconnect, device
number
Sep 10 23:06:49 

Re: undefined reference to `printk'

2016-09-24 Thread Joe Perches
On Sun, 2016-09-25 at 11:40 +0800, kbuild test robot wrote:
> Hi Joe,

Hey Fengguang

> It's probably a bug fix that unveils the link errors.

I think all of these reports about compiler-gcc integrations
are bogons.

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   9c0e28a7be656d737fb18998e2dcb0b8ce595643
> commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
> various compiler-gcc[345].h files
> date:   1 year, 3 months ago
> config: m32r-allnoconfig (attached as .config)
> compiler: m32r-linux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
> # save the attached .config to linux build tree
> make.cross ARCH=m32r 
> 
> 
> All errors (new ones prefixed by >>):
> 
> 
>arch/m32r/kernel/built-in.o: In function `default_eit_handler':
> > > (.text+0x3fc): undefined reference to `printk'

There isn't any association to integration here.

> 


Re: undefined reference to `printk'

2016-09-24 Thread Joe Perches
On Sun, 2016-09-25 at 11:40 +0800, kbuild test robot wrote:
> Hi Joe,

Hey Fengguang

> It's probably a bug fix that unveils the link errors.

I think all of these reports about compiler-gcc integrations
are bogons.

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   9c0e28a7be656d737fb18998e2dcb0b8ce595643
> commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
> various compiler-gcc[345].h files
> date:   1 year, 3 months ago
> config: m32r-allnoconfig (attached as .config)
> compiler: m32r-linux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
> # save the attached .config to linux build tree
> make.cross ARCH=m32r 
> 
> 
> All errors (new ones prefixed by >>):
> 
> 
>arch/m32r/kernel/built-in.o: In function `default_eit_handler':
> > > (.text+0x3fc): undefined reference to `printk'

There isn't any association to integration here.

> 


RE: [PATCH][v10] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen, Yu C
Hi,
Sorry for late response, I missed the thread in mailbox,

> -Original Message-
> From: rjwyso...@gmail.com [mailto:rjwyso...@gmail.com] On Behalf Of
> Rafael J. Wysocki
> Sent: Monday, September 19, 2016 7:46 PM
> To: Chen, Yu C
> Cc: Linux PM; the arch/x86 maintainers; Linux Kernel Mailing List; Thomas
> Gleixner; Ingo Molnar; H. Peter Anvin; Wysocki, Rafael J; Pavel Machek; Lee
> Chun-Yi; Borislav Petkov
> Subject: Re: [PATCH][v10] PM / hibernate: Verify the consistent of e820
> memory map by md5 digest
> 
> On Fri, Sep 9, 2016 at 2:21 PM, Chen Yu  wrote:
> > On some platforms, there is occasional panic triggered when trying to
> > resume from hibernation, a typical panic looks like:
> 
> [cut]
> 
> > @@ -211,10 +292,15 @@ int arch_hibernation_header_save(void *addr,
> unsigned int max_size)
> >   */
> >  int arch_hibernation_header_restore(void *addr)  {
> > +   bool e820_mismatch = false;
> 
> The extra local variable can be avoided if you structure the code slightly
> differently.
> 
> > struct restore_data_record *rdr = addr;
> >
> > restore_jump_address = rdr->jump_address;
> > jump_address_phys = rdr->jump_address_phys;
> > restore_cr3 = rdr->cr3;
> > -   return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
> > +
> > +   e820_mismatch = hibernation_e820_mismatch(rdr->e820_digest);
> 
> Also calling hibernation_e820_mismatch() before checking rdr->magic may not
> be useful at all.
> 
Yes.
> > +
> > +   return (rdr->magic == RESTORE_MAGIC) ?
> > +   (e820_mismatch ? -ENODEV : 0) : -EINVAL;
> 
> So what about:
> 
> if (rdr->magic != RESTORE_MAGIC)
> return -EINVAL;
> 
> if (hibernation_e820_mismatch(rdr->e820_digest))
> return -ENODEV;
> 
> return 0;
> 
> 
Ok, will change it to this one. Thanks.
> >  }
> > --
> 
> Thanks,
> Rafael


Thanks,
Yu


RE: [PATCH][v10] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen, Yu C
Hi,
Sorry for late response, I missed the thread in mailbox,

> -Original Message-
> From: rjwyso...@gmail.com [mailto:rjwyso...@gmail.com] On Behalf Of
> Rafael J. Wysocki
> Sent: Monday, September 19, 2016 7:46 PM
> To: Chen, Yu C
> Cc: Linux PM; the arch/x86 maintainers; Linux Kernel Mailing List; Thomas
> Gleixner; Ingo Molnar; H. Peter Anvin; Wysocki, Rafael J; Pavel Machek; Lee
> Chun-Yi; Borislav Petkov
> Subject: Re: [PATCH][v10] PM / hibernate: Verify the consistent of e820
> memory map by md5 digest
> 
> On Fri, Sep 9, 2016 at 2:21 PM, Chen Yu  wrote:
> > On some platforms, there is occasional panic triggered when trying to
> > resume from hibernation, a typical panic looks like:
> 
> [cut]
> 
> > @@ -211,10 +292,15 @@ int arch_hibernation_header_save(void *addr,
> unsigned int max_size)
> >   */
> >  int arch_hibernation_header_restore(void *addr)  {
> > +   bool e820_mismatch = false;
> 
> The extra local variable can be avoided if you structure the code slightly
> differently.
> 
> > struct restore_data_record *rdr = addr;
> >
> > restore_jump_address = rdr->jump_address;
> > jump_address_phys = rdr->jump_address_phys;
> > restore_cr3 = rdr->cr3;
> > -   return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
> > +
> > +   e820_mismatch = hibernation_e820_mismatch(rdr->e820_digest);
> 
> Also calling hibernation_e820_mismatch() before checking rdr->magic may not
> be useful at all.
> 
Yes.
> > +
> > +   return (rdr->magic == RESTORE_MAGIC) ?
> > +   (e820_mismatch ? -ENODEV : 0) : -EINVAL;
> 
> So what about:
> 
> if (rdr->magic != RESTORE_MAGIC)
> return -EINVAL;
> 
> if (hibernation_e820_mismatch(rdr->e820_digest))
> return -ENODEV;
> 
> return 0;
> 
> 
Ok, will change it to this one. Thanks.
> >  }
> > --
> 
> Thanks,
> Rafael


Thanks,
Yu


RE: [PATCH][v10] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen, Yu C
Hi,
Sorry for late response, I missed this thread in mailbox,

> -Original Message-
> From: rjwyso...@gmail.com [mailto:rjwyso...@gmail.com] On Behalf Of
> Rafael J. Wysocki
> Sent: Monday, September 19, 2016 7:46 PM
> To: Chen, Yu C
> Cc: Linux PM; the arch/x86 maintainers; Linux Kernel Mailing List; Thomas
> Gleixner; Ingo Molnar; H. Peter Anvin; Wysocki, Rafael J; Pavel Machek; Lee
> Chun-Yi; Borislav Petkov
> Subject: Re: [PATCH][v10] PM / hibernate: Verify the consistent of e820
> memory map by md5 digest
> 
> On Fri, Sep 9, 2016 at 2:21 PM, Chen Yu  wrote:
> > On some platforms, there is occasional panic triggered when trying to
> > resume from hibernation, a typical panic looks like:
> 
> [cut]
> 
> > @@ -211,10 +292,15 @@ int arch_hibernation_header_save(void *addr,
> unsigned int max_size)
> >   */
> >  int arch_hibernation_header_restore(void *addr)  {
> > +   bool e820_mismatch = false;
> 
> The extra local variable can be avoided if you structure the code slightly
> differently.
> 
> > struct restore_data_record *rdr = addr;
> >
> > restore_jump_address = rdr->jump_address;
> > jump_address_phys = rdr->jump_address_phys;
> > restore_cr3 = rdr->cr3;
> > -   return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
> > +
> > +   e820_mismatch = hibernation_e820_mismatch(rdr->e820_digest);
> 
> Also calling hibernation_e820_mismatch() before checking rdr->magic may not
> be useful at all.
Yes.
> 
> > +
> > +   return (rdr->magic == RESTORE_MAGIC) ?
> > +   (e820_mismatch ? -ENODEV : 0) : -EINVAL;
> 
> So what about:
> 
> if (rdr->magic != RESTORE_MAGIC)
> return -EINVAL;
> 
> if (hibernation_e820_mismatch(rdr->e820_digest))
> return -ENODEV;
> 
> return 0;
> 
OK, will change it to this one. Thanks!
> >  }
> > --
> 
> Thanks,
> Rafael

Thanks,
Yu


RE: [PATCH][v10] PM / hibernate: Verify the consistent of e820 memory map by md5 digest

2016-09-24 Thread Chen, Yu C
Hi,
Sorry for late response, I missed this thread in mailbox,

> -Original Message-
> From: rjwyso...@gmail.com [mailto:rjwyso...@gmail.com] On Behalf Of
> Rafael J. Wysocki
> Sent: Monday, September 19, 2016 7:46 PM
> To: Chen, Yu C
> Cc: Linux PM; the arch/x86 maintainers; Linux Kernel Mailing List; Thomas
> Gleixner; Ingo Molnar; H. Peter Anvin; Wysocki, Rafael J; Pavel Machek; Lee
> Chun-Yi; Borislav Petkov
> Subject: Re: [PATCH][v10] PM / hibernate: Verify the consistent of e820
> memory map by md5 digest
> 
> On Fri, Sep 9, 2016 at 2:21 PM, Chen Yu  wrote:
> > On some platforms, there is occasional panic triggered when trying to
> > resume from hibernation, a typical panic looks like:
> 
> [cut]
> 
> > @@ -211,10 +292,15 @@ int arch_hibernation_header_save(void *addr,
> unsigned int max_size)
> >   */
> >  int arch_hibernation_header_restore(void *addr)  {
> > +   bool e820_mismatch = false;
> 
> The extra local variable can be avoided if you structure the code slightly
> differently.
> 
> > struct restore_data_record *rdr = addr;
> >
> > restore_jump_address = rdr->jump_address;
> > jump_address_phys = rdr->jump_address_phys;
> > restore_cr3 = rdr->cr3;
> > -   return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
> > +
> > +   e820_mismatch = hibernation_e820_mismatch(rdr->e820_digest);
> 
> Also calling hibernation_e820_mismatch() before checking rdr->magic may not
> be useful at all.
Yes.
> 
> > +
> > +   return (rdr->magic == RESTORE_MAGIC) ?
> > +   (e820_mismatch ? -ENODEV : 0) : -EINVAL;
> 
> So what about:
> 
> if (rdr->magic != RESTORE_MAGIC)
> return -EINVAL;
> 
> if (hibernation_e820_mismatch(rdr->e820_digest))
> return -ENODEV;
> 
> return 0;
> 
OK, will change it to this one. Thanks!
> >  }
> > --
> 
> Thanks,
> Rafael

Thanks,
Yu


undefined reference to `printk'

2016-09-24 Thread kbuild test robot
Hi Joe,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   9c0e28a7be656d737fb18998e2dcb0b8ce595643
commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
various compiler-gcc[345].h files
date:   1 year, 3 months ago
config: m32r-allnoconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
>> (.text+0x3fc): undefined reference to `printk'
   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
   (.text+0x3fc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `printk'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


undefined reference to `printk'

2016-09-24 Thread kbuild test robot
Hi Joe,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   9c0e28a7be656d737fb18998e2dcb0b8ce595643
commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
various compiler-gcc[345].h files
date:   1 year, 3 months ago
config: m32r-allnoconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
>> (.text+0x3fc): undefined reference to `printk'
   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
   (.text+0x3fc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `printk'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 01/01] drivers:input:byd fix greedy detection of Sentelic FSP by the BYD touchpad driver

2016-09-24 Thread Christophe TORDEUX
From: Christophe TORDEUX 

With kernel v4.6 and later, the Sentelic touchpad STL3888_C0 and
probably other Sentelic FSP touchpads are detected as a BYD touchpad and
lose multitouch features.

During the BYD handshake in the byd_detect function, the BYD driver
mistakenly interprets a standard PS/2 protocol status request answer
from the Sentelic touchpad as a successful handshake with a BYD
touchpad. This is clearly a bug of the BYD driver.

Description of the patch: In byd_detect function, remove positive
detection result based on standard PS/2 protocol status request answer.
Replace it with positive detection based on handshake answers as they
can be inferred from the BYD touchpad datasheets found on BYD website.

Signed-off-by: Christophe TORDEUX 

---
Comments/discussion:
A Sentelic touchpad STL3888_C0 is available to the author of this patch.

No BYD touchpad device is available to the author of this patch for
testing purpose. The BYD website contains 5 data sheets documents for 5
touchpads. Unfortunately the handshake procedure description from the
BYD datasheets is either not fully consistent or not fully detailed.

This means that while the author is positive the bug of Sentelic greedy
detection is fixed by this patch, the effect on detection of BYD
touchpads is not tested on actual hardware. But, because this patch
codes the detection according to expected handshake answers based on BYD
datasheets, the approach taken by this patch is probably the best in the
author's opinion.
Nevertheless alternatives can be considered.

Alternative 1: move the detection of Sentelic touchpads above the
detection of BYD touchpads in psmouse_try_protocol function. However
based on the code comments, this could have adverse effects which I
don't really know about.

Alternative2: Sentelic STL3888_C0 answers E9 status request with a
standard PS/2 protocol answer, however I found out my Sentelic
STL3888_C0 answers E8/00/E8/00/E8/00/E8/00/E9 with 00/88/64, which looks
like a handshake answer. This could be used as a test to exit the
byd_detect function. Still effect on detection of a BYD device is not
known.

---
 drivers/input/mouse/byd.c | 76 ++-
 1 file changed, 62 insertions(+), 14 deletions(-)

diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
index b27aa63..b5acca0 100644
--- a/drivers/input/mouse/byd.c
+++ b/drivers/input/mouse/byd.c
@@ -35,6 +35,18 @@
  * BYD pad constants
  */
 
+/* Handshake answer of BTP6034 */
+#define BYD_MODEL_BTP6034  0x00E801
+/* Handshake answer of BTP6740 */
+#define BYD_MODEL_BTP6740  0x001155
+/* Handshake answers of BTP8644, BTP10463 and BTP11484 */
+#define BYD_MODEL_BTP8644  0x011155
+
+/* Handshake SETRES byte of BTP6034 and BTP6740 */
+#define BYD_SHAKE_BYTE_A   0x00
+/* Handshake SETRES byte of BTP8644, BTP10463 and BTP11484 */
+#define BYD_SHAKE_BYTE_B   0x03
+
 /*
  * True device resolution is unknown, however experiments show the
  * resolution is about 111 units/mm.
@@ -434,23 +446,59 @@ static void byd_disconnect(struct psmouse *psmouse)
}
 }
 
+u32 byd_try_model(u32 model)
+{
+   size_t i;
+
+   u32 byd_model[] = {
+   BYD_MODEL_BTP6034,
+   BYD_MODEL_BTP6740,
+   BYD_MODEL_BTP8644
+   };
+
+   for (i=0; i < ARRAY_SIZE(byd_model); i++) {
+   if (model ==  byd_model[i])
+   return model;
+   }
+
+   return 0;
+}
+
 int byd_detect(struct psmouse *psmouse, bool set_properties)
 {
struct ps2dev *ps2dev = >ps2dev;
-   u8 param[4] = {0x03, 0x00, 0x00, 0x00};
-
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
-   return -1;
-
-   if (param[1] != 0x03 || param[2] != 0x64)
+   size_t i;
+
+   u8 byd_shbyte[] = {
+   BYD_SHAKE_BYTE_A,
+   BYD_SHAKE_BYTE_B
+   };
+
+   bool detect = false;
+   for (i=0; i < ARRAY_SIZE(byd_shbyte); i++) {
+   u32 model;
+   u8 param[4] = {byd_shbyte[i], 0x00, 0x00, 0x00};
+
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
+   return -1;

[PATCH 01/01] drivers:input:byd fix greedy detection of Sentelic FSP by the BYD touchpad driver

2016-09-24 Thread Christophe TORDEUX
From: Christophe TORDEUX 

With kernel v4.6 and later, the Sentelic touchpad STL3888_C0 and
probably other Sentelic FSP touchpads are detected as a BYD touchpad and
lose multitouch features.

During the BYD handshake in the byd_detect function, the BYD driver
mistakenly interprets a standard PS/2 protocol status request answer
from the Sentelic touchpad as a successful handshake with a BYD
touchpad. This is clearly a bug of the BYD driver.

Description of the patch: In byd_detect function, remove positive
detection result based on standard PS/2 protocol status request answer.
Replace it with positive detection based on handshake answers as they
can be inferred from the BYD touchpad datasheets found on BYD website.

Signed-off-by: Christophe TORDEUX 

---
Comments/discussion:
A Sentelic touchpad STL3888_C0 is available to the author of this patch.

No BYD touchpad device is available to the author of this patch for
testing purpose. The BYD website contains 5 data sheets documents for 5
touchpads. Unfortunately the handshake procedure description from the
BYD datasheets is either not fully consistent or not fully detailed.

This means that while the author is positive the bug of Sentelic greedy
detection is fixed by this patch, the effect on detection of BYD
touchpads is not tested on actual hardware. But, because this patch
codes the detection according to expected handshake answers based on BYD
datasheets, the approach taken by this patch is probably the best in the
author's opinion.
Nevertheless alternatives can be considered.

Alternative 1: move the detection of Sentelic touchpads above the
detection of BYD touchpads in psmouse_try_protocol function. However
based on the code comments, this could have adverse effects which I
don't really know about.

Alternative2: Sentelic STL3888_C0 answers E9 status request with a
standard PS/2 protocol answer, however I found out my Sentelic
STL3888_C0 answers E8/00/E8/00/E8/00/E8/00/E9 with 00/88/64, which looks
like a handshake answer. This could be used as a test to exit the
byd_detect function. Still effect on detection of a BYD device is not
known.

---
 drivers/input/mouse/byd.c | 76 ++-
 1 file changed, 62 insertions(+), 14 deletions(-)

diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
index b27aa63..b5acca0 100644
--- a/drivers/input/mouse/byd.c
+++ b/drivers/input/mouse/byd.c
@@ -35,6 +35,18 @@
  * BYD pad constants
  */
 
+/* Handshake answer of BTP6034 */
+#define BYD_MODEL_BTP6034  0x00E801
+/* Handshake answer of BTP6740 */
+#define BYD_MODEL_BTP6740  0x001155
+/* Handshake answers of BTP8644, BTP10463 and BTP11484 */
+#define BYD_MODEL_BTP8644  0x011155
+
+/* Handshake SETRES byte of BTP6034 and BTP6740 */
+#define BYD_SHAKE_BYTE_A   0x00
+/* Handshake SETRES byte of BTP8644, BTP10463 and BTP11484 */
+#define BYD_SHAKE_BYTE_B   0x03
+
 /*
  * True device resolution is unknown, however experiments show the
  * resolution is about 111 units/mm.
@@ -434,23 +446,59 @@ static void byd_disconnect(struct psmouse *psmouse)
}
 }
 
+u32 byd_try_model(u32 model)
+{
+   size_t i;
+
+   u32 byd_model[] = {
+   BYD_MODEL_BTP6034,
+   BYD_MODEL_BTP6740,
+   BYD_MODEL_BTP8644
+   };
+
+   for (i=0; i < ARRAY_SIZE(byd_model); i++) {
+   if (model ==  byd_model[i])
+   return model;
+   }
+
+   return 0;
+}
+
 int byd_detect(struct psmouse *psmouse, bool set_properties)
 {
struct ps2dev *ps2dev = >ps2dev;
-   u8 param[4] = {0x03, 0x00, 0x00, 0x00};
-
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
-   return -1;
-   if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
-   return -1;
-
-   if (param[1] != 0x03 || param[2] != 0x64)
+   size_t i;
+
+   u8 byd_shbyte[] = {
+   BYD_SHAKE_BYTE_A,
+   BYD_SHAKE_BYTE_B
+   };
+
+   bool detect = false;
+   for (i=0; i < ARRAY_SIZE(byd_shbyte); i++) {
+   u32 model;
+   u8 param[4] = {byd_shbyte[i], 0x00, 0x00, 0x00};
+
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
+   return -1;
+   if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
+   return -1;
+
+   model = param[2];
+   

Re: powerpc/32: Remove CLR_TOP32

2016-09-24 Thread Michael Ellerman
On Fri, 2016-05-08 at 11:27:59 UTC, Christophe Leroy wrote:
> CLR_TOP32() is defined as blank. Last useful instance of CLR_TOP32()
> was removed by commit 40ef8cbc6d360 ("powerpc: Get 64-bit configs to
> compile with ARCH=powerpc")
> 
> Signed-off-by: Christophe Leroy 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/148151a66a74bf43c6acc932a3

cheers


Re: powerpc/32: Remove CLR_TOP32

2016-09-24 Thread Michael Ellerman
On Fri, 2016-05-08 at 11:27:59 UTC, Christophe Leroy wrote:
> CLR_TOP32() is defined as blank. Last useful instance of CLR_TOP32()
> was removed by commit 40ef8cbc6d360 ("powerpc: Get 64-bit configs to
> compile with ARCH=powerpc")
> 
> Signed-off-by: Christophe Leroy 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/148151a66a74bf43c6acc932a3

cheers


Re: [v2] powerpc: fix usage of _PAGE_RO in hugepage

2016-09-24 Thread Michael Ellerman
On Mon, 2016-19-09 at 10:58:54 UTC, Christophe Leroy wrote:
> On some CPUs like the 8xx, _PAGE_RW hence _PAGE_WRITE is defined
> as 0 and _PAGE_RO has to be set when a page is not writable
> 
> _PAGE_RO is defined by default in pte-common.h, however BOOK3S/64
> doesn't include that file so _PAGE_RO has to be defined explicitly
> in book3s/64/pgtable.h
> 
> fixes: a7b9f671f2d14 ("powerpc32: adds handling of _PAGE_RO")
> Signed-off-by: Christophe Leroy 
> Reviewed-by: Aneesh Kumar K.V 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/6b8cb66a6a7cc182b47da6a0a1

cheers


Re: [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c

2016-09-24 Thread Michael Ellerman
On Fri, 2016-02-09 at 06:17:26 UTC, Rui Teng wrote:
> The same logic appears twice and should probably be pulled out into a 
> function.
> 
> Suggested-by: Michael Ellerman 
> Signed-off-by: Rui Teng 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f1a55ce0544251746d9b52fb85

cheers


Re: [v2] powerpc: fix usage of _PAGE_RO in hugepage

2016-09-24 Thread Michael Ellerman
On Mon, 2016-19-09 at 10:58:54 UTC, Christophe Leroy wrote:
> On some CPUs like the 8xx, _PAGE_RW hence _PAGE_WRITE is defined
> as 0 and _PAGE_RO has to be set when a page is not writable
> 
> _PAGE_RO is defined by default in pte-common.h, however BOOK3S/64
> doesn't include that file so _PAGE_RO has to be defined explicitly
> in book3s/64/pgtable.h
> 
> fixes: a7b9f671f2d14 ("powerpc32: adds handling of _PAGE_RO")
> Signed-off-by: Christophe Leroy 
> Reviewed-by: Aneesh Kumar K.V 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/6b8cb66a6a7cc182b47da6a0a1

cheers


Re: [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c

2016-09-24 Thread Michael Ellerman
On Fri, 2016-02-09 at 06:17:26 UTC, Rui Teng wrote:
> The same logic appears twice and should probably be pulled out into a 
> function.
> 
> Suggested-by: Michael Ellerman 
> Signed-off-by: Rui Teng 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f1a55ce0544251746d9b52fb85

cheers


[PATCH] PCI: enable extended tags support for PCIe endpoints

2016-09-24 Thread Sinan Kaya
Each PCIe device can issue up to 32 transactions at a time by default.
Each transaction is tracked by a tag number on the bus. 32 outstanding
transactions is not enough for some performance critical applications
especially when a lot of small sized frames are transmitted.

Extended tags support increases this number to 256. Devices not
supporting extended tags tie-off this field to 0. According to ECN, it
is safe to enable this feature for all PCIe endpoints.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/probe.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 93f280d..2424f38 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1505,12 +1505,19 @@ static void program_hpp_type2(struct pci_dev *dev, 
struct hpp_type2 *hpp)
 */
 }
 
+static int pci_configure_extended_tags(struct pci_dev *dev)
+{
+   return pcie_capability_set_word(dev, PCI_EXP_DEVCTL,
+PCI_EXP_DEVCTL_EXT_TAG);
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
struct hotplug_params hpp;
int ret;
 
pci_configure_mps(dev);
+   pci_configure_extended_tags(dev);
 
memset(, 0, sizeof(hpp));
ret = pci_get_hp_params(dev, );
-- 
1.9.1



[PATCH] PCI: enable extended tags support for PCIe endpoints

2016-09-24 Thread Sinan Kaya
Each PCIe device can issue up to 32 transactions at a time by default.
Each transaction is tracked by a tag number on the bus. 32 outstanding
transactions is not enough for some performance critical applications
especially when a lot of small sized frames are transmitted.

Extended tags support increases this number to 256. Devices not
supporting extended tags tie-off this field to 0. According to ECN, it
is safe to enable this feature for all PCIe endpoints.

Signed-off-by: Sinan Kaya 
---
 drivers/pci/probe.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 93f280d..2424f38 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1505,12 +1505,19 @@ static void program_hpp_type2(struct pci_dev *dev, 
struct hpp_type2 *hpp)
 */
 }
 
+static int pci_configure_extended_tags(struct pci_dev *dev)
+{
+   return pcie_capability_set_word(dev, PCI_EXP_DEVCTL,
+PCI_EXP_DEVCTL_EXT_TAG);
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
struct hotplug_params hpp;
int ret;
 
pci_configure_mps(dev);
+   pci_configure_extended_tags(dev);
 
memset(, 0, sizeof(hpp));
ret = pci_get_hp_params(dev, );
-- 
1.9.1



[PATCH][V2] mlxsw: spectrum: remove redundant check if err is zero

2016-09-24 Thread Colin King
From: Colin Ian King 

There is an earlier check and return if err is non-zero, so
the check to see if it is zero is redundant in every iteration
of the loop and hence the check can be removed.

Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 2a61617..1073673 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -117,11 +117,11 @@ static int validate_filter(struct net_device *dev,
return 0;
 }
 
-static unsigned int get_filter_steerq(struct net_device *dev,
- struct ch_filter_specification *fs)
+static int get_filter_steerq(struct net_device *dev,
+struct ch_filter_specification *fs)
 {
struct adapter *adapter = netdev2adap(dev);
-   unsigned int iq;
+   int iq;
 
/* If the user has requested steering matching Ingress Packets
 * to a specific Queue Set, we need to make sure it's in range
@@ -443,10 +443,10 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
   struct filter_ctx *ctx)
 {
struct adapter *adapter = netdev2adap(dev);
-   unsigned int max_fidx, fidx, iq;
+   unsigned int max_fidx, fidx;
struct filter_entry *f;
u32 iconf;
-   int ret;
+   int iq, ret;
 
max_fidx = adapter->tids.nftids;
if (filter_id != (max_fidx + adapter->tids.nsftids - 1) &&
-- 
2.9.3



[PATCH][V2] mlxsw: spectrum: remove redundant check if err is zero

2016-09-24 Thread Colin King
From: Colin Ian King 

There is an earlier check and return if err is non-zero, so
the check to see if it is zero is redundant in every iteration
of the loop and hence the check can be removed.

Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 2a61617..1073673 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -117,11 +117,11 @@ static int validate_filter(struct net_device *dev,
return 0;
 }
 
-static unsigned int get_filter_steerq(struct net_device *dev,
- struct ch_filter_specification *fs)
+static int get_filter_steerq(struct net_device *dev,
+struct ch_filter_specification *fs)
 {
struct adapter *adapter = netdev2adap(dev);
-   unsigned int iq;
+   int iq;
 
/* If the user has requested steering matching Ingress Packets
 * to a specific Queue Set, we need to make sure it's in range
@@ -443,10 +443,10 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
   struct filter_ctx *ctx)
 {
struct adapter *adapter = netdev2adap(dev);
-   unsigned int max_fidx, fidx, iq;
+   unsigned int max_fidx, fidx;
struct filter_entry *f;
u32 iconf;
-   int ret;
+   int iq, ret;
 
max_fidx = adapter->tids.nftids;
if (filter_id != (max_fidx + adapter->tids.nsftids - 1) &&
-- 
2.9.3



Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 4:35 PM, Cedric Blancher
 wrote:
>>
>> void *entry = parent->slots[offset];
>> int siboff = entry - parent->slots;
>
> If entry is a pointer to void, how can you do pointer arithmetic with it?

It's actually void **.

(That said, gcc has an extension that considers "void *" to be a byte
pointer, so you can actually do arithmetic on them, and it acts like
"char *")

> Also, if you use pointer distances, the use of int is not valid, it
> should then be ptrdiff_t siboff.

The use of "int" is perfectly valid, since it's limited by
RADIX_TREE_MAP_SIZE, so it's going to be a small integer.

 Linus


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 4:35 PM, Cedric Blancher
 wrote:
>>
>> void *entry = parent->slots[offset];
>> int siboff = entry - parent->slots;
>
> If entry is a pointer to void, how can you do pointer arithmetic with it?

It's actually void **.

(That said, gcc has an extension that considers "void *" to be a byte
pointer, so you can actually do arithmetic on them, and it acts like
"char *")

> Also, if you use pointer distances, the use of int is not valid, it
> should then be ptrdiff_t siboff.

The use of "int" is perfectly valid, since it's limited by
RADIX_TREE_MAP_SIZE, so it's going to be a small integer.

 Linus


Re: [RFC] remove unnecessary condition in remove_inode_hugepages

2016-09-24 Thread Mike Kravetz
On 09/23/2016 07:56 PM, zhong jiang wrote:
> On 2016/9/24 1:19, Mike Kravetz wrote:
>> On 09/22/2016 06:53 PM, zhong jiang wrote:
>>> At present, we need to call hugetlb_fix_reserve_count when 
>>> hugetlb_unrserve_pages fails,
>>> and PagePrivate will decide hugetlb reserves counts.
>>>
>>> we obtain the page from page cache. and use page both lock_page and 
>>> mutex_lock.
>>> alloc_huge_page add page to page chace always hold lock page, then bail out 
>>> clearpageprivate
>>> before unlock page. 
>>>
>>> but I' m not sure  it is right  or I miss the points.
>> Let me try to explain the code you suggest is unnecessary.
>>
>> The PagePrivate flag is used in huge page allocation/deallocation to
>> indicate that the page was globally reserved.  For example, in
>> dequeue_huge_page_vma() there is this code:
>>
>> if (page) {
>> if (avoid_reserve)
>> break;
>> if (!vma_has_reserves(vma, chg))
>> break;
>>
>> SetPagePrivate(page);
>> h->resv_huge_pages--;
>> break;
>> }
>>
>> and in free_huge_page():
>>
>> restore_reserve = PagePrivate(page);
>> ClearPagePrivate(page);
>>  .
>>  
>>  .
>> if (restore_reserve)
>> h->resv_huge_pages++;
>>
>> This helps maintains the global huge page reserve count.
>>
>> In addition to the global reserve count, there are per VMA reservation
>> structures.  Unfortunately, these structures have different meanings
>> depending on the context in which they are used.
>>
>> If there is a VMA reservation entry for a page, and the page has not
>> been instantiated in the VMA this indicates there is a huge page reserved
>> and the global resv_huge_pages count reflects that reservation.  Even
>> if a page was not reserved, a VMA reservation entry is added when a page
>> is instantiated in the VMA.
>>
>> With that background, let's look at the existing code/proposed changes.
>  Clearly. 
>>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>>> index 4ea71eb..010723b 100644
>>> --- a/fs/hugetlbfs/inode.c
>>> +++ b/fs/hugetlbfs/inode.c
>>> @@ -462,14 +462,12 @@ static void remove_inode_hugepages(struct inode 
>>> *inode, loff_t lstart,
>>>  * the page, note PagePrivate which is used in case
>>>  * of error.
>>>  */
>>> -   rsv_on_error = !PagePrivate(page);
>> This rsv_on_error flag indicates that when the huge page was allocated,
>yes
>> it was NOT counted against the global reserve count.  So, when
>> remove_huge_page eventually calls free_huge_page(), the global count
>> resv_huge_pages is not incremented.  So far, no problem.
>  but the page comes from the page cache.  if it is.  it should implement
>  ClearPageprivate(page) when lock page.   This condition always true.
> 
>   The key point is why it need still check the PagePrivate(page) when page 
> from
>   page cache and hold lock.

You are correct.  My apologies for not seeing your point in the original
post.

When the huge page is added to the page cache (huge_add_to_page_cache),
the Page Private flag will be cleared.  Since this code
(remove_inode_hugepages) will only be called for pages in the page cache,
PagePrivate(page) will always be false.

The comments in this area should be changed along with the code.

-- 
Mike Kravetz

> 
>   Thanks you
>  zhongjiang
>>> remove_huge_page(page);
>>> freed++;
>>> if (!truncate_op) {
>>> if (unlikely(hugetlb_unreserve_pages(inode,
>>> next, next + 1, 1)))
>> We now have this VERY unlikely situation that hugetlb_unreserve_pages fails.
>> This means that the VMA reservation entry for the page was not removed.
>> So, we are in a bit of a mess.  The page has already been removed, but the
>> VMA reservation entry can not.  This LOOKS like there is a reservation for
>> the page in the VMA reservation structure.  But, the global count
>> resv_huge_pages does not reflect this reservation.
>>
>> If we do nothing, when the VMA is eventually removed the VMA reservation
>> structure will be completely removed and the global count resv_huge_pages
>> will be decremented for each entry in the structure.  Since, there is a
>> VMA reservation entry without a corresponding global count, the global
>> count will be one less than it should (will eventually go to -1).
>>
>> To 'fix' this, hugetlb_fix_reserve_counts is called.  In this case, it will
>> increment the global count so that it is consistent with the entries in
>> the VMA reservation structure.
>>
>> This is all quite confusing and really unlikely to happen. 

Re: [RFC] remove unnecessary condition in remove_inode_hugepages

2016-09-24 Thread Mike Kravetz
On 09/23/2016 07:56 PM, zhong jiang wrote:
> On 2016/9/24 1:19, Mike Kravetz wrote:
>> On 09/22/2016 06:53 PM, zhong jiang wrote:
>>> At present, we need to call hugetlb_fix_reserve_count when 
>>> hugetlb_unrserve_pages fails,
>>> and PagePrivate will decide hugetlb reserves counts.
>>>
>>> we obtain the page from page cache. and use page both lock_page and 
>>> mutex_lock.
>>> alloc_huge_page add page to page chace always hold lock page, then bail out 
>>> clearpageprivate
>>> before unlock page. 
>>>
>>> but I' m not sure  it is right  or I miss the points.
>> Let me try to explain the code you suggest is unnecessary.
>>
>> The PagePrivate flag is used in huge page allocation/deallocation to
>> indicate that the page was globally reserved.  For example, in
>> dequeue_huge_page_vma() there is this code:
>>
>> if (page) {
>> if (avoid_reserve)
>> break;
>> if (!vma_has_reserves(vma, chg))
>> break;
>>
>> SetPagePrivate(page);
>> h->resv_huge_pages--;
>> break;
>> }
>>
>> and in free_huge_page():
>>
>> restore_reserve = PagePrivate(page);
>> ClearPagePrivate(page);
>>  .
>>  
>>  .
>> if (restore_reserve)
>> h->resv_huge_pages++;
>>
>> This helps maintains the global huge page reserve count.
>>
>> In addition to the global reserve count, there are per VMA reservation
>> structures.  Unfortunately, these structures have different meanings
>> depending on the context in which they are used.
>>
>> If there is a VMA reservation entry for a page, and the page has not
>> been instantiated in the VMA this indicates there is a huge page reserved
>> and the global resv_huge_pages count reflects that reservation.  Even
>> if a page was not reserved, a VMA reservation entry is added when a page
>> is instantiated in the VMA.
>>
>> With that background, let's look at the existing code/proposed changes.
>  Clearly. 
>>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>>> index 4ea71eb..010723b 100644
>>> --- a/fs/hugetlbfs/inode.c
>>> +++ b/fs/hugetlbfs/inode.c
>>> @@ -462,14 +462,12 @@ static void remove_inode_hugepages(struct inode 
>>> *inode, loff_t lstart,
>>>  * the page, note PagePrivate which is used in case
>>>  * of error.
>>>  */
>>> -   rsv_on_error = !PagePrivate(page);
>> This rsv_on_error flag indicates that when the huge page was allocated,
>yes
>> it was NOT counted against the global reserve count.  So, when
>> remove_huge_page eventually calls free_huge_page(), the global count
>> resv_huge_pages is not incremented.  So far, no problem.
>  but the page comes from the page cache.  if it is.  it should implement
>  ClearPageprivate(page) when lock page.   This condition always true.
> 
>   The key point is why it need still check the PagePrivate(page) when page 
> from
>   page cache and hold lock.

You are correct.  My apologies for not seeing your point in the original
post.

When the huge page is added to the page cache (huge_add_to_page_cache),
the Page Private flag will be cleared.  Since this code
(remove_inode_hugepages) will only be called for pages in the page cache,
PagePrivate(page) will always be false.

The comments in this area should be changed along with the code.

-- 
Mike Kravetz

> 
>   Thanks you
>  zhongjiang
>>> remove_huge_page(page);
>>> freed++;
>>> if (!truncate_op) {
>>> if (unlikely(hugetlb_unreserve_pages(inode,
>>> next, next + 1, 1)))
>> We now have this VERY unlikely situation that hugetlb_unreserve_pages fails.
>> This means that the VMA reservation entry for the page was not removed.
>> So, we are in a bit of a mess.  The page has already been removed, but the
>> VMA reservation entry can not.  This LOOKS like there is a reservation for
>> the page in the VMA reservation structure.  But, the global count
>> resv_huge_pages does not reflect this reservation.
>>
>> If we do nothing, when the VMA is eventually removed the VMA reservation
>> structure will be completely removed and the global count resv_huge_pages
>> will be decremented for each entry in the structure.  Since, there is a
>> VMA reservation entry without a corresponding global count, the global
>> count will be one less than it should (will eventually go to -1).
>>
>> To 'fix' this, hugetlb_fix_reserve_counts is called.  In this case, it will
>> increment the global count so that it is consistent with the entries in
>> the VMA reservation structure.
>>
>> This is all quite confusing and really unlikely to happen. 

Re: [PATCH] Net Driver: Add Cypress GX3 VID=04b4 PID=3610.

2016-09-24 Thread David Miller
From: Chris Roth 
Date: Sat, 24 Sep 2016 10:59:04 -0600

> Due to my lack of familiarity with the how git send-email works, I've
> unintentionally had my name listed as the first 'from' whereas I
> intended Allan Chou to be listed as the first 'from' in the patch. If
> anyone can correct this on my behalf, I would appreciate it.

Simply just submit a 'v2' of this patch with this issue fixed.


Re: [PATCH] Net Driver: Add Cypress GX3 VID=04b4 PID=3610.

2016-09-24 Thread David Miller
From: Chris Roth 
Date: Sat, 24 Sep 2016 10:59:04 -0600

> Due to my lack of familiarity with the how git send-email works, I've
> unintentionally had my name listed as the first 'from' whereas I
> intended Allan Chou to be listed as the first 'from' in the patch. If
> anyone can correct this on my behalf, I would appreciate it.

Simply just submit a 'v2' of this patch with this issue fixed.


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Cedric Blancher
On 22 September 2016 at 20:53, Matthew Wilcox
 wrote:
> From: Matthew Wilcox 
>
> When compiling the radix tree with -O2, GCC thinks it can optimise:
>
> void *entry = parent->slots[offset];
> int siboff = entry - parent->slots;

If entry is a pointer to void, how can you do pointer arithmetic with it?
Also, if you use pointer distances, the use of int is not valid, it
should then be ptrdiff_t siboff.

lint(1) would bite your arse off in both cases.
Sadly only UNIX (Solaris, AIX, ...) use lint(1) as mandatory part of
the build process and make warnings and errors of lint(1) fatal...

Ced
-- 
Cedric Blancher 
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Cedric Blancher
On 22 September 2016 at 20:53, Matthew Wilcox
 wrote:
> From: Matthew Wilcox 
>
> When compiling the radix tree with -O2, GCC thinks it can optimise:
>
> void *entry = parent->slots[offset];
> int siboff = entry - parent->slots;

If entry is a pointer to void, how can you do pointer arithmetic with it?
Also, if you use pointer distances, the use of int is not valid, it
should then be ptrdiff_t siboff.

lint(1) would bite your arse off in both cases.
Sadly only UNIX (Solaris, AIX, ...) use lint(1) as mandatory part of
the build process and make warnings and errors of lint(1) fatal...

Ced
-- 
Cedric Blancher 
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur


[PATCH net-next 4/8] rxrpc: Reinitialise the call ACK and timer state for client reply phase

2016-09-24 Thread David Howells
Clear the ACK reason, ACK timer and resend timer when entering the client
reply phase when the first DATA packet is received.  New ACKs will be
proposed once the data is queued.

The resend timer is no longer relevant and we need to cancel ACKs scheduled
to probe for a lost reply.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |1 +
 net/rxrpc/input.c   |9 +
 net/rxrpc/misc.c|1 +
 3 files changed, 11 insertions(+)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index e3bf9c0e3ad1..cdd35e2b40ba 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -682,6 +682,7 @@ extern const char 
rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5];
 
 enum rxrpc_timer_trace {
rxrpc_timer_begin,
+   rxrpc_timer_init_for_reply,
rxrpc_timer_expired,
rxrpc_timer_set_for_ack,
rxrpc_timer_set_for_resend,
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 757c16f033a0..bda11eb2ab2a 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -149,6 +149,15 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
 {
rxrpc_seq_t top = READ_ONCE(call->tx_top);
 
+   if (call->ackr_reason) {
+   spin_lock_bh(>lock);
+   call->ackr_reason = 0;
+   call->resend_at = call->expire_at;
+   call->ack_at = call->expire_at;
+   spin_unlock_bh(>lock);
+   rxrpc_set_timer(call, rxrpc_timer_init_for_reply);
+   }
+
if (!test_bit(RXRPC_CALL_TX_LAST, >flags))
rxrpc_rotate_tx_window(call, top);
if (!test_bit(RXRPC_CALL_TX_LAST, >flags)) {
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index a473fd7dabaa..901c012a2700 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -191,6 +191,7 @@ const char rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5] = 
{
 const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8] = {
[rxrpc_timer_begin] = "Begin ",
[rxrpc_timer_expired]   = "*EXPR*",
+   [rxrpc_timer_init_for_reply]= "IniRpl",
[rxrpc_timer_set_for_ack]   = "SetAck",
[rxrpc_timer_set_for_send]  = "SetTx ",
[rxrpc_timer_set_for_resend]= "SetRTx",



[PATCH net-next 3/8] rxrpc: Include the last reply DATA serial number in the final ACK

2016-09-24 Thread David Howells
In a client call, include the serial number of the last DATA packet of the
reply in the final ACK.

Signed-off-by: David Howells 
---

 net/rxrpc/recvmsg.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index a7458c398b9e..038ae62ddb4d 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -133,7 +133,7 @@ static int rxrpc_recvmsg_new_call(struct rxrpc_sock *rx,
 /*
  * End the packet reception phase.
  */
-static void rxrpc_end_rx_phase(struct rxrpc_call *call)
+static void rxrpc_end_rx_phase(struct rxrpc_call *call, rxrpc_serial_t serial)
 {
_enter("%d,%s", call->debug_id, rxrpc_call_states[call->state]);
 
@@ -141,7 +141,7 @@ static void rxrpc_end_rx_phase(struct rxrpc_call *call)
ASSERTCMP(call->rx_hard_ack, ==, call->rx_top);
 
if (call->state == RXRPC_CALL_CLIENT_RECV_REPLY) {
-   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, 0, true, false,
+   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, serial, true, false,
  rxrpc_propose_ack_terminal_ack);
rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ACK);
}
@@ -202,7 +202,7 @@ static void rxrpc_rotate_rx_window(struct rxrpc_call *call)
_debug("%u,%u,%02x", hard_ack, top, flags);
trace_rxrpc_receive(call, rxrpc_receive_rotate, serial, hard_ack);
if (flags & RXRPC_LAST_PACKET) {
-   rxrpc_end_rx_phase(call);
+   rxrpc_end_rx_phase(call, serial);
} else {
/* Check to see if there's an ACK that needs sending. */
if (after_eq(hard_ack, call->ackr_consumed + 2) ||



[PATCH net-next 6/8] rxrpc: Generate a summary of the ACK state for later use

2016-09-24 Thread David Howells
Generate a summary of the Tx buffer packet state when an ACK is received
for use in a later patch that does congestion management.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |   14 ++
 net/rxrpc/input.c   |   45 ++---
 2 files changed, 48 insertions(+), 11 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index cdd35e2b40ba..1a700b6a998b 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -540,6 +540,20 @@ struct rxrpc_call {
 
/* transmission-phase ACK management */
rxrpc_serial_t  acks_latest;/* serial number of latest ACK 
received */
+   rxrpc_seq_t acks_lowest_nak; /* Lowest NACK in the buffer 
(or ==tx_hard_ack) */
+};
+
+/*
+ * Summary of a new ACK and the changes it made.
+ */
+struct rxrpc_ack_summary {
+   u8  ack_reason;
+   u8  nr_acks;/* Number of ACKs in 
packet */
+   u8  nr_nacks;   /* Number of NACKs in 
packet */
+   u8  nr_new_acks;/* Number of new ACKs 
in packet */
+   u8  nr_new_nacks;   /* Number of new NACKs 
in packet */
+   u8  nr_rot_new_acks;/* Number of rotated 
new ACKs */
+   boolnew_low_nack;   /* T if new low NACK 
found */
 };
 
 enum rxrpc_skb_trace {
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index bda11eb2ab2a..dd699667eeef 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -56,12 +56,20 @@ static void rxrpc_send_ping(struct rxrpc_call *call, struct 
sk_buff *skb,
 /*
  * Apply a hard ACK by advancing the Tx window.
  */
-static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to)
+static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
+  struct rxrpc_ack_summary *summary)
 {
struct sk_buff *skb, *list = NULL;
int ix;
u8 annotation;
 
+   if (call->acks_lowest_nak == call->tx_hard_ack) {
+   call->acks_lowest_nak = to;
+   } else if (before_eq(call->acks_lowest_nak, to)) {
+   summary->new_low_nack = true;
+   call->acks_lowest_nak = to;
+   }
+
spin_lock(>lock);
 
while (before(call->tx_hard_ack, to)) {
@@ -77,6 +85,8 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, 
rxrpc_seq_t to)
 
if (annotation & RXRPC_TX_ANNO_LAST)
set_bit(RXRPC_CALL_TX_LAST, >flags);
+   if ((annotation & RXRPC_TX_ANNO_MASK) != RXRPC_TX_ANNO_ACK)
+   summary->nr_rot_new_acks++;
}
 
spin_unlock(>lock);
@@ -147,6 +157,7 @@ bad_state:
  */
 static bool rxrpc_receiving_reply(struct rxrpc_call *call)
 {
+   struct rxrpc_ack_summary summary = { 0 };
rxrpc_seq_t top = READ_ONCE(call->tx_top);
 
if (call->ackr_reason) {
@@ -159,7 +170,7 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
}
 
if (!test_bit(RXRPC_CALL_TX_LAST, >flags))
-   rxrpc_rotate_tx_window(call, top);
+   rxrpc_rotate_tx_window(call, top, );
if (!test_bit(RXRPC_CALL_TX_LAST, >flags)) {
rxrpc_proto_abort("TXL", call, top);
return false;
@@ -508,7 +519,8 @@ static void rxrpc_input_ackinfo(struct rxrpc_call *call, 
struct sk_buff *skb,
  * the time the ACK was sent.
  */
 static void rxrpc_input_soft_acks(struct rxrpc_call *call, u8 *acks,
- rxrpc_seq_t seq, int nr_acks)
+ rxrpc_seq_t seq, int nr_acks,
+ struct rxrpc_ack_summary *summary)
 {
bool resend = false;
int ix;
@@ -521,14 +533,23 @@ static void rxrpc_input_soft_acks(struct rxrpc_call 
*call, u8 *acks,
annotation &= ~RXRPC_TX_ANNO_MASK;
switch (*acks++) {
case RXRPC_ACK_TYPE_ACK:
+   summary->nr_acks++;
if (anno_type == RXRPC_TX_ANNO_ACK)
continue;
+   summary->nr_new_acks++;
call->rxtx_annotations[ix] =
RXRPC_TX_ANNO_ACK | annotation;
break;
case RXRPC_ACK_TYPE_NACK:
+   if (!summary->nr_nacks &&
+   call->acks_lowest_nak != seq) {
+   call->acks_lowest_nak = seq;
+   summary->new_low_nack = true;
+   }
+   summary->nr_nacks++;
if (anno_type == RXRPC_TX_ANNO_NAK)
continue;
+   summary->nr_new_nacks++;
if 

[PATCH net-next 8/8] rxrpc: Implement slow-start

2016-09-24 Thread David Howells
Implement RxRPC slow-start, which is similar to RFC 5681 for TCP.  A
tracepoint is added to log the state of the congestion management algorithm
and the decisions it makes.

Notes:

 (1) Since we send fixed-size DATA packets (apart from the final packet in
 each phase), counters and calculations are in terms of packets rather
 than bytes.

 (2) The ACK packet carries the equivalent of TCP SACK.

 (3) The FLIGHT_SIZE calculation in RFC 5681 doesn't seem particularly
 suited to SACK of a small number of packets.  It seems that, almost
 inevitably, by the time three 'duplicate' ACKs have been seen, we have
 narrowed the loss down to one or two missing packets, and the
 FLIGHT_SIZE calculation ends up as 2.

 (4) In rxrpc_resend(), if there was no data that apparently needed
 retransmission, we transmit a PING ACK to ask the peer to tell us what
 its Rx window state is.

Signed-off-by: David Howells 
---

 include/trace/events/rxrpc.h |   45 +++
 net/rxrpc/ar-internal.h  |   53 +
 net/rxrpc/call_event.c   |   36 -
 net/rxrpc/call_object.c  |   13 +++
 net/rxrpc/conn_event.c   |1 
 net/rxrpc/input.c|  169 +-
 net/rxrpc/misc.c |   19 +
 net/rxrpc/output.c   |9 ++
 net/rxrpc/sendmsg.c  |7 +-
 9 files changed, 339 insertions(+), 13 deletions(-)

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 56475497043d..ada12d00118c 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -570,6 +570,51 @@ TRACE_EVENT(rxrpc_retransmit,
  __entry->expiry)
);
 
+TRACE_EVENT(rxrpc_congest,
+   TP_PROTO(struct rxrpc_call *call, struct rxrpc_ack_summary *summary,
+rxrpc_serial_t ack_serial, enum rxrpc_congest_change 
change),
+
+   TP_ARGS(call, summary, ack_serial, change),
+
+   TP_STRUCT__entry(
+   __field(struct rxrpc_call *,call
)
+   __field(enum rxrpc_congest_change,  change  
)
+   __field(rxrpc_seq_t,hard_ack
)
+   __field(rxrpc_seq_t,top 
)
+   __field(rxrpc_seq_t,lowest_nak  
)
+   __field(rxrpc_serial_t, ack_serial  
)
+   __field_struct(struct rxrpc_ack_summary,sum 
)
+),
+
+   TP_fast_assign(
+   __entry->call   = call;
+   __entry->change = change;
+   __entry->hard_ack   = call->tx_hard_ack;
+   __entry->top= call->tx_top;
+   __entry->lowest_nak = call->acks_lowest_nak;
+   __entry->ack_serial = ack_serial;
+   memcpy(&__entry->sum, summary, sizeof(__entry->sum));
+  ),
+
+   TP_printk("c=%p %08x %s %08x %s cw=%u ss=%u nr=%u,%u nw=%u,%u r=%u 
b=%u u=%u d=%u l=%x%s%s%s",
+ __entry->call,
+ __entry->ack_serial,
+ rxrpc_ack_names[__entry->sum.ack_reason],
+ __entry->hard_ack,
+ rxrpc_congest_modes[__entry->sum.mode],
+ __entry->sum.cwnd,
+ __entry->sum.ssthresh,
+ __entry->sum.nr_acks, __entry->sum.nr_nacks,
+ __entry->sum.nr_new_acks, __entry->sum.nr_new_nacks,
+ __entry->sum.nr_rot_new_acks,
+ __entry->top - __entry->hard_ack,
+ __entry->sum.cumulative_acks,
+ __entry->sum.dup_acks,
+ __entry->lowest_nak, __entry->sum.new_low_nack ? "!" : "",
+ rxrpc_congest_changes[__entry->change],
+ __entry->sum.retrans_timeo ? " rTxTo" : "")
+   );
+
 #endif /* _TRACE_RXRPC_H */
 
 /* This part must be outside protection */
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index b1e697fc9ffb..ca96e547cb9a 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -402,6 +402,7 @@ enum rxrpc_call_flag {
RXRPC_CALL_RX_LAST, /* Received the last packet (at 
rxtx_top) */
RXRPC_CALL_TX_LAST, /* Last packet in Tx buffer (at 
rxtx_top) */
RXRPC_CALL_PINGING, /* Ping in process */
+   RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout 
occurred */
 };
 
 /*
@@ -447,6 +448,17 @@ enum rxrpc_call_completion {
 };
 
 /*
+ * Call Tx congestion management modes.
+ */
+enum rxrpc_congest_mode {
+   RXRPC_CALL_SLOW_START,
+   RXRPC_CALL_CONGEST_AVOIDANCE,
+   RXRPC_CALL_PACKET_LOSS,
+   

[PATCH net-next 6/8] rxrpc: Generate a summary of the ACK state for later use

2016-09-24 Thread David Howells
Generate a summary of the Tx buffer packet state when an ACK is received
for use in a later patch that does congestion management.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |   14 ++
 net/rxrpc/input.c   |   45 ++---
 2 files changed, 48 insertions(+), 11 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index cdd35e2b40ba..1a700b6a998b 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -540,6 +540,20 @@ struct rxrpc_call {
 
/* transmission-phase ACK management */
rxrpc_serial_t  acks_latest;/* serial number of latest ACK 
received */
+   rxrpc_seq_t acks_lowest_nak; /* Lowest NACK in the buffer 
(or ==tx_hard_ack) */
+};
+
+/*
+ * Summary of a new ACK and the changes it made.
+ */
+struct rxrpc_ack_summary {
+   u8  ack_reason;
+   u8  nr_acks;/* Number of ACKs in 
packet */
+   u8  nr_nacks;   /* Number of NACKs in 
packet */
+   u8  nr_new_acks;/* Number of new ACKs 
in packet */
+   u8  nr_new_nacks;   /* Number of new NACKs 
in packet */
+   u8  nr_rot_new_acks;/* Number of rotated 
new ACKs */
+   boolnew_low_nack;   /* T if new low NACK 
found */
 };
 
 enum rxrpc_skb_trace {
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index bda11eb2ab2a..dd699667eeef 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -56,12 +56,20 @@ static void rxrpc_send_ping(struct rxrpc_call *call, struct 
sk_buff *skb,
 /*
  * Apply a hard ACK by advancing the Tx window.
  */
-static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to)
+static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
+  struct rxrpc_ack_summary *summary)
 {
struct sk_buff *skb, *list = NULL;
int ix;
u8 annotation;
 
+   if (call->acks_lowest_nak == call->tx_hard_ack) {
+   call->acks_lowest_nak = to;
+   } else if (before_eq(call->acks_lowest_nak, to)) {
+   summary->new_low_nack = true;
+   call->acks_lowest_nak = to;
+   }
+
spin_lock(>lock);
 
while (before(call->tx_hard_ack, to)) {
@@ -77,6 +85,8 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, 
rxrpc_seq_t to)
 
if (annotation & RXRPC_TX_ANNO_LAST)
set_bit(RXRPC_CALL_TX_LAST, >flags);
+   if ((annotation & RXRPC_TX_ANNO_MASK) != RXRPC_TX_ANNO_ACK)
+   summary->nr_rot_new_acks++;
}
 
spin_unlock(>lock);
@@ -147,6 +157,7 @@ bad_state:
  */
 static bool rxrpc_receiving_reply(struct rxrpc_call *call)
 {
+   struct rxrpc_ack_summary summary = { 0 };
rxrpc_seq_t top = READ_ONCE(call->tx_top);
 
if (call->ackr_reason) {
@@ -159,7 +170,7 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
}
 
if (!test_bit(RXRPC_CALL_TX_LAST, >flags))
-   rxrpc_rotate_tx_window(call, top);
+   rxrpc_rotate_tx_window(call, top, );
if (!test_bit(RXRPC_CALL_TX_LAST, >flags)) {
rxrpc_proto_abort("TXL", call, top);
return false;
@@ -508,7 +519,8 @@ static void rxrpc_input_ackinfo(struct rxrpc_call *call, 
struct sk_buff *skb,
  * the time the ACK was sent.
  */
 static void rxrpc_input_soft_acks(struct rxrpc_call *call, u8 *acks,
- rxrpc_seq_t seq, int nr_acks)
+ rxrpc_seq_t seq, int nr_acks,
+ struct rxrpc_ack_summary *summary)
 {
bool resend = false;
int ix;
@@ -521,14 +533,23 @@ static void rxrpc_input_soft_acks(struct rxrpc_call 
*call, u8 *acks,
annotation &= ~RXRPC_TX_ANNO_MASK;
switch (*acks++) {
case RXRPC_ACK_TYPE_ACK:
+   summary->nr_acks++;
if (anno_type == RXRPC_TX_ANNO_ACK)
continue;
+   summary->nr_new_acks++;
call->rxtx_annotations[ix] =
RXRPC_TX_ANNO_ACK | annotation;
break;
case RXRPC_ACK_TYPE_NACK:
+   if (!summary->nr_nacks &&
+   call->acks_lowest_nak != seq) {
+   call->acks_lowest_nak = seq;
+   summary->new_low_nack = true;
+   }
+   summary->nr_nacks++;
if (anno_type == RXRPC_TX_ANNO_NAK)
continue;
+   summary->nr_new_nacks++;
if (anno_type == 

[PATCH net-next 8/8] rxrpc: Implement slow-start

2016-09-24 Thread David Howells
Implement RxRPC slow-start, which is similar to RFC 5681 for TCP.  A
tracepoint is added to log the state of the congestion management algorithm
and the decisions it makes.

Notes:

 (1) Since we send fixed-size DATA packets (apart from the final packet in
 each phase), counters and calculations are in terms of packets rather
 than bytes.

 (2) The ACK packet carries the equivalent of TCP SACK.

 (3) The FLIGHT_SIZE calculation in RFC 5681 doesn't seem particularly
 suited to SACK of a small number of packets.  It seems that, almost
 inevitably, by the time three 'duplicate' ACKs have been seen, we have
 narrowed the loss down to one or two missing packets, and the
 FLIGHT_SIZE calculation ends up as 2.

 (4) In rxrpc_resend(), if there was no data that apparently needed
 retransmission, we transmit a PING ACK to ask the peer to tell us what
 its Rx window state is.

Signed-off-by: David Howells 
---

 include/trace/events/rxrpc.h |   45 +++
 net/rxrpc/ar-internal.h  |   53 +
 net/rxrpc/call_event.c   |   36 -
 net/rxrpc/call_object.c  |   13 +++
 net/rxrpc/conn_event.c   |1 
 net/rxrpc/input.c|  169 +-
 net/rxrpc/misc.c |   19 +
 net/rxrpc/output.c   |9 ++
 net/rxrpc/sendmsg.c  |7 +-
 9 files changed, 339 insertions(+), 13 deletions(-)

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 56475497043d..ada12d00118c 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -570,6 +570,51 @@ TRACE_EVENT(rxrpc_retransmit,
  __entry->expiry)
);
 
+TRACE_EVENT(rxrpc_congest,
+   TP_PROTO(struct rxrpc_call *call, struct rxrpc_ack_summary *summary,
+rxrpc_serial_t ack_serial, enum rxrpc_congest_change 
change),
+
+   TP_ARGS(call, summary, ack_serial, change),
+
+   TP_STRUCT__entry(
+   __field(struct rxrpc_call *,call
)
+   __field(enum rxrpc_congest_change,  change  
)
+   __field(rxrpc_seq_t,hard_ack
)
+   __field(rxrpc_seq_t,top 
)
+   __field(rxrpc_seq_t,lowest_nak  
)
+   __field(rxrpc_serial_t, ack_serial  
)
+   __field_struct(struct rxrpc_ack_summary,sum 
)
+),
+
+   TP_fast_assign(
+   __entry->call   = call;
+   __entry->change = change;
+   __entry->hard_ack   = call->tx_hard_ack;
+   __entry->top= call->tx_top;
+   __entry->lowest_nak = call->acks_lowest_nak;
+   __entry->ack_serial = ack_serial;
+   memcpy(&__entry->sum, summary, sizeof(__entry->sum));
+  ),
+
+   TP_printk("c=%p %08x %s %08x %s cw=%u ss=%u nr=%u,%u nw=%u,%u r=%u 
b=%u u=%u d=%u l=%x%s%s%s",
+ __entry->call,
+ __entry->ack_serial,
+ rxrpc_ack_names[__entry->sum.ack_reason],
+ __entry->hard_ack,
+ rxrpc_congest_modes[__entry->sum.mode],
+ __entry->sum.cwnd,
+ __entry->sum.ssthresh,
+ __entry->sum.nr_acks, __entry->sum.nr_nacks,
+ __entry->sum.nr_new_acks, __entry->sum.nr_new_nacks,
+ __entry->sum.nr_rot_new_acks,
+ __entry->top - __entry->hard_ack,
+ __entry->sum.cumulative_acks,
+ __entry->sum.dup_acks,
+ __entry->lowest_nak, __entry->sum.new_low_nack ? "!" : "",
+ rxrpc_congest_changes[__entry->change],
+ __entry->sum.retrans_timeo ? " rTxTo" : "")
+   );
+
 #endif /* _TRACE_RXRPC_H */
 
 /* This part must be outside protection */
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index b1e697fc9ffb..ca96e547cb9a 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -402,6 +402,7 @@ enum rxrpc_call_flag {
RXRPC_CALL_RX_LAST, /* Received the last packet (at 
rxtx_top) */
RXRPC_CALL_TX_LAST, /* Last packet in Tx buffer (at 
rxtx_top) */
RXRPC_CALL_PINGING, /* Ping in process */
+   RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout 
occurred */
 };
 
 /*
@@ -447,6 +448,17 @@ enum rxrpc_call_completion {
 };
 
 /*
+ * Call Tx congestion management modes.
+ */
+enum rxrpc_congest_mode {
+   RXRPC_CALL_SLOW_START,
+   RXRPC_CALL_CONGEST_AVOIDANCE,
+   RXRPC_CALL_PACKET_LOSS,
+   RXRPC_CALL_FAST_RETRANSMIT,
+   

[PATCH net-next 3/8] rxrpc: Include the last reply DATA serial number in the final ACK

2016-09-24 Thread David Howells
In a client call, include the serial number of the last DATA packet of the
reply in the final ACK.

Signed-off-by: David Howells 
---

 net/rxrpc/recvmsg.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index a7458c398b9e..038ae62ddb4d 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -133,7 +133,7 @@ static int rxrpc_recvmsg_new_call(struct rxrpc_sock *rx,
 /*
  * End the packet reception phase.
  */
-static void rxrpc_end_rx_phase(struct rxrpc_call *call)
+static void rxrpc_end_rx_phase(struct rxrpc_call *call, rxrpc_serial_t serial)
 {
_enter("%d,%s", call->debug_id, rxrpc_call_states[call->state]);
 
@@ -141,7 +141,7 @@ static void rxrpc_end_rx_phase(struct rxrpc_call *call)
ASSERTCMP(call->rx_hard_ack, ==, call->rx_top);
 
if (call->state == RXRPC_CALL_CLIENT_RECV_REPLY) {
-   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, 0, true, false,
+   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, serial, true, false,
  rxrpc_propose_ack_terminal_ack);
rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ACK);
}
@@ -202,7 +202,7 @@ static void rxrpc_rotate_rx_window(struct rxrpc_call *call)
_debug("%u,%u,%02x", hard_ack, top, flags);
trace_rxrpc_receive(call, rxrpc_receive_rotate, serial, hard_ack);
if (flags & RXRPC_LAST_PACKET) {
-   rxrpc_end_rx_phase(call);
+   rxrpc_end_rx_phase(call, serial);
} else {
/* Check to see if there's an ACK that needs sending. */
if (after_eq(hard_ack, call->ackr_consumed + 2) ||



[PATCH net-next 4/8] rxrpc: Reinitialise the call ACK and timer state for client reply phase

2016-09-24 Thread David Howells
Clear the ACK reason, ACK timer and resend timer when entering the client
reply phase when the first DATA packet is received.  New ACKs will be
proposed once the data is queued.

The resend timer is no longer relevant and we need to cancel ACKs scheduled
to probe for a lost reply.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |1 +
 net/rxrpc/input.c   |9 +
 net/rxrpc/misc.c|1 +
 3 files changed, 11 insertions(+)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index e3bf9c0e3ad1..cdd35e2b40ba 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -682,6 +682,7 @@ extern const char 
rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5];
 
 enum rxrpc_timer_trace {
rxrpc_timer_begin,
+   rxrpc_timer_init_for_reply,
rxrpc_timer_expired,
rxrpc_timer_set_for_ack,
rxrpc_timer_set_for_resend,
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 757c16f033a0..bda11eb2ab2a 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -149,6 +149,15 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
 {
rxrpc_seq_t top = READ_ONCE(call->tx_top);
 
+   if (call->ackr_reason) {
+   spin_lock_bh(>lock);
+   call->ackr_reason = 0;
+   call->resend_at = call->expire_at;
+   call->ack_at = call->expire_at;
+   spin_unlock_bh(>lock);
+   rxrpc_set_timer(call, rxrpc_timer_init_for_reply);
+   }
+
if (!test_bit(RXRPC_CALL_TX_LAST, >flags))
rxrpc_rotate_tx_window(call, top);
if (!test_bit(RXRPC_CALL_TX_LAST, >flags)) {
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index a473fd7dabaa..901c012a2700 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -191,6 +191,7 @@ const char rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5] = 
{
 const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8] = {
[rxrpc_timer_begin] = "Begin ",
[rxrpc_timer_expired]   = "*EXPR*",
+   [rxrpc_timer_init_for_reply]= "IniRpl",
[rxrpc_timer_set_for_ack]   = "SetAck",
[rxrpc_timer_set_for_send]  = "SetTx ",
[rxrpc_timer_set_for_resend]= "SetRTx",



[PATCH net-next 7/8] rxrpc: Schedule an ACK if the reply to a client call appears overdue

2016-09-24 Thread David Howells
If we've sent all the request data in a client call but haven't seen any
sign of the reply data yet, schedule an ACK to be sent to the server to
find out if the reply data got lost.

If the server hasn't yet hard-ACK'd the request data, we send a PING ACK to
demand a response to find out whether we need to retransmit.

If the server says it has received all of the data, we send an IDLE ACK to
tell the server that we haven't received anything in the receive phase as
yet.

To make this work, a non-immediate PING ACK must carry a delay.  I've chosen
the same as the IDLE ACK for the moment.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |2 ++
 net/rxrpc/call_event.c  |1 +
 net/rxrpc/input.c   |8 
 net/rxrpc/misc.c|2 ++
 4 files changed, 13 insertions(+)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 1a700b6a998b..b1e697fc9ffb 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -707,7 +707,9 @@ enum rxrpc_timer_trace {
 extern const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8];
 
 enum rxrpc_propose_ack_trace {
+   rxrpc_propose_ack_client_tx_end,
rxrpc_propose_ack_input_data,
+   rxrpc_propose_ack_ping_for_lost_reply,
rxrpc_propose_ack_ping_for_params,
rxrpc_propose_ack_respond_to_ack,
rxrpc_propose_ack_respond_to_ping,
diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index d5bf9ce7ec6f..05b94d1acf52 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -100,6 +100,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 
ack_reason,
expiry = rxrpc_soft_ack_delay;
break;
 
+   case RXRPC_ACK_PING:
case RXRPC_ACK_IDLE:
if (rxrpc_idle_ack_delay < expiry)
expiry = rxrpc_idle_ack_delay;
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index dd699667eeef..0344f4494eb7 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -138,6 +138,8 @@ static bool rxrpc_end_tx_phase(struct rxrpc_call *call, 
bool reply_begun,
 
write_unlock(>state_lock);
if (call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY) {
+   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, 0, false, true,
+ rxrpc_propose_ack_client_tx_end);
trace_rxrpc_transmit(call, rxrpc_transmit_await_reply);
} else {
trace_rxrpc_transmit(call, rxrpc_transmit_end);
@@ -684,6 +686,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, 
struct sk_buff *skb,
return;
}
 
+   if (call->rxtx_annotations[call->tx_top & RXRPC_RXTX_BUFF_MASK] &
+   RXRPC_TX_ANNO_LAST &&
+   summary.nr_acks == call->tx_top - hard_ack)
+   rxrpc_propose_ACK(call, RXRPC_ACK_PING, skew, sp->hdr.serial,
+ false, true,
+ rxrpc_propose_ack_ping_for_lost_reply);
 }
 
 /*
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index 901c012a2700..a608769343e6 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -198,7 +198,9 @@ const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8] = {
 };
 
 const char rxrpc_propose_ack_traces[rxrpc_propose_ack__nr_trace][8] = {
+   [rxrpc_propose_ack_client_tx_end]   = "ClTxEnd",
[rxrpc_propose_ack_input_data]  = "DataIn ",
+   [rxrpc_propose_ack_ping_for_lost_reply] = "LostRpl",
[rxrpc_propose_ack_ping_for_params] = "Params ",
[rxrpc_propose_ack_respond_to_ack]  = "Rsp2Ack",
[rxrpc_propose_ack_respond_to_ping] = "Rsp2Png",



[PATCH net-next 5/8] rxrpc: Delay the resend timer to allow for nsec->jiffies conv error

2016-09-24 Thread David Howells
When determining the resend timer value, we have a value in nsec but the
timer is in jiffies which may be a million or more times more coarse.
nsecs_to_jiffies() rounds down - which means that the resend timeout
expressed as jiffies is very likely earlier than the one expressed as
nanoseconds from which it was derived.

The problem is that rxrpc_resend() gets triggered by the timer, but can't
then find anything to resend yet.  It sets the timer again - but gets
kicked off immediately again and again until the nanosecond-based expiry
time is reached and we actually retransmit.

Fix this by adding 1 to the jiffies-based resend_at value to counteract the
rounding and make sure that the timer happens after the nanosecond-based
expiry is passed.

Alternatives would be to adjust the timestamp on the packets to align
with the jiffie scale or to switch back to using jiffie-timestamps.

Signed-off-by: David Howells 
---

 net/rxrpc/call_event.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index a78a92fe5d77..d5bf9ce7ec6f 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -200,8 +200,14 @@ static void rxrpc_resend(struct rxrpc_call *call)
   ktime_to_ns(ktime_sub(skb->tstamp, 
max_age)));
}
 
-   resend_at = ktime_sub(ktime_add_ms(oldest, rxrpc_resend_timeout), now);
-   call->resend_at = jiffies + nsecs_to_jiffies(ktime_to_ns(resend_at));
+   resend_at = ktime_add_ms(oldest, rxrpc_resend_timeout);
+   call->resend_at = jiffies +
+   nsecs_to_jiffies(ktime_to_ns(ktime_sub(resend_at, now))) +
+   1; /* We have to make sure that the calculated jiffies value
+   * falls at or after the nsec value, or we shall loop
+   * ceaselessly because the timer times out, but we haven't
+   * reached the nsec timeout yet.
+   */
 
/* Now go through the Tx window and perform the retransmissions.  We
 * have to drop the lock for each send.  If an ACK comes in whilst the



[PATCH net-next 7/8] rxrpc: Schedule an ACK if the reply to a client call appears overdue

2016-09-24 Thread David Howells
If we've sent all the request data in a client call but haven't seen any
sign of the reply data yet, schedule an ACK to be sent to the server to
find out if the reply data got lost.

If the server hasn't yet hard-ACK'd the request data, we send a PING ACK to
demand a response to find out whether we need to retransmit.

If the server says it has received all of the data, we send an IDLE ACK to
tell the server that we haven't received anything in the receive phase as
yet.

To make this work, a non-immediate PING ACK must carry a delay.  I've chosen
the same as the IDLE ACK for the moment.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |2 ++
 net/rxrpc/call_event.c  |1 +
 net/rxrpc/input.c   |8 
 net/rxrpc/misc.c|2 ++
 4 files changed, 13 insertions(+)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 1a700b6a998b..b1e697fc9ffb 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -707,7 +707,9 @@ enum rxrpc_timer_trace {
 extern const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8];
 
 enum rxrpc_propose_ack_trace {
+   rxrpc_propose_ack_client_tx_end,
rxrpc_propose_ack_input_data,
+   rxrpc_propose_ack_ping_for_lost_reply,
rxrpc_propose_ack_ping_for_params,
rxrpc_propose_ack_respond_to_ack,
rxrpc_propose_ack_respond_to_ping,
diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index d5bf9ce7ec6f..05b94d1acf52 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -100,6 +100,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 
ack_reason,
expiry = rxrpc_soft_ack_delay;
break;
 
+   case RXRPC_ACK_PING:
case RXRPC_ACK_IDLE:
if (rxrpc_idle_ack_delay < expiry)
expiry = rxrpc_idle_ack_delay;
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index dd699667eeef..0344f4494eb7 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -138,6 +138,8 @@ static bool rxrpc_end_tx_phase(struct rxrpc_call *call, 
bool reply_begun,
 
write_unlock(>state_lock);
if (call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY) {
+   rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, 0, false, true,
+ rxrpc_propose_ack_client_tx_end);
trace_rxrpc_transmit(call, rxrpc_transmit_await_reply);
} else {
trace_rxrpc_transmit(call, rxrpc_transmit_end);
@@ -684,6 +686,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, 
struct sk_buff *skb,
return;
}
 
+   if (call->rxtx_annotations[call->tx_top & RXRPC_RXTX_BUFF_MASK] &
+   RXRPC_TX_ANNO_LAST &&
+   summary.nr_acks == call->tx_top - hard_ack)
+   rxrpc_propose_ACK(call, RXRPC_ACK_PING, skew, sp->hdr.serial,
+ false, true,
+ rxrpc_propose_ack_ping_for_lost_reply);
 }
 
 /*
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index 901c012a2700..a608769343e6 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -198,7 +198,9 @@ const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8] = {
 };
 
 const char rxrpc_propose_ack_traces[rxrpc_propose_ack__nr_trace][8] = {
+   [rxrpc_propose_ack_client_tx_end]   = "ClTxEnd",
[rxrpc_propose_ack_input_data]  = "DataIn ",
+   [rxrpc_propose_ack_ping_for_lost_reply] = "LostRpl",
[rxrpc_propose_ack_ping_for_params] = "Params ",
[rxrpc_propose_ack_respond_to_ack]  = "Rsp2Ack",
[rxrpc_propose_ack_respond_to_ping] = "Rsp2Png",



[PATCH net-next 5/8] rxrpc: Delay the resend timer to allow for nsec->jiffies conv error

2016-09-24 Thread David Howells
When determining the resend timer value, we have a value in nsec but the
timer is in jiffies which may be a million or more times more coarse.
nsecs_to_jiffies() rounds down - which means that the resend timeout
expressed as jiffies is very likely earlier than the one expressed as
nanoseconds from which it was derived.

The problem is that rxrpc_resend() gets triggered by the timer, but can't
then find anything to resend yet.  It sets the timer again - but gets
kicked off immediately again and again until the nanosecond-based expiry
time is reached and we actually retransmit.

Fix this by adding 1 to the jiffies-based resend_at value to counteract the
rounding and make sure that the timer happens after the nanosecond-based
expiry is passed.

Alternatives would be to adjust the timestamp on the packets to align
with the jiffie scale or to switch back to using jiffie-timestamps.

Signed-off-by: David Howells 
---

 net/rxrpc/call_event.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index a78a92fe5d77..d5bf9ce7ec6f 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -200,8 +200,14 @@ static void rxrpc_resend(struct rxrpc_call *call)
   ktime_to_ns(ktime_sub(skb->tstamp, 
max_age)));
}
 
-   resend_at = ktime_sub(ktime_add_ms(oldest, rxrpc_resend_timeout), now);
-   call->resend_at = jiffies + nsecs_to_jiffies(ktime_to_ns(resend_at));
+   resend_at = ktime_add_ms(oldest, rxrpc_resend_timeout);
+   call->resend_at = jiffies +
+   nsecs_to_jiffies(ktime_to_ns(ktime_sub(resend_at, now))) +
+   1; /* We have to make sure that the calculated jiffies value
+   * falls at or after the nsec value, or we shall loop
+   * ceaselessly because the timer times out, but we haven't
+   * reached the nsec timeout yet.
+   */
 
/* Now go through the Tx window and perform the retransmissions.  We
 * have to drop the lock for each send.  If an ACK comes in whilst the



[PATCH net-next 2/8] rxrpc: Send an immediate ACK if we fill in a hole

2016-09-24 Thread David Howells
Send an immediate ACK if we fill in a hole in the buffer left by an
out-of-sequence packet.  This may allow the congestion management in the peer
to avoid a retransmission if packets got reordered on the wire.

Signed-off-by: David Howells 
---

 net/rxrpc/input.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 349698d87ad1..757c16f033a0 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -331,8 +331,16 @@ next_subpacket:
call->rxtx_annotations[ix] = annotation;
smp_wmb();
call->rxtx_buffer[ix] = skb;
-   if (after(seq, call->rx_top))
+   if (after(seq, call->rx_top)) {
smp_store_release(>rx_top, seq);
+   } else if (before(seq, call->rx_top)) {
+   /* Send an immediate ACK if we fill in a hole */
+   if (!ack) {
+   ack = RXRPC_ACK_DELAY;
+   ack_serial = serial;
+   }
+   immediate_ack = true;
+   }
if (flags & RXRPC_LAST_PACKET) {
set_bit(RXRPC_CALL_RX_LAST, >flags);
trace_rxrpc_receive(call, rxrpc_receive_queue_last, serial, 
seq);



[PATCH net-next 0/8] rxrpc: Implement slow-start and other bits

2016-09-24 Thread David Howells

This set of patches implements the RxRPC slow-start feature for AF_RXRPC to
improve performance and handling of occasional packet loss.  This is more or
less the same as TCP slow start [RFC 5681].  Firstly, there are some ACK
generation improvements:

 (1) Send ACKs regularly to apprise the peer of our state so that they can do
 congestion management of their own.

 (2) Send an ACK when we fill in a hole in the buffer so that the peer can
 find out that we did this thus forestalling retransmission.

 (3) Note the final DATA packet's serial number in the final ACK for
 correlation purposes.

and a couple of bug fixes:

 (4) Reinitialise the ACK state and clear the ACK and resend timers upon
 entering the client reply reception phase to kill off any pending probe
 ACKs.

 (5) Delay the resend timer to allow for nsec->jiffies conversion errors.

and then there's the slow-start pieces:

 (6) Summarise an ACK.

 (7) Schedule a PING or IDLE ACK if the reply to a client call is overdue to
 try and find out what happened to it.

 (8) Implement the slow start feature.

The patches can be found here also:


http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-rewrite

Tagged thusly:

git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
rxrpc-rewrite-20160924

David
---
David Howells (8):
  rxrpc: Send an ACK after every few DATA packets we receive
  rxrpc: Send an immediate ACK if we fill in a hole
  rxrpc: Include the last reply DATA serial number in the final ACK
  rxrpc: Reinitialise the call ACK and timer state for client reply phase
  rxrpc: Delay the resend timer to allow for nsec->jiffies conv error
  rxrpc: Generate a summary of the ACK state for later use
  rxrpc: Schedule an ACK if the reply to a client call appears overdue
  rxrpc: Implement slow-start


 include/trace/events/rxrpc.h |   45 
 net/rxrpc/ar-internal.h  |   71 
 net/rxrpc/call_event.c   |   47 +++-
 net/rxrpc/call_object.c  |   13 ++
 net/rxrpc/conn_event.c   |1 
 net/rxrpc/input.c|  241 +++---
 net/rxrpc/misc.c |   23 
 net/rxrpc/output.c   |   34 --
 net/rxrpc/recvmsg.c  |   19 +++
 net/rxrpc/sendmsg.c  |7 +
 10 files changed, 463 insertions(+), 38 deletions(-)



[PATCH net-next 1/8] rxrpc: Send an ACK after every few DATA packets we receive

2016-09-24 Thread David Howells
Send an ACK if we haven't sent one for the last two packets we've received.
This keeps the other end apprised of where we've got to - which is
important if they're doing slow-start.

We do this in recvmsg so that we can dispatch a packet directly without the
need to wake up the background thread.

This should possibly be made configurable in future.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |3 +++
 net/rxrpc/misc.c|1 +
 net/rxrpc/output.c  |   25 +
 net/rxrpc/recvmsg.c |   13 -
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 042dbcc52654..e3bf9c0e3ad1 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -533,6 +533,8 @@ struct rxrpc_call {
u16 ackr_skew;  /* skew on packet being ACK'd */
rxrpc_serial_t  ackr_serial;/* serial of packet being ACK'd 
*/
rxrpc_seq_t ackr_prev_seq;  /* previous sequence number 
received */
+   rxrpc_seq_t ackr_consumed;  /* Highest packet shown 
consumed */
+   rxrpc_seq_t ackr_seen;  /* Highest packet shown seen */
rxrpc_serial_t  ackr_ping;  /* Last ping sent */
ktime_t ackr_ping_time; /* Time last ping sent */
 
@@ -695,6 +697,7 @@ enum rxrpc_propose_ack_trace {
rxrpc_propose_ack_respond_to_ack,
rxrpc_propose_ack_respond_to_ping,
rxrpc_propose_ack_retry_tx,
+   rxrpc_propose_ack_rotate_rx,
rxrpc_propose_ack_terminal_ack,
rxrpc_propose_ack__nr_trace
 };
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index 1ca14835d87f..a473fd7dabaa 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -202,6 +202,7 @@ const char 
rxrpc_propose_ack_traces[rxrpc_propose_ack__nr_trace][8] = {
[rxrpc_propose_ack_respond_to_ack]  = "Rsp2Ack",
[rxrpc_propose_ack_respond_to_ping] = "Rsp2Png",
[rxrpc_propose_ack_retry_tx]= "RetryTx",
+   [rxrpc_propose_ack_rotate_rx]   = "RxAck  ",
[rxrpc_propose_ack_terminal_ack]= "ClTerm ",
 };
 
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index 0c563e325c9d..3eb01445e814 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -36,7 +36,9 @@ struct rxrpc_pkt_buffer {
  * Fill out an ACK packet.
  */
 static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
-struct rxrpc_pkt_buffer *pkt)
+struct rxrpc_pkt_buffer *pkt,
+rxrpc_seq_t *_hard_ack,
+rxrpc_seq_t *_top)
 {
rxrpc_serial_t serial;
rxrpc_seq_t hard_ack, top, seq;
@@ -48,6 +50,8 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
serial = call->ackr_serial;
hard_ack = READ_ONCE(call->rx_hard_ack);
top = smp_load_acquire(>rx_top);
+   *_hard_ack = hard_ack;
+   *_top = top;
 
pkt->ack.bufferSpace= htons(8);
pkt->ack.maxSkew= htons(call->ackr_skew);
@@ -96,6 +100,7 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 type)
struct msghdr msg;
struct kvec iov[2];
rxrpc_serial_t serial;
+   rxrpc_seq_t hard_ack, top;
size_t len, n;
bool ping = false;
int ioc, ret;
@@ -146,7 +151,7 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 type)
goto out;
}
ping = (call->ackr_reason == RXRPC_ACK_PING);
-   n = rxrpc_fill_out_ack(call, pkt);
+   n = rxrpc_fill_out_ack(call, pkt, _ack, );
call->ackr_reason = 0;
 
spin_unlock_bh(>lock);
@@ -203,18 +208,22 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 
type)
if (ping)
call->ackr_ping_time = ktime_get_real();
 
-   if (ret < 0 && call->state < RXRPC_CALL_COMPLETE) {
-   switch (type) {
-   case RXRPC_PACKET_TYPE_ACK:
+   if (type == RXRPC_PACKET_TYPE_ACK &&
+   call->state < RXRPC_CALL_COMPLETE) {
+   if (ret < 0) {
clear_bit(RXRPC_CALL_PINGING, >flags);
rxrpc_propose_ACK(call, pkt->ack.reason,
  ntohs(pkt->ack.maxSkew),
  ntohl(pkt->ack.serial),
  true, true,
  rxrpc_propose_ack_retry_tx);
-   break;
-   case RXRPC_PACKET_TYPE_ABORT:
-   break;
+   } else {
+   spin_lock_bh(>lock);
+   if (after(hard_ack, call->ackr_consumed))
+   call->ackr_consumed = hard_ack;
+   if (after(top, 

[PATCH net-next 2/8] rxrpc: Send an immediate ACK if we fill in a hole

2016-09-24 Thread David Howells
Send an immediate ACK if we fill in a hole in the buffer left by an
out-of-sequence packet.  This may allow the congestion management in the peer
to avoid a retransmission if packets got reordered on the wire.

Signed-off-by: David Howells 
---

 net/rxrpc/input.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 349698d87ad1..757c16f033a0 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -331,8 +331,16 @@ next_subpacket:
call->rxtx_annotations[ix] = annotation;
smp_wmb();
call->rxtx_buffer[ix] = skb;
-   if (after(seq, call->rx_top))
+   if (after(seq, call->rx_top)) {
smp_store_release(>rx_top, seq);
+   } else if (before(seq, call->rx_top)) {
+   /* Send an immediate ACK if we fill in a hole */
+   if (!ack) {
+   ack = RXRPC_ACK_DELAY;
+   ack_serial = serial;
+   }
+   immediate_ack = true;
+   }
if (flags & RXRPC_LAST_PACKET) {
set_bit(RXRPC_CALL_RX_LAST, >flags);
trace_rxrpc_receive(call, rxrpc_receive_queue_last, serial, 
seq);



[PATCH net-next 0/8] rxrpc: Implement slow-start and other bits

2016-09-24 Thread David Howells

This set of patches implements the RxRPC slow-start feature for AF_RXRPC to
improve performance and handling of occasional packet loss.  This is more or
less the same as TCP slow start [RFC 5681].  Firstly, there are some ACK
generation improvements:

 (1) Send ACKs regularly to apprise the peer of our state so that they can do
 congestion management of their own.

 (2) Send an ACK when we fill in a hole in the buffer so that the peer can
 find out that we did this thus forestalling retransmission.

 (3) Note the final DATA packet's serial number in the final ACK for
 correlation purposes.

and a couple of bug fixes:

 (4) Reinitialise the ACK state and clear the ACK and resend timers upon
 entering the client reply reception phase to kill off any pending probe
 ACKs.

 (5) Delay the resend timer to allow for nsec->jiffies conversion errors.

and then there's the slow-start pieces:

 (6) Summarise an ACK.

 (7) Schedule a PING or IDLE ACK if the reply to a client call is overdue to
 try and find out what happened to it.

 (8) Implement the slow start feature.

The patches can be found here also:


http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-rewrite

Tagged thusly:

git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
rxrpc-rewrite-20160924

David
---
David Howells (8):
  rxrpc: Send an ACK after every few DATA packets we receive
  rxrpc: Send an immediate ACK if we fill in a hole
  rxrpc: Include the last reply DATA serial number in the final ACK
  rxrpc: Reinitialise the call ACK and timer state for client reply phase
  rxrpc: Delay the resend timer to allow for nsec->jiffies conv error
  rxrpc: Generate a summary of the ACK state for later use
  rxrpc: Schedule an ACK if the reply to a client call appears overdue
  rxrpc: Implement slow-start


 include/trace/events/rxrpc.h |   45 
 net/rxrpc/ar-internal.h  |   71 
 net/rxrpc/call_event.c   |   47 +++-
 net/rxrpc/call_object.c  |   13 ++
 net/rxrpc/conn_event.c   |1 
 net/rxrpc/input.c|  241 +++---
 net/rxrpc/misc.c |   23 
 net/rxrpc/output.c   |   34 --
 net/rxrpc/recvmsg.c  |   19 +++
 net/rxrpc/sendmsg.c  |7 +
 10 files changed, 463 insertions(+), 38 deletions(-)



[PATCH net-next 1/8] rxrpc: Send an ACK after every few DATA packets we receive

2016-09-24 Thread David Howells
Send an ACK if we haven't sent one for the last two packets we've received.
This keeps the other end apprised of where we've got to - which is
important if they're doing slow-start.

We do this in recvmsg so that we can dispatch a packet directly without the
need to wake up the background thread.

This should possibly be made configurable in future.

Signed-off-by: David Howells 
---

 net/rxrpc/ar-internal.h |3 +++
 net/rxrpc/misc.c|1 +
 net/rxrpc/output.c  |   25 +
 net/rxrpc/recvmsg.c |   13 -
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 042dbcc52654..e3bf9c0e3ad1 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -533,6 +533,8 @@ struct rxrpc_call {
u16 ackr_skew;  /* skew on packet being ACK'd */
rxrpc_serial_t  ackr_serial;/* serial of packet being ACK'd 
*/
rxrpc_seq_t ackr_prev_seq;  /* previous sequence number 
received */
+   rxrpc_seq_t ackr_consumed;  /* Highest packet shown 
consumed */
+   rxrpc_seq_t ackr_seen;  /* Highest packet shown seen */
rxrpc_serial_t  ackr_ping;  /* Last ping sent */
ktime_t ackr_ping_time; /* Time last ping sent */
 
@@ -695,6 +697,7 @@ enum rxrpc_propose_ack_trace {
rxrpc_propose_ack_respond_to_ack,
rxrpc_propose_ack_respond_to_ping,
rxrpc_propose_ack_retry_tx,
+   rxrpc_propose_ack_rotate_rx,
rxrpc_propose_ack_terminal_ack,
rxrpc_propose_ack__nr_trace
 };
diff --git a/net/rxrpc/misc.c b/net/rxrpc/misc.c
index 1ca14835d87f..a473fd7dabaa 100644
--- a/net/rxrpc/misc.c
+++ b/net/rxrpc/misc.c
@@ -202,6 +202,7 @@ const char 
rxrpc_propose_ack_traces[rxrpc_propose_ack__nr_trace][8] = {
[rxrpc_propose_ack_respond_to_ack]  = "Rsp2Ack",
[rxrpc_propose_ack_respond_to_ping] = "Rsp2Png",
[rxrpc_propose_ack_retry_tx]= "RetryTx",
+   [rxrpc_propose_ack_rotate_rx]   = "RxAck  ",
[rxrpc_propose_ack_terminal_ack]= "ClTerm ",
 };
 
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index 0c563e325c9d..3eb01445e814 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -36,7 +36,9 @@ struct rxrpc_pkt_buffer {
  * Fill out an ACK packet.
  */
 static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
-struct rxrpc_pkt_buffer *pkt)
+struct rxrpc_pkt_buffer *pkt,
+rxrpc_seq_t *_hard_ack,
+rxrpc_seq_t *_top)
 {
rxrpc_serial_t serial;
rxrpc_seq_t hard_ack, top, seq;
@@ -48,6 +50,8 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
serial = call->ackr_serial;
hard_ack = READ_ONCE(call->rx_hard_ack);
top = smp_load_acquire(>rx_top);
+   *_hard_ack = hard_ack;
+   *_top = top;
 
pkt->ack.bufferSpace= htons(8);
pkt->ack.maxSkew= htons(call->ackr_skew);
@@ -96,6 +100,7 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 type)
struct msghdr msg;
struct kvec iov[2];
rxrpc_serial_t serial;
+   rxrpc_seq_t hard_ack, top;
size_t len, n;
bool ping = false;
int ioc, ret;
@@ -146,7 +151,7 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 type)
goto out;
}
ping = (call->ackr_reason == RXRPC_ACK_PING);
-   n = rxrpc_fill_out_ack(call, pkt);
+   n = rxrpc_fill_out_ack(call, pkt, _ack, );
call->ackr_reason = 0;
 
spin_unlock_bh(>lock);
@@ -203,18 +208,22 @@ int rxrpc_send_call_packet(struct rxrpc_call *call, u8 
type)
if (ping)
call->ackr_ping_time = ktime_get_real();
 
-   if (ret < 0 && call->state < RXRPC_CALL_COMPLETE) {
-   switch (type) {
-   case RXRPC_PACKET_TYPE_ACK:
+   if (type == RXRPC_PACKET_TYPE_ACK &&
+   call->state < RXRPC_CALL_COMPLETE) {
+   if (ret < 0) {
clear_bit(RXRPC_CALL_PINGING, >flags);
rxrpc_propose_ACK(call, pkt->ack.reason,
  ntohs(pkt->ack.maxSkew),
  ntohl(pkt->ack.serial),
  true, true,
  rxrpc_propose_ack_retry_tx);
-   break;
-   case RXRPC_PACKET_TYPE_ABORT:
-   break;
+   } else {
+   spin_lock_bh(>lock);
+   if (after(hard_ack, call->ackr_consumed))
+   call->ackr_consumed = hard_ack;
+   if (after(top, call->ackr_seen))
+

Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 2:04 PM, Kirill A. Shutemov
 wrote:
>
> Well, my ext4-with-huge-pages patchset[1] uses multi-order entries.
> It also converts shmem-with-huge-pages and hugetlb to them.

Ok, so that code actually has a chance of being used. I guess we'll
not remove it. But I *would* like this subtle issue to have a comment
around that odd cast/and/mask thing.

Linus


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 2:04 PM, Kirill A. Shutemov
 wrote:
>
> Well, my ext4-with-huge-pages patchset[1] uses multi-order entries.
> It also converts shmem-with-huge-pages and hugetlb to them.

Ok, so that code actually has a chance of being used. I guess we'll
not remove it. But I *would* like this subtle issue to have a comment
around that odd cast/and/mask thing.

Linus


[PATCH] libnvdimm, region: fix flush hint table thinko

2016-09-24 Thread Dan Williams
The definition of the flush hint table as:

void __iomem *flush_wpq[0][0];

...passed the unit test, but is broken as flush_wpq[0][1] and
flush_wpq[1][0] refer to the same entry.  Fix this to use a helper that
calculates a slot in the table based on the geometry of flush hints in
the region.  This is important to get right since virtualization
solutions use this mechanism to trigger hypervisor flushes to platform
persistence.

Reported-by: Dave Jiang 
Signed-off-by: Dan Williams 
---
 drivers/nvdimm/nd.h  |   22 --
 drivers/nvdimm/region_devs.c |   20 
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 8024a0ef86d3..0b78a8211f4a 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -52,10 +52,28 @@ struct nvdimm_drvdata {
 struct nd_region_data {
int ns_count;
int ns_active;
-   unsigned int flush_mask;
-   void __iomem *flush_wpq[0][0];
+   unsigned int hints_shift;
+   void __iomem *flush_wpq[0];
 };
 
+static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
+   int dimm, int hint)
+{
+   unsigned int num = 1 << ndrd->hints_shift;
+   unsigned int mask = num - 1;
+
+   return ndrd->flush_wpq[dimm * num + (hint & mask)];
+}
+
+static inline void ndrd_set_flush_wpq(struct nd_region_data *ndrd, int dimm,
+   int hint, void __iomem *flush)
+{
+   unsigned int num = 1 << ndrd->hints_shift;
+   unsigned int mask = num - 1;
+
+   ndrd->flush_wpq[dimm * num + (hint & mask)] = flush;
+}
+
 static inline struct nd_namespace_index *to_namespace_index(
struct nvdimm_drvdata *ndd, int i)
 {
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 4eef88eb5144..4c0ac4abb629 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -38,7 +38,7 @@ static int nvdimm_map_flush(struct device *dev, struct nvdimm 
*nvdimm, int dimm,
 
dev_dbg(dev, "%s: map %d flush address%s\n", nvdimm_name(nvdimm),
nvdimm->num_flush, nvdimm->num_flush == 1 ? "" : "es");
-   for (i = 0; i < nvdimm->num_flush; i++) {
+   for (i = 0; i < (1 << ndrd->hints_shift); i++) {
struct resource *res = >flush_wpq[i];
unsigned long pfn = PHYS_PFN(res->start);
void __iomem *flush_page;
@@ -54,14 +54,15 @@ static int nvdimm_map_flush(struct device *dev, struct 
nvdimm *nvdimm, int dimm,
 
if (j < i)
flush_page = (void __iomem *) ((unsigned long)
-   ndrd->flush_wpq[dimm][j] & PAGE_MASK);
+   ndrd_get_flush_wpq(ndrd, dimm, j)
+   & PAGE_MASK);
else
flush_page = devm_nvdimm_ioremap(dev,
PFN_PHYS(pfn), PAGE_SIZE);
if (!flush_page)
return -ENXIO;
-   ndrd->flush_wpq[dimm][i] = flush_page
-   + (res->start & ~PAGE_MASK);
+   ndrd_set_flush_wpq(ndrd, dimm, i, flush_page
+   + (res->start & ~PAGE_MASK));
}
 
return 0;
@@ -93,7 +94,10 @@ int nd_region_activate(struct nd_region *nd_region)
return -ENOMEM;
dev_set_drvdata(dev, ndrd);
 
-   ndrd->flush_mask = (1 << ilog2(num_flush)) - 1;
+   if (!num_flush)
+   return 0;
+
+   ndrd->hints_shift = ilog2(num_flush);
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = _region->mapping[i];
struct nvdimm *nvdimm = nd_mapping->nvdimm;
@@ -900,8 +904,8 @@ void nvdimm_flush(struct nd_region *nd_region)
 */
wmb();
for (i = 0; i < nd_region->ndr_mappings; i++)
-   if (ndrd->flush_wpq[i][0])
-   writeq(1, ndrd->flush_wpq[i][idx & ndrd->flush_mask]);
+   if (ndrd_get_flush_wpq(ndrd, i, 0))
+   writeq(1, ndrd_get_flush_wpq(ndrd, i, idx));
wmb();
 }
 EXPORT_SYMBOL_GPL(nvdimm_flush);
@@ -925,7 +929,7 @@ int nvdimm_has_flush(struct nd_region *nd_region)
 
for (i = 0; i < nd_region->ndr_mappings; i++)
/* flush hints present, flushing required */
-   if (ndrd->flush_wpq[i][0])
+   if (ndrd_get_flush_wpq(ndrd, i, 0))
return 1;
 
/*



[PATCH] libnvdimm, region: fix flush hint table thinko

2016-09-24 Thread Dan Williams
The definition of the flush hint table as:

void __iomem *flush_wpq[0][0];

...passed the unit test, but is broken as flush_wpq[0][1] and
flush_wpq[1][0] refer to the same entry.  Fix this to use a helper that
calculates a slot in the table based on the geometry of flush hints in
the region.  This is important to get right since virtualization
solutions use this mechanism to trigger hypervisor flushes to platform
persistence.

Reported-by: Dave Jiang 
Signed-off-by: Dan Williams 
---
 drivers/nvdimm/nd.h  |   22 --
 drivers/nvdimm/region_devs.c |   20 
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 8024a0ef86d3..0b78a8211f4a 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -52,10 +52,28 @@ struct nvdimm_drvdata {
 struct nd_region_data {
int ns_count;
int ns_active;
-   unsigned int flush_mask;
-   void __iomem *flush_wpq[0][0];
+   unsigned int hints_shift;
+   void __iomem *flush_wpq[0];
 };
 
+static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
+   int dimm, int hint)
+{
+   unsigned int num = 1 << ndrd->hints_shift;
+   unsigned int mask = num - 1;
+
+   return ndrd->flush_wpq[dimm * num + (hint & mask)];
+}
+
+static inline void ndrd_set_flush_wpq(struct nd_region_data *ndrd, int dimm,
+   int hint, void __iomem *flush)
+{
+   unsigned int num = 1 << ndrd->hints_shift;
+   unsigned int mask = num - 1;
+
+   ndrd->flush_wpq[dimm * num + (hint & mask)] = flush;
+}
+
 static inline struct nd_namespace_index *to_namespace_index(
struct nvdimm_drvdata *ndd, int i)
 {
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 4eef88eb5144..4c0ac4abb629 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -38,7 +38,7 @@ static int nvdimm_map_flush(struct device *dev, struct nvdimm 
*nvdimm, int dimm,
 
dev_dbg(dev, "%s: map %d flush address%s\n", nvdimm_name(nvdimm),
nvdimm->num_flush, nvdimm->num_flush == 1 ? "" : "es");
-   for (i = 0; i < nvdimm->num_flush; i++) {
+   for (i = 0; i < (1 << ndrd->hints_shift); i++) {
struct resource *res = >flush_wpq[i];
unsigned long pfn = PHYS_PFN(res->start);
void __iomem *flush_page;
@@ -54,14 +54,15 @@ static int nvdimm_map_flush(struct device *dev, struct 
nvdimm *nvdimm, int dimm,
 
if (j < i)
flush_page = (void __iomem *) ((unsigned long)
-   ndrd->flush_wpq[dimm][j] & PAGE_MASK);
+   ndrd_get_flush_wpq(ndrd, dimm, j)
+   & PAGE_MASK);
else
flush_page = devm_nvdimm_ioremap(dev,
PFN_PHYS(pfn), PAGE_SIZE);
if (!flush_page)
return -ENXIO;
-   ndrd->flush_wpq[dimm][i] = flush_page
-   + (res->start & ~PAGE_MASK);
+   ndrd_set_flush_wpq(ndrd, dimm, i, flush_page
+   + (res->start & ~PAGE_MASK));
}
 
return 0;
@@ -93,7 +94,10 @@ int nd_region_activate(struct nd_region *nd_region)
return -ENOMEM;
dev_set_drvdata(dev, ndrd);
 
-   ndrd->flush_mask = (1 << ilog2(num_flush)) - 1;
+   if (!num_flush)
+   return 0;
+
+   ndrd->hints_shift = ilog2(num_flush);
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = _region->mapping[i];
struct nvdimm *nvdimm = nd_mapping->nvdimm;
@@ -900,8 +904,8 @@ void nvdimm_flush(struct nd_region *nd_region)
 */
wmb();
for (i = 0; i < nd_region->ndr_mappings; i++)
-   if (ndrd->flush_wpq[i][0])
-   writeq(1, ndrd->flush_wpq[i][idx & ndrd->flush_mask]);
+   if (ndrd_get_flush_wpq(ndrd, i, 0))
+   writeq(1, ndrd_get_flush_wpq(ndrd, i, idx));
wmb();
 }
 EXPORT_SYMBOL_GPL(nvdimm_flush);
@@ -925,7 +929,7 @@ int nvdimm_has_flush(struct nd_region *nd_region)
 
for (i = 0; i < nd_region->ndr_mappings; i++)
/* flush hints present, flushing required */
-   if (ndrd->flush_wpq[i][0])
+   if (ndrd_get_flush_wpq(ndrd, i, 0))
return 1;
 
/*



[PATCH] clk: at91: Fix a return value in case of error

2016-09-24 Thread Christophe JAILLET
If 'clk_hw_register()' fails, it is likely that we expect to return an
error instead of a valid pointer (which would mean success).
'clk_hw_register()' returns a bool, so we don't have the detail of the
error. Return -ENOMEM instead, as it seems to be the most common error
returned by clk_register().

Fix commit f5644f10dcfb ("clk: at91: Migrate to clk_hw based registration
and OF APIs")

Signed-off-by: Christophe JAILLET 
---
It is likely that a bigger change is needed. For example using clk_register
instead of clk_hw_register would return the error instead of a bool.
We could then propagate this error to the caller without the need to choose
an arbitrary error value.

This proposal is un-compiled and un-tested.
I get an error when I run 'make drivers/clk/at91/' which is likely due to
my building environment. 
---
 drivers/clk/at91/clk-programmable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 190122e64a3a..2cf200e22d48 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -203,7 +203,7 @@ at91_clk_register_programmable(struct regmap *regmap,
ret = clk_hw_register(NULL, >hw);
if (ret) {
kfree(prog);
-   hw = >hw;
+   hw = ERR_PTR(-ENOMEM);
}
 
return hw;
-- 
2.7.4



[PATCH] clk: at91: Fix a return value in case of error

2016-09-24 Thread Christophe JAILLET
If 'clk_hw_register()' fails, it is likely that we expect to return an
error instead of a valid pointer (which would mean success).
'clk_hw_register()' returns a bool, so we don't have the detail of the
error. Return -ENOMEM instead, as it seems to be the most common error
returned by clk_register().

Fix commit f5644f10dcfb ("clk: at91: Migrate to clk_hw based registration
and OF APIs")

Signed-off-by: Christophe JAILLET 
---
It is likely that a bigger change is needed. For example using clk_register
instead of clk_hw_register would return the error instead of a bool.
We could then propagate this error to the caller without the need to choose
an arbitrary error value.

This proposal is un-compiled and un-tested.
I get an error when I run 'make drivers/clk/at91/' which is likely due to
my building environment. 
---
 drivers/clk/at91/clk-programmable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 190122e64a3a..2cf200e22d48 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -203,7 +203,7 @@ at91_clk_register_programmable(struct regmap *regmap,
ret = clk_hw_register(NULL, >hw);
if (ret) {
kfree(prog);
-   hw = >hw;
+   hw = ERR_PTR(-ENOMEM);
}
 
return hw;
-- 
2.7.4



[PATCH] firewire: nosy: do not ignore errors in ioremap_nocache()

2016-09-24 Thread Alexey Khoroshilov
There is no check if ioremap_nocache() returns a valid pointer.
Potentially it can lead to null pointer dereference.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/firewire/nosy.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 631c977b0da5..f68a749f740b 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -566,6 +566,11 @@ add_card(struct pci_dev *dev, const struct pci_device_id 
*unused)
 
lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
  PCILYNX_MAX_REGISTER);
+   if (lynx->registers == NULL) {
+   dev_err(>dev, "Failed to map registers\n");
+   ret = -ENOMEM;
+   goto fail_deallocate2;
+   }
 
lynx->rcv_start_pcl = pci_alloc_consistent(lynx->pci_device,
sizeof(struct pcl), >rcv_start_pcl_bus);
@@ -679,6 +684,8 @@ fail_deallocate:
pci_free_consistent(lynx->pci_device, PAGE_SIZE,
lynx->rcv_buffer, lynx->rcv_buffer_bus);
iounmap(lynx->registers);
+
+fail_deallocate2:
kfree(lynx);
 
 fail_disable:
-- 
2.7.4



[PATCH] firewire: nosy: do not ignore errors in ioremap_nocache()

2016-09-24 Thread Alexey Khoroshilov
There is no check if ioremap_nocache() returns a valid pointer.
Potentially it can lead to null pointer dereference.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/firewire/nosy.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 631c977b0da5..f68a749f740b 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -566,6 +566,11 @@ add_card(struct pci_dev *dev, const struct pci_device_id 
*unused)
 
lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
  PCILYNX_MAX_REGISTER);
+   if (lynx->registers == NULL) {
+   dev_err(>dev, "Failed to map registers\n");
+   ret = -ENOMEM;
+   goto fail_deallocate2;
+   }
 
lynx->rcv_start_pcl = pci_alloc_consistent(lynx->pci_device,
sizeof(struct pcl), >rcv_start_pcl_bus);
@@ -679,6 +684,8 @@ fail_deallocate:
pci_free_consistent(lynx->pci_device, PAGE_SIZE,
lynx->rcv_buffer, lynx->rcv_buffer_bus);
iounmap(lynx->registers);
+
+fail_deallocate2:
kfree(lynx);
 
 fail_disable:
-- 
2.7.4



Re: [PATCH] ARM: dts: exynos: Add reboot reason support for Trats2

2016-09-24 Thread Wolfgang Wiedmeyer

Krzysztof Kozlowski writes:

> On Thu, Sep 22, 2016 at 08:59:03PM +0200, Wolfgang Wiedmeyer wrote:
>> 
>> Krzysztof Kozlowski writes:
>> 
>> > On Thu, Sep 22, 2016 at 06:48:35PM +0200, Wolfgang Wiedmeyer wrote:
>> >> This allows to reboot the device into recovery mode and into the download
>> >> mode of the bootloader.
>> >
>> > Which bootloader? Probably UBoot... or Samsung stock one? Could you put
>> > that information here?
>> 
>> I'm only working with the stock one. I was under the impression that the
>> stock bootloader cannot be replaced on a i9300 because there's a
>> signature check. Is UBoot loaded after the stock one on Trats2 or how
>> does this work? I didn't find information on that.
>
> +CC Marek,
>
> Trats2 is working with U-Boot. Just U-Boot. However I never converted S3
> into Trats2 on my own. I always used targets prepared to be "Trats2"
> type. 

It would be awesome to be able to run U-Boot on i9300. Is there a way to
test this by not risking to brick the device, e.g. by booting from the
SD card? Then I could send an updated version of the patch that is
compatible with U-Boot :) 

> Of course kernel is independent to bootloader but in that case you want
> to use a specific interface between kernel and specific bootloader
> type/version. In that case - this should be U-Boot, I think.

I absolutely understand that. Having the patch in mainline doesn't make
much sense if it's not compatible with U-Boot.

Best regards,
Wolfgang

>> >> Signed-off-by: Wolfgang Wiedmeyer 
>> >> ---
>> >>  arch/arm/boot/dts/exynos4412-trats2.dts | 14 ++
>> >>  arch/arm/boot/dts/exynos4x12.dtsi   |  2 +-
>> >>  2 files changed, 15 insertions(+), 1 deletion(-)
>> >> 
>> >> diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts 
>> >> b/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> index 129e973..a38d1e3 100644
>> >> --- a/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> +++ b/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> @@ -1294,3 +1294,17 @@
>> >>   vtmu-supply = <_reg>;
>> >>   status = "okay";
>> >>  };
>> >> +
>> >> + {
>> >> + compatible = "syscon", "simple-mfd";
>> >> +
>> >> + reboot-mode {
>> >> + compatible = "syscon-reboot-mode";
>> >> + offset = <0x80c>;
>> >> +
>> >> + mode-normal = <0x12345670>;
>> >> + mode-bootloader = <0x12345671>;
>> >> + mode-download   = <0x12345671>;
>> >> + mode-recovery   = <0x12345674>;
>> >
>> > Hmmm, how did you get these values? Are they already supported?
>> 
>> I only have the vendor source drop as documentation. The magic mode
>> values [1] and the offset [2] can be found there.
>
> It would be useful to mention that in commit msg (just the source)...
> however as I wrote above, these values should be for U-Boot, not the
> stock one.
>
> Best regards,
> Krzysztof
>
>> 
>> > It would be nice to document them:
>> > 1. In Documentation/arm/Samsung/Bootloader-interface.txt
>> > 2. In header. I hate such magic numbers... you could add new header next
>> >to existing rockchip one:
>> >include/dt-bindings/soc/samsung,boot-mode.h
>> >(and update maintainers entry :) )
>> 
>> Thanks for the review! I will do the documentation and update the commit
>> message.
>> 
>> Best regards,
>> Wolfgang
>> 
>> [1] 
>> https://code.fossencdi.org/kernel_samsung_smdk4412.git/tree/arch/arm/mach-exynos/sec-reboot.c#n65
>> 
>> [2] 
>> https://code.fossencdi.org/kernel_samsung_smdk4412.git/tree/arch/arm/mach-exynos/include/mach/regs-pmu.h#n79
>> 
>> 
>> -- 
>> Website: https://fossencdi.org
>> Jabber: wolfg...@wiedmeyer.de
>> OpenPGP: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4
>> Key download: https://wiedmeyer.de/keys/ww.asc


-- 
Website: https://fossencdi.org
Jabber: wolfg...@wiedmeyer.de
OpenPGP: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4
Key download: https://wiedmeyer.de/keys/ww.asc


signature.asc
Description: PGP signature


Re: [PATCH] ARM: dts: exynos: Add reboot reason support for Trats2

2016-09-24 Thread Wolfgang Wiedmeyer

Krzysztof Kozlowski writes:

> On Thu, Sep 22, 2016 at 08:59:03PM +0200, Wolfgang Wiedmeyer wrote:
>> 
>> Krzysztof Kozlowski writes:
>> 
>> > On Thu, Sep 22, 2016 at 06:48:35PM +0200, Wolfgang Wiedmeyer wrote:
>> >> This allows to reboot the device into recovery mode and into the download
>> >> mode of the bootloader.
>> >
>> > Which bootloader? Probably UBoot... or Samsung stock one? Could you put
>> > that information here?
>> 
>> I'm only working with the stock one. I was under the impression that the
>> stock bootloader cannot be replaced on a i9300 because there's a
>> signature check. Is UBoot loaded after the stock one on Trats2 or how
>> does this work? I didn't find information on that.
>
> +CC Marek,
>
> Trats2 is working with U-Boot. Just U-Boot. However I never converted S3
> into Trats2 on my own. I always used targets prepared to be "Trats2"
> type. 

It would be awesome to be able to run U-Boot on i9300. Is there a way to
test this by not risking to brick the device, e.g. by booting from the
SD card? Then I could send an updated version of the patch that is
compatible with U-Boot :) 

> Of course kernel is independent to bootloader but in that case you want
> to use a specific interface between kernel and specific bootloader
> type/version. In that case - this should be U-Boot, I think.

I absolutely understand that. Having the patch in mainline doesn't make
much sense if it's not compatible with U-Boot.

Best regards,
Wolfgang

>> >> Signed-off-by: Wolfgang Wiedmeyer 
>> >> ---
>> >>  arch/arm/boot/dts/exynos4412-trats2.dts | 14 ++
>> >>  arch/arm/boot/dts/exynos4x12.dtsi   |  2 +-
>> >>  2 files changed, 15 insertions(+), 1 deletion(-)
>> >> 
>> >> diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts 
>> >> b/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> index 129e973..a38d1e3 100644
>> >> --- a/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> +++ b/arch/arm/boot/dts/exynos4412-trats2.dts
>> >> @@ -1294,3 +1294,17 @@
>> >>   vtmu-supply = <_reg>;
>> >>   status = "okay";
>> >>  };
>> >> +
>> >> + {
>> >> + compatible = "syscon", "simple-mfd";
>> >> +
>> >> + reboot-mode {
>> >> + compatible = "syscon-reboot-mode";
>> >> + offset = <0x80c>;
>> >> +
>> >> + mode-normal = <0x12345670>;
>> >> + mode-bootloader = <0x12345671>;
>> >> + mode-download   = <0x12345671>;
>> >> + mode-recovery   = <0x12345674>;
>> >
>> > Hmmm, how did you get these values? Are they already supported?
>> 
>> I only have the vendor source drop as documentation. The magic mode
>> values [1] and the offset [2] can be found there.
>
> It would be useful to mention that in commit msg (just the source)...
> however as I wrote above, these values should be for U-Boot, not the
> stock one.
>
> Best regards,
> Krzysztof
>
>> 
>> > It would be nice to document them:
>> > 1. In Documentation/arm/Samsung/Bootloader-interface.txt
>> > 2. In header. I hate such magic numbers... you could add new header next
>> >to existing rockchip one:
>> >include/dt-bindings/soc/samsung,boot-mode.h
>> >(and update maintainers entry :) )
>> 
>> Thanks for the review! I will do the documentation and update the commit
>> message.
>> 
>> Best regards,
>> Wolfgang
>> 
>> [1] 
>> https://code.fossencdi.org/kernel_samsung_smdk4412.git/tree/arch/arm/mach-exynos/sec-reboot.c#n65
>> 
>> [2] 
>> https://code.fossencdi.org/kernel_samsung_smdk4412.git/tree/arch/arm/mach-exynos/include/mach/regs-pmu.h#n79
>> 
>> 
>> -- 
>> Website: https://fossencdi.org
>> Jabber: wolfg...@wiedmeyer.de
>> OpenPGP: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4
>> Key download: https://wiedmeyer.de/keys/ww.asc


-- 
Website: https://fossencdi.org
Jabber: wolfg...@wiedmeyer.de
OpenPGP: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4
Key download: https://wiedmeyer.de/keys/ww.asc


signature.asc
Description: PGP signature


Re: [PATCH] staging: sm750fb: rename getChipType to get_chip_type

2016-09-24 Thread Moshe Green
On Fri, Sep 23, 2016 at 02:13:52PM +0200, Greg KH wrote:
> On Thu, Sep 22, 2016 at 09:15:45PM +0300, Moshe Green wrote:
> > Rename CamelCased function getChipType to get_chip_type.
> > This issue was found by checkpatch.pl
> 
> As this is a global function, can you rename it to something like
> "sm750_get_chip_type()"?  Having a driver-specific function called
> get_chip_type() is not good.
> 
> thanks,
> 
> greg k-h

Will do.
Thanks,

Moshe Green


Re: [PATCH] staging: sm750fb: rename getChipType to get_chip_type

2016-09-24 Thread Moshe Green
On Fri, Sep 23, 2016 at 02:13:52PM +0200, Greg KH wrote:
> On Thu, Sep 22, 2016 at 09:15:45PM +0300, Moshe Green wrote:
> > Rename CamelCased function getChipType to get_chip_type.
> > This issue was found by checkpatch.pl
> 
> As this is a global function, can you rename it to something like
> "sm750_get_chip_type()"?  Having a driver-specific function called
> get_chip_type() is not good.
> 
> thanks,
> 
> greg k-h

Will do.
Thanks,

Moshe Green


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Kirill A. Shutemov
On Sat, Sep 24, 2016 at 01:21:36PM -0700, Linus Torvalds wrote:
> On Fri, Sep 23, 2016 at 1:16 PM, Matthew Wilcox  
> wrote:
> >
> >  #ifdef CONFIG_RADIX_TREE_MULTIORDER
> > if (radix_tree_is_internal_node(entry)) {
> > -   unsigned long siboff = get_slot_offset(parent, entry);
> > +   unsigned long siboff = get_slot_offset(parent,
> > +   (void 
> > **)entry_to_node(entry));
> 
> I feel that it is *this* part that I think needs a huge honking comment.
> 
> If you are going to make get_slot_offset() different, then you could
> just rewrite get_slot_offset() to do
> 
> unsigned long diff = (unsigned long) slot - (unsigned
> long)parent->slots;
> return diff / sizeof(void *);
> 
> and add a comment to say "don't do this as a pointer diff, because
> 'slot' may not be an aligned pointer". No BUG_ON() necessary, because
> it "just works".
> 
> At that point, gcc should just generate the right code, because it
> doesn't see it as a pointer subtraction followed by a pointer
> addition.
> 
> And yes, that crazy " (void **)entry_to_node(entry)" fixes it *too*,
> but it needs a *comment*.
> 
> Why is that special, when all the other uses of get_slot_offset()
> don't have that? *That* is what should be explained. Not some internal
> detail.
> 
> That said, if this code isn't even used, as Konstantin says (THP
> selects it - doesn't THP use it?), then the fix really should be to
> just remove the odd code instead of adding to it.
> 
> Looking around for uses that set "order" to anything but zero, I
> really don't see it. So maybe we should just do *that* trivial thing
> instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
> to be buggy and always has been.

Well, my ext4-with-huge-pages patchset[1] uses multi-order entries.
It also converts shmem-with-huge-pages and hugetlb to them.

I'm okay with converting it to other mechanism, but I need something.
(I looked into Konstantin's RFC patchset[2]. It looks okay, but I don't
feel myself qualified to review it as I don't know much about radix-tree
internals.)

[1] 
http://lkml.kernel.org/r/20160915115523.29737-1-kirill.shute...@linux.intel.com
[2] http://lkml.kernel.org/r/147230727479.9957.1087787722571077339.stgit@zurg

-- 
 Kirill A. Shutemov


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Kirill A. Shutemov
On Sat, Sep 24, 2016 at 01:21:36PM -0700, Linus Torvalds wrote:
> On Fri, Sep 23, 2016 at 1:16 PM, Matthew Wilcox  
> wrote:
> >
> >  #ifdef CONFIG_RADIX_TREE_MULTIORDER
> > if (radix_tree_is_internal_node(entry)) {
> > -   unsigned long siboff = get_slot_offset(parent, entry);
> > +   unsigned long siboff = get_slot_offset(parent,
> > +   (void 
> > **)entry_to_node(entry));
> 
> I feel that it is *this* part that I think needs a huge honking comment.
> 
> If you are going to make get_slot_offset() different, then you could
> just rewrite get_slot_offset() to do
> 
> unsigned long diff = (unsigned long) slot - (unsigned
> long)parent->slots;
> return diff / sizeof(void *);
> 
> and add a comment to say "don't do this as a pointer diff, because
> 'slot' may not be an aligned pointer". No BUG_ON() necessary, because
> it "just works".
> 
> At that point, gcc should just generate the right code, because it
> doesn't see it as a pointer subtraction followed by a pointer
> addition.
> 
> And yes, that crazy " (void **)entry_to_node(entry)" fixes it *too*,
> but it needs a *comment*.
> 
> Why is that special, when all the other uses of get_slot_offset()
> don't have that? *That* is what should be explained. Not some internal
> detail.
> 
> That said, if this code isn't even used, as Konstantin says (THP
> selects it - doesn't THP use it?), then the fix really should be to
> just remove the odd code instead of adding to it.
> 
> Looking around for uses that set "order" to anything but zero, I
> really don't see it. So maybe we should just do *that* trivial thing
> instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
> to be buggy and always has been.

Well, my ext4-with-huge-pages patchset[1] uses multi-order entries.
It also converts shmem-with-huge-pages and hugetlb to them.

I'm okay with converting it to other mechanism, but I need something.
(I looked into Konstantin's RFC patchset[2]. It looks okay, but I don't
feel myself qualified to review it as I don't know much about radix-tree
internals.)

[1] 
http://lkml.kernel.org/r/20160915115523.29737-1-kirill.shute...@linux.intel.com
[2] http://lkml.kernel.org/r/147230727479.9957.1087787722571077339.stgit@zurg

-- 
 Kirill A. Shutemov


Re: [PATCH V3 2/4] ARM64 LPC: LPC driver implementation on Hip06

2016-09-24 Thread Arnd Bergmann
On Saturday, September 24, 2016 4:14:15 PM CEST zhichang wrote:
> 
> In V3, the outb is :
> 
> void outb(u8 value, unsigned long addr)
> {
> if (!arm64_extio_ops || arm64_extio_ops->start > addr ||
> arm64_extio_ops->end < addr)
> writeb(value, PCI_IOBASE + addr);
> else
> if (arm64_extio_ops->pfout)
> arm64_extio_ops->pfout(arm64_extio_ops->devpara,
> addr + arm64_extio_ops->ptoffset, ,
> sizeof(u8), 1);
> }
> 
> here, arm64_extio_ops->ptoffset is the offset between the real legacy IO 
> address
> and the logical IO address, similar to the offset of primary address and
> secondary address in PCI bridge.

Ok, though we can probably simplify this by making the assumption that
'ptoffset' is the negative of 'start', as the bus we register should
always start at port zero.

> But in V3, LPC driver call pci_address_to_pio to request the logical IO as PCI
> host bridge during its probing.

Right, so this still needs to be fixed.

Arnd


Re: [PATCH V3 2/4] ARM64 LPC: LPC driver implementation on Hip06

2016-09-24 Thread Arnd Bergmann
On Saturday, September 24, 2016 4:14:15 PM CEST zhichang wrote:
> 
> In V3, the outb is :
> 
> void outb(u8 value, unsigned long addr)
> {
> if (!arm64_extio_ops || arm64_extio_ops->start > addr ||
> arm64_extio_ops->end < addr)
> writeb(value, PCI_IOBASE + addr);
> else
> if (arm64_extio_ops->pfout)
> arm64_extio_ops->pfout(arm64_extio_ops->devpara,
> addr + arm64_extio_ops->ptoffset, ,
> sizeof(u8), 1);
> }
> 
> here, arm64_extio_ops->ptoffset is the offset between the real legacy IO 
> address
> and the logical IO address, similar to the offset of primary address and
> secondary address in PCI bridge.

Ok, though we can probably simplify this by making the assumption that
'ptoffset' is the negative of 'start', as the bus we register should
always start at port zero.

> But in V3, LPC driver call pci_address_to_pio to request the logical IO as PCI
> host bridge during its probing.

Right, so this still needs to be fixed.

Arnd


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 1:21 PM, Linus Torvalds
 wrote:
>
> That said, if this code isn't even used, as Konstantin says (THP
> selects it - doesn't THP use it?), then the fix really should be to
> just remove the odd code instead of adding to it.
>
> Looking around for uses that set "order" to anything but zero, I
> really don't see it. So maybe we should just do *that* trivial thing
> instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
> to be buggy and always has been.

IOW, a patch something like this?

NOTE! This is entirely untested. Things still seem to compile with it,
at least with some configurations. That's all I can say.

I do like this part:

   11 files changed, 29 insertions(+), 518 deletions(-)

although admittedly 2/3rds of the deletions were for the multiorder
tests. But even if you ignore the test side, it's just fairly clean
removal of code that is apparently not used, and that was buggy.

   Linus
 include/linux/radix-tree.h|  48 +---
 lib/Kconfig   |   3 -
 lib/radix-tree.c  | 100 +---
 mm/Kconfig|   1 -
 mm/filemap.c  |   2 +-
 tools/testing/radix-tree/Makefile |   2 +-
 tools/testing/radix-tree/generated/autoconf.h |   1 -
 tools/testing/radix-tree/main.c   |  34 +--
 tools/testing/radix-tree/multiorder.c | 337 --
 tools/testing/radix-tree/test.c   |  14 +-
 tools/testing/radix-tree/test.h   |   5 -
 11 files changed, 29 insertions(+), 518 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 4c45105dece3..ac546baa604c 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -263,15 +263,9 @@ static inline void radix_tree_replace_slot(void **pslot, void *item)
 }
 
 int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
-			unsigned order, struct radix_tree_node **nodep,
+			struct radix_tree_node **nodep,
 			void ***slotp);
-int __radix_tree_insert(struct radix_tree_root *, unsigned long index,
-			unsigned order, void *);
-static inline int radix_tree_insert(struct radix_tree_root *root,
-			unsigned long index, void *entry)
-{
-	return __radix_tree_insert(root, index, 0, entry);
-}
+int radix_tree_insert(struct radix_tree_root *, unsigned long index, void *);
 void *__radix_tree_lookup(struct radix_tree_root *root, unsigned long index,
 			  struct radix_tree_node **nodep, void ***slotp);
 void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
@@ -338,20 +332,8 @@ struct radix_tree_iter {
 	unsigned long	index;
 	unsigned long	next_index;
 	unsigned long	tags;
-#ifdef CONFIG_RADIX_TREE_MULTIORDER
-	unsigned int	shift;
-#endif
 };
 
-static inline unsigned int iter_shift(struct radix_tree_iter *iter)
-{
-#ifdef CONFIG_RADIX_TREE_MULTIORDER
-	return iter->shift;
-#else
-	return 0;
-#endif
-}
-
 #define RADIX_TREE_ITER_TAG_MASK	0x00FF	/* tag index in lower byte */
 #define RADIX_TREE_ITER_TAGGED		0x0100	/* lookup tagged slots */
 #define RADIX_TREE_ITER_CONTIG		0x0200	/* stop at first hole */
@@ -415,7 +397,7 @@ void **radix_tree_iter_retry(struct radix_tree_iter *iter)
 static inline unsigned long
 __radix_tree_iter_add(struct radix_tree_iter *iter, unsigned long slots)
 {
-	return iter->index + (slots << iter_shift(iter));
+	return iter->index + slots;
 }
 
 /**
@@ -443,7 +425,7 @@ void **radix_tree_iter_next(struct radix_tree_iter *iter)
 static __always_inline long
 radix_tree_chunk_size(struct radix_tree_iter *iter)
 {
-	return (iter->next_index - iter->index) >> iter_shift(iter);
+	return iter->next_index - iter->index;
 }
 
 static inline struct radix_tree_node *entry_to_node(void *ptr)
@@ -466,22 +448,9 @@ static __always_inline void **
 radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 {
 	if (flags & RADIX_TREE_ITER_TAGGED) {
-		void *canon = slot;
-
 		iter->tags >>= 1;
 		if (unlikely(!iter->tags))
 			return NULL;
-		while (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
-	radix_tree_is_internal_node(slot[1])) {
-			if (entry_to_node(slot[1]) == canon) {
-iter->tags >>= 1;
-iter->index = __radix_tree_iter_add(iter, 1);
-slot++;
-continue;
-			}
-			iter->next_index = __radix_tree_iter_add(iter, 1);
-			return NULL;
-		}
 		if (likely(iter->tags & 1ul)) {
 			iter->index = __radix_tree_iter_add(iter, 1);
 			return slot + 1;
@@ -495,20 +464,11 @@ radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 		}
 	} else {
 		long count = radix_tree_chunk_size(iter);
-		void *canon = slot;
 
 		while (--count > 0) {
 			slot++;
 			iter->index = __radix_tree_iter_add(iter, 1);
 
-			if (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
-			radix_tree_is_internal_node(*slot)) {
-if (entry_to_node(*slot) == canon)
-	continue;
-

Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Sat, Sep 24, 2016 at 1:21 PM, Linus Torvalds
 wrote:
>
> That said, if this code isn't even used, as Konstantin says (THP
> selects it - doesn't THP use it?), then the fix really should be to
> just remove the odd code instead of adding to it.
>
> Looking around for uses that set "order" to anything but zero, I
> really don't see it. So maybe we should just do *that* trivial thing
> instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
> to be buggy and always has been.

IOW, a patch something like this?

NOTE! This is entirely untested. Things still seem to compile with it,
at least with some configurations. That's all I can say.

I do like this part:

   11 files changed, 29 insertions(+), 518 deletions(-)

although admittedly 2/3rds of the deletions were for the multiorder
tests. But even if you ignore the test side, it's just fairly clean
removal of code that is apparently not used, and that was buggy.

   Linus
 include/linux/radix-tree.h|  48 +---
 lib/Kconfig   |   3 -
 lib/radix-tree.c  | 100 +---
 mm/Kconfig|   1 -
 mm/filemap.c  |   2 +-
 tools/testing/radix-tree/Makefile |   2 +-
 tools/testing/radix-tree/generated/autoconf.h |   1 -
 tools/testing/radix-tree/main.c   |  34 +--
 tools/testing/radix-tree/multiorder.c | 337 --
 tools/testing/radix-tree/test.c   |  14 +-
 tools/testing/radix-tree/test.h   |   5 -
 11 files changed, 29 insertions(+), 518 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 4c45105dece3..ac546baa604c 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -263,15 +263,9 @@ static inline void radix_tree_replace_slot(void **pslot, void *item)
 }
 
 int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
-			unsigned order, struct radix_tree_node **nodep,
+			struct radix_tree_node **nodep,
 			void ***slotp);
-int __radix_tree_insert(struct radix_tree_root *, unsigned long index,
-			unsigned order, void *);
-static inline int radix_tree_insert(struct radix_tree_root *root,
-			unsigned long index, void *entry)
-{
-	return __radix_tree_insert(root, index, 0, entry);
-}
+int radix_tree_insert(struct radix_tree_root *, unsigned long index, void *);
 void *__radix_tree_lookup(struct radix_tree_root *root, unsigned long index,
 			  struct radix_tree_node **nodep, void ***slotp);
 void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
@@ -338,20 +332,8 @@ struct radix_tree_iter {
 	unsigned long	index;
 	unsigned long	next_index;
 	unsigned long	tags;
-#ifdef CONFIG_RADIX_TREE_MULTIORDER
-	unsigned int	shift;
-#endif
 };
 
-static inline unsigned int iter_shift(struct radix_tree_iter *iter)
-{
-#ifdef CONFIG_RADIX_TREE_MULTIORDER
-	return iter->shift;
-#else
-	return 0;
-#endif
-}
-
 #define RADIX_TREE_ITER_TAG_MASK	0x00FF	/* tag index in lower byte */
 #define RADIX_TREE_ITER_TAGGED		0x0100	/* lookup tagged slots */
 #define RADIX_TREE_ITER_CONTIG		0x0200	/* stop at first hole */
@@ -415,7 +397,7 @@ void **radix_tree_iter_retry(struct radix_tree_iter *iter)
 static inline unsigned long
 __radix_tree_iter_add(struct radix_tree_iter *iter, unsigned long slots)
 {
-	return iter->index + (slots << iter_shift(iter));
+	return iter->index + slots;
 }
 
 /**
@@ -443,7 +425,7 @@ void **radix_tree_iter_next(struct radix_tree_iter *iter)
 static __always_inline long
 radix_tree_chunk_size(struct radix_tree_iter *iter)
 {
-	return (iter->next_index - iter->index) >> iter_shift(iter);
+	return iter->next_index - iter->index;
 }
 
 static inline struct radix_tree_node *entry_to_node(void *ptr)
@@ -466,22 +448,9 @@ static __always_inline void **
 radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 {
 	if (flags & RADIX_TREE_ITER_TAGGED) {
-		void *canon = slot;
-
 		iter->tags >>= 1;
 		if (unlikely(!iter->tags))
 			return NULL;
-		while (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
-	radix_tree_is_internal_node(slot[1])) {
-			if (entry_to_node(slot[1]) == canon) {
-iter->tags >>= 1;
-iter->index = __radix_tree_iter_add(iter, 1);
-slot++;
-continue;
-			}
-			iter->next_index = __radix_tree_iter_add(iter, 1);
-			return NULL;
-		}
 		if (likely(iter->tags & 1ul)) {
 			iter->index = __radix_tree_iter_add(iter, 1);
 			return slot + 1;
@@ -495,20 +464,11 @@ radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 		}
 	} else {
 		long count = radix_tree_chunk_size(iter);
-		void *canon = slot;
 
 		while (--count > 0) {
 			slot++;
 			iter->index = __radix_tree_iter_add(iter, 1);
 
-			if (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
-			radix_tree_is_internal_node(*slot)) {
-if (entry_to_node(*slot) == canon)
-	continue;
-iter->next_index = iter->index;

[PATCH 1/2] brcmfmac: initialize fws(ignal) for BCDC protocol only

2016-09-24 Thread Rafał Miłecki
From: Rafał Miłecki 

There are two protocols used by Broadcom FullMAC devices: BCDC and
msgbuf. They use different ways for (some part of) communication with
the firmware. Firmware Signaling is required for the first one only
(BCDC).

So far we were always initializing fws and always calling it's skb
processing function. It was fws that was passing skb processing to the
protocol specific function. It was redundant for the msgbuf case.

Simply taking few lines of code out of fws allows us to totally avoid
using it. This simplifies code flow, saves some memory & will allow
further optimizations like not compiling fwsignal.c.

Signed-off-by: Rafał Miłecki 
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 24 --
 .../broadcom/brcm80211/brcmfmac/fwsignal.c | 17 ++-
 .../broadcom/brcm80211/brcmfmac/fwsignal.h |  1 +
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 27cd50a..bc3d8ab 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -250,7 +250,17 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff 
*skb,
if (eh->h_proto == htons(ETH_P_PAE))
atomic_inc(>pend_8021x_cnt);
 
-   ret = brcmf_fws_process_skb(ifp, skb);
+   /* determine the priority */
+   if (skb->priority == 0 || skb->priority > 7)
+   skb->priority = cfg80211_classify8021d(skb, NULL);
+
+   if (drvr->fws && brcmf_fws_skbs_queueing(drvr->fws)) {
+   ret = brcmf_fws_process_skb(ifp, skb);
+   } else {
+   ret = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb);
+   if (ret < 0)
+   brcmf_txfinalize(ifp, skb, false);
+   }
 
 done:
if (ret) {
@@ -405,7 +415,7 @@ void brcmf_txcomplete(struct device *dev, struct sk_buff 
*txp, bool success)
struct brcmf_if *ifp;
 
/* await txstatus signal for firmware if active */
-   if (brcmf_fws_fc_active(drvr->fws)) {
+   if (drvr->fws && brcmf_fws_fc_active(drvr->fws)) {
if (!success)
brcmf_fws_bustxfail(drvr->fws, txp);
} else {
@@ -1006,11 +1016,13 @@ int brcmf_bus_start(struct device *dev)
}
brcmf_feat_attach(drvr);
 
-   ret = brcmf_fws_init(drvr);
-   if (ret < 0)
-   goto fail;
+   if (bus_if->proto_type == BRCMF_PROTO_BCDC) {
+   ret = brcmf_fws_init(drvr);
+   if (ret < 0)
+   goto fail;
 
-   brcmf_fws_add_interface(ifp);
+   brcmf_fws_add_interface(ifp);
+   }
 
drvr->config = brcmf_cfg80211_attach(drvr, bus_if->dev,
 drvr->settings->p2p_enable);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
index a190f53..495eaf8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
@@ -2100,16 +2100,6 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct 
sk_buff *skb)
int rc = 0;
 
brcmf_dbg(DATA, "tx proto=0x%X\n", ntohs(eh->h_proto));
-   /* determine the priority */
-   if ((skb->priority == 0) || (skb->priority > 7))
-   skb->priority = cfg80211_classify8021d(skb, NULL);
-
-   if (fws->avoid_queueing) {
-   rc = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb);
-   if (rc < 0)
-   brcmf_txfinalize(ifp, skb, false);
-   return rc;
-   }
 
/* set control buffer information */
skcb->if_flags = 0;
@@ -2155,7 +2145,7 @@ void brcmf_fws_add_interface(struct brcmf_if *ifp)
struct brcmf_fws_info *fws = ifp->drvr->fws;
struct brcmf_fws_mac_descriptor *entry;
 
-   if (!ifp->ndev)
+   if (!fws || !ifp->ndev)
return;
 
entry = >desc.iface[ifp->ifidx];
@@ -2442,6 +2432,11 @@ void brcmf_fws_deinit(struct brcmf_pub *drvr)
kfree(fws);
 }
 
+bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws)
+{
+   return !fws->avoid_queueing;
+}
+
 bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
 {
if (!fws->creditmap_received)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
index ef0ad85..8f7c1d7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
@@ -20,6 +20,7 @@
 
 int brcmf_fws_init(struct brcmf_pub *drvr);
 void brcmf_fws_deinit(struct brcmf_pub *drvr);
+bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws);
 bool brcmf_fws_fc_active(struct 

[PATCH 2/2] brcmfmac: compile fws(ignal) code only with BCDC support enabled

2016-09-24 Thread Rafał Miłecki
From: Rafał Miłecki 

It's not needed by the other (msgbuf) protocol, so let's save some size
and compile it conditionally.

Signed-off-by: Rafał Miłecki 
---
 .../wireless/broadcom/brcm80211/brcmfmac/Makefile  |  4 +-
 .../broadcom/brcm80211/brcmfmac/fwsignal.h | 59 ++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
index 9e4b505..ad3b06e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
@@ -27,7 +27,6 @@ brcmfmac-objs += \
chip.o \
fwil.o \
fweh.o \
-   fwsignal.o \
p2p.o \
proto.o \
common.o \
@@ -37,7 +36,8 @@ brcmfmac-objs += \
btcoex.o \
vendor.o
 brcmfmac-$(CONFIG_BRCMFMAC_PROTO_BCDC) += \
-   bcdc.o
+   bcdc.o \
+   fwsignal.o
 brcmfmac-$(CONFIG_BRCMFMAC_PROTO_MSGBUF) += \
commonring.o \
flowring.o \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
index 8f7c1d7..ba0c1bc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
@@ -18,6 +18,7 @@
 #ifndef FWSIGNAL_H_
 #define FWSIGNAL_H_
 
+#ifdef CONFIG_BRCMFMAC_PROTO_BCDC
 int brcmf_fws_init(struct brcmf_pub *drvr);
 void brcmf_fws_deinit(struct brcmf_pub *drvr);
 bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws);
@@ -31,5 +32,63 @@ void brcmf_fws_del_interface(struct brcmf_if *ifp);
 void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb);
 void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked);
 void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb);
+#else
+static inline int brcmf_fws_init(struct brcmf_pub *drvr)
+{
+   return -ENOTSUPP;
+}
+
+static inline void brcmf_fws_deinit(struct brcmf_pub *drvr)
+{
+}
+
+static inline bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws)
+{
+   return false;
+}
+
+static inline bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
+{
+   return false;
+}
+
+static inline void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen,
+struct sk_buff *skb)
+{
+}
+
+static inline int brcmf_fws_process_skb(struct brcmf_if *ifp,
+   struct sk_buff *skb)
+{
+   return -ENOTSUPP;
+}
+
+static inline void brcmf_fws_reset_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_add_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_del_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_bustxfail(struct brcmf_fws_info *fws,
+  struct sk_buff *skb)
+{
+}
+
+static inline void brcmf_fws_bus_blocked(struct brcmf_pub *drvr,
+bool flow_blocked)
+{
+}
+
+static inline void brcmf_fws_rxreorder(struct brcmf_if *ifp,
+  struct sk_buff *skb)
+{
+}
+#endif
 
 #endif /* FWSIGNAL_H_ */
-- 
2.9.3



[PATCH 1/2] brcmfmac: initialize fws(ignal) for BCDC protocol only

2016-09-24 Thread Rafał Miłecki
From: Rafał Miłecki 

There are two protocols used by Broadcom FullMAC devices: BCDC and
msgbuf. They use different ways for (some part of) communication with
the firmware. Firmware Signaling is required for the first one only
(BCDC).

So far we were always initializing fws and always calling it's skb
processing function. It was fws that was passing skb processing to the
protocol specific function. It was redundant for the msgbuf case.

Simply taking few lines of code out of fws allows us to totally avoid
using it. This simplifies code flow, saves some memory & will allow
further optimizations like not compiling fwsignal.c.

Signed-off-by: Rafał Miłecki 
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 24 --
 .../broadcom/brcm80211/brcmfmac/fwsignal.c | 17 ++-
 .../broadcom/brcm80211/brcmfmac/fwsignal.h |  1 +
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 27cd50a..bc3d8ab 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -250,7 +250,17 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff 
*skb,
if (eh->h_proto == htons(ETH_P_PAE))
atomic_inc(>pend_8021x_cnt);
 
-   ret = brcmf_fws_process_skb(ifp, skb);
+   /* determine the priority */
+   if (skb->priority == 0 || skb->priority > 7)
+   skb->priority = cfg80211_classify8021d(skb, NULL);
+
+   if (drvr->fws && brcmf_fws_skbs_queueing(drvr->fws)) {
+   ret = brcmf_fws_process_skb(ifp, skb);
+   } else {
+   ret = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb);
+   if (ret < 0)
+   brcmf_txfinalize(ifp, skb, false);
+   }
 
 done:
if (ret) {
@@ -405,7 +415,7 @@ void brcmf_txcomplete(struct device *dev, struct sk_buff 
*txp, bool success)
struct brcmf_if *ifp;
 
/* await txstatus signal for firmware if active */
-   if (brcmf_fws_fc_active(drvr->fws)) {
+   if (drvr->fws && brcmf_fws_fc_active(drvr->fws)) {
if (!success)
brcmf_fws_bustxfail(drvr->fws, txp);
} else {
@@ -1006,11 +1016,13 @@ int brcmf_bus_start(struct device *dev)
}
brcmf_feat_attach(drvr);
 
-   ret = brcmf_fws_init(drvr);
-   if (ret < 0)
-   goto fail;
+   if (bus_if->proto_type == BRCMF_PROTO_BCDC) {
+   ret = brcmf_fws_init(drvr);
+   if (ret < 0)
+   goto fail;
 
-   brcmf_fws_add_interface(ifp);
+   brcmf_fws_add_interface(ifp);
+   }
 
drvr->config = brcmf_cfg80211_attach(drvr, bus_if->dev,
 drvr->settings->p2p_enable);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
index a190f53..495eaf8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
@@ -2100,16 +2100,6 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct 
sk_buff *skb)
int rc = 0;
 
brcmf_dbg(DATA, "tx proto=0x%X\n", ntohs(eh->h_proto));
-   /* determine the priority */
-   if ((skb->priority == 0) || (skb->priority > 7))
-   skb->priority = cfg80211_classify8021d(skb, NULL);
-
-   if (fws->avoid_queueing) {
-   rc = brcmf_proto_txdata(drvr, ifp->ifidx, 0, skb);
-   if (rc < 0)
-   brcmf_txfinalize(ifp, skb, false);
-   return rc;
-   }
 
/* set control buffer information */
skcb->if_flags = 0;
@@ -2155,7 +2145,7 @@ void brcmf_fws_add_interface(struct brcmf_if *ifp)
struct brcmf_fws_info *fws = ifp->drvr->fws;
struct brcmf_fws_mac_descriptor *entry;
 
-   if (!ifp->ndev)
+   if (!fws || !ifp->ndev)
return;
 
entry = >desc.iface[ifp->ifidx];
@@ -2442,6 +2432,11 @@ void brcmf_fws_deinit(struct brcmf_pub *drvr)
kfree(fws);
 }
 
+bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws)
+{
+   return !fws->avoid_queueing;
+}
+
 bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
 {
if (!fws->creditmap_received)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
index ef0ad85..8f7c1d7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
@@ -20,6 +20,7 @@
 
 int brcmf_fws_init(struct brcmf_pub *drvr);
 void brcmf_fws_deinit(struct brcmf_pub *drvr);
+bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws);
 bool brcmf_fws_fc_active(struct brcmf_fws_info *fws);
 void 

[PATCH 2/2] brcmfmac: compile fws(ignal) code only with BCDC support enabled

2016-09-24 Thread Rafał Miłecki
From: Rafał Miłecki 

It's not needed by the other (msgbuf) protocol, so let's save some size
and compile it conditionally.

Signed-off-by: Rafał Miłecki 
---
 .../wireless/broadcom/brcm80211/brcmfmac/Makefile  |  4 +-
 .../broadcom/brcm80211/brcmfmac/fwsignal.h | 59 ++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
index 9e4b505..ad3b06e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
@@ -27,7 +27,6 @@ brcmfmac-objs += \
chip.o \
fwil.o \
fweh.o \
-   fwsignal.o \
p2p.o \
proto.o \
common.o \
@@ -37,7 +36,8 @@ brcmfmac-objs += \
btcoex.o \
vendor.o
 brcmfmac-$(CONFIG_BRCMFMAC_PROTO_BCDC) += \
-   bcdc.o
+   bcdc.o \
+   fwsignal.o
 brcmfmac-$(CONFIG_BRCMFMAC_PROTO_MSGBUF) += \
commonring.o \
flowring.o \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
index 8f7c1d7..ba0c1bc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
@@ -18,6 +18,7 @@
 #ifndef FWSIGNAL_H_
 #define FWSIGNAL_H_
 
+#ifdef CONFIG_BRCMFMAC_PROTO_BCDC
 int brcmf_fws_init(struct brcmf_pub *drvr);
 void brcmf_fws_deinit(struct brcmf_pub *drvr);
 bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws);
@@ -31,5 +32,63 @@ void brcmf_fws_del_interface(struct brcmf_if *ifp);
 void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb);
 void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked);
 void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb);
+#else
+static inline int brcmf_fws_init(struct brcmf_pub *drvr)
+{
+   return -ENOTSUPP;
+}
+
+static inline void brcmf_fws_deinit(struct brcmf_pub *drvr)
+{
+}
+
+static inline bool brcmf_fws_skbs_queueing(struct brcmf_fws_info *fws)
+{
+   return false;
+}
+
+static inline bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
+{
+   return false;
+}
+
+static inline void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen,
+struct sk_buff *skb)
+{
+}
+
+static inline int brcmf_fws_process_skb(struct brcmf_if *ifp,
+   struct sk_buff *skb)
+{
+   return -ENOTSUPP;
+}
+
+static inline void brcmf_fws_reset_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_add_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_del_interface(struct brcmf_if *ifp)
+{
+}
+
+static inline void brcmf_fws_bustxfail(struct brcmf_fws_info *fws,
+  struct sk_buff *skb)
+{
+}
+
+static inline void brcmf_fws_bus_blocked(struct brcmf_pub *drvr,
+bool flow_blocked)
+{
+}
+
+static inline void brcmf_fws_rxreorder(struct brcmf_if *ifp,
+  struct sk_buff *skb)
+{
+}
+#endif
 
 #endif /* FWSIGNAL_H_ */
-- 
2.9.3



Re: [PATCH] realtek: Add switch variable to 'switch case not processed' messages

2016-09-24 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-09-24 at 14:06 -0500, Larry Finger wrote:
>> On 09/24/2016 12:32 PM, Joe Perches wrote:
> []
>> o Reindent all the switch/case blocks to a more normal
>>   kernel style (git diff -w would show no changes here)
>> That sounds like busy work to me, but if you want to do it, go ahead.
>
> It's really just to make the comparison case block reductions
> easier to verify for later steps done
>
>> > o cast, spacing and parenthesis reductions
>> >   Lots of odd and somewhat unique styles in various
>> >   drivers, looks like too many individual authors without
>> >   a style guide / code enforcer using slightly different
>> >   personalized code.  Glancing at the code, it looks to be
>> >   similar logic, just written in different styles.
>> Same comment.
>
> Same rationale
>
>> > o Logic changes like
>> >   from:
>> > if (foo) func(..., bar, ...); else func(..., baz, ...);
>> >   to:
>> > func(..., foo ? bar : baz, ...);
>> >   to make the case statement code blocks more consistent
>> >   and emit somewhat smaller object code.
>> I find if .. else constructs much easier to read than the cond ?  :  
>> form. I would reject any such patches.
>
>  I think object code reduction generally a good thing
> but then again, I'm not a maintainer here.

I missed this part, but I am with Larry here - 'foo ? bar : boo' are
just obfuscating the code and far less clear than if or switch
statements.

Jes


Re: [PATCH] realtek: Add switch variable to 'switch case not processed' messages

2016-09-24 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-09-24 at 14:06 -0500, Larry Finger wrote:
>> On 09/24/2016 12:32 PM, Joe Perches wrote:
> []
>> o Reindent all the switch/case blocks to a more normal
>>   kernel style (git diff -w would show no changes here)
>> That sounds like busy work to me, but if you want to do it, go ahead.
>
> It's really just to make the comparison case block reductions
> easier to verify for later steps done
>
>> > o cast, spacing and parenthesis reductions
>> >   Lots of odd and somewhat unique styles in various
>> >   drivers, looks like too many individual authors without
>> >   a style guide / code enforcer using slightly different
>> >   personalized code.  Glancing at the code, it looks to be
>> >   similar logic, just written in different styles.
>> Same comment.
>
> Same rationale
>
>> > o Logic changes like
>> >   from:
>> > if (foo) func(..., bar, ...); else func(..., baz, ...);
>> >   to:
>> > func(..., foo ? bar : baz, ...);
>> >   to make the case statement code blocks more consistent
>> >   and emit somewhat smaller object code.
>> I find if .. else constructs much easier to read than the cond ?  :  
>> form. I would reject any such patches.
>
>  I think object code reduction generally a good thing
> but then again, I'm not a maintainer here.

I missed this part, but I am with Larry here - 'foo ? bar : boo' are
just obfuscating the code and far less clear than if or switch
statements.

Jes


RE: [PATCH v6 1/9] rpmb: add Replay Protected Memory Block (RPMB) subsystem

2016-09-24 Thread Winkler, Tomas
> 
> 
> >
> > Signed-off-by: Tomas Winkler 
> > Signed-off-by: Alexander Usyskin 
> Tested-by: Avri Altman 
> 
> - mmc -  full functionality. One issue found that was fixed on V6: patch V6 
> 2/9.
> - ufs - read & read counter only.  Testing is still wip.
> 
> 
> > +static int rpmb_request_verify(struct rpmb_dev *rdev, struct rpmb_data
> > +*rpmbd) {
> 
> Seems excessive - Isn't the standard should be enforced by the device?

Yes the device is responsible to detect the issues in the protocol. The 
rpmb_request_verify is called only for the managed interface (rpmb_cmd_req) the 
raw interface (rpm_cmd_seq) is going through.  Second,  we only check more or 
less if we can accommodate the request/response into the arguments.  If there 
is a specific issue  you see in this check, please let me know.

Thanks
Tomas




RE: [PATCH v6 1/9] rpmb: add Replay Protected Memory Block (RPMB) subsystem

2016-09-24 Thread Winkler, Tomas
> 
> 
> >
> > Signed-off-by: Tomas Winkler 
> > Signed-off-by: Alexander Usyskin 
> Tested-by: Avri Altman 
> 
> - mmc -  full functionality. One issue found that was fixed on V6: patch V6 
> 2/9.
> - ufs - read & read counter only.  Testing is still wip.
> 
> 
> > +static int rpmb_request_verify(struct rpmb_dev *rdev, struct rpmb_data
> > +*rpmbd) {
> 
> Seems excessive - Isn't the standard should be enforced by the device?

Yes the device is responsible to detect the issues in the protocol. The 
rpmb_request_verify is called only for the managed interface (rpmb_cmd_req) the 
raw interface (rpm_cmd_seq) is going through.  Second,  we only check more or 
less if we can accommodate the request/response into the arguments.  If there 
is a specific issue  you see in this check, please let me know.

Thanks
Tomas




Re: [PATCH] realtek: Add switch variable to 'switch case not processed' messages

2016-09-24 Thread Joe Perches
On Sat, 2016-09-24 at 14:06 -0500, Larry Finger wrote:
> On 09/24/2016 12:32 PM, Joe Perches wrote:
[]
> o Reindent all the switch/case blocks to a more normal
>   kernel style (git diff -w would show no changes here)
> That sounds like busy work to me, but if you want to do it, go ahead.

It's really just to make the comparison case block reductions
easier to verify for later steps done

> > o cast, spacing and parenthesis reductions
> >   Lots of odd and somewhat unique styles in various
> >   drivers, looks like too many individual authors without
> >   a style guide / code enforcer using slightly different
> >   personalized code.  Glancing at the code, it looks to be
> >   similar logic, just written in different styles.
> Same comment.

Same rationale

> > o Logic changes like
> >   from:
> > if (foo) func(..., bar, ...); else func(..., baz, ...);
> >   to:
> > func(..., foo ? bar : baz, ...);
> >   to make the case statement code blocks more consistent
> >   and emit somewhat smaller object code.
> I find if .. else constructs much easier to read than the cond ?  :  
> form. I would reject any such patches.

 I think object code reduction generally a good thing
but then again, I'm not a maintainer here.

> > o Consolidation of equivalent function spanning drivers
> >   With the style only changes minimized, where possible
> >   make the drivers use common ops/callback functions.
> The is no question that there are similar routines in different drivers. I 
> would 
> like to place as much as possible into common routines, but I never seem to 
> find 
> the time. There are too many bugs in other things I support to consider these 
> niceties.

Consolidation generally reduces defects and improves ease of
updating.
> 


Re: [PATCH] realtek: Add switch variable to 'switch case not processed' messages

2016-09-24 Thread Joe Perches
On Sat, 2016-09-24 at 14:06 -0500, Larry Finger wrote:
> On 09/24/2016 12:32 PM, Joe Perches wrote:
[]
> o Reindent all the switch/case blocks to a more normal
>   kernel style (git diff -w would show no changes here)
> That sounds like busy work to me, but if you want to do it, go ahead.

It's really just to make the comparison case block reductions
easier to verify for later steps done

> > o cast, spacing and parenthesis reductions
> >   Lots of odd and somewhat unique styles in various
> >   drivers, looks like too many individual authors without
> >   a style guide / code enforcer using slightly different
> >   personalized code.  Glancing at the code, it looks to be
> >   similar logic, just written in different styles.
> Same comment.

Same rationale

> > o Logic changes like
> >   from:
> > if (foo) func(..., bar, ...); else func(..., baz, ...);
> >   to:
> > func(..., foo ? bar : baz, ...);
> >   to make the case statement code blocks more consistent
> >   and emit somewhat smaller object code.
> I find if .. else constructs much easier to read than the cond ?  :  
> form. I would reject any such patches.

 I think object code reduction generally a good thing
but then again, I'm not a maintainer here.

> > o Consolidation of equivalent function spanning drivers
> >   With the style only changes minimized, where possible
> >   make the drivers use common ops/callback functions.
> The is no question that there are similar routines in different drivers. I 
> would 
> like to place as much as possible into common routines, but I never seem to 
> find 
> the time. There are too many bugs in other things I support to consider these 
> niceties.

Consolidation generally reduces defects and improves ease of
updating.
> 


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Fri, Sep 23, 2016 at 1:16 PM, Matthew Wilcox  wrote:
>
>  #ifdef CONFIG_RADIX_TREE_MULTIORDER
> if (radix_tree_is_internal_node(entry)) {
> -   unsigned long siboff = get_slot_offset(parent, entry);
> +   unsigned long siboff = get_slot_offset(parent,
> +   (void 
> **)entry_to_node(entry));

I feel that it is *this* part that I think needs a huge honking comment.

If you are going to make get_slot_offset() different, then you could
just rewrite get_slot_offset() to do

unsigned long diff = (unsigned long) slot - (unsigned
long)parent->slots;
return diff / sizeof(void *);

and add a comment to say "don't do this as a pointer diff, because
'slot' may not be an aligned pointer". No BUG_ON() necessary, because
it "just works".

At that point, gcc should just generate the right code, because it
doesn't see it as a pointer subtraction followed by a pointer
addition.

And yes, that crazy " (void **)entry_to_node(entry)" fixes it *too*,
but it needs a *comment*.

Why is that special, when all the other uses of get_slot_offset()
don't have that? *That* is what should be explained. Not some internal
detail.

That said, if this code isn't even used, as Konstantin says (THP
selects it - doesn't THP use it?), then the fix really should be to
just remove the odd code instead of adding to it.

Looking around for uses that set "order" to anything but zero, I
really don't see it. So maybe we should just do *that* trivial thing
instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
to be buggy and always has been.

  Linus


Re: [PATCH 2/2] radix-tree: Fix optimisation problem

2016-09-24 Thread Linus Torvalds
On Fri, Sep 23, 2016 at 1:16 PM, Matthew Wilcox  wrote:
>
>  #ifdef CONFIG_RADIX_TREE_MULTIORDER
> if (radix_tree_is_internal_node(entry)) {
> -   unsigned long siboff = get_slot_offset(parent, entry);
> +   unsigned long siboff = get_slot_offset(parent,
> +   (void 
> **)entry_to_node(entry));

I feel that it is *this* part that I think needs a huge honking comment.

If you are going to make get_slot_offset() different, then you could
just rewrite get_slot_offset() to do

unsigned long diff = (unsigned long) slot - (unsigned
long)parent->slots;
return diff / sizeof(void *);

and add a comment to say "don't do this as a pointer diff, because
'slot' may not be an aligned pointer". No BUG_ON() necessary, because
it "just works".

At that point, gcc should just generate the right code, because it
doesn't see it as a pointer subtraction followed by a pointer
addition.

And yes, that crazy " (void **)entry_to_node(entry)" fixes it *too*,
but it needs a *comment*.

Why is that special, when all the other uses of get_slot_offset()
don't have that? *That* is what should be explained. Not some internal
detail.

That said, if this code isn't even used, as Konstantin says (THP
selects it - doesn't THP use it?), then the fix really should be to
just remove the odd code instead of adding to it.

Looking around for uses that set "order" to anything but zero, I
really don't see it. So maybe we should just do *that* trivial thing
instead, and remove CONFIG_RADIX_TREE_MULTIORDER, since it's appears
to be buggy and always has been.

  Linus


  1   2   3   4   5   >