Re: [PATCH 1/1] xen: xenbus: set error code on failure

2016-12-04 Thread Pan Bian
From: PanBian 

On Mon, Dec 05, 2016 at 07:30:49AM +0100, Juergen Gross wrote:
> On 03/12/16 11:49, Pan Bian wrote:
> > In function xenstored_local_init(), the value of return variable err
> > should be negative on errors. But the value of err keeps 0 even if the 
> > call to get_zeroed_page() returns a NULL pointer. This patch assigns 
> > "-ENOMEM" to err on the error branch.
> > 
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188721
> > 
> > Signed-off-by: Pan Bian 
> > ---
> >  drivers/xen/xenbus/xenbus_probe.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/xen/xenbus/xenbus_probe.c 
> > b/drivers/xen/xenbus/xenbus_probe.c
> > index 33a31cf..f87d047 100644
> > --- a/drivers/xen/xenbus/xenbus_probe.c
> > +++ b/drivers/xen/xenbus/xenbus_probe.c
> > @@ -708,8 +708,10 @@ static int __init xenstored_local_init(void)
> >  
> > /* Allocate Xenstore page */
> > page = get_zeroed_page(GFP_KERNEL);
> > -   if (!page)
> > +   if (!page) {
> > +   err = -ENOMEM;
> > goto out_err;
> > +   }
> >  
> > xen_store_gfn = xen_start_info->store_mfn = virt_to_gfn((void *)page);
> 
> Why don't you preset err to -ENOMEM instead? Initializing it to 0
> is kind of pointless.

  I think presetting and setting on demand are both effective to fix
  this bug. Nevertheless, I will resubmit a second version if you
  insist.

> 
> Ans while at it: preinitializing page isn't needed, too, and in the
> error path testing page for being non-zero isn't neede either
> (free_page() will do the right thing in case the parameter is 0).
> 
> 
> Juergen
> 

Thanks!

Best regards,
Pan



Re: [PATCH 1/1] xen: xenbus: set error code on failure

2016-12-04 Thread Pan Bian
From: PanBian 

On Mon, Dec 05, 2016 at 07:30:49AM +0100, Juergen Gross wrote:
> On 03/12/16 11:49, Pan Bian wrote:
> > In function xenstored_local_init(), the value of return variable err
> > should be negative on errors. But the value of err keeps 0 even if the 
> > call to get_zeroed_page() returns a NULL pointer. This patch assigns 
> > "-ENOMEM" to err on the error branch.
> > 
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188721
> > 
> > Signed-off-by: Pan Bian 
> > ---
> >  drivers/xen/xenbus/xenbus_probe.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/xen/xenbus/xenbus_probe.c 
> > b/drivers/xen/xenbus/xenbus_probe.c
> > index 33a31cf..f87d047 100644
> > --- a/drivers/xen/xenbus/xenbus_probe.c
> > +++ b/drivers/xen/xenbus/xenbus_probe.c
> > @@ -708,8 +708,10 @@ static int __init xenstored_local_init(void)
> >  
> > /* Allocate Xenstore page */
> > page = get_zeroed_page(GFP_KERNEL);
> > -   if (!page)
> > +   if (!page) {
> > +   err = -ENOMEM;
> > goto out_err;
> > +   }
> >  
> > xen_store_gfn = xen_start_info->store_mfn = virt_to_gfn((void *)page);
> 
> Why don't you preset err to -ENOMEM instead? Initializing it to 0
> is kind of pointless.

  I think presetting and setting on demand are both effective to fix
  this bug. Nevertheless, I will resubmit a second version if you
  insist.

> 
> Ans while at it: preinitializing page isn't needed, too, and in the
> error path testing page for being non-zero isn't neede either
> (free_page() will do the right thing in case the parameter is 0).
> 
> 
> Juergen
> 

Thanks!

Best regards,
Pan



Re: [PATCH V1] rtc: ds1307: Add ACPI support

