Re: sparse: __pure declaration only

2019-10-19 Thread Luc Van Oostenryck
On Fri, Oct 18, 2019 at 08:31:48AM -0700, Linus Torvalds wrote:
> On Fri, Oct 18, 2019 at 4:15 AM Ben Dooks  wrote:
> >
> > is this a valid warning? if not, should sparse be ignoring these.
> 
> It's technically valid, but maybe it's not useful.
> 
> If we make sure that any pure bits from a declaration always make it
> into the definition, then I suspect that the "was not declared"
> warning (if the definition is non-static and seen without a
> declaration) is sufficient.
> 
> Of course, sparse doesn't actually _care_ about "pure" in the
> definition, only in the use, so right now it doesn't even make any
> difference to sparse whether the definition has the "pure" or not.
> It's only when the function is used that the "pure" matters (it makes
> the call instruction be CSE'd like any other random instruction).

Yes, for 'pure' it doesn't matter much but it's a problem anyway.
For example with 'static':

$ cat file.c
static void foo(void);
void foo(void) { }

$ sparse file.c
file.c:2:6: warning: symbol 'foo' was not declared. Should it be static?

Which is kinda absurd: foo() was declared and was even declared static.
But the definition is a different symbol than its declaration (OK) which
doesn't 'inherit' the declaration's specifier/modifier/attributes.
It's on my to-be-fixed list for a long time but ..

-- Luc


[PATCH v7 3/3] HID: logitech-hidpp: Support WirelessDeviceStatus connect events

2019-10-19 Thread Mazin Rezk
This patch allows hidpp_report_is_connect_event to support
WirelessDeviceStatus connect events.

The WirelessDeviceStatus feature index is stored in hidpp_device when
probed. The connect event's fap feature_index is compared against it if the
device supports it.

Thanks,
Mazin

Signed-off-by: Mazin Rezk 
---
 drivers/hid/hid-logitech-hidpp.c | 39 
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 19b315e4e91b..c8b23568d0b1 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -191,6 +191,8 @@ struct hidpp_device {

struct hidpp_battery battery;
struct hidpp_scroll_counter vertical_wheel_counter;
+
+   u8 wireless_feature_index;
 };

 /* HID++ 1.0 error codes */
@@ -403,10 +405,13 @@ static inline bool hidpp_match_error(struct hidpp_report 
*question,
(answer->fap.params[0] == question->fap.funcindex_clientid);
 }

-static inline bool hidpp_report_is_connect_event(struct hidpp_report *report)
+static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp,
+   struct hidpp_report *report)
 {
-   return (report->report_id == REPORT_ID_HIDPP_SHORT) &&
-   (report->rap.sub_id == 0x41);
+   return (hidpp->wireless_feature_index &&
+   (report->fap.feature_index == hidpp->wireless_feature_index)) ||
+   ((report->report_id == REPORT_ID_HIDPP_SHORT) &&
+   (report->rap.sub_id == 0x41));
 }

 /**
@@ -1283,6 +1288,24 @@ static int hidpp_battery_get_property(struct 
power_supply *psy,
return ret;
 }

+/* -- 
*/
+/* 0x1d4b: Wireless device status 
*/
+/* -- 
*/
+#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS  0x1d4b
+
+static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp)
+{
+   u8 feature_type;
+   int ret;
+
+   ret = hidpp_root_get_feature(hidpp,
+HIDPP_PAGE_WIRELESS_DEVICE_STATUS,
+>wireless_feature_index,
+_type);
+
+   return ret;
+}
+
 /* -- 
*/
 /* 0x2120: Hi-resolution scrolling
*/
 /* -- 
*/
@@ -3078,7 +3101,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device 
*hidpp, u8 *data,
}
}

-   if (unlikely(hidpp_report_is_connect_event(report))) {
+   if (unlikely(hidpp_report_is_connect_event(hidpp, report))) {
atomic_set(>connected,
!(report->rap.params[0] & (1 << 6)));
if (schedule_work(>work) == 0)
@@ -3628,6 +3651,14 @@ static int hidpp_probe(struct hid_device *hdev, const 
struct hid_device_id *id)
hidpp_overwrite_name(hdev);
}

+   if (connected && hidpp->protocol_major >= 2) {
+   ret = hidpp_set_wireless_feature_index(hidpp);
+   if (ret == -ENOENT)
+   hidpp->wireless_feature_index = 0;
+   else if (ret)
+   goto hid_hw_init_fail;
+   }
+
if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
ret = wtp_get_config(hidpp);
if (ret)
--
2.23.0



[PATCH v7 2/3] HID: logitech-hidpp: Support MX Master (b012, b01e) over Bluetooth

2019-10-19 Thread Mazin Rezk
This patch adds support for the MX Master over Bluetooth (b012, b01e).

I have only added the devices that have been tested, so the 0xb017 variant
of the MX Master needs to be added once it is tested.

Since this patch series adds support for Bluetooth LE devices in general,
other Bluetooth LE devices should also be added later

Thanks,
Mazin

Signed-off-by: Mazin Rezk 
---
 drivers/hid/hid-logitech-hidpp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index ee604b17514f..19b315e4e91b 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -3792,6 +3792,11 @@ static const struct hid_device_id hidpp_devices[] = {
{ /* MX5500 keyboard over Bluetooth */
  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb30b),
  .driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS },
+   { /* MX Master mouse over Bluetooth */
+ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012),
+ .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
+   { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e),
+ .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
{}
 };

--
2.23.0



[PATCH v7 1/3] HID: logitech-hidpp: Support translations from short to long reports

2019-10-19 Thread Mazin Rezk
This patch allows short reports to be translated into long reports.

hidpp_validate_device now returns a u8 instead of a bool which represents
the supported reports. The corresponding bits (i.e.
HIDPP_REPORT_*_SUPPORTED) are set if an HID++ report is supported.

If a short report is being sent and the device does not support it, it is
instead sent as a long report.

Thanks,
Mazin

Signed-off-by: Mazin Rezk 
---
 drivers/hid/hid-logitech-hidpp.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index e9bba282f9c1..ee604b17514f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -49,6 +49,10 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_REPORT_LONG_LENGTH   20
 #define HIDPP_REPORT_VERY_LONG_MAX_LENGTH  64

+#define HIDPP_REPORT_SHORT_SUPPORTED   BIT(0)
+#define HIDPP_REPORT_LONG_SUPPORTEDBIT(1)
+#define HIDPP_REPORT_VERY_LONG_SUPPORTED   BIT(2)
+
 #define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS  0x03
 #define HIDPP_SUB_ID_ROLLER0x05
 #define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS  0x06
@@ -183,6 +187,7 @@ struct hidpp_device {

unsigned long quirks;
unsigned long capabilities;
+   u8 supported_reports;

struct hidpp_battery battery;
struct hidpp_scroll_counter vertical_wheel_counter;
@@ -340,6 +345,11 @@ static int hidpp_send_rap_command_sync(struct hidpp_device 
*hidpp_dev,
struct hidpp_report *message;
int ret, max_count;

+   /* Send as long report if short reports are not supported. */
+   if (report_id == REPORT_ID_HIDPP_SHORT &&
+   !(hidpp_dev->supported_reports & HIDPP_REPORT_SHORT_SUPPORTED))
+   report_id = REPORT_ID_HIDPP_LONG;
+
switch (report_id) {
case REPORT_ID_HIDPP_SHORT:
max_count = HIDPP_REPORT_SHORT_LENGTH - 4;
@@ -3458,10 +3468,11 @@ static int hidpp_get_report_length(struct hid_device 
*hdev, int id)
return report->field[0]->report_count + 1;
 }

-static bool hidpp_validate_device(struct hid_device *hdev)
+static u8 hidpp_validate_device(struct hid_device *hdev)
 {
struct hidpp_device *hidpp = hid_get_drvdata(hdev);
-   int id, report_length, supported_reports = 0;
+   int id, report_length;
+   u8 supported_reports = 0;

id = REPORT_ID_HIDPP_SHORT;
report_length = hidpp_get_report_length(hdev, id);
@@ -3469,7 +3480,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
if (report_length < HIDPP_REPORT_SHORT_LENGTH)
goto bad_device;

-   supported_reports++;
+   supported_reports |= HIDPP_REPORT_SHORT_SUPPORTED;
}

id = REPORT_ID_HIDPP_LONG;
@@ -3478,7 +3489,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
if (report_length < HIDPP_REPORT_LONG_LENGTH)
goto bad_device;

-   supported_reports++;
+   supported_reports |= HIDPP_REPORT_LONG_SUPPORTED;
}

id = REPORT_ID_HIDPP_VERY_LONG;
@@ -3488,7 +3499,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
goto bad_device;

-   supported_reports++;
+   supported_reports |= HIDPP_REPORT_VERY_LONG_SUPPORTED;
hidpp->very_long_report_length = report_length;
}

@@ -3536,7 +3547,9 @@ static int hidpp_probe(struct hid_device *hdev, const 
struct hid_device_id *id)
/*
 * Make sure the device is HID++ capable, otherwise treat as generic HID
 */