2016-12-04 Thread Tin Huynh
On Wed, Nov 30, 2016 at 9:57 AM, Tin Huynh  wrote:
>
> This patch enables ACPI support for rtc-ds1307 driver.
>
> Signed-off-by: Tin Huynh 
> ---
>  drivers/rtc/rtc-ds1307.c |   51 ++---
>  1 files changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 4e31036..2a1a4d3 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -11,6 +11,7 @@
>   * published by the Free Software Foundation.
>   */
>
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -191,6 +192,26 @@ static u8 do_trickle_setup_ds1339(struct i2c_client *,
>  };
>  MODULE_DEVICE_TABLE(i2c, ds1307_id);
>
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id ds1307_acpi_ids[] = {
> +   { .id = "DS1307", .driver_data = ds_1307 },
> +   { .id = "DS1337", .driver_data = ds_1337 },
> +   { .id = "DS1338", .driver_data = ds_1338 },
> +   { .id = "DS1339", .driver_data = ds_1339 },
> +   { .id = "DS1388", .driver_data = ds_1388 },
> +   { .id = "DS1340", .driver_data = ds_1340 },
> +   { .id = "DS3231", .driver_data = ds_3231 },
> +   { .id = "M41T00", .driver_data = m41t00 },
> +   { .id = "MCP7940X", .driver_data = mcp794xx },
> +   { .id = "MCP7941X", .driver_data = mcp794xx },
> +   { .id = "PT7C4338", .driver_data = ds_1307 },
> +   { .id = "RX8025", .driver_data = rx_8025 },
> +   { .id = "ISL12057", .driver_data = ds_1337 },
> +   { }
> +};
> +MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids);
> +#endif
> +
>  /*--*/
>
>  #define BLOCK_DATA_MAX_TRIES 10
> @@ -874,7 +895,7 @@ static u8 do_trickle_setup_ds1339(struct i2c_client 
> *client,
> return setup;
>  }
>
> -static void ds1307_trickle_of_init(struct i2c_client *client,
> +static void ds1307_trickle_init(struct i2c_client *client,
>struct chip_desc *chip)
>  {
> uint32_t ohms = 0;
> @@ -882,9 +903,10 @@ static void ds1307_trickle_of_init(struct i2c_client 
> *client,
>
> if (!chip->do_trickle_setup)
> goto out;
> -   if (of_property_read_u32(client->dev.of_node, "trickle-resistor-ohms" 
> , ))
> +   if (device_property_read_u32(>dev, "trickle-resistor-ohms",
> +   ))
> goto out;
> -   if (of_property_read_bool(client->dev.of_node, 
> "trickle-diode-disable"))
> +   if (device_property_read_bool(>dev, "trickle-diode-disable"))
> diode = false;
> chip->trickle_charger_setup = chip->do_trickle_setup(client,
>  ohms, diode);
> @@ -1268,7 +1290,7 @@ static int ds1307_probe(struct i2c_client *client,
> struct ds1307   *ds1307;
> int err = -ENODEV;
> int tmp, wday;
> -   struct chip_desc*chip = [id->driver_data];
> +   struct chip_desc*chip;
> struct i2c_adapter  *adapter = to_i2c_adapter(client->dev.parent);
> boolwant_irq = false;
> boolds1307_can_wakeup_device = false;
> @@ -1297,11 +1319,23 @@ static int ds1307_probe(struct i2c_client *client,
> i2c_set_clientdata(client, ds1307);
>
> ds1307->client  = client;
> -   ds1307->type= id->driver_data;
> +   if (id) {
> +   chip = [id->driver_data];
> +   ds1307->type = id->driver_data;
> +   } else {
> +   const struct acpi_device_id *acpi_id;
> +
> +   acpi_id = acpi_match_device(ACPI_PTR(ds1307_acpi_ids),
> +   >dev);
> +   if (!acpi_id)
> +   return -ENODEV;
> +   chip = [acpi_id->driver_data];
> +   ds1307->type = acpi_id->driver_data;
> +   }
>
> -   if (!pdata && client->dev.of_node)
> -   ds1307_trickle_of_init(client, chip);
> -   else if (pdata && pdata->trickle_charger_setup)
> +   if (!pdata)
> +   ds1307_trickle_init(client, chip);
> +   else if (pdata->trickle_charger_setup)
> chip->trickle_charger_setup = pdata->trickle_charger_setup;
>
> if (chip->trickle_charger_setup && chip->trickle_charger_reg) {
> @@ -1678,6 +1712,7 @@ static int ds1307_remove(struct i2c_client *client)
>  static struct i2c_driver ds1307_driver = {
> .driver = {
> .name   = "rtc-ds1307",
> +   .acpi_match_table = ACPI_PTR(ds1307_acpi_ids),
> },
> .probe  = ds1307_probe,
> .remove = ds1307_remove,
> --
> 1.7.1
>

Hi ,
Any update for this patch ?
Thank you ,
Tin


Re: [PATCH V1] rtc: ds1307: Add ACPI support

2016-12-04 Thread Tin Huynh
On Wed, Nov 30, 2016 at 9:57 AM, Tin Huynh  wrote:
>
> This patch enables ACPI support for rtc-ds1307 driver.
>
> Signed-off-by: Tin Huynh 
> ---
>  drivers/rtc/rtc-ds1307.c |   51 ++---
>  1 files changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 4e31036..2a1a4d3 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -11,6 +11,7 @@
>   * published by the Free Software Foundation.
>   */
>
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -191,6 +192,26 @@ static u8 do_trickle_setup_ds1339(struct i2c_client *,
>  };
>  MODULE_DEVICE_TABLE(i2c, ds1307_id);
>
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id ds1307_acpi_ids[] = {
> +   { .id = "DS1307", .driver_data = ds_1307 },
> +   { .id = "DS1337", .driver_data = ds_1337 },
> +   { .id = "DS1338", .driver_data = ds_1338 },
> +   { .id = "DS1339", .driver_data = ds_1339 },
> +   { .id = "DS1388", .driver_data = ds_1388 },
> +   { .id = "DS1340", .driver_data = ds_1340 },
> +   { .id = "DS3231", .driver_data = ds_3231 },
> +   { .id = "M41T00", .driver_data = m41t00 },
> +   { .id = "MCP7940X", .driver_data = mcp794xx },
> +   { .id = "MCP7941X", .driver_data = mcp794xx },
> +   { .id = "PT7C4338", .driver_data = ds_1307 },
> +   { .id = "RX8025", .driver_data = rx_8025 },
> +   { .id = "ISL12057", .driver_data = ds_1337 },
> +   { }
> +};
> +MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids);
> +#endif
> +
>  /*--*/
>
>  #define BLOCK_DATA_MAX_TRIES 10
> @@ -874,7 +895,7 @@ static u8 do_trickle_setup_ds1339(struct i2c_client 
> *client,
> return setup;
>  }
>
> -static void ds1307_trickle_of_init(struct i2c_client *client,
> +static void ds1307_trickle_init(struct i2c_client *client,
>struct chip_desc *chip)
>  {
> uint32_t ohms = 0;
> @@ -882,9 +903,10 @@ static void ds1307_trickle_of_init(struct i2c_client 
> *client,
>
> if (!chip->do_trickle_setup)
> goto out;
> -   if (of_property_read_u32(client->dev.of_node, "trickle-resistor-ohms" 
> , ))
> +   if (device_property_read_u32(>dev, "trickle-resistor-ohms",
> +   ))
> goto out;
> -   if (of_property_read_bool(client->dev.of_node, 
> "trickle-diode-disable"))
> +   if (device_property_read_bool(>dev, "trickle-diode-disable"))
> diode = false;
> chip->trickle_charger_setup = chip->do_trickle_setup(client,
>  ohms, diode);
> @@ -1268,7 +1290,7 @@ static int ds1307_probe(struct i2c_client *client,
> struct ds1307   *ds1307;
> int err = -ENODEV;
> int tmp, wday;
> -   struct chip_desc*chip = [id->driver_data];
> +   struct chip_desc*chip;
> struct i2c_adapter  *adapter = to_i2c_adapter(client->dev.parent);
> boolwant_irq = false;
> boolds1307_can_wakeup_device = false;
> @@ -1297,11 +1319,23 @@ static int ds1307_probe(struct i2c_client *client,
> i2c_set_clientdata(client, ds1307);
>
> ds1307->client  = client;
> -   ds1307->type= id->driver_data;
> +   if (id) {
> +   chip = [id->driver_data];
> +   ds1307->type = id->driver_data;
> +   } else {
> +   const struct acpi_device_id *acpi_id;
> +
> +   acpi_id = acpi_match_device(ACPI_PTR(ds1307_acpi_ids),
> +   >dev);
> +   if (!acpi_id)
> +   return -ENODEV;
> +   chip = [acpi_id->driver_data];
> +   ds1307->type = acpi_id->driver_data;
> +   }
>
> -   if (!pdata && client->dev.of_node)
> -   ds1307_trickle_of_init(client, chip);
> -   else if (pdata && pdata->trickle_charger_setup)
> +   if (!pdata)
> +   ds1307_trickle_init(client, chip);
> +   else if (pdata->trickle_charger_setup)
> chip->trickle_charger_setup = pdata->trickle_charger_setup;
>
> if (chip->trickle_charger_setup && chip->trickle_charger_reg) {
> @@ -1678,6 +1712,7 @@ static int ds1307_remove(struct i2c_client *client)
>  static struct i2c_driver ds1307_driver = {
> .driver = {
> .name   = "rtc-ds1307",
> +   .acpi_match_table = ACPI_PTR(ds1307_acpi_ids),
> },
> .probe  = ds1307_probe,
> .remove = ds1307_remove,
> --
> 1.7.1
>

Hi ,
Any update for this patch ?
Thank you ,
Tin


[PATCH v6 1/2] mtd: arasan: Add device tree binding documentation

2016-12-04 Thread Punnaiah Choudary Kalluri
This patch adds the dts binding document for arasan nand flash
controller.

Signed-off-by: Punnaiah Choudary Kalluri 
Acked-by: Rob Herring 
---
changes in v6:
- Removed num-cs property
- Separated nandchip from nand controller
changes in v5:
- None
Changes in v4:
- Added num-cs property
- Added clock support
Changes in v3:
- None
Changes in v2:
- None
---
 .../devicetree/bindings/mtd/arasan_nfc.txt | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/arasan_nfc.txt

diff --git a/Documentation/devicetree/bindings/mtd/arasan_nfc.txt 
b/Documentation/devicetree/bindings/mtd/arasan_nfc.txt
new file mode 100644
index 000..dcbe7ad
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/arasan_nfc.txt
@@ -0,0 +1,38 @@
+Arasan Nand Flash Controller with ONFI 3.1 support
+
+Required properties:
+- compatible: Should be "arasan,nfc-v3p10"
+- reg: Memory map for module access
+- interrupt-parent: Interrupt controller the interrupt is routed through
+- interrupts: Should contain the interrupt for the device
+- clock-name: List of input clocks - "clk_sys", "clk_flash"
+ (See clock bindings for details)
+- clocks: Clock phandles (see clock bindings for details)
+
+Optional properties:
+- arasan,has-mdma: Enables Dma support
+
+for nand partition information please refer the below file
+Documentation/devicetree/bindings/mtd/partition.txt
+
+Example:
+   nand0: nand@ff10 {
+   compatible = "arasan,nfc-v3p10"
+   reg = <0x0 0xff10 0x1000>;
+   clock-name = "clk_sys", "clk_flash"
+   clocks = <_clk _clk>;
+   interrupt-parent = <>;
+   interrupts = <0 14 4>;
+   arasan,has-mdma;
+   #address-cells = <1>;
+   #size-cells = <0>
+
+   nand@0 {
+   reg = <0>
+   partition@0 {
+   label = "filesystem";
+   reg = <0x0 0x0 0x100>;
+   };
+   (...)
+   };
+   };
-- 
2.7.4



[PATCH v6 1/2] mtd: arasan: Add device tree binding documentation

2016-12-04 Thread Punnaiah Choudary Kalluri
This patch adds the dts binding document for arasan nand flash
controller.

Signed-off-by: Punnaiah Choudary Kalluri 
Acked-by: Rob Herring 
---
changes in v6:
- Removed num-cs property
- Separated nandchip from nand controller
changes in v5:
- None
Changes in v4:
- Added num-cs property
- Added clock support
Changes in v3:
- None
Changes in v2:
- None
---
 .../devicetree/bindings/mtd/arasan_nfc.txt | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/arasan_nfc.txt

diff --git a/Documentation/devicetree/bindings/mtd/arasan_nfc.txt 
b/Documentation/devicetree/bindings/mtd/arasan_nfc.txt
new file mode 100644
index 000..dcbe7ad
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/arasan_nfc.txt
@@ -0,0 +1,38 @@
+Arasan Nand Flash Controller with ONFI 3.1 support
+
+Required properties:
+- compatible: Should be "arasan,nfc-v3p10"
+- reg: Memory map for module access
+- interrupt-parent: Interrupt controller the interrupt is routed through
+- interrupts: Should contain the interrupt for the device
+- clock-name: List of input clocks - "clk_sys", "clk_flash"
+ (See clock bindings for details)
+- clocks: Clock phandles (see clock bindings for details)
+
+Optional properties:
+- arasan,has-mdma: Enables Dma support
+
+for nand partition information please refer the below file
+Documentation/devicetree/bindings/mtd/partition.txt
+
+Example:
+   nand0: nand@ff10 {
+   compatible = "arasan,nfc-v3p10"
+   reg = <0x0 0xff10 0x1000>;
+   clock-name = "clk_sys", "clk_flash"
+   clocks = <_clk _clk>;
+   interrupt-parent = <>;
+   interrupts = <0 14 4>;
+   arasan,has-mdma;
+   #address-cells = <1>;
+   #size-cells = <0>
+
+   nand@0 {
+   reg = <0>
+   partition@0 {
+   label = "filesystem";
+   reg = <0x0 0x0 0x100>;
+   };
+   (...)
+   };
+   };
-- 
2.7.4



Re: [PATCH] drm/radeon: don't add files at control minor debugfs directory

2016-12-04 Thread Christian König

Am 05.12.2016 um 08:27 schrieb Daniel Vetter:

On Sat, Dec 03, 2016 at 03:47:00PM +0100, Nicolai Stange wrote:

Since commit 8a357d10043c ("drm: Nerf DRM_CONTROL nodes"), a
struct drm_device's ->control member is always NULL.

In the case of CONFIG_DEBUG_FS=y, radeon_debugfs_add_files() accesses
->control->debugfs_root though. This results in the following Oops:

   BUG: unable to handle kernel NULL pointer dereference at 0018
   IP: radeon_debugfs_add_files+0x90/0x100 [radeon]
   PGD 0
   Oops:  [#1] SMP
   [...]
   Call Trace:
? work_on_cpu+0xb0/0xb0
radeon_fence_driver_init+0x120/0x150 [radeon]
si_init+0x122/0xd50 [radeon]
? _raw_spin_unlock_irq+0x2c/0x40
? device_pm_check_callbacks+0xb3/0xc0
radeon_device_init+0x958/0xda0 [radeon]
radeon_driver_load_kms+0x9a/0x210 [radeon]
drm_dev_register+0xa9/0xd0 [drm]
drm_get_pci_dev+0x9c/0x1e0 [drm]
radeon_pci_probe+0xb8/0xe0 [radeon]
   [...]

Fix this by omitting the drm_debugfs_create_files() call for the
control minor debugfs directory which is now non-existent anyway.

Fixes: 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
Signed-off-by: Nicolai Stange 

Applied to drm-misc with Dave's irc ack, thanks for your patch.


If it's still worth it the patch is Reviewed-by: Christian König 
.


On the other hand when ->control is always NULL, why do we still have 
->control anyway?


And BTW: Please double check the other drivers as well.

Regards,
Christian.


-Daniel


---
Tested on top of next-20161202.
That 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
is in next since 20161201.

  drivers/gpu/drm/radeon/radeon_device.c | 6 --
  1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index 60a8920..8a1df2a 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1949,9 +1949,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
rdev->debugfs_count = i;
  #if defined(CONFIG_DEBUG_FS)
drm_debugfs_create_files(files, nfiles,
-rdev->ddev->control->debugfs_root,
-rdev->ddev->control);
-   drm_debugfs_create_files(files, nfiles,
 rdev->ddev->primary->debugfs_root,
 rdev->ddev->primary);
  #endif
@@ -1966,9 +1963,6 @@ static void radeon_debugfs_remove_files(struct 
radeon_device *rdev)
for (i = 0; i < rdev->debugfs_count; i++) {
drm_debugfs_remove_files(rdev->debugfs[i].files,
 rdev->debugfs[i].num_files,
-rdev->ddev->control);
-   drm_debugfs_remove_files(rdev->debugfs[i].files,
-rdev->debugfs[i].num_files,
 rdev->ddev->primary);
}
  #endif
--
2.10.2

___
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel





Re: [PATCH] drm/radeon: don't add files at control minor debugfs directory

2016-12-04 Thread Christian König

Am 05.12.2016 um 08:27 schrieb Daniel Vetter:

On Sat, Dec 03, 2016 at 03:47:00PM +0100, Nicolai Stange wrote:

Since commit 8a357d10043c ("drm: Nerf DRM_CONTROL nodes"), a
struct drm_device's ->control member is always NULL.

In the case of CONFIG_DEBUG_FS=y, radeon_debugfs_add_files() accesses
->control->debugfs_root though. This results in the following Oops:

   BUG: unable to handle kernel NULL pointer dereference at 0018
   IP: radeon_debugfs_add_files+0x90/0x100 [radeon]
   PGD 0
   Oops:  [#1] SMP
   [...]
   Call Trace:
? work_on_cpu+0xb0/0xb0
radeon_fence_driver_init+0x120/0x150 [radeon]
si_init+0x122/0xd50 [radeon]
? _raw_spin_unlock_irq+0x2c/0x40
? device_pm_check_callbacks+0xb3/0xc0
radeon_device_init+0x958/0xda0 [radeon]
radeon_driver_load_kms+0x9a/0x210 [radeon]
drm_dev_register+0xa9/0xd0 [drm]
drm_get_pci_dev+0x9c/0x1e0 [drm]
radeon_pci_probe+0xb8/0xe0 [radeon]
   [...]

Fix this by omitting the drm_debugfs_create_files() call for the
control minor debugfs directory which is now non-existent anyway.

Fixes: 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
Signed-off-by: Nicolai Stange 

Applied to drm-misc with Dave's irc ack, thanks for your patch.


If it's still worth it the patch is Reviewed-by: Christian König 
.


On the other hand when ->control is always NULL, why do we still have 
->control anyway?


And BTW: Please double check the other drivers as well.

Regards,
Christian.


-Daniel


---
Tested on top of next-20161202.
That 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
is in next since 20161201.

  drivers/gpu/drm/radeon/radeon_device.c | 6 --
  1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index 60a8920..8a1df2a 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1949,9 +1949,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
rdev->debugfs_count = i;
  #if defined(CONFIG_DEBUG_FS)
drm_debugfs_create_files(files, nfiles,
-rdev->ddev->control->debugfs_root,
-rdev->ddev->control);
-   drm_debugfs_create_files(files, nfiles,
 rdev->ddev->primary->debugfs_root,
 rdev->ddev->primary);
  #endif
@@ -1966,9 +1963,6 @@ static void radeon_debugfs_remove_files(struct 
radeon_device *rdev)
for (i = 0; i < rdev->debugfs_count; i++) {
drm_debugfs_remove_files(rdev->debugfs[i].files,
 rdev->debugfs[i].num_files,
-rdev->ddev->control);
-   drm_debugfs_remove_files(rdev->debugfs[i].files,
-rdev->debugfs[i].num_files,
 rdev->ddev->primary);
}
  #endif
--
2.10.2

___
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel





[PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread Zhao Qiang
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
Changes for v7:
- split qeic part to another patch
- rebase
Changes for v8:
- include  in ucc_uart
Changes for v9:
- fix cast warning

 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  | 74 ---
 drivers/tty/serial/Kconfig |  2 +-
 drivers/tty/serial/ucc_uart.c  |  1 +
 drivers/usb/gadget/udc/Kconfig |  2 +-
 drivers/usb/host/Kconfig   |  2 +-
 include/soc/fsl/qe/qe.h|  1 -
 12 files changed, 123 insertions(+), 111 deletions(-)

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index d1ca45f..6677aff 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -5,10 +5,10 @@
 config NET_VENDOR_FREESCALE
bool "Freescale devices"
default y
-   depends on FSL_SOC || QUICC_ENGINE || CPM1 || CPM2 || PPC_MPC512x || \
-  M523x || M527x || M5272 || M528x || M520x || M532x || \
-  ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM) || \
-  ARCH_LAYERSCAPE
+   depends on FSL_SOC || (QUICC_ENGINE && PPC32) || CPM1 || CPM2 || \
+  PPC_MPC512x || M523x || M527x || M5272 || M528x || M520x || \
+  M532x || ARCH_MXC || ARCH_MXS || \
+  (PPC_MPC52xx && PPC_BESTCOMM) || ARCH_LAYERSCAPE
---help---
  If you have a network (Ethernet) card belonging to this class, say Y.
 
@@ -72,7 +72,7 @@ config FSL_XGMAC_MDIO
 
 config UCC_GETH
tristate "Freescale QE Gigabit Ethernet"
-   depends on QUICC_ENGINE
+   depends on QUICC_ENGINE && FSL_SOC && PPC32
select FSL_PQ_MDIO
select PHYLIB
---help---
diff --git a/drivers/soc/fsl/qe/Kconfig b/drivers/soc/fsl/qe/Kconfig
index 73a2e08..b26b643 100644
--- a/drivers/soc/fsl/qe/Kconfig
+++ b/drivers/soc/fsl/qe/Kconfig
@@ -4,7 +4,7 @@
 
 config QUICC_ENGINE
bool "Freescale QUICC Engine (QE) Support"
-   depends on FSL_SOC && PPC32
+   depends on OF && HAS_IOMEM
select GENERIC_ALLOCATOR
select CRC32
help
diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index 2707a82..2b53e85 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -33,8 +33,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 static void qe_snums_init(void);
 static int qe_sdma_init(void);
@@ -109,15 +107,27 @@ void qe_reset(void)
panic("sdma init failed!");
 }
 
+/* issue commands to QE, return 0 on success while -EIO on error
+ *
+ * @cmd: the command code, should be QE_INIT_TX_RX, QE_STOP_TX and so on
+ * @device: which sub-block will run the command, QE_CR_SUBBLOCK_UCCFAST1 - 8
+ * , QE_CR_SUBBLOCK_UCCSLOW1 - 8, QE_CR_SUBBLOCK_MCC1 - 3,
+ * QE_CR_SUBBLOCK_IDMA1 - 4 and such on.
+ * @mcn_protocol: specifies mode for the command for non-MCC, should be
+ * QE_CR_PROTOCOL_HDLC_TRANSPARENT, QE_CR_PROTOCOL_QMC, QE_CR_PROTOCOL_UART
+ * and such on.
+ * @cmd_input: command related data.
+ */
 int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
 {
unsigned long flags;
u8 mcn_shift = 0, dev_shift = 0;
-   u32 ret;
+   int ret;
+   int i;
 
spin_lock_irqsave(_lock, flags);
if (cmd == QE_RESET) {
-   out_be32(_immr->cp.cecr, (u32) (cmd | QE_CR_FLG));
+   iowrite32be((cmd | QE_CR_FLG), _immr->cp.cecr);
} else {
if (cmd == QE_ASSIGN_PAGE) {
/* Here device is the SNUM, not sub-block */
@@ -134,20 +144,26 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, 
u32 cmd_input)
mcn_shift = QE_CR_MCN_NORMAL_SHIFT;
}
 
-   out_be32(_immr->cp.cecdr, cmd_input);
-   out_be32(_immr->cp.cecr,
-(cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32)
- mcn_protocol << mcn_shift));
+  

[PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread Zhao Qiang
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
Changes for v7:
- split qeic part to another patch
- rebase
Changes for v8:
- include  in ucc_uart
Changes for v9:
- fix cast warning

 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  | 74 ---
 drivers/tty/serial/Kconfig |  2 +-
 drivers/tty/serial/ucc_uart.c  |  1 +
 drivers/usb/gadget/udc/Kconfig |  2 +-
 drivers/usb/host/Kconfig   |  2 +-
 include/soc/fsl/qe/qe.h|  1 -
 12 files changed, 123 insertions(+), 111 deletions(-)

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index d1ca45f..6677aff 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -5,10 +5,10 @@
 config NET_VENDOR_FREESCALE
bool "Freescale devices"
default y
-   depends on FSL_SOC || QUICC_ENGINE || CPM1 || CPM2 || PPC_MPC512x || \
-  M523x || M527x || M5272 || M528x || M520x || M532x || \
-  ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM) || \
-  ARCH_LAYERSCAPE
+   depends on FSL_SOC || (QUICC_ENGINE && PPC32) || CPM1 || CPM2 || \
+  PPC_MPC512x || M523x || M527x || M5272 || M528x || M520x || \
+  M532x || ARCH_MXC || ARCH_MXS || \
+  (PPC_MPC52xx && PPC_BESTCOMM) || ARCH_LAYERSCAPE
---help---
  If you have a network (Ethernet) card belonging to this class, say Y.
 
@@ -72,7 +72,7 @@ config FSL_XGMAC_MDIO
 
 config UCC_GETH
tristate "Freescale QE Gigabit Ethernet"
-   depends on QUICC_ENGINE
+   depends on QUICC_ENGINE && FSL_SOC && PPC32
select FSL_PQ_MDIO
select PHYLIB
---help---
diff --git a/drivers/soc/fsl/qe/Kconfig b/drivers/soc/fsl/qe/Kconfig
index 73a2e08..b26b643 100644
--- a/drivers/soc/fsl/qe/Kconfig
+++ b/drivers/soc/fsl/qe/Kconfig
@@ -4,7 +4,7 @@
 
 config QUICC_ENGINE
bool "Freescale QUICC Engine (QE) Support"
-   depends on FSL_SOC && PPC32
+   depends on OF && HAS_IOMEM
select GENERIC_ALLOCATOR
select CRC32
help
diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index 2707a82..2b53e85 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -33,8 +33,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 static void qe_snums_init(void);
 static int qe_sdma_init(void);
@@ -109,15 +107,27 @@ void qe_reset(void)
panic("sdma init failed!");
 }
 
+/* issue commands to QE, return 0 on success while -EIO on error
+ *
+ * @cmd: the command code, should be QE_INIT_TX_RX, QE_STOP_TX and so on
+ * @device: which sub-block will run the command, QE_CR_SUBBLOCK_UCCFAST1 - 8
+ * , QE_CR_SUBBLOCK_UCCSLOW1 - 8, QE_CR_SUBBLOCK_MCC1 - 3,
+ * QE_CR_SUBBLOCK_IDMA1 - 4 and such on.
+ * @mcn_protocol: specifies mode for the command for non-MCC, should be
+ * QE_CR_PROTOCOL_HDLC_TRANSPARENT, QE_CR_PROTOCOL_QMC, QE_CR_PROTOCOL_UART
+ * and such on.
+ * @cmd_input: command related data.
+ */
 int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
 {
unsigned long flags;
u8 mcn_shift = 0, dev_shift = 0;
-   u32 ret;
+   int ret;
+   int i;
 
spin_lock_irqsave(_lock, flags);
if (cmd == QE_RESET) {
-   out_be32(_immr->cp.cecr, (u32) (cmd | QE_CR_FLG));
+   iowrite32be((cmd | QE_CR_FLG), _immr->cp.cecr);
} else {
if (cmd == QE_ASSIGN_PAGE) {
/* Here device is the SNUM, not sub-block */
@@ -134,20 +144,26 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, 
u32 cmd_input)
mcn_shift = QE_CR_MCN_NORMAL_SHIFT;
}
 
-   out_be32(_immr->cp.cecdr, cmd_input);
-   out_be32(_immr->cp.cecr,
-(cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32)
- mcn_protocol << mcn_shift));
+   

[RESEND PATCH v12 2/4] drm: Move locking into drm_debugfs_crtc_crc_add

2016-12-04 Thread Tomeu Vizoso
There's no reason any more for callers of this function to take the lock
themselves, so just move the lock to the function to avoid confusion and
bugs when more callers are contributed.

Signed-off-by: Tomeu Vizoso 
---

 drivers/gpu/drm/drm_debugfs_crc.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs_crc.c 
b/drivers/gpu/drm/drm_debugfs_crc.c
index 00e771fb7df2..68b171af237b 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -325,16 +325,19 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool 
has_frame,
struct drm_crtc_crc_entry *entry;
int head, tail;
 
-   assert_spin_locked(>lock);
+   spin_lock(>lock);
 
/* Caller may not have noticed yet that userspace has stopped reading */
-   if (!crc->opened)
+   if (!crc->opened) {
+   spin_unlock(>lock);
return -EINVAL;
+   }
 
head = crc->head;
tail = crc->tail;
 
if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(>lock);
DRM_ERROR("Overflow of CRC buffer, userspace reads too 
slow.\n");
return -ENOBUFS;
}
@@ -347,6 +350,8 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool 
has_frame,
head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1);
crc->head = head;
 
+   spin_unlock(>lock);
+
return 0;
 }
 EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry);
-- 
2.7.4



[RESEND PATCH v12 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-12-04 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 2eac6ed0f653..a395fe0fb4f3 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(>base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(>base, true,
+
drm_accurate_vblank_count(>base),
+crcs);
if (!ret)
wake_up_interruptible(>base.crc.wq);
}
-- 
2.7.4



[RESEND PATCH v12 2/4] drm: Move locking into drm_debugfs_crtc_crc_add

2016-12-04 Thread Tomeu Vizoso
There's no reason any more for callers of this function to take the lock
themselves, so just move the lock to the function to avoid confusion and
bugs when more callers are contributed.

Signed-off-by: Tomeu Vizoso 
---

 drivers/gpu/drm/drm_debugfs_crc.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs_crc.c 
b/drivers/gpu/drm/drm_debugfs_crc.c
index 00e771fb7df2..68b171af237b 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -325,16 +325,19 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool 
has_frame,
struct drm_crtc_crc_entry *entry;
int head, tail;
 
-   assert_spin_locked(>lock);
+   spin_lock(>lock);
 
/* Caller may not have noticed yet that userspace has stopped reading */
-   if (!crc->opened)
+   if (!crc->opened) {
+   spin_unlock(>lock);
return -EINVAL;
+   }
 
head = crc->head;
tail = crc->tail;
 
if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(>lock);
DRM_ERROR("Overflow of CRC buffer, userspace reads too 
slow.\n");
return -ENOBUFS;
}
@@ -347,6 +350,8 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool 
has_frame,
head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1);
crc->head = head;
 
+   spin_unlock(>lock);
+
return 0;
 }
 EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry);
-- 
2.7.4



[RESEND PATCH v12 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-12-04 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 2eac6ed0f653..a395fe0fb4f3 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(>base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(>base, true,
+
drm_accurate_vblank_count(>base),
+crcs);
if (!ret)
wake_up_interruptible(>base.crc.wq);
}
-- 
2.7.4



[RESEND PATCH v12 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-12-04 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

v12: Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 882 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 939 ++
 4 files changed, 949 insertions(+), 879 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3dea46af9fe6..0e4c15b93f04 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 96407f684f7f..d6de8e70ee96 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3547,12 +3537,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3582,844 +3566,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
-   pipe_crc_data_count(pipe_crc), pipe_crc->lock);
-   if (ret) {
-   

[RESEND PATCH v12 0/4] New debugfs API for capturing CRC of frames

2016-12-04 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series. They have
been rebased and I have also addressed two smaller comments:

- Move locking into drm_crtc_add_crc_entry (Daniel Vetter).
- Define intel_crtc_set_crc_source as NULL if !CONFIG_DEBUG_FS (Jani
  Nikula).

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c |9 +-
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  882 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   81 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   11 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1009 +
 8 files changed, 1089 insertions(+), 907 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

-- 
2.7.4



[RESEND PATCH v12 3/4] drm/i915: Use new CRC debugfs API

2016-12-04 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 56002a52936d..70aeb0d640fc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1751,6 +1751,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 07ca71cabb2b..2eac6ed0f653 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = _crc->entries[head];
+   entry = _crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(_crc->lock);
+   spin_unlock(_crc->lock);
 
-   wake_up_interruptible(_crc->wq);
+   wake_up_interruptible(_crc->wq);
+   } else {
+   /*
+* For 

[RESEND PATCH v12 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-12-04 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

v12: Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 882 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 939 ++
 4 files changed, 949 insertions(+), 879 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3dea46af9fe6..0e4c15b93f04 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 96407f684f7f..d6de8e70ee96 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3547,12 +3537,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3582,844 +3566,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
-   pipe_crc_data_count(pipe_crc), pipe_crc->lock);
-   if (ret) {
-   spin_unlock_irq(_crc->lock);
-   return ret;
-   }

[RESEND PATCH v12 0/4] New debugfs API for capturing CRC of frames

2016-12-04 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series. They have
been rebased and I have also addressed two smaller comments:

- Move locking into drm_crtc_add_crc_entry (Daniel Vetter).
- Define intel_crtc_set_crc_source as NULL if !CONFIG_DEBUG_FS (Jani
  Nikula).

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c |9 +-
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  882 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   81 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   11 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1009 +
 8 files changed, 1089 insertions(+), 907 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

-- 
2.7.4



[RESEND PATCH v12 3/4] drm/i915: Use new CRC debugfs API

2016-12-04 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 56002a52936d..70aeb0d640fc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1751,6 +1751,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 07ca71cabb2b..2eac6ed0f653 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = _crc->entries[head];
+   entry = _crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(_crc->lock);
+   spin_unlock(_crc->lock);
 
-   wake_up_interruptible(_crc->wq);
+   wake_up_interruptible(_crc->wq);
+   } else {
+   /*
+* For some not yet identified reason, the first CRC is
+ 

[RFC PATCH] doc: change the way how the stable backport is requested

2016-12-04 Thread Michal Hocko
From: Michal Hocko 

Currently if a patch should aim a stable tree backport one should add

Cc: sta...@vger.kernel.org # $version

to the s-o-b block. This has two major disadvantages a) it spams the
stable mailing list with patches which are just discussed and not merged
yet and b) it is easy to make a mistake and disclose a patch via
git-send-email while it is still discussed under security embargo.

In fact it is not necessary to have the stable mailing list address in
the Cc until it hits the Linus tree and all we need is to have a
grepable marker for automatic identification of such a patch. Let's
use

stable-request: $version[s]

instead. Where $version would tell which stable trees might be
interested in the backport. This will make the process much less error
prone without any actual downsides.

Signed-off-by: Michal Hocko 
---

Hi,
this is mostly motivated by the "recent" leak when a security related
patch made it to the stable tree before the embargo was lifted while it
has been discussed on the security mailing list because of careless git
send-email usage. It's not been the first time AFAIR.

This is not the only reason to change this workflow though. I also think
that CCing stable on the patch submission just adds a lot of noise to the
stable mailing list. I personally stopped following the list because the
email volume was just too high. IMHO the mailing list should only
contain patches that are currently aiming the stable tree to be useful.

Thoughts/Comments?

 Documentation/stable_kernel_rules.txt | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/Documentation/stable_kernel_rules.txt 
b/Documentation/stable_kernel_rules.txt
index 4d82e31b7958..a9f2ca460ec7 100644
--- a/Documentation/stable_kernel_rules.txt
+++ b/Documentation/stable_kernel_rules.txt
@@ -54,11 +54,13 @@ To have the patch automatically included in the stable 
tree, add the tag
 
 .. code-block:: none
 
- Cc: sta...@vger.kernel.org
+ stable-request: $version[s]
 
 in the sign-off area. Once the patch is merged it will be applied to
-the stable tree without anything else needing to be done by the author
-or subsystem maintainer.
+the stable tree[s] without anything else needing to be done by the author
+or subsystem maintainer. In exceptional cases when the $version is not
+known to the patch submitter "any" can be used and the final version will
+get resolved at the time of backporting.
 
 .. _option_2:
 
@@ -104,10 +106,10 @@ prerequisites which can be cherry-picked. This can be 
specified in the following
 
 .. code-block:: none
 
- Cc:  # 3.3.x: a1f84a3: sched: Check for idle
- Cc:  # 3.3.x: 1b9508f: sched: Rate-limit newidle
- Cc:  # 3.3.x: fd21073: sched: Fix affinity logic
- Cc:  # 3.3.x
+ stable-request: depends on a1f84a3: sched: Check for idle
+ stable-request: depends on 1b9508f: sched: Rate-limit newidle
+ stable-request: depends on fd21073: sched: Fix affinity logic
+ stable-request: 3.3.x
  Signed-off-by: Ingo Molnar 
 
 The tag sequence has the meaning of:
@@ -119,13 +121,6 @@ prerequisites which can be cherry-picked. This can be 
specified in the following
  git cherry-pick fd21073
  git cherry-pick 
 
-Also, some patches may have kernel version prerequisites.  This can be
-specified in the following format in the sign-off area:
-
-.. code-block:: none
-
- Cc:  # 3.3.x-
-
 The tag has the meaning of:
 
 .. code-block:: none
-- 
2.10.2



[RFC PATCH] doc: change the way how the stable backport is requested

2016-12-04 Thread Michal Hocko
From: Michal Hocko 

Currently if a patch should aim a stable tree backport one should add

Cc: sta...@vger.kernel.org # $version

to the s-o-b block. This has two major disadvantages a) it spams the
stable mailing list with patches which are just discussed and not merged
yet and b) it is easy to make a mistake and disclose a patch via
git-send-email while it is still discussed under security embargo.

In fact it is not necessary to have the stable mailing list address in
the Cc until it hits the Linus tree and all we need is to have a
grepable marker for automatic identification of such a patch. Let's
use

stable-request: $version[s]

instead. Where $version would tell which stable trees might be
interested in the backport. This will make the process much less error
prone without any actual downsides.

Signed-off-by: Michal Hocko 
---

Hi,
this is mostly motivated by the "recent" leak when a security related
patch made it to the stable tree before the embargo was lifted while it
has been discussed on the security mailing list because of careless git
send-email usage. It's not been the first time AFAIR.

This is not the only reason to change this workflow though. I also think
that CCing stable on the patch submission just adds a lot of noise to the
stable mailing list. I personally stopped following the list because the
email volume was just too high. IMHO the mailing list should only
contain patches that are currently aiming the stable tree to be useful.

Thoughts/Comments?

 Documentation/stable_kernel_rules.txt | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/Documentation/stable_kernel_rules.txt 
b/Documentation/stable_kernel_rules.txt
index 4d82e31b7958..a9f2ca460ec7 100644
--- a/Documentation/stable_kernel_rules.txt
+++ b/Documentation/stable_kernel_rules.txt
@@ -54,11 +54,13 @@ To have the patch automatically included in the stable 
tree, add the tag
 
 .. code-block:: none
 
- Cc: sta...@vger.kernel.org
+ stable-request: $version[s]
 
 in the sign-off area. Once the patch is merged it will be applied to
-the stable tree without anything else needing to be done by the author
-or subsystem maintainer.
+the stable tree[s] without anything else needing to be done by the author
+or subsystem maintainer. In exceptional cases when the $version is not
+known to the patch submitter "any" can be used and the final version will
+get resolved at the time of backporting.
 
 .. _option_2:
 
@@ -104,10 +106,10 @@ prerequisites which can be cherry-picked. This can be 
specified in the following
 
 .. code-block:: none
 
- Cc:  # 3.3.x: a1f84a3: sched: Check for idle
- Cc:  # 3.3.x: 1b9508f: sched: Rate-limit newidle
- Cc:  # 3.3.x: fd21073: sched: Fix affinity logic
- Cc:  # 3.3.x
+ stable-request: depends on a1f84a3: sched: Check for idle
+ stable-request: depends on 1b9508f: sched: Rate-limit newidle
+ stable-request: depends on fd21073: sched: Fix affinity logic
+ stable-request: 3.3.x
  Signed-off-by: Ingo Molnar 
 
 The tag sequence has the meaning of:
@@ -119,13 +121,6 @@ prerequisites which can be cherry-picked. This can be 
specified in the following
  git cherry-pick fd21073
  git cherry-pick 
 
-Also, some patches may have kernel version prerequisites.  This can be
-specified in the following format in the sign-off area:
-
-.. code-block:: none
-
- Cc:  # 3.3.x-
-
 The tag has the meaning of:
 
 .. code-block:: none
-- 
2.10.2



RE: [LINUX RFC v4 3/4] mtd: spi-nor: add stripe support

2016-12-04 Thread Naga Sureshkumar Relli
Hi Cyrille,

> > Hi Cyrille,
> >
> >> I have not finished to review the whole series yet but here some
> >> first
> >> comments:
> >
> > Thanks for reviewing these patch series.
> >
> >>
> >> Le 27/11/2016 à 09:33, Naga Sureshkumar Relli a écrit :
> >>> This patch adds stripe support and it is needed for GQSPI parallel
> >>> configuration mode by:
> >>>
> >>> - Adding required parameters like stripe and shift to spi_nor
> >>>   structure.
> >>> - Initializing all added parameters in spi_nor_scan()
> >>> - Updating read_sr() and read_fsr() for getting status from both
> >>>   flashes
> >>> - Increasing page_size, sector_size, erase_size and toatal flash
> >>>   size as and when required.
> >>> - Dividing address by 2
> >>> - Updating spi->master->flags for qspi driver to change CS
> >>>
> >>> Signed-off-by: Naga Sureshkumar Relli 
> >>> ---
> >>> Changes for v4:
> >>>  - rename isparallel to stripe
> >>> Changes for v3:
> >>>  - No change
> >>> Changes for v2:
> >>>  - Splitted to separate MTD layer changes from SPI core changes
> >>> ---
> >>>  drivers/mtd/spi-nor/spi-nor.c | 130
> >> --
> >>>  include/linux/mtd/spi-nor.h   |   2 +
> >>>  2 files changed, 103 insertions(+), 29 deletions(-)
> >>>
> >>> diff --git a/drivers/mtd/spi-nor/spi-nor.c
> >>> b/drivers/mtd/spi-nor/spi-nor.c index d0fc165..4252239 100644
> >>> --- a/drivers/mtd/spi-nor/spi-nor.c
> >>> +++ b/drivers/mtd/spi-nor/spi-nor.c
> >>> @@ -22,6 +22,7 @@
> >>>  #include 
> >>>  #include 
> >>>  #include 
> >>> +#include 
> >>>
> >>>  /* Define max times to check status register before we give up. */
> >>>
> >>> @@ -89,15 +90,24 @@ static const struct flash_info
> >>> *spi_nor_match_id(const char *name);  static int read_sr(struct
> >>> spi_nor *nor)  {
> >>>   int ret;
> >>> - u8 val;
> >>> + u8 val[2];
> >>>
> >>> - ret = nor->read_reg(nor, SPINOR_OP_RDSR, , 1);
> >>> - if (ret < 0) {
> >>> - pr_err("error %d reading SR\n", (int) ret);
> >>> - return ret;
> >>> + if (nor->stripe) {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDSR, [0], 2);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading SR\n", (int) ret);
> >>> + return ret;
> >>> + }
> >>> + val[0] |= val[1];
> >> Why '|' rather than '&' ?
> >> I guess because of the 'Write In Progress/Busy' bit: when called by
> >> spi_nor_sr_ready(), you want to be sure that this 'BUSY' bit is
> >> cleared on both memories.
> >>
> >> But what about when the Status Register is read for purpose other
> >> than checking the state of the 'BUSY' bit?
> >>
> > Yes you are correct, I will change this.
> >
> >> What about SPI controllers supporting more than 2 memories in parallel?
> >>
> >> This solution might fit the ZynqMP controller but doesn't look so generic.
> >>
> >>> + } else {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDSR, [0], 1);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading SR\n", (int) ret);
> >>> + return ret;
> >>> + }
> >>>   }
> >>>
> >>> - return val;
> >>> + return val[0];
> >>>  }
> >>>
> >>>  /*
> >>> @@ -108,15 +118,24 @@ static int read_sr(struct spi_nor *nor)
> >>> static int read_fsr(struct spi_nor *nor)  {
> >>>   int ret;
> >>> - u8 val;
> >>> + u8 val[2];
> >>>
> >>> - ret = nor->read_reg(nor, SPINOR_OP_RDFSR, , 1);
> >>> - if (ret < 0) {
> >>> - pr_err("error %d reading FSR\n", ret);
> >>> - return ret;
> >>> + if (nor->stripe) {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDFSR, [0], 2);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading FSR\n", ret);
> >>> + return ret;
> >>> + }
> >>> + val[0] &= val[1];
> >> Same comment here: why '&' rather than '|'?
> >> Surely because of the the 'READY' bit which should be set for both
> memories.
> > I will update this also.
> >>
> >>> + } else {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDFSR, [0], 1);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading FSR\n", ret);
> >>> + return ret;
> >>> + }
> >>>   }
> >>>
> >>> - return val;
> >>> + return val[0];
> >>>  }
> >>>
> >>>  /*
> >>> @@ -290,9 +309,16 @@ static int spi_nor_wait_till_ready(struct
> >>> spi_nor
> >> *nor)
> >>>   */
> >>>  static int erase_chip(struct spi_nor *nor)  {
> >>> + u32 ret;
> >>> +
> >>>   dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
> >>>
> >>> - return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0);
> >>> + ret = nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0);
> >>> + if (ret)
> >>> + return ret;
> >>> +
> >>> + return ret;
> >>> +
> >>
> >>if (ret)
> >>return ret;
> >>else
> >>return ret;
> >>
> >> This chunk should be removed, it doesn't ease the patch review ;)
> > Ok, I will remove.
> >>
> >>>  }
> >>>
> >>>  static int 

RE: [LINUX RFC v4 3/4] mtd: spi-nor: add stripe support

2016-12-04 Thread Naga Sureshkumar Relli
Hi Cyrille,

> > Hi Cyrille,
> >
> >> I have not finished to review the whole series yet but here some
> >> first
> >> comments:
> >
> > Thanks for reviewing these patch series.
> >
> >>
> >> Le 27/11/2016 à 09:33, Naga Sureshkumar Relli a écrit :
> >>> This patch adds stripe support and it is needed for GQSPI parallel
> >>> configuration mode by:
> >>>
> >>> - Adding required parameters like stripe and shift to spi_nor
> >>>   structure.
> >>> - Initializing all added parameters in spi_nor_scan()
> >>> - Updating read_sr() and read_fsr() for getting status from both
> >>>   flashes
> >>> - Increasing page_size, sector_size, erase_size and toatal flash
> >>>   size as and when required.
> >>> - Dividing address by 2
> >>> - Updating spi->master->flags for qspi driver to change CS
> >>>
> >>> Signed-off-by: Naga Sureshkumar Relli 
> >>> ---
> >>> Changes for v4:
> >>>  - rename isparallel to stripe
> >>> Changes for v3:
> >>>  - No change
> >>> Changes for v2:
> >>>  - Splitted to separate MTD layer changes from SPI core changes
> >>> ---
> >>>  drivers/mtd/spi-nor/spi-nor.c | 130
> >> --
> >>>  include/linux/mtd/spi-nor.h   |   2 +
> >>>  2 files changed, 103 insertions(+), 29 deletions(-)
> >>>
> >>> diff --git a/drivers/mtd/spi-nor/spi-nor.c
> >>> b/drivers/mtd/spi-nor/spi-nor.c index d0fc165..4252239 100644
> >>> --- a/drivers/mtd/spi-nor/spi-nor.c
> >>> +++ b/drivers/mtd/spi-nor/spi-nor.c
> >>> @@ -22,6 +22,7 @@
> >>>  #include 
> >>>  #include 
> >>>  #include 
> >>> +#include 
> >>>
> >>>  /* Define max times to check status register before we give up. */
> >>>
> >>> @@ -89,15 +90,24 @@ static const struct flash_info
> >>> *spi_nor_match_id(const char *name);  static int read_sr(struct
> >>> spi_nor *nor)  {
> >>>   int ret;
> >>> - u8 val;
> >>> + u8 val[2];
> >>>
> >>> - ret = nor->read_reg(nor, SPINOR_OP_RDSR, , 1);
> >>> - if (ret < 0) {
> >>> - pr_err("error %d reading SR\n", (int) ret);
> >>> - return ret;
> >>> + if (nor->stripe) {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDSR, [0], 2);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading SR\n", (int) ret);
> >>> + return ret;
> >>> + }
> >>> + val[0] |= val[1];
> >> Why '|' rather than '&' ?
> >> I guess because of the 'Write In Progress/Busy' bit: when called by
> >> spi_nor_sr_ready(), you want to be sure that this 'BUSY' bit is
> >> cleared on both memories.
> >>
> >> But what about when the Status Register is read for purpose other
> >> than checking the state of the 'BUSY' bit?
> >>
> > Yes you are correct, I will change this.
> >
> >> What about SPI controllers supporting more than 2 memories in parallel?
> >>
> >> This solution might fit the ZynqMP controller but doesn't look so generic.
> >>
> >>> + } else {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDSR, [0], 1);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading SR\n", (int) ret);
> >>> + return ret;
> >>> + }
> >>>   }
> >>>
> >>> - return val;
> >>> + return val[0];
> >>>  }
> >>>
> >>>  /*
> >>> @@ -108,15 +118,24 @@ static int read_sr(struct spi_nor *nor)
> >>> static int read_fsr(struct spi_nor *nor)  {
> >>>   int ret;
> >>> - u8 val;
> >>> + u8 val[2];
> >>>
> >>> - ret = nor->read_reg(nor, SPINOR_OP_RDFSR, , 1);
> >>> - if (ret < 0) {
> >>> - pr_err("error %d reading FSR\n", ret);
> >>> - return ret;
> >>> + if (nor->stripe) {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDFSR, [0], 2);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading FSR\n", ret);
> >>> + return ret;
> >>> + }
> >>> + val[0] &= val[1];
> >> Same comment here: why '&' rather than '|'?
> >> Surely because of the the 'READY' bit which should be set for both
> memories.
> > I will update this also.
> >>
> >>> + } else {
> >>> + ret = nor->read_reg(nor, SPINOR_OP_RDFSR, [0], 1);
> >>> + if (ret < 0) {
> >>> + pr_err("error %d reading FSR\n", ret);
> >>> + return ret;
> >>> + }
> >>>   }
> >>>
> >>> - return val;
> >>> + return val[0];
> >>>  }
> >>>
> >>>  /*
> >>> @@ -290,9 +309,16 @@ static int spi_nor_wait_till_ready(struct
> >>> spi_nor
> >> *nor)
> >>>   */
> >>>  static int erase_chip(struct spi_nor *nor)  {
> >>> + u32 ret;
> >>> +
> >>>   dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
> >>>
> >>> - return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0);
> >>> + ret = nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0);
> >>> + if (ret)
> >>> + return ret;
> >>> +
> >>> + return ret;
> >>> +
> >>
> >>if (ret)
> >>return ret;
> >>else
> >>return ret;
> >>
> >> This chunk should be removed, it doesn't ease the patch review ;)
> > Ok, I will remove.
> >>
> >>>  }
> >>>
> >>>  static int spi_nor_lock_and_prep(struct spi_nor 

Re: [PATCH 2/3 v2] ALSA: usb-audio: avoid setting of sample rate multiple times on bus

2016-12-04 Thread Jiada Wang

Hi Sakamoto

On 11/30/2016 02:45 AM, Takashi Sakamoto wrote:

Hi Jiada,

I don't oppose this patch. Nevertheless, your description is not 
necessarily correct.


On Nov 30 2016 16:59, Jiada Wang wrote:

From: Daniel Girnus 

ALSA usually calls the prepare function twice before starting the 
playback:

1. On hw_params call from userland and
2. internally when starting the stream.


ALSA PCM core in kernel land doesn't perform like this.

In alsa-lib, 'snd_pcm_hw_params()' calls 
'snd_pcm_hw_params_internal()' and 'snd_pcm_prepare()' sequentially.
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm.c;h=cd87bc759ded95953e332b7e8d56b0f2d5b4185d;hb=HEAD#l853 



In system call level (e.g. see by strace(1)), this looks like two 
ioctl(2)s with 'SNDRV_PCM_IOCTL_HW_PARAMS' and 'SNDRV_PCM_IOCTL_PREPARE'.


Well, when applications are written to execute 'snd_pcm_hw_params()' 
and 'snd_pcm_hw_prepare()' sequentially, additional ioctl(2) with 
'SNDRV_PCM_IOCTL_PREPARE' appears. PulseAudio is this kind of 
application. I indicated the useless in 2014, but it still remains:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2014-January/019773.html 



You have the misunderstanding due to a nature of alsa-lib and tendency 
of major applications, from my point of view.


Thanks for your indication, so because some of userland applications 
call 'snd_pcm_hw_params()' and
'snd_pcm_hw_prepare()' sequentially, means the second 
'SNDRV_PCM_IOCTL_PREPARE' be called in 'SNDRV_PCM_STATE_PREPARED' state, 
some devices are unable to manage this and stop working.


I will update Changelog in v2 Patchset.

Thanks,
Jiada


Some device are not able to manage this and they will stop playback
if the sample rate will be configured several times over USB protocol.

Signed-off-by: Jens Lorenz 
Signed-off-by: Jiada Wang 
---
 sound/usb/pcm.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 44d178e..a522c9a 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -806,17 +806,18 @@ static int snd_usb_pcm_prepare(struct 
snd_pcm_substream *substream)

 if (ret < 0)
 goto unlock;

-iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
-alts = >altsetting[subs->cur_audiofmt->altset_idx];
-ret = snd_usb_init_sample_rate(subs->stream->chip,
-   subs->cur_audiofmt->iface,
-   alts,
-   subs->cur_audiofmt,
-   subs->cur_rate);
-if (ret < 0)
-goto unlock;
-
 if (subs->need_setup_ep) {
+
+iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
+alts = >altsetting[subs->cur_audiofmt->altset_idx];
+ret = snd_usb_init_sample_rate(subs->stream->chip,
+   subs->cur_audiofmt->iface,
+   alts,
+   subs->cur_audiofmt,
+   subs->cur_rate);
+if (ret < 0)
+goto unlock;
+
 ret = configure_endpoint(subs);
 if (ret < 0)
 goto unlock;



Regards

Takashi Sakamoto




Re: [PATCH 2/3 v2] ALSA: usb-audio: avoid setting of sample rate multiple times on bus

2016-12-04 Thread Jiada Wang

Hi Sakamoto

On 11/30/2016 02:45 AM, Takashi Sakamoto wrote:

Hi Jiada,

I don't oppose this patch. Nevertheless, your description is not 
necessarily correct.


On Nov 30 2016 16:59, Jiada Wang wrote:

From: Daniel Girnus 

ALSA usually calls the prepare function twice before starting the 
playback:

1. On hw_params call from userland and
2. internally when starting the stream.


ALSA PCM core in kernel land doesn't perform like this.

In alsa-lib, 'snd_pcm_hw_params()' calls 
'snd_pcm_hw_params_internal()' and 'snd_pcm_prepare()' sequentially.
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm.c;h=cd87bc759ded95953e332b7e8d56b0f2d5b4185d;hb=HEAD#l853 



In system call level (e.g. see by strace(1)), this looks like two 
ioctl(2)s with 'SNDRV_PCM_IOCTL_HW_PARAMS' and 'SNDRV_PCM_IOCTL_PREPARE'.


Well, when applications are written to execute 'snd_pcm_hw_params()' 
and 'snd_pcm_hw_prepare()' sequentially, additional ioctl(2) with 
'SNDRV_PCM_IOCTL_PREPARE' appears. PulseAudio is this kind of 
application. I indicated the useless in 2014, but it still remains:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2014-January/019773.html 



You have the misunderstanding due to a nature of alsa-lib and tendency 
of major applications, from my point of view.


Thanks for your indication, so because some of userland applications 
call 'snd_pcm_hw_params()' and
'snd_pcm_hw_prepare()' sequentially, means the second 
'SNDRV_PCM_IOCTL_PREPARE' be called in 'SNDRV_PCM_STATE_PREPARED' state, 
some devices are unable to manage this and stop working.


I will update Changelog in v2 Patchset.

Thanks,
Jiada


Some device are not able to manage this and they will stop playback
if the sample rate will be configured several times over USB protocol.

Signed-off-by: Jens Lorenz 
Signed-off-by: Jiada Wang 
---
 sound/usb/pcm.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 44d178e..a522c9a 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -806,17 +806,18 @@ static int snd_usb_pcm_prepare(struct 
snd_pcm_substream *substream)

 if (ret < 0)
 goto unlock;

-iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
-alts = >altsetting[subs->cur_audiofmt->altset_idx];
-ret = snd_usb_init_sample_rate(subs->stream->chip,
-   subs->cur_audiofmt->iface,
-   alts,
-   subs->cur_audiofmt,
-   subs->cur_rate);
-if (ret < 0)
-goto unlock;
-
 if (subs->need_setup_ep) {
+
+iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
+alts = >altsetting[subs->cur_audiofmt->altset_idx];
+ret = snd_usb_init_sample_rate(subs->stream->chip,
+   subs->cur_audiofmt->iface,
+   alts,
+   subs->cur_audiofmt,
+   subs->cur_rate);
+if (ret < 0)
+goto unlock;
+
 ret = configure_endpoint(subs);
 if (ret < 0)
 goto unlock;



Regards

Takashi Sakamoto




[v2 PATCH] netlink: Do not schedule work from sk_destruct

2016-12-04 Thread Herbert Xu
On Mon, Dec 05, 2016 at 03:19:46PM +0800, Herbert Xu wrote:
>
> Thanks for the patch.  It'll obviously work but I wanted avoid that
> because it penalises the common path for the rare case.
> 
> Andrey, please try this patch and let me know if it's any better.
> 
> ---8<---
> Subject: netlink: Do not schedule work from sk_destruct

Crap, I screwed it up again.  Here is a v2 which moves the atomic
call into the RCU callback as otherwise the socket can be freed from
another path while we await the RCU callback.

---8<---
It is wrong to schedule a work from sk_destruct using the socket
as the memory reserve because the socket will be freed immediately
after the return from sk_destruct.

Instead we should do the deferral prior to sk_free.

This patch does just that.

Fixes: 707693c8a498 ("netlink: Call cb->done from a worker thread")
Signed-off-by: Herbert Xu 

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 602e5eb..463f5cf 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -322,11 +322,13 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, 
struct sock *sk)
sk_mem_charge(sk, skb->truesize);
 }
 
-static void __netlink_sock_destruct(struct sock *sk)
+static void netlink_sock_destruct(struct sock *sk)
 {
struct netlink_sock *nlk = nlk_sk(sk);
 
if (nlk->cb_running) {
+   if (nlk->cb.done)
+   nlk->cb.done(>cb);
module_put(nlk->cb.module);
kfree_skb(nlk->cb.skb);
}
@@ -348,21 +350,7 @@ static void netlink_sock_destruct_work(struct work_struct 
*work)
struct netlink_sock *nlk = container_of(work, struct netlink_sock,
work);
 
-   nlk->cb.done(>cb);
-   __netlink_sock_destruct(>sk);
-}
-
-static void netlink_sock_destruct(struct sock *sk)
-{
-   struct netlink_sock *nlk = nlk_sk(sk);
-
-   if (nlk->cb_running && nlk->cb.done) {
-   INIT_WORK(>work, netlink_sock_destruct_work);
-   schedule_work(>work);
-   return;
-   }
-
-   __netlink_sock_destruct(sk);
+   sk_free(>sk);
 }
 
 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
@@ -664,11 +652,21 @@ static int netlink_create(struct net *net, struct socket 
*sock, int protocol,
goto out;
 }
 
-static void deferred_put_nlk_sk(struct rcu_head *head)
+static void deferred_free_nlk_sk(struct rcu_head *head)
 {
struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
+   struct sock *sk = >sk;
+
+   if (!atomic_dec_and_test(>sk_refcnt))
+   return;
+
+   if (nlk->cb_running && nlk->cb.done) {
+   INIT_WORK(>work, netlink_sock_destruct_work);
+   schedule_work(>work);
+   return;
+   }
 
-   sock_put(>sk);
+   sk_free(sk);
 }
 
 static int netlink_release(struct socket *sock)
@@ -743,7 +741,7 @@ static int netlink_release(struct socket *sock)
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), _proto, -1);
local_bh_enable();
-   call_rcu(>rcu, deferred_put_nlk_sk);
+   call_rcu(>rcu, deferred_free_nlk_sk);
return 0;
 }
 
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] drm/radeon: don't add files at control minor debugfs directory

2016-12-04 Thread Daniel Vetter
On Sat, Dec 03, 2016 at 03:47:00PM +0100, Nicolai Stange wrote:
> Since commit 8a357d10043c ("drm: Nerf DRM_CONTROL nodes"), a
> struct drm_device's ->control member is always NULL.
> 
> In the case of CONFIG_DEBUG_FS=y, radeon_debugfs_add_files() accesses
> ->control->debugfs_root though. This results in the following Oops:
> 
>   BUG: unable to handle kernel NULL pointer dereference at 0018
>   IP: radeon_debugfs_add_files+0x90/0x100 [radeon]
>   PGD 0
>   Oops:  [#1] SMP
>   [...]
>   Call Trace:
>? work_on_cpu+0xb0/0xb0
>radeon_fence_driver_init+0x120/0x150 [radeon]
>si_init+0x122/0xd50 [radeon]
>? _raw_spin_unlock_irq+0x2c/0x40
>? device_pm_check_callbacks+0xb3/0xc0
>radeon_device_init+0x958/0xda0 [radeon]
>radeon_driver_load_kms+0x9a/0x210 [radeon]
>drm_dev_register+0xa9/0xd0 [drm]
>drm_get_pci_dev+0x9c/0x1e0 [drm]
>radeon_pci_probe+0xb8/0xe0 [radeon]
>   [...]
> 
> Fix this by omitting the drm_debugfs_create_files() call for the
> control minor debugfs directory which is now non-existent anyway.
> 
> Fixes: 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
> Signed-off-by: Nicolai Stange 

Applied to drm-misc with Dave's irc ack, thanks for your patch.
-Daniel

> ---
> Tested on top of next-20161202.
> That 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
> is in next since 20161201.
> 
>  drivers/gpu/drm/radeon/radeon_device.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index 60a8920..8a1df2a 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -1949,9 +1949,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
>   rdev->debugfs_count = i;
>  #if defined(CONFIG_DEBUG_FS)
>   drm_debugfs_create_files(files, nfiles,
> -  rdev->ddev->control->debugfs_root,
> -  rdev->ddev->control);
> - drm_debugfs_create_files(files, nfiles,
>rdev->ddev->primary->debugfs_root,
>rdev->ddev->primary);
>  #endif
> @@ -1966,9 +1963,6 @@ static void radeon_debugfs_remove_files(struct 
> radeon_device *rdev)
>   for (i = 0; i < rdev->debugfs_count; i++) {
>   drm_debugfs_remove_files(rdev->debugfs[i].files,
>rdev->debugfs[i].num_files,
> -  rdev->ddev->control);
> - drm_debugfs_remove_files(rdev->debugfs[i].files,
> -  rdev->debugfs[i].num_files,
>rdev->ddev->primary);
>   }
>  #endif
> -- 
> 2.10.2
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[v2 PATCH] netlink: Do not schedule work from sk_destruct

2016-12-04 Thread Herbert Xu
On Mon, Dec 05, 2016 at 03:19:46PM +0800, Herbert Xu wrote:
>
> Thanks for the patch.  It'll obviously work but I wanted avoid that
> because it penalises the common path for the rare case.
> 
> Andrey, please try this patch and let me know if it's any better.
> 
> ---8<---
> Subject: netlink: Do not schedule work from sk_destruct

Crap, I screwed it up again.  Here is a v2 which moves the atomic
call into the RCU callback as otherwise the socket can be freed from
another path while we await the RCU callback.

---8<---
It is wrong to schedule a work from sk_destruct using the socket
as the memory reserve because the socket will be freed immediately
after the return from sk_destruct.

Instead we should do the deferral prior to sk_free.

This patch does just that.

Fixes: 707693c8a498 ("netlink: Call cb->done from a worker thread")
Signed-off-by: Herbert Xu 

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 602e5eb..463f5cf 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -322,11 +322,13 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, 
struct sock *sk)
sk_mem_charge(sk, skb->truesize);
 }
 
-static void __netlink_sock_destruct(struct sock *sk)
+static void netlink_sock_destruct(struct sock *sk)
 {
struct netlink_sock *nlk = nlk_sk(sk);
 
if (nlk->cb_running) {
+   if (nlk->cb.done)
+   nlk->cb.done(>cb);
module_put(nlk->cb.module);
kfree_skb(nlk->cb.skb);
}
@@ -348,21 +350,7 @@ static void netlink_sock_destruct_work(struct work_struct 
*work)
struct netlink_sock *nlk = container_of(work, struct netlink_sock,
work);
 
-   nlk->cb.done(>cb);
-   __netlink_sock_destruct(>sk);
-}
-
-static void netlink_sock_destruct(struct sock *sk)
-{
-   struct netlink_sock *nlk = nlk_sk(sk);
-
-   if (nlk->cb_running && nlk->cb.done) {
-   INIT_WORK(>work, netlink_sock_destruct_work);
-   schedule_work(>work);
-   return;
-   }
-
-   __netlink_sock_destruct(sk);
+   sk_free(>sk);
 }
 
 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
@@ -664,11 +652,21 @@ static int netlink_create(struct net *net, struct socket 
*sock, int protocol,
goto out;
 }
 
-static void deferred_put_nlk_sk(struct rcu_head *head)
+static void deferred_free_nlk_sk(struct rcu_head *head)
 {
struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
+   struct sock *sk = >sk;
+
+   if (!atomic_dec_and_test(>sk_refcnt))
+   return;
+
+   if (nlk->cb_running && nlk->cb.done) {
+   INIT_WORK(>work, netlink_sock_destruct_work);
+   schedule_work(>work);
+   return;
+   }
 
-   sock_put(>sk);
+   sk_free(sk);
 }
 
 static int netlink_release(struct socket *sock)
@@ -743,7 +741,7 @@ static int netlink_release(struct socket *sock)
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), _proto, -1);
local_bh_enable();
-   call_rcu(>rcu, deferred_put_nlk_sk);
+   call_rcu(>rcu, deferred_free_nlk_sk);
return 0;
 }
 
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] drm/radeon: don't add files at control minor debugfs directory

2016-12-04 Thread Daniel Vetter
On Sat, Dec 03, 2016 at 03:47:00PM +0100, Nicolai Stange wrote:
> Since commit 8a357d10043c ("drm: Nerf DRM_CONTROL nodes"), a
> struct drm_device's ->control member is always NULL.
> 
> In the case of CONFIG_DEBUG_FS=y, radeon_debugfs_add_files() accesses
> ->control->debugfs_root though. This results in the following Oops:
> 
>   BUG: unable to handle kernel NULL pointer dereference at 0018
>   IP: radeon_debugfs_add_files+0x90/0x100 [radeon]
>   PGD 0
>   Oops:  [#1] SMP
>   [...]
>   Call Trace:
>? work_on_cpu+0xb0/0xb0
>radeon_fence_driver_init+0x120/0x150 [radeon]
>si_init+0x122/0xd50 [radeon]
>? _raw_spin_unlock_irq+0x2c/0x40
>? device_pm_check_callbacks+0xb3/0xc0
>radeon_device_init+0x958/0xda0 [radeon]
>radeon_driver_load_kms+0x9a/0x210 [radeon]
>drm_dev_register+0xa9/0xd0 [drm]
>drm_get_pci_dev+0x9c/0x1e0 [drm]
>radeon_pci_probe+0xb8/0xe0 [radeon]
>   [...]
> 
> Fix this by omitting the drm_debugfs_create_files() call for the
> control minor debugfs directory which is now non-existent anyway.
> 
> Fixes: 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
> Signed-off-by: Nicolai Stange 

Applied to drm-misc with Dave's irc ack, thanks for your patch.
-Daniel

> ---
> Tested on top of next-20161202.
> That 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
> is in next since 20161201.
> 
>  drivers/gpu/drm/radeon/radeon_device.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index 60a8920..8a1df2a 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -1949,9 +1949,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
>   rdev->debugfs_count = i;
>  #if defined(CONFIG_DEBUG_FS)
>   drm_debugfs_create_files(files, nfiles,
> -  rdev->ddev->control->debugfs_root,
> -  rdev->ddev->control);
> - drm_debugfs_create_files(files, nfiles,
>rdev->ddev->primary->debugfs_root,
>rdev->ddev->primary);
>  #endif
> @@ -1966,9 +1963,6 @@ static void radeon_debugfs_remove_files(struct 
> radeon_device *rdev)
>   for (i = 0; i < rdev->debugfs_count; i++) {
>   drm_debugfs_remove_files(rdev->debugfs[i].files,
>rdev->debugfs[i].num_files,
> -  rdev->ddev->control);
> - drm_debugfs_remove_files(rdev->debugfs[i].files,
> -  rdev->debugfs[i].num_files,
>rdev->ddev->primary);
>   }
>  #endif
> -- 
> 2.10.2
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 1/2 v2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Pan Bian
Variable ret is reset in the loop, and its value will be 0 during the 
after repeat of the loop. Then, if pci_alloc_consistent() returns NULL, 
the return value is 0. 0 means no error, which may make it impossible 
for the callers of beiscsi_create_cqs() to detect the memory allocation 
error. This patch fixes the bug, assigning "-ENOMEM" to ret on the path 
that the call to pci_alloc_consistent() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188941

Signed-off-by: Pan Bian 
---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index d9239c2..b6c5791 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3113,8 +3113,10 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
cq_vaddress = pci_alloc_consistent(phba->pcidev,
   num_cq_pages * PAGE_SIZE,
   );
-   if (!cq_vaddress)
+   if (!cq_vaddress) {
+   ret = -ENOMEM;
goto create_cq_error;
+   }
 
ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress);
-- 
1.9.1




[PATCH 1/2 v2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Pan Bian
Variable ret is reset in the loop, and its value will be 0 during the 
after repeat of the loop. Then, if pci_alloc_consistent() returns NULL, 
the return value is 0. 0 means no error, which may make it impossible 
for the callers of beiscsi_create_cqs() to detect the memory allocation 
error. This patch fixes the bug, assigning "-ENOMEM" to ret on the path 
that the call to pci_alloc_consistent() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188941

Signed-off-by: Pan Bian 
---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index d9239c2..b6c5791 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3113,8 +3113,10 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
cq_vaddress = pci_alloc_consistent(phba->pcidev,
   num_cq_pages * PAGE_SIZE,
   );
-   if (!cq_vaddress)
+   if (!cq_vaddress) {
+   ret = -ENOMEM;
goto create_cq_error;
+   }
 
ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress);
-- 
1.9.1




Re: [PATCH v3 4/7] PWM: add pwm driver for stm32 plaftorm

2016-12-04 Thread Thierry Reding
On Fri, Dec 02, 2016 at 11:17:19AM +0100, Benjamin Gaignard wrote:
> This driver add support for pwm driver on stm32 platform.

"adds". Also please use PWM in prose because it's an abbreviation.

> The SoC have multiple instances of the hardware IP and each
> of them could have small differences: number of channels,
> complementary output, counter register size...
> Use DT parameters to handle those differentes configuration

"different configurations"

> 
> version 2:
> - only keep one comptatible
> - use DT paramaters to discover hardware block configuration

"parameters"

> 
> Signed-off-by: Benjamin Gaignard 
> ---
>  drivers/pwm/Kconfig |   8 ++
>  drivers/pwm/Makefile|   1 +
>  drivers/pwm/pwm-stm32.c | 285 
> 
>  3 files changed, 294 insertions(+)
>  create mode 100644 drivers/pwm/pwm-stm32.c
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index bf01288..a89fdba 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -388,6 +388,14 @@ config PWM_STI
> To compile this driver as a module, choose M here: the module
> will be called pwm-sti.
>  
> +config PWM_STM32
> + bool "STMicroelectronics STM32 PWM"
> + depends on ARCH_STM32
> + depends on OF
> + select MFD_STM32_GP_TIMER

Should that be a "depends on"?