-   if (!hidpp_validate_device(hdev)) {
+   hidpp->supported_reports = hidpp_validate_device(hdev);
+
+   if (!hidpp->supported_reports) {
hid_set_drvdata(hdev, NULL);
devm_kfree(>dev, hidpp);
return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
--
2.23.0



[PATCH v7 0/3] Logitech HID++ Bluetooth LE support

2019-10-19 Thread Mazin Rezk
This series allows hid-logitech-hidpp to support Bluetooth LE HID++
devices. Only the MX Master is added right now but more HID++ Bluetooth LE
devices can be added once they are tested.

Thanks,
Mazin

Changes since [v6]:

- Based patch on "HID: logitech-hidpp: rework device validation"

- Removed the need for additional quirks

Changes since [v5]:

- Fixed bug where added quirks would overflow an unsigned long

- Changed the reserved quirk class bits from 0..20 to 0..15

Changes since [v4]:

- Omitted "HID: logitech: Add feature 0x0001: FeatureSet"

- Stored WirelessDeviceStatus feature index in hidpp_device

- Made Bluetooth quirk class alias quirks instead of vice versa

- Omitted non-tested devices

Changes since [v3]:

- Renamed hidpp20_featureset_get_feature to
  hidpp20_featureset_get_feature_id.

- Re-ordered hidpp20_featureset_get_count and
  hidpp20_featureset_get_feature_id based on their command IDs.

- Made feature_count initialize to 0 before running
  hidpp20_get_features.

Changes since [v2]:

- Split up the single patch into a series

Changes since [v1]:

- Added WirelessDeviceStatus support

[v6] 
https://lore.kernel.org/lkml/ggKipcQplIlTFmoP3hPnrQ-7_5-C0PKGd5feFymts3uenIBA8zOwz47YmKheD34H1rpkguDAGdx5YbS9UqpwfjT5Ir0Lji941liLVp--QtQ=@protonmail.com
[v5] 
https://lore.kernel.org/lkml/Mbf4goGxXZTfWwWtQQUke_rNf8kezpNOS9DVEVHf6RnnmjS1oRtMOJf4r14WfCC6GRYVs7gi0uZcIJ18Va2OJowzSbyMUGwLrl6I5fjW48o=@protonmail.com
[v4] 
https://lore.kernel.org/lkml/uBbIS3nFJ1jdYNLHcqjW5wxQAwmZv0kmYEoeoPrxNhfzi6cHwmCOY-ewdqe7S1hNEj-p4Hd9D0_Y3PymUTdh_6WFXuMmIYUkV2xaKCPMYz0=@protonmail.com
[v3] 
https://lore.kernel.org/lkml/l7xYjnA9EGfZe03FsrFhnH2aMq8qS8plWhHVvOtY_l4ShZ1NV6HA6hn9aI-jAzbLYUGFCIQCIKkx9z42Uoj4-AZDwBfRcAecYIn-0ZA5upE=@protonmail.com
[v2] https://www.spinics.net/lists/linux-input/msg63467.html
[v1] https://www.spinics.net/lists/linux-input/msg63317.html

Mazin Rezk (3):
  HID: logitech-hidpp: Support translations from short to long reports
  HID: logitech-hidpp: Support MX Master (b012, b01e) over Bluetooth
  HID: logitech-hidpp: Support WirelessDeviceStatus connect events

 drivers/hid/hid-logitech-hidpp.c | 69 +++-
 1 file changed, 59 insertions(+), 10 deletions(-)

--
2.23.0



linux-next: cleanup the kgdb trees

2019-10-19 Thread Stephen Rothwell
Hi all,

The kgdb tree
(git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb.git#kgdb-next)
has not been updated in more than a year, so I have rmeoved it from
linux-next.  It contained:

3bd67b37e350 kdb: print real address of pointers instead of hashed addresses
a0ca72c2d1ac kdb: use correct pointer when 'btc' calls 'btt'

Please let me know if/when you want it reinstated.

I have also renamed the kgdb-dt tree to kgdb.

-- 
Cheers,
Stephen Rothwell


pgpUGxI7KcBuv.pgp
Description: OpenPGP digital signature


linux-next: remove the pcmcia tree

2019-10-19 Thread Stephen Rothwell
Hi all,

The pcmcia tree
(git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux.git#pcmcia-next)
has not been updated in more than a year, so I have removed it from
linux-next.  Please let me know if/when you want it reinstated.

-- 
Cheers,
Stephen Rothwell


pgpbACrVOT79P.pgp
Description: OpenPGP digital signature


[PATCH v2 1/8] dt-bindings: watchdog: realtek: Convert RTD119x to schema

2019-10-19 Thread Andreas Färber
Convert the Realtek watchdog binding to a YAML schema.

Signed-off-by: Andreas Färber 
---
 v2: New
 
 .../bindings/watchdog/realtek,rtd119x.txt  | 17 --
 .../bindings/watchdog/realtek,rtd119x.yaml | 38 ++
 2 files changed, 38 insertions(+), 17 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/watchdog/realtek,rtd119x.txt
 create mode 100644 
Documentation/devicetree/bindings/watchdog/realtek,rtd119x.yaml

diff --git a/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.txt 
b/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.txt
deleted file mode 100644
index 05653054bd5b..
--- a/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-Realtek RTD1295 Watchdog
-
-
-Required properties:
-
-- compatible :  Should be "realtek,rtd1295-watchdog"
-- reg:  Specifies the physical base address and size of registers
-- clocks :  Specifies one clock input
-
-
-Example:
-
-   watchdog@98007680 {
-   compatible = "realtek,rtd1295-watchdog";
-   reg = <0x98007680 0x100>;
-   clocks = <>;
-   };
diff --git a/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.yaml 
b/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.yaml
new file mode 100644
index ..5d92cfdfd046
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/realtek,rtd119x.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/watchdog/realtek,rtd119x.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: Realtek RTD1295 Watchdog
+
+maintainers:
+  - Andreas Färber 
+
+allOf:
+  - $ref: watchdog.yaml#
+
+properties:
+  compatible:
+oneOf:
+  - const: realtek,rtd1295-watchdog
+
+  reg:
+maxItems: 1
+
+  clocks:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+examples:
+  - |
+   watchdog@98007680 {
+   compatible = "realtek,rtd1295-watchdog";
+   reg = <0x98007680 0x100>;
+   clocks = <>;
+   };
+...
-- 
2.16.4



[PATCH v2 5/8] arm64: dts: realtek: Change dual-license from MIT to BSD

2019-10-19 Thread Andreas Färber
Move the SPDX-License-Identifier to the top line and update to SPDX 2.0.
While at it, switch from GPLv2+/MIT to GPLv2+/BSD2c before adding more.

Suggested-by: Rob Herring 
Cc: Rob Herring 
Signed-off-by: Andreas Färber 
---
 v2: New
 
 arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts | 3 +--
 arch/arm64/boot/dts/realtek/rtd1295.dtsi  | 3 +--
 arch/arm64/boot/dts/realtek/rtd129x.dtsi  | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts 
b/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
index da19faab29d5..e98e508b9514 100644
--- a/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
+++ b/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
 /*
  * Copyright (c) 2016-2017 Andreas Färber
- *
- * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
 
 /dts-v1/;
diff --git a/arch/arm64/boot/dts/realtek/rtd1295.dtsi 
b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
index 41d7858da826..93f0e1d97721 100644
--- a/arch/arm64/boot/dts/realtek/rtd1295.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
 /*
  * Realtek RTD1295 SoC
  *
  * Copyright (c) 2016-2017 Andreas Färber
- *
- * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
 
 #include "rtd129x.dtsi"
diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi 
b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
index b9cb92466fc7..a26c375ee1bb 100644
--- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
 /*
  * Realtek RTD1293/RTD1295/RTD1296 SoC
  *
  * Copyright (c) 2016-2017 Andreas Färber
- *
- * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
 
 /memreserve/   0x 0x0003;
-- 
2.16.4



[PATCH v2 2/8] dt-bindings: rtc: realtek: Convert RTD119x to schema

2019-10-19 Thread Andreas Färber
Convert the RTD119x binding to a YAML schema.

Signed-off-by: Andreas Färber 
---
 v2: New
 
 .../devicetree/bindings/rtc/realtek,rtd119x.txt| 16 -
 .../devicetree/bindings/rtc/realtek,rtd119x.yaml   | 38 ++
 2 files changed, 38 insertions(+), 16 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt
 create mode 100644 Documentation/devicetree/bindings/rtc/realtek,rtd119x.yaml

diff --git a/Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt 
b/Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt
deleted file mode 100644
index bbf1ccb5df31..
--- a/Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Realtek RTD129x Real-Time Clock
-===
-
-Required properties:
-- compatible :  Should be "realtek,rtd1295-rtc"
-- reg:  Specifies the physical base address and size
-- clocks :  Specifies the clock gate
-
-
-Example:
-
-   rtc@9801b600 {
-   compatible = "realtek,rtd1295-clk";
-   reg = <0x9801b600 0x100>;
-   clocks = < RTD1295_CLK_EN_MISC_RTC>;
-   };
diff --git a/Documentation/devicetree/bindings/rtc/realtek,rtd119x.yaml 
b/Documentation/devicetree/bindings/rtc/realtek,rtd119x.yaml
new file mode 100644
index ..71b7396bd469
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/realtek,rtd119x.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rtc/realtek,rtd119x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek RTD129x Real-Time Clock
+
+allOf:
+  - $ref: "rtc.yaml#"
+
+maintainers:
+  - Andreas Färber 
+
+properties:
+  compatible:
+const: realtek,rtd1295-rtc
+
+  reg:
+maxItems: 1
+
+  clocks:
+maxItems: 1
+description: Specifies the clock gate
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+examples:
+  - |
+   rtc@9801b600 {
+   compatible = "realtek,rtd1295-clk";
+   reg = <0x9801b600 0x100>;
+   clocks = < RTD1295_CLK_EN_MISC_RTC>;
+   };
+...
-- 
2.16.4



[PATCH v2 4/8] dt-bindings: arm: realtek: Document RTD1293 and Synology DS418j

2019-10-19 Thread Andreas Färber
Define compatible strings for Realtek RTD1293 SoC and Synology
DiskStation DS418j NAS.

Cc: i...@synology.com
Acked-by: Rob Herring 
[AF: Converted to json-schema]
Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Converted to YAML schema
 
 Documentation/devicetree/bindings/arm/realtek.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/realtek.yaml 
b/Documentation/devicetree/bindings/arm/realtek.yaml
index 66458a3f422d..6ea3a79825cc 100644
--- a/Documentation/devicetree/bindings/arm/realtek.yaml
+++ b/Documentation/devicetree/bindings/arm/realtek.yaml
@@ -14,6 +14,12 @@ properties:
 const: '/'
   compatible:
 oneOf:
+  # RTD1293 SoC based boards
+  - items:
+  - enum:
+  - synology,ds418j # Synology DiskStation DS418j
+  - const: realtek,rtd1293
+
   # RTD1295 SoC based boards
   - items:
   - enum:
-- 
2.16.4



[PATCH v2 8/8] arm64: dts: realtek: Add RTD1296 and Synology DS418

2019-10-19 Thread Andreas Färber
Add Device Trees for RTD1296 SoC and Synology DiskStation DS418.

Cc: i...@synology.com
Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Moved SPDX-License-Identifier to top
 * Dropped "arm,armv8" (Rob)
 * Changed from MIT to BSD-2-Clause (Rob)
 * Dropped accidental enable-method and cpu-release-addr
 * Fixed DS418 to use rtd1296.dtsi
 
 arch/arm64/boot/dts/realtek/Makefile  |  2 +
 arch/arm64/boot/dts/realtek/rtd1296-ds418.dts | 30 +
 arch/arm64/boot/dts/realtek/rtd1296.dtsi  | 65 +++
 3 files changed, 97 insertions(+)
 create mode 100644 arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
 create mode 100644 arch/arm64/boot/dts/realtek/rtd1296.dtsi

diff --git a/arch/arm64/boot/dts/realtek/Makefile 
b/arch/arm64/boot/dts/realtek/Makefile
index e7ff40461ddc..555638ada721 100644
--- a/arch/arm64/boot/dts/realtek/Makefile
+++ b/arch/arm64/boot/dts/realtek/Makefile
@@ -5,3 +5,5 @@ dtb-$(CONFIG_ARCH_REALTEK) += rtd1293-ds418j.dtb
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-mele-v9.dtb
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-probox2-ava.dtb
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-zidoo-x9s.dtb
+
+dtb-$(CONFIG_ARCH_REALTEK) += rtd1296-ds418.dtb
diff --git a/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts 
b/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
new file mode 100644
index ..5a051a52bf88
--- /dev/null
+++ b/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Copyright (c) 2017-2019 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "rtd1296.dtsi"
+
+/ {
+   compatible = "synology,ds418", "realtek,rtd1296";
+   model = "Synology DiskStation DS418";
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x8000>;
+   };
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/realtek/rtd1296.dtsi 
b/arch/arm64/boot/dts/realtek/rtd1296.dtsi
new file mode 100644
index ..0f9e59cac086
--- /dev/null
+++ b/arch/arm64/boot/dts/realtek/rtd1296.dtsi
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Realtek RTD1296 SoC
+ *
+ * Copyright (c) 2017-2019 Andreas Färber
+ */
+
+#include "rtd129x.dtsi"
+
+/ {
+   compatible = "realtek,rtd1296";
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   next-level-cache = <>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   next-level-cache = <>;
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   next-level-cache = <>;
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   next-level-cache = <>;
+   };
+
+   l2: l2-cache {
+   compatible = "cache";
+   };
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+};
+
+_pmu {
+   interrupt-affinity = <>, <>, <>, <>;
+};
-- 
2.16.4



[PATCH v2 7/8] dt-bindings: arm: realtek: Document RTD1296 and Synology DS418

2019-10-19 Thread Andreas Färber
Define compatible strings for Realtek RTD1296 SoC and Synology
DiskStation DS418 NAS.

Cc: i...@synology.com
Acked-by: Rob Herring 
[AF: Converted to json-schema]
Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Converted to YAML schema
 
 Documentation/devicetree/bindings/arm/realtek.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/realtek.yaml 
b/Documentation/devicetree/bindings/arm/realtek.yaml
index 6ea3a79825cc..ab59de17152d 100644
--- a/Documentation/devicetree/bindings/arm/realtek.yaml
+++ b/Documentation/devicetree/bindings/arm/realtek.yaml
@@ -27,4 +27,10 @@ properties:
   - probox2,ava # ProBox2 AVA
   - zidoo,x9s # Zidoo X9S
   - const: realtek,rtd1295
+
+  # RTD1296 SoC based boards
+  - items:
+  - enum:
+  - synology,ds418 # Synology DiskStation DS418
+  - const: realtek,rtd1296
 ...
-- 
2.16.4



[PATCH v2 3/8] dt-bindings: arm: realtek: Tidy up conversion to json-schema

2019-10-19 Thread Andreas Färber
Restore the device names for compatible strings as comments.
Prepare for adding more SoCs by inserting oneOf.

Fixes: 693af5f3eeaa ("dt-bindings: arm: Convert Realtek board/soc bindings to 
json-schema")
Signed-off-by: Andreas Färber 
---
 v2: New
 
 Documentation/devicetree/bindings/arm/realtek.yaml | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/realtek.yaml 
b/Documentation/devicetree/bindings/arm/realtek.yaml
index 3528b61963b4..66458a3f422d 100644
--- a/Documentation/devicetree/bindings/arm/realtek.yaml
+++ b/Documentation/devicetree/bindings/arm/realtek.yaml
@@ -13,11 +13,12 @@ properties:
   $nodename:
 const: '/'
   compatible:
-# RTD1295 SoC based boards
-items:
-  - enum:
-  - mele,v9
-  - probox2,ava
-  - zidoo,x9s
-  - const: realtek,rtd1295
+oneOf:
+  # RTD1295 SoC based boards
+  - items:
+  - enum:
+  - mele,v9 # MeLE V9
+  - probox2,ava # ProBox2 AVA
+  - zidoo,x9s # Zidoo X9S
+  - const: realtek,rtd1295
 ...
-- 
2.16.4



[PATCH v2 6/8] arm64: dts: realtek: Add RTD1293 and Synology DS418j

2019-10-19 Thread Andreas Färber
Add Device Trees for RTD1293 SoC and Synology DiskStation DS418j NAS.

Cc: i...@synology.com
Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Moved SPDX-License-Identifier to top
 * Dropped "arm,armv8" (Rob)
 * Changed from MIT to BSD-2-Clause (Rob)
 * Dropped accidental enable-method and cpu-release-addr
 
 arch/arm64/boot/dts/realtek/Makefile   |  3 ++
 arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts | 30 +++
 arch/arm64/boot/dts/realtek/rtd1293.dtsi   | 51 ++
 3 files changed, 84 insertions(+)
 create mode 100644 arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
 create mode 100644 arch/arm64/boot/dts/realtek/rtd1293.dtsi

diff --git a/arch/arm64/boot/dts/realtek/Makefile 
b/arch/arm64/boot/dts/realtek/Makefile
index 90c897ac3f7a..e7ff40461ddc 100644
--- a/arch/arm64/boot/dts/realtek/Makefile
+++ b/arch/arm64/boot/dts/realtek/Makefile
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
+
+dtb-$(CONFIG_ARCH_REALTEK) += rtd1293-ds418j.dtb
+
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-mele-v9.dtb
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-probox2-ava.dtb
 dtb-$(CONFIG_ARCH_REALTEK) += rtd1295-zidoo-x9s.dtb
diff --git a/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts 
b/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
new file mode 100644
index ..b2dd583146b4
--- /dev/null
+++ b/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "rtd1293.dtsi"
+
+/ {
+   compatible = "synology,ds418j", "realtek,rtd1293";
+   model = "Synology DiskStation DS418j";
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x4000>;
+   };
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/realtek/rtd1293.dtsi 
b/arch/arm64/boot/dts/realtek/rtd1293.dtsi
new file mode 100644
index ..bd4e22723f7b
--- /dev/null
+++ b/arch/arm64/boot/dts/realtek/rtd1293.dtsi
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Realtek RTD1293 SoC
+ *
+ * Copyright (c) 2017-2019 Andreas Färber
+ */
+
+#include "rtd129x.dtsi"
+
+/ {
+   compatible = "realtek,rtd1293";
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   next-level-cache = <>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   next-level-cache = <>;
+   };
+
+   l2: l2-cache {
+   compatible = "cache";
+   };
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+};
+
+_pmu {
+   interrupt-affinity = <>, <>;
+};
-- 
2.16.4



linux-next: remove the actions tree

2019-10-19 Thread Stephen Rothwell
Hi all,

The actions tree
(git://git.kernel.org/pub/scm/linux/kernel/git/afaerber/linux-actions.git#for-next)
has not been updated in more than a year, so I have removed it from
linux-next.  Please let me know if/when you want it reinstated.

-- 
Cheers,
Stephen Rothwell


pgpI9wXVoDwH1.pgp
Description: OpenPGP digital signature


linux-next: remove the siox tree

2019-10-19 Thread Stephen Rothwell
Hi all,

The siox tree (https://git.pengutronix.de/git/ukl/linux#siox/next) has
not bee updated in more than a year, so I have removed it from linux-next.
Please let me know if/when you want it reinstated.

-- 
Cheers,
Stephen Rothwell


pgppBmIJWJCD8.pgp
Description: OpenPGP digital signature


linux-next: remove the hdlcd tree

2019-10-19 Thread Stephen Rothwell
Hi all,

The hdlcd tree (git://linux-arm.org/linux-ld#for-upstream/hdlcd) has not
been updated in more than a year, so I have removed it from linux-next.
Plesee let me know if/when you want it reinstated.

-- 
Cheers,
Stephen Rothwell


pgpTGjpksI5wQ.pgp
Description: OpenPGP digital signature


linux-next: cleanup the btrfs trees

2019-10-19 Thread Stephen Rothwell
Hi all,

The btrfs tree
(git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git#next)
has not bee updated in more than a year, so I have removed it and then
renamed the btrfs-kdave tree to btrfs.  I hope this is OK and if any
other changes are needed, please let me know.

-- 
Cheers,
Stephen Rothwell


pgpRRONi7iP2W.pgp
Description: OpenPGP digital signature


[PATCH net-next 10/16] net: dsa: use ports list to setup default CPU port

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of iterating over switches and their
ports when setting up the default CPU port. Unassign it on teardown.

Now that we can iterate over multiple CPU ports, remove dst->cpu_dp.

At the same time, provide a better error message for CPU-less tree.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h |  5 -
 net/dsa/dsa2.c| 33 -
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index b199a8ca6393..020f5db8666b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -120,11 +120,6 @@ struct dsa_switch_tree {
 */
struct dsa_platform_data*pd;
 
-   /*
-* The switch port to which the CPU is attached.
-*/
-   struct dsa_port *cpu_dp;
-
/* List of switch ports */
struct list_head ports;
 
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 99f5dab06787..772deacc33d3 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -197,38 +197,29 @@ static struct dsa_port *dsa_tree_find_first_cpu(struct 
dsa_switch_tree *dst)
 
 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst)
 {
-   struct dsa_switch *ds;
-   struct dsa_port *dp;
-   int device, port;
+   struct dsa_port *cpu_dp, *dp;
 
-   /* DSA currently only supports a single CPU port */
-   dst->cpu_dp = dsa_tree_find_first_cpu(dst);
-   if (!dst->cpu_dp) {
-   pr_warn("Tree has no master device\n");
+   cpu_dp = dsa_tree_find_first_cpu(dst);
+   if (!cpu_dp) {
+   pr_err("DSA: tree %d has no CPU port\n", dst->index);
return -EINVAL;
}
 
/* Assign the default CPU port to all ports of the fabric */
-   for (device = 0; device < DSA_MAX_SWITCHES; device++) {
-   ds = dst->ds[device];
-   if (!ds)
-   continue;
-
-   for (port = 0; port < ds->num_ports; port++) {
-   dp = >ports[port];
-
-   if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
-   dp->cpu_dp = dst->cpu_dp;
-   }
-   }
+   list_for_each_entry(dp, >ports, list)
+   if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
+   dp->cpu_dp = cpu_dp;
 
return 0;
 }
 
 static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst)
 {
-   /* DSA currently only supports a single CPU port */
-   dst->cpu_dp = NULL;
+   struct dsa_port *dp;
+
+   list_for_each_entry(dp, >ports, list)
+   if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
+   dp->cpu_dp = NULL;
 }
 
 static int dsa_port_setup(struct dsa_port *dp)
-- 
2.23.0



[PATCH net-next 01/16] net: dsa: use dsa_to_port helper everywhere

2019-10-19 Thread Vivien Didelot
Do not let the drivers access the ds->ports static array directly
while there is a dsa_to_port helper for this purpose.

At the same time, un-const this helper since the SJA1105 driver
assigns the priv member of the returned dsa_port structure.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/b53/b53_common.c   |  6 +++---
 drivers/net/dsa/bcm_sf2.c  |  8 
 drivers/net/dsa/bcm_sf2_cfp.c  |  6 +++---
 drivers/net/dsa/mt7530.c   | 12 ++--
 drivers/net/dsa/mv88e6xxx/chip.c   | 10 +-
 drivers/net/dsa/qca8k.c|  2 +-
 drivers/net/dsa/sja1105/sja1105_main.c | 18 +-
 include/net/dsa.h  |  2 +-
 net/dsa/dsa.c  |  8 +---
 net/dsa/dsa2.c |  4 ++--
 net/dsa/switch.c   |  4 ++--
 net/dsa/tag_8021q.c|  6 +++---
 12 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 526ba2ab66f1..9ba91f1370ac 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -524,7 +524,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct 
phy_device *phy)
if (!dsa_is_user_port(ds, port))
return 0;
 
-   cpu_port = ds->ports[port].cpu_dp->index;
+   cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
 
if (dev->ops->irq_enable)
ret = dev->ops->irq_enable(dev, port);
@@ -1629,7 +1629,7 @@ EXPORT_SYMBOL(b53_fdb_dump);
 int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br)
 {
struct b53_device *dev = ds->priv;
-   s8 cpu_port = ds->ports[port].cpu_dp->index;
+   s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
u16 pvlan, reg;
unsigned int i;
 
@@ -1675,7 +1675,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct 
net_device *br)
 {
struct b53_device *dev = ds->priv;
struct b53_vlan *vl = >vlans[0];
-   s8 cpu_port = ds->ports[port].cpu_dp->index;
+   s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
unsigned int i;
u16 pvlan, reg, pvid;
 
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 26509fa37a50..c068a3b7207b 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -662,7 +662,7 @@ static void bcm_sf2_sw_fixed_state(struct dsa_switch *ds, 
int port,
 * state machine and make it go in PHY_FORCING state instead.
 */
if (!status->link)
-   netif_carrier_off(ds->ports[port].slave);
+   netif_carrier_off(dsa_to_port(ds, port)->slave);
status->duplex = DUPLEX_FULL;
} else {
status->link = true;
@@ -728,7 +728,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
 static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
   struct ethtool_wolinfo *wol)
 {
-   struct net_device *p = ds->ports[port].cpu_dp->master;
+   struct net_device *p = dsa_to_port(ds, port)->cpu_dp->master;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
struct ethtool_wolinfo pwol = { };
 
@@ -752,9 +752,9 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int 
port,
 static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
  struct ethtool_wolinfo *wol)
 {
-   struct net_device *p = ds->ports[port].cpu_dp->master;
+   struct net_device *p = dsa_to_port(ds, port)->cpu_dp->master;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
-   s8 cpu_port = ds->ports[port].cpu_dp->index;
+   s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
struct ethtool_wolinfo pwol =  { };
 
if (p->ethtool_ops->get_wol)
diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
index d264776a95a3..f3f0c3f07391 100644
--- a/drivers/net/dsa/bcm_sf2_cfp.c
+++ b/drivers/net/dsa/bcm_sf2_cfp.c
@@ -821,7 +821,7 @@ static int bcm_sf2_cfp_rule_insert(struct dsa_switch *ds, 
int port,
   struct ethtool_rx_flow_spec *fs)
 {
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
-   s8 cpu_port = ds->ports[port].cpu_dp->index;
+   s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
__u64 ring_cookie = fs->ring_cookie;
unsigned int queue_num, port_num;
int ret;
@@ -1049,7 +1049,7 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv 
*priv,
 int bcm_sf2_get_rxnfc(struct dsa_switch *ds, int port,
  struct ethtool_rxnfc *nfc, u32 *rule_locs)
 {
-   struct net_device *p = ds->ports[port].cpu_dp->master;
+   struct net_device *p = dsa_to_port(ds, port)->cpu_dp->master;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
int ret = 0;
 
@@ -1092,7 +1092,7 @@ int bcm_sf2_get_rxnfc(struct dsa_switch *ds, 

[PATCH net-next 09/16] net: dsa: use ports list to find first CPU port

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of iterating over switches and their
ports when looking up the first CPU port in the tree.

Signed-off-by: Vivien Didelot 
---
 net/dsa/dsa2.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 3b8de155bc0b..99f5dab06787 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -186,22 +186,11 @@ static bool dsa_tree_setup_routing_table(struct 
dsa_switch_tree *dst)
 
 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
 {
-   struct dsa_switch *ds;
struct dsa_port *dp;
-   int device, port;
-
-   for (device = 0; device < DSA_MAX_SWITCHES; device++) {
-   ds = dst->ds[device];
-   if (!ds)
-   continue;
 
-   for (port = 0; port < ds->num_ports; port++) {
-   dp = >ports[port];
-
-   if (dsa_port_is_cpu(dp))
-   return dp;
-   }
-   }
+   list_for_each_entry(dp, >ports, list)
+   if (dsa_port_is_cpu(dp))
+   return dp;
 
return NULL;
 }
-- 
2.23.0



[PATCH net-next 04/16] net: dsa: use ports list to find slave

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of iterating over switches and their
ports when looking for a slave device from a given master interface.

Signed-off-by: Vivien Didelot 
---
 net/dsa/dsa_priv.h | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 12f8c7ee4dd8..53e7577896b6 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -104,25 +104,14 @@ static inline struct net_device 
*dsa_master_find_slave(struct net_device *dev,
 {
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch_tree *dst = cpu_dp->dst;
-   struct dsa_switch *ds;
-   struct dsa_port *slave_port;
+   struct dsa_port *dp;
 
-   if (device < 0 || device >= DSA_MAX_SWITCHES)
-   return NULL;
+   list_for_each_entry(dp, >ports, list)
+   if (dp->ds->index == device && dp->index == port &&
+   dp->type == DSA_PORT_TYPE_USER)
+   return dp->slave;
 
-   ds = dst->ds[device];
-   if (!ds)
-   return NULL;
-
-   if (port < 0 || port >= ds->num_ports)
-   return NULL;
-
-   slave_port = >ports[port];
-
-   if (unlikely(slave_port->type != DSA_PORT_TYPE_USER))
-   return NULL;
-
-   return slave_port->slave;
+   return NULL;
 }
 
 /* port.c */
-- 
2.23.0



[PATCH net-next 08/16] net: dsa: use ports list to setup multiple master devices

2019-10-19 Thread Vivien Didelot
Now that we have a potential list of CPU ports, make use of it instead
of only configuring the master device of an unique CPU port.

Signed-off-by: Vivien Didelot 
---
 net/dsa/dsa2.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 8b038cc56769..3b8de155bc0b 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -501,19 +501,27 @@ static void dsa_tree_teardown_switches(struct 
dsa_switch_tree *dst)
 
 static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
 {
-   struct dsa_port *cpu_dp = dst->cpu_dp;
-   struct net_device *master = cpu_dp->master;
+   struct dsa_port *dp;
+   int err;
 
-   /* DSA currently supports a single pair of CPU port and master device */
-   return dsa_master_setup(master, cpu_dp);
+   list_for_each_entry(dp, >ports, list) {
+   if (dsa_port_is_cpu(dp)) {
+   err = dsa_master_setup(dp->master, dp);
+   if (err)
+   return err;
+   }
+   }
+
+   return 0;
 }
 
 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
 {
-   struct dsa_port *cpu_dp = dst->cpu_dp;
-   struct net_device *master = cpu_dp->master;
+   struct dsa_port *dp;
 
-   return dsa_master_teardown(master);
+   list_for_each_entry(dp, >ports, list)
+   if (dsa_port_is_cpu(dp))
+   dsa_master_teardown(dp->master);
 }
 
 static int dsa_tree_setup(struct dsa_switch_tree *dst)
-- 
2.23.0



[PATCH net-next 07/16] net: dsa: use ports list to find a port by node

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of iterating over switches and their
ports to find a port from a given node.

Signed-off-by: Vivien Didelot 
---
 net/dsa/dsa2.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 84afeaeef141..8b038cc56769 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -113,22 +113,11 @@ static bool dsa_port_is_user(struct dsa_port *dp)
 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst,
   struct device_node *dn)
 {
-   struct dsa_switch *ds;
struct dsa_port *dp;
-   int device, port;
-
-   for (device = 0; device < DSA_MAX_SWITCHES; device++) {
-   ds = dst->ds[device];
-   if (!ds)
-   continue;
 
-   for (port = 0; port < ds->num_ports; port++) {
-   dp = >ports[port];
-
-   if (dp->dn == dn)
-   return dp;
-   }
-   }
+   list_for_each_entry(dp, >ports, list)
+   if (dp->dn == dn)
+   return dp;
 
return NULL;
 }
-- 
2.23.0



[PATCH net-next 05/16] net: dsa: use ports list to setup switches

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of iterating over switches and their
ports when setting up the switches and their ports.

At the same time, provide setup states and messages for ports and
switches as it is done for the trees.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h |   4 ++
 net/dsa/dsa2.c| 101 ++
 2 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 938de9518c61..b199a8ca6393 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -215,9 +215,13 @@ struct dsa_port {
 * Original copy of the master netdev net_device_ops
 */
const struct net_device_ops *orig_ndo_ops;
+
+   bool setup;
 };
 
 struct dsa_switch {
+   bool setup;
+
struct device *dev;
 
/*
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index b6536641ac99..fd2b7f157f97 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -267,6 +267,9 @@ static int dsa_port_setup(struct dsa_port *dp)
bool dsa_port_enabled = false;
int err = 0;
 
+   if (dp->setup)
+   return 0;
+
switch (dp->type) {
case DSA_PORT_TYPE_UNUSED:
dsa_port_disable(dp);
@@ -335,14 +338,23 @@ static int dsa_port_setup(struct dsa_port *dp)
dsa_port_link_unregister_of(dp);
if (err && devlink_port_registered)
devlink_port_unregister(dlp);
+   if (err)
+   return err;
 
-   return err;
+   dp->setup = true;
+
+   pr_info("DSA: switch %d port %d setup\n", dp->ds->index, dp->index);
+
+   return 0;
 }
 
 static void dsa_port_teardown(struct dsa_port *dp)
 {
struct devlink_port *dlp = >devlink_port;
 
+   if (!dp->setup)
+   return;
+
switch (dp->type) {
case DSA_PORT_TYPE_UNUSED:
break;
@@ -365,11 +377,18 @@ static void dsa_port_teardown(struct dsa_port *dp)
}
break;
}
+
+   dp->setup = false;
+
+   pr_info("DSA: switch %d port %d torn down\n", dp->ds->index, dp->index);
 }
 
 static int dsa_switch_setup(struct dsa_switch *ds)
 {
-   int err = 0;
+   int err;
+
+   if (ds->setup)
+   return 0;
 
/* Initialize ds->phys_mii_mask before registering the slave MDIO bus
 * driver and before ops->setup() has run, since the switch drivers and
@@ -411,6 +430,10 @@ static int dsa_switch_setup(struct dsa_switch *ds)
goto unregister_notifier;
}
 
+   ds->setup = true;
+
+   pr_info("DSA: switch %d setup\n", ds->index);
+
return 0;
 
 unregister_notifier:
@@ -426,6 +449,9 @@ static int dsa_switch_setup(struct dsa_switch *ds)
 
 static void dsa_switch_teardown(struct dsa_switch *ds)
 {
+   if (!ds->setup)
+   return;
+
if (ds->slave_mii_bus && ds->ops->phy_read)
mdiobus_unregister(ds->slave_mii_bus);
 
@@ -440,78 +466,49 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
ds->devlink = NULL;
}
 
+   ds->setup = false;
+
+   pr_info("DSA: switch %d torn down\n", ds->index);
 }
 
 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst)
 {
-   struct dsa_switch *ds;
struct dsa_port *dp;
-   int device, port, i;
-   int err = 0;
-
-   for (device = 0; device < DSA_MAX_SWITCHES; device++) {
-   ds = dst->ds[device];
-   if (!ds)
-   continue;
+   int err;
 
-   err = dsa_switch_setup(ds);
+   list_for_each_entry(dp, >ports, list) {
+   err = dsa_switch_setup(dp->ds);
if (err)
-   goto switch_teardown;
-
-   for (port = 0; port < ds->num_ports; port++) {
-   dp = >ports[port];
+   goto teardown;
+   }
 
-   err = dsa_port_setup(dp);
-   if (err)
-   goto ports_teardown;
-   }
+   list_for_each_entry(dp, >ports, list) {
+   err = dsa_port_setup(dp);
+   if (err)
+   goto teardown;
}
 
return 0;
 
-ports_teardown:
-   for (i = 0; i < port; i++)
-   dsa_port_teardown(>ports[i]);
-
-   dsa_switch_teardown(ds);
-
-switch_teardown:
-   for (i = 0; i < device; i++) {
-   ds = dst->ds[i];
-   if (!ds)
-   continue;
-
-   for (port = 0; port < ds->num_ports; port++) {
-   dp = >ports[port];
-
-   dsa_port_teardown(dp);
-   }
+teardown:
+   list_for_each_entry(dp, >ports, list)
+   dsa_port_teardown(dp);
 
-   dsa_switch_teardown(ds);
-   }
+   list_for_each_entry(dp, >ports, list)
+   dsa_switch_teardown(dp->ds);
 
return err;
 }
 
 

[PATCH net-next 14/16] net: dsa: sja1105: register switch before assigning port private data

2019-10-19 Thread Vivien Didelot
Like the dsa_switch_tree structures, the dsa_port structures will be
allocated on switch registration.

The SJA1105 driver is the only one accessing the dsa_port structure
after the switch allocation and before the switch registration.
For that reason, move switch registration prior to assigning the priv
member of the dsa_port structures.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/sja1105/sja1105_main.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c 
b/drivers/net/dsa/sja1105/sja1105_main.c
index 4b0cb779f187..0ebbda5ca665 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -2057,6 +2057,15 @@ static int sja1105_probe(struct spi_device *spi)
 
tagger_data = >tagger_data;
 
+   mutex_init(>ptp_data.lock);
+   mutex_init(>mgmt_lock);
+
+   sja1105_tas_setup(ds);
+
+   rc = dsa_register_switch(priv->ds);
+   if (rc)
+   return rc;
+
/* Connections between dsa_port and sja1105_port */
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
struct sja1105_port *sp = >ports[i];
@@ -2065,12 +2074,8 @@ static int sja1105_probe(struct spi_device *spi)
sp->dp = dsa_to_port(ds, i);
sp->data = tagger_data;
}
-   mutex_init(>ptp_data.lock);
-   mutex_init(>mgmt_lock);
 
-   sja1105_tas_setup(ds);
-
-   return dsa_register_switch(priv->ds);
+   return 0;
 }
 
 static int sja1105_remove(struct spi_device *spi)
-- 
2.23.0



[PATCH net-next 13/16] net: dsa: mv88e6xxx: use ports list to map bridge

2019-10-19 Thread Vivien Didelot
Instead of digging into the other dsa_switch structures of the fabric
and relying too much on the dsa_to_port helper, use the new list
of switch fabric ports to remap the Port VLAN Map of local bridge
group members or remap the Port VLAN Table entry of external bridge
group members.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.c | 36 +---
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index af8943142053..8771f2525932 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2043,29 +2043,23 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch 
*ds, int port,
 static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
struct net_device *br)
 {
-   struct dsa_switch *ds;
-   int port;
-   int dev;
+   struct dsa_switch *ds = chip->ds;
+   struct dsa_switch_tree *dst = ds->dst;
+   struct dsa_port *dp;
int err;
 
-   /* Remap the Port VLAN of each local bridge group member */
-   for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
-   if (dsa_to_port(chip->ds, port)->bridge_dev == br) {
-   err = mv88e6xxx_port_vlan_map(chip, port);
-   if (err)
-   return err;
-   }
-   }
-
-   /* Remap the Port VLAN of each cross-chip bridge group member */
-   for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
-   ds = chip->ds->dst->ds[dev];
-   if (!ds)
-   break;
-
-   for (port = 0; port < ds->num_ports; ++port) {
-   if (dsa_to_port(ds, port)->bridge_dev == br) {
-   err = mv88e6xxx_pvt_map(chip, dev, port);
+   list_for_each_entry(dp, >ports, list) {
+   /* Remap the Port VLAN Map of local bridge group members and
+* remap the PVT entry of external bridge group members.
+*/
+   if (dp->bridge_dev == br) {
+   if (dp->ds == ds) {
+   err = mv88e6xxx_port_vlan_map(chip, dp->index);
+   if (err)
+   return err;
+   } else {
+   err = mv88e6xxx_pvt_map(chip, dp->ds->index,
+   dp->index);
if (err)
return err;
}
-- 
2.23.0



[PATCH net-next 12/16] net: dsa: mv88e6xxx: use ports list to map port VLAN

2019-10-19 Thread Vivien Didelot
Instead of digging into the other dsa_switch structures of the fabric
and relying too much on the dsa_to_port helper, use the new list of
switch fabric ports to define the mask of the local ports allowed to
receive frames from another port of the fabric.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 510ccdc2d03c..af8943142053 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1057,35 +1057,43 @@ static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, 
int port,
return 0;
 }
 
+/* Mask of the local ports allowed to receive frames from a given fabric port 
*/
 static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
 {
-   struct dsa_switch *ds = NULL;
+   struct dsa_switch *ds = chip->ds;
+   struct dsa_switch_tree *dst = ds->dst;
struct net_device *br;
+   struct dsa_port *dp;
+   bool found = false;
u16 pvlan;
-   int i;
 
-   if (dev < DSA_MAX_SWITCHES)
-   ds = chip->ds->dst->ds[dev];
+   list_for_each_entry(dp, >ports, list) {
+   if (dp->ds->index == dev && dp->index == port) {
+   found = true;
+   break;
+   }
+   }
 
/* Prevent frames from unknown switch or port */
-   if (!ds || port >= ds->num_ports)
+   if (!found)
return 0;
 
/* Frames from DSA links and CPU ports can egress any local port */
-   if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
+   if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
return mv88e6xxx_port_mask(chip);
 
-   br = dsa_to_port(ds, port)->bridge_dev;
+   br = dp->bridge_dev;
pvlan = 0;
 
/* Frames from user ports can egress any local DSA links and CPU ports,
 * as well as any local member of their bridge group.
 */
-   for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
-   if (dsa_is_cpu_port(chip->ds, i) ||
-   dsa_is_dsa_port(chip->ds, i) ||
-   (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
-   pvlan |= BIT(i);
+   list_for_each_entry(dp, >ports, list)
+   if (dp->ds == ds &&
+   (dp->type == DSA_PORT_TYPE_CPU ||
+dp->type == DSA_PORT_TYPE_DSA ||
+(br && dp->bridge_dev == br)))
+   pvlan |= BIT(dp->index);
 
return pvlan;
 }
-- 
2.23.0



[PATCH net-next 15/16] net: dsa: allocate ports on touch

2019-10-19 Thread Vivien Didelot
Allocate the struct dsa_port the first time it is accessed with
dsa_port_touch, and remove the static dsa_port array from the
dsa_switch structure.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h |  2 --
 net/dsa/dsa2.c| 16 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 020f5db8666b..d28ac54cb8c4 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -277,9 +277,7 @@ struct dsa_switch {
 */
boolvlan_filtering;
 
-   /* Dynamically allocated ports, keep last */
size_t num_ports;
-   struct dsa_port ports[];
 };
 
 static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 772deacc33d3..7669a6278c40 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -596,7 +596,13 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch 
*ds, int index)
struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp;
 
-   dp = >ports[index];
+   list_for_each_entry(dp, >ports, list)
+   if (dp->ds == ds && dp->index == index)
+   return dp;
+
+   dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+   if (!dp)
+   return NULL;
 
dp->ds = ds;
dp->index = index;
@@ -865,7 +871,7 @@ struct dsa_switch *dsa_switch_alloc(struct device *dev, 
size_t n)
 {
struct dsa_switch *ds;
 
-   ds = devm_kzalloc(dev, struct_size(ds, ports, n), GFP_KERNEL);
+   ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
if (!ds)
return NULL;
 
@@ -893,6 +899,12 @@ static void dsa_switch_remove(struct dsa_switch *ds)
 {
struct dsa_switch_tree *dst = ds->dst;
unsigned int index = ds->index;
+   struct dsa_port *dp, *next;
+
+   list_for_each_entry_safe(dp, next, >ports, list) {
+   list_del(>list);
+   kfree(dp);
+   }
 
dsa_tree_remove_switch(dst, index);
 }
-- 
2.23.0



[PATCH net-next 16/16] net: dsa: remove dsa_switch_alloc helper

2019-10-19 Thread Vivien Didelot
Now that ports are dynamically listed in the fabric, there is no need
to provide a special helper to allocate the dsa_switch structure. This
will give more flexibility to drivers to embed this structure as they
wish in their private structure.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/b53/b53_common.c   |  5 -
 drivers/net/dsa/dsa_loop.c |  5 -
 drivers/net/dsa/lan9303-core.c |  4 +++-
 drivers/net/dsa/lantiq_gswip.c |  4 +++-
 drivers/net/dsa/microchip/ksz_common.c |  5 -
 drivers/net/dsa/mt7530.c   |  5 -
 drivers/net/dsa/mv88e6060.c|  4 +++-
 drivers/net/dsa/mv88e6xxx/chip.c   |  4 +++-
 drivers/net/dsa/qca8k.c|  5 -
 drivers/net/dsa/realtek-smi-core.c |  5 -
 drivers/net/dsa/sja1105/sja1105_main.c |  4 +++-
 drivers/net/dsa/vitesse-vsc73xx-core.c |  5 -
 include/net/dsa.h  |  1 -
 net/dsa/dsa2.c | 21 ++---
 14 files changed, 49 insertions(+), 28 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 9ba91f1370ac..0a5ab2ce74e3 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2342,10 +2342,13 @@ struct b53_device *b53_switch_alloc(struct device *base,
struct dsa_switch *ds;
struct b53_device *dev;
 
-   ds = dsa_switch_alloc(base, DSA_MAX_PORTS);
+   ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
if (!ds)
return NULL;
 
+   ds->dev = base;
+   ds->num_ports = DSA_MAX_PORTS;
+
dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL);
if (!dev)
return NULL;
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 925ed135a4d9..c8d7ef27fd72 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -286,10 +286,13 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
dev_info(>dev, "%s: 0x%0x\n",
 pdata->name, pdata->enabled_ports);
 
-   ds = dsa_switch_alloc(>dev, DSA_MAX_PORTS);
+   ds = devm_kzalloc(>dev, sizeof(*ds), GFP_KERNEL);
if (!ds)
return -ENOMEM;
 
+   ds->dev = >dev;
+   ds->num_ports = DSA_MAX_PORTS;
+
ps = devm_kzalloc(>dev, sizeof(*ps), GFP_KERNEL);
if (!ps)
return -ENOMEM;
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index bbec86b9418e..e3c333a8f45d 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -1283,10 +1283,12 @@ static int lan9303_register_switch(struct lan9303 *chip)
 {
int base;
 
-   chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS);
+   chip->ds = devm_kzalloc(chip->dev, sizeof(*chip->ds), GFP_KERNEL);
if (!chip->ds)
return -ENOMEM;
 
+   chip->ds->dev = chip->dev;
+   chip->ds->num_ports = LAN9303_NUM_PORTS;
chip->ds->priv = chip;
chip->ds->ops = _switch_ops;
base = chip->phy_addr_base;
diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index a69c9b9878b7..955324968b74 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1854,10 +1854,12 @@ static int gswip_probe(struct platform_device *pdev)
if (!priv->hw_info)
return -EINVAL;
 
-   priv->ds = dsa_switch_alloc(dev, priv->hw_info->max_ports);
+   priv->ds = devm_kzalloc(dev, sizeof(*priv->ds), GFP_KERNEL);
if (!priv->ds)
return -ENOMEM;
 
+   priv->ds->dev = dev;
+   priv->ds->num_ports = priv->hw_info->max_ports;
priv->ds->priv = priv;
priv->ds->ops = _switch_ops;
priv->dev = dev;
diff --git a/drivers/net/dsa/microchip/ksz_common.c 
b/drivers/net/dsa/microchip/ksz_common.c
index b0b870f0c252..c755d9e1c4f6 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -398,10 +398,13 @@ struct ksz_device *ksz_switch_alloc(struct device *base, 
void *priv)
struct dsa_switch *ds;
struct ksz_device *swdev;
 
-   ds = dsa_switch_alloc(base, DSA_MAX_PORTS);
+   ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
if (!ds)
return NULL;
 
+   ds->dev = base;
+   ds->num_ports = DSA_MAX_PORTS;
+
swdev = devm_kzalloc(base, sizeof(*swdev), GFP_KERNEL);
if (!swdev)
return NULL;
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index a91293e47a57..add9e4279176 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -1632,10 +1632,13 @@ mt7530_probe(struct mdio_device *mdiodev)
if (!priv)
return -ENOMEM;
 
-   priv->ds = dsa_switch_alloc(>dev, DSA_MAX_PORTS);
+   priv->ds = devm_kzalloc(>dev, sizeof(*priv->ds), GFP_KERNEL);
if (!priv->ds)
return -ENOMEM;
 
+   

[PATCH net-next 11/16] net: dsa: mv88e6xxx: silently skip PVT ops

2019-10-19 Thread Vivien Didelot
Since mv88e6xxx_pvt_map is a static helper, no need to return
-EOPNOTSUPP if the chip has no PVT, simply silently skip the operation.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index d67deec77452..510ccdc2d03c 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1253,7 +1253,7 @@ static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, 
int dev, int port)
u16 pvlan = 0;
 
if (!mv88e6xxx_has_pvt(chip))
-   return -EOPNOTSUPP;
+   return 0;
 
/* Skip the local source device, which uses in-chip port VLAN */
if (dev != chip->ds->index)
@@ -2049,9 +2049,6 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip 
*chip,
}
}
 
-   if (!mv88e6xxx_has_pvt(chip))
-   return 0;
-
/* Remap the Port VLAN of each cross-chip bridge group member */
for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
ds = chip->ds->dst->ds[dev];
@@ -2101,9 +2098,6 @@ static int mv88e6xxx_crosschip_bridge_join(struct 
dsa_switch *ds, int dev,
struct mv88e6xxx_chip *chip = ds->priv;
int err;
 
-   if (!mv88e6xxx_has_pvt(chip))
-   return 0;
-
mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_pvt_map(chip, dev, port);
mv88e6xxx_reg_unlock(chip);
@@ -2116,9 +2110,6 @@ static void mv88e6xxx_crosschip_bridge_leave(struct 
dsa_switch *ds, int dev,
 {
struct mv88e6xxx_chip *chip = ds->priv;
 
-   if (!mv88e6xxx_has_pvt(chip))
-   return;
-
mv88e6xxx_reg_lock(chip);
if (mv88e6xxx_pvt_map(chip, dev, port))
dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
-- 
2.23.0



[PATCH net-next 06/16] net: dsa: use ports list for routing table setup

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of accessing the dsa_switch array
of ports when iterating over DSA ports of a switch to set up the
routing table.

Signed-off-by: Vivien Didelot 
---
 net/dsa/dsa2.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index fd2b7f157f97..84afeaeef141 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -157,6 +157,7 @@ static bool dsa_port_setup_routing_table(struct dsa_port 
*dp)
 
 static bool dsa_switch_setup_routing_table(struct dsa_switch *ds)
 {
+   struct dsa_switch_tree *dst = ds->dst;
bool complete = true;
struct dsa_port *dp;
int i;
@@ -164,10 +165,8 @@ static bool dsa_switch_setup_routing_table(struct 
dsa_switch *ds)
for (i = 0; i < DSA_MAX_SWITCHES; i++)
ds->rtable[i] = DSA_RTABLE_NONE;
 
-   for (i = 0; i < ds->num_ports; i++) {
-   dp = >ports[i];
-
-   if (dsa_port_is_dsa(dp)) {
+   list_for_each_entry(dp, >ports, list) {
+   if (dp->ds == ds && dsa_port_is_dsa(dp)) {
complete = dsa_port_setup_routing_table(dp);
if (!complete)
break;
-- 
2.23.0



[PATCH net-next 02/16] net: dsa: add ports list in the switch fabric

2019-10-19 Thread Vivien Didelot
Add a list of switch ports within the switch fabric. This will help the
lookup of a port inside the whole fabric, and it is the first step
towards supporting multiple CPU ports, before deprecating the usage of
the unique dst->cpu_dp pointer.

In preparation for a future allocation of the dsa_port structures,
return -ENOMEM in case no structure is returned, even though this
error cannot be reached yet.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h |  5 +
 net/dsa/dsa2.c| 48 +--
 2 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2e4fe2f8962b..6ff6dfcdc61d 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -125,6 +125,9 @@ struct dsa_switch_tree {
 */
struct dsa_port *cpu_dp;
 
+   /* List of switch ports */
+   struct list_head ports;
+
/*
 * Data for the individual switch chips.
 */
@@ -195,6 +198,8 @@ struct dsa_port {
struct work_struct  xmit_work;
struct sk_buff_head xmit_queue;
 
+   struct list_head list;
+
/*
 * Give the switch driver somewhere to hang its per-port private data
 * structures (accessible from the tagger).
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 1716535167ee..b6536641ac99 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -45,6 +45,8 @@ static struct dsa_switch_tree *dsa_tree_alloc(int index)
 
dst->index = index;
 
+   INIT_LIST_HEAD(>ports);
+
INIT_LIST_HEAD(>list);
list_add_tail(>list, _tree_list);
 
@@ -616,6 +618,22 @@ static int dsa_tree_add_switch(struct dsa_switch_tree *dst,
return err;
 }
 
+static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
+{
+   struct dsa_switch_tree *dst = ds->dst;
+   struct dsa_port *dp;
+
+   dp = >ports[index];
+
+   dp->ds = ds;
+   dp->index = index;
+
+   INIT_LIST_HEAD(>list);
+   list_add(>list, >ports);
+
+   return dp;
+}
+
 static int dsa_port_parse_user(struct dsa_port *dp, const char *name)
 {
if (!name)
@@ -742,6 +760,20 @@ static int dsa_switch_parse_member_of(struct dsa_switch 
*ds,
return 0;
 }
 
+static int dsa_switch_touch_ports(struct dsa_switch *ds)
+{
+   struct dsa_port *dp;
+   int port;
+
+   for (port = 0; port < ds->num_ports; port++) {
+   dp = dsa_port_touch(ds, port);
+   if (!dp)
+   return -ENOMEM;
+   }
+
+   return 0;
+}
+
 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
 {
int err;
@@ -750,6 +782,10 @@ static int dsa_switch_parse_of(struct dsa_switch *ds, 
struct device_node *dn)
if (err)
return err;
 
+   err = dsa_switch_touch_ports(ds);
+   if (err)
+   return err;
+
return dsa_switch_parse_ports_of(ds, dn);
 }
 
@@ -807,6 +843,8 @@ static int dsa_switch_parse_ports(struct dsa_switch *ds,
 
 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd)
 {
+   int err;
+
ds->cd = cd;
 
/* We don't support interconnected switches nor multiple trees via
@@ -817,6 +855,10 @@ static int dsa_switch_parse(struct dsa_switch *ds, struct 
dsa_chip_data *cd)
if (!ds->dst)
return -ENOMEM;
 
+   err = dsa_switch_touch_ports(ds);
+   if (err)
+   return err;
+
return dsa_switch_parse_ports(ds, cd);
 }
 
@@ -849,7 +891,6 @@ static int dsa_switch_probe(struct dsa_switch *ds)
 struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n)
 {
struct dsa_switch *ds;
-   int i;
 
ds = devm_kzalloc(dev, struct_size(ds, ports, n), GFP_KERNEL);
if (!ds)
@@ -858,11 +899,6 @@ struct dsa_switch *dsa_switch_alloc(struct device *dev, 
size_t n)
ds->dev = dev;
ds->num_ports = n;
 
-   for (i = 0; i < ds->num_ports; ++i) {
-   ds->ports[i].index = i;
-   ds->ports[i].ds = ds;
-   }
-
return ds;
 }
 EXPORT_SYMBOL_GPL(dsa_switch_alloc);
-- 
2.23.0



[PATCH net-next 03/16] net: dsa: use ports list in dsa_to_port

2019-10-19 Thread Vivien Didelot
Use the new ports list instead of accessing the dsa_switch array
of ports in the dsa_to_port helper.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6ff6dfcdc61d..938de9518c61 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -285,7 +285,14 @@ struct dsa_switch {
 
 static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
 {
-   return >ports[p];
+   struct dsa_switch_tree *dst = ds->dst;
+   struct dsa_port *dp;
+
+   list_for_each_entry(dp, >ports, list)
+   if (dp->ds == ds && dp->index == p)
+   return dp;
+
+   return NULL;
 }
 
 static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)
-- 
2.23.0



[PATCH net-next 00/16] net: dsa: turn arrays of ports into a list

2019-10-19 Thread Vivien Didelot
The dsa_switch structure represents the physical switch device itself,
and is allocated by the driver. The dsa_switch_tree and dsa_port structures
represent the logical switch fabric (eventually composed of multiple switch
devices) and its ports, and are allocated by the DSA core.

This branch lists the logical ports directly in the fabric which simplifies
the iteration over all ports when assigning the default CPU port or configuring
the D in DSA in drivers like mv88e6xxx.

This also removes the unique dst->cpu_dp pointer and is a first step towards
supporting multiple CPU ports and dropping the DSA_MAX_PORTS limitation.

Because the dsa_port structures are not tight to the dsa_switch structure
anymore, we do not need to provide an helper for the drivers to allocate a
switch structure. Like in many other subsystems, drivers can now embed their
dsa_switch structure as they wish into their private structure. This will
be particularly interesting for the Broadcom drivers which were currently
limited by the dynamically allocated array of DSA ports.

The series implements the list of dsa_port structures, makes use of it,
then drops dst->cpu_dp and the dsa_switch_alloc helper.


Vivien Didelot (16):
  net: dsa: use dsa_to_port helper everywhere
  net: dsa: add ports list in the switch fabric
  net: dsa: use ports list in dsa_to_port
  net: dsa: use ports list to find slave
  net: dsa: use ports list to setup switches
  net: dsa: use ports list for routing table setup
  net: dsa: use ports list to find a port by node
  net: dsa: use ports list to setup multiple master devices
  net: dsa: use ports list to find first CPU port
  net: dsa: use ports list to setup default CPU port
  net: dsa: mv88e6xxx: silently skip PVT ops
  net: dsa: mv88e6xxx: use ports list to map port VLAN
  net: dsa: mv88e6xxx: use ports list to map bridge
  net: dsa: sja1105: register switch before assigning port private data
  net: dsa: allocate ports on touch
  net: dsa: remove dsa_switch_alloc helper

 drivers/net/dsa/b53/b53_common.c   |  11 +-
 drivers/net/dsa/bcm_sf2.c  |   8 +-
 drivers/net/dsa/bcm_sf2_cfp.c  |   6 +-
 drivers/net/dsa/dsa_loop.c |   5 +-
 drivers/net/dsa/lan9303-core.c |   4 +-
 drivers/net/dsa/lantiq_gswip.c |   4 +-
 drivers/net/dsa/microchip/ksz_common.c |   5 +-
 drivers/net/dsa/mt7530.c   |  17 +-
 drivers/net/dsa/mv88e6060.c|   4 +-
 drivers/net/dsa/mv88e6xxx/chip.c   |  87 
 drivers/net/dsa/qca8k.c|   7 +-
 drivers/net/dsa/realtek-smi-core.c |   5 +-
 drivers/net/dsa/sja1105/sja1105_main.c |  37 ++--
 drivers/net/dsa/vitesse-vsc73xx-core.c |   5 +-
 include/net/dsa.h  |  26 ++-
 net/dsa/dsa.c  |   8 +-
 net/dsa/dsa2.c | 282 +
 net/dsa/dsa_priv.h |  23 +-
 net/dsa/switch.c   |   4 +-
 net/dsa/tag_8021q.c|   6 +-
 20 files changed, 297 insertions(+), 257 deletions(-)

-- 
2.23.0



From Lisa Tofan

2019-10-19 Thread Lisa Tofan
Hello Dear,

This is Miss Lisa Tofan, How are you today hope all is well with you,
please I will need your urgent attention

regarding this important discussion kindly write me back here :
lisatofan...@gmail.com : for more details,
Thanks,
Lisa Tofan


Re: [PATCH] mm/vmstat: do not use size of vmstat_text as count of /proc/vmstat items

2019-10-19 Thread Randy Dunlap
On 10/19/19 2:45 PM, Konstantin Khlebnikov wrote:
> Strings from vmstat_text[] will be used for printing memory cgroup
> statistics which exists even if CONFIG_VM_EVENT_COUNTERS=n.
> 
> This should be applied before patch "mm/memcontrol: use vmstat names
> for printing statistics".
> 
> Signed-off-by: Konstantin Khlebnikov 
> Link: 
> https://lore.kernel.org/linux-mm/cd1c42ae-281f-c8a8-70ac-1d01d417b...@infradead.org/T/#u

Reported-by: Randy Dunlap 
Acked-by: Randy Dunlap  # build-tested

Thanks.

> ---
>  mm/vmstat.c |   26 --
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 590aeca27cab..13e36da70f3c 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1638,25 +1638,23 @@ static const struct seq_operations zoneinfo_op = {
>   .show   = zoneinfo_show,
>  };
>  
> +#define NR_VMSTAT_ITEMS (NR_VM_ZONE_STAT_ITEMS + \
> +  NR_VM_NUMA_STAT_ITEMS + \
> +  NR_VM_NODE_STAT_ITEMS + \
> +  NR_VM_WRITEBACK_STAT_ITEMS + \
> +  (IS_ENABLED(CONFIG_VM_EVENT_COUNTERS) ? \
> +   NR_VM_EVENT_ITEMS : 0))
> +
>  static void *vmstat_start(struct seq_file *m, loff_t *pos)
>  {
>   unsigned long *v;
> - int i, stat_items_size;
> + int i;
>  
> - if (*pos >= ARRAY_SIZE(vmstat_text))
> + if (*pos >= NR_VMSTAT_ITEMS)
>   return NULL;
> - stat_items_size = NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) +
> -   NR_VM_NUMA_STAT_ITEMS * sizeof(unsigned long) +
> -   NR_VM_NODE_STAT_ITEMS * sizeof(unsigned long) +
> -   NR_VM_WRITEBACK_STAT_ITEMS * sizeof(unsigned long);
> -
> -#ifdef CONFIG_VM_EVENT_COUNTERS
> - stat_items_size += sizeof(struct vm_event_state);
> -#endif
>  
> - BUILD_BUG_ON(stat_items_size !=
> -  ARRAY_SIZE(vmstat_text) * sizeof(unsigned long));
> - v = kmalloc(stat_items_size, GFP_KERNEL);
> + BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) < NR_VMSTAT_ITEMS);
> + v = kmalloc_array(NR_VMSTAT_ITEMS, sizeof(unsigned long), GFP_KERNEL);
>   m->private = v;
>   if (!v)
>   return ERR_PTR(-ENOMEM);
> @@ -1689,7 +1687,7 @@ static void *vmstat_start(struct seq_file *m, loff_t 
> *pos)
>  static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)
>  {
>   (*pos)++;
> - if (*pos >= ARRAY_SIZE(vmstat_text))
> + if (*pos >= NR_VMSTAT_ITEMS)
>   return NULL;
>   return (unsigned long *)m->private + *pos;
>  }
> 


-- 
~Randy



[PATCH] of: reserved_mem: add missing of_node_put() for proper ref-counting

2019-10-19 Thread Chris Goldsworthy
Commit d698a388146c ("of: reserved-memory: ignore disabled memory-region
nodes") added an early return in of_reserved_mem_device_init_by_idx(), but
didn't call of_node_put() on a device_node whose ref-count was incremented
in the call to of_parse_phandle() preceding the early exit.

Fixes: d698a388146c ("of: reserved-memory: ignore disabled memory-region nodes")
Signed-off-by: Chris Goldsworthy 
To: Rob Herring 
Cc: devicet...@vger.kernel.org
Cc: sta...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
---
 drivers/of/of_reserved_mem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 7989703..6bd610e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -324,8 +324,10 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
if (!target)
return -ENODEV;
 
-   if (!of_device_is_available(target))
+   if (!of_device_is_available(target)) {
+   of_node_put(target);
return 0;
+   }
 
rmem = __find_rmem(target);
of_node_put(target);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] usb: xhci: fix Immediate Data Transfer endianness

2019-10-19 Thread Samuel Holland
The arguments to queue_trb are always byteswapped to LE for placement in
the ring, but this should not happen in the case of immediate data; the
bytes copied out of transfer_buffer are already in the correct order.
Add a complementary byteswap so the bytes end up in the ring correctly.

This was observed on BE ppc64 with a "Texas Instruments TUSB73x0
SuperSpeed USB 3.0 xHCI Host Controller [104c:8241]" as a ch341
usb-serial adapter ("1a86:7523 QinHeng Electronics HL-340 USB-Serial
adapter") always transmitting the same character (generally NUL) over
the serial link regardless of the key pressed.

Cc: sta...@vger.kernel.org
Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support")
Signed-off-by: Samuel Holland 
---
 drivers/usb/host/xhci-ring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 85ceb43e3405..e7aab31fd9a5 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3330,6 +3330,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t 
mem_flags,
if (xhci_urb_suitable_for_idt(urb)) {
memcpy(_addr, urb->transfer_buffer,
   trb_buff_len);
+   le64_to_cpus(_addr);
field |= TRB_IDT;
}
}
@@ -3475,6 +3476,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t 
mem_flags,
if (xhci_urb_suitable_for_idt(urb)) {
memcpy(, urb->transfer_buffer,
   urb->transfer_buffer_length);
+   le64_to_cpus();
field |= TRB_IDT;
} else {
addr = (u64) urb->transfer_dma;
-- 
2.21.0



[PATCH] platform/x86: huawei-wmi: Remove unnecessary battery mutex

2019-10-19 Thread Ayman Bagabas
battery_lock mutex is never used and not needed.

Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging 
thresholds")
Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/huawei-wmi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
index 7373a65a61d3..a2d846c4a7ee 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -67,7 +67,6 @@ struct huawei_wmi {
struct led_classdev cdev;
struct device *dev;
 
-   struct mutex battery_lock;
struct mutex wmi_lock;
 };
 
@@ -807,7 +806,6 @@ static int huawei_wmi_probe(struct platform_device *pdev)
 
if (wmi_has_guid(HWMI_METHOD_GUID)) {
mutex_init(_wmi->wmi_lock);
-   mutex_init(_wmi->battery_lock);
 
huawei_wmi_leds_setup(>dev);
huawei_wmi_fn_lock_setup(>dev);

base-commit: fd13c8622a5ad4f7317b64de4f6aa2de1962220e
prerequisite-patch-id: 7639f479e344d2a1be074f93dc5e5530611928f9
prerequisite-patch-id: ad5932635d0c0d531a99e15e239f81ecc69b47d6
-- 
2.21.0



Re: [GIT] Networking

2019-10-19 Thread pr-tracker-bot
The pull request you sent on Sat, 19 Oct 2019 12:39:27 -0700 (PDT):

> git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git refs/heads/master

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/531e93d11470aa2e14e6a3febef50d9bc7bab7a1

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH 2/2] platform/x86: huawei-wmi: No need to check for battery name

2019-10-19 Thread ayman . bagabas
On Fri, 2019-10-18 at 18:42 -0400, Ayman Bagabas wrote:
> No need to check for battery name, we already check if the WMI
> function is
> available in huawei_wmi_battery_setup.

Signed-off-by: Ayman Bagabas 

Thank you,
Ayman
> ---
>  drivers/platform/x86/huawei-wmi.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/huawei-wmi.c
> b/drivers/platform/x86/huawei-wmi.c
> index 26041d44286a..7373a65a61d3 100644
> --- a/drivers/platform/x86/huawei-wmi.c
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -471,10 +471,6 @@ static
> DEVICE_ATTR_RW(charge_control_thresholds);
>  
>  static int huawei_wmi_battery_add(struct power_supply *battery)
>  {
> - /* Huawei laptops come with one battery only */
> - if (strcmp(battery->desc->name, "BAT") != 1)
> - return -ENODEV;
> -
>   device_create_file(>dev,
> _attr_charge_control_start_threshold);
>   device_create_file(>dev,
> _attr_charge_control_end_threshold);
>  



Re: [PATCH 1/2] platform/x86: huawei-wmi: Stricter battery thresholds set

2019-10-19 Thread ayman . bagabas
On Sat, 2019-10-19 at 11:31 +0300, Dan Carpenter wrote:
> On Fri, Oct 18, 2019 at 06:42:13PM -0400, Ayman Bagabas wrote:
> > Check if battery thresholds are within 0 and 100.
> > ---
> 
> Thanks!
> 
> Don't forget to add your Signed-off-by: though.

Signed-off-by: Ayman Bagabas 

Thank you,
Ayman
> 
> regards,
> dan carpenter
> 



Re: [PATCH] fs: exFAT read-only driver GPL implementation by Paragon Software.

2019-10-19 Thread Pali Rohár
Hello! I have not read deeply whole implementation, just spotted
suspicious options. See below.

On Friday 18 October 2019 15:18:39 Konstantin Komarov wrote:
> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> new file mode 100644
> index ..5f8713fe1b0c
> --- /dev/null
> +++ b/fs/exfat/exfat_fs.h
> @@ -0,0 +1,388 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + *  linux/fs/exfat/super.c
> + *
> + * Copyright (c) 2010-2019 Paragon Software GmbH, All rights reserved.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct exfat_mount_options {
> + kuid_t fs_uid;
> + kgid_t fs_gid;
> + u16 fs_fmask;
> + u16 fs_dmask;
> + u16 codepage; /* Codepage for shortname conversions */

According to exFAT specification, section 7.7.3 FileName Field there is
no 8.3 shortname support with DOS/OEM codepage.

https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification#773-filename-field

Plus it looks like that this member codepage is only set and never
accessed in whole driver.

So it can be clean it up and removed?

> + /* minutes bias= UTC - local time. Eastern time zone: +300, */
> + /*Paris,Berlin: -60, Moscow: -180*/
> + int bias;
> + u16 allow_utime; /* permission for setting the [am]time */
> + unsigned quiet : 1, /* set = fake successful chmods and chowns */
> + showexec : 1, /* set = only set x bit for com/exe/bat */
> + sys_immutable : 1, /* set = system files are immutable */
> + utf8 : 1, /* Use of UTF-8 character set (Default) */
> + /* create escape sequences for unhandled Unicode */
> + unicode_xlate : 1, flush : 1, /* write things quickly */
> + tz_set : 1, /* Filesystem timestamps' offset set */
> + discard : 1 /* Issue discard requests on deletions */
> + ;
> +};

...

> diff --git a/fs/exfat/super.c b/fs/exfat/super.c
> new file mode 100644
> index ..0705dab3c3fc
> --- /dev/null
> +++ b/fs/exfat/super.c
...
> +enum {
> + Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask, Opt_allow_utime,
> + Opt_codepage, Opt_quiet, Opt_showexec, Opt_debug, Opt_immutable,
> + Opt_utf8_no, Opt_utf8_yes, Opt_uni_xl_no, Opt_uni_xl_yes, Opt_flush,
> + Opt_tz_utc, Opt_discard, Opt_nfs, Opt_bias, Opt_err,
> +};
> +
> +static const match_table_t fat_tokens = {
> + { Opt_uid, "uid=%u" },
> + { Opt_gid, "gid=%u" },
> + { Opt_umask, "umask=%o" },
> + { Opt_dmask, "dmask=%o" },
> + { Opt_fmask, "fmask=%o" },
> + { Opt_allow_utime, "allow_utime=%o" },
> + { Opt_codepage, "codepage=%u" },
> + { Opt_quiet, "quiet" },
> + { Opt_showexec, "showexec" },
> + { Opt_debug, "debug" },
> + { Opt_immutable, "sys_immutable" },
> + { Opt_flush, "flush" },
> + { Opt_tz_utc, "tz=UTC" },
> + { Opt_bias, "bias=%d" },
> + { Opt_discard, "discard" },
> + { Opt_utf8_no, "utf8=0" }, /* 0 or no or false */
> + { Opt_utf8_no, "utf8=no" },
> + { Opt_utf8_no, "utf8=false" },
> + { Opt_utf8_yes, "utf8=1" }, /* empty or 1 or yes or true */
> + { Opt_utf8_yes, "utf8=yes" },
> + { Opt_utf8_yes, "utf8=true" },
> + { Opt_utf8_yes, "utf8" },

There are lot of utf8 mount options. Are they really needed?

Would not it be better to use just one "iocharset" mount option like
other Unicode based filesystem have it (e.g. vfat, jfs, iso9660, udf or
ntfs)?

> + { Opt_uni_xl_no, "uni_xlate=0" }, /* 0 or no or false */
> + { Opt_uni_xl_no, "uni_xlate=no" },
> + { Opt_uni_xl_no, "uni_xlate=false" },
> + { Opt_uni_xl_yes, "uni_xlate=1" }, /* empty or 1 or yes or true */
> + { Opt_uni_xl_yes, "uni_xlate=yes" },
> + { Opt_uni_xl_yes, "uni_xlate=true" },
> + { Opt_uni_xl_yes, "uni_xlate" },
> + { Opt_err, NULL }
> +};

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: PGP signature


Re: [PATCH] fs/dax: Fix pmd vs pte conflict detection

2019-10-19 Thread Dan Williams
On Sat, Oct 19, 2019 at 4:09 PM Dan Williams  wrote:
>
> On Sat, Oct 19, 2019 at 1:50 PM Matthew Wilcox  wrote:
> >
> > On Sat, Oct 19, 2019 at 09:26:19AM -0700, Dan Williams wrote:
> > > Check for NULL entries before checking the entry order, otherwise NULL
> > > is misinterpreted as a present pte conflict. The 'order' check needs to
> > > happen before the locked check as an unlocked entry at the wrong order
> > > must fallback to lookup the correct order.
> > >
> > > Reported-by: Jeff Smits 
> > > Reported-by: Doug Nelson 
> > > Cc: 
> > > Fixes: 23c84eb78375 ("dax: Fix missed wakeup with PMD faults")
> > > Cc: Jan Kara 
> > > Cc: Matthew Wilcox (Oracle) 
> > > Signed-off-by: Dan Williams 
> > > ---
> > >  fs/dax.c |5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fs/dax.c b/fs/dax.c
> > > index a71881e77204..08160011d94c 100644
> > > --- a/fs/dax.c
> > > +++ b/fs/dax.c
> > > @@ -221,10 +221,11 @@ static void *get_unlocked_entry(struct xa_state 
> > > *xas, unsigned int order)
> > >
> > >   for (;;) {
> > >   entry = xas_find_conflict(xas);
> > > + if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
> > > + return entry;
> > >   if (dax_entry_order(entry) < order)
> > >   return XA_RETRY_ENTRY;
> > > - if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) ||
> > > - !dax_is_locked(entry))
> > > + if (!dax_is_locked(entry))
> > >   return entry;
> >
> > Yes, I think this works.  Should we also add:
> >
> >  static unsigned int dax_entry_order(void *entry)
> >  {
> > +   BUG_ON(!xa_is_value(entry));
> > if (xa_to_value(entry) & DAX_PMD)
> > return PMD_ORDER;
> > return 0;
> >  }
> >
> > which would have caught this logic error before it caused a performance
> > regression?
>
> Sounds good will add it to v2.

...except that there are multiple dax helpers that have the 'value'
entry assumption. I'd rather do all of them in a separate patch, or
none of them. It turns out that after this change all
dax_entry_order() invocations are now protected by a xa_is_value()
assert earlier in the calling function.


DNS Records for Teo En Ming Corporation (Office 365 Business Premium)

2019-10-19 Thread Turritopsis Dohrnii Teo En Ming
Subject: DNS Records for Teo En Ming Corporation (Office 365 Business Premium)

Good day from Singapore,

Office 365 Business Premium User: c...@teo-en-ming-corp.com

Windows Command Prompt nslookup:

teo-en-ming-corp.cominternet address = 184.168.221.46
teo-en-ming-corp.comnameserver = ns37.domaincontrol.com
teo-en-ming-corp.comnameserver = ns38.domaincontrol.com
teo-en-ming-corp.com
primary name server = ns37.domaincontrol.com
responsible mail addr = dns.jomax.net
serial  = 2019101803
refresh = 28800 (8 hours)
retry   = 7200 (2 hours)
expire  = 604800 (7 days)
default TTL = 600 (10 mins)
teo-en-ming-corp.comMX preference = 0, mail exchanger = 
teoenmingcorp-com0iei.mail.protection.outlook.com
teo-en-ming-corp.comtext =

"v=spf1 include:spf.protection.outlook.com -all"


-BEGIN EMAIL SIGNATURE-

The Gospel for all Targeted Individuals (TIs):

[The New York Times] Microwave Weapons Are Prime Suspect in Ills of
U.S. Embassy Workers

Link: 
https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html



Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic
Qualifications as at 14 Feb 2019 and refugee seeking attempts at the
United Nations Refugee Agency Bangkok (21 Mar 2017) and in Taiwan (5
Aug 2019):

[1] https://tdtemcerts.wordpress.com/

[2] https://tdtemcerts.blogspot.sg/

[3] https://www.scribd.com/user/270125049/Teo-En-Ming

-END EMAIL SIGNATURE-



Re: [PATCH] fs/dax: Fix pmd vs pte conflict detection

2019-10-19 Thread Dan Williams
On Sat, Oct 19, 2019 at 1:50 PM Matthew Wilcox  wrote:
>
> On Sat, Oct 19, 2019 at 09:26:19AM -0700, Dan Williams wrote:
> > Check for NULL entries before checking the entry order, otherwise NULL
> > is misinterpreted as a present pte conflict. The 'order' check needs to
> > happen before the locked check as an unlocked entry at the wrong order
> > must fallback to lookup the correct order.
> >
> > Reported-by: Jeff Smits 
> > Reported-by: Doug Nelson 
> > Cc: 
> > Fixes: 23c84eb78375 ("dax: Fix missed wakeup with PMD faults")
> > Cc: Jan Kara 
> > Cc: Matthew Wilcox (Oracle) 
> > Signed-off-by: Dan Williams 
> > ---
> >  fs/dax.c |5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/dax.c b/fs/dax.c
> > index a71881e77204..08160011d94c 100644
> > --- a/fs/dax.c
> > +++ b/fs/dax.c
> > @@ -221,10 +221,11 @@ static void *get_unlocked_entry(struct xa_state *xas, 
> > unsigned int order)
> >
> >   for (;;) {
> >   entry = xas_find_conflict(xas);
> > + if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
> > + return entry;
> >   if (dax_entry_order(entry) < order)
> >   return XA_RETRY_ENTRY;
> > - if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) ||
> > - !dax_is_locked(entry))
> > + if (!dax_is_locked(entry))
> >   return entry;
>
> Yes, I think this works.  Should we also add:
>
>  static unsigned int dax_entry_order(void *entry)
>  {
> +   BUG_ON(!xa_is_value(entry));
> if (xa_to_value(entry) & DAX_PMD)
> return PMD_ORDER;
> return 0;
>  }
>
> which would have caught this logic error before it caused a performance
> regression?

Sounds good will add it to v2.


Re: [PATCH] scripts: prune-kernel : prune kernels generalized way

2019-10-19 Thread Bhaskar Chowdhury

On 12:01 Sat 19 Oct 2019, J. Bruce Fields wrote:

On Sat, Oct 19, 2019 at 06:37:22PM +0530, Bhaskar Chowdhury wrote:

This patch will remove old kernel from the system in a selective way.


Please don't comment out code, just delete it, git's there to keep the
old code.


I thought it would be more appropriate to know user why it's written in
first place.So ,deleting is not a good idea!


There's some redundant code that should be inside a loop.

I don't want to make thing unnecessary complicated. Two more line
,scripts like this, doesn't harm at all. Easy for readability.


A little more detail in the changelog might be useful to those of us who
are lazy about reading bash script


More "unnecessary" words doesn't make the actual purpose of the scripts
more helpful. I believe the single line I put is good enough for the
people to capture the essence.

Looks like this just prompts for each individual delete?  Actually it
looks like it requires the user to enter the module path and kernel
version for each one which makes it not much more convenient use than a
bare "ls" and "rm".


No , it is not. You missed out the point. The user should be reminded
what they are upto and precisely what is needed. I don't care who the
user are. This is operation just can not be done airy-fairy way.

I personally use this in unattended scripts.  I mean, I don't really
care what we do with this, as I use my own copy of the script, so
whatever's useful to more people is fine.


Yes, you wrote it for your convenience, and that's great. I am thinking
of putting broader user base, so the verbosity and explicitness.

But if somebody does actually use it as-is, it'd be nicer to keep the
current behavior and add an option ("-i" or something) for the
interactive behavior.

Subtle thing is not my cup of tea, honestly lack of bent of mind always
prevent me to doing that kind of thing.What you mention a flag would be
great and pretty trivial . But the whole point of having this script to
be "usable" lies somewhere else.


--b.


Bruce, I am no way trying to demean or over riding your thought and
work. Just trying to make things work for everyone else. I just took it
your good work to extend it , certainly others could have done much
better if they stab on it,including you. No, doubt about it.

Thanks,
Bhaskar


Signed-off-by: Bhaskar Chowdhury 
---
 scripts/prune-kernel | 86 
 1 file changed, 72 insertions(+), 14 deletions(-)

diff --git a/scripts/prune-kernel b/scripts/prune-kernel
index e8aa940bc0a9..9d839a4e4539 100755
--- a/scripts/prune-kernel
+++ b/scripts/prune-kernel
@@ -5,17 +5,75 @@
 # again, /boot and /lib/modules/ eventually fill up.
 # Dumb script to purge that stuff:

-for f in "$@"
-do
-if rpm -qf "/lib/modules/$f" >/dev/null; then
-echo "keeping $f (installed from rpm)"
-elif [ $(uname -r) = "$f" ]; then
-echo "keeping $f (running kernel) "
-else
-echo "removing $f"
-rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
-rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
-rm -rf "/lib/modules/$f"
-new-kernel-pkg --remove $f
-fi
-done
+#for f in "$@"
+#do
+#   if rpm -qf "/lib/modules/$f" >/dev/null; then
+#echo "keeping $f (installed from rpm)"
+#elif [ $(uname -r) = "$f" ]; then
+#echo "keeping $f (running kernel) "
+#else
+#echo "removing $f"
+#rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
+#rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
+#rm -rf "/lib/modules/$f"
+#new-kernel-pkg --remove $f
+#   fi
+#done
+boot_dir=/boot
+modules_dir=/lib/modules
+
+function remove_old_kernel(){
+   cd $boot_dir
+   rm -If vmlinuz-$kernel_version System.map-$kernel_version 
config-$kernel_version
+}
+
+function remove_old_modules_dir(){
+   cd $modules_dir
+   rm -rf $modules_version
+}
+
+printf "\n\n Enlist the installed kernels \n\n"
+
+
+find $boot_dir -name "vmlinuz-*" -type f -exec ls -1 {} \;
+
+printf "\n\n\n Please give the kernel version to remove: %s"
+read kernel_version
+
+if [[ $kernel_version == "" ]];then
+   exit 1
+else
+   remove_old_kernel
+fi
+
+printf "\n\n Enlist the installed modules directory \n\n"
+
+find $modules_dir -maxdepth 0 -type d -exec ls -1 {} \;
+
+printf "\n\n Please give the full modules directory name to remove: %s"
+read modules_version
+
+if [[ $modules_version == "" ]];then
+   printf "You have forgotten to give the modules dir to remove"
+else
+   remove_old_modules_dir
+fi
+
+printf "\n\n\n Removed kernel version:$kernel_version and associated 
modules:$modules_version ...Done \n"
+
+while :
+ do
+printf "\n\n Do you want to remove another?[YN]: %s"
+read response
+   if [[ $response == "Y" ]];then
+printf "Please 

[PATCH] arm64: dts: qcom: msm8998: Fixup uart3 gpio config for bluetooth

2019-10-19 Thread Jeffrey Hugo
It turns out that the wcn3990 can float the gpio lines during bootup, etc
which will result in the uart core thinking there is incoming data.  This
results in the bluetooth stack getting garbage.  By applying a bias to
match what wcn3990 would drive, the issue is corrected.

Signed-off-by: Jeffrey Hugo 
---
 .../boot/dts/qcom/msm8998-clamshell.dtsi  | 31 +++
 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 31 +++
 2 files changed, 62 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
index ab24d415acc0..7e02cb6c8e07 100644
--- a/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
@@ -74,6 +74,37 @@
};
 };
 
+_uart3_on {
+   /delete-node/ config;
+
+   pinconf-cts {
+   /*
+* Configure a pull-down on 47 (CTS) to match the pull
+* of the Bluetooth module.
+*/
+   pins = "gpio47";
+   bias-pull-down;
+   };
+
+   pinconf-rts-tx {
+   /* We'll drive 48 (RFR) and 45 (TX), so no pull */
+   pins = "gpio45", "gpio48";
+   drive-strength = <2>;
+   bias-disable;
+   };
+
+   pinconf-rx {
+   /*
+* Configure a pull-up on 45 (RX). This is needed to
+* avoid garbage data when the TX pin of the Bluetooth
+* module is in tri-state (module powered off or not
+* driving the signal yet).
+*/
+   pins = "gpio45";
+   bias-pull-up;
+   };
+};
+
  {
status = "okay";
 
diff --git a/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
index 1a1836ed1052..17f51af5e999 100644
--- a/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
@@ -37,6 +37,37 @@
};
 };
 
+_uart3_on {
+   /delete-node/ config;
+
+   pinconf-cts {
+   /*
+* Configure a pull-down on 47 (CTS) to match the pull
+* of the Bluetooth module.
+*/
+   pins = "gpio47";
+   bias-pull-down;
+   };
+
+   pinconf-rts-tx {
+   /* We'll drive 48 (RFR) and 45 (TX), so no pull */
+   pins = "gpio45", "gpio48";
+   drive-strength = <2>;
+   bias-disable;
+   };
+
+   pinconf-rx {
+   /*
+* Configure a pull-up on 45 (RX). This is needed to
+* avoid garbage data when the TX pin of the Bluetooth
+* module is in tri-state (module powered off or not
+* driving the signal yet).
+*/
+   pins = "gpio45";
+   bias-pull-up;
+   };
+};
+
 _uart1 {
status = "okay";
 };
-- 
2.17.1



[PATCH] perf/x86/intel/pt: Fix base for single entry topa

2019-10-19 Thread Jiri Olsa
Jan reported failing ltp test for pt. It looks like the reason
is commit 38bb8d77d0b9, that did not keep the TOPA_SHIFT for
entry base, adding it back.

[1] 
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/tracing/pt_test/pt_test.c

Reported-by: Jan Stancek 
Fixes: 38bb8d77d0b9 ("perf/x86/intel/pt: Split ToPA metadata and page layout")
Signed-off-by: Jiri Olsa 
---
 arch/x86/events/intel/pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 74e80ed9c6c4..05e43d0f430b 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -627,7 +627,7 @@ static struct topa *topa_alloc(int cpu, gfp_t gfp)
 * link as the 2nd entry in the table
 */
if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) {
-   TOPA_ENTRY(>topa, 1)->base = page_to_phys(p);
+   TOPA_ENTRY(>topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT;
TOPA_ENTRY(>topa, 1)->end = 1;
}
 
-- 
2.21.0



Re: [RESEND RFC PATCH v3] rtc: Fix the AltCentury value on AMD/Hygon platform

2019-10-19 Thread Alexandre Belloni
On 15/10/2019 16:08:27+0800, Jinke Fan wrote:
> When using following operations:
> date -s "21190910 19:20:00"
> hwclock -w
> to change date from 2019 to 2119 for test, it will fail on Hygon
> Dhyana and AMD Zen CPUs, while the same operations run ok on Intel i7
> platform.
> 
> MC146818 driver use function mc146818_set_time() to set register
> RTC_FREQ_SELECT(RTC_REG_A)'s bit4-bit6 field which means divider stage
> reset value on Intel platform to 0x7.
> 
> While AMD/Hygon RTC_REG_A(0Ah)'s bit4 is defined as DV0 [Reference]:
> DV0 = 0 selects Bank 0, DV0 = 1 selects Bank 1. Bit5-bit6 is defined
> as reserved.
> 
> DV0 is set to 1, it will select Bank 1, which will disable AltCentury
> register(0x32) access. As UEFI pass acpi_gbl_FADT.century 0x32
> (AltCentury), the CMOS write will be failed on code:
> CMOS_WRITE(century, acpi_gbl_FADT.century).
> 
> Correct RTC_REG_A bank select bit(DV0) to 0 on AMD/Hygon CPUs, it will
> enable AltCentury(0x32) register writing and finally setup century as
> expected.
> 
> Test results on AMD/Hygon machine show that it works as expected.
> 
> Reference:
> https://www.amd.com/system/files/TechDocs/51192_Bolton_FCH_RRG.pdf
> section: 3.13 Real Time Clock (RTC)
> 
> Reported-by: kbuild test robot 
> Signed-off-by: Jinke Fan 
> ---
> 
> v2->v3:
>   - Make the changes only relevant to AMD/Hygon.
> 
> v1->v2:
>   - Fix the compile errors on sparc64/alpha platform.
> 
>  drivers/rtc/rtc-mc146818-lib.c | 11 ++-
>  include/linux/mc146818rtc.h|  6 ++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
> index 2ecd8752b088..70502881785d 100644
> --- a/drivers/rtc/rtc-mc146818-lib.c
> +++ b/drivers/rtc/rtc-mc146818-lib.c
> @@ -172,7 +172,16 @@ int mc146818_set_time(struct rtc_time *time)
>   save_control = CMOS_READ(RTC_CONTROL);
>   CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
>   save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
> - CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
> +
> +#ifdef CONFIG_X86
> + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
> + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
> + CMOS_WRITE((save_freq_select & (~RTC_DV0)), RTC_FREQ_SELECT);

This should probably use ~RTC_DIV_RESET2.

> + else
> + CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), 
> RTC_FREQ_SELECT);
> +#else
> + CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT);
> +#endif

Also, later you have:

CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);

This may write bit4 again which would make mc146818_get_time fail so you
probably want to update save_freq_select.

>  
>  #ifdef CONFIG_MACH_DECSTATION
>   CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
> diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
> index 0661af17a758..7066a7bced61 100644
> --- a/include/linux/mc146818rtc.h
> +++ b/include/linux/mc146818rtc.h
> @@ -86,6 +86,12 @@ struct cmos_rtc_board_info {
> /* 2 values for divider stage reset, others for "testing purposes only" */
>  #  define RTC_DIV_RESET1 0x60
>  #  define RTC_DIV_RESET2 0x70
> +
> +#ifdef CONFIG_X86
> +   /* DV0 = 0 selects Bank 0, DV0 = 1 selects Bank 1 on AMD/Hygon platform */
> +#  define RTC_DV00x10
> +#endif
> +
>/* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz 
> */
>  # define RTC_RATE_SELECT 0x0F
>  
> -- 
> 2.17.1
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


RE:PERSONAL LETTER FROM MRS RASHIA AMIRA

2019-10-19 Thread Mr Barrister Hans Erich
Greetings

My name is Barrister Hans Erich.

I have a client who is interested to invest in your country, she is a well 
known politician in her country and deserve a lucrative investment partnership 
with you outside her country without any delay   Please can you manage such 
investment please Kindly reply for further details.

Your full names -


Your urgent response will be appreciated

Thank you and God bless you.

Barrister Hans Erich

Yours sincerely,
Barrister Hans Erich


Re: [musl] [PATCH] arm64: uapi: Fix user space compile with musl libc

2019-10-19 Thread Hauke Mehrtens
On 10/19/19 10:29 PM, Rich Felker wrote:
> On Sat, Oct 19, 2019 at 10:17:17PM +0200, Hauke Mehrtens wrote:
>> musl libc also defines the structures in their arch/aarch64/bits/signal.h
>> header file. Some applications like strace and gdb include both of them
>> and then the structure definitions are clashing and the build of these
>> user space applications fails.
>>
>> This patch allows a libc to define a constant which tells the kernel
>> header file that the libc already defined these structures and that they
>> should not be defined by the kernel uapi header files any more to
>> prevent clashes. This is done in a similar way as it is already done for
>> other header files.
>>
>> When this patch was accepted into the kernel I will also update musl
>> libc to define these constants.
> 
> I don't entirely object to this outright, but I'd really like to avoid
> adding further __UAPI_DEF_* suppressions. AIUI asm/sigcontext.h is not
> intended to be used with userspace headers. Is it still being
> indirectly included via some other uapi headers? (I thought that was
> fixed..) If so, that should really be fixed first, and then we can see
> if there's still motivation for the patch here.
> 
> Rich
> 
Hi Rich,

I did some more research and it looks like this patch also fixes my
problem with strace and gdb compile:
https://git.kernel.org/linus/9966a05c7b80f075f2bc7e48dbb108d3f2927234

I will backport it in OpenWrt to kernel 4.19.

Please drop my patch.

It would be nice if it could go into the stable 4.19 kernel.

Hauke


[PATCH] mm/vmstat: do not use size of vmstat_text as count of /proc/vmstat items

2019-10-19 Thread Konstantin Khlebnikov
Strings from vmstat_text[] will be used for printing memory cgroup
statistics which exists even if CONFIG_VM_EVENT_COUNTERS=n.

This should be applied before patch "mm/memcontrol: use vmstat names
for printing statistics".

Signed-off-by: Konstantin Khlebnikov 
Link: 
https://lore.kernel.org/linux-mm/cd1c42ae-281f-c8a8-70ac-1d01d417b...@infradead.org/T/#u
---
 mm/vmstat.c |   26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 590aeca27cab..13e36da70f3c 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1638,25 +1638,23 @@ static const struct seq_operations zoneinfo_op = {
.show   = zoneinfo_show,
 };
 
+#define NR_VMSTAT_ITEMS (NR_VM_ZONE_STAT_ITEMS + \
+NR_VM_NUMA_STAT_ITEMS + \
+NR_VM_NODE_STAT_ITEMS + \
+NR_VM_WRITEBACK_STAT_ITEMS + \
+(IS_ENABLED(CONFIG_VM_EVENT_COUNTERS) ? \
+ NR_VM_EVENT_ITEMS : 0))
+
 static void *vmstat_start(struct seq_file *m, loff_t *pos)
 {
unsigned long *v;
-   int i, stat_items_size;
+   int i;
 
-   if (*pos >= ARRAY_SIZE(vmstat_text))
+   if (*pos >= NR_VMSTAT_ITEMS)
return NULL;
-   stat_items_size = NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) +
- NR_VM_NUMA_STAT_ITEMS * sizeof(unsigned long) +
- NR_VM_NODE_STAT_ITEMS * sizeof(unsigned long) +
- NR_VM_WRITEBACK_STAT_ITEMS * sizeof(unsigned long);
-
-#ifdef CONFIG_VM_EVENT_COUNTERS
-   stat_items_size += sizeof(struct vm_event_state);
-#endif
 
-   BUILD_BUG_ON(stat_items_size !=
-ARRAY_SIZE(vmstat_text) * sizeof(unsigned long));
-   v = kmalloc(stat_items_size, GFP_KERNEL);
+   BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) < NR_VMSTAT_ITEMS);
+   v = kmalloc_array(NR_VMSTAT_ITEMS, sizeof(unsigned long), GFP_KERNEL);
m->private = v;
if (!v)
return ERR_PTR(-ENOMEM);
@@ -1689,7 +1687,7 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
 static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)
 {
(*pos)++;
-   if (*pos >= ARRAY_SIZE(vmstat_text))
+   if (*pos >= NR_VMSTAT_ITEMS)
return NULL;
return (unsigned long *)m->private + *pos;
 }



Re: [dax] 23c84eb783: fio.write_bw_MBps -61.6% regression

2019-10-19 Thread Matthew Wilcox
On Fri, Oct 18, 2019 at 04:12:03PM -0700, Dan Williams wrote:
> I've got several reports of v5.3 performance regressions tracking back
> to this change. I instrumented the ndctl "dax.sh" unit test to
> validate that it is getting huge page faults and it always falls back
> to 4K starting with these commits. It looks like the xa_is_internal()
> returns true for any DAX_LOCKED entry.

That's not true today, but I do intend to make it true at some point.
I think we can reclaim three bits from the encoding of a DAX entry,
allowing us to support three more physical bits on a 32-bit system.
Clearly that hasn't been a focus so far.

The plan is ...

DAX_LOCKED -> XA_LOCK_ENTRY (xa_mk_internal(something))

DAX_ZERO_PAGE -> XA_ZERO_ENTRY

DAX_EMPTY goes away.  It's only used in combination with DAX_LOCKED, and
it won't be necessary once DAX_LOCKED has become XA_LOCK_ENTRY.

DAX_PMD essentially stays, but we can encode arbitrary orders using a single
bit rather than just PTE vs PMD.

We may need to encode a size in DAX_LOCKED, or we may be able to get that
information from the XArray.  Anyway, this transformation is about tenth
on my todo list right now, so if someone else wants to take this on ...


Re: [PATCH] net: fix sk_page_frag() recursion from memory reclaim

2019-10-19 Thread Eric Dumazet



On 10/19/19 2:18 PM, Tejun Heo wrote:

> Whatever works is fine by me.  gfpflags_allow_blocking() is clearer
> than testing __GFP_DIRECT_RECLAIM directly tho.  Maybe a better way is
> introducing a new gfpflags_ helper?

Sounds good to me !



Re: [PATCH] net: fix sk_page_frag() recursion from memory reclaim

2019-10-19 Thread Tejun Heo
Hello,

On Sat, Oct 19, 2019 at 11:15:28AM -0700, Eric Dumazet wrote:
> It seems compiler generates better code with :
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 
> ab905c4b1f0efd42ebdcae333b3f0a2c7c1b2248..56de6ac99f0952bd0bc003353c094ce3a5a852f4
>  100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2238,7 +2238,8 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, 
> int size, gfp_t gfp,
>   */
>  static inline struct page_frag *sk_page_frag(struct sock *sk)
>  {
> -   if (gfpflags_allow_blocking(sk->sk_allocation))
> +   if (likely((sk->sk_allocation & (__GFP_DIRECT_RECLAIM | 
> __GFP_MEMALLOC)) ==
> +   __GFP_DIRECT_RECLAIM))
> return >task_frag;
>  
> return >sk_frag;
> 
> 
> WDYT ?

Whatever works is fine by me.  gfpflags_allow_blocking() is clearer
than testing __GFP_DIRECT_RECLAIM directly tho.  Maybe a better way is
introducing a new gfpflags_ helper?

Thanks.

-- 
tejun


Re: [PATCH] Bluetooth: hci_qca: Add delay for wcn3990 stability

2019-10-19 Thread Marcel Holtmann
Hi Jeffrey,

> On the msm8998 mtp, the response to the baudrate change command is 
> never
> received.  On the Lenovo Miix 630, the response to the baudrate change
> command is corrupted - "Frame reassembly failed (-84)".
> 
> Adding a 50ms delay before re-enabling flow to receive the baudrate 
> change
> command response from the wcn3990 addesses both issues, and allows
> bluetooth to become functional.
 
 From my earlier debugging on sdm845 I don't think this is what happens.
 The problem is that the wcn3990 sends the response to the baudrate 
 change
 command using the new baudrate, while the UART on the SoC still 
 operates
 with the prior speed (for details see 2faa3f15fa2f ("Bluetooth: 
 hci_qca:
 wcn3990: Drop baudrate change vendor event"))
 
 IIRC the 50ms delay causes the HCI core to discard the received data,
 which is why the "Frame reassembly failed" message disappears, not
 because the response was received. In theory commit 78e8fa2972e5
 ("Bluetooth: hci_qca: Deassert RTS while baudrate change command")
 should have fixed those messages, do you know if CTS/RTS are connected
 on the Bluetooth UART of the Lenovo Miix 630?
>>> 
>>> I was testing with 5.4-rc1 which contains the indicated RTS fix.
>>> 
>>> Yes, CTS/RTS are connected on the Lenovo Miix 630.
>>> 
>>> I added debug statements which indicated that data was received,
>>> however it was corrupt, and the packet type did not match what was
>>> expected, hence the frame reassembly errors.
>> 
>> Do you know if any data is received during the delay? In theory that
>> shouldn't be the case since RTS is deasserted, just double-checking.
> 
> I don't think so, but I've run so many tests, I'm not 100% positive.
> Let me go double check and get back to you.
>>> 
>>> Apparently I'd be wrong.  I instrumented the uart driver so that it
>>> would indicate when it got data from the bam.  Apparently its getting
>>> the data during the 50ms sleep, approximately right after the host
>>> baud rate is set.
>> 
>> Good finding!
>> 
> 
>> 
>> What happens if you add a longer delay (e.g. 1s) before/after setting
>> the host baudrate?
> 
> Hmm, not exactly sure.  I will test.
>>> 
>>> Adding a 1 second delay before setting the host baud rate did not
>>> change the observed results - still received the data during the 50ms
>>> sleep after the host baud rate set operation.
>>> Adding a 1 second delay after setting the host baud rate did not
>>> change when the data was received.
>> 
>> Thanks for testing!
>> 
> 
>> 
>>> In response to this patch, Balakrishna pointed me to a bug report
>>> which indicated that some of the UART GPIO lines need to have a bias
>>> applied to prevent errant data from floating lines -
>>> 
>>> https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1391888
>> 
>> Yeah, that was another source of frame reassembly errors that we were
>> seeing on SDM845.
>> 
>> Balakrishna, please post these kind of replies on-list, so that
>> everybody can benefit from possible solutions or contribute to the
>> discussion.
>> 
>>> It turns out this fix was never applied to msm8998.  Applying the fix
>>> does cause the the frame reassembly errors to go away, however then
>>> the host SoC never receives the baud rate change response (I increased
>>> the timeout from 2faa3f15fa2f ("Bluetooth: hci_qca: wcn3990: Drop
>>> baudrate change vendor event") to 5 seconds).  As of now, this patch
>>> is still required.
>> 
>> Interesting.
>> 
>> FTR, this is the full UART pin configuration for cheza (SDM845):
>> 
>> _uart6_default {
>>/* Change pinmux to all 4 pins since CTS and RTS are connected */
>>pinmux {
>>pins = "gpio45", "gpio46",
>>   "gpio47", "gpio48";
>>};
>> 
>>pinconf-cts {
>>/*
>> * Configure a pull-down on 45 (CTS) to match the pull of
>> * the Bluetooth module.
>> */
>>pins = "gpio45";
>>bias-pull-down;
>>};
>> 
>>pinconf-rts-tx {
>>/* We'll drive 46 (RTS) and 47 (TX), so no pull */
>>pins = "gpio46", "gpio47";
>>drive-strength = <2>;
>>bias-disable;
>>};
>> 
>>pinconf-rx {
>>/*
>> * Configure a pull-up on 48 (RX). This is needed to avoid
>> * garbage data when the TX pin of the Bluetooth module is
>> * in tri-state 

Re: [PATCH 2/6] ARM: ep93xx: enable SPARSE_IRQ

2019-10-19 Thread Alexander Sverdlin
Hi!

On Sat, 19 Oct 2019 22:44:18 +0200
Arnd Bergmann  wrote:

> > > > # cat /proc/interrupts
> > > >CPU0
> > > >  39:146   VIC   7 Edge  eth0
> > > >  51: 162161   VIC  19 Edge  ep93xx timer
> > > >  52:139   VIC  20 Edge  uart-pl010
> > > >  53:  4   VIC  21 Edge  ep93xx-spi
> > > >  60:  0   VIC  28 Edge  ep93xx-i2s
> > > > Err:  0
> > >
> > > I guess that is partial success: some irqs do work ;-)
> >
> > Yep, VIC1 is working, while VIC0 is not.
> >
> > > The two interrupts that did not get registered are for the
> > > dmaengine driver, and that makes sense given the error
> > > message about the DMA not working. No idea how
> > > that would be a result of the irq changes though.
> >
> > Seems, that it has exposed some incompatibilities of
> > starting IRQ 0 in EP93xx platform fir VIC0 and VIC code
> > itself, which assumes 0 means "auto assignment" (refer
> > to vic_init()).
> 
> Ah, that makes sense. so all interrupt numbers need to
> be shifted by a fixed number (e.g. 1) like we did for
> other platforms (see attachment).

Yes, the below patch resolved both GPIO and DMA issues.
Previous patch (selecting IRQ_DOMAIN_HIERARCHY) is not
required.

If you re-spin all 3 ep93xx-relevant patches together, you can put my
Tested-by: Alexander Sverdlin 
on them.

> diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
> index 6fb19a393fd2..f0a71d4e076f 100644
> --- a/arch/arm/mach-ep93xx/core.c
> +++ b/arch/arm/mach-ep93xx/core.c
> @@ -47,6 +47,7 @@
>  #include 
>  
>  #include "soc.h"
> +#include "irqs.h"
>  
>  /*
>   * Static I/O mappings that are needed for all EP93xx platforms
> @@ -75,8 +76,8 @@ void __init ep93xx_map_io(void)
>   */
>  void __init ep93xx_init_irq(void)
>  {
> - vic_init(EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK, 0);
> - vic_init(EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK, 0);
> + vic_init(EP93XX_VIC1_BASE, IRQ_EP93XX_VIC0, EP93XX_VIC1_VALID_IRQ_MASK, 
> 0);
> + vic_init(EP93XX_VIC2_BASE, IRQ_EP93XX_VIC1, EP93XX_VIC2_VALID_IRQ_MASK, 
> 0);
>  }
>  
>  
> diff --git a/arch/arm/mach-ep93xx/irqs.h b/arch/arm/mach-ep93xx/irqs.h
> index 3ffdb3a2f3e4..353201b90c66 100644
> --- a/arch/arm/mach-ep93xx/irqs.h
> +++ b/arch/arm/mach-ep93xx/irqs.h
> @@ -2,69 +2,73 @@
>  #ifndef __ASM_ARCH_IRQS_H
>  #define __ASM_ARCH_IRQS_H
>  
> -#define IRQ_EP93XX_COMMRX2
> -#define IRQ_EP93XX_COMMTX3
> -#define IRQ_EP93XX_TIMER14
> -#define IRQ_EP93XX_TIMER25
> -#define IRQ_EP93XX_AACINTR   6
> -#define IRQ_EP93XX_DMAM2P0   7
> -#define IRQ_EP93XX_DMAM2P1   8
> -#define IRQ_EP93XX_DMAM2P2   9
> -#define IRQ_EP93XX_DMAM2P3   10
> -#define IRQ_EP93XX_DMAM2P4   11
> -#define IRQ_EP93XX_DMAM2P5   12
> -#define IRQ_EP93XX_DMAM2P6   13
> -#define IRQ_EP93XX_DMAM2P7   14
> -#define IRQ_EP93XX_DMAM2P8   15
> -#define IRQ_EP93XX_DMAM2P9   16
> -#define IRQ_EP93XX_DMAM2M0   17
> -#define IRQ_EP93XX_DMAM2M1   18
> -#define IRQ_EP93XX_GPIO0MUX  19
> -#define IRQ_EP93XX_GPIO1MUX  20
> -#define IRQ_EP93XX_GPIO2MUX  21
> -#define IRQ_EP93XX_GPIO3MUX  22
> -#define IRQ_EP93XX_UART1RX   23
> -#define IRQ_EP93XX_UART1TX   24
> -#define IRQ_EP93XX_UART2RX   25
> -#define IRQ_EP93XX_UART2TX   26
> -#define IRQ_EP93XX_UART3RX   27
> -#define IRQ_EP93XX_UART3TX   28
> -#define IRQ_EP93XX_KEY   29
> -#define IRQ_EP93XX_TOUCH 30
> +#define IRQ_EP93XX_VIC0  1
> +
> +#define IRQ_EP93XX_COMMRX(IRQ_EP93XX_VIC0 + 2)
> +#define IRQ_EP93XX_COMMTX(IRQ_EP93XX_VIC0 + 3)
> +#define IRQ_EP93XX_TIMER1(IRQ_EP93XX_VIC0 + 4)
> +#define IRQ_EP93XX_TIMER2(IRQ_EP93XX_VIC0 + 5)
> +#define IRQ_EP93XX_AACINTR   (IRQ_EP93XX_VIC0 + 6)
> +#define IRQ_EP93XX_DMAM2P0   (IRQ_EP93XX_VIC0 + 7)
> +#define IRQ_EP93XX_DMAM2P1   (IRQ_EP93XX_VIC0 + 8)
> +#define IRQ_EP93XX_DMAM2P2   (IRQ_EP93XX_VIC0 + 9)
> +#define IRQ_EP93XX_DMAM2P3   (IRQ_EP93XX_VIC0 + 10)
> +#define IRQ_EP93XX_DMAM2P4   (IRQ_EP93XX_VIC0 + 11)
> +#define IRQ_EP93XX_DMAM2P5   (IRQ_EP93XX_VIC0 + 12)
> +#define IRQ_EP93XX_DMAM2P6   (IRQ_EP93XX_VIC0 + 13)
> +#define IRQ_EP93XX_DMAM2P7   (IRQ_EP93XX_VIC0 + 14)
> +#define IRQ_EP93XX_DMAM2P8   (IRQ_EP93XX_VIC0 + 15)
> +#define IRQ_EP93XX_DMAM2P9   (IRQ_EP93XX_VIC0 + 16)
> +#define IRQ_EP93XX_DMAM2M0   (IRQ_EP93XX_VIC0 + 17)
> +#define IRQ_EP93XX_DMAM2M1   (IRQ_EP93XX_VIC0 + 18)
> +#define IRQ_EP93XX_GPIO0MUX  (IRQ_EP93XX_VIC0 + 19)
> +#define 

Re: [PATCH v2] rtc: rv3028: add clkout support

2019-10-19 Thread Alexandre Belloni
On 18/10/2019 12:04:25+0200, Parthiban Nallathambi wrote:
> rv3028 provides clkout (enabled by default). Add clkout
> to clock framework source and control from device tree for
> variable frequency with enable and disable functionality.
> 
> Signed-off-by: Parthiban Nallathambi 
> ---
> 
> Notes:
> Notes:
> Changlog in v2:
>   - Removed disabling the clock. clk core will disable it
>   when no consumer is detected
>   - Remove multiple write to CLKF
> 
>  drivers/rtc/rtc-rv3028.c | 146 +++
>  1 file changed, 146 insertions(+)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


[PATCH] tty: serial: msm_serial: Fix flow control

2019-10-19 Thread Jeffrey Hugo
hci_qca interfaces to the wcn3990 via a uart_dm on the msm8998 mtp and
Lenovo Miix 630 laptop.  As part of initializing the wcn3990, hci_qca
disables flow, configures the uart baudrate, and then reenables flow - at
which point an event is expected to be received over the uart from the
wcn3990.  It is observed that this event comes after the baudrate change
but before hci_qca re-enables flow. This is unexpected, and is a result of
msm_reset() being broken.

According to the uart_dm hardware documentation, it is recommended that
automatic hardware flow control be enabled by setting RX_RDY_CTL.  Auto
hw flow control will manage RFR based on the configured watermark.  When
there is space to receive data, the hw will assert RFR.  When the watermark
is hit, the hw will de-assert RFR.

The hardware documentation indicates that RFR can me manually managed via
CR when RX_RDY_CTL is not set.  SET_RFR asserts RFR, and RESET_RFR
de-asserts RFR.

msm_reset() is broken because after resetting the hardware, it
unconditionally asserts RFR via SET_RFR.  This enables flow regardless of
the current configuration, and would undo a previous flow disable
operation.  It should instead de-assert RFR via RESET_RFR to block flow
until the hardware is reconfigured.  msm_serial should rely on the client
to specify that flow should be enabled, either via mctrl() or the termios
structure, and only assert RFR in response to those triggers.

Fixes: 04896a77a97b ("msm_serial: serial driver for MSM7K onboard serial 
peripheral.")
Signed-off-by: Jeffrey Hugo 
---
 drivers/tty/serial/msm_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 3657a24913fc..aedabf7646f1 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -987,7 +987,7 @@ static void msm_reset(struct uart_port *port)
msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR);
msm_write(port, UART_CR_CMD_RESET_BREAK_INT, UART_CR);
msm_write(port, UART_CR_CMD_RESET_CTS, UART_CR);
-   msm_write(port, UART_CR_CMD_SET_RFR, UART_CR);
+   msm_write(port, UART_CR_CMD_RESET_RFR, UART_CR);
 
/* Disable DM modes */
if (msm_port->is_uartdm)
-- 
2.17.1



[PATCH] rtc: introduce lock helpers

2019-10-19 Thread Alexandre Belloni
Introduce rtc_lock and rtc_unlock to shorten the code when locking and
unlocking ops_lock from drivers.

Signed-off-by: Alexandre Belloni 
---
 include/linux/rtc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index e86a9f307b82..4e9d3c71addb 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -159,6 +159,9 @@ struct rtc_device {
 };
 #define to_rtc_device(d) container_of(d, struct rtc_device, dev)
 
+#define rtc_lock(d) mutex_lock(>ops_lock)
+#define rtc_unlock(d) mutex_unlock(>ops_lock)
+
 /* useful timestamps */
 #define RTC_TIMESTAMP_BEGIN_   -62167219200ULL /* -01-01 00:00:00 
*/
 #define RTC_TIMESTAMP_BEGIN_1900   -2208988800LL /* 1900-01-01 00:00:00 */
-- 
2.21.0



[PATCH 2/9] rtc: ds1343: remove dead code

2019-10-19 Thread Alexandre Belloni
RTC_SET_CHARGE doesn't exist, the ioctl code is never used.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 21 -
 1 file changed, 21 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index b45d1b8fd631..9d7d571e722b 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -87,26 +87,6 @@ struct ds1343_priv {
int alarm_mday;
 };
 
-static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long 
arg)
-{
-   switch (cmd) {
-#ifdef RTC_SET_CHARGE
-   case RTC_SET_CHARGE:
-   {
-   int val;
-
-   if (copy_from_user(, (int __user *)arg, sizeof(int)))
-   return -EFAULT;
-
-   return regmap_write(priv->map, DS1343_TRICKLE_REG, val);
-   }
-   break;
-#endif
-   }
-
-   return -ENOIOCTLCMD;
-}
-
 static ssize_t ds1343_show_glitchfilter(struct device *dev,
struct device_attribute *attr, char *buf)
 {
@@ -452,7 +432,6 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
 }
 
 static const struct rtc_class_ops ds1343_rtc_ops = {
-   .ioctl  = ds1343_ioctl,
.read_time  = ds1343_read_time,
.set_time   = ds1343_set_time,
.read_alarm = ds1343_read_alarm,
-- 
2.21.0



[PATCH 6/9] rtc: ds1343: check regmap_read return value

2019-10-19 Thread Alexandre Belloni
Check whether regmap_read fails before continuing in the sysfs .show
callbacks.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 7532a2e8407e..c96a505972e6 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -92,8 +92,11 @@ static ssize_t ds1343_show_glitchfilter(struct device *dev,
 {
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int glitch_filt_status, data;
+   int res;
 
-   regmap_read(priv->map, DS1343_CONTROL_REG, );
+   res = regmap_read(priv->map, DS1343_CONTROL_REG, );
+   if (res)
+   return res;
 
glitch_filt_status = !!(data & DS1343_EGFIL);
 
@@ -147,10 +150,12 @@ static ssize_t ds1343_show_tricklecharger(struct device 
*dev,
struct device_attribute *attr, char *buf)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
-   int data;
+   int res, data;
char *diodes = "disabled", *resistors = " ";
 
-   regmap_read(priv->map, DS1343_TRICKLE_REG, );
+   res = regmap_read(priv->map, DS1343_TRICKLE_REG, );
+   if (res)
+   return res;
 
if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) {
switch (data & 0x0c) {
-- 
2.21.0



Re: [PATCH] fs/dax: Fix pmd vs pte conflict detection

2019-10-19 Thread Matthew Wilcox
On Sat, Oct 19, 2019 at 09:26:19AM -0700, Dan Williams wrote:
> Check for NULL entries before checking the entry order, otherwise NULL
> is misinterpreted as a present pte conflict. The 'order' check needs to
> happen before the locked check as an unlocked entry at the wrong order
> must fallback to lookup the correct order.
> 
> Reported-by: Jeff Smits 
> Reported-by: Doug Nelson 
> Cc: 
> Fixes: 23c84eb78375 ("dax: Fix missed wakeup with PMD faults")
> Cc: Jan Kara 
> Cc: Matthew Wilcox (Oracle) 
> Signed-off-by: Dan Williams 
> ---
>  fs/dax.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index a71881e77204..08160011d94c 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -221,10 +221,11 @@ static void *get_unlocked_entry(struct xa_state *xas, 
> unsigned int order)
>  
>   for (;;) {
>   entry = xas_find_conflict(xas);
> + if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
> + return entry;
>   if (dax_entry_order(entry) < order)
>   return XA_RETRY_ENTRY;
> - if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) ||
> - !dax_is_locked(entry))
> + if (!dax_is_locked(entry))
>   return entry;

Yes, I think this works.  Should we also add:

 static unsigned int dax_entry_order(void *entry)
 {
+   BUG_ON(!xa_is_value(entry));
if (xa_to_value(entry) & DAX_PMD)
return PMD_ORDER;
return 0;
 }

which would have caught this logic error before it caused a performance
regression?


[PATCH 3/9] rtc: ds1343: use burst write to set time

2019-10-19 Thread Alexandre Belloni
To avoid possible race condition, use regmap_bulk_write to write all the
date/time registers at once instead of sequentially.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 52 ++--
 1 file changed, 12 insertions(+), 40 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 9d7d571e722b..8a4f1fbb57fd 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -236,46 +236,18 @@ static int ds1343_read_time(struct device *dev, struct 
rtc_time *dt)
 static int ds1343_set_time(struct device *dev, struct rtc_time *dt)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   int res;
-
-   res = regmap_write(priv->map, DS1343_SECONDS_REG,
-   bin2bcd(dt->tm_sec));
-   if (res)
-   return res;
-
-   res = regmap_write(priv->map, DS1343_MINUTES_REG,
-   bin2bcd(dt->tm_min));
-   if (res)
-   return res;
-
-   res = regmap_write(priv->map, DS1343_HOURS_REG,
-   bin2bcd(dt->tm_hour) & 0x3F);
-   if (res)
-   return res;
-
-   res = regmap_write(priv->map, DS1343_DAY_REG,
-   bin2bcd(dt->tm_wday + 1));
-   if (res)
-   return res;
-
-   res = regmap_write(priv->map, DS1343_DATE_REG,
-   bin2bcd(dt->tm_mday));
-   if (res)
-   return res;
-
-   res = regmap_write(priv->map, DS1343_MONTH_REG,
-   bin2bcd(dt->tm_mon + 1));
-   if (res)
-   return res;
-
-   dt->tm_year %= 100;
-
-   res = regmap_write(priv->map, DS1343_YEAR_REG,
-   bin2bcd(dt->tm_year));
-   if (res)
-   return res;
-
-   return 0;
+   u8 buf[7];
+
+   buf[0] = bin2bcd(dt->tm_sec);
+   buf[1] = bin2bcd(dt->tm_min);
+   buf[2] = bin2bcd(dt->tm_hour) & 0x3F;
+   buf[3] = bin2bcd(dt->tm_wday + 1);
+   buf[4] = bin2bcd(dt->tm_mday);
+   buf[5] = bin2bcd(dt->tm_mon + 1);
+   buf[6] = bin2bcd(dt->tm_year - 100);
+
+   return regmap_bulk_write(priv->map, DS1343_SECONDS_REG,
+buf, sizeof(buf));
 }
 
 static int ds1343_update_alarm(struct device *dev)
-- 
2.21.0



[PATCH 1/9] rtc: ds1343: set range

2019-10-19 Thread Alexandre Belloni
This is a standard BCD rtc with a useless century bit (no leap year
correction after 2099).

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index fa6de31d5793..b45d1b8fd631 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -520,6 +520,8 @@ static int ds1343_probe(struct spi_device *spi)
 
priv->rtc->nvram_old_abi = true;
priv->rtc->ops = _rtc_ops;
+   priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
+   priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
 
res = rtc_register_device(priv->rtc);
if (res)
-- 
2.21.0



[PATCH 4/9] rtc: ds1343: use rtc_add_group

2019-10-19 Thread Alexandre Belloni
Use rtc_add_group to add the sysfs group in a race free manner.
This has the side effect of moving the files to their proper location.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 47 ++--
 1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 8a4f1fbb57fd..ec8d1e82d7ac 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -90,7 +90,7 @@ struct ds1343_priv {
 static ssize_t ds1343_show_glitchfilter(struct device *dev,
struct device_attribute *attr, char *buf)
 {
-   struct ds1343_priv *priv = dev_get_drvdata(dev);
+   struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int glitch_filt_status, data;
 
regmap_read(priv->map, DS1343_CONTROL_REG, );
@@ -107,7 +107,7 @@ static ssize_t ds1343_store_glitchfilter(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct ds1343_priv *priv = dev_get_drvdata(dev);
+   struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int data;
 
regmap_read(priv->map, DS1343_CONTROL_REG, );
@@ -148,7 +148,7 @@ static int ds1343_nvram_read(void *priv, unsigned int off, 
void *val,
 static ssize_t ds1343_show_tricklecharger(struct device *dev,
struct device_attribute *attr, char *buf)
 {
-   struct ds1343_priv *priv = dev_get_drvdata(dev);
+   struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int data;
char *diodes = "disabled", *resistors = " ";
 
@@ -189,28 +189,15 @@ static ssize_t ds1343_show_tricklecharger(struct device 
*dev,
 
 static DEVICE_ATTR(trickle_charger, S_IRUGO, ds1343_show_tricklecharger, NULL);
 
-static int ds1343_sysfs_register(struct device *dev)
-{
-   int err;
-
-   err = device_create_file(dev, _attr_glitch_filter);
-   if (err)
-   return err;
-
-   err = device_create_file(dev, _attr_trickle_charger);
-   if (!err)
-   return 0;
-
-   device_remove_file(dev, _attr_glitch_filter);
-
-   return err;
-}
+static struct attribute *ds1343_attrs[] = {
+   _attr_glitch_filter.attr,
+   _attr_trickle_charger.attr,
+   NULL
+};
 
-static void ds1343_sysfs_unregister(struct device *dev)
-{
-   device_remove_file(dev, _attr_glitch_filter);
-   device_remove_file(dev, _attr_trickle_charger);
-}
+static const struct attribute_group ds1343_attr_group = {
+   .attrs  = ds1343_attrs,
+};
 
 static int ds1343_read_time(struct device *dev, struct rtc_time *dt)
 {
@@ -474,6 +461,11 @@ static int ds1343_probe(struct spi_device *spi)
priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
 
+   res = rtc_add_group(priv->rtc, _attr_group);
+   if (res)
+   dev_err(>dev,
+   "unable to create sysfs entries for rtc ds1343\n");
+
res = rtc_register_device(priv->rtc);
if (res)
return res;
@@ -497,11 +489,6 @@ static int ds1343_probe(struct spi_device *spi)
}
}
 
-   res = ds1343_sysfs_register(>dev);
-   if (res)
-   dev_err(>dev,
-   "unable to create sysfs entries for rtc ds1343\n");
-
return 0;
 }
 
@@ -521,8 +508,6 @@ static int ds1343_remove(struct spi_device *spi)
 
spi_set_drvdata(spi, NULL);
 
-   ds1343_sysfs_unregister(>dev);
-
return 0;
 }
 
-- 
2.21.0



[PATCH 7/9] rtc: ds1343: remove unnecessary mutex

2019-10-19 Thread Alexandre Belloni
Use rtc_lock and rtc_unlock to lock the rtc from the interrupt handler.
This removes the need for a driver specific lock.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 36 +++-
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index c96a505972e6..867187325d41 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -78,7 +78,6 @@ struct ds1343_priv {
struct spi_device *spi;
struct rtc_device *rtc;
struct regmap *map;
-   struct mutex mutex;
unsigned int irqen;
int irq;
int alarm_sec;
@@ -290,17 +289,15 @@ static int ds1343_update_alarm(struct device *dev)
 static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   int res = 0;
+   int res;
unsigned int stat;
 
if (priv->irq <= 0)
return -EINVAL;
 
-   mutex_lock(>mutex);
-
res = regmap_read(priv->map, DS1343_STATUS_REG, );
if (res)
-   goto out;
+   return res;
 
alarm->enabled = !!(priv->irqen & RTC_AF);
alarm->pending = !!(stat & DS1343_IRQF0);
@@ -310,21 +307,16 @@ static int ds1343_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
alarm->time.tm_hour = priv->alarm_hour < 0 ? 0 : priv->alarm_hour;
alarm->time.tm_mday = priv->alarm_mday < 0 ? 0 : priv->alarm_mday;
 
-out:
-   mutex_unlock(>mutex);
-   return res;
+   return 0;
 }
 
 static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   int res = 0;
 
if (priv->irq <= 0)
return -EINVAL;
 
-   mutex_lock(>mutex);
-
priv->alarm_sec = alarm->time.tm_sec;
priv->alarm_min = alarm->time.tm_min;
priv->alarm_hour = alarm->time.tm_hour;
@@ -333,33 +325,22 @@ static int ds1343_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
if (alarm->enabled)
priv->irqen |= RTC_AF;
 
-   res = ds1343_update_alarm(dev);
-
-   mutex_unlock(>mutex);
-
-   return res;
+   return ds1343_update_alarm(dev);
 }
 
 static int ds1343_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   int res = 0;
 
if (priv->irq <= 0)
return -EINVAL;
 
-   mutex_lock(>mutex);
-
if (enabled)
priv->irqen |= RTC_AF;
else
priv->irqen &= ~RTC_AF;
 
-   res = ds1343_update_alarm(dev);
-
-   mutex_unlock(>mutex);
-
-   return res;
+   return ds1343_update_alarm(dev);
 }
 
 static irqreturn_t ds1343_thread(int irq, void *dev_id)
@@ -368,7 +349,7 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
unsigned int stat, control;
int res = 0;
 
-   mutex_lock(>mutex);
+   rtc_lock(priv->rtc);
 
res = regmap_read(priv->map, DS1343_STATUS_REG, );
if (res)
@@ -389,7 +370,7 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
}
 
 out:
-   mutex_unlock(>mutex);
+   rtc_unlock(priv->rtc);
return IRQ_HANDLED;
 }
 
@@ -422,7 +403,6 @@ static int ds1343_probe(struct spi_device *spi)
return -ENOMEM;
 
priv->spi = spi;
-   mutex_init(>mutex);
 
/* RTC DS1347 works in spi mode 3 and
 * its chip select is active high
@@ -500,9 +480,7 @@ static int ds1343_remove(struct spi_device *spi)
struct ds1343_priv *priv = spi_get_drvdata(spi);
 
if (spi->irq) {
-   mutex_lock(>mutex);
priv->irqen &= ~RTC_AF;
-   mutex_unlock(>mutex);
 
dev_pm_clear_wake_irq(>dev);
device_init_wakeup(>dev, false);
-- 
2.21.0



[PATCH 8/9] rtc: ds1343: rework interrupt handling

2019-10-19 Thread Alexandre Belloni
Rework the interrupt handling to avoid caching the values as the core is
already doing that. The core also always ensures the rtc_time passed for
the alarm is fully populated.

The only trick is in read_alarm where status needs to be read before the
alarm registers to ensure the potential irq is not cleared.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 112 ---
 1 file changed, 35 insertions(+), 77 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 867187325d41..3e2957983703 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -78,12 +78,7 @@ struct ds1343_priv {
struct spi_device *spi;
struct rtc_device *rtc;
struct regmap *map;
-   unsigned int irqen;
int irq;
-   int alarm_sec;
-   int alarm_min;
-   int alarm_hour;
-   int alarm_mday;
 };
 
 static ssize_t ds1343_show_glitchfilter(struct device *dev,
@@ -239,93 +234,66 @@ static int ds1343_set_time(struct device *dev, struct 
rtc_time *dt)
 buf, sizeof(buf));
 }
 
-static int ds1343_update_alarm(struct device *dev)
+static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   unsigned int control, stat;
unsigned char buf[4];
-   int res = 0;
+   unsigned int val;
+   int res;
 
-   res = regmap_read(priv->map, DS1343_CONTROL_REG, );
-   if (res)
-   return res;
+   if (priv->irq <= 0)
+   return -EINVAL;
 
-   res = regmap_read(priv->map, DS1343_STATUS_REG, );
+   res = regmap_read(priv->map, DS1343_STATUS_REG, );
if (res)
return res;
 
-   control &= ~(DS1343_A0IE);
-   stat &= ~(DS1343_IRQF0);
+   alarm->pending = !!(val & DS1343_IRQF0);
 
-   res = regmap_write(priv->map, DS1343_CONTROL_REG, control);
+   res = regmap_read(priv->map, DS1343_CONTROL_REG, );
if (res)
return res;
+   alarm->enabled = !!(val & DS1343_A0IE);
 
-   res = regmap_write(priv->map, DS1343_STATUS_REG, stat);
+   res = regmap_bulk_read(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
if (res)
return res;
 
-   buf[0] = priv->alarm_sec < 0 || (priv->irqen & RTC_UF) ?
-   0x80 : bin2bcd(priv->alarm_sec) & 0x7F;
-   buf[1] = priv->alarm_min < 0 || (priv->irqen & RTC_UF) ?
-   0x80 : bin2bcd(priv->alarm_min) & 0x7F;
-   buf[2] = priv->alarm_hour < 0 || (priv->irqen & RTC_UF) ?
-   0x80 : bin2bcd(priv->alarm_hour) & 0x3F;
-   buf[3] = priv->alarm_mday < 0 || (priv->irqen & RTC_UF) ?
-   0x80 : bin2bcd(priv->alarm_mday) & 0x7F;
-
-   res = regmap_bulk_write(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
-   if (res)
-   return res;
+   alarm->time.tm_sec = bcd2bin(buf[0]) & 0x7f;
+   alarm->time.tm_min = bcd2bin(buf[1]) & 0x7f;
+   alarm->time.tm_hour = bcd2bin(buf[2]) & 0x3f;
+   alarm->time.tm_mday = bcd2bin(buf[3]) & 0x3f;
 
-   if (priv->irqen) {
-   control |= DS1343_A0IE;
-   res = regmap_write(priv->map, DS1343_CONTROL_REG, control);
-   }
-
-   return res;
+   return 0;
 }
 
-static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev);
-   int res;
-   unsigned int stat;
+   unsigned char buf[4];
+   int res = 0;
 
if (priv->irq <= 0)
return -EINVAL;
 
-   res = regmap_read(priv->map, DS1343_STATUS_REG, );
+   res = regmap_update_bits(priv->map, DS1343_CONTROL_REG, DS1343_A0IE, 0);
if (res)
return res;
 
-   alarm->enabled = !!(priv->irqen & RTC_AF);
-   alarm->pending = !!(stat & DS1343_IRQF0);
+   buf[0] = bin2bcd(alarm->time.tm_sec);
+   buf[1] = bin2bcd(alarm->time.tm_min);
+   buf[2] = bin2bcd(alarm->time.tm_hour);
+   buf[3] = bin2bcd(alarm->time.tm_mday);
 
-   alarm->time.tm_sec = priv->alarm_sec < 0 ? 0 : priv->alarm_sec;
-   alarm->time.tm_min = priv->alarm_min < 0 ? 0 : priv->alarm_min;
-   alarm->time.tm_hour = priv->alarm_hour < 0 ? 0 : priv->alarm_hour;
-   alarm->time.tm_mday = priv->alarm_mday < 0 ? 0 : priv->alarm_mday;
-
-   return 0;
-}
-
-static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
-{
-   struct ds1343_priv *priv = dev_get_drvdata(dev);
-
-   if (priv->irq <= 0)
-   return -EINVAL;
-
-   priv->alarm_sec = alarm->time.tm_sec;
-   priv->alarm_min = alarm->time.tm_min;
-   priv->alarm_hour = alarm->time.tm_hour;
-   priv->alarm_mday = alarm->time.tm_mday;
+   res = regmap_bulk_write(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
+   if (res)
+   return res;
 
  

[PATCH 5/9] rtc: ds1343: use regmap_update_bits for glitch filter

2019-10-19 Thread Alexandre Belloni
Use regmap_update_bits to update DS1343_CONTROL_REG in a race free manner
when setting the glitch filter.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index ec8d1e82d7ac..7532a2e8407e 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -108,20 +108,18 @@ static ssize_t ds1343_store_glitchfilter(struct device 
*dev,
const char *buf, size_t count)
 {
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
-   int data;
-
-   regmap_read(priv->map, DS1343_CONTROL_REG, );
+   int data = 0;
+   int res;
 
if (strncmp(buf, "enabled", 7) == 0)
-   data |= DS1343_EGFIL;
-
-   else if (strncmp(buf, "disabled", 8) == 0)
-   data &= ~(DS1343_EGFIL);
-
-   else
+   data = DS1343_EGFIL;
+   else if (strncmp(buf, "disabled", 8))
return -EINVAL;
 
-   regmap_write(priv->map, DS1343_CONTROL_REG, data);
+   res = regmap_update_bits(priv->map, DS1343_CONTROL_REG,
+DS1343_EGFIL, data);
+   if (res)
+   return res;
 
return count;
 }
-- 
2.21.0



[PATCH 9/9] rtc: ds1343: cleanup .remove

2019-10-19 Thread Alexandre Belloni
It is not necessary to call device_init_wakeup(dev, false) in .remove as
device_del will take care of that. It is also not necessary to
devm_free_irq. Finally, dev_pm_clear_wake_irq can be called
unconditionally.

Signed-off-by: Alexandre Belloni 
---
 drivers/rtc/rtc-ds1343.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 3e2957983703..73513688f6f7 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -437,15 +437,7 @@ static int ds1343_probe(struct spi_device *spi)
 
 static int ds1343_remove(struct spi_device *spi)
 {
-   struct ds1343_priv *priv = spi_get_drvdata(spi);
-
-   if (spi->irq) {
-   dev_pm_clear_wake_irq(>dev);
-   device_init_wakeup(>dev, false);
-   devm_free_irq(>dev, spi->irq, priv);
-   }
-
-   spi_set_drvdata(spi, NULL);
+   dev_pm_clear_wake_irq(>dev);
 
return 0;
 }
-- 
2.21.0



Re: [PATCH 6/6 v2] MMC: JZ4740: Add support for LPM.

2019-10-19 Thread Ezequiel Garcia
On Friday, October 18, 2019 13:54 -03, Zhou Yanjie  wrote: 
 

> 
> >
> > I also have a general question. Should we perhaps rename the driver
> > from jz4740_mmc.c to ingenic.c (and the file for the DT bindings, the
> > Kconfig, etc), as that seems like a more appropriate name? No?
> 
> I am very much in favor of this proposal. Now jz4740_mmc.c is not only used
> for the JZ4740 processor, it is also used for JZ4725, JZ4760, JZ4770, JZ4780
> and X1000, and now Ingenic's processor is no longer named after JZ47xx,
> it is divided into three product lines: M, T, and X. It is easy to cause 
> some
> misunderstandings by using jz4740_mmc.c. At the same time, I think that
> some register names also need to be adjusted. For example, the STLPPL
> register name has only appeared in JZ4730 and JZ4740, and this register
> in all subsequent processors is called CTRL. This time I was confused by
> the STLPPL when I added drivers for the JZ4760's and X1000's LPM.
> 

I am very much against renamings, for several reasons. As Paul already 
mentioned, it's pointless and just adds noise to the git-log, making history 
harder to recover. Driver file names don't really have to reflect the device 
exactly. For the compatibility list, it's far easier to just git-grep for 
compatible strings, or git-grep Documentation and/or Kconfig.

Renaming macros and register names, is equally pointless and equally 
git-history invasive. Simply adding some documentation is enough.

Thanks,
Ezequiel



Re: [PATCH 2/6] ARM: ep93xx: enable SPARSE_IRQ

2019-10-19 Thread Arnd Bergmann
On Sat, Oct 19, 2019 at 10:24 PM Alexander Sverdlin
 wrote:
> On Sat, 19 Oct 2019 22:08:40 +0200
> Arnd Bergmann  wrote:
>
> > > # cat /proc/interrupts
> > >CPU0
> > >  39:146   VIC   7 Edge  eth0
> > >  51: 162161   VIC  19 Edge  ep93xx timer
> > >  52:139   VIC  20 Edge  uart-pl010
> > >  53:  4   VIC  21 Edge  ep93xx-spi
> > >  60:  0   VIC  28 Edge  ep93xx-i2s
> > > Err:  0
> >
> > I guess that is partial success: some irqs do work ;-)
>
> Yep, VIC1 is working, while VIC0 is not.
>
> > The two interrupts that did not get registered are for the
> > dmaengine driver, and that makes sense given the error
> > message about the DMA not working. No idea how
> > that would be a result of the irq changes though.
>
> Seems, that it has exposed some incompatibilities of
> starting IRQ 0 in EP93xx platform fir VIC0 and VIC code
> itself, which assumes 0 means "auto assignment" (refer
> to vic_init()).

Ah, that makes sense. so all interrupt numbers need to
be shifted by a fixed number (e.g. 1) like we did for
other platforms (see attachment).

  Arnd
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 6fb19a393fd2..f0a71d4e076f 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -47,6 +47,7 @@
 #include 
 
 #include "soc.h"
+#include "irqs.h"
 
 /*
  * Static I/O mappings that are needed for all EP93xx platforms
@@ -75,8 +76,8 @@ void __init ep93xx_map_io(void)
  */
 void __init ep93xx_init_irq(void)
 {
-	vic_init(EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK, 0);
-	vic_init(EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK, 0);
+	vic_init(EP93XX_VIC1_BASE, IRQ_EP93XX_VIC0, EP93XX_VIC1_VALID_IRQ_MASK, 0);
+	vic_init(EP93XX_VIC2_BASE, IRQ_EP93XX_VIC1, EP93XX_VIC2_VALID_IRQ_MASK, 0);
 }
 
 
diff --git a/arch/arm/mach-ep93xx/irqs.h b/arch/arm/mach-ep93xx/irqs.h
index 3ffdb3a2f3e4..353201b90c66 100644
--- a/arch/arm/mach-ep93xx/irqs.h
+++ b/arch/arm/mach-ep93xx/irqs.h
@@ -2,69 +2,73 @@
 #ifndef __ASM_ARCH_IRQS_H
 #define __ASM_ARCH_IRQS_H
 
-#define IRQ_EP93XX_COMMRX		2
-#define IRQ_EP93XX_COMMTX		3
-#define IRQ_EP93XX_TIMER1		4
-#define IRQ_EP93XX_TIMER2		5
-#define IRQ_EP93XX_AACINTR		6
-#define IRQ_EP93XX_DMAM2P0		7
-#define IRQ_EP93XX_DMAM2P1		8
-#define IRQ_EP93XX_DMAM2P2		9
-#define IRQ_EP93XX_DMAM2P3		10
-#define IRQ_EP93XX_DMAM2P4		11
-#define IRQ_EP93XX_DMAM2P5		12
-#define IRQ_EP93XX_DMAM2P6		13
-#define IRQ_EP93XX_DMAM2P7		14
-#define IRQ_EP93XX_DMAM2P8		15
-#define IRQ_EP93XX_DMAM2P9		16
-#define IRQ_EP93XX_DMAM2M0		17
-#define IRQ_EP93XX_DMAM2M1		18
-#define IRQ_EP93XX_GPIO0MUX		19
-#define IRQ_EP93XX_GPIO1MUX		20
-#define IRQ_EP93XX_GPIO2MUX		21
-#define IRQ_EP93XX_GPIO3MUX		22
-#define IRQ_EP93XX_UART1RX		23
-#define IRQ_EP93XX_UART1TX		24
-#define IRQ_EP93XX_UART2RX		25
-#define IRQ_EP93XX_UART2TX		26
-#define IRQ_EP93XX_UART3RX		27
-#define IRQ_EP93XX_UART3TX		28
-#define IRQ_EP93XX_KEY			29
-#define IRQ_EP93XX_TOUCH		30
+#define IRQ_EP93XX_VIC0			1
+
+#define IRQ_EP93XX_COMMRX		(IRQ_EP93XX_VIC0 + 2)
+#define IRQ_EP93XX_COMMTX		(IRQ_EP93XX_VIC0 + 3)
+#define IRQ_EP93XX_TIMER1		(IRQ_EP93XX_VIC0 + 4)
+#define IRQ_EP93XX_TIMER2		(IRQ_EP93XX_VIC0 + 5)
+#define IRQ_EP93XX_AACINTR		(IRQ_EP93XX_VIC0 + 6)
+#define IRQ_EP93XX_DMAM2P0		(IRQ_EP93XX_VIC0 + 7)
+#define IRQ_EP93XX_DMAM2P1		(IRQ_EP93XX_VIC0 + 8)
+#define IRQ_EP93XX_DMAM2P2		(IRQ_EP93XX_VIC0 + 9)
+#define IRQ_EP93XX_DMAM2P3		(IRQ_EP93XX_VIC0 + 10)
+#define IRQ_EP93XX_DMAM2P4		(IRQ_EP93XX_VIC0 + 11)
+#define IRQ_EP93XX_DMAM2P5		(IRQ_EP93XX_VIC0 + 12)
+#define IRQ_EP93XX_DMAM2P6		(IRQ_EP93XX_VIC0 + 13)
+#define IRQ_EP93XX_DMAM2P7		(IRQ_EP93XX_VIC0 + 14)
+#define IRQ_EP93XX_DMAM2P8		(IRQ_EP93XX_VIC0 + 15)
+#define IRQ_EP93XX_DMAM2P9		(IRQ_EP93XX_VIC0 + 16)
+#define IRQ_EP93XX_DMAM2M0		(IRQ_EP93XX_VIC0 + 17)
+#define IRQ_EP93XX_DMAM2M1		(IRQ_EP93XX_VIC0 + 18)
+#define IRQ_EP93XX_GPIO0MUX		(IRQ_EP93XX_VIC0 + 19)
+#define IRQ_EP93XX_GPIO1MUX		(IRQ_EP93XX_VIC0 + 20)
+#define IRQ_EP93XX_GPIO2MUX		(IRQ_EP93XX_VIC0 + 21)
+#define IRQ_EP93XX_GPIO3MUX		(IRQ_EP93XX_VIC0 + 22)
+#define IRQ_EP93XX_UART1RX		(IRQ_EP93XX_VIC0 + 23)
+#define IRQ_EP93XX_UART1TX		(IRQ_EP93XX_VIC0 + 24)
+#define IRQ_EP93XX_UART2RX		(IRQ_EP93XX_VIC0 + 25)
+#define IRQ_EP93XX_UART2TX		(IRQ_EP93XX_VIC0 + 26)
+#define IRQ_EP93XX_UART3RX		(IRQ_EP93XX_VIC0 + 27)
+#define IRQ_EP93XX_UART3TX		(IRQ_EP93XX_VIC0 + 28)
+#define IRQ_EP93XX_KEY			(IRQ_EP93XX_VIC0 + 29)
+#define IRQ_EP93XX_TOUCH		(IRQ_EP93XX_VIC0 + 30)
 #define EP93XX_VIC1_VALID_IRQ_MASK	0x7ffc
 
-#define IRQ_EP93XX_EXT0			32
-#define IRQ_EP93XX_EXT1			33
-#define IRQ_EP93XX_EXT2			34
-#define IRQ_EP93XX_64HZ			35
-#define IRQ_EP93XX_WATCHDOG		36
-#define IRQ_EP93XX_RTC			37
-#define IRQ_EP93XX_IRDA			38
-#define IRQ_EP93XX_ETHERNET		39

[PATCH v2] w1: new driver. DS2430 chip

2019-10-19 Thread Angelo Dureghello
add support for ds2430, 1 page, 256bit (32bytes) eeprom
(family 0x14).

Tests done:

32 bytes dump:

x@y:~# hexdump -C -n 32 /sys/bus/w1/devices/14-0158556e/eeprom
  39 39 0a 00 00 36 0a ff  ff ff ff ff ff ff ff ff
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
0020

34 bytes dump: 32 only displayed

x@y:~# hexdump -C -n 34 /sys/bus/w1/devices/14-0158556e/eeprom
  39 39 0a 00 00 36 0a ff  ff ff ff ff ff ff ff ff
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
0020

pattern write:

x@y:~# echo 123456789 > /sys/bus/w1/devices/14-0158556e/eeprom
x@y:~# hexdump -C -n 54 /sys/bus/w1/devices/14-0158556e/eeprom
  31 32 33 34 35 36 37 38  39 0a ff ff ff ff ff ff
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
0020

specific address 1-byte write

x@y:~# dd if=/dev/zero of=/sys/bus/w1/devices/14-0158556e/eeprom \
count=1 bs=1 seek=4
1+0 records in
1+0 records out
x@y:~# hexdump -C -n 54 /sys/bus/w1/devices/14-0158556e/eeprom
  31 32 33 34 00 36 37 38  39 0a ff ff ff ff ff ff
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
0020

writing binary block

x@y:~# cat dump-128bytes.bin > /sys/bus/w1/devices/14-0158556e/eeprom
cat: write error: File too large

x@y:~# cat dump-32bytes.bin > /sys/bus/w1/devices/14-0158556e/eeprom
x@y:~# hexdump -C -n 54 /sys/bus/w1/devices/14-0158556e/eeprom
  10 0b 5b ff ff ff ff ff  ff ff ff ff ff ff ff ff
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff 40
0020

Signed-off-by: Angelo Dureghello 
---
 drivers/w1/slaves/Kconfig |   8 +
 drivers/w1/slaves/Makefile|   1 +
 drivers/w1/slaves/w1_ds2430.c | 295 ++
 3 files changed, 304 insertions(+)
 create mode 100644 drivers/w1/slaves/w1_ds2430.c

diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig
index b7847636501d..687753889c34 100644
--- a/drivers/w1/slaves/Kconfig
+++ b/drivers/w1/slaves/Kconfig
@@ -74,6 +74,14 @@ config W1_SLAVE_DS2805
   organized as 7 pages of 16 bytes each with 64bit
   unique number. Requires OverDrive Speed to talk to.
 
+config W1_SLAVE_DS2430
+   tristate "256b EEPROM family support (DS2430)"
+   help
+ Say Y here if you want to use a 1-wire 256bit EEPROM
+ family device (DS2430).
+ This EEPROM is organized as one page of 32 bytes for random
+ access.
+
 config W1_SLAVE_DS2431
tristate "1kb EEPROM family support (DS2431)"
help
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
index 8e9655eaa478..278bcf2a9bfd 100644
--- a/drivers/w1/slaves/Makefile
+++ b/drivers/w1/slaves/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_W1_SLAVE_DS2408) += w1_ds2408.o
 obj-$(CONFIG_W1_SLAVE_DS2413)  += w1_ds2413.o
 obj-$(CONFIG_W1_SLAVE_DS2406)  += w1_ds2406.o
 obj-$(CONFIG_W1_SLAVE_DS2423)  += w1_ds2423.o
+obj-$(CONFIG_W1_SLAVE_DS2430)  += w1_ds2430.o
 obj-$(CONFIG_W1_SLAVE_DS2431)  += w1_ds2431.o
 obj-$(CONFIG_W1_SLAVE_DS2805)  += w1_ds2805.o
 obj-$(CONFIG_W1_SLAVE_DS2433)  += w1_ds2433.o
diff --git a/drivers/w1/slaves/w1_ds2430.c b/drivers/w1/slaves/w1_ds2430.c
new file mode 100644
index ..6fb0563fb2ae
--- /dev/null
+++ b/drivers/w1/slaves/w1_ds2430.c
@@ -0,0 +1,295 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * w1_ds2430.c - w1 family 14 (DS2430) driver
+ **
+ * Copyright (c) 2019 Angelo Dureghello 
+ *
+ * Cloned and modified from ds2431
+ * Copyright (c) 2008 Bernhard Weirich 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define W1_EEPROM_DS2430   0x14
+
+#define W1_F14_EEPROM_SIZE 32
+#define W1_F14_PAGE_COUNT  1
+#define W1_F14_PAGE_BITS   5
+#define W1_F14_PAGE_SIZE   (1 << W1_F14_PAGE_BITS)
+#define W1_F14_PAGE_MASK   0x1F
+
+#define W1_F14_SCRATCH_BITS5
+#define W1_F14_SCRATCH_SIZE(1 << W1_F14_SCRATCH_BITS)
+#define W1_F14_SCRATCH_MASK(W1_F14_SCRATCH_SIZE-1)
+
+#define W1_F14_READ_EEPROM 0xF0
+#define W1_F14_WRITE_SCRATCH   0x0F
+#define W1_F14_READ_SCRATCH0xAA
+#define W1_F14_COPY_SCRATCH0x55
+#define W1_F14_VALIDATION_KEY  0xa5
+
+#define W1_F14_TPROG_MS11
+#define W1_F14_READ_RETRIES10
+#define W1_F14_READ_MAXLEN W1_F14_SCRATCH_SIZE
+
+/*
+ * Check the file size bounds and adjusts count as needed.
+ * This would not be needed if the file size didn't reset to 0 after a write.
+ */
+static inline size_t w1_f14_fix_count(loff_t off, size_t count, size_t size)
+{
+   if (off > size)
+   return 0;
+
+   if ((off + count) > size)
+   return size - off;
+
+   return count;
+}
+
+/*
+ * Read a block from W1 ROM two times and compares the results.
+ * If they are equal they are returned, otherwise the read
+ * is repeated W1_F14_READ_RETRIES times.
+ *
+ * count must not exceed W1_F14_READ_MAXLEN.
+ */
+static int w1_f14_readblock(struct w1_slave *sl, int off, 

Re: [PATCH] Bluetooth: hci_qca: Add delay for wcn3990 stability

2019-10-19 Thread Jeffrey Hugo
On Fri, Oct 18, 2019 at 5:15 PM Matthias Kaehlcke  wrote:
>
> On Fri, Oct 18, 2019 at 04:36:23PM -0600, Jeffrey Hugo wrote:
> > On Fri, Oct 18, 2019 at 3:33 PM Matthias Kaehlcke  wrote:
> > >
> > > On Fri, Oct 18, 2019 at 01:51:39PM -0600, Jeffrey Hugo wrote:
> > > > On Fri, Oct 18, 2019 at 1:40 PM Matthias Kaehlcke  
> > > > wrote:
> > > > >
> > > > > On Fri, Oct 18, 2019 at 12:30:09PM -0600, Jeffrey Hugo wrote:
> > > > > > On Fri, Oct 18, 2019 at 12:03 PM Matthias Kaehlcke 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Thu, Oct 17, 2019 at 02:29:55PM -0700, Jeffrey Hugo wrote:
> > > > > > > > On the msm8998 mtp, the response to the baudrate change command 
> > > > > > > > is never
> > > > > > > > received.  On the Lenovo Miix 630, the response to the baudrate 
> > > > > > > > change
> > > > > > > > command is corrupted - "Frame reassembly failed (-84)".
> > > > > > > >
> > > > > > > > Adding a 50ms delay before re-enabling flow to receive the 
> > > > > > > > baudrate change
> > > > > > > > command response from the wcn3990 addesses both issues, and 
> > > > > > > > allows
> > > > > > > > bluetooth to become functional.
> > > > > > >
> > > > > > > From my earlier debugging on sdm845 I don't think this is what 
> > > > > > > happens.
> > > > > > > The problem is that the wcn3990 sends the response to the 
> > > > > > > baudrate change
> > > > > > > command using the new baudrate, while the UART on the SoC still 
> > > > > > > operates
> > > > > > > with the prior speed (for details see 2faa3f15fa2f ("Bluetooth: 
> > > > > > > hci_qca:
> > > > > > > wcn3990: Drop baudrate change vendor event"))
> > > > > > >
> > > > > > > IIRC the 50ms delay causes the HCI core to discard the received 
> > > > > > > data,
> > > > > > > which is why the "Frame reassembly failed" message disappears, not
> > > > > > > because the response was received. In theory commit 78e8fa2972e5
> > > > > > > ("Bluetooth: hci_qca: Deassert RTS while baudrate change command")
> > > > > > > should have fixed those messages, do you know if CTS/RTS are 
> > > > > > > connected
> > > > > > > on the Bluetooth UART of the Lenovo Miix 630?
> > > > > >
> > > > > > I was testing with 5.4-rc1 which contains the indicated RTS fix.
> > > > > >
> > > > > > Yes, CTS/RTS are connected on the Lenovo Miix 630.
> > > > > >
> > > > > > I added debug statements which indicated that data was received,
> > > > > > however it was corrupt, and the packet type did not match what was
> > > > > > expected, hence the frame reassembly errors.
> > > > >
> > > > > Do you know if any data is received during the delay? In theory that
> > > > > shouldn't be the case since RTS is deasserted, just double-checking.
> > > >
> > > > I don't think so, but I've run so many tests, I'm not 100% positive.
> > > > Let me go double check and get back to you.
> >
> > Apparently I'd be wrong.  I instrumented the uart driver so that it
> > would indicate when it got data from the bam.  Apparently its getting
> > the data during the 50ms sleep, approximately right after the host
> > baud rate is set.
>
> Good finding!
>
> > > >
> > > > >
> > > > > What happens if you add a longer delay (e.g. 1s) before/after setting
> > > > > the host baudrate?
> > > >
> > > > Hmm, not exactly sure.  I will test.
> >
> > Adding a 1 second delay before setting the host baud rate did not
> > change the observed results - still received the data during the 50ms
> > sleep after the host baud rate set operation.
> > Adding a 1 second delay after setting the host baud rate did not
> > change when the data was received.
>
> Thanks for testing!
>
> > > >
> > > > >
> > > > > > In response to this patch, Balakrishna pointed me to a bug report
> > > > > > which indicated that some of the UART GPIO lines need to have a bias
> > > > > > applied to prevent errant data from floating lines -
> > > > > >
> > > > > > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1391888
> > > > >
> > > > > Yeah, that was another source of frame reassembly errors that we were
> > > > > seeing on SDM845.
> > > > >
> > > > > Balakrishna, please post these kind of replies on-list, so that
> > > > > everybody can benefit from possible solutions or contribute to the
> > > > > discussion.
> > > > >
> > > > > > It turns out this fix was never applied to msm8998.  Applying the 
> > > > > > fix
> > > > > > does cause the the frame reassembly errors to go away, however then
> > > > > > the host SoC never receives the baud rate change response (I 
> > > > > > increased
> > > > > > the timeout from 2faa3f15fa2f ("Bluetooth: hci_qca: wcn3990: Drop
> > > > > > baudrate change vendor event") to 5 seconds).  As of now, this patch
> > > > > > is still required.
> > > > >
> > > > > Interesting.
> > > > >
> > > > > FTR, this is the full UART pin configuration for cheza (SDM845):
> > > > >
> > > > > _uart6_default {
> > > > > /* Change pinmux to all 4 pins since CTS and RTS are 
> > > > > connected */
> > > > > 

Re: [musl] [PATCH] arm64: uapi: Fix user space compile with musl libc

2019-10-19 Thread Rich Felker
On Sat, Oct 19, 2019 at 10:17:17PM +0200, Hauke Mehrtens wrote:
> musl libc also defines the structures in their arch/aarch64/bits/signal.h
> header file. Some applications like strace and gdb include both of them
> and then the structure definitions are clashing and the build of these
> user space applications fails.
> 
> This patch allows a libc to define a constant which tells the kernel
> header file that the libc already defined these structures and that they
> should not be defined by the kernel uapi header files any more to
> prevent clashes. This is done in a similar way as it is already done for
> other header files.
> 
> When this patch was accepted into the kernel I will also update musl
> libc to define these constants.

I don't entirely object to this outright, but I'd really like to avoid
adding further __UAPI_DEF_* suppressions. AIUI asm/sigcontext.h is not
intended to be used with userspace headers. Is it still being
indirectly included via some other uapi headers? (I thought that was
fixed..) If so, that should really be fixed first, and then we can see
if there's still motivation for the patch here.

Rich


> Signed-off-by: Hauke Mehrtens 
> Cc: sta...@vger.kernel.org
> ---
>  arch/arm64/include/uapi/asm/sigcontext.h | 13 +
>  include/uapi/linux/libc-compat.h | 20 
>  2 files changed, 33 insertions(+)
> 
> diff --git a/arch/arm64/include/uapi/asm/sigcontext.h 
> b/arch/arm64/include/uapi/asm/sigcontext.h
> index 8b0ebce92427..92d911146137 100644
> --- a/arch/arm64/include/uapi/asm/sigcontext.h
> +++ b/arch/arm64/include/uapi/asm/sigcontext.h
> @@ -20,7 +20,9 @@
>  #ifndef __ASSEMBLY__
>  
>  #include 
> +#include 
>  
> +#if __UAPI_DEF_SIGCONTEXT
>  /*
>   * Signal context structure - contains all info to do with the state
>   * before the signal handler was invoked.
> @@ -35,6 +37,7 @@ struct sigcontext {
>   /* 4K reserved for FP/SIMD state and future expansion */
>   __u8 __reserved[4096] __attribute__((__aligned__(16)));
>  };
> +#endif
>  
>  /*
>   * Allocation of __reserved[]:
> @@ -57,6 +60,7 @@ struct sigcontext {
>   * generated when userspace does not opt in for any such extension.
>   */
>  
> +#if __UAPI_DEF_AARCH64_CTX
>  /*
>   * Header to be used at the beginning of structures extending the user
>   * context. Such structures must be placed after the rt_sigframe on the stack
> @@ -67,7 +71,9 @@ struct _aarch64_ctx {
>   __u32 magic;
>   __u32 size;
>  };
> +#endif
>  
> +#if __UAPI_DEF_FPSIMD_CONTEXT
>  #define FPSIMD_MAGIC 0x46508001
>  
>  struct fpsimd_context {
> @@ -76,7 +82,9 @@ struct fpsimd_context {
>   __u32 fpcr;
>   __uint128_t vregs[32];
>  };
> +#endif
>  
> +#if __UAPI_DEF_ESR_CONTEXT
>  /*
>   * Note: similarly to all other integer fields, each V-register is stored in 
> an
>   * endianness-dependent format, with the byte at offset i from the start of 
> the
> @@ -93,7 +101,9 @@ struct esr_context {
>   struct _aarch64_ctx head;
>   __u64 esr;
>  };
> +#endif
>  
> +#if __UAPI_DEF_EXTRA_CONTEXT
>  /*
>   * extra_context: describes extra space in the signal frame for
>   * additional structures that don't fit in sigcontext.__reserved[].
> @@ -128,7 +138,9 @@ struct extra_context {
>   __u32 size; /* size in bytes of the extra space */
>   __u32 __reserved[3];
>  };
> +#endif
>  
> +#if __UAPI_DEF_SVE_CONTEXT
>  #define SVE_MAGIC0x53564501
>  
>  struct sve_context {
> @@ -136,6 +148,7 @@ struct sve_context {
>   __u16 vl;
>   __u16 __reserved[3];
>  };
> +#endif
>  
>  #endif /* !__ASSEMBLY__ */
>  
> diff --git a/include/uapi/linux/libc-compat.h 
> b/include/uapi/linux/libc-compat.h
> index 8254c937c9f4..a863130f4638 100644
> --- a/include/uapi/linux/libc-compat.h
> +++ b/include/uapi/linux/libc-compat.h
> @@ -264,4 +264,24 @@
>  
>  #endif /* __GLIBC__ */
>  
> +/* Definitions for arch/arm64/include/uapi/asm/sigcontext.h */
> +#ifndef __UAPI_DEF_SIGCONTEXT
> +#define __UAPI_DEF_SIGCONTEXT1
> +#endif
> +#ifndef __UAPI_DEF_AARCH64_CTX
> +#define __UAPI_DEF_AARCH64_CTX   1
> +#endif
> +#ifndef __UAPI_DEF_FPSIMD_CONTEXT
> +#define __UAPI_DEF_FPSIMD_CONTEXT1
> +#endif
> +#ifndef __UAPI_DEF_ESR_CONTEXT
> +#define __UAPI_DEF_ESR_CONTEXT   1
> +#endif
> +#ifndef __UAPI_DEF_EXTRA_CONTEXT
> +#define __UAPI_DEF_EXTRA_CONTEXT 1
> +#endif
> +#ifndef __UAPI_DEF_SVE_CONTEXT
> +#define __UAPI_DEF_SVE_CONTEXT   1
> +#endif
> +
>  #endif /* _UAPI_LIBC_COMPAT_H */
> -- 
> 2.20.1


Re: [PATCH 2/6] ARM: ep93xx: enable SPARSE_IRQ

2019-10-19 Thread Alexander Sverdlin
Hi!

On Sat, 19 Oct 2019 22:08:40 +0200
Arnd Bergmann  wrote:

> > # cat /proc/interrupts
> >CPU0
> >  39:146   VIC   7 Edge  eth0
> >  51: 162161   VIC  19 Edge  ep93xx timer
> >  52:139   VIC  20 Edge  uart-pl010
> >  53:  4   VIC  21 Edge  ep93xx-spi
> >  60:  0   VIC  28 Edge  ep93xx-i2s
> > Err:  0
> 
> I guess that is partial success: some irqs do work ;-)

Yep, VIC1 is working, while VIC0 is not.

> The two interrupts that did not get registered are for the
> dmaengine driver, and that makes sense given the error
> message about the DMA not working. No idea how
> that would be a result of the irq changes though.

Seems, that it has exposed some incompatibilities of
starting IRQ 0 in EP93xx platform fir VIC0 and VIC code
itself, which assumes 0 means "auto assignment" (refer
to vic_init()).

But there are more problems I didn't resolve yet.

-- 
Alexander Sverdlin.


[PATCH] arm64: uapi: Fix user space compile with musl libc

2019-10-19 Thread Hauke Mehrtens
musl libc also defines the structures in their arch/aarch64/bits/signal.h
header file. Some applications like strace and gdb include both of them
and then the structure definitions are clashing and the build of these
user space applications fails.

This patch allows a libc to define a constant which tells the kernel
header file that the libc already defined these structures and that they
should not be defined by the kernel uapi header files any more to
prevent clashes. This is done in a similar way as it is already done for
other header files.

When this patch was accepted into the kernel I will also update musl
libc to define these constants.

Signed-off-by: Hauke Mehrtens 
Cc: sta...@vger.kernel.org
---
 arch/arm64/include/uapi/asm/sigcontext.h | 13 +
 include/uapi/linux/libc-compat.h | 20 
 2 files changed, 33 insertions(+)

diff --git a/arch/arm64/include/uapi/asm/sigcontext.h 
b/arch/arm64/include/uapi/asm/sigcontext.h
index 8b0ebce92427..92d911146137 100644
--- a/arch/arm64/include/uapi/asm/sigcontext.h
+++ b/arch/arm64/include/uapi/asm/sigcontext.h
@@ -20,7 +20,9 @@
 #ifndef __ASSEMBLY__
 
 #include 
+#include 
 
+#if __UAPI_DEF_SIGCONTEXT
 /*
  * Signal context structure - contains all info to do with the state
  * before the signal handler was invoked.
@@ -35,6 +37,7 @@ struct sigcontext {
/* 4K reserved for FP/SIMD state and future expansion */
__u8 __reserved[4096] __attribute__((__aligned__(16)));
 };
+#endif
 
 /*
  * Allocation of __reserved[]:
@@ -57,6 +60,7 @@ struct sigcontext {
  * generated when userspace does not opt in for any such extension.
  */
 
+#if __UAPI_DEF_AARCH64_CTX
 /*
  * Header to be used at the beginning of structures extending the user
  * context. Such structures must be placed after the rt_sigframe on the stack
@@ -67,7 +71,9 @@ struct _aarch64_ctx {
__u32 magic;
__u32 size;
 };
+#endif
 
+#if __UAPI_DEF_FPSIMD_CONTEXT
 #define FPSIMD_MAGIC   0x46508001
 
 struct fpsimd_context {
@@ -76,7 +82,9 @@ struct fpsimd_context {
__u32 fpcr;
__uint128_t vregs[32];
 };
+#endif
 
+#if __UAPI_DEF_ESR_CONTEXT
 /*
  * Note: similarly to all other integer fields, each V-register is stored in an
  * endianness-dependent format, with the byte at offset i from the start of the
@@ -93,7 +101,9 @@ struct esr_context {
struct _aarch64_ctx head;
__u64 esr;
 };
+#endif
 
+#if __UAPI_DEF_EXTRA_CONTEXT
 /*
  * extra_context: describes extra space in the signal frame for
  * additional structures that don't fit in sigcontext.__reserved[].
@@ -128,7 +138,9 @@ struct extra_context {
__u32 size; /* size in bytes of the extra space */
__u32 __reserved[3];
 };
+#endif
 
+#if __UAPI_DEF_SVE_CONTEXT
 #define SVE_MAGIC  0x53564501
 
 struct sve_context {
@@ -136,6 +148,7 @@ struct sve_context {
__u16 vl;
__u16 __reserved[3];
 };
+#endif
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 8254c937c9f4..a863130f4638 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -264,4 +264,24 @@
 
 #endif /* __GLIBC__ */
 
+/* Definitions for arch/arm64/include/uapi/asm/sigcontext.h */
+#ifndef __UAPI_DEF_SIGCONTEXT
+#define __UAPI_DEF_SIGCONTEXT  1
+#endif
+#ifndef __UAPI_DEF_AARCH64_CTX
+#define __UAPI_DEF_AARCH64_CTX 1
+#endif
+#ifndef __UAPI_DEF_FPSIMD_CONTEXT
+#define __UAPI_DEF_FPSIMD_CONTEXT  1
+#endif
+#ifndef __UAPI_DEF_ESR_CONTEXT
+#define __UAPI_DEF_ESR_CONTEXT 1
+#endif
+#ifndef __UAPI_DEF_EXTRA_CONTEXT
+#define __UAPI_DEF_EXTRA_CONTEXT   1
+#endif
+#ifndef __UAPI_DEF_SVE_CONTEXT
+#define __UAPI_DEF_SVE_CONTEXT 1
+#endif
+
 #endif /* _UAPI_LIBC_COMPAT_H */
-- 
2.20.1



Re: [PATCH 2/6] ARM: ep93xx: enable SPARSE_IRQ

2019-10-19 Thread Arnd Bergmann
On Sat, Oct 19, 2019 at 6:43 PM Alexander Sverdlin
 wrote:
> On Fri, 18 Oct 2019 18:29:15 +0200
> Arnd Bergmann  wrote:
>
> > Without CONFIG_SPARSE_IRQ, we rely on mach/irqs.h to define NR_IRQS
> > globally. Do the minimal conversion by setting .nr_irqs in each
> > machine descriptor.
> >
> > Only the vision_ep9307 machine has extra IRQs for GPIOs, so make
> > .nr_irqs the original value there, while using the plain NR_EP93XX_IRQS
> > everywhere else.
>
> This patch causes multiple problems on EDB9302:
>
> 1. WARNINGs during gpiochip registration, for instance:
>
> [ cut here ]
> WARNING: CPU: 0 PID: 1 at kernel/irq/chip.c:1013 
> __irq_do_set_handler+0x94/0x188
> CPU: 0 PID: 1 Comm: swapper Tainted: GW 5.4.0-rc3 #1
> Hardware name: Cirrus Logic EDB9302 Evaluation Board
> [] (unwind_backtrace) from [] (show_stack+0x10/0x18)
> [] (show_stack) from [] (dump_stack+0x18/0x24)
> [] (dump_stack) from [] (__warn+0xa4/0xc8)
> [] (__warn) from [] (warn_slowpath_fmt+0xa8/0xb8)
> [] (warn_slowpath_fmt) from [] 
> (__irq_do_set_handler+0x94/0x188)
> [] (__irq_do_set_handler) from [] 
> (irq_set_chained_handler_and_data+0x48/0x7c)
> [] (irq_set_chained_handler_and_data) from [] 
> (gpiochip_add_data_with_key+0x6d4/0xabc)
> [] (gpiochip_add_data_with_key) from [] 
> (devm_gpiochip_add_data+0x40/0x88)
> [] (devm_gpiochip_add_data) from [] 
> (ep93xx_gpio_probe+0x1ac/0x280)
> [] (ep93xx_gpio_probe) from [] 
> (platform_drv_probe+0x28/0x6c)
> [] (platform_drv_probe) from [] (really_probe+0x1c8/0x340)
> [] (really_probe) from [] (bus_for_each_drv+0x58/0xc0)
> [] (bus_for_each_drv) from [] (__device_attach+0xb4/0x104)
> [] (__device_attach) from [] (bus_probe_device+0x8c/0x94)
> [] (bus_probe_device) from [] (device_add+0x3d0/0x59c)
> [] (device_add) from [] (platform_device_add+0x100/0x20c)
> [] (platform_device_add) from [] 
> (ep93xx_init_devices+0x16c/0x20c)
> [] (ep93xx_init_devices) from [] 
> (edb93xx_init_machine+0xc/0x84)
> [] (edb93xx_init_machine) from [] 
> (customize_machine+0x20/0x38)
> [] (customize_machine) from [] 
> (do_one_initcall+0x78/0x1a0)
> [] (do_one_initcall) from [] 
> (kernel_init_freeable+0x104/0x1b8)
> [] (kernel_init_freeable) from [] (kernel_init+0x8/0xf8)
> [] (kernel_init) from [] (ret_from_fork+0x14/0x24)
> Exception stack(0xc4433fb0 to 0xc4433ff8)
> 3fa0:    
> 3fc0:        
> 3fe0:     0013 
> ---[ end trace 8f9e35e2d6224882 ]---

My first guess would be that this is just the missing irq domain code:

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 38e096e6925f..7c195af6f75d 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -205,6 +205,7 @@ config GPIO_EP93XX
depends on ARCH_EP93XX
select GPIO_GENERIC
select GPIOLIB_IRQCHIP
+   select IRQ_DOMAIN_HIERARCHY

 config GPIO_EXAR
tristate "Support for GPIO pins on XR17V352/354/358"

But most likely there are more changes required to the gpio code.

> 2. Broken sound (I2S), this looks like below in the log:
>
> ep93xx-i2s ep93xx-i2s: Missing dma channel for stream: 0
>  CS4271: ASoC: pcm constructor failed: -22
> edb93xx-audio edb93xx-audio: ASoC: can't create pcm CS4271 HiFi :-22
>
> And /proc/interrupts has two entries less. Without patch:
>
> # cat /proc/interrupts
>CPU0
>   7:  0   VIC   7 Edge  i2s-pcm-out
>   8:  0   VIC   8 Edge  i2s-pcm-in
>  39:  2   VIC   7 Edge  eth0
>  51:   7532   VIC  19 Edge  ep93xx timer
>  52:144   VIC  20 Edge  uart-pl010
>  53:  4   VIC  21 Edge  ep93xx-spi
>  60:  0   VIC  28 Edge  ep93xx-i2s
> Err:  0
>
> With patch:
>
> # cat /proc/interrupts
>CPU0
>  39:146   VIC   7 Edge  eth0
>  51: 162161   VIC  19 Edge  ep93xx timer
>  52:139   VIC  20 Edge  uart-pl010
>  53:  4   VIC  21 Edge  ep93xx-spi
>  60:  0   VIC  28 Edge  ep93xx-i2s
> Err:  0

I guess that is partial success: some irqs do work ;-)

The two interrupts that did not get registered are for the
dmaengine driver, and that makes sense given the error
message about the DMA not working. No idea how
that would be a result of the irq changes though.

> I will try to look into I2S problem...

Thanks!

   Arnd


Re: [PATCH v1 1/5] staging: wfx: fix warnings of no space is necessary

2019-10-19 Thread Joe Perches
On Sat, 2019-10-19 at 21:05 +0300, Dan Carpenter wrote:
> On Sat, Oct 19, 2019 at 04:09:03PM +0100, Jules Irenge wrote:
> > Checkpatch was complaining about  space between type cast and the 
> > variable. I just get rid of the space. Well I don't know whether this was 
> > false positive one.
> > 
> > Thanks for the feedback. I will update the patch.
> 
> No no.  The patch is fine.  I was saying that in the *future* you might
> want to look at the void casts.  Some of them are not required and
> others are buggy code.

Hello Jules.

Frequently, checkpatch is not the best tool to find and
possibly correct various unnecessary code styles.

checkpatch is OK to look at some odd uses

coccinelle is frequently a better overall tool for these uses.

A trivial cocci script to remove some unnecessary void * casts
from mem and str calls might be like the below, but
watch out for __iomem and __force uses where coccinelle doesn't
understand the syntax.

$ cat unnecessary_void_ptr.cocci
@@
type T1;
type T2;
T1 *p1;
T2 *p2;
@@

\(memcpy\|memmove\|strcpy\|strncmp\)(
-   (void *)
p1,
-   (void *)
p2, ...)

@@
type T1;
type T2;
T1 *p1;
T2 *p2;
@@

\(memcpy\|memmove\|strcpy\|strncmp\)(
p1,
-   (void *)
p2, ...)

@@
type T;
T *p;
@@

\(memcpy\|memset\|memmove\|memzero\|strcpy\|strncmp\|strnlen\)(
-   (void *)
p, ...)

$

For instance, when run over today's drivers/staging, this produces:

$ spatch --very-quiet -sp-file unnecessary_void_ptr.cocci drivers/staging
---
diff -u -p a/exfat/exfat_core.c b/exfat/exfat_core.c
--- a/exfat/exfat_core.c
+++ b/exfat/exfat_core.c
@@ -3427,7 +3427,7 @@ s32 rename_file(struct inode *inode, str
return FFS_MEDIAERR;
}
 
-   memcpy((void *)epnew, (void *)epold, DENTRY_SIZE);
+   memcpy(epnew, epold, DENTRY_SIZE);
if (fs_func->get_entry_type(epnew) == TYPE_FILE) {
fs_func->set_entry_attr(epnew,
fs_func->get_entry_attr(epnew) |
@@ -3449,7 +3449,7 @@ s32 rename_file(struct inode *inode, str
return FFS_MEDIAERR;
}
 
-   memcpy((void *)epnew, (void *)epold, DENTRY_SIZE);
+   memcpy(epnew, epold, DENTRY_SIZE);
buf_modify(sb, sector_new);
buf_unlock(sb, sector_old);
}
@@ -3538,7 +3538,7 @@ s32 move_file(struct inode *inode, struc
return FFS_MEDIAERR;
}
 
-   memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE);
+   memcpy(epnew, epmov, DENTRY_SIZE);
if (fs_func->get_entry_type(epnew) == TYPE_FILE) {
fs_func->set_entry_attr(epnew, fs_func->get_entry_attr(epnew) |
ATTR_ARCHIVE);
@@ -3558,7 +3558,7 @@ s32 move_file(struct inode *inode, struc
return FFS_MEDIAERR;
}
 
-   memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE);
+   memcpy(epnew, epmov, DENTRY_SIZE);
buf_modify(sb, sector_new);
buf_unlock(sb, sector_mov);
} else if (fs_func->get_entry_type(epnew) == TYPE_DIR) {
diff -u -p a/qlge/qlge_main.c b/qlge/qlge_main.c
--- a/qlge/qlge_main.c
+++ b/qlge/qlge_main.c
@@ -2583,7 +2583,7 @@ static netdev_tx_t qlge_send(struct sk_b
}
tx_ring_desc = _ring->q[tx_ring->prod_idx];
mac_iocb_ptr = tx_ring_desc->queue_entry;
-   memset((void *)mac_iocb_ptr, 0, sizeof(*mac_iocb_ptr));
+   memset(mac_iocb_ptr, 0, sizeof(*mac_iocb_ptr));
 
mac_iocb_ptr->opcode = OPCODE_OB_MAC_IOCB;
mac_iocb_ptr->tid = tx_ring_desc->index;
@@ -3029,7 +3029,7 @@ static int ql_start_rx_ring(struct ql_ad
/* PCI doorbell mem area + 0x1c */
rx_ring->sbq.prod_idx_db_reg = (u32 __iomem *)(doorbell_area + 0x1c);
 
-   memset((void *)cqicb, 0, sizeof(struct cqicb));
+   memset(cqicb, 0, sizeof(struct cqicb));
cqicb->msix_vect = rx_ring->irq;
 
cqicb->len = cpu_to_le16(QLGE_FIT16(rx_ring->cq_len) | LEN_V |
@@ -3473,7 +3473,7 @@ static int ql_start_rss(struct ql_adapte
int i;
u8 *hash_id = (u8 *) ricb->hash_cq_id;
 
-   memset((void *)ricb, 0, sizeof(*ricb));
+   memset(ricb, 0, sizeof(*ricb));
 
ricb->base_cq = RSS_L4K;
ricb->flags =
@@ -3486,8 +3486,8 @@ static int ql_start_rss(struct ql_adapte
for (i = 0; i < 1024; i++)
hash_id[i] = (i & (qdev->rss_ring_count - 1));
 
-   memcpy((void *)>ipv6_hash_key[0], init_hash_seed, 40);
-   memcpy((void *)>ipv4_hash_key[0], init_hash_seed, 16);
+   memcpy(>ipv6_hash_key[0], init_hash_seed, 40);
+   memcpy(>ipv4_hash_key[0], init_hash_seed, 16);
 
status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0);
if (status) {
@@ -3983,7 +3983,7 @@ static 

[PATCH v2] arm64: defconfig: Enable Qualcomm pseudo rng

2019-10-19 Thread Bjorn Andersson
Most Qualcomm platforms contain a pseudo random number generator
hardware block. Enable the driver for this block and also enable the
interface for exposing this to userspace.

Signed-off-by: Bjorn Andersson 
---
 arch/arm64/configs/defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 6baf90875263..4591bf1303da 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -860,6 +860,8 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_SECURITY=y
 CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_ANSI_CPRNG=y
+CONFIG_CRYPTO_USER_API_RNG=m
+CONFIG_CRYPTO_DEV_QCOM_RNG=m
 CONFIG_DMA_CMA=y
 CONFIG_CMA_SIZE_MBYTES=32
 CONFIG_PRINTK_TIME=y
-- 
2.23.0



[GIT] Networking

2019-10-19 Thread David Miller


I was battling a cold after some recent trips, so quite a bit piled up
meanwhile, sorry about that.

Highlights:

1) Fix fd leak in various bpf selftests, from Brian Vazquez.

2) Fix crash in xsk when device doesn't support some methods, from
   Magnus Karlsson.

3) Fix various leaks and use-after-free in rxrpc, from David Howells.

4) Fix several SKB leaks due to confusion of who owns an SKB and who
   should release it in the llc code.  From Eric Biggers.

5) Kill a bunc of KCSAN warnings in TCP, from Eric Dumazet.

6) Jumbo packets don't work after resume on r8169, as the BIOS
   resets the chip into non-jumbo mode during suspend.  From
   Heiner Kallweit.

7) Corrupt L2 header during MPLS push, from Davide Caratti.

8) Prevent possible infinite loop in tc_ctl_action, from Eric
   Dumazet.

9) Get register bits right in bcmgenet driver, based upon chip
   version.  From Florian Fainelli.

10) Fix mutex problems in microchip DSA driver, from Marek Vasut.

11) Cure race between route lookup and invalidation in ipv4, from
Wei Wang.

12) Fix performance regression due to false sharing in 'net'
structure, from Eric Dumazet.

Please pull, thanks a lot!

The following changes since commit 2d00aee21a5d4966e086d98f9d710afb92fb14e8:

  Merge tag 'kbuild-fixes-v5.4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild 
(2019-10-05 12:56:59 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 

for you to fetch changes up to 2a06b8982f8f2f40d03a3daf634676386bd84dbc:

  net: reorder 'struct net' fields to avoid false sharing (2019-10-19 12:21:53 
-0700)


Aaron Komisar (1):
  mac80211: fix scan when operating on DFS channels in ETSI domains

Alex Vesker (1):
  net/mlx5: DR, Allow insertion of duplicate rules

Alexandra Winter (2):
  s390/qeth: Fix error handling during VNICC initialization
  s390/qeth: Fix initialization of vnicc cmd masks during set online

Alexandre Belloni (1):
  net: lpc_eth: avoid resetting twice

Andrew Lunn (1):
  net: usb: lan78xx: Connect PHY before registering MAC

Antonio Borneo (3):
  ptp: fix typo of "mechanism" in Kconfig help text
  net: stmmac: fix length of PTP clock's name string
  net: stmmac: fix disabling flexible PPS output

Ben Dooks (Codethink) (3):
  davinci_cpdma: make cpdma_chan_split_pool static
  net: stmmac: make tc_flow_parsers static
  net: stmmac: fix argument to stmmac_pcs_ctrl_ane()

Biao Huang (1):
  net: stmmac: disable/enable ptp_ref_clk in suspend/resume flow

Björn Töpel (1):
  samples/bpf: Fix build for task_fd_query_user.c

Brian Vazquez (2):
  selftests/bpf: test_progs: Don't leak server_fd in tcp_rtt
  selftests/bpf: test_progs: Don't leak server_fd in test_sockopt_inherit

Chenwandun (1):
  net: aquantia: add an error handling in aq_nic_set_multicast_list

Cong Wang (2):
  net_sched: fix backward compatibility for TCA_KIND
  net_sched: fix backward compatibility for TCA_ACT_KIND

Cédric Le Goater (1):
  net/ibmvnic: Fix EOI when running in XIVE mode.

Daniele Palmas (1):
  net: usb: qmi_wwan: add Telit 0x1050 composition

David Ahern (1):
  net: Update address for vrf and l3mdev in MAINTAINERS

David Howells (7):
  rxrpc: Fix call ref leak
  rxrpc: Fix trace-after-put looking at the put peer record
  rxrpc: Fix trace-after-put looking at the put connection record
  rxrpc: Fix trace-after-put looking at the put call record
  rxrpc: rxrpc_peer needs to hold a ref on the rxrpc_local record
  rxrpc: Fix call crypto state cleanup
  rxrpc: Fix possible NULL pointer access in ICMP handling

David S. Miller (12):
  Merge branch 'stmmac-fixes'
  Merge tag 'rxrpc-fixes-20191007' of 
git://git.kernel.org/.../dhowells/linux-fs
  Merge git://git.kernel.org/.../bpf/bpf
  Merge branch 'tcp-address-KCSAN-reports-in-tcp_poll-part-I'
  Merge branch 'aquantia-fixes'
  Merge tag 'wireless-drivers-for-davem-2019-10-15' of 
git://git.kernel.org/.../kvalo/wireless-drivers
  Merge branch 'mpls-push-pop-fix'
  Merge branch 'Update-MT7629-to-support-PHYLINK-API'
  Merge branch 'dpaa2-eth-misc-fixes'
  Merge branch 'net-bcmgenet-restore-internal-EPHY-support'
  Merge branch 'vsock-virtio-make-the-credit-mechanism-more-robust'
  Merge branch 'netem-fix-further-issues-with-packet-corruption'

Davide Caratti (2):
  net: avoid errors when trying to pop MLPS header on non-MPLS packets
  net/sched: fix corrupted L2 header with MPLS 'push' and 'pop' actions

Dmitry Bogdanov (2):
  net: aquantia: do not pass lro session with invalid tcp checksum
  net: aquantia: correctly handle macvlan and multicast coexistence

Dmitry Torokhov (1):
  rt2x00: remove input-polldev.h header

Doug Berger (4):
  net: bcmgenet: don't set phydev->link from MAC
  net: phy: 

Re: [PATCH 44/46] ARM: mmp: remove tavorevb board support

2019-10-19 Thread Arnd Bergmann
On Sat, Oct 19, 2019 at 4:20 PM Lubomir Rintel  wrote:
> On Fri, 2019-10-18 at 17:41 +0200, Arnd Bergmann wrote:
> >
> > There is a third board named TavorEVB in the Kconfig description,
> > but this refers to the "TTC_DKB" machine. The two are clearly
> > related, so I change the Kconfig description to just list both
> > names.
> >
> > Cc: Lubomir Rintel 
> > Signed-off-by: Arnd Bergmann 
>
> Reviewed-by: Lubomir Rintel 
>
> In fact, I'd love to see more non-DT boards go from mach-mmp. There are
> good indications nobody is looking after MMP2-based "Jasper", "Flint"
> and "Brownstone" and they probably weren't seen outside Marvell either.
> The latter has a DTS file.
>
> Would anybody miss them?

Probably not, but I had a hard time identifying any boards in mmp
and some other platforms that are actually worth keeping.

Back in the days, a common way the platforms were maintained
was to only have the official development board in mainline Linux,
while many products were left with out of tree board files.
This means it's impossible to see which SoCs actually got used
in the field and which ones did not. It also means the other
machines stopped getting forward-ported and nobody could test
the mainline changes.

I wouldn't mind just removing all of the machines that were clearly
reference hardware rather than actual products unless we know of
someone still using them.

In case of MMP, that doesn't leave a lot though, the gplugD is the
only one that clearly meant as an end-user product. I'd also leave
all the DT based platforms as a rule, mainly because the DT has
made it possible to support additional boards with a custom dt blob
and no kernel changes.

If you have any more insight into what particular boards actually
were used for, and which ones can get removed, that would
be very welcome.

Arnd


Re: [PATCH] Bluetooth: hci_qca: Add delay for wcn3990 stability

2019-10-19 Thread Marcel Holtmann
Hi Matthias,

>> On the msm8998 mtp, the response to the baudrate change command is never
>> received.  On the Lenovo Miix 630, the response to the baudrate change
>> command is corrupted - "Frame reassembly failed (-84)".
>> 
>> Adding a 50ms delay before re-enabling flow to receive the baudrate 
>> change
>> command response from the wcn3990 addesses both issues, and allows
>> bluetooth to become functional.
> 
> From my earlier debugging on sdm845 I don't think this is what happens.
> The problem is that the wcn3990 sends the response to the baudrate change
> command using the new baudrate, while the UART on the SoC still operates
> with the prior speed (for details see 2faa3f15fa2f ("Bluetooth: hci_qca:
> wcn3990: Drop baudrate change vendor event"))
> 
> IIRC the 50ms delay causes the HCI core to discard the received data,
> which is why the "Frame reassembly failed" message disappears, not
> because the response was received. In theory commit 78e8fa2972e5
> ("Bluetooth: hci_qca: Deassert RTS while baudrate change command")
> should have fixed those messages, do you know if CTS/RTS are connected
> on the Bluetooth UART of the Lenovo Miix 630?
 
 I was testing with 5.4-rc1 which contains the indicated RTS fix.
 
 Yes, CTS/RTS are connected on the Lenovo Miix 630.
 
 I added debug statements which indicated that data was received,
 however it was corrupt, and the packet type did not match what was
 expected, hence the frame reassembly errors.
>>> 
>>> Do you know if any data is received during the delay? In theory that
>>> shouldn't be the case since RTS is deasserted, just double-checking.
>> 
>> I don't think so, but I've run so many tests, I'm not 100% positive.
>> Let me go double check and get back to you.
>> 
>>> 
>>> What happens if you add a longer delay (e.g. 1s) before/after setting
>>> the host baudrate?
>> 
>> Hmm, not exactly sure.  I will test.
>> 
>>> 
 In response to this patch, Balakrishna pointed me to a bug report
 which indicated that some of the UART GPIO lines need to have a bias
 applied to prevent errant data from floating lines -
 
 https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1391888
>>> 
>>> Yeah, that was another source of frame reassembly errors that we were
>>> seeing on SDM845.
>>> 
>>> Balakrishna, please post these kind of replies on-list, so that
>>> everybody can benefit from possible solutions or contribute to the
>>> discussion.
>>> 
 It turns out this fix was never applied to msm8998.  Applying the fix
 does cause the the frame reassembly errors to go away, however then
 the host SoC never receives the baud rate change response (I increased
 the timeout from 2faa3f15fa2f ("Bluetooth: hci_qca: wcn3990: Drop
 baudrate change vendor event") to 5 seconds).  As of now, this patch
 is still required.
>>> 
>>> Interesting.
>>> 
>>> FTR, this is the full UART pin configuration for cheza (SDM845):
>>> 
>>> _uart6_default {
>>>/* Change pinmux to all 4 pins since CTS and RTS are connected */
>>>pinmux {
>>>pins = "gpio45", "gpio46",
>>>   "gpio47", "gpio48";
>>>};
>>> 
>>>pinconf-cts {
>>>/*
>>> * Configure a pull-down on 45 (CTS) to match the pull of
>>> * the Bluetooth module.
>>> */
>>>pins = "gpio45";
>>>bias-pull-down;
>>>};
>>> 
>>>pinconf-rts-tx {
>>>/* We'll drive 46 (RTS) and 47 (TX), so no pull */
>>>pins = "gpio46", "gpio47";
>>>drive-strength = <2>;
>>>bias-disable;
>>>};
>>> 
>>>pinconf-rx {
>>>/*
>>> * Configure a pull-up on 48 (RX). This is needed to avoid
>>> * garbage data when the TX pin of the Bluetooth module is
>>> * in tri-state (module powered off or not driving the
>>> * signal yet).
>>> */
>>>pins = "gpio48";
>>>bias-pull-up;
>>>};
>>> };
>>> 
>>> Does this correspond to what you tried on the Lenovo Miix 630?
>> 
>> Which GPIO maps to which pin is different -
>> 45 - TX
>> 46 - RX
>> 47 - CTS
>> 48 - RFR (RTS)
>> 
>> However, accounting for that, yes that corresponds to what I used.
> 
> Thanks for re-confirming.
> 
 I have no idea why the delay is required, and was hoping that posting
 this patch would result in someone else providing some missing pieces
 to determine the real root cause.  I suspect that asserting RTS at the
 wrong time may cause an issue for the wcn3990, but I have no data nor
 documentation to support this guess.  I welcome any further insights
 you may have.
>>> 
>>> Unfortunately I don't have a clear suggestion at this point, 

Re: [PATCH v2] net: ethernet: dwmac-sun8i: show message only when switching to promisc

2019-10-19 Thread David Miller
From: Mans Rullgard 
Date: Fri, 18 Oct 2019 17:56:58 +0100

> Printing the info message every time more than the max number of mac
> addresses are requested generates unnecessary log spam.  Showing it only
> when the hw is not already in promiscous mode is equally informative
> without being annoying.
> 
> Signed-off-by: Mans Rullgard 
> ---
> Changed in v2:
> - test only RXALL bit

Applied, thanks.


Re: [PATCH v2] net: aquantia: add an error handling in aq_nic_set_multicast_list

2019-10-19 Thread David Miller
From: Chen Wandun 
Date: Fri, 18 Oct 2019 18:20:37 +0800

> From: Chenwandun 
> 
> add an error handling in aq_nic_set_multicast_list, it may not
> work when hw_multicast_list_set error; and at the same time
> it will remove gcc Wunused-but-set-variable warning.
> 
> Signed-off-by: Chenwandun 

Applied, thanks.


Re: [PATCH v2] rtlwifi: Fix potential overflow on P2P code

2019-10-19 Thread Laura Abbott

On 10/19/19 6:51 AM, Kalle Valo wrote:

Laura Abbott  writes:


Nicolas Waisman noticed that even though noa_len is checked for
a compatible length it's still possible to overrun the buffers
of p2pinfo since there's no check on the upper bound of noa_num.
Bound noa_num against P2P_MAX_NOA_NUM.

Reported-by: Nicolas Waisman 
Signed-off-by: Laura Abbott 
---
v2: Use P2P_MAX_NOA_NUM instead of erroring out.
---
  drivers/net/wireless/realtek/rtlwifi/ps.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c 
b/drivers/net/wireless/realtek/rtlwifi/ps.c
index 70f04c2f5b17..fff8dda14023 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -754,6 +754,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void 
*data,
return;
} else {
noa_num = (noa_len - 2) / 13;
+   if (noa_num > P2P_MAX_NOA_NUM)
+   noa_num = P2P_MAX_NOA_NUM;
+
}
noa_index = ie[3];
if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode ==
@@ -848,6 +851,9 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void 
*data,
return;
} else {
noa_num = (noa_len - 2) / 13;
+   if (noa_num > P2P_MAX_NOA_NUM)
+   noa_num = P2P_MAX_NOA_NUM;


IMHO using min() would be cleaner, but I'm fine with this as well. Up to
you.



I believe the intention is to re-write this anyway so I'd prefer to
just get this in given the uptick this issue seems to have gotten.

Thanks,
Laura



Re: [PATCH] xen/netback: fix error path of xenvif_connect_data()

2019-10-19 Thread David Miller
From: Juergen Gross 
Date: Fri, 18 Oct 2019 09:45:49 +0200

> xenvif_connect_data() calls module_put() in case of error. This is
> wrong as there is no related module_get().
> 
> Remove the superfluous module_put().
> 
> Fixes: 279f438e36c0a7 ("xen-netback: Don't destroy the netdev until the vif 
> is shut down")
> Signed-off-by: Juergen Gross 
> Reviewed-by: Paul Durrant 

Applied and queued up for -stable.


[PATCH v2 09/11] mmc: core: fix wl1251 sdio quirks

2019-10-19 Thread H. Nikolaus Schaller
wl1251 and wl1271 have different vendor id and device id.
So we need to handle both with sdio quirks.

Fixes: 884f38607897 ("mmc: core: move some sdio IDs out of quirks file")

Signed-off-by: H. Nikolaus Schaller 
Cc:  # 4.11.0
---
 drivers/mmc/core/quirks.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
index 2d2d9ea8be4f..3dba15bccce2 100644
--- a/drivers/mmc/core/quirks.h
+++ b/drivers/mmc/core/quirks.h
@@ -119,7 +119,14 @@ static const struct mmc_fixup mmc_ext_csd_fixups[] = {
END_FIXUP
 };
 
+
 static const struct mmc_fixup sdio_fixup_methods[] = {
+   SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251,
+  add_quirk, MMC_QUIRK_NONSTD_FUNC_IF),
+
+   SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251,
+  add_quirk, MMC_QUIRK_DISABLE_CD),
+
SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271,
   add_quirk, MMC_QUIRK_NONSTD_FUNC_IF),
 
-- 
2.19.1



[PATCH v2 08/11] mmc: sdio: fix wl1251 vendor id

2019-10-19 Thread H. Nikolaus Schaller
v4.11-rc1 did introduce a patch series that rearranged the
sdio quirks into a header file. Unfortunately this did forget
to handle SDIO_VENDOR_ID_TI differently between wl1251 and
wl1271 with the result that although the wl1251 was found on
the sdio bus, the firmware did not load any more and there was
no interface registration.

This patch defines separate constants to be used by sdio quirks
and drivers.

Fixes: 884f38607897 ("mmc: core: move some sdio IDs out of quirks file")

Signed-off-by: H. Nikolaus Schaller 
Cc:  # 4.11.0
---
 include/linux/mmc/sdio_ids.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
index d1a5d5df02f5..08b25c02b5a1 100644
--- a/include/linux/mmc/sdio_ids.h
+++ b/include/linux/mmc/sdio_ids.h
@@ -71,6 +71,8 @@
 
 #define SDIO_VENDOR_ID_TI  0x0097
 #define SDIO_DEVICE_ID_TI_WL1271   0x4076
+#define SDIO_VENDOR_ID_TI_WL1251   0x104c
+#define SDIO_DEVICE_ID_TI_WL1251   0x9066
 
 #define SDIO_VENDOR_ID_STE 0x0020
 #define SDIO_DEVICE_ID_STE_CW1200  0x2280
-- 
2.19.1



[PATCH v2 04/11] mmc: host: omap_hsmmc: add code for special init of wl1251 to get rid of pandora_wl1251_init_card

2019-10-19 Thread H. Nikolaus Schaller
Pandora_wl1251_init_card was used to do special pdata based
setup of the sdio mmc interface. This does no longer work with
v4.7 and later. A fix requires a device tree based mmc3 setup.

Therefore we move the special setup to omap_hsmmc.c instead
of calling some pdata supplied init_card function.

The new code checks for a DT child node compatible to wl1251
so it will not affect other MMC3 use cases.

Fixes: 81eef6ca9201 ("mmc: omap_hsmmc: Use dma_request_chan() for requesting 
DMA channel")

Signed-off-by: H. Nikolaus Schaller 
Cc:  # 4.7.0
---
 drivers/mmc/host/omap_hsmmc.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 952fa4063ff8..03ba80bcf319 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1512,6 +1512,27 @@ static void omap_hsmmc_init_card(struct mmc_host *mmc, 
struct mmc_card *card)
 
if (mmc_pdata(host)->init_card)
mmc_pdata(host)->init_card(card);
+   else if (card->type == MMC_TYPE_SDIO || card->type == 
MMC_TYPE_SD_COMBO) {
+   struct device_node *np = mmc_dev(mmc)->of_node;
+
+   np = of_get_compatible_child(np, "ti,wl1251");
+   if (np) {
+   /*
+* We have TI wl1251 attached to MMC3. Pass this 
information to
+* SDIO core because it can't be probed by normal 
methods.
+*/
+
+   dev_info(host->dev, "found wl1251\n");
+   card->quirks |= MMC_QUIRK_NONSTD_SDIO;
+   card->cccr.wide_bus = 1;
+   card->cis.vendor = 0x104c;
+   card->cis.device = 0x9066;
+   card->cis.blksize = 512;
+   card->cis.max_dtr = 2400;
+   card->ocr = 0x80;
+   of_node_put(np);
+   }
+   }
 }
 
 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
-- 
2.19.1



[PATCH v2 01/11] Documentation: dt: wireless: update wl1251 for sdio

2019-10-19 Thread H. Nikolaus Schaller
The standard method for sdio devices connected to
an sdio interface is to define them as a child node
like we can see with wlcore.

Signed-off-by: H. Nikolaus Schaller 
Acked-by: Kalle Valo 
---
 .../bindings/net/wireless/ti,wl1251.txt   | 26 +++
 1 file changed, 26 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt 
b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
index bb2fcde6f7ff..88612ff29f2d 100644
--- a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
+++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
@@ -35,3 +35,29 @@ Examples:
ti,power-gpio = < 23 GPIO_ACTIVE_HIGH>; /* 87 */
};
 };
+
+ {
+   vmmc-supply = <_en>;
+
+   bus-width = <4>;
+   non-removable;
+   ti,non-removable;
+   cap-power-off-card;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   wlan: wl1251@1 {
+   compatible = "ti,wl1251";
+
+   reg = <1>;
+
+   interrupt-parent = <>;
+   interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;  /* GPIO_21 */
+
+   ti,wl1251-has-eeprom;
+   };
+};
-- 
2.19.1



[PATCH v2 07/11] omap: remove old hsmmc.[ch] and in Makefile

2019-10-19 Thread H. Nikolaus Schaller
There is a new one in drivers/mmc/host/omap_hsmmc.c
configured by CONFIG_MMC_OMAP_HS and the last user
was the pdata-quirks for pandora.

Suggested-by: Tony Lindgren 
Signed-off-by: H. Nikolaus Schaller 
---
 arch/arm/mach-omap2/Makefile   |   1 -
 arch/arm/mach-omap2/hsmmc.c| 171 -
 arch/arm/mach-omap2/hsmmc.h|  32 --
 arch/arm/mach-omap2/pdata-quirks.c |   1 -
 4 files changed, 205 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/hsmmc.c
 delete mode 100644 arch/arm/mach-omap2/hsmmc.h

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 8f208197988f..1b3062f32899 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -216,7 +216,6 @@ obj-$(CONFIG_MACH_NOKIA_N8X0)   += board-n8x0.o
 
 # Platform specific device init code
 
-omap-hsmmc-$(CONFIG_MMC_OMAP_HS)   := hsmmc.o
 obj-y  += $(omap-hsmmc-m) $(omap-hsmmc-y)
 
 obj-y  += omap_phy_internal.o
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
deleted file mode 100644
index 63423ea6a240..
--- a/arch/arm/mach-omap2/hsmmc.c
+++ /dev/null
@@ -1,171 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * linux/arch/arm/mach-omap2/hsmmc.c
- *
- * Copyright (C) 2007-2008 Texas Instruments
- * Copyright (C) 2008 Nokia Corporation
- * Author: Texas Instruments
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "soc.h"
-#include "omap_device.h"
-
-#include "hsmmc.h"
-#include "control.h"
-
-#if IS_ENABLED(CONFIG_MMC_OMAP_HS)
-
-static u16 control_pbias_offset;
-static u16 control_devconf1_offset;
-
-#define HSMMC_NAME_LEN 9
-
-static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
-   struct omap_hsmmc_platform_data *mmc)
-{
-   char *hc_name;
-
-   hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL);
-   if (!hc_name)
-   return -ENOMEM;
-
-   snprintf(hc_name, (HSMMC_NAME_LEN + 1), "mmc%islot%i", c->mmc, 1);
-   mmc->name = hc_name;
-   mmc->caps = c->caps;
-   mmc->reg_offset = 0;
-
-   return 0;
-}
-
-static int omap_hsmmc_done;
-
-void omap_hsmmc_late_init(struct omap2_hsmmc_info *c)
-{
-   struct platform_device *pdev;
-   int res;
-
-   if (omap_hsmmc_done)
-   return;
-
-   omap_hsmmc_done = 1;
-
-   for (; c->mmc; c++) {
-   pdev = c->pdev;
-   if (!pdev)
-   continue;
-   res = omap_device_register(pdev);
-   if (res)
-   pr_err("Could not late init MMC\n");
-   }
-}
-
-#define MAX_OMAP_MMC_HWMOD_NAME_LEN16
-
-static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
-   int ctrl_nr)
-{
-   struct omap_hwmod *oh;
-   struct omap_hwmod *ohs[1];
-   struct omap_device *od;
-   struct platform_device *pdev;
-   char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
-   struct omap_hsmmc_platform_data *mmc_data;
-   struct omap_hsmmc_dev_attr *mmc_dev_attr;
-   char *name;
-   int res;
-
-   mmc_data = kzalloc(sizeof(*mmc_data), GFP_KERNEL);
-   if (!mmc_data)
-   return;
-
-   res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
-   if (res < 0)
-   goto free_mmc;
-
-   name = "omap_hsmmc";
-   res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
-"mmc%d", ctrl_nr);
-   WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
-"String buffer overflow in MMC%d device setup\n", ctrl_nr);
-
-   oh = omap_hwmod_lookup(oh_name);
-   if (!oh) {
-   pr_err("Could not look up %s\n", oh_name);
-   goto free_name;
-   }
-   ohs[0] = oh;
-   if (oh->dev_attr != NULL) {
-   mmc_dev_attr = oh->dev_attr;
-   mmc_data->controller_flags = mmc_dev_attr->flags;
-   }
-
-   pdev = platform_device_alloc(name, ctrl_nr - 1);
-   if (!pdev) {
-   pr_err("Could not allocate pdev for %s\n", name);
-   goto free_name;
-   }
-   dev_set_name(>dev, "%s.%d", pdev->name, pdev->id);
-
-   od = omap_device_alloc(pdev, ohs, 1);
-   if (IS_ERR(od)) {
-   pr_err("Could not allocate od for %s\n", name);
-   goto put_pdev;
-   }
-
-   res = platform_device_add_data(pdev, mmc_data,
- sizeof(struct omap_hsmmc_platform_data));
-   if (res) {
-   pr_err("Could not add pdata for %s\n", name);
-   goto put_pdev;
-   }
-
-   hsmmcinfo->pdev = pdev;
-
-   res = omap_device_register(pdev);
-   if (res) {
-   pr_err("Could not register od for %s\n", name);
-   goto free_od;
-   }
-
-   goto free_mmc;
-
-free_od:
-   

[PATCH v2 03/11] DTS: ARM: pandora-common: define wl1251 as child node of mmc3

2019-10-19 Thread H. Nikolaus Schaller
Since v4.7 the dma initialization requires that there is a
device tree property for "rx" and "tx" channels which is
not provided by the pdata-quirks initialization.

By conversion of the mmc3 setup to device tree this will
finally allows to remove the OpenPandora wlan specific omap3
data-quirks.

Fixes: 81eef6ca9201 ("mmc: omap_hsmmc: Use dma_request_chan() for requesting 
DMA channel")

Signed-off-by: H. Nikolaus Schaller 
Cc:  # 4.7.0
---
 arch/arm/boot/dts/omap3-pandora-common.dtsi | 37 +++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-pandora-common.dtsi 
b/arch/arm/boot/dts/omap3-pandora-common.dtsi
index ec5891718ae6..c595b3eb314d 100644
--- a/arch/arm/boot/dts/omap3-pandora-common.dtsi
+++ b/arch/arm/boot/dts/omap3-pandora-common.dtsi
@@ -226,6 +226,18 @@
gpio = < 4 GPIO_ACTIVE_HIGH>; /* GPIO_164 */
};
 
+   /* wl1251 wifi+bt module */
+   wlan_en: fixed-regulator-wg7210_en {
+   compatible = "regulator-fixed";
+   regulator-name = "vwlan";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   startup-delay-us = <5>;
+   regulator-always-on;
+   enable-active-high;
+   gpio = < 23 GPIO_ACTIVE_HIGH>;
+   };
+
/* wg7210 (wifi+bt module) 32k clock buffer */
wg7210_32k: fixed-regulator-wg7210_32k {
compatible = "regulator-fixed";
@@ -522,9 +534,30 @@
/*wp-gpios = < 31 GPIO_ACTIVE_HIGH>;*//* GPIO_127 */
 };
 
-/* mmc3 is probed using pdata-quirks to pass wl1251 card data */
  {
-   status = "disabled";
+   vmmc-supply = <_en>;
+
+   bus-width = <4>;
+   non-removable;
+   ti,non-removable;
+   cap-power-off-card;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   wlan: wl1251@1 {
+   compatible = "ti,wl1251";
+
+   reg = <1>;
+
+   interrupt-parent = <>;
+   interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;  /* GPIO_21 */
+
+   ti,wl1251-has-eeprom;
+   };
 };
 
 /* bluetooth*/
-- 
2.19.1



[PATCH v2 02/11] net: wireless: ti: wl1251 add device tree support

2019-10-19 Thread H. Nikolaus Schaller
We will have the wl1251 defined as a child node of the mmc interface
and can read setup for gpios, interrupts and the ti,use-eeprom
property from there instead of pdata to be provided by pdata-quirks.

Fixes: 81eef6ca9201 ("mmc: omap_hsmmc: Use dma_request_chan() for requesting 
DMA channel")

Signed-off-by: H. Nikolaus Schaller 
Acked-by: Kalle Valo 
---
 drivers/net/wireless/ti/wl1251/sdio.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ti/wl1251/sdio.c 
b/drivers/net/wireless/ti/wl1251/sdio.c
index 677f1146ccf0..c54a273713ed 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -16,6 +16,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "wl1251.h"
 
@@ -217,6 +220,7 @@ static int wl1251_sdio_probe(struct sdio_func *func,
struct ieee80211_hw *hw;
struct wl1251_sdio *wl_sdio;
const struct wl1251_platform_data *wl1251_board_data;
+   struct device_node *np = func->dev.of_node;
 
hw = wl1251_alloc_hw();
if (IS_ERR(hw))
@@ -248,6 +252,15 @@ static int wl1251_sdio_probe(struct sdio_func *func,
wl->power_gpio = wl1251_board_data->power_gpio;
wl->irq = wl1251_board_data->irq;
wl->use_eeprom = wl1251_board_data->use_eeprom;
+   } else if (np) {
+   wl->use_eeprom =of_property_read_bool(np, 
"ti,wl1251-has-eeprom");
+   wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0);
+   wl->irq = of_irq_get(np, 0);
+
+   if (wl->power_gpio == -EPROBE_DEFER || wl->irq == 
-EPROBE_DEFER) {
+   ret = -EPROBE_DEFER;
+   goto disable;
+   }
}
 
if (gpio_is_valid(wl->power_gpio)) {
-- 
2.19.1



Re: [PATCH net] net: hns3: fix mis-counting IRQ vector numbers issue

2019-10-19 Thread David Miller
From: Huazhong Tan 
Date: Fri, 18 Oct 2019 11:42:59 +0800

> From: Yonglong Liu 
> 
> Currently, the num_msi_left means the vector numbers of NIC,
> but if the PF supported RoCE, it contains the vector numbers
> of NIC and RoCE(Not expected).
> 
> This may cause interrupts lost in some case, because of the
> NIC module used the vector resources which belongs to RoCE.
> 
> This patch adds a new variable num_nic_msi to store the vector
> numbers of NIC, and adjust the default TQP numbers and rss_size
> according to the value of num_nic_msi.
> 
> Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility 
> Layer Support")
> Signed-off-by: Yonglong Liu 
> Signed-off-by: Huazhong Tan 

Applied, thanks.


[PATCH v2 10/11] net: wireless: ti: wl1251 use new SDIO_VENDOR_ID_TI_WL1251 definition

2019-10-19 Thread H. Nikolaus Schaller
SDIO_VENDOR_ID_TI_WL1251 is now defined in mmc/sdio_ids.h separately
from SDIO_VENDOR_ID_TI for wl1271.

Fixes: 884f38607897 ("mmc: core: move some sdio IDs out of quirks file")

Signed-off-by: H. Nikolaus Schaller 
Acked-by: Kalle Valo 
Cc:  # 4.11.0
---
 drivers/net/wireless/ti/wl1251/sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ti/wl1251/sdio.c 
b/drivers/net/wireless/ti/wl1251/sdio.c
index c54a273713ed..42b55f3a50df 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -52,7 +52,7 @@ static void wl1251_sdio_interrupt(struct sdio_func *func)
 }
 
 static const struct sdio_device_id wl1251_devices[] = {
-   { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1251) },
+   { SDIO_DEVICE(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251) },
{}
 };
 MODULE_DEVICE_TABLE(sdio, wl1251_devices);
-- 
2.19.1



[PATCH v2 00/11] OpenPandora: make wl1251 connected to mmc3 sdio port of OpenPandora work again

2019-10-19 Thread H. Nikolaus Schaller


* added acked-by for wl1251 patches - Kalle Valo 
* really removed old pdata-quirks code (not through #if 0)
* splited out a partial revert of
efdfeb079cc3b ("regulator: fixed: Convert to use GPIO descriptor only")
  because that was introduced after v4.19 and stops the removal of
  the pdata-quirks patch from cleanly applying to v4.9, v4.14, v4.19
  - reported by Sasha Levin 
* added a new patch to remove old omap hsmmc since pdata quirks
  were last user - suggested by Tony Lindgren 

PATCH V1 2019-10-18 22:25:39:

Here we have a set of scattered patches to make the OpenPandora WiFi work again.

v4.7 did break the pdata-quirks which made the mmc3 interface
fail completely, because some code now assumes device tree
based instantiation.

Fixes: 81eef6ca9201 ("mmc: omap_hsmmc: Use dma_request_chan() for requesting 
DMA channel")

v4.11 did break the sdio qirks for wl1251 which made the driver no longer
load, although the device was found as an sdio client.

Fixes: 884f38607897 ("mmc: core: move some sdio IDs out of quirks file")

To solve these issues:
* we convert mmc3 and wl1251 initialization from pdata-quirks
  to device tree
* we make the wl1251 driver read properties from device tree
* we fix the mmc core vendor ids and quirks
* we fix the wl1251 (and wl1271) driver to use only vendor ids
  from header file instead of (potentially conflicting) local
  definitions


H. Nikolaus Schaller (11):
  Documentation: dt: wireless: update wl1251 for sdio
  net: wireless: ti: wl1251 add device tree support
  DTS: ARM: pandora-common: define wl1251 as child node of mmc3
  mmc: host: omap_hsmmc: add code for special init of wl1251 to get rid
of pandora_wl1251_init_card
  omap: pdata-quirks: revert pandora specific gpiod additions
  omap: pdata-quirks: remove openpandora quirks for mmc3 and wl1251
  omap: remove old hsmmc.[ch] and in Makefile
  mmc: sdio: fix wl1251 vendor id
  mmc: core: fix wl1251 sdio quirks
  net: wireless: ti: wl1251 use new SDIO_VENDOR_ID_TI_WL1251 definition
  net: wireless: ti: remove local VENDOR_ID and DEVICE_ID definitions

 .../bindings/net/wireless/ti,wl1251.txt   |  26 +++
 arch/arm/boot/dts/omap3-pandora-common.dtsi   |  37 +++-
 arch/arm/mach-omap2/Makefile  |   1 -
 arch/arm/mach-omap2/hsmmc.c   | 171 --
 arch/arm/mach-omap2/hsmmc.h   |  32 
 arch/arm/mach-omap2/pdata-quirks.c| 105 ---
 drivers/mmc/core/quirks.h |   7 +
 drivers/mmc/host/omap_hsmmc.c |  21 +++
 drivers/net/wireless/ti/wl1251/sdio.c |  23 ++-
 drivers/net/wireless/ti/wlcore/sdio.c |   8 -
 include/linux/mmc/sdio_ids.h  |   2 +
 11 files changed, 105 insertions(+), 328 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/hsmmc.c
 delete mode 100644 arch/arm/mach-omap2/hsmmc.h

-- 
2.19.1



  1   2   3   >