> + help
> +   Generic PWM framework driver for STM32 SoCs.
> +
>  config PWM_STMPE
>   bool "STMPE expander PWM export"
>   depends on MFD_STMPE
> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
> index 1194c54..5aa9308 100644
> --- a/drivers/pwm/Makefile
> +++ b/drivers/pwm/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_PWM_ROCKCHIP)  += pwm-rockchip.o
>  obj-$(CONFIG_PWM_SAMSUNG)+= pwm-samsung.o
>  obj-$(CONFIG_PWM_SPEAR)  += pwm-spear.o
>  obj-$(CONFIG_PWM_STI)+= pwm-sti.o
> +obj-$(CONFIG_PWM_STM32)  += pwm-stm32.o
>  obj-$(CONFIG_PWM_STMPE)  += pwm-stmpe.o
>  obj-$(CONFIG_PWM_SUN4I)  += pwm-sun4i.o
>  obj-$(CONFIG_PWM_TEGRA)  += pwm-tegra.o
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> new file mode 100644
> index 000..a362f63
> --- /dev/null
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -0,0 +1,285 @@
> +/*
> + * Copyright (C) STMicroelectronics 2016
> + * Author:  Gerald Baeza 

Could use a blank line between the above. Also, please use a single
space after : for consistency.

> + * License terms:  GNU General Public License (GPL), version 2

Here too.

> + *
> + * Inspired by timer-stm32.c from Maxime Coquelin
> + * pwm-atmel.c from Bo Shen
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 

Please sort these alphabetically.

> +
> +#include 
> +
> +#define DRIVER_NAME "stm32-pwm"
> +
> +#define CAP_COMPLEMENTARYBIT(0)
> +#define CAP_32BITS_COUNTER   BIT(1)
> +#define CAP_BREAKINPUT   BIT(2)
> +#define CAP_BREAKINPUT_POLARITY BIT(3)

Just make these boolean. Makes the conditionals a lot simpler to read.

> +
> +struct stm32_pwm_dev {

No need for the _dev suffix.

> + struct device *dev;
> + struct clk *clk;
> + struct regmap *regmap;
> + struct pwm_chip chip;

It's slightly more efficient to put this as first field because then
to_stm32_pwm() becomes a no-op.

> + int caps;
> + int npwm;

unsigned int, please.

> + u32 polarity;

Maybe use a prefix here to stress that it is the polarity of the
complementary output. Otherwise one might take it for the PWM signal's
polarity that's already part of the PWM state.

> +};
> +
> +#define to_stm32_pwm_dev(x) container_of(chip, struct stm32_pwm_dev, chip)

Please turn this into a static inline.

> +
> +static u32 __active_channels(struct stm32_pwm_dev *pwm_dev)

No need for a __ prefix.

> +{
> + u32 ccer;
> +
> + regmap_read(pwm_dev->regmap, TIM_CCER, );
> +
> + return ccer & TIM_CCER_CCXE;
> +}
> +
> +static int write_ccrx(struct stm32_pwm_dev *dev, struct pwm_device *pwm,
> +   u32 ccr)

u32 value, perhaps? I first mistook this to be a register offset.

> +{
> + switch (pwm->hwpwm) {
> + case 0:
> + return regmap_write(dev->regmap, TIM_CCR1, ccr);
> + case 1:
> + return regmap_write(dev->regmap, TIM_CCR2, ccr);
> + case 2:
> + return regmap_write(dev->regmap, TIM_CCR3, ccr);
> + case 3:
> + return regmap_write(dev->regmap, TIM_CCR4, ccr);
> + }
> + return -EINVAL;
> +}
> +
> +static int stm32_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> + int duty_ns, int period_ns)

Please implement this as an atomic PWM driver, I don't want new drivers
to use the legacy callbacks.

> +{
> + struct stm32_pwm_dev *dev = to_stm32_pwm_dev(chip);

I think something like "stm", or "priv" would be more appropriate here.
If you ever need access to a struct device, you'll be 

Re: [PATCH v3 4/7] PWM: add pwm driver for stm32 plaftorm

2016-12-04 Thread Thierry Reding
On Fri, Dec 02, 2016 at 11:17:19AM +0100, Benjamin Gaignard wrote:
> This driver add support for pwm driver on stm32 platform.

"adds". Also please use PWM in prose because it's an abbreviation.

> The SoC have multiple instances of the hardware IP and each
> of them could have small differences: number of channels,
> complementary output, counter register size...
> Use DT parameters to handle those differentes configuration

"different configurations"

> 
> version 2:
> - only keep one comptatible
> - use DT paramaters to discover hardware block configuration

"parameters"

> 
> Signed-off-by: Benjamin Gaignard 
> ---
>  drivers/pwm/Kconfig |   8 ++
>  drivers/pwm/Makefile|   1 +
>  drivers/pwm/pwm-stm32.c | 285 
> 
>  3 files changed, 294 insertions(+)
>  create mode 100644 drivers/pwm/pwm-stm32.c
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index bf01288..a89fdba 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -388,6 +388,14 @@ config PWM_STI
> To compile this driver as a module, choose M here: the module
> will be called pwm-sti.
>  
> +config PWM_STM32
> + bool "STMicroelectronics STM32 PWM"
> + depends on ARCH_STM32
> + depends on OF
> + select MFD_STM32_GP_TIMER

Should that be a "depends on"?

> + help
> +   Generic PWM framework driver for STM32 SoCs.
> +
>  config PWM_STMPE
>   bool "STMPE expander PWM export"
>   depends on MFD_STMPE
> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
> index 1194c54..5aa9308 100644
> --- a/drivers/pwm/Makefile
> +++ b/drivers/pwm/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_PWM_ROCKCHIP)  += pwm-rockchip.o
>  obj-$(CONFIG_PWM_SAMSUNG)+= pwm-samsung.o
>  obj-$(CONFIG_PWM_SPEAR)  += pwm-spear.o
>  obj-$(CONFIG_PWM_STI)+= pwm-sti.o
> +obj-$(CONFIG_PWM_STM32)  += pwm-stm32.o
>  obj-$(CONFIG_PWM_STMPE)  += pwm-stmpe.o
>  obj-$(CONFIG_PWM_SUN4I)  += pwm-sun4i.o
>  obj-$(CONFIG_PWM_TEGRA)  += pwm-tegra.o
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> new file mode 100644
> index 000..a362f63
> --- /dev/null
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -0,0 +1,285 @@
> +/*
> + * Copyright (C) STMicroelectronics 2016
> + * Author:  Gerald Baeza 

Could use a blank line between the above. Also, please use a single
space after : for consistency.

> + * License terms:  GNU General Public License (GPL), version 2

Here too.

> + *
> + * Inspired by timer-stm32.c from Maxime Coquelin
> + * pwm-atmel.c from Bo Shen
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 

Please sort these alphabetically.

> +
> +#include 
> +
> +#define DRIVER_NAME "stm32-pwm"
> +
> +#define CAP_COMPLEMENTARYBIT(0)
> +#define CAP_32BITS_COUNTER   BIT(1)
> +#define CAP_BREAKINPUT   BIT(2)
> +#define CAP_BREAKINPUT_POLARITY BIT(3)

Just make these boolean. Makes the conditionals a lot simpler to read.

> +
> +struct stm32_pwm_dev {

No need for the _dev suffix.

> + struct device *dev;
> + struct clk *clk;
> + struct regmap *regmap;
> + struct pwm_chip chip;

It's slightly more efficient to put this as first field because then
to_stm32_pwm() becomes a no-op.

> + int caps;
> + int npwm;

unsigned int, please.

> + u32 polarity;

Maybe use a prefix here to stress that it is the polarity of the
complementary output. Otherwise one might take it for the PWM signal's
polarity that's already part of the PWM state.

> +};
> +
> +#define to_stm32_pwm_dev(x) container_of(chip, struct stm32_pwm_dev, chip)

Please turn this into a static inline.

> +
> +static u32 __active_channels(struct stm32_pwm_dev *pwm_dev)

No need for a __ prefix.

> +{
> + u32 ccer;
> +
> + regmap_read(pwm_dev->regmap, TIM_CCER, );
> +
> + return ccer & TIM_CCER_CCXE;
> +}
> +
> +static int write_ccrx(struct stm32_pwm_dev *dev, struct pwm_device *pwm,
> +   u32 ccr)

u32 value, perhaps? I first mistook this to be a register offset.

> +{
> + switch (pwm->hwpwm) {
> + case 0:
> + return regmap_write(dev->regmap, TIM_CCR1, ccr);
> + case 1:
> + return regmap_write(dev->regmap, TIM_CCR2, ccr);
> + case 2:
> + return regmap_write(dev->regmap, TIM_CCR3, ccr);
> + case 3:
> + return regmap_write(dev->regmap, TIM_CCR4, ccr);
> + }
> + return -EINVAL;
> +}
> +
> +static int stm32_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> + int duty_ns, int period_ns)

Please implement this as an atomic PWM driver, I don't want new drivers
to use the legacy callbacks.

> +{
> + struct stm32_pwm_dev *dev = to_stm32_pwm_dev(chip);

I think something like "stm", or "priv" would be more appropriate here.
If you ever need access to a struct device, you'll be hard-pressed to
find a good name for it.

> + 

[PATCH 2/2 v2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Pan Bian
Variable ret is reset in the loop, and its value will be 0 during the
after repeat of the loop. Then, if pci_alloc_consistent() returns NULL, 
the return value is 0. 0 means no error, which may make it impossible 
for the callers of beiscsi_create_eqs() to detect the memory allocation 
error. This patch fixes the bug, assigning "-ENOMEM" to ret on the path 
that the call to pci_alloc_consistent() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188951

Signed-off-by: Pan Bian 
---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b6c5791..b5112d6 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3049,8 +3049,10 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
eq_vaddress = pci_alloc_consistent(phba->pcidev,
   num_eq_pages * PAGE_SIZE,
   );
-   if (!eq_vaddress)
+   if (!eq_vaddress) {
+   ret = -ENOMEM;
goto create_eq_error;
+   }
 
mem->va = eq_vaddress;
ret = be_fill_queue(eq, phba->params.num_eq_entries,
-- 
1.9.1




[PATCH 2/2 v2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Pan Bian
Variable ret is reset in the loop, and its value will be 0 during the
after repeat of the loop. Then, if pci_alloc_consistent() returns NULL, 
the return value is 0. 0 means no error, which may make it impossible 
for the callers of beiscsi_create_eqs() to detect the memory allocation 
error. This patch fixes the bug, assigning "-ENOMEM" to ret on the path 
that the call to pci_alloc_consistent() fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188951

Signed-off-by: Pan Bian 
---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b6c5791..b5112d6 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3049,8 +3049,10 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
eq_vaddress = pci_alloc_consistent(phba->pcidev,
   num_eq_pages * PAGE_SIZE,
   );
-   if (!eq_vaddress)
+   if (!eq_vaddress) {
+   ret = -ENOMEM;
goto create_eq_error;
+   }
 
mem->va = eq_vaddress;
ret = be_fill_queue(eq, phba->params.num_eq_entries,
-- 
1.9.1




Re: net: use-after-free in worker_thread

2016-12-04 Thread Herbert Xu
On Sat, Dec 03, 2016 at 05:49:07AM -0800, Eric Dumazet wrote:
>
> @@ -600,6 +600,7 @@ static int __netlink_create(struct net *net, struct 
> socket *sock,
>   }
>   init_waitqueue_head(>wait);
>  
> + sock_set_flag(sk, SOCK_RCU_FREE);
>   sk->sk_destruct = netlink_sock_destruct;
>   sk->sk_protocol = protocol;
>   return 0;

It's not necessarily a big deal but I just wanted to point out
that SOCK_RCU_FREE is not equivalent to the call_rcu thing that
netlink does.  The latter only does the RCU deferral for the socket
release call which is the only place where it's needed while
SOCK_RCU_FREE will force every path to do an RCU deferral.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: net: use-after-free in worker_thread

2016-12-04 Thread Herbert Xu
On Sat, Dec 03, 2016 at 05:49:07AM -0800, Eric Dumazet wrote:
>
> @@ -600,6 +600,7 @@ static int __netlink_create(struct net *net, struct 
> socket *sock,
>   }
>   init_waitqueue_head(>wait);
>  
> + sock_set_flag(sk, SOCK_RCU_FREE);
>   sk->sk_destruct = netlink_sock_destruct;
>   sk->sk_protocol = protocol;
>   return 0;

It's not necessarily a big deal but I just wanted to point out
that SOCK_RCU_FREE is not equivalent to the call_rcu thing that
netlink does.  The latter only does the RCU deferral for the socket
release call which is the only place where it's needed while
SOCK_RCU_FREE will force every path to do an RCU deferral.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: net: use-after-free in worker_thread

2016-12-04 Thread Herbert Xu
On Sat, Dec 03, 2016 at 10:14:48AM -0800, Cong Wang wrote:
> On Sat, Dec 3, 2016 at 9:41 AM, Cong Wang  wrote:
> > On Sat, Dec 3, 2016 at 4:56 AM, Andrey Konovalov  
> > wrote:
> >> Hi!
> >>
> >> I'm seeing lots of the following error reports while running the
> >> syzkaller fuzzer.
> >>
> >> Reports appeared when I updated to 3c49de52 (Dec 2) from 2caceb32 (Dec 1).
> >>
> >> ==
> >> BUG: KASAN: use-after-free in worker_thread+0x17d8/0x18a0
> >> Read of size 8 at addr 880067f3ecd8 by task kworker/3:1/774
> >>
> >> page:ea00019fce00 count:1 mapcount:0 mapping:  (null)
> >> index:0x880067f39c10 compound_mapcount: 0
> >> flags: 0x5004080(slab|head)
> >> page dumped because: kasan: bad access detected
> >>
> >> CPU: 3 PID: 774 Comm: kworker/3:1 Not tainted 4.9.0-rc7+ #66
> >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 
> >> 01/01/2011
> >>  88006c267838 81f882da 6c25e338 11000d84ce9a
> >>  ed000d84ce92 88006c25e340 41b58ab3 8541e198
> >>  81f88048 0001 41b58ab3 853d3ee8
> >> Call Trace:
> >>  [< inline >] __dump_stack lib/dump_stack.c:15
> >>  [] dump_stack+0x292/0x398 lib/dump_stack.c:51
> >>  [< inline >] describe_address mm/kasan/report.c:262
> >>  [] kasan_report_error+0x121/0x560 mm/kasan/report.c:368
> >>  [< inline >] kasan_report mm/kasan/report.c:390
> >>  [] __asan_report_load8_noabort+0x3e/0x40
> >> mm/kasan/report.c:411
> >>  [] worker_thread+0x17d8/0x18a0 kernel/workqueue.c:2228
> >>  [] kthread+0x323/0x3e0 kernel/kthread.c:209
> >>  [] ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:433
> >
> > Heck... this is the pending work vs. sk_destruct() race. :-/
> > We can't wait for the work in RCU callback, let me think about it...

Sorry, my patch was obviously crap as it was trying to delay the
freeing of a socket from sk_destruct which can't be done.

> Please try the attached patch, I only did compile test, I can't access
> my desktop now, so can't do further tests.

Thanks for the patch.  It'll obviously work but I wanted avoid that
because it penalises the common path for the rare case.

Andrey, please try this patch and let me know if it's any better.

---8<---
Subject: netlink: Do not schedule work from sk_destruct

It is wrong to schedule a work from sk_destruct using the socket
as the memory reserve because the socket will be freed immediately
after the return from sk_destruct.

Instead we should do the deferral prior to sk_free.

This patch does just that.

Fixes: 707693c8a498 ("netlink: Call cb->done from a worker thread")
Signed-off-by: Herbert Xu 

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 602e5eb..8a642c5 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -322,11 +322,13 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, 
struct sock *sk)
sk_mem_charge(sk, skb->truesize);
 }
 
-static void __netlink_sock_destruct(struct sock *sk)
+static void netlink_sock_destruct(struct sock *sk)
 {
struct netlink_sock *nlk = nlk_sk(sk);
 
if (nlk->cb_running) {
+   if (nlk->cb.done)
+   nlk->cb.done(>cb);
module_put(nlk->cb.module);
kfree_skb(nlk->cb.skb);
}
@@ -348,21 +350,7 @@ static void netlink_sock_destruct_work(struct work_struct 
*work)
struct netlink_sock *nlk = container_of(work, struct netlink_sock,
work);
 
-   nlk->cb.done(>cb);
-   __netlink_sock_destruct(>sk);
-}
-
-static void netlink_sock_destruct(struct sock *sk)
-{
-   struct netlink_sock *nlk = nlk_sk(sk);
-
-   if (nlk->cb_running && nlk->cb.done) {
-   INIT_WORK(>work, netlink_sock_destruct_work);
-   schedule_work(>work);
-   return;
-   }
-
-   __netlink_sock_destruct(sk);
+   sk_free(>sk);
 }
 
 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
@@ -664,11 +652,17 @@ static int netlink_create(struct net *net, struct socket 
*sock, int protocol,
goto out;
 }
 
-static void deferred_put_nlk_sk(struct rcu_head *head)
+static void deferred_free_nlk_sk(struct rcu_head *head)
 {
struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
 
-   sock_put(>sk);
+   if (nlk->cb_running && nlk->cb.done) {
+   INIT_WORK(>work, netlink_sock_destruct_work);
+   schedule_work(>work);
+   return;
+   }
+
+   sk_free(>sk);
 }
 
 static int netlink_release(struct socket *sock)
@@ -743,7 +737,9 @@ static int netlink_release(struct socket *sock)
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), _proto, -1);
local_bh_enable();
-   call_rcu(>rcu, 

Re: net: use-after-free in worker_thread

2016-12-04 Thread Herbert Xu
On Sat, Dec 03, 2016 at 10:14:48AM -0800, Cong Wang wrote:
> On Sat, Dec 3, 2016 at 9:41 AM, Cong Wang  wrote:
> > On Sat, Dec 3, 2016 at 4:56 AM, Andrey Konovalov  
> > wrote:
> >> Hi!
> >>
> >> I'm seeing lots of the following error reports while running the
> >> syzkaller fuzzer.
> >>
> >> Reports appeared when I updated to 3c49de52 (Dec 2) from 2caceb32 (Dec 1).
> >>
> >> ==
> >> BUG: KASAN: use-after-free in worker_thread+0x17d8/0x18a0
> >> Read of size 8 at addr 880067f3ecd8 by task kworker/3:1/774
> >>
> >> page:ea00019fce00 count:1 mapcount:0 mapping:  (null)
> >> index:0x880067f39c10 compound_mapcount: 0
> >> flags: 0x5004080(slab|head)
> >> page dumped because: kasan: bad access detected
> >>
> >> CPU: 3 PID: 774 Comm: kworker/3:1 Not tainted 4.9.0-rc7+ #66
> >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 
> >> 01/01/2011
> >>  88006c267838 81f882da 6c25e338 11000d84ce9a
> >>  ed000d84ce92 88006c25e340 41b58ab3 8541e198
> >>  81f88048 0001 41b58ab3 853d3ee8
> >> Call Trace:
> >>  [< inline >] __dump_stack lib/dump_stack.c:15
> >>  [] dump_stack+0x292/0x398 lib/dump_stack.c:51
> >>  [< inline >] describe_address mm/kasan/report.c:262
> >>  [] kasan_report_error+0x121/0x560 mm/kasan/report.c:368
> >>  [< inline >] kasan_report mm/kasan/report.c:390
> >>  [] __asan_report_load8_noabort+0x3e/0x40
> >> mm/kasan/report.c:411
> >>  [] worker_thread+0x17d8/0x18a0 kernel/workqueue.c:2228
> >>  [] kthread+0x323/0x3e0 kernel/kthread.c:209
> >>  [] ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:433
> >
> > Heck... this is the pending work vs. sk_destruct() race. :-/
> > We can't wait for the work in RCU callback, let me think about it...

Sorry, my patch was obviously crap as it was trying to delay the
freeing of a socket from sk_destruct which can't be done.

> Please try the attached patch, I only did compile test, I can't access
> my desktop now, so can't do further tests.

Thanks for the patch.  It'll obviously work but I wanted avoid that
because it penalises the common path for the rare case.

Andrey, please try this patch and let me know if it's any better.

---8<---
Subject: netlink: Do not schedule work from sk_destruct

It is wrong to schedule a work from sk_destruct using the socket
as the memory reserve because the socket will be freed immediately
after the return from sk_destruct.

Instead we should do the deferral prior to sk_free.

This patch does just that.

Fixes: 707693c8a498 ("netlink: Call cb->done from a worker thread")
Signed-off-by: Herbert Xu 

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 602e5eb..8a642c5 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -322,11 +322,13 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, 
struct sock *sk)
sk_mem_charge(sk, skb->truesize);
 }
 
-static void __netlink_sock_destruct(struct sock *sk)
+static void netlink_sock_destruct(struct sock *sk)
 {
struct netlink_sock *nlk = nlk_sk(sk);
 
if (nlk->cb_running) {
+   if (nlk->cb.done)
+   nlk->cb.done(>cb);
module_put(nlk->cb.module);
kfree_skb(nlk->cb.skb);
}
@@ -348,21 +350,7 @@ static void netlink_sock_destruct_work(struct work_struct 
*work)
struct netlink_sock *nlk = container_of(work, struct netlink_sock,
work);
 
-   nlk->cb.done(>cb);
-   __netlink_sock_destruct(>sk);
-}
-
-static void netlink_sock_destruct(struct sock *sk)
-{
-   struct netlink_sock *nlk = nlk_sk(sk);
-
-   if (nlk->cb_running && nlk->cb.done) {
-   INIT_WORK(>work, netlink_sock_destruct_work);
-   schedule_work(>work);
-   return;
-   }
-
-   __netlink_sock_destruct(sk);
+   sk_free(>sk);
 }
 
 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
@@ -664,11 +652,17 @@ static int netlink_create(struct net *net, struct socket 
*sock, int protocol,
goto out;
 }
 
-static void deferred_put_nlk_sk(struct rcu_head *head)
+static void deferred_free_nlk_sk(struct rcu_head *head)
 {
struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
 
-   sock_put(>sk);
+   if (nlk->cb_running && nlk->cb.done) {
+   INIT_WORK(>work, netlink_sock_destruct_work);
+   schedule_work(>work);
+   return;
+   }
+
+   sk_free(>sk);
 }
 
 static int netlink_release(struct socket *sock)
@@ -743,7 +737,9 @@ static int netlink_release(struct socket *sock)
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), _proto, -1);
local_bh_enable();
-   call_rcu(>rcu, deferred_put_nlk_sk);
+
+   if (atomic_dec_and_test(>sk_refcnt))
+

RE: [PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread Qiang Zhao
This patch depends on the patchset of QEIC as following links:
http://patchwork.ozlabs.org/patch/675925/
http://patchwork.ozlabs.org/patch/675926/
http://patchwork.ozlabs.org/patch/675927/
http://patchwork.ozlabs.org/patch/675928/

> -Original Message-
> From: kbuild test robot [mailto:l...@intel.com]
> Sent: Monday, December 05, 2016 3:00 PM
> To: Qiang Zhao 
> Cc: kbuild-...@01.org; o...@buserror.net; ba...@kernel.org;
> gre...@linuxfoundation.org; Xiaobo Xie ; linux-
> ker...@vger.kernel.org; linuxppc-...@lists.ozlabs.org; Qiang Zhao
> 
> Subject: Re: [PATCH v9] QE: remove PPCisms for QE
> 
> Hi Zhao,
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.9-rc8]
> [cannot apply to next-20161202]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system]
> 
> url:https://github.com/0day-ci/linux/commits/Zhao-Qiang/QE-remove-
> PPCisms-for-QE/20161205-131352
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
> 
> All errors (new ones prefixed by >>):
> 
>In file included from drivers/soc/fsl/qe/qe_ic.c:31:0:
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_ipic':
> >> include/soc/fsl/qe/qe_ic.h:86:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h:86:21: note: each undeclared identifier is 
> reported
> only once for each function it appears in
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_ipic':
>include/soc/fsl/qe/qe_ic.h:95:21: error: 'NO_IRQ' undeclared (first use in 
> this
> function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_mpic':
>include/soc/fsl/qe/qe_ic.h:105:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_mpic':
>include/soc/fsl/qe/qe_ic.h:117:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_muxed_mpic':
>include/soc/fsl/qe/qe_ic.h:130:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq == NO_IRQ)
> ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_read':
> >> drivers/soc/fsl/qe/qe_ic.c:180:9: error: implicit declaration of function
> 'in_be32' [-Werror=implicit-function-declaration]
>  return in_be32(base + (reg >> 2));
> ^~~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_write':
> >> drivers/soc/fsl/qe/qe_ic.c:186:2: error: implicit declaration of function
> 'out_be32' [-Werror=implicit-function-declaration]
>  out_be32(base + (reg >> 2), value);
>  ^~~~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_low_irq':
> >> drivers/soc/fsl/qe/qe_ic.c:299:10: error: 'NO_IRQ' undeclared (first use in
> this function)
>   return NO_IRQ;
>  ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_high_irq':
>drivers/soc/fsl/qe/qe_ic.c:315:10: error: 'NO_IRQ' undeclared (first use 
> in this
> function)
>   return NO_IRQ;
>  ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_init':
>drivers/soc/fsl/qe/qe_ic.c:350:25: error: 'NO_IRQ' undeclared (first use 
> in this
> function)
>  if (qe_ic->virq_low == NO_IRQ) {
> ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_set_highest_priority':
> >> drivers/soc/fsl/qe/qe_ic.c:392:21: error: implicit declaration of function
> 'virq_to_hw' [-Werror=implicit-function-declaration]
>  unsigned int src = virq_to_hw(virq);
> ^~
>cc1: some warnings being treated as errors
> 
> vim +/in_be32 +180 drivers/soc/fsl/qe/qe_ic.c
> 
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 174
>   .pri_reg = QEIC_CIPYCC,
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 175
>   },
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 176  };
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 177
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 178
> static inline u32 qe_ic_read(volatile __be32  __iomem * base, unsigned int 
> reg)
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 179  {
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 
> @180
>   return in_be32(base + (reg >> 2));
> 

RE: [PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread Qiang Zhao
This patch depends on the patchset of QEIC as following links:
http://patchwork.ozlabs.org/patch/675925/
http://patchwork.ozlabs.org/patch/675926/
http://patchwork.ozlabs.org/patch/675927/
http://patchwork.ozlabs.org/patch/675928/

> -Original Message-
> From: kbuild test robot [mailto:l...@intel.com]
> Sent: Monday, December 05, 2016 3:00 PM
> To: Qiang Zhao 
> Cc: kbuild-...@01.org; o...@buserror.net; ba...@kernel.org;
> gre...@linuxfoundation.org; Xiaobo Xie ; linux-
> ker...@vger.kernel.org; linuxppc-...@lists.ozlabs.org; Qiang Zhao
> 
> Subject: Re: [PATCH v9] QE: remove PPCisms for QE
> 
> Hi Zhao,
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.9-rc8]
> [cannot apply to next-20161202]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system]
> 
> url:https://github.com/0day-ci/linux/commits/Zhao-Qiang/QE-remove-
> PPCisms-for-QE/20161205-131352
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
> 
> All errors (new ones prefixed by >>):
> 
>In file included from drivers/soc/fsl/qe/qe_ic.c:31:0:
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_ipic':
> >> include/soc/fsl/qe/qe_ic.h:86:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h:86:21: note: each undeclared identifier is 
> reported
> only once for each function it appears in
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_ipic':
>include/soc/fsl/qe/qe_ic.h:95:21: error: 'NO_IRQ' undeclared (first use in 
> this
> function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_mpic':
>include/soc/fsl/qe/qe_ic.h:105:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_mpic':
>include/soc/fsl/qe/qe_ic.h:117:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq != NO_IRQ)
> ^~
>include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_muxed_mpic':
>include/soc/fsl/qe/qe_ic.h:130:21: error: 'NO_IRQ' undeclared (first use in
> this function)
>  if (cascade_irq == NO_IRQ)
> ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_read':
> >> drivers/soc/fsl/qe/qe_ic.c:180:9: error: implicit declaration of function
> 'in_be32' [-Werror=implicit-function-declaration]
>  return in_be32(base + (reg >> 2));
> ^~~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_write':
> >> drivers/soc/fsl/qe/qe_ic.c:186:2: error: implicit declaration of function
> 'out_be32' [-Werror=implicit-function-declaration]
>  out_be32(base + (reg >> 2), value);
>  ^~~~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_low_irq':
> >> drivers/soc/fsl/qe/qe_ic.c:299:10: error: 'NO_IRQ' undeclared (first use in
> this function)
>   return NO_IRQ;
>  ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_high_irq':
>drivers/soc/fsl/qe/qe_ic.c:315:10: error: 'NO_IRQ' undeclared (first use 
> in this
> function)
>   return NO_IRQ;
>  ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_init':
>drivers/soc/fsl/qe/qe_ic.c:350:25: error: 'NO_IRQ' undeclared (first use 
> in this
> function)
>  if (qe_ic->virq_low == NO_IRQ) {
> ^~
>drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_set_highest_priority':
> >> drivers/soc/fsl/qe/qe_ic.c:392:21: error: implicit declaration of function
> 'virq_to_hw' [-Werror=implicit-function-declaration]
>  unsigned int src = virq_to_hw(virq);
> ^~
>cc1: some warnings being treated as errors
> 
> vim +/in_be32 +180 drivers/soc/fsl/qe/qe_ic.c
> 
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 174
>   .pri_reg = QEIC_CIPYCC,
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 175
>   },
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 176  };
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 177
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 178
> static inline u32 qe_ic_read(volatile __be32  __iomem * base, unsigned int 
> reg)
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  
> 179  {
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 
> @180
>   return in_be32(base + (reg >> 2));
> 98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 

Re: [PATCH 1/1] mtd: ubi: fix improper return value

2016-12-04 Thread Artem Bityutskiy
On Sun, 2016-12-04 at 21:52 +0100, Richard Weinberger wrote:
> We should better think about how to get ubi_self_check_all_ff()
> fixed.
> When enabled on a modern NAND, vmalloc() is likely to fail now and
> then
> since len is the erase block size and can be up to a few mega bytes.

I did an attempt to switch from virtually continuous buffers to an
array of page pointers, but never finished.


Re: [PATCH 1/1] mtd: ubi: fix improper return value

2016-12-04 Thread Artem Bityutskiy
On Sun, 2016-12-04 at 21:52 +0100, Richard Weinberger wrote:
> We should better think about how to get ubi_self_check_all_ff()
> fixed.
> When enabled on a modern NAND, vmalloc() is likely to fail now and
> then
> since len is the erase block size and can be up to a few mega bytes.

I did an attempt to switch from virtually continuous buffers to an
array of page pointers, but never finished.


Re: [PATCH] ARM: dts: imx7d: fix LCDIF clock assignment

2016-12-04 Thread Uwe Kleine-König
Hello Stefan,

On Sun, Dec 04, 2016 at 05:26:58PM -0800, Stefan Agner wrote:
> Since this fixes a kernel freeze, is there a chance to get this still in
> 4.9?

a Fixes:-Line would be nice then.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH] ARM: dts: imx7d: fix LCDIF clock assignment

2016-12-04 Thread Uwe Kleine-König
Hello Stefan,

On Sun, Dec 04, 2016 at 05:26:58PM -0800, Stefan Agner wrote:
> Since this fixes a kernel freeze, is there a chance to get this still in
> 4.9?

a Fixes:-Line would be nice then.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


[PATCH v1 2/2] crypto: mediatek - add DT bindings documentation

2016-12-04 Thread Ryder Lee
Add DT bindings documentation for the crypto driver

Signed-off-by: Ryder Lee 
---
 .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt

diff --git a/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt 
b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
new file mode 100644
index 000..8b1db08
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
@@ -0,0 +1,32 @@
+MediaTek cryptographic accelerators
+
+Required properties:
+- compatible: Should be "mediatek,mt7623-crypto"
+- reg: Address and length of the register set for the device
+- interrupts: Should contain the five crypto engines interrupts in numeric
+   order. These are global system and four descriptor rings.
+- clocks: the clock used by the core
+- clock-names: the names of the clock listed in the clocks property. These are
+   "ethif", "cryp"
+- power-domains: Must contain a reference to the PM domain.
+
+
+Optional properties:
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+
+
+Example:
+   crypto: crypto@1b24 {
+   compatible = "mediatek,mt7623-crypto";
+   reg = <0 0x1b24 0 0x2>;
+   interrupts = ,
+,
+,
+,
+;
+   clocks = < CLK_TOP_ETHIF_SEL>,
+< CLK_ETHSYS_CRYPTO>;
+   clock-names = "ethif","cryp";
+   power-domains = < MT2701_POWER_DOMAIN_ETH>;
+   };
-- 
1.9.1



[PATCH v1 1/2] Add crypto driver support for some MediaTek chips

2016-12-04 Thread Ryder Lee
This adds support for the MediaTek hardware accelerator on
mt7623/mt2701/mt8521p SoC.

This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.

Signed-off-by: Ryder Lee 
---
 drivers/crypto/Kconfig |   17 +
 drivers/crypto/Makefile|1 +
 drivers/crypto/mediatek/Makefile   |2 +
 drivers/crypto/mediatek/mtk-aes.c  |  763 +
 drivers/crypto/mediatek/mtk-platform.c |  580 +
 drivers/crypto/mediatek/mtk-platform.h |  235 ++
 drivers/crypto/mediatek/mtk-regs.h |  194 +
 drivers/crypto/mediatek/mtk-sha.c  | 1423 
 8 files changed, 3215 insertions(+)
 create mode 100644 drivers/crypto/mediatek/Makefile
 create mode 100644 drivers/crypto/mediatek/mtk-aes.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.h
 create mode 100644 drivers/crypto/mediatek/mtk-regs.h
 create mode 100644 drivers/crypto/mediatek/mtk-sha.c

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 4d2b81f..ad0a00b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -553,6 +553,23 @@ config CRYPTO_DEV_ROCKCHIP
  This driver interfaces with the hardware crypto accelerator.
  Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode.
 
+config CRYPTO_DEV_MEDIATEK
+   tristate "MediaTek's Cryptographic Engine driver"
+   depends on ARM && (ARCH_MEDIATEK || COMPILE_TEST)
+   select NEON
+   select KERNEL_MODE_NEON
+   select ARM_CRYPTO
+   select CRYPTO_AES
+   select CRYPTO_BLKCIPHER
+   select CRYPTO_SHA1_ARM_NEON
+   select CRYPTO_SHA256_ARM
+   select CRYPTO_SHA512_ARM
+   select CRYPTO_HMAC
+   help
+ This driver allows you to utilize the hardware crypto accelerator
+ which can be found on the MT7623 MT2701, MT8521p, etc 
+ Select this if you want to use it for AES/SHA1/SHA2 algorithms.
+
 source "drivers/crypto/chelsio/Kconfig"
 
 endif # CRYPTO_HW
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index ad7250f..272b51a 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_CRYPTO_DEV_IMGTEC_HASH) += img-hash.o
 obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
 obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o
 obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell/
+obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mediatek/
 obj-$(CONFIG_CRYPTO_DEV_MXS_DCP) += mxs-dcp.o
 obj-$(CONFIG_CRYPTO_DEV_NIAGARA2) += n2_crypto.o
 n2_crypto-y := n2_core.o n2_asm.o
diff --git a/drivers/crypto/mediatek/Makefile b/drivers/crypto/mediatek/Makefile
new file mode 100644
index 000..187be79
--- /dev/null
+++ b/drivers/crypto/mediatek/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mtk-crypto.o
+mtk-crypto-objs:= mtk-platform.o mtk-aes.o mtk-sha.o
diff --git a/drivers/crypto/mediatek/mtk-aes.c 
b/drivers/crypto/mediatek/mtk-aes.c
new file mode 100644
index 000..0208981
--- /dev/null
+++ b/drivers/crypto/mediatek/mtk-aes.c
@@ -0,0 +1,763 @@
+/*
+ * Cryptographic API.
+ *
+ * Support for MediaTek AES hardware accelerator.
+ *
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ryder Lee 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Some ideas are from atmel-aes.c drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mtk-platform.h"
+#include "mtk-regs.h"
+
+#define AES_QUEUE_LENGTH   512
+#define AES_BUFFER_ORDER   2
+#define AES_BUFFER_SIZE((PAGE_SIZE << AES_BUFFER_ORDER) \
+   & ~(AES_BLOCK_SIZE - 1))
+
+/* AES command token */
+#define AES_CT_SIZE_ECB2
+#define AES_CT_SIZE_CBC3
+#define AES_CT_CTRL_HDR0x0022
+#define AES_COMMAND0   0x0500
+#define AES_COMMAND1   0x2d06
+#define AES_COMMAND2   0xe4a63806
+
+/* AES transform information */
+#define AES_TFM_ECB(0x0 << 0)
+#define AES_TFM_CBC(0x1 << 0)
+#define AES_TFM_DECRYPT(0x5 << 0)
+#define AES_TFM_ENCRYPT(0x4 << 0)
+#define AES_TFM_SIZE(x)((x) << 8)
+#define AES_TFM_128BITS(0xb << 16)
+#define AES_TFM_192BITS(0xd << 16)
+#define AES_TFM_256BITS(0xf << 16)
+#define AES_TFM_FULL_IV(0xf << 5)
+
+/* AES flags */
+#define AES_FLAGS_MODE_MSK GENMASK(2, 0)
+#define AES_FLAGS_ECB  BIT(0)
+#define AES_FLAGS_CBC  BIT(1)
+#define AES_FLAGS_ENCRYPT  BIT(2)
+#define AES_FLAGS_BUSY BIT(3)
+
+/**
+ * AES command token(CT) is a set of hardware 

[net-next][PATCH 00/18] net: RDS updates

2016-12-04 Thread Santosh Shilimkar
Series consist of:
 - RDMA transport fixes for map failure, listen sequence, handler panic and
   composite message notification.
 - Couple of sparse fixes.
 - Message logging improvements for bind failure, use once mr semantics
   and connection remote address, active end point.
 - Performance improvement for RDMA transport by reducing the post send
   pressure on the queue and spreading the CQ vectors.
 - Useful statistics for socket send/recv usage and receive cache usage.
   rds-tools already equipped to parse this info.
 - Additional RDS CMSG used by application to track the RDS message
   stages for certain type of traffic to find out latency spots.
   Can be enabled/disabled per socket.

Series generated against 'net-next'. Patchset is also available on
below git tree.

The following changes since commit adc176c5472214971d77c1a61c83db9b01e9cdc7:

  ipv6 addrconf: Implemented enhanced DAD (RFC7527) (2016-12-03 23:21:37 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux.git 
for_4.10/net-next/rds

for you to fetch changes up to 35b76a2744f63f936a8b2e5c306d47618883144b:

  RDS: IB: add missing connection cache usage info (2016-12-04 17:06:30 -0800)



Avinash Repaka (1):
  RDS: make message size limit compliant with spec

Qing Huang (1):
  RDS: RDMA: start rdma listening after init

Santosh Shilimkar (15):
  RDS: log the address on bind failure
  RDS: mark few internal functions static to make sparse build happy
  RDS: IB: include faddr in connection log
  RDS: IB: make the transport retry count smallest
  RDS: RDMA: fix the ib_map_mr_sg_zbva() argument
  RDS: RDMA: return appropriate error on rdma map failures
  RDS: IB: split the mr registration and invalidation path
  RDS: RDMA: silence the use_once mr log flood
  RDS: IB: track and log active side endpoint in connection
  RDS: IB: add few useful cache stasts
  RDS: IB: Add vector spreading for cqs
  RDS: RDMA: Fix the composite message user notification
  RDS: IB: fix panic due to handlers running post teardown
  RDS: add receive message trace used by application
  RDS: IB: add missing connection cache usage info

Venkat Venkatsubra (1):
  RDS: add stat for socket recv memory usage

 include/uapi/linux/rds.h | 34 ++
 net/rds/af_rds.c | 28 +++
 net/rds/bind.c   |  4 +--
 net/rds/connection.c |  2 +-
 net/rds/ib.c | 12 +++
 net/rds/ib.h | 22 ++--
 net/rds/ib_cm.c  | 89 ++--
 net/rds/ib_frmr.c| 16 +
 net/rds/ib_recv.c| 14 ++--
 net/rds/ib_send.c| 29 +---
 net/rds/ib_stats.c   |  2 ++
 net/rds/rdma.c   | 22 ++--
 net/rds/rdma_transport.c | 11 ++
 net/rds/rds.h| 17 +
 net/rds/recv.c   | 36 ++--
 net/rds/send.c   | 50 ---
 net/rds/tcp_listen.c |  1 +
 net/rds/tcp_recv.c   |  5 +++
 18 files changed, 333 insertions(+), 61 deletions(-)

-- 
1.9.1



[net-next][PATCH 04/18] RDS: IB: make the transport retry count smallest

2016-12-04 Thread Santosh Shilimkar
Transport retry is not much useful since it indicate packet loss
in fabric so its better to failover fast rather than longer retry.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 45ac8e8..f4e8121 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -16,7 +16,7 @@
 #define RDS_IB_DEFAULT_SEND_WR 256
 #define RDS_IB_DEFAULT_FR_WR   512
 
-#define RDS_IB_DEFAULT_RETRY_COUNT 2
+#define RDS_IB_DEFAULT_RETRY_COUNT 1
 
 #define RDS_IB_SUPPORTED_PROTOCOLS 0x0003  /* minor versions 
supported */
 
-- 
1.9.1



[net-next][PATCH 02/18] RDS: mark few internal functions static to make sparse build happy

2016-12-04 Thread Santosh Shilimkar
Fixes below warnings:
warning: symbol 'rds_send_probe' was not declared. Should it be static?
warning: symbol 'rds_send_ping' was not declared. Should it be static?
warning: symbol 'rds_tcp_accept_one_path' was not declared. Should it be static?
warning: symbol 'rds_walk_conn_path_info' was not declared. Should it be static?

Signed-off-by: Santosh Shilimkar 
---
 net/rds/connection.c | 2 +-
 net/rds/send.c   | 4 ++--
 net/rds/tcp_listen.c | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/rds/connection.c b/net/rds/connection.c
index fe9d31c..26533b2 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -545,7 +545,7 @@ void rds_for_each_conn_info(struct socket *sock, unsigned 
int len,
 }
 EXPORT_SYMBOL_GPL(rds_for_each_conn_info);
 
-void rds_walk_conn_path_info(struct socket *sock, unsigned int len,
+static void rds_walk_conn_path_info(struct socket *sock, unsigned int len,
 struct rds_info_iterator *iter,
 struct rds_info_lengths *lens,
 int (*visitor)(struct rds_conn_path *, void *),
diff --git a/net/rds/send.c b/net/rds/send.c
index 77c8c6e..bb13c56 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1169,7 +1169,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
  * or
  *   RDS_FLAG_HB_PONG|RDS_FLAG_ACK_REQUIRED
  */
-int
+static int
 rds_send_probe(struct rds_conn_path *cp, __be16 sport,
   __be16 dport, u8 h_flags)
 {
@@ -1238,7 +1238,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
return rds_send_probe(cp, 0, dport, 0);
 }
 
-void
+static void
 rds_send_ping(struct rds_connection *conn)
 {
unsigned long flags;
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index f74bab3..67d0929 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -79,6 +79,7 @@ int rds_tcp_keepalive(struct socket *sock)
  * smaller ip address, we recycle conns in RDS_CONN_ERROR on the passive side
  * by moving them to CONNECTING in this function.
  */
+static
 struct rds_tcp_connection *rds_tcp_accept_one_path(struct rds_connection *conn)
 {
int i;
-- 
1.9.1



[net-next][PATCH 05/18] RDS: RDMA: fix the ib_map_mr_sg_zbva() argument

2016-12-04 Thread Santosh Shilimkar
Fixes warning: Using plain integer as NULL pointer

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_frmr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index d921adc..66b3d62 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -104,14 +104,15 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
struct rds_ib_frmr *frmr = >u.frmr;
struct ib_send_wr *failed_wr;
struct ib_reg_wr reg_wr;
-   int ret;
+   int ret, off = 0;
 
while (atomic_dec_return(>ic->i_fastreg_wrs) <= 0) {
atomic_inc(>ic->i_fastreg_wrs);
cpu_relax();
}
 
-   ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len, 0, PAGE_SIZE);
+   ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len,
+   , PAGE_SIZE);
if (unlikely(ret != ibmr->sg_len))
return ret < 0 ? ret : -EINVAL;
 
-- 
1.9.1



[PATCH v1 2/2] crypto: mediatek - add DT bindings documentation

2016-12-04 Thread Ryder Lee
Add DT bindings documentation for the crypto driver

Signed-off-by: Ryder Lee 
---
 .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt

diff --git a/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt 
b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
new file mode 100644
index 000..8b1db08
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
@@ -0,0 +1,32 @@
+MediaTek cryptographic accelerators
+
+Required properties:
+- compatible: Should be "mediatek,mt7623-crypto"
+- reg: Address and length of the register set for the device
+- interrupts: Should contain the five crypto engines interrupts in numeric
+   order. These are global system and four descriptor rings.
+- clocks: the clock used by the core
+- clock-names: the names of the clock listed in the clocks property. These are
+   "ethif", "cryp"
+- power-domains: Must contain a reference to the PM domain.
+
+
+Optional properties:
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+
+
+Example:
+   crypto: crypto@1b24 {
+   compatible = "mediatek,mt7623-crypto";
+   reg = <0 0x1b24 0 0x2>;
+   interrupts = ,
+,
+,
+,
+;
+   clocks = < CLK_TOP_ETHIF_SEL>,
+< CLK_ETHSYS_CRYPTO>;
+   clock-names = "ethif","cryp";
+   power-domains = < MT2701_POWER_DOMAIN_ETH>;
+   };
-- 
1.9.1



[PATCH v1 1/2] Add crypto driver support for some MediaTek chips

2016-12-04 Thread Ryder Lee
This adds support for the MediaTek hardware accelerator on
mt7623/mt2701/mt8521p SoC.

This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.

Signed-off-by: Ryder Lee 
---
 drivers/crypto/Kconfig |   17 +
 drivers/crypto/Makefile|1 +
 drivers/crypto/mediatek/Makefile   |2 +
 drivers/crypto/mediatek/mtk-aes.c  |  763 +
 drivers/crypto/mediatek/mtk-platform.c |  580 +
 drivers/crypto/mediatek/mtk-platform.h |  235 ++
 drivers/crypto/mediatek/mtk-regs.h |  194 +
 drivers/crypto/mediatek/mtk-sha.c  | 1423 
 8 files changed, 3215 insertions(+)
 create mode 100644 drivers/crypto/mediatek/Makefile
 create mode 100644 drivers/crypto/mediatek/mtk-aes.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.h
 create mode 100644 drivers/crypto/mediatek/mtk-regs.h
 create mode 100644 drivers/crypto/mediatek/mtk-sha.c

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 4d2b81f..ad0a00b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -553,6 +553,23 @@ config CRYPTO_DEV_ROCKCHIP
  This driver interfaces with the hardware crypto accelerator.
  Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode.
 
+config CRYPTO_DEV_MEDIATEK
+   tristate "MediaTek's Cryptographic Engine driver"
+   depends on ARM && (ARCH_MEDIATEK || COMPILE_TEST)
+   select NEON
+   select KERNEL_MODE_NEON
+   select ARM_CRYPTO
+   select CRYPTO_AES
+   select CRYPTO_BLKCIPHER
+   select CRYPTO_SHA1_ARM_NEON
+   select CRYPTO_SHA256_ARM
+   select CRYPTO_SHA512_ARM
+   select CRYPTO_HMAC
+   help
+ This driver allows you to utilize the hardware crypto accelerator
+ which can be found on the MT7623 MT2701, MT8521p, etc 
+ Select this if you want to use it for AES/SHA1/SHA2 algorithms.
+
 source "drivers/crypto/chelsio/Kconfig"
 
 endif # CRYPTO_HW
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index ad7250f..272b51a 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_CRYPTO_DEV_IMGTEC_HASH) += img-hash.o
 obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
 obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o
 obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell/
+obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mediatek/
 obj-$(CONFIG_CRYPTO_DEV_MXS_DCP) += mxs-dcp.o
 obj-$(CONFIG_CRYPTO_DEV_NIAGARA2) += n2_crypto.o
 n2_crypto-y := n2_core.o n2_asm.o
diff --git a/drivers/crypto/mediatek/Makefile b/drivers/crypto/mediatek/Makefile
new file mode 100644
index 000..187be79
--- /dev/null
+++ b/drivers/crypto/mediatek/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mtk-crypto.o
+mtk-crypto-objs:= mtk-platform.o mtk-aes.o mtk-sha.o
diff --git a/drivers/crypto/mediatek/mtk-aes.c 
b/drivers/crypto/mediatek/mtk-aes.c
new file mode 100644
index 000..0208981
--- /dev/null
+++ b/drivers/crypto/mediatek/mtk-aes.c
@@ -0,0 +1,763 @@
+/*
+ * Cryptographic API.
+ *
+ * Support for MediaTek AES hardware accelerator.
+ *
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ryder Lee 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Some ideas are from atmel-aes.c drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mtk-platform.h"
+#include "mtk-regs.h"
+
+#define AES_QUEUE_LENGTH   512
+#define AES_BUFFER_ORDER   2
+#define AES_BUFFER_SIZE((PAGE_SIZE << AES_BUFFER_ORDER) \
+   & ~(AES_BLOCK_SIZE - 1))
+
+/* AES command token */
+#define AES_CT_SIZE_ECB2
+#define AES_CT_SIZE_CBC3
+#define AES_CT_CTRL_HDR0x0022
+#define AES_COMMAND0   0x0500
+#define AES_COMMAND1   0x2d06
+#define AES_COMMAND2   0xe4a63806
+
+/* AES transform information */
+#define AES_TFM_ECB(0x0 << 0)
+#define AES_TFM_CBC(0x1 << 0)
+#define AES_TFM_DECRYPT(0x5 << 0)
+#define AES_TFM_ENCRYPT(0x4 << 0)
+#define AES_TFM_SIZE(x)((x) << 8)
+#define AES_TFM_128BITS(0xb << 16)
+#define AES_TFM_192BITS(0xd << 16)
+#define AES_TFM_256BITS(0xf << 16)
+#define AES_TFM_FULL_IV(0xf << 5)
+
+/* AES flags */
+#define AES_FLAGS_MODE_MSK GENMASK(2, 0)
+#define AES_FLAGS_ECB  BIT(0)
+#define AES_FLAGS_CBC  BIT(1)
+#define AES_FLAGS_ENCRYPT  BIT(2)
+#define AES_FLAGS_BUSY BIT(3)
+
+/**
+ * AES command token(CT) is a set of hardware instructions that
+ * are used to control crypto 

[net-next][PATCH 00/18] net: RDS updates

2016-12-04 Thread Santosh Shilimkar
Series consist of:
 - RDMA transport fixes for map failure, listen sequence, handler panic and
   composite message notification.
 - Couple of sparse fixes.
 - Message logging improvements for bind failure, use once mr semantics
   and connection remote address, active end point.
 - Performance improvement for RDMA transport by reducing the post send
   pressure on the queue and spreading the CQ vectors.
 - Useful statistics for socket send/recv usage and receive cache usage.
   rds-tools already equipped to parse this info.
 - Additional RDS CMSG used by application to track the RDS message
   stages for certain type of traffic to find out latency spots.
   Can be enabled/disabled per socket.

Series generated against 'net-next'. Patchset is also available on
below git tree.

The following changes since commit adc176c5472214971d77c1a61c83db9b01e9cdc7:

  ipv6 addrconf: Implemented enhanced DAD (RFC7527) (2016-12-03 23:21:37 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux.git 
for_4.10/net-next/rds

for you to fetch changes up to 35b76a2744f63f936a8b2e5c306d47618883144b:

  RDS: IB: add missing connection cache usage info (2016-12-04 17:06:30 -0800)



Avinash Repaka (1):
  RDS: make message size limit compliant with spec

Qing Huang (1):
  RDS: RDMA: start rdma listening after init

Santosh Shilimkar (15):
  RDS: log the address on bind failure
  RDS: mark few internal functions static to make sparse build happy
  RDS: IB: include faddr in connection log
  RDS: IB: make the transport retry count smallest
  RDS: RDMA: fix the ib_map_mr_sg_zbva() argument
  RDS: RDMA: return appropriate error on rdma map failures
  RDS: IB: split the mr registration and invalidation path
  RDS: RDMA: silence the use_once mr log flood
  RDS: IB: track and log active side endpoint in connection
  RDS: IB: add few useful cache stasts
  RDS: IB: Add vector spreading for cqs
  RDS: RDMA: Fix the composite message user notification
  RDS: IB: fix panic due to handlers running post teardown
  RDS: add receive message trace used by application
  RDS: IB: add missing connection cache usage info

Venkat Venkatsubra (1):
  RDS: add stat for socket recv memory usage

 include/uapi/linux/rds.h | 34 ++
 net/rds/af_rds.c | 28 +++
 net/rds/bind.c   |  4 +--
 net/rds/connection.c |  2 +-
 net/rds/ib.c | 12 +++
 net/rds/ib.h | 22 ++--
 net/rds/ib_cm.c  | 89 ++--
 net/rds/ib_frmr.c| 16 +
 net/rds/ib_recv.c| 14 ++--
 net/rds/ib_send.c| 29 +---
 net/rds/ib_stats.c   |  2 ++
 net/rds/rdma.c   | 22 ++--
 net/rds/rdma_transport.c | 11 ++
 net/rds/rds.h| 17 +
 net/rds/recv.c   | 36 ++--
 net/rds/send.c   | 50 ---
 net/rds/tcp_listen.c |  1 +
 net/rds/tcp_recv.c   |  5 +++
 18 files changed, 333 insertions(+), 61 deletions(-)

-- 
1.9.1



[net-next][PATCH 04/18] RDS: IB: make the transport retry count smallest

2016-12-04 Thread Santosh Shilimkar
Transport retry is not much useful since it indicate packet loss
in fabric so its better to failover fast rather than longer retry.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 45ac8e8..f4e8121 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -16,7 +16,7 @@
 #define RDS_IB_DEFAULT_SEND_WR 256
 #define RDS_IB_DEFAULT_FR_WR   512
 
-#define RDS_IB_DEFAULT_RETRY_COUNT 2
+#define RDS_IB_DEFAULT_RETRY_COUNT 1
 
 #define RDS_IB_SUPPORTED_PROTOCOLS 0x0003  /* minor versions 
supported */
 
-- 
1.9.1



[net-next][PATCH 02/18] RDS: mark few internal functions static to make sparse build happy

2016-12-04 Thread Santosh Shilimkar
Fixes below warnings:
warning: symbol 'rds_send_probe' was not declared. Should it be static?
warning: symbol 'rds_send_ping' was not declared. Should it be static?
warning: symbol 'rds_tcp_accept_one_path' was not declared. Should it be static?
warning: symbol 'rds_walk_conn_path_info' was not declared. Should it be static?

Signed-off-by: Santosh Shilimkar 
---
 net/rds/connection.c | 2 +-
 net/rds/send.c   | 4 ++--
 net/rds/tcp_listen.c | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/rds/connection.c b/net/rds/connection.c
index fe9d31c..26533b2 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -545,7 +545,7 @@ void rds_for_each_conn_info(struct socket *sock, unsigned 
int len,
 }
 EXPORT_SYMBOL_GPL(rds_for_each_conn_info);
 
-void rds_walk_conn_path_info(struct socket *sock, unsigned int len,
+static void rds_walk_conn_path_info(struct socket *sock, unsigned int len,
 struct rds_info_iterator *iter,
 struct rds_info_lengths *lens,
 int (*visitor)(struct rds_conn_path *, void *),
diff --git a/net/rds/send.c b/net/rds/send.c
index 77c8c6e..bb13c56 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1169,7 +1169,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
  * or
  *   RDS_FLAG_HB_PONG|RDS_FLAG_ACK_REQUIRED
  */
-int
+static int
 rds_send_probe(struct rds_conn_path *cp, __be16 sport,
   __be16 dport, u8 h_flags)
 {
@@ -1238,7 +1238,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
return rds_send_probe(cp, 0, dport, 0);
 }
 
-void
+static void
 rds_send_ping(struct rds_connection *conn)
 {
unsigned long flags;
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index f74bab3..67d0929 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -79,6 +79,7 @@ int rds_tcp_keepalive(struct socket *sock)
  * smaller ip address, we recycle conns in RDS_CONN_ERROR on the passive side
  * by moving them to CONNECTING in this function.
  */
+static
 struct rds_tcp_connection *rds_tcp_accept_one_path(struct rds_connection *conn)
 {
int i;
-- 
1.9.1



[net-next][PATCH 05/18] RDS: RDMA: fix the ib_map_mr_sg_zbva() argument

2016-12-04 Thread Santosh Shilimkar
Fixes warning: Using plain integer as NULL pointer

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_frmr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index d921adc..66b3d62 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -104,14 +104,15 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
struct rds_ib_frmr *frmr = >u.frmr;
struct ib_send_wr *failed_wr;
struct ib_reg_wr reg_wr;
-   int ret;
+   int ret, off = 0;
 
while (atomic_dec_return(>ic->i_fastreg_wrs) <= 0) {
atomic_inc(>ic->i_fastreg_wrs);
cpu_relax();
}
 
-   ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len, 0, PAGE_SIZE);
+   ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len,
+   , PAGE_SIZE);
if (unlikely(ret != ibmr->sg_len))
return ret < 0 ? ret : -EINVAL;
 
-- 
1.9.1



[PATCH v1 0/2] Add MediaTek crypto acclelrator driver

2016-12-04 Thread Ryder Lee
Hello,

This adds support for the MediaTek hardware accelerator on 
mt7623 SoC.

This driver currently implement: 
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.

Changes since v1:
- remove EXPORT_SYMBOL
- remove unused PRNG setting
- sort headers in alphabetical order
- add a definition for IRQ unmber
- replace ambiguous definition
- add more annotation and function comment
- add COMPILE_TEST in Kconfig


Ryder Lee (2):
  Add crypto driver support for some MediaTek chips
  crypto: mediatek - add DT bindings documentation

 .../devicetree/bindings/crypto/mediatek-crypto.txt |   32 +
 drivers/crypto/Kconfig |   17 +
 drivers/crypto/Makefile|1 +
 drivers/crypto/mediatek/Makefile   |2 +
 drivers/crypto/mediatek/mtk-aes.c  |  763 +++
 drivers/crypto/mediatek/mtk-platform.c |  580 
 drivers/crypto/mediatek/mtk-platform.h |  235 
 drivers/crypto/mediatek/mtk-regs.h |  194 +++
 drivers/crypto/mediatek/mtk-sha.c  | 1423 
 9 files changed, 3247 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
 create mode 100644 drivers/crypto/mediatek/Makefile
 create mode 100644 drivers/crypto/mediatek/mtk-aes.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.h
 create mode 100644 drivers/crypto/mediatek/mtk-regs.h
 create mode 100644 drivers/crypto/mediatek/mtk-sha.c

-- 
1.9.1



[net-next][PATCH 06/18] RDS: RDMA: start rdma listening after init

2016-12-04 Thread Santosh Shilimkar
From: Qing Huang 

This prevents RDS from handling incoming rdma packets before RDS
completes initializing its recv/send components.

Signed-off-by: Qing Huang 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma_transport.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c
index 345f090..250c6b8 100644
--- a/net/rds/rdma_transport.c
+++ b/net/rds/rdma_transport.c
@@ -203,18 +203,13 @@ static int rds_rdma_init(void)
 {
int ret;
 
-   ret = rds_rdma_listen_init();
+   ret = rds_ib_init();
if (ret)
goto out;
 
-   ret = rds_ib_init();
+   ret = rds_rdma_listen_init();
if (ret)
-   goto err_ib_init;
-
-   goto out;
-
-err_ib_init:
-   rds_rdma_listen_stop();
+   rds_ib_exit();
 out:
return ret;
 }
-- 
1.9.1



[net-next][PATCH 03/18] RDS: IB: include faddr in connection log

2016-12-04 Thread Santosh Shilimkar
Also use pr_* for it.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_cm.c   | 19 +--
 net/rds/ib_recv.c |  4 ++--
 net/rds/ib_send.c |  4 ++--
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 5b2ab95..b9da1e5 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -113,19 +113,18 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
}
 
if (conn->c_version < RDS_PROTOCOL(3, 1)) {
-   printk(KERN_NOTICE "RDS/IB: Connection to %pI4 version %u.%u 
failed,"
-  " no longer supported\n",
-  >c_faddr,
-  RDS_PROTOCOL_MAJOR(conn->c_version),
-  RDS_PROTOCOL_MINOR(conn->c_version));
+   pr_notice("RDS/IB: Connection <%pI4,%pI4> version %u.%u no 
longer supported\n",
+ >c_laddr, >c_faddr,
+ RDS_PROTOCOL_MAJOR(conn->c_version),
+ RDS_PROTOCOL_MINOR(conn->c_version));
rds_conn_destroy(conn);
return;
} else {
-   printk(KERN_NOTICE "RDS/IB: connected to %pI4 version 
%u.%u%s\n",
-  >c_faddr,
-  RDS_PROTOCOL_MAJOR(conn->c_version),
-  RDS_PROTOCOL_MINOR(conn->c_version),
-  ic->i_flowctl ? ", flow control" : "");
+   pr_notice("RDS/IB: connected <%pI4,%pI4> version %u.%u%s\n",
+ >c_laddr, >c_faddr,
+ RDS_PROTOCOL_MAJOR(conn->c_version),
+ RDS_PROTOCOL_MINOR(conn->c_version),
+ ic->i_flowctl ? ", flow control" : "");
}
 
/*
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 606a11f..6803b75 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -980,8 +980,8 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,
} else {
/* We expect errors as the qp is drained during shutdown */
if (rds_conn_up(conn) || rds_conn_connecting(conn))
-   rds_ib_conn_error(conn, "recv completion on %pI4 had 
status %u (%s), disconnecting and reconnecting\n",
- >c_faddr,
+   rds_ib_conn_error(conn, "recv completion on <%pI4,%pI4> 
had status %u (%s), disconnecting and reconnecting\n",
+ >c_laddr, >c_faddr,
  wc->status,
  ib_wc_status_msg(wc->status));
}
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 84d90c9..19eca5c 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -300,8 +300,8 @@ void rds_ib_send_cqe_handler(struct rds_ib_connection *ic, 
struct ib_wc *wc)
 
/* We expect errors as the qp is drained during shutdown */
if (wc->status != IB_WC_SUCCESS && rds_conn_up(conn)) {
-   rds_ib_conn_error(conn, "send completion on %pI4 had status %u 
(%s), disconnecting and reconnecting\n",
- >c_faddr, wc->status,
+   rds_ib_conn_error(conn, "send completion on <%pI4,%pI4> had 
status %u (%s), disconnecting and reconnecting\n",
+ >c_laddr, >c_faddr, wc->status,
  ib_wc_status_msg(wc->status));
}
 }
-- 
1.9.1



[net-next][PATCH 18/18] RDS: IB: add missing connection cache usage info

2016-12-04 Thread Santosh Shilimkar
rds-tools already support it.

Signed-off-by: Santosh Shilimkar 
---
 include/uapi/linux/rds.h | 1 +
 net/rds/ib.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 3833113..410ae3c 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -183,6 +183,7 @@ struct rds_info_rdma_connection {
uint32_tmax_send_sge;
uint32_trdma_mr_max;
uint32_trdma_mr_size;
+   uint32_tcache_allocs;
 };
 
 /* RDS message Receive Path Latency points */
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 8d70884..b5e2699 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -313,6 +313,7 @@ static int rds_ib_conn_info_visitor(struct rds_connection 
*conn,
iinfo->max_send_wr = ic->i_send_ring.w_nr;
iinfo->max_recv_wr = ic->i_recv_ring.w_nr;
iinfo->max_send_sge = rds_ibdev->max_sge;
+   iinfo->cache_allocs = atomic_read(>i_cache_allocs);
rds_ib_get_mr_info(rds_ibdev, iinfo);
}
return 1;
-- 
1.9.1



[net-next][PATCH 15/18] RDS: add stat for socket recv memory usage

2016-12-04 Thread Santosh Shilimkar
From: Venkat Venkatsubra 

Tracks the receive side memory added to scokets and removed from sockets.

Signed-off-by: Venkat Venkatsubra 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rds.h  | 3 +++
 net/rds/recv.c | 4 
 2 files changed, 7 insertions(+)

diff --git a/net/rds/rds.h b/net/rds/rds.h
index 0bb8213..8ccd5a9 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -631,6 +631,9 @@ struct rds_statistics {
uint64_ts_cong_update_received;
uint64_ts_cong_send_error;
uint64_ts_cong_send_blocked;
+   uint64_ts_recv_bytes_added_to_socket;
+   uint64_ts_recv_bytes_removed_from_socket;
+
 };
 
 /* af_rds.c */
diff --git a/net/rds/recv.c b/net/rds/recv.c
index 9d0666e..ba19eee 100644
--- a/net/rds/recv.c
+++ b/net/rds/recv.c
@@ -94,6 +94,10 @@ static void rds_recv_rcvbuf_delta(struct rds_sock *rs, 
struct sock *sk,
return;
 
rs->rs_rcv_bytes += delta;
+   if (delta > 0)
+   rds_stats_add(s_recv_bytes_added_to_socket, delta);
+   else
+   rds_stats_add(s_recv_bytes_removed_from_socket, -delta);
now_congested = rs->rs_rcv_bytes > rds_sk_rcvbuf(rs);
 
rdsdebug("rs %p (%pI4:%u) recv bytes %d buf %d "
-- 
1.9.1



[net-next][PATCH 06/18] RDS: RDMA: start rdma listening after init

2016-12-04 Thread Santosh Shilimkar
From: Qing Huang 

This prevents RDS from handling incoming rdma packets before RDS
completes initializing its recv/send components.

Signed-off-by: Qing Huang 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma_transport.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c
index 345f090..250c6b8 100644
--- a/net/rds/rdma_transport.c
+++ b/net/rds/rdma_transport.c
@@ -203,18 +203,13 @@ static int rds_rdma_init(void)
 {
int ret;
 
-   ret = rds_rdma_listen_init();
+   ret = rds_ib_init();
if (ret)
goto out;
 
-   ret = rds_ib_init();
+   ret = rds_rdma_listen_init();
if (ret)
-   goto err_ib_init;
-
-   goto out;
-
-err_ib_init:
-   rds_rdma_listen_stop();
+   rds_ib_exit();
 out:
return ret;
 }
-- 
1.9.1



[net-next][PATCH 03/18] RDS: IB: include faddr in connection log

2016-12-04 Thread Santosh Shilimkar
Also use pr_* for it.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_cm.c   | 19 +--
 net/rds/ib_recv.c |  4 ++--
 net/rds/ib_send.c |  4 ++--
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 5b2ab95..b9da1e5 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -113,19 +113,18 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
}
 
if (conn->c_version < RDS_PROTOCOL(3, 1)) {
-   printk(KERN_NOTICE "RDS/IB: Connection to %pI4 version %u.%u 
failed,"
-  " no longer supported\n",
-  >c_faddr,
-  RDS_PROTOCOL_MAJOR(conn->c_version),
-  RDS_PROTOCOL_MINOR(conn->c_version));
+   pr_notice("RDS/IB: Connection <%pI4,%pI4> version %u.%u no 
longer supported\n",
+ >c_laddr, >c_faddr,
+ RDS_PROTOCOL_MAJOR(conn->c_version),
+ RDS_PROTOCOL_MINOR(conn->c_version));
rds_conn_destroy(conn);
return;
} else {
-   printk(KERN_NOTICE "RDS/IB: connected to %pI4 version 
%u.%u%s\n",
-  >c_faddr,
-  RDS_PROTOCOL_MAJOR(conn->c_version),
-  RDS_PROTOCOL_MINOR(conn->c_version),
-  ic->i_flowctl ? ", flow control" : "");
+   pr_notice("RDS/IB: connected <%pI4,%pI4> version %u.%u%s\n",
+ >c_laddr, >c_faddr,
+ RDS_PROTOCOL_MAJOR(conn->c_version),
+ RDS_PROTOCOL_MINOR(conn->c_version),
+ ic->i_flowctl ? ", flow control" : "");
}
 
/*
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 606a11f..6803b75 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -980,8 +980,8 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,
} else {
/* We expect errors as the qp is drained during shutdown */
if (rds_conn_up(conn) || rds_conn_connecting(conn))
-   rds_ib_conn_error(conn, "recv completion on %pI4 had 
status %u (%s), disconnecting and reconnecting\n",
- >c_faddr,
+   rds_ib_conn_error(conn, "recv completion on <%pI4,%pI4> 
had status %u (%s), disconnecting and reconnecting\n",
+ >c_laddr, >c_faddr,
  wc->status,
  ib_wc_status_msg(wc->status));
}
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 84d90c9..19eca5c 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -300,8 +300,8 @@ void rds_ib_send_cqe_handler(struct rds_ib_connection *ic, 
struct ib_wc *wc)
 
/* We expect errors as the qp is drained during shutdown */
if (wc->status != IB_WC_SUCCESS && rds_conn_up(conn)) {
-   rds_ib_conn_error(conn, "send completion on %pI4 had status %u 
(%s), disconnecting and reconnecting\n",
- >c_faddr, wc->status,
+   rds_ib_conn_error(conn, "send completion on <%pI4,%pI4> had 
status %u (%s), disconnecting and reconnecting\n",
+ >c_laddr, >c_faddr, wc->status,
  ib_wc_status_msg(wc->status));
}
 }
-- 
1.9.1



[net-next][PATCH 18/18] RDS: IB: add missing connection cache usage info

2016-12-04 Thread Santosh Shilimkar
rds-tools already support it.

Signed-off-by: Santosh Shilimkar 
---
 include/uapi/linux/rds.h | 1 +
 net/rds/ib.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 3833113..410ae3c 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -183,6 +183,7 @@ struct rds_info_rdma_connection {
uint32_tmax_send_sge;
uint32_trdma_mr_max;
uint32_trdma_mr_size;
+   uint32_tcache_allocs;
 };
 
 /* RDS message Receive Path Latency points */
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 8d70884..b5e2699 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -313,6 +313,7 @@ static int rds_ib_conn_info_visitor(struct rds_connection 
*conn,
iinfo->max_send_wr = ic->i_send_ring.w_nr;
iinfo->max_recv_wr = ic->i_recv_ring.w_nr;
iinfo->max_send_sge = rds_ibdev->max_sge;
+   iinfo->cache_allocs = atomic_read(>i_cache_allocs);
rds_ib_get_mr_info(rds_ibdev, iinfo);
}
return 1;
-- 
1.9.1



[net-next][PATCH 15/18] RDS: add stat for socket recv memory usage

2016-12-04 Thread Santosh Shilimkar
From: Venkat Venkatsubra 

Tracks the receive side memory added to scokets and removed from sockets.

Signed-off-by: Venkat Venkatsubra 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rds.h  | 3 +++
 net/rds/recv.c | 4 
 2 files changed, 7 insertions(+)

diff --git a/net/rds/rds.h b/net/rds/rds.h
index 0bb8213..8ccd5a9 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -631,6 +631,9 @@ struct rds_statistics {
uint64_ts_cong_update_received;
uint64_ts_cong_send_error;
uint64_ts_cong_send_blocked;
+   uint64_ts_recv_bytes_added_to_socket;
+   uint64_ts_recv_bytes_removed_from_socket;
+
 };
 
 /* af_rds.c */
diff --git a/net/rds/recv.c b/net/rds/recv.c
index 9d0666e..ba19eee 100644
--- a/net/rds/recv.c
+++ b/net/rds/recv.c
@@ -94,6 +94,10 @@ static void rds_recv_rcvbuf_delta(struct rds_sock *rs, 
struct sock *sk,
return;
 
rs->rs_rcv_bytes += delta;
+   if (delta > 0)
+   rds_stats_add(s_recv_bytes_added_to_socket, delta);
+   else
+   rds_stats_add(s_recv_bytes_removed_from_socket, -delta);
now_congested = rs->rs_rcv_bytes > rds_sk_rcvbuf(rs);
 
rdsdebug("rs %p (%pI4:%u) recv bytes %d buf %d "
-- 
1.9.1



[PATCH v1 0/2] Add MediaTek crypto acclelrator driver

2016-12-04 Thread Ryder Lee
Hello,

This adds support for the MediaTek hardware accelerator on 
mt7623 SoC.

This driver currently implement: 
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.

Changes since v1:
- remove EXPORT_SYMBOL
- remove unused PRNG setting
- sort headers in alphabetical order
- add a definition for IRQ unmber
- replace ambiguous definition
- add more annotation and function comment
- add COMPILE_TEST in Kconfig


Ryder Lee (2):
  Add crypto driver support for some MediaTek chips
  crypto: mediatek - add DT bindings documentation

 .../devicetree/bindings/crypto/mediatek-crypto.txt |   32 +
 drivers/crypto/Kconfig |   17 +
 drivers/crypto/Makefile|1 +
 drivers/crypto/mediatek/Makefile   |2 +
 drivers/crypto/mediatek/mtk-aes.c  |  763 +++
 drivers/crypto/mediatek/mtk-platform.c |  580 
 drivers/crypto/mediatek/mtk-platform.h |  235 
 drivers/crypto/mediatek/mtk-regs.h |  194 +++
 drivers/crypto/mediatek/mtk-sha.c  | 1423 
 9 files changed, 3247 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
 create mode 100644 drivers/crypto/mediatek/Makefile
 create mode 100644 drivers/crypto/mediatek/mtk-aes.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.c
 create mode 100644 drivers/crypto/mediatek/mtk-platform.h
 create mode 100644 drivers/crypto/mediatek/mtk-regs.h
 create mode 100644 drivers/crypto/mediatek/mtk-sha.c

-- 
1.9.1



Re: [PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread kbuild test robot
Hi Zhao,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.9-rc8]
[cannot apply to next-20161202]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Zhao-Qiang/QE-remove-PPCisms-for-QE/20161205-131352
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from drivers/soc/fsl/qe/qe_ic.c:31:0:
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_ipic':
>> include/soc/fsl/qe/qe_ic.h:86:21: error: 'NO_IRQ' undeclared (first use in 
>> this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h:86:21: note: each undeclared identifier is 
reported only once for each function it appears in
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_ipic':
   include/soc/fsl/qe/qe_ic.h:95:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_mpic':
   include/soc/fsl/qe/qe_ic.h:105:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_mpic':
   include/soc/fsl/qe/qe_ic.h:117:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_muxed_mpic':
   include/soc/fsl/qe/qe_ic.h:130:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq == NO_IRQ)
^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_read':
>> drivers/soc/fsl/qe/qe_ic.c:180:9: error: implicit declaration of function 
>> 'in_be32' [-Werror=implicit-function-declaration]
 return in_be32(base + (reg >> 2));
^~~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_write':
>> drivers/soc/fsl/qe/qe_ic.c:186:2: error: implicit declaration of function 
>> 'out_be32' [-Werror=implicit-function-declaration]
 out_be32(base + (reg >> 2), value);
 ^~~~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_low_irq':
>> drivers/soc/fsl/qe/qe_ic.c:299:10: error: 'NO_IRQ' undeclared (first use in 
>> this function)
  return NO_IRQ;
 ^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_high_irq':
   drivers/soc/fsl/qe/qe_ic.c:315:10: error: 'NO_IRQ' undeclared (first use in 
this function)
  return NO_IRQ;
 ^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_init':
   drivers/soc/fsl/qe/qe_ic.c:350:25: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (qe_ic->virq_low == NO_IRQ) {
^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_set_highest_priority':
>> drivers/soc/fsl/qe/qe_ic.c:392:21: error: implicit declaration of function 
>> 'virq_to_hw' [-Werror=implicit-function-declaration]
 unsigned int src = virq_to_hw(virq);
^~
   cc1: some warnings being treated as errors

vim +/in_be32 +180 drivers/soc/fsl/qe/qe_ic.c

98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  174 
.pri_reg = QEIC_CIPYCC,
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  175 
},
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  176 
 };
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  177 
 
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  178 
 static inline u32 qe_ic_read(volatile __be32  __iomem * base, unsigned int reg)
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  179 
 {
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 @180 
return in_be32(base + (reg >> 2));
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  181 
 }
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  182 
 
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  183 
 static inline void qe_ic_write(volatile __be32  __iomem * base, unsigned int 
reg,
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  184 
   u32 value)
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  185 
 {
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 @186 
out_be32(base + (reg >> 2), value);
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  187 
 }
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  188 
 
98658538 

Re: [PATCH v9] QE: remove PPCisms for QE

2016-12-04 Thread kbuild test robot
Hi Zhao,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.9-rc8]
[cannot apply to next-20161202]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Zhao-Qiang/QE-remove-PPCisms-for-QE/20161205-131352
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from drivers/soc/fsl/qe/qe_ic.c:31:0:
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_ipic':
>> include/soc/fsl/qe/qe_ic.h:86:21: error: 'NO_IRQ' undeclared (first use in 
>> this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h:86:21: note: each undeclared identifier is 
reported only once for each function it appears in
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_ipic':
   include/soc/fsl/qe/qe_ic.h:95:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_low_mpic':
   include/soc/fsl/qe/qe_ic.h:105:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_high_mpic':
   include/soc/fsl/qe/qe_ic.h:117:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq != NO_IRQ)
^~
   include/soc/fsl/qe/qe_ic.h: In function 'qe_ic_cascade_muxed_mpic':
   include/soc/fsl/qe/qe_ic.h:130:21: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (cascade_irq == NO_IRQ)
^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_read':
>> drivers/soc/fsl/qe/qe_ic.c:180:9: error: implicit declaration of function 
>> 'in_be32' [-Werror=implicit-function-declaration]
 return in_be32(base + (reg >> 2));
^~~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_write':
>> drivers/soc/fsl/qe/qe_ic.c:186:2: error: implicit declaration of function 
>> 'out_be32' [-Werror=implicit-function-declaration]
 out_be32(base + (reg >> 2), value);
 ^~~~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_low_irq':
>> drivers/soc/fsl/qe/qe_ic.c:299:10: error: 'NO_IRQ' undeclared (first use in 
>> this function)
  return NO_IRQ;
 ^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_get_high_irq':
   drivers/soc/fsl/qe/qe_ic.c:315:10: error: 'NO_IRQ' undeclared (first use in 
this function)
  return NO_IRQ;
 ^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_init':
   drivers/soc/fsl/qe/qe_ic.c:350:25: error: 'NO_IRQ' undeclared (first use in 
this function)
 if (qe_ic->virq_low == NO_IRQ) {
^~
   drivers/soc/fsl/qe/qe_ic.c: In function 'qe_ic_set_highest_priority':
>> drivers/soc/fsl/qe/qe_ic.c:392:21: error: implicit declaration of function 
>> 'virq_to_hw' [-Werror=implicit-function-declaration]
 unsigned int src = virq_to_hw(virq);
^~
   cc1: some warnings being treated as errors

vim +/in_be32 +180 drivers/soc/fsl/qe/qe_ic.c

98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  174 
.pri_reg = QEIC_CIPYCC,
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  175 
},
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  176 
 };
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  177 
 
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  178 
 static inline u32 qe_ic_read(volatile __be32  __iomem * base, unsigned int reg)
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  179 
 {
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 @180 
return in_be32(base + (reg >> 2));
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  181 
 }
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  182 
 
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  183 
 static inline void qe_ic_write(volatile __be32  __iomem * base, unsigned int 
reg,
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  184 
   u32 value)
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  185 
 {
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03 @186 
out_be32(base + (reg >> 2), value);
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  187 
 }
98658538 arch/powerpc/sysdev/qe_lib/qe_ic.c Li Yang 2006-10-03  188 
 
98658538 

[net-next][PATCH 16/18] RDS: make message size limit compliant with spec

2016-12-04 Thread Santosh Shilimkar
From: Avinash Repaka 

RDS support max message size as 1M but the code doesn't check this
in all cases. Patch fixes it for RDMA & non-RDMA and RDS MR size
and its enforced irrespective of underlying transport.

Signed-off-by: Avinash Repaka 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma.c |  9 -
 net/rds/rds.h  |  3 +++
 net/rds/send.c | 31 +++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index dd508e0..6e8db33 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -40,7 +40,6 @@
 /*
  * XXX
  *  - build with sparse
- *  - should we limit the size of a mr region?  let transport return failure?
  *  - should we detect duplicate keys on a socket?  hmm.
  *  - an rdma is an mlock, apply rlimit?
  */
@@ -200,6 +199,14 @@ static int __rds_rdma_map(struct rds_sock *rs, struct 
rds_get_mr_args *args,
goto out;
}
 
+   /* Restrict the size of mr irrespective of underlying transport
+* To account for unaligned mr regions, subtract one from nr_pages
+*/
+   if ((nr_pages - 1) > (RDS_MAX_MSG_SIZE >> PAGE_SHIFT)) {
+   ret = -EMSGSIZE;
+   goto out;
+   }
+
rdsdebug("RDS: get_mr addr %llx len %llu nr_pages %u\n",
args->vec.addr, args->vec.bytes, nr_pages);
 
diff --git a/net/rds/rds.h b/net/rds/rds.h
index 8ccd5a9..f713194 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -50,6 +50,9 @@ void rdsdebug(char *fmt, ...)
 #define RDS_FRAG_SHIFT 12
 #define RDS_FRAG_SIZE  ((unsigned int)(1 << RDS_FRAG_SHIFT))
 
+/* Used to limit both RDMA and non-RDMA RDS message to 1MB */
+#define RDS_MAX_MSG_SIZE   ((unsigned int)(1 << 20))
+
 #define RDS_CONG_MAP_BYTES (65536 / 8)
 #define RDS_CONG_MAP_PAGES (PAGE_ALIGN(RDS_CONG_MAP_BYTES) / PAGE_SIZE)
 #define RDS_CONG_MAP_PAGE_BITS (PAGE_SIZE * 8)
diff --git a/net/rds/send.c b/net/rds/send.c
index 45e025b..5cc6403 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -994,6 +994,26 @@ static int rds_send_mprds_hash(struct rds_sock *rs, struct 
rds_connection *conn)
return hash;
 }
 
+static int rds_rdma_bytes(struct msghdr *msg, size_t *rdma_bytes)
+{
+   struct rds_rdma_args *args;
+   struct cmsghdr *cmsg;
+
+   for_each_cmsghdr(cmsg, msg) {
+   if (!CMSG_OK(msg, cmsg))
+   return -EINVAL;
+
+   if (cmsg->cmsg_level != SOL_RDS)
+   continue;
+
+   if (cmsg->cmsg_type == RDS_CMSG_RDMA_ARGS) {
+   args = CMSG_DATA(cmsg);
+   *rdma_bytes += args->remote_vec.bytes;
+   }
+   }
+   return 0;
+}
+
 int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 {
struct sock *sk = sock->sk;
@@ -1008,6 +1028,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
int nonblock = msg->msg_flags & MSG_DONTWAIT;
long timeo = sock_sndtimeo(sk, nonblock);
struct rds_conn_path *cpath;
+   size_t total_payload_len = payload_len, rdma_payload_len = 0;
 
/* Mirror Linux UDP mirror of BSD error message compatibility */
/* XXX: Perhaps MSG_MORE someday */
@@ -1040,6 +1061,16 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
}
release_sock(sk);
 
+   ret = rds_rdma_bytes(msg, _payload_len);
+   if (ret)
+   goto out;
+
+   total_payload_len += rdma_payload_len;
+   if (max_t(size_t, payload_len, rdma_payload_len) > RDS_MAX_MSG_SIZE) {
+   ret = -EMSGSIZE;
+   goto out;
+   }
+
if (payload_len > rds_sk_sndbuf(rs)) {
ret = -EMSGSIZE;
goto out;
-- 
1.9.1



[net-next][PATCH 16/18] RDS: make message size limit compliant with spec

2016-12-04 Thread Santosh Shilimkar
From: Avinash Repaka 

RDS support max message size as 1M but the code doesn't check this
in all cases. Patch fixes it for RDMA & non-RDMA and RDS MR size
and its enforced irrespective of underlying transport.

Signed-off-by: Avinash Repaka 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma.c |  9 -
 net/rds/rds.h  |  3 +++
 net/rds/send.c | 31 +++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index dd508e0..6e8db33 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -40,7 +40,6 @@
 /*
  * XXX
  *  - build with sparse
- *  - should we limit the size of a mr region?  let transport return failure?
  *  - should we detect duplicate keys on a socket?  hmm.
  *  - an rdma is an mlock, apply rlimit?
  */
@@ -200,6 +199,14 @@ static int __rds_rdma_map(struct rds_sock *rs, struct 
rds_get_mr_args *args,
goto out;
}
 
+   /* Restrict the size of mr irrespective of underlying transport
+* To account for unaligned mr regions, subtract one from nr_pages
+*/
+   if ((nr_pages - 1) > (RDS_MAX_MSG_SIZE >> PAGE_SHIFT)) {
+   ret = -EMSGSIZE;
+   goto out;
+   }
+
rdsdebug("RDS: get_mr addr %llx len %llu nr_pages %u\n",
args->vec.addr, args->vec.bytes, nr_pages);
 
diff --git a/net/rds/rds.h b/net/rds/rds.h
index 8ccd5a9..f713194 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -50,6 +50,9 @@ void rdsdebug(char *fmt, ...)
 #define RDS_FRAG_SHIFT 12
 #define RDS_FRAG_SIZE  ((unsigned int)(1 << RDS_FRAG_SHIFT))
 
+/* Used to limit both RDMA and non-RDMA RDS message to 1MB */
+#define RDS_MAX_MSG_SIZE   ((unsigned int)(1 << 20))
+
 #define RDS_CONG_MAP_BYTES (65536 / 8)
 #define RDS_CONG_MAP_PAGES (PAGE_ALIGN(RDS_CONG_MAP_BYTES) / PAGE_SIZE)
 #define RDS_CONG_MAP_PAGE_BITS (PAGE_SIZE * 8)
diff --git a/net/rds/send.c b/net/rds/send.c
index 45e025b..5cc6403 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -994,6 +994,26 @@ static int rds_send_mprds_hash(struct rds_sock *rs, struct 
rds_connection *conn)
return hash;
 }
 
+static int rds_rdma_bytes(struct msghdr *msg, size_t *rdma_bytes)
+{
+   struct rds_rdma_args *args;
+   struct cmsghdr *cmsg;
+
+   for_each_cmsghdr(cmsg, msg) {
+   if (!CMSG_OK(msg, cmsg))
+   return -EINVAL;
+
+   if (cmsg->cmsg_level != SOL_RDS)
+   continue;
+
+   if (cmsg->cmsg_type == RDS_CMSG_RDMA_ARGS) {
+   args = CMSG_DATA(cmsg);
+   *rdma_bytes += args->remote_vec.bytes;
+   }
+   }
+   return 0;
+}
+
 int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 {
struct sock *sk = sock->sk;
@@ -1008,6 +1028,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
int nonblock = msg->msg_flags & MSG_DONTWAIT;
long timeo = sock_sndtimeo(sk, nonblock);
struct rds_conn_path *cpath;
+   size_t total_payload_len = payload_len, rdma_payload_len = 0;
 
/* Mirror Linux UDP mirror of BSD error message compatibility */
/* XXX: Perhaps MSG_MORE someday */
@@ -1040,6 +1061,16 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
}
release_sock(sk);
 
+   ret = rds_rdma_bytes(msg, _payload_len);
+   if (ret)
+   goto out;
+
+   total_payload_len += rdma_payload_len;
+   if (max_t(size_t, payload_len, rdma_payload_len) > RDS_MAX_MSG_SIZE) {
+   ret = -EMSGSIZE;
+   goto out;
+   }
+
if (payload_len > rds_sk_sndbuf(rs)) {
ret = -EMSGSIZE;
goto out;
-- 
1.9.1



[net-next][PATCH 09/18] RDS: RDMA: silence the use_once mr log flood

2016-12-04 Thread Santosh Shilimkar
In absence of extension headers, message log will keep
flooding the console. As such even without use_once we can
clean up the MRs so its not really an error case message
so make it debug message

Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c93bad..8151c49 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -415,7 +415,8 @@ void rds_rdma_unuse(struct rds_sock *rs, u32 r_key, int 
force)
spin_lock_irqsave(>rs_rdma_lock, flags);
mr = rds_mr_tree_walk(>rs_rdma_keys, r_key, NULL);
if (!mr) {
-   printk(KERN_ERR "rds: trying to unuse MR with unknown r_key 
%u!\n", r_key);
+   pr_debug("rds: trying to unuse MR with unknown r_key %u!\n",
+r_key);
spin_unlock_irqrestore(>rs_rdma_lock, flags);
return;
}
-- 
1.9.1



[net-next][PATCH 09/18] RDS: RDMA: silence the use_once mr log flood

2016-12-04 Thread Santosh Shilimkar
In absence of extension headers, message log will keep
flooding the console. As such even without use_once we can
clean up the MRs so its not really an error case message
so make it debug message

Signed-off-by: Santosh Shilimkar 
---
 net/rds/rdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c93bad..8151c49 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -415,7 +415,8 @@ void rds_rdma_unuse(struct rds_sock *rs, u32 r_key, int 
force)
spin_lock_irqsave(>rs_rdma_lock, flags);
mr = rds_mr_tree_walk(>rs_rdma_keys, r_key, NULL);
if (!mr) {
-   printk(KERN_ERR "rds: trying to unuse MR with unknown r_key 
%u!\n", r_key);
+   pr_debug("rds: trying to unuse MR with unknown r_key %u!\n",
+r_key);
spin_unlock_irqrestore(>rs_rdma_lock, flags);
return;
}
-- 
1.9.1



[net-next][PATCH 17/18] RDS: add receive message trace used by application

2016-12-04 Thread Santosh Shilimkar
Socket option to tap receive path latency in various stages
in nano seconds. It can be enabled on selective sockets using
using SO_RDS_MSG_RXPATH_LATENCY socket option. RDS will return
the data to application with RDS_CMSG_RXPATH_LATENCY in defined
format. Scope is left to add more trace points for future
without need of change in the interface.

Reviewed-by: Sowmini Varadhan 
Signed-off-by: Santosh Shilimkar 
---
 include/uapi/linux/rds.h | 33 +
 net/rds/af_rds.c | 28 
 net/rds/ib_recv.c|  4 
 net/rds/rds.h| 10 ++
 net/rds/recv.c   | 32 +---
 net/rds/tcp_recv.c   |  5 +
 6 files changed, 109 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 0f9265c..3833113 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -52,6 +52,13 @@
 #define RDS_GET_MR_FOR_DEST7
 #define SO_RDS_TRANSPORT   8
 
+/* Socket option to tap receive path latency
+ * SO_RDS: SO_RDS_MSG_RXPATH_LATENCY
+ * Format used struct rds_rx_trace_so
+ */
+#define SO_RDS_MSG_RXPATH_LATENCY  10
+
+
 /* supported values for SO_RDS_TRANSPORT */
 #defineRDS_TRANS_IB0
 #defineRDS_TRANS_IWARP 1
@@ -77,6 +84,12 @@
  * the same as for the GET_MR setsockopt.
  * RDS_CMSG_RDMA_STATUS (recvmsg)
  * Returns the status of a completed RDMA operation.
+ * RDS_CMSG_RXPATH_LATENCY(recvmsg)
+ * Returns rds message latencies in various stages of receive
+ * path in nS. Its set per socket using SO_RDS_MSG_RXPATH_LATENCY
+ * socket option. Legitimate points are defined in
+ * enum rds_message_rxpath_latency. More points can be added in
+ * future. CSMG format is struct rds_cmsg_rx_trace.
  */
 #define RDS_CMSG_RDMA_ARGS 1
 #define RDS_CMSG_RDMA_DEST 2
@@ -87,6 +100,7 @@
 #define RDS_CMSG_ATOMIC_CSWP   7
 #define RDS_CMSG_MASKED_ATOMIC_FADD8
 #define RDS_CMSG_MASKED_ATOMIC_CSWP9
+#define RDS_CMSG_RXPATH_LATENCY11
 
 #define RDS_INFO_FIRST 1
 #define RDS_INFO_COUNTERS  1
@@ -171,6 +185,25 @@ struct rds_info_rdma_connection {
uint32_trdma_mr_size;
 };
 
+/* RDS message Receive Path Latency points */
+enum rds_message_rxpath_latency {
+   RDS_MSG_RX_HDR_TO_DGRAM_START = 0,
+   RDS_MSG_RX_DGRAM_REASSEMBLE,
+   RDS_MSG_RX_DGRAM_DELIVERED,
+   RDS_MSG_RX_DGRAM_TRACE_MAX
+};
+
+struct rds_rx_trace_so {
+   u8 rx_traces;
+   u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
+};
+
+struct rds_cmsg_rx_trace {
+   u8 rx_traces;
+   u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
+   u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX];
+};
+
 /*
  * Congestion monitoring.
  * Congestion control in RDS happens at the host connection
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c
index 2ac1e61..fd821740 100644
--- a/net/rds/af_rds.c
+++ b/net/rds/af_rds.c
@@ -298,6 +298,30 @@ static int rds_enable_recvtstamp(struct sock *sk, char 
__user *optval,
return 0;
 }
 
+static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval,
+ int optlen)
+{
+   struct rds_rx_trace_so trace;
+   int i;
+
+   if (optlen != sizeof(struct rds_rx_trace_so))
+   return -EFAULT;
+
+   if (copy_from_user(, optval, sizeof(trace)))
+   return -EFAULT;
+
+   rs->rs_rx_traces = trace.rx_traces;
+   for (i = 0; i < rs->rs_rx_traces; i++) {
+   if (trace.rx_trace_pos[i] > RDS_MSG_RX_DGRAM_TRACE_MAX) {
+   rs->rs_rx_traces = 0;
+   return -EFAULT;
+   }
+   rs->rs_rx_trace[i] = trace.rx_trace_pos[i];
+   }
+
+   return 0;
+}
+
 static int rds_setsockopt(struct socket *sock, int level, int optname,
  char __user *optval, unsigned int optlen)
 {
@@ -338,6 +362,9 @@ static int rds_setsockopt(struct socket *sock, int level, 
int optname,
ret = rds_enable_recvtstamp(sock->sk, optval, optlen);
release_sock(sock->sk);
break;
+   case SO_RDS_MSG_RXPATH_LATENCY:
+   ret = rds_recv_track_latency(rs, optval, optlen);
+   break;
default:
ret = -ENOPROTOOPT;
}
@@ -484,6 +511,7 @@ static int __rds_create(struct socket *sock, struct sock 
*sk, int protocol)
INIT_LIST_HEAD(>rs_cong_list);
spin_lock_init(>rs_rdma_lock);
rs->rs_rdma_keys = RB_ROOT;
+   rs->rs_rx_traces = 0;
 
spin_lock_bh(_sock_lock);
list_add_tail(>rs_item, _sock_list);
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 4b0f126..e10624a 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -911,8 +911,12 @@ static void 

[net-next][PATCH 10/18] RDS: IB: track and log active side endpoint in connection

2016-12-04 Thread Santosh Shilimkar
Useful to know the active and passive end points in a
RDS IB connection.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h|  3 +++
 net/rds/ib_cm.c | 11 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index f14c26d..97e7696 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -181,6 +181,9 @@ struct rds_ib_connection {
 
/* Batched completions */
unsigned inti_unsignaled_wrs;
+
+   /* Endpoint role in connection */
+   int i_active_side;
 };
 
 /* This assumes that atomic_t is at least 32 bits */
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 3002acf..4d1bf04 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -120,16 +120,17 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
rds_conn_destroy(conn);
return;
} else {
-   pr_notice("RDS/IB: connected <%pI4,%pI4> version %u.%u%s\n",
+   pr_notice("RDS/IB: %s conn connected <%pI4,%pI4> version 
%u.%u%s\n",
+ ic->i_active_side ? "Active" : "Passive",
  >c_laddr, >c_faddr,
  RDS_PROTOCOL_MAJOR(conn->c_version),
  RDS_PROTOCOL_MINOR(conn->c_version),
  ic->i_flowctl ? ", flow control" : "");
}
 
-   /*
-* Init rings and fill recv. this needs to wait until protocol 
negotiation
-* is complete, since ring layout is different from 3.0 to 3.1.
+   /* Init rings and fill recv. this needs to wait until protocol
+* negotiation is complete, since ring layout is different
+* from 3.1 to 4.1.
 */
rds_ib_send_init_ring(ic);
rds_ib_recv_init_ring(ic);
@@ -685,6 +686,7 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
if (ic->i_cm_id == cm_id)
ret = 0;
}
+   ic->i_active_side = true;
return ret;
 }
 
@@ -859,6 +861,7 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
ic->i_sends = NULL;
vfree(ic->i_recvs);
ic->i_recvs = NULL;
+   ic->i_active_side = false;
 }
 
 int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)
-- 
1.9.1



[net-next][PATCH 11/18] RDS: IB: add few useful cache stasts

2016-12-04 Thread Santosh Shilimkar
Tracks the ib receive cache total, incoming and frag allocations.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h   | 7 +++
 net/rds/ib_recv.c  | 6 ++
 net/rds/ib_stats.c | 2 ++
 3 files changed, 15 insertions(+)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 97e7696..4987387 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -151,6 +151,7 @@ struct rds_ib_connection {
u64 i_ack_recv; /* last ACK received */
struct rds_ib_refill_cache i_cache_incs;
struct rds_ib_refill_cache i_cache_frags;
+   atomic_ti_cache_allocs;
 
/* sending acks */
unsigned long   i_ack_flags;
@@ -254,6 +255,8 @@ struct rds_ib_statistics {
uint64_ts_ib_rx_refill_from_cq;
uint64_ts_ib_rx_refill_from_thread;
uint64_ts_ib_rx_alloc_limit;
+   uint64_ts_ib_rx_total_frags;
+   uint64_ts_ib_rx_total_incs;
uint64_ts_ib_rx_credit_updates;
uint64_ts_ib_ack_sent;
uint64_ts_ib_ack_send_failure;
@@ -276,6 +279,8 @@ struct rds_ib_statistics {
uint64_ts_ib_rdma_mr_1m_reused;
uint64_ts_ib_atomic_cswp;
uint64_ts_ib_atomic_fadd;
+   uint64_ts_ib_recv_added_to_cache;
+   uint64_ts_ib_recv_removed_from_cache;
 };
 
 extern struct workqueue_struct *rds_ib_wq;
@@ -406,6 +411,8 @@ int rds_ib_send_grab_credits(struct rds_ib_connection *ic, 
u32 wanted,
 /* ib_stats.c */
 DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats);
 #define rds_ib_stats_inc(member) rds_stats_inc_which(rds_ib_stats, member)
+#define rds_ib_stats_add(member, count) \
+   rds_stats_add_which(rds_ib_stats, member, count)
 unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
unsigned int avail);
 
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 6803b75..4b0f126 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -194,6 +194,8 @@ static void rds_ib_frag_free(struct rds_ib_connection *ic,
rdsdebug("frag %p page %p\n", frag, sg_page(>f_sg));
 
rds_ib_recv_cache_put(>f_cache_entry, >i_cache_frags);
+   atomic_add(RDS_FRAG_SIZE / SZ_1K, >i_cache_allocs);
+   rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
 }
 
 /* Recycle inc after freeing attached frags */
@@ -261,6 +263,7 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct 
rds_ib_connection *i
atomic_dec(_ib_allocation);
return NULL;
}
+   rds_ib_stats_inc(s_ib_rx_total_incs);
}
INIT_LIST_HEAD(>ii_frags);
rds_inc_init(>ii_inc, ic->conn, ic->conn->c_faddr);
@@ -278,6 +281,8 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct 
rds_ib_connection *ic
cache_item = rds_ib_recv_cache_get(>i_cache_frags);
if (cache_item) {
frag = container_of(cache_item, struct rds_page_frag, 
f_cache_entry);
+   atomic_sub(RDS_FRAG_SIZE / SZ_1K, >i_cache_allocs);
+   rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
} else {
frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask);
if (!frag)
@@ -290,6 +295,7 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct 
rds_ib_connection *ic
kmem_cache_free(rds_ib_frag_slab, frag);
return NULL;
}
+   rds_ib_stats_inc(s_ib_rx_total_frags);
}
 
INIT_LIST_HEAD(>f_item);
diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c
index 7e78dca..9252ad1 100644
--- a/net/rds/ib_stats.c
+++ b/net/rds/ib_stats.c
@@ -55,6 +55,8 @@
"ib_rx_refill_from_cq",
"ib_rx_refill_from_thread",
"ib_rx_alloc_limit",
+   "ib_rx_total_frags",
+   "ib_rx_total_incs",
"ib_rx_credit_updates",
"ib_ack_sent",
"ib_ack_send_failure",
-- 
1.9.1



[net-next][PATCH 14/18] RDS: IB: fix panic due to handlers running post teardown

2016-12-04 Thread Santosh Shilimkar
Shutdown code reaping loop takes care of emptying the
CQ's before they being destroyed. And once tasklets are
killed, the hanlders are not expected to run.

But because of core tasklet code issues, tasklet handler could
still run even after tasklet_kill,
RDS IB shutdown code already reaps the CQs before freeing
cq/qp resources so as such the handlers have nothing left
to do post shutdown.

On other hand any handler running after teardown and trying
to access already freed qp/cq resources causes issues
Patch fixes this race by  makes sure that handlers returns
without any action post teardown.

Reviewed-by: Wengang 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h|  1 +
 net/rds/ib_cm.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 4b133b8..8efd1eb 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -185,6 +185,7 @@ struct rds_ib_connection {
 
/* Endpoint role in connection */
int i_active_side;
+   atomic_ti_cq_quiesce;
 
/* Send/Recv vectors */
int i_scq_vector;
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 33c8584..ce3775a 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -128,6 +128,8 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
  ic->i_flowctl ? ", flow control" : "");
}
 
+   atomic_set(>i_cq_quiesce, 0);
+
/* Init rings and fill recv. this needs to wait until protocol
 * negotiation is complete, since ring layout is different
 * from 3.1 to 4.1.
@@ -267,6 +269,10 @@ static void rds_ib_tasklet_fn_send(unsigned long data)
 
rds_ib_stats_inc(s_ib_tasklet_call);
 
+   /* if cq has been already reaped, ignore incoming cq event */
+   if (atomic_read(>i_cq_quiesce))
+   return;
+
poll_scq(ic, ic->i_send_cq, ic->i_send_wc);
ib_req_notify_cq(ic->i_send_cq, IB_CQ_NEXT_COMP);
poll_scq(ic, ic->i_send_cq, ic->i_send_wc);
@@ -308,6 +314,10 @@ static void rds_ib_tasklet_fn_recv(unsigned long data)
 
rds_ib_stats_inc(s_ib_tasklet_call);
 
+   /* if cq has been already reaped, ignore incoming cq event */
+   if (atomic_read(>i_cq_quiesce))
+   return;
+
memset(, 0, sizeof(state));
poll_rcq(ic, ic->i_recv_cq, ic->i_recv_wc, );
ib_req_notify_cq(ic->i_recv_cq, IB_CQ_SOLICITED);
@@ -804,6 +814,8 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
tasklet_kill(>i_send_tasklet);
tasklet_kill(>i_recv_tasklet);
 
+   atomic_set(>i_cq_quiesce, 1);
+
/* first destroy the ib state that generates callbacks */
if (ic->i_cm_id->qp)
rdma_destroy_qp(ic->i_cm_id);
-- 
1.9.1



[net-next][PATCH 17/18] RDS: add receive message trace used by application

2016-12-04 Thread Santosh Shilimkar
Socket option to tap receive path latency in various stages
in nano seconds. It can be enabled on selective sockets using
using SO_RDS_MSG_RXPATH_LATENCY socket option. RDS will return
the data to application with RDS_CMSG_RXPATH_LATENCY in defined
format. Scope is left to add more trace points for future
without need of change in the interface.

Reviewed-by: Sowmini Varadhan 
Signed-off-by: Santosh Shilimkar 
---
 include/uapi/linux/rds.h | 33 +
 net/rds/af_rds.c | 28 
 net/rds/ib_recv.c|  4 
 net/rds/rds.h| 10 ++
 net/rds/recv.c   | 32 +---
 net/rds/tcp_recv.c   |  5 +
 6 files changed, 109 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 0f9265c..3833113 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -52,6 +52,13 @@
 #define RDS_GET_MR_FOR_DEST7
 #define SO_RDS_TRANSPORT   8
 
+/* Socket option to tap receive path latency
+ * SO_RDS: SO_RDS_MSG_RXPATH_LATENCY
+ * Format used struct rds_rx_trace_so
+ */
+#define SO_RDS_MSG_RXPATH_LATENCY  10
+
+
 /* supported values for SO_RDS_TRANSPORT */
 #defineRDS_TRANS_IB0
 #defineRDS_TRANS_IWARP 1
@@ -77,6 +84,12 @@
  * the same as for the GET_MR setsockopt.
  * RDS_CMSG_RDMA_STATUS (recvmsg)
  * Returns the status of a completed RDMA operation.
+ * RDS_CMSG_RXPATH_LATENCY(recvmsg)
+ * Returns rds message latencies in various stages of receive
+ * path in nS. Its set per socket using SO_RDS_MSG_RXPATH_LATENCY
+ * socket option. Legitimate points are defined in
+ * enum rds_message_rxpath_latency. More points can be added in
+ * future. CSMG format is struct rds_cmsg_rx_trace.
  */
 #define RDS_CMSG_RDMA_ARGS 1
 #define RDS_CMSG_RDMA_DEST 2
@@ -87,6 +100,7 @@
 #define RDS_CMSG_ATOMIC_CSWP   7
 #define RDS_CMSG_MASKED_ATOMIC_FADD8
 #define RDS_CMSG_MASKED_ATOMIC_CSWP9
+#define RDS_CMSG_RXPATH_LATENCY11
 
 #define RDS_INFO_FIRST 1
 #define RDS_INFO_COUNTERS  1
@@ -171,6 +185,25 @@ struct rds_info_rdma_connection {
uint32_trdma_mr_size;
 };
 
+/* RDS message Receive Path Latency points */
+enum rds_message_rxpath_latency {
+   RDS_MSG_RX_HDR_TO_DGRAM_START = 0,
+   RDS_MSG_RX_DGRAM_REASSEMBLE,
+   RDS_MSG_RX_DGRAM_DELIVERED,
+   RDS_MSG_RX_DGRAM_TRACE_MAX
+};
+
+struct rds_rx_trace_so {
+   u8 rx_traces;
+   u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
+};
+
+struct rds_cmsg_rx_trace {
+   u8 rx_traces;
+   u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
+   u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX];
+};
+
 /*
  * Congestion monitoring.
  * Congestion control in RDS happens at the host connection
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c
index 2ac1e61..fd821740 100644
--- a/net/rds/af_rds.c
+++ b/net/rds/af_rds.c
@@ -298,6 +298,30 @@ static int rds_enable_recvtstamp(struct sock *sk, char 
__user *optval,
return 0;
 }
 
+static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval,
+ int optlen)
+{
+   struct rds_rx_trace_so trace;
+   int i;
+
+   if (optlen != sizeof(struct rds_rx_trace_so))
+   return -EFAULT;
+
+   if (copy_from_user(, optval, sizeof(trace)))
+   return -EFAULT;
+
+   rs->rs_rx_traces = trace.rx_traces;
+   for (i = 0; i < rs->rs_rx_traces; i++) {
+   if (trace.rx_trace_pos[i] > RDS_MSG_RX_DGRAM_TRACE_MAX) {
+   rs->rs_rx_traces = 0;
+   return -EFAULT;
+   }
+   rs->rs_rx_trace[i] = trace.rx_trace_pos[i];
+   }
+
+   return 0;
+}
+
 static int rds_setsockopt(struct socket *sock, int level, int optname,
  char __user *optval, unsigned int optlen)
 {
@@ -338,6 +362,9 @@ static int rds_setsockopt(struct socket *sock, int level, 
int optname,
ret = rds_enable_recvtstamp(sock->sk, optval, optlen);
release_sock(sock->sk);
break;
+   case SO_RDS_MSG_RXPATH_LATENCY:
+   ret = rds_recv_track_latency(rs, optval, optlen);
+   break;
default:
ret = -ENOPROTOOPT;
}
@@ -484,6 +511,7 @@ static int __rds_create(struct socket *sock, struct sock 
*sk, int protocol)
INIT_LIST_HEAD(>rs_cong_list);
spin_lock_init(>rs_rdma_lock);
rs->rs_rdma_keys = RB_ROOT;
+   rs->rs_rx_traces = 0;
 
spin_lock_bh(_sock_lock);
list_add_tail(>rs_item, _sock_list);
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 4b0f126..e10624a 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -911,8 +911,12 @@ static void rds_ib_process_recv(struct rds_connection 
*conn,

[net-next][PATCH 10/18] RDS: IB: track and log active side endpoint in connection

2016-12-04 Thread Santosh Shilimkar
Useful to know the active and passive end points in a
RDS IB connection.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h|  3 +++
 net/rds/ib_cm.c | 11 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index f14c26d..97e7696 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -181,6 +181,9 @@ struct rds_ib_connection {
 
/* Batched completions */
unsigned inti_unsignaled_wrs;
+
+   /* Endpoint role in connection */
+   int i_active_side;
 };
 
 /* This assumes that atomic_t is at least 32 bits */
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 3002acf..4d1bf04 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -120,16 +120,17 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
rds_conn_destroy(conn);
return;
} else {
-   pr_notice("RDS/IB: connected <%pI4,%pI4> version %u.%u%s\n",
+   pr_notice("RDS/IB: %s conn connected <%pI4,%pI4> version 
%u.%u%s\n",
+ ic->i_active_side ? "Active" : "Passive",
  >c_laddr, >c_faddr,
  RDS_PROTOCOL_MAJOR(conn->c_version),
  RDS_PROTOCOL_MINOR(conn->c_version),
  ic->i_flowctl ? ", flow control" : "");
}
 
-   /*
-* Init rings and fill recv. this needs to wait until protocol 
negotiation
-* is complete, since ring layout is different from 3.0 to 3.1.
+   /* Init rings and fill recv. this needs to wait until protocol
+* negotiation is complete, since ring layout is different
+* from 3.1 to 4.1.
 */
rds_ib_send_init_ring(ic);
rds_ib_recv_init_ring(ic);
@@ -685,6 +686,7 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
if (ic->i_cm_id == cm_id)
ret = 0;
}
+   ic->i_active_side = true;
return ret;
 }
 
@@ -859,6 +861,7 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
ic->i_sends = NULL;
vfree(ic->i_recvs);
ic->i_recvs = NULL;
+   ic->i_active_side = false;
 }
 
 int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)
-- 
1.9.1



[net-next][PATCH 11/18] RDS: IB: add few useful cache stasts

2016-12-04 Thread Santosh Shilimkar
Tracks the ib receive cache total, incoming and frag allocations.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h   | 7 +++
 net/rds/ib_recv.c  | 6 ++
 net/rds/ib_stats.c | 2 ++
 3 files changed, 15 insertions(+)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 97e7696..4987387 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -151,6 +151,7 @@ struct rds_ib_connection {
u64 i_ack_recv; /* last ACK received */
struct rds_ib_refill_cache i_cache_incs;
struct rds_ib_refill_cache i_cache_frags;
+   atomic_ti_cache_allocs;
 
/* sending acks */
unsigned long   i_ack_flags;
@@ -254,6 +255,8 @@ struct rds_ib_statistics {
uint64_ts_ib_rx_refill_from_cq;
uint64_ts_ib_rx_refill_from_thread;
uint64_ts_ib_rx_alloc_limit;
+   uint64_ts_ib_rx_total_frags;
+   uint64_ts_ib_rx_total_incs;
uint64_ts_ib_rx_credit_updates;
uint64_ts_ib_ack_sent;
uint64_ts_ib_ack_send_failure;
@@ -276,6 +279,8 @@ struct rds_ib_statistics {
uint64_ts_ib_rdma_mr_1m_reused;
uint64_ts_ib_atomic_cswp;
uint64_ts_ib_atomic_fadd;
+   uint64_ts_ib_recv_added_to_cache;
+   uint64_ts_ib_recv_removed_from_cache;
 };
 
 extern struct workqueue_struct *rds_ib_wq;
@@ -406,6 +411,8 @@ int rds_ib_send_grab_credits(struct rds_ib_connection *ic, 
u32 wanted,
 /* ib_stats.c */
 DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats);
 #define rds_ib_stats_inc(member) rds_stats_inc_which(rds_ib_stats, member)
+#define rds_ib_stats_add(member, count) \
+   rds_stats_add_which(rds_ib_stats, member, count)
 unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
unsigned int avail);
 
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 6803b75..4b0f126 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -194,6 +194,8 @@ static void rds_ib_frag_free(struct rds_ib_connection *ic,
rdsdebug("frag %p page %p\n", frag, sg_page(>f_sg));
 
rds_ib_recv_cache_put(>f_cache_entry, >i_cache_frags);
+   atomic_add(RDS_FRAG_SIZE / SZ_1K, >i_cache_allocs);
+   rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
 }
 
 /* Recycle inc after freeing attached frags */
@@ -261,6 +263,7 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct 
rds_ib_connection *i
atomic_dec(_ib_allocation);
return NULL;
}
+   rds_ib_stats_inc(s_ib_rx_total_incs);
}
INIT_LIST_HEAD(>ii_frags);
rds_inc_init(>ii_inc, ic->conn, ic->conn->c_faddr);
@@ -278,6 +281,8 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct 
rds_ib_connection *ic
cache_item = rds_ib_recv_cache_get(>i_cache_frags);
if (cache_item) {
frag = container_of(cache_item, struct rds_page_frag, 
f_cache_entry);
+   atomic_sub(RDS_FRAG_SIZE / SZ_1K, >i_cache_allocs);
+   rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
} else {
frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask);
if (!frag)
@@ -290,6 +295,7 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct 
rds_ib_connection *ic
kmem_cache_free(rds_ib_frag_slab, frag);
return NULL;
}
+   rds_ib_stats_inc(s_ib_rx_total_frags);
}
 
INIT_LIST_HEAD(>f_item);
diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c
index 7e78dca..9252ad1 100644
--- a/net/rds/ib_stats.c
+++ b/net/rds/ib_stats.c
@@ -55,6 +55,8 @@
"ib_rx_refill_from_cq",
"ib_rx_refill_from_thread",
"ib_rx_alloc_limit",
+   "ib_rx_total_frags",
+   "ib_rx_total_incs",
"ib_rx_credit_updates",
"ib_ack_sent",
"ib_ack_send_failure",
-- 
1.9.1



[net-next][PATCH 14/18] RDS: IB: fix panic due to handlers running post teardown

2016-12-04 Thread Santosh Shilimkar
Shutdown code reaping loop takes care of emptying the
CQ's before they being destroyed. And once tasklets are
killed, the hanlders are not expected to run.

But because of core tasklet code issues, tasklet handler could
still run even after tasklet_kill,
RDS IB shutdown code already reaps the CQs before freeing
cq/qp resources so as such the handlers have nothing left
to do post shutdown.

On other hand any handler running after teardown and trying
to access already freed qp/cq resources causes issues
Patch fixes this race by  makes sure that handlers returns
without any action post teardown.

Reviewed-by: Wengang 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h|  1 +
 net/rds/ib_cm.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index 4b133b8..8efd1eb 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -185,6 +185,7 @@ struct rds_ib_connection {
 
/* Endpoint role in connection */
int i_active_side;
+   atomic_ti_cq_quiesce;
 
/* Send/Recv vectors */
int i_scq_vector;
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 33c8584..ce3775a 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -128,6 +128,8 @@ void rds_ib_cm_connect_complete(struct rds_connection 
*conn, struct rdma_cm_even
  ic->i_flowctl ? ", flow control" : "");
}
 
+   atomic_set(>i_cq_quiesce, 0);
+
/* Init rings and fill recv. this needs to wait until protocol
 * negotiation is complete, since ring layout is different
 * from 3.1 to 4.1.
@@ -267,6 +269,10 @@ static void rds_ib_tasklet_fn_send(unsigned long data)
 
rds_ib_stats_inc(s_ib_tasklet_call);
 
+   /* if cq has been already reaped, ignore incoming cq event */
+   if (atomic_read(>i_cq_quiesce))
+   return;
+
poll_scq(ic, ic->i_send_cq, ic->i_send_wc);
ib_req_notify_cq(ic->i_send_cq, IB_CQ_NEXT_COMP);
poll_scq(ic, ic->i_send_cq, ic->i_send_wc);
@@ -308,6 +314,10 @@ static void rds_ib_tasklet_fn_recv(unsigned long data)
 
rds_ib_stats_inc(s_ib_tasklet_call);
 
+   /* if cq has been already reaped, ignore incoming cq event */
+   if (atomic_read(>i_cq_quiesce))
+   return;
+
memset(, 0, sizeof(state));
poll_rcq(ic, ic->i_recv_cq, ic->i_recv_wc, );
ib_req_notify_cq(ic->i_recv_cq, IB_CQ_SOLICITED);
@@ -804,6 +814,8 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
tasklet_kill(>i_send_tasklet);
tasklet_kill(>i_recv_tasklet);
 
+   atomic_set(>i_cq_quiesce, 1);
+
/* first destroy the ib state that generates callbacks */
if (ic->i_cm_id->qp)
rdma_destroy_qp(ic->i_cm_id);
-- 
1.9.1



[net-next][PATCH 08/18] RDS: IB: split the mr registration and invalidation path

2016-12-04 Thread Santosh Shilimkar
MR invalidation in RDS is done in background thread and not in
data path like registration. So break the dependency between them
which helps to remove the performance bottleneck.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h  |  4 +++-
 net/rds/ib_cm.c   |  9 +++--
 net/rds/ib_frmr.c | 11 ++-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index f4e8121..f14c26d 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -14,7 +14,8 @@
 
 #define RDS_IB_DEFAULT_RECV_WR 1024
 #define RDS_IB_DEFAULT_SEND_WR 256
-#define RDS_IB_DEFAULT_FR_WR   512
+#define RDS_IB_DEFAULT_FR_WR   256
+#define RDS_IB_DEFAULT_FR_INV_WR   256
 
 #define RDS_IB_DEFAULT_RETRY_COUNT 1
 
@@ -125,6 +126,7 @@ struct rds_ib_connection {
 
/* To control the number of wrs from fastreg */
atomic_ti_fastreg_wrs;
+   atomic_ti_fastunreg_wrs;
 
/* interrupt handling */
struct tasklet_struct   i_send_tasklet;
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index b9da1e5..3002acf 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -382,7 +382,10 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
 * completion queue and send queue. This extra space is used for FRMR
 * registration and invalidation work requests
 */
-   fr_queue_space = (rds_ibdev->use_fastreg ? RDS_IB_DEFAULT_FR_WR : 0);
+   fr_queue_space = rds_ibdev->use_fastreg ?
+(RDS_IB_DEFAULT_FR_WR + 1) +
+(RDS_IB_DEFAULT_FR_INV_WR + 1)
+: 0;
 
/* add the conn now so that connection establishment has the dev */
rds_ib_add_conn(rds_ibdev, conn);
@@ -444,6 +447,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
attr.send_cq = ic->i_send_cq;
attr.recv_cq = ic->i_recv_cq;
atomic_set(>i_fastreg_wrs, RDS_IB_DEFAULT_FR_WR);
+   atomic_set(>i_fastunreg_wrs, RDS_IB_DEFAULT_FR_INV_WR);
 
/*
 * XXX this can fail if max_*_wr is too large?  Are we supposed
@@ -766,7 +770,8 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
wait_event(rds_ib_ring_empty_wait,
   rds_ib_ring_empty(>i_recv_ring) &&
   (atomic_read(>i_signaled_sends) == 0) &&
-  (atomic_read(>i_fastreg_wrs) == 
RDS_IB_DEFAULT_FR_WR));
+  (atomic_read(>i_fastreg_wrs) == 
RDS_IB_DEFAULT_FR_WR) &&
+  (atomic_read(>i_fastunreg_wrs) == 
RDS_IB_DEFAULT_FR_INV_WR));
tasklet_kill(>i_send_tasklet);
tasklet_kill(>i_recv_tasklet);
 
diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 66b3d62..48332a6 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -241,8 +241,8 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
if (frmr->fr_state != FRMR_IS_INUSE)
goto out;
 
-   while (atomic_dec_return(>ic->i_fastreg_wrs) <= 0) {
-   atomic_inc(>ic->i_fastreg_wrs);
+   while (atomic_dec_return(>ic->i_fastunreg_wrs) <= 0) {
+   atomic_inc(>ic->i_fastunreg_wrs);
cpu_relax();
}
 
@@ -261,7 +261,7 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
if (unlikely(ret)) {
frmr->fr_state = FRMR_IS_STALE;
frmr->fr_inv = false;
-   atomic_inc(>ic->i_fastreg_wrs);
+   atomic_inc(>ic->i_fastunreg_wrs);
pr_err("RDS/IB: %s returned error(%d)\n", __func__, ret);
goto out;
}
@@ -289,9 +289,10 @@ void rds_ib_mr_cqe_handler(struct rds_ib_connection *ic, 
struct ib_wc *wc)
if (frmr->fr_inv) {
frmr->fr_state = FRMR_IS_FREE;
frmr->fr_inv = false;
+   atomic_inc(>i_fastreg_wrs);
+   } else {
+   atomic_inc(>i_fastunreg_wrs);
}
-
-   atomic_inc(>i_fastreg_wrs);
 }
 
 void rds_ib_unreg_frmr(struct list_head *list, unsigned int *nfreed,
-- 
1.9.1



[net-next][PATCH 07/18] RDS: RDMA: return appropriate error on rdma map failures

2016-12-04 Thread Santosh Shilimkar
The first message to a remote node should prompt a new
connection even if it is RDMA operation. For RDMA operation
the MR mapping can fail because connections is not yet up.

Since the connection establishment is asynchronous,
we make sure the map failure because of unavailable
connection reach to the user by appropriate error code.
Before returning to the user, lets trigger the connection
so that its ready for the next retry.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/send.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index bb13c56..0a6f38b 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -945,6 +945,11 @@ static int rds_cmsg_send(struct rds_sock *rs, struct 
rds_message *rm,
ret = rds_cmsg_rdma_map(rs, rm, cmsg);
if (!ret)
*allocated_mr = 1;
+   else if (ret == -ENODEV)
+   /* Accommodate the get_mr() case which can fail
+* if connection isn't established yet.
+*/
+   ret = -EAGAIN;
break;
case RDS_CMSG_ATOMIC_CSWP:
case RDS_CMSG_ATOMIC_FADD:
@@ -1082,8 +1087,12 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
 
/* Parse any control messages the user may have included. */
ret = rds_cmsg_send(rs, rm, msg, _mr);
-   if (ret)
+   if (ret) {
+   /* Trigger connection so that its ready for the next retry */
+   if (ret ==  -EAGAIN)
+   rds_conn_connect_if_down(conn);
goto out;
+   }
 
if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) {
printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",
-- 
1.9.1



[net-next][PATCH 08/18] RDS: IB: split the mr registration and invalidation path

2016-12-04 Thread Santosh Shilimkar
MR invalidation in RDS is done in background thread and not in
data path like registration. So break the dependency between them
which helps to remove the performance bottleneck.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.h  |  4 +++-
 net/rds/ib_cm.c   |  9 +++--
 net/rds/ib_frmr.c | 11 ++-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/net/rds/ib.h b/net/rds/ib.h
index f4e8121..f14c26d 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -14,7 +14,8 @@
 
 #define RDS_IB_DEFAULT_RECV_WR 1024
 #define RDS_IB_DEFAULT_SEND_WR 256
-#define RDS_IB_DEFAULT_FR_WR   512
+#define RDS_IB_DEFAULT_FR_WR   256
+#define RDS_IB_DEFAULT_FR_INV_WR   256
 
 #define RDS_IB_DEFAULT_RETRY_COUNT 1
 
@@ -125,6 +126,7 @@ struct rds_ib_connection {
 
/* To control the number of wrs from fastreg */
atomic_ti_fastreg_wrs;
+   atomic_ti_fastunreg_wrs;
 
/* interrupt handling */
struct tasklet_struct   i_send_tasklet;
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index b9da1e5..3002acf 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -382,7 +382,10 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
 * completion queue and send queue. This extra space is used for FRMR
 * registration and invalidation work requests
 */
-   fr_queue_space = (rds_ibdev->use_fastreg ? RDS_IB_DEFAULT_FR_WR : 0);
+   fr_queue_space = rds_ibdev->use_fastreg ?
+(RDS_IB_DEFAULT_FR_WR + 1) +
+(RDS_IB_DEFAULT_FR_INV_WR + 1)
+: 0;
 
/* add the conn now so that connection establishment has the dev */
rds_ib_add_conn(rds_ibdev, conn);
@@ -444,6 +447,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
attr.send_cq = ic->i_send_cq;
attr.recv_cq = ic->i_recv_cq;
atomic_set(>i_fastreg_wrs, RDS_IB_DEFAULT_FR_WR);
+   atomic_set(>i_fastunreg_wrs, RDS_IB_DEFAULT_FR_INV_WR);
 
/*
 * XXX this can fail if max_*_wr is too large?  Are we supposed
@@ -766,7 +770,8 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
wait_event(rds_ib_ring_empty_wait,
   rds_ib_ring_empty(>i_recv_ring) &&
   (atomic_read(>i_signaled_sends) == 0) &&
-  (atomic_read(>i_fastreg_wrs) == 
RDS_IB_DEFAULT_FR_WR));
+  (atomic_read(>i_fastreg_wrs) == 
RDS_IB_DEFAULT_FR_WR) &&
+  (atomic_read(>i_fastunreg_wrs) == 
RDS_IB_DEFAULT_FR_INV_WR));
tasklet_kill(>i_send_tasklet);
tasklet_kill(>i_recv_tasklet);
 
diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 66b3d62..48332a6 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -241,8 +241,8 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
if (frmr->fr_state != FRMR_IS_INUSE)
goto out;
 
-   while (atomic_dec_return(>ic->i_fastreg_wrs) <= 0) {
-   atomic_inc(>ic->i_fastreg_wrs);
+   while (atomic_dec_return(>ic->i_fastunreg_wrs) <= 0) {
+   atomic_inc(>ic->i_fastunreg_wrs);
cpu_relax();
}
 
@@ -261,7 +261,7 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr)
if (unlikely(ret)) {
frmr->fr_state = FRMR_IS_STALE;
frmr->fr_inv = false;
-   atomic_inc(>ic->i_fastreg_wrs);
+   atomic_inc(>ic->i_fastunreg_wrs);
pr_err("RDS/IB: %s returned error(%d)\n", __func__, ret);
goto out;
}
@@ -289,9 +289,10 @@ void rds_ib_mr_cqe_handler(struct rds_ib_connection *ic, 
struct ib_wc *wc)
if (frmr->fr_inv) {
frmr->fr_state = FRMR_IS_FREE;
frmr->fr_inv = false;
+   atomic_inc(>i_fastreg_wrs);
+   } else {
+   atomic_inc(>i_fastunreg_wrs);
}
-
-   atomic_inc(>i_fastreg_wrs);
 }
 
 void rds_ib_unreg_frmr(struct list_head *list, unsigned int *nfreed,
-- 
1.9.1



[net-next][PATCH 07/18] RDS: RDMA: return appropriate error on rdma map failures

2016-12-04 Thread Santosh Shilimkar
The first message to a remote node should prompt a new
connection even if it is RDMA operation. For RDMA operation
the MR mapping can fail because connections is not yet up.

Since the connection establishment is asynchronous,
we make sure the map failure because of unavailable
connection reach to the user by appropriate error code.
Before returning to the user, lets trigger the connection
so that its ready for the next retry.

Signed-off-by: Santosh Shilimkar 
---
 net/rds/send.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index bb13c56..0a6f38b 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -945,6 +945,11 @@ static int rds_cmsg_send(struct rds_sock *rs, struct 
rds_message *rm,
ret = rds_cmsg_rdma_map(rs, rm, cmsg);
if (!ret)
*allocated_mr = 1;
+   else if (ret == -ENODEV)
+   /* Accommodate the get_mr() case which can fail
+* if connection isn't established yet.
+*/
+   ret = -EAGAIN;
break;
case RDS_CMSG_ATOMIC_CSWP:
case RDS_CMSG_ATOMIC_FADD:
@@ -1082,8 +1087,12 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t payload_len)
 
/* Parse any control messages the user may have included. */
ret = rds_cmsg_send(rs, rm, msg, _mr);
-   if (ret)
+   if (ret) {
+   /* Trigger connection so that its ready for the next retry */
+   if (ret ==  -EAGAIN)
+   rds_conn_connect_if_down(conn);
goto out;
+   }
 
if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) {
printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",
-- 
1.9.1



[net-next][PATCH 13/18] RDS: RDMA: Fix the composite message user notification

2016-12-04 Thread Santosh Shilimkar
When application sends an RDS RDMA composite message consist of
RDMA transfer to be followed up by non RDMA payload, it expect to
be notified *only* when the full message gets delivered. RDS RDMA
notification doesn't behave this way though.

Thanks to Venkat for debug and root casuing the issue
where only first part of the message(RDMA) was
successfully delivered but remainder payload delivery failed.
In that case, application should not be notified with
a false positive of message delivery success.

Fix this case by making sure the user gets notified only after
the full message delivery.

Reviewed-by: Venkat Venkatsubra 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_send.c | 25 +++--
 net/rds/rdma.c| 10 ++
 net/rds/rds.h |  1 +
 net/rds/send.c|  4 +++-
 4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 19eca5c..5e72de1 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -69,16 +69,6 @@ static void rds_ib_send_complete(struct rds_message *rm,
complete(rm, notify_status);
 }
 
-static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
-  struct rm_data_op *op,
-  int wc_status)
-{
-   if (op->op_nents)
-   ib_dma_unmap_sg(ic->i_cm_id->device,
-   op->op_sg, op->op_nents,
-   DMA_TO_DEVICE);
-}
-
 static void rds_ib_send_unmap_rdma(struct rds_ib_connection *ic,
   struct rm_rdma_op *op,
   int wc_status)
@@ -139,6 +129,21 @@ static void rds_ib_send_unmap_atomic(struct 
rds_ib_connection *ic,
rds_ib_stats_inc(s_ib_atomic_fadd);
 }
 
+static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
+  struct rm_data_op *op,
+  int wc_status)
+{
+   struct rds_message *rm = container_of(op, struct rds_message, data);
+
+   if (op->op_nents)
+   ib_dma_unmap_sg(ic->i_cm_id->device,
+   op->op_sg, op->op_nents,
+   DMA_TO_DEVICE);
+
+   if (rm->rdma.op_active && rm->data.op_notify)
+   rds_ib_send_unmap_rdma(ic, >rdma, wc_status);
+}
+
 /*
  * Unmap the resources associated with a struct send_work.
  *
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 8151c49..dd508e0 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -627,6 +627,16 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct 
rds_message *rm,
}
op->op_notifier->n_user_token = args->user_token;
op->op_notifier->n_status = RDS_RDMA_SUCCESS;
+
+   /* Enable rmda notification on data operation for composite
+* rds messages and make sure notification is enabled only
+* for the data operation which follows it so that application
+* gets notified only after full message gets delivered.
+*/
+   if (rm->data.op_sg) {
+   rm->rdma.op_notify = 0;
+   rm->data.op_notify = !!(args->flags & 
RDS_RDMA_NOTIFY_ME);
+   }
}
 
/* The cookie contains the R_Key of the remote memory region, and
diff --git a/net/rds/rds.h b/net/rds/rds.h
index ebbf909..0bb8213 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -419,6 +419,7 @@ struct rds_message {
} rdma;
struct rm_data_op {
unsigned intop_active:1;
+   unsigned intop_notify:1;
unsigned intop_nents;
unsigned intop_count;
unsigned intop_dmasg;
diff --git a/net/rds/send.c b/net/rds/send.c
index 0a6f38b..45e025b 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -476,12 +476,14 @@ void rds_rdma_send_complete(struct rds_message *rm, int 
status)
struct rm_rdma_op *ro;
struct rds_notifier *notifier;
unsigned long flags;
+   unsigned int notify = 0;
 
spin_lock_irqsave(>m_rs_lock, flags);
 
+   notify =  rm->rdma.op_notify | rm->data.op_notify;
ro = >rdma;
if (test_bit(RDS_MSG_ON_SOCK, >m_flags) &&
-   ro->op_active && ro->op_notify && ro->op_notifier) {
+   ro->op_active && notify && ro->op_notifier) {
notifier = ro->op_notifier;
rs = rm->m_rs;
sock_hold(rds_rs_to_sk(rs));
-- 
1.9.1



[net-next][PATCH 12/18] RDS: IB: Add vector spreading for cqs

2016-12-04 Thread Santosh Shilimkar
Based on available device vectors, allocate cqs accordingly to
get better spread of completion vectors which helps performace
great deal..

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.c| 11 +++
 net/rds/ib.h|  5 +
 net/rds/ib_cm.c | 40 +---
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/net/rds/ib.c b/net/rds/ib.c
index 5680d90..8d70884 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -111,6 +111,9 @@ static void rds_ib_dev_free(struct work_struct *work)
kfree(i_ipaddr);
}
 
+   if (rds_ibdev->vector_load)
+   kfree(rds_ibdev->vector_load);
+
kfree(rds_ibdev);
 }
 
@@ -159,6 +162,14 @@ static void rds_ib_add_one(struct ib_device *device)
rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
 
+   rds_ibdev->vector_load = kzalloc(sizeof(int) * device->num_comp_vectors,
+GFP_KERNEL);
+   if (!rds_ibdev->vector_load) {
+   pr_err("RDS/IB: %s failed to allocate vector memory\n",
+   __func__);
+   goto put_dev;
+   }
+
rds_ibdev->dev = device;
rds_ibdev->pd = ib_alloc_pd(device, 0);
if (IS_ERR(rds_ibdev->pd)) {
diff --git a/net/rds/ib.h b/net/rds/ib.h
index 4987387..4b133b8 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -185,6 +185,10 @@ struct rds_ib_connection {
 
/* Endpoint role in connection */
int i_active_side;
+
+   /* Send/Recv vectors */
+   int i_scq_vector;
+   int i_rcq_vector;
 };
 
 /* This assumes that atomic_t is at least 32 bits */
@@ -227,6 +231,7 @@ struct rds_ib_device {
spinlock_t  spinlock;   /* protect the above */
atomic_trefcount;
struct work_struct  free_work;
+   int *vector_load;
 };
 
 #define ibdev_to_node(ibdev) dev_to_node(ibdev->dma_device)
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 4d1bf04..33c8584 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -358,6 +358,28 @@ static void rds_ib_cq_comp_handler_send(struct ib_cq *cq, 
void *context)
tasklet_schedule(>i_send_tasklet);
 }
 
+static inline int ibdev_get_unused_vector(struct rds_ib_device *rds_ibdev)
+{
+   int min = rds_ibdev->vector_load[rds_ibdev->dev->num_comp_vectors - 1];
+   int index = rds_ibdev->dev->num_comp_vectors - 1;
+   int i;
+
+   for (i = rds_ibdev->dev->num_comp_vectors - 1; i >= 0; i--) {
+   if (rds_ibdev->vector_load[i] < min) {
+   index = i;
+   min = rds_ibdev->vector_load[i];
+   }
+   }
+
+   rds_ibdev->vector_load[index]++;
+   return index;
+}
+
+static inline void ibdev_put_vector(struct rds_ib_device *rds_ibdev, int index)
+{
+   rds_ibdev->vector_load[index]--;
+}
+
 /*
  * This needs to be very careful to not leave IS_ERR pointers around for
  * cleanup to trip over.
@@ -399,25 +421,30 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
/* Protection domain and memory range */
ic->i_pd = rds_ibdev->pd;
 
+   ic->i_scq_vector = ibdev_get_unused_vector(rds_ibdev);
cq_attr.cqe = ic->i_send_ring.w_nr + fr_queue_space + 1;
-
+   cq_attr.comp_vector = ic->i_scq_vector;
ic->i_send_cq = ib_create_cq(dev, rds_ib_cq_comp_handler_send,
 rds_ib_cq_event_handler, conn,
 _attr);
if (IS_ERR(ic->i_send_cq)) {
ret = PTR_ERR(ic->i_send_cq);
ic->i_send_cq = NULL;
+   ibdev_put_vector(rds_ibdev, ic->i_scq_vector);
rdsdebug("ib_create_cq send failed: %d\n", ret);
goto out;
}
 
+   ic->i_rcq_vector = ibdev_get_unused_vector(rds_ibdev);
cq_attr.cqe = ic->i_recv_ring.w_nr;
+   cq_attr.comp_vector = ic->i_rcq_vector;
ic->i_recv_cq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv,
 rds_ib_cq_event_handler, conn,
 _attr);
if (IS_ERR(ic->i_recv_cq)) {
ret = PTR_ERR(ic->i_recv_cq);
ic->i_recv_cq = NULL;
+   ibdev_put_vector(rds_ibdev, ic->i_rcq_vector);
rdsdebug("ib_create_cq recv failed: %d\n", ret);
goto out;
}
@@ -780,10 +807,17 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
/* first destroy the ib state that generates callbacks */
if (ic->i_cm_id->qp)
rdma_destroy_qp(ic->i_cm_id);
-   if (ic->i_send_cq)
+   if (ic->i_send_cq) {
+   if (ic->rds_ibdev)
+

[net-next][PATCH 01/18] RDS: log the address on bind failure

2016-12-04 Thread Santosh Shilimkar
It's useful to know the IP address when RDS fails to bind a
connection. Thus, adding it to the error message.

Orabug: 21894138
Reviewed-by: Wei Lin Guay 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/bind.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rds/bind.c b/net/rds/bind.c
index 095f6ce..3a915be 100644
--- a/net/rds/bind.c
+++ b/net/rds/bind.c
@@ -176,8 +176,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, 
int addr_len)
if (!trans) {
ret = -EADDRNOTAVAIL;
rds_remove_bound(rs);
-   printk_ratelimited(KERN_INFO "RDS: rds_bind() could not find a 
transport, "
-   "load rds_tcp or rds_rdma?\n");
+   pr_info_ratelimited("RDS: %s could not find a transport for 
%pI4, load rds_tcp or rds_rdma?\n",
+   __func__, >sin_addr.s_addr);
goto out;
}
 
-- 
1.9.1



[net-next][PATCH 13/18] RDS: RDMA: Fix the composite message user notification

2016-12-04 Thread Santosh Shilimkar
When application sends an RDS RDMA composite message consist of
RDMA transfer to be followed up by non RDMA payload, it expect to
be notified *only* when the full message gets delivered. RDS RDMA
notification doesn't behave this way though.

Thanks to Venkat for debug and root casuing the issue
where only first part of the message(RDMA) was
successfully delivered but remainder payload delivery failed.
In that case, application should not be notified with
a false positive of message delivery success.

Fix this case by making sure the user gets notified only after
the full message delivery.

Reviewed-by: Venkat Venkatsubra 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib_send.c | 25 +++--
 net/rds/rdma.c| 10 ++
 net/rds/rds.h |  1 +
 net/rds/send.c|  4 +++-
 4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 19eca5c..5e72de1 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -69,16 +69,6 @@ static void rds_ib_send_complete(struct rds_message *rm,
complete(rm, notify_status);
 }
 
-static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
-  struct rm_data_op *op,
-  int wc_status)
-{
-   if (op->op_nents)
-   ib_dma_unmap_sg(ic->i_cm_id->device,
-   op->op_sg, op->op_nents,
-   DMA_TO_DEVICE);
-}
-
 static void rds_ib_send_unmap_rdma(struct rds_ib_connection *ic,
   struct rm_rdma_op *op,
   int wc_status)
@@ -139,6 +129,21 @@ static void rds_ib_send_unmap_atomic(struct 
rds_ib_connection *ic,
rds_ib_stats_inc(s_ib_atomic_fadd);
 }
 
+static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
+  struct rm_data_op *op,
+  int wc_status)
+{
+   struct rds_message *rm = container_of(op, struct rds_message, data);
+
+   if (op->op_nents)
+   ib_dma_unmap_sg(ic->i_cm_id->device,
+   op->op_sg, op->op_nents,
+   DMA_TO_DEVICE);
+
+   if (rm->rdma.op_active && rm->data.op_notify)
+   rds_ib_send_unmap_rdma(ic, >rdma, wc_status);
+}
+
 /*
  * Unmap the resources associated with a struct send_work.
  *
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 8151c49..dd508e0 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -627,6 +627,16 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct 
rds_message *rm,
}
op->op_notifier->n_user_token = args->user_token;
op->op_notifier->n_status = RDS_RDMA_SUCCESS;
+
+   /* Enable rmda notification on data operation for composite
+* rds messages and make sure notification is enabled only
+* for the data operation which follows it so that application
+* gets notified only after full message gets delivered.
+*/
+   if (rm->data.op_sg) {
+   rm->rdma.op_notify = 0;
+   rm->data.op_notify = !!(args->flags & 
RDS_RDMA_NOTIFY_ME);
+   }
}
 
/* The cookie contains the R_Key of the remote memory region, and
diff --git a/net/rds/rds.h b/net/rds/rds.h
index ebbf909..0bb8213 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -419,6 +419,7 @@ struct rds_message {
} rdma;
struct rm_data_op {
unsigned intop_active:1;
+   unsigned intop_notify:1;
unsigned intop_nents;
unsigned intop_count;
unsigned intop_dmasg;
diff --git a/net/rds/send.c b/net/rds/send.c
index 0a6f38b..45e025b 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -476,12 +476,14 @@ void rds_rdma_send_complete(struct rds_message *rm, int 
status)
struct rm_rdma_op *ro;
struct rds_notifier *notifier;
unsigned long flags;
+   unsigned int notify = 0;
 
spin_lock_irqsave(>m_rs_lock, flags);
 
+   notify =  rm->rdma.op_notify | rm->data.op_notify;
ro = >rdma;
if (test_bit(RDS_MSG_ON_SOCK, >m_flags) &&
-   ro->op_active && ro->op_notify && ro->op_notifier) {
+   ro->op_active && notify && ro->op_notifier) {
notifier = ro->op_notifier;
rs = rm->m_rs;
sock_hold(rds_rs_to_sk(rs));
-- 
1.9.1



[net-next][PATCH 12/18] RDS: IB: Add vector spreading for cqs

2016-12-04 Thread Santosh Shilimkar
Based on available device vectors, allocate cqs accordingly to
get better spread of completion vectors which helps performace
great deal..

Signed-off-by: Santosh Shilimkar 
---
 net/rds/ib.c| 11 +++
 net/rds/ib.h|  5 +
 net/rds/ib_cm.c | 40 +---
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/net/rds/ib.c b/net/rds/ib.c
index 5680d90..8d70884 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -111,6 +111,9 @@ static void rds_ib_dev_free(struct work_struct *work)
kfree(i_ipaddr);
}
 
+   if (rds_ibdev->vector_load)
+   kfree(rds_ibdev->vector_load);
+
kfree(rds_ibdev);
 }
 
@@ -159,6 +162,14 @@ static void rds_ib_add_one(struct ib_device *device)
rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
 
+   rds_ibdev->vector_load = kzalloc(sizeof(int) * device->num_comp_vectors,
+GFP_KERNEL);
+   if (!rds_ibdev->vector_load) {
+   pr_err("RDS/IB: %s failed to allocate vector memory\n",
+   __func__);
+   goto put_dev;
+   }
+
rds_ibdev->dev = device;
rds_ibdev->pd = ib_alloc_pd(device, 0);
if (IS_ERR(rds_ibdev->pd)) {
diff --git a/net/rds/ib.h b/net/rds/ib.h
index 4987387..4b133b8 100644
--- a/net/rds/ib.h
+++ b/net/rds/ib.h
@@ -185,6 +185,10 @@ struct rds_ib_connection {
 
/* Endpoint role in connection */
int i_active_side;
+
+   /* Send/Recv vectors */
+   int i_scq_vector;
+   int i_rcq_vector;
 };
 
 /* This assumes that atomic_t is at least 32 bits */
@@ -227,6 +231,7 @@ struct rds_ib_device {
spinlock_t  spinlock;   /* protect the above */
atomic_trefcount;
struct work_struct  free_work;
+   int *vector_load;
 };
 
 #define ibdev_to_node(ibdev) dev_to_node(ibdev->dma_device)
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 4d1bf04..33c8584 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -358,6 +358,28 @@ static void rds_ib_cq_comp_handler_send(struct ib_cq *cq, 
void *context)
tasklet_schedule(>i_send_tasklet);
 }
 
+static inline int ibdev_get_unused_vector(struct rds_ib_device *rds_ibdev)
+{
+   int min = rds_ibdev->vector_load[rds_ibdev->dev->num_comp_vectors - 1];
+   int index = rds_ibdev->dev->num_comp_vectors - 1;
+   int i;
+
+   for (i = rds_ibdev->dev->num_comp_vectors - 1; i >= 0; i--) {
+   if (rds_ibdev->vector_load[i] < min) {
+   index = i;
+   min = rds_ibdev->vector_load[i];
+   }
+   }
+
+   rds_ibdev->vector_load[index]++;
+   return index;
+}
+
+static inline void ibdev_put_vector(struct rds_ib_device *rds_ibdev, int index)
+{
+   rds_ibdev->vector_load[index]--;
+}
+
 /*
  * This needs to be very careful to not leave IS_ERR pointers around for
  * cleanup to trip over.
@@ -399,25 +421,30 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
/* Protection domain and memory range */
ic->i_pd = rds_ibdev->pd;
 
+   ic->i_scq_vector = ibdev_get_unused_vector(rds_ibdev);
cq_attr.cqe = ic->i_send_ring.w_nr + fr_queue_space + 1;
-
+   cq_attr.comp_vector = ic->i_scq_vector;
ic->i_send_cq = ib_create_cq(dev, rds_ib_cq_comp_handler_send,
 rds_ib_cq_event_handler, conn,
 _attr);
if (IS_ERR(ic->i_send_cq)) {
ret = PTR_ERR(ic->i_send_cq);
ic->i_send_cq = NULL;
+   ibdev_put_vector(rds_ibdev, ic->i_scq_vector);
rdsdebug("ib_create_cq send failed: %d\n", ret);
goto out;
}
 
+   ic->i_rcq_vector = ibdev_get_unused_vector(rds_ibdev);
cq_attr.cqe = ic->i_recv_ring.w_nr;
+   cq_attr.comp_vector = ic->i_rcq_vector;
ic->i_recv_cq = ib_create_cq(dev, rds_ib_cq_comp_handler_recv,
 rds_ib_cq_event_handler, conn,
 _attr);
if (IS_ERR(ic->i_recv_cq)) {
ret = PTR_ERR(ic->i_recv_cq);
ic->i_recv_cq = NULL;
+   ibdev_put_vector(rds_ibdev, ic->i_rcq_vector);
rdsdebug("ib_create_cq recv failed: %d\n", ret);
goto out;
}
@@ -780,10 +807,17 @@ void rds_ib_conn_path_shutdown(struct rds_conn_path *cp)
/* first destroy the ib state that generates callbacks */
if (ic->i_cm_id->qp)
rdma_destroy_qp(ic->i_cm_id);
-   if (ic->i_send_cq)
+   if (ic->i_send_cq) {
+   if (ic->rds_ibdev)
+   

[net-next][PATCH 01/18] RDS: log the address on bind failure

2016-12-04 Thread Santosh Shilimkar
It's useful to know the IP address when RDS fails to bind a
connection. Thus, adding it to the error message.

Orabug: 21894138
Reviewed-by: Wei Lin Guay 
Signed-off-by: Santosh Shilimkar 
---
 net/rds/bind.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rds/bind.c b/net/rds/bind.c
index 095f6ce..3a915be 100644
--- a/net/rds/bind.c
+++ b/net/rds/bind.c
@@ -176,8 +176,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, 
int addr_len)
if (!trans) {
ret = -EADDRNOTAVAIL;
rds_remove_bound(rs);
-   printk_ratelimited(KERN_INFO "RDS: rds_bind() could not find a 
transport, "
-   "load rds_tcp or rds_rdma?\n");
+   pr_info_ratelimited("RDS: %s could not find a transport for 
%pI4, load rds_tcp or rds_rdma?\n",
+   __func__, >sin_addr.s_addr);
goto out;
}
 
-- 
1.9.1



Re: [PATCH 1/1] xen: set error code on failures

2016-12-04 Thread Juergen Gross
On 04/12/16 07:24, Pan Bian wrote:
> From: Pan Bian 
> 
> The return variable rc is initialized with "-ENOMEM" outside the loop.
> However, it is reset in the loop, and its value is not negative during 
> the second or after repeat of the loop. If kzalloc() fails then, it will 
> return 0. This patch fixes the bug, assigning "-ENOMEM" to rc when 
> kzalloc() or alloc_page() returns NULL.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189111
> 
> Signed-off-by: Pan Bian 
> ---
>  drivers/xen/gntalloc.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
> index 7a47c4c..55ef246 100644
> --- a/drivers/xen/gntalloc.c
> +++ b/drivers/xen/gntalloc.c
> @@ -130,15 +130,19 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref 
> *op,
>   rc = -ENOMEM;

You can drop this now.

>   for (i = 0; i < op->count; i++) {
>   gref = kzalloc(sizeof(*gref), GFP_KERNEL);
> - if (!gref)
> + if (!gref) {
> + rc = -ENOMEM;
>   goto undo;
> + }
>   list_add_tail(>next_gref, _gref);
>   list_add_tail(>next_file, _file);
>   gref->users = 1;
>   gref->file_index = op->index + i * PAGE_SIZE;
>   gref->page = alloc_page(GFP_KERNEL|__GFP_ZERO);
> - if (!gref->page)
> + if (!gref->page) {
> + rc = -ENOMEM;
>   goto undo;
> + }
>  
>   /* Grant foreign access to the page. */
>   rc = gnttab_grant_foreign_access(op->domid,
> 


Juergen


Re: [PATCH 1/1] xen: set error code on failures

2016-12-04 Thread Juergen Gross
On 04/12/16 07:24, Pan Bian wrote:
> From: Pan Bian 
> 
> The return variable rc is initialized with "-ENOMEM" outside the loop.
> However, it is reset in the loop, and its value is not negative during 
> the second or after repeat of the loop. If kzalloc() fails then, it will 
> return 0. This patch fixes the bug, assigning "-ENOMEM" to rc when 
> kzalloc() or alloc_page() returns NULL.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189111
> 
> Signed-off-by: Pan Bian 
> ---
>  drivers/xen/gntalloc.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
> index 7a47c4c..55ef246 100644
> --- a/drivers/xen/gntalloc.c
> +++ b/drivers/xen/gntalloc.c
> @@ -130,15 +130,19 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref 
> *op,
>   rc = -ENOMEM;

You can drop this now.

>   for (i = 0; i < op->count; i++) {
>   gref = kzalloc(sizeof(*gref), GFP_KERNEL);
> - if (!gref)
> + if (!gref) {
> + rc = -ENOMEM;
>   goto undo;
> + }
>   list_add_tail(>next_gref, _gref);
>   list_add_tail(>next_file, _file);
>   gref->users = 1;
>   gref->file_index = op->index + i * PAGE_SIZE;
>   gref->page = alloc_page(GFP_KERNEL|__GFP_ZERO);
> - if (!gref->page)
> + if (!gref->page) {
> + rc = -ENOMEM;
>   goto undo;
> + }
>  
>   /* Grant foreign access to the page. */
>   rc = gnttab_grant_foreign_access(op->domid,
> 


Juergen


Re: [PATCH v3 3/7] PWM: add pwm-stm32 DT bindings

2016-12-04 Thread Thierry Reding
On Fri, Dec 02, 2016 at 11:17:18AM +0100, Benjamin Gaignard wrote:
> Define bindings for pwm-stm32
> 
> version 2:
> - use parameters instead of compatible of handle the hardware configuration
> 
> Signed-off-by: Benjamin Gaignard 
> ---
>  .../devicetree/bindings/pwm/pwm-stm32.txt  | 38 
> ++
>  1 file changed, 38 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> 
> diff --git a/Documentation/devicetree/bindings/pwm/pwm-stm32.txt 
> b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> new file mode 100644
> index 000..575b9fb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> @@ -0,0 +1,38 @@
> +STMicroelectronics PWM driver bindings for STM32

Technically this bindings describe devices, so "driver binding" is a
somewhat odd wording. Perhaps:

STMicroelectronics STM32 General Purpose Timer PWM bindings

?

> +
> +Must be a sub-node of STM32 general purpose timer driver
> +Parent node properties are describe in ../mfd/stm32-general-purpose-timer.txt

Again, "driver parent node" is odd. Perhaps:

Must be a sub-node of an STM32 General Purpose Timer device tree
node. See ../mfd/stm32-general-purpose-timer.txt for details about
the parent node.

?

> +Required parameters:
> +- compatible:Must be "st,stm32-pwm"
> +- pinctrl-names: Set to "default".
> +- pinctrl-0: List of phandles pointing to pin configuration 
> nodes
> + for PWM module.
> + For Pinctrl properties, please refer to [1].

Your indentation and capitalization are inconsistent. Also, please refer
to the pinctrl bindings by relative path and inline, rather than as a
footnote reference.

> +
> +Optional parameters:
> +- st,breakinput: Set if the hardware have break input capabilities
> +- st,breakinput-polarity: Set break input polarity. Default is 0
> +  The value define the active polarity:
> +   - 0 (active LOW)
> +   - 1 (active HIGH)

Could we fold these into a single property? If st,breakinput-polarity is
not present it could simply mean that there is no break input, and if it
is present you don't have to rely on a default.

> +- st,pwm-num-chan:   Number of available PWM channels.  Default is 0.

The pwm- prefix is rather redundant since the node is already named pwm.
Why not simply st,channels? Or simply channels, since it's not really
anything specific to this hardware.

Come to think of it, might be worth having a discussion with our DT
gurus about what their stance is on using the # as prefix for numbers
(such as in #address-cells or #size-cells). This could be #channels to
mark it more explicitly as representing a count.

> +- st,32bits-counter: Set if the hardware have a 32 bits counter
> +- st,complementary:  Set if the hardware have complementary output channels

"hardware has" and also maybe mention explicitly that this is a boolean
property. Otherwise people might be left wondering what it should be set
to. Or maybe word this differently to imply that it's boolean:

- st,32bits-counter: if present, the hardware has a 32 bit counter
- st,complementary: if present, the hardware has a complementary
output channel

Thierry


signature.asc
Description: PGP signature


Re: [PATCH v3 3/7] PWM: add pwm-stm32 DT bindings

2016-12-04 Thread Thierry Reding
On Fri, Dec 02, 2016 at 11:17:18AM +0100, Benjamin Gaignard wrote:
> Define bindings for pwm-stm32
> 
> version 2:
> - use parameters instead of compatible of handle the hardware configuration
> 
> Signed-off-by: Benjamin Gaignard 
> ---
>  .../devicetree/bindings/pwm/pwm-stm32.txt  | 38 
> ++
>  1 file changed, 38 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> 
> diff --git a/Documentation/devicetree/bindings/pwm/pwm-stm32.txt 
> b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> new file mode 100644
> index 000..575b9fb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
> @@ -0,0 +1,38 @@
> +STMicroelectronics PWM driver bindings for STM32

Technically this bindings describe devices, so "driver binding" is a
somewhat odd wording. Perhaps:

STMicroelectronics STM32 General Purpose Timer PWM bindings

?

> +
> +Must be a sub-node of STM32 general purpose timer driver
> +Parent node properties are describe in ../mfd/stm32-general-purpose-timer.txt

Again, "driver parent node" is odd. Perhaps:

Must be a sub-node of an STM32 General Purpose Timer device tree
node. See ../mfd/stm32-general-purpose-timer.txt for details about
the parent node.

?

> +Required parameters:
> +- compatible:Must be "st,stm32-pwm"
> +- pinctrl-names: Set to "default".
> +- pinctrl-0: List of phandles pointing to pin configuration 
> nodes
> + for PWM module.
> + For Pinctrl properties, please refer to [1].

Your indentation and capitalization are inconsistent. Also, please refer
to the pinctrl bindings by relative path and inline, rather than as a
footnote reference.

> +
> +Optional parameters:
> +- st,breakinput: Set if the hardware have break input capabilities
> +- st,breakinput-polarity: Set break input polarity. Default is 0
> +  The value define the active polarity:
> +   - 0 (active LOW)
> +   - 1 (active HIGH)

Could we fold these into a single property? If st,breakinput-polarity is
not present it could simply mean that there is no break input, and if it
is present you don't have to rely on a default.

> +- st,pwm-num-chan:   Number of available PWM channels.  Default is 0.

The pwm- prefix is rather redundant since the node is already named pwm.
Why not simply st,channels? Or simply channels, since it's not really
anything specific to this hardware.

Come to think of it, might be worth having a discussion with our DT
gurus about what their stance is on using the # as prefix for numbers
(such as in #address-cells or #size-cells). This could be #channels to
mark it more explicitly as representing a count.

> +- st,32bits-counter: Set if the hardware have a 32 bits counter
> +- st,complementary:  Set if the hardware have complementary output channels

"hardware has" and also maybe mention explicitly that this is a boolean
property. Otherwise people might be left wondering what it should be set
to. Or maybe word this differently to imply that it's boolean:

- st,32bits-counter: if present, the hardware has a 32 bit counter
- st,complementary: if present, the hardware has a complementary
output channel

Thierry


signature.asc
Description: PGP signature


Re: [PATCH] crypto: rsa - fix a potential race condition in build

2016-12-04 Thread Herbert Xu
On Fri, Dec 02, 2016 at 03:41:04PM -0800, Yang Shi wrote:
> When building kernel with RSA enabled with multithreaded, the below
> compile failure might be caught:
> 
> | /buildarea/kernel-source/crypto/rsa_helper.c:18:28: fatal error: 
> rsapubkey-asn1.h: No such file or directory
> | #include "rsapubkey-asn1.h"
> | ^
> | compilation terminated.
> | CC crypto/rsa-pkcs1pad.o
> | CC crypto/algboss.o
> | CC crypto/testmgr.o
> | make[3]: *** [/buildarea/kernel-source/scripts/Makefile.build:289: 
> crypto/rsa_helper.o] Error 1
> | make[3]: *** Waiting for unfinished jobs
> | make[2]: *** [/buildarea/kernel-source/Makefile:969: crypto] Error 2
> | make[1]: *** [Makefile:150: sub-make] Error 2
> | make: *** [Makefile:24: __sub-make] Error 2
> 
> The header file is not generated before rsa_helper is compiled, so
> adding dependency to avoid such issue.
> 
> Signed-off-by: Yang Shi 

This should already be fixed in the latest crypto tree.  Could
you please double-check?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] crypto: rsa - fix a potential race condition in build

2016-12-04 Thread Herbert Xu
On Fri, Dec 02, 2016 at 03:41:04PM -0800, Yang Shi wrote:
> When building kernel with RSA enabled with multithreaded, the below
> compile failure might be caught:
> 
> | /buildarea/kernel-source/crypto/rsa_helper.c:18:28: fatal error: 
> rsapubkey-asn1.h: No such file or directory
> | #include "rsapubkey-asn1.h"
> | ^
> | compilation terminated.
> | CC crypto/rsa-pkcs1pad.o
> | CC crypto/algboss.o
> | CC crypto/testmgr.o
> | make[3]: *** [/buildarea/kernel-source/scripts/Makefile.build:289: 
> crypto/rsa_helper.o] Error 1
> | make[3]: *** Waiting for unfinished jobs
> | make[2]: *** [/buildarea/kernel-source/Makefile:969: crypto] Error 2
> | make[1]: *** [Makefile:150: sub-make] Error 2
> | make: *** [Makefile:24: __sub-make] Error 2
> 
> The header file is not generated before rsa_helper is compiled, so
> adding dependency to avoid such issue.
> 
> Signed-off-by: Yang Shi 

This should already be fixed in the latest crypto tree.  Could
you please double-check?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Crypto Fixes for 4.9

2016-12-04 Thread Herbert Xu
Hi Linus:

This push fixes the following issues:

- Intermittent build failure in RSA.
- Memory corruption in chelsio crypto driver.
- Regression in DRBG due to vmalloced stack.


Please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git linus


David Michael (1):
  crypto: rsa - Add Makefile dependencies to fix parallel builds

Harsh Jain (1):
  crypto: chcr - Fix memory corruption

Stephan Mueller (1):
  crypto: drbg - prevent invalid SG mappings

 crypto/Makefile|1 +
 crypto/drbg.c  |   29 -
 drivers/crypto/chelsio/chcr_algo.h |3 ++-
 include/crypto/drbg.h  |2 ++
 4 files changed, 29 insertions(+), 6 deletions(-)

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Crypto Fixes for 4.9

2016-12-04 Thread Herbert Xu
Hi Linus:

This push fixes the following issues:

- Intermittent build failure in RSA.
- Memory corruption in chelsio crypto driver.
- Regression in DRBG due to vmalloced stack.


Please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git linus


David Michael (1):
  crypto: rsa - Add Makefile dependencies to fix parallel builds

Harsh Jain (1):
  crypto: chcr - Fix memory corruption

Stephan Mueller (1):
  crypto: drbg - prevent invalid SG mappings

 crypto/Makefile|1 +
 crypto/drbg.c  |   29 -
 drivers/crypto/chelsio/chcr_algo.h |3 ++-
 include/crypto/drbg.h  |2 ++
 4 files changed, 29 insertions(+), 6 deletions(-)

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


  1   2   3   4   5   6   >