History

Merge tag 'char-misc-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc updates from Greg KH: "Here is the big set of char/misc driver patches for 4.17-rc1. There are a lot of little things in here, nothing huge, but all important to the different hardware types involved: - thunderbolt driver updates - parport updates (people still care...) - nvmem driver updates - mei updates (as always) - hwtracing driver updates - hyperv driver updates - extcon driver updates - ... and a handful of even smaller driver subsystem and individual driver updates All of these have been in linux-next with no reported issues" * tag 'char-misc-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (149 commits) hwtracing: Add HW tracing support menu intel_th: Add ACPI glue layer intel_th: Allow forcing host mode through drvdata intel_th: Pick up irq number from resources intel_th: Don't touch switch routing in host mode intel_th: Use correct method of finding hub intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate stm class: Make dummy's master/channel ranges configurable stm class: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate MAINTAINERS: Bestow upon myself the care for drivers/hwtracing hv: add SPDX license id to Kconfig hv: add SPDX license to trace Drivers: hv: vmbus: do not mark HV_PCIE as perf_device Drivers: hv: vmbus: respect what we get from hv_get_synint_state() /dev/mem: Avoid overwriting "err" in read_mem() eeprom: at24: use SPDX identifier instead of GPL boiler-plate eeprom: at24: simplify the i2c functionality checking eeprom: at24: fix a line break eeprom: at24: tweak newlines eeprom: at24: refactor at24_probe() ...

Linus Torvalds committed 8 years ago

Commit 06dd3df2 parents 38047d5 86f690e141 files · +3377 −1207Browse files

Unified · Split

141 files
  1. Documentation/ABI/stable/sysfs-bus-vmbus +7 −0
  2. Documentation/ABI/testing/sysfs-bus-thunderbolt +33 −0
  3. Documentation/ABI/testing/sysfs-class-mei +9 −0
  4. Documentation/ABI/testing/sysfs-driver-fsi-master-gpio +10 −0
  5. Documentation/admin-guide/thunderbolt.rst +10 −5
  6. Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt +49 −0
  7. Documentation/devicetree/bindings/connector/usb-connector.txt +75 −0
  8. Documentation/devicetree/bindings/fsi/fsi.txt +151 −0
  9. Documentation/devicetree/bindings/mfd/aspeed-lpc.txt +41 −0
  10. Documentation/devicetree/bindings/nvmem/imx-ocotp.txt +19 −4
  11. Documentation/devicetree/bindings/nvmem/snvs-lpgpr.txt +2 −1
  12. Documentation/driver-api/uio-howto.rst +5 −0
  13. MAINTAINERS +6 −1
  14. arch/x86/entry/entry_32.S +3 −0
  15. arch/x86/entry/entry_64.S +3 −0
  16. arch/x86/include/asm/hardirq.h +1 −0
  17. arch/x86/include/asm/irq_vectors.h +2 −1
  18. arch/x86/include/asm/mshyperv.h +13 −0
  19. arch/x86/include/uapi/asm/hyperv.h +3 −0
  20. arch/x86/kernel/cpu/mshyperv.c +40 −0
  21. arch/x86/kernel/irq.c +7 −0
  22. block/genhd.c +11 −8
  23. drivers/Kconfig +1 −3
  24. drivers/char/Kconfig +1 −1
  25. drivers/char/mem.c +3 −3
  26. drivers/char/xillybus/xillybus_pcie.c +0 −1
  27. drivers/extcon/extcon-gpio.c +45 −58
  28. drivers/extcon/extcon-intel-cht-wc.c +7 −4
  29. drivers/extcon/extcon-intel-int3496.c +5 −4
  30. drivers/extcon/extcon.c +34 −10
  31. drivers/fpga/altera-cvp.c +0 −2
  32. drivers/fsi/Kconfig +1 −0
  33. drivers/fsi/fsi-core.c +120 −9
  34. drivers/fsi/fsi-master-gpio.c +87 −2
  35. drivers/fsi/fsi-master-hub.c +23 −4
  36. drivers/fsi/fsi-master.h +17 −0
  37. drivers/gpu/drm/bridge/sil-sii8620.c +94 −3
  38. drivers/hv/Kconfig +2 −0
  39. drivers/hv/Makefile +1 −0
  40. drivers/hv/channel_mgmt.c +3 −5
  41. drivers/hv/hv.c +58 −6
  42. drivers/hv/hv_balloon.c +83 −38
  43. drivers/hv/hv_trace.c +2 −0
  44. drivers/hv/hv_trace.h +2 −0
  45. drivers/hv/hv_trace_balloon.h +48 −0
  46. drivers/hv/hyperv_vmbus.h +3 −1
  47. drivers/hwtracing/Kconfig +7 −0
  48. drivers/hwtracing/coresight/coresight-cpu-debug.c +1 −1
  49. drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +2 −2
  50. drivers/hwtracing/intel_th/Kconfig +12 −0
  51. drivers/hwtracing/intel_th/Makefile +3 −0
  52. drivers/hwtracing/intel_th/acpi.c +79 −0
  53. drivers/hwtracing/intel_th/core.c +18 −13
  54. drivers/hwtracing/intel_th/debug.c +1 −9
  55. drivers/hwtracing/intel_th/debug.h +1 −9
  56. drivers/hwtracing/intel_th/gth.c +1 −9
  57. drivers/hwtracing/intel_th/gth.h +1 −9
  58. drivers/hwtracing/intel_th/intel_th.h +4 −10
  59. drivers/hwtracing/intel_th/msu.c +1 −9
  60. drivers/hwtracing/intel_th/msu.h +1 −9
  61. drivers/hwtracing/intel_th/pci.c +1 −9
  62. drivers/hwtracing/intel_th/pti.c +1 −9
  63. drivers/hwtracing/intel_th/pti.h +1 −9
  64. drivers/hwtracing/intel_th/sth.c +1 −9
  65. drivers/hwtracing/intel_th/sth.h +1 −9
  66. drivers/hwtracing/stm/console.c +1 −9
  67. drivers/hwtracing/stm/core.c +1 −9
  68. drivers/hwtracing/stm/dummy_stm.c +22 −12
  69. drivers/hwtracing/stm/heartbeat.c +1 −9
  70. drivers/hwtracing/stm/policy.c +1 −9
  71. drivers/hwtracing/stm/stm.h +1 −9
  72. drivers/mcb/mcb-pci.c +1 −0
  73. drivers/misc/Kconfig +0 −1
  74. drivers/misc/Makefile +1 −19
  75. drivers/misc/aspeed-lpc-ctrl.c +39 −5
  76. drivers/misc/cardreader/rts5260.c +6 −6
  77. drivers/misc/eeprom/at24.c +156 −137
  78. drivers/misc/eeprom/at25.c +1 −1
  79. drivers/misc/lkdtm/Makefile +20 −0
  80. drivers/misc/lkdtm/bugs.c +0 −0
  81. drivers/misc/lkdtm/core.c +0 −0
  82. drivers/misc/lkdtm/heap.c +0 −0
  83. drivers/misc/lkdtm/lkdtm.h +0 −0
  84. drivers/misc/lkdtm/perms.c +0 −0
  85. drivers/misc/lkdtm/refcount.c +1 −0
  86. drivers/misc/lkdtm/rodata.c +0 −0
  87. drivers/misc/lkdtm/usercopy.c +0 −0
  88. drivers/misc/mei/bus.c +51 −32
  89. drivers/misc/mei/client.c +50 −37
  90. drivers/misc/mei/debugfs.c +4 −3
  91. drivers/misc/mei/init.c +1 −0
  92. drivers/misc/mei/main.c +65 −1
  93. drivers/misc/mei/mei_dev.h +8 −2
  94. drivers/misc/mic/bus/vop_bus.c +4 −2
  95. drivers/misc/ocxl/pci.c +1 −1
  96. drivers/nvmem/Kconfig +2 −2
  97. drivers/nvmem/bcm-ocotp.c +2 −13
  98. drivers/nvmem/core.c +67 −3
  99. drivers/nvmem/imx-iim.c +3 −15
  100. drivers/nvmem/imx-ocotp.c +2 −16
  101. drivers/nvmem/lpc18xx_otp.c +2 −14
  102. drivers/nvmem/meson-efuse.c +2 −14
  103. drivers/nvmem/meson-mx-efuse.c +2 −14
  104. drivers/nvmem/mtk-efuse.c +2 −14
  105. drivers/nvmem/qfprom.c +2 −14
  106. drivers/nvmem/rockchip-efuse.c +10 −22
  107. drivers/nvmem/snvs_lpgpr.c +28 −25
  108. drivers/nvmem/sunxi_sid.c +50 −21
  109. drivers/nvmem/uniphier-efuse.c +2 −14
  110. drivers/nvmem/vf610-ocotp.c +5 −19
  111. drivers/parport/parport_ax88796.c +3 −5
  112. drivers/parport/parport_pc.c +4 −0
  113. drivers/parport/parport_serial.c +46 −76
  114. drivers/pps/clients/pps_parport.c +18 −3
  115. drivers/pps/generators/pps_gen_parport.c +9 −3
  116. drivers/siox/siox-core.c +1 −1
  117. drivers/slimbus/core.c +1 −1
  118. drivers/thunderbolt/dma_port.c +13 −15
  119. drivers/thunderbolt/domain.c +129 −1
  120. drivers/thunderbolt/icm.c +685 −79
  121. drivers/thunderbolt/nhi.c +4 −1
  122. drivers/thunderbolt/nhi.h +5 −0
  123. drivers/thunderbolt/switch.c +60 −1
  124. drivers/thunderbolt/tb.h +14 −0
  125. drivers/thunderbolt/tb_msgs.h +179 −1
  126. drivers/thunderbolt/xdomain.c +35 −12
  127. drivers/uio/uio_hv_generic.c +89 −0
  128. drivers/w1/w1.c +1 −0
  129. fs/char_dev.c +5 −5
  130. include/linux/extcon.h +6 −0
  131. include/linux/extcon/extcon-gpio.h +0 −47
  132. include/linux/hyperv.h +1 −1
  133. include/linux/nvmem-provider.h +42 −0
  134. include/linux/pci_ids.h +2 −0
  135. include/linux/stm.h +1 −9
  136. include/linux/thunderbolt.h +19 −0
  137. include/uapi/linux/stm.h +4 −9
  138. lib/devres.c +38 −40
  139. tools/hv/hv_fcopy_daemon.c +3 −1
  140. tools/hv/hv_kvp_daemon.c +65 −73
  141. tools/hv/hv_vss_daemon.c +1 −0
Documentation/ABI/stable/sysfs-bus-vmbus+7−0
@@ -132,3 +132,10 @@ KernelVersion: 4.16 · 131 unmodified lines
132132 Contact: Stephen Hemminger <sthemmin@microsoft.com>
133133 Description: Monitor bit associated with channel
134134 Users: Debugging tools and userspace drivers
135+
136+What: /sys/bus/vmbus/devices/vmbus_*/channels/NN/ring
137+Date: January. 2018
138+KernelVersion: 4.16
139+Contact: Stephen Hemminger <sthemmin@microsoft.com>
140+Description: Binary file created by uio_hv_generic for ring buffer
141+Users: Userspace drivers
Documentation/ABI/testing/sysfs-bus-thunderbolt+33−0
@@ -1,3 +1,26 @@
1+What: /sys/bus/thunderbolt/devices/.../domainX/boot_acl
2+Date: Jun 2018
3+KernelVersion: 4.17
4+Contact: thunderbolt-software@lists.01.org
5+Description: Holds a comma separated list of device unique_ids that
6+ are allowed to be connected automatically during system
7+ startup (e.g boot devices). The list always contains
8+ maximum supported number of unique_ids where unused
9+ entries are empty. This allows the userspace software
10+ to determine how many entries the controller supports.
11+ If there are multiple controllers, each controller has
12+ its own ACL list and size may be different between the
13+ controllers.
14+
15+ System BIOS may have an option "Preboot ACL" or similar
16+ that needs to be selected before this list is taken into
17+ consideration.
18+
19+ Software always updates a full list in each write.
20+
21+ If a device is authorized automatically during boot its
22+ boot attribute is set to 1.
23+
124 What: /sys/bus/thunderbolt/devices/.../domainX/security
225 Date: Sep 2017
326 KernelVersion: 4.13
@@ -12,6 +35,9 @@ Description: This attribute holds current Thunderbolt security level · 8 unmodified lines
1235 minimum. User needs to authorize each device.
1336 dponly: Automatically tunnel Display port (and USB). No
1437 PCIe tunnels are created.
38+ usbonly: Automatically tunnel USB controller of the
39+ connected Thunderbolt dock (and Display Port). All
40+ PCIe links downstream of the dock are removed.
1541
1642 What: /sys/bus/thunderbolt/devices/.../authorized
1743 Date: Sep 2017
@@ -38,6 +64,13 @@ Description: This attribute is used to authorize Thunderbolt devices · 20 unmodified lines
3864 the device did not contain a key at all, and
3965 EKEYREJECTED if the challenge response did not match.
4066
67+What: /sys/bus/thunderbolt/devices/.../boot
68+Date: Jun 2018
69+KernelVersion: 4.17
70+Contact: thunderbolt-software@lists.01.org
71+Description: This attribute contains 1 if Thunderbolt device was already
72+ authorized on boot and 0 otherwise.
73+
4174 What: /sys/bus/thunderbolt/devices/.../key
4275 Date: Sep 2017
4376 KernelVersion: 4.13
Documentation/ABI/testing/sysfs-class-mei+9−0
@@ -45,3 +45,12 @@ Contact: Tomas Winkler <tomas.winkler@intel.com> · 44 unmodified lines
4545 Description: Display the driver HBM protocol version.
4646
4747 The HBM protocol version supported by the driver.
48+
49+What: /sys/class/mei/meiN/tx_queue_limit
50+Date: Jan 2018
51+KernelVersion: 4.16
52+Contact: Tomas Winkler <tomas.winkler@intel.com>
53+Description: Configure tx queue limit
54+
55+ Set maximal number of pending writes
56+ per opened session.
Documentation/ABI/testing/sysfs-driver-fsi-master-gpio+10−0
@@ -0,0 +1,10 @@
1+What: /sys/bus/platform/devices/[..]/fsi-master-gpio/external_mode
2+Date: Feb 2018
3+KernelVersion: 4.17
4+Contact: jk@ozlabs.org
5+Description:
6+ Controls access arbitration for GPIO-based FSI master. A
7+ value of 0 (the default) sets normal mode, where the
8+ driver performs FSI bus transactions, 1 sets external mode,
9+ where the FSI bus is driven externally (for example, by
10+ a debug device).
Documentation/admin-guide/thunderbolt.rst+10−5
@@ -21,11 +21,11 @@ vulnerable to DMA attacks. · 20 unmodified lines
2121 Security levels and how to use them
2222 -----------------------------------
2323 Starting with Intel Falcon Ridge Thunderbolt controller there are 4
24−security levels available. The reason for these is the fact that the
25−connected devices can be DMA masters and thus read contents of the host
26−memory without CPU and OS knowing about it. There are ways to prevent
27−this by setting up an IOMMU but it is not always available for various
28−reasons.
24+security levels available. Intel Titan Ridge added one more security level
25+(usbonly). The reason for these is the fact that the connected devices can
26+be DMA masters and thus read contents of the host memory without CPU and OS
27+knowing about it. There are ways to prevent this by setting up an IOMMU but
28+it is not always available for various reasons.
2929
3030 The security levels are as follows:
3131
@@ -52,6 +52,11 @@ The security levels are as follows: · 20 unmodified lines
5252 USB. No PCIe tunneling is done. In BIOS settings this is
5353 typically called *Display Port Only*.
5454
55+ usbonly
56+ The firmware automatically creates tunnels for the USB controller and
57+ Display Port in a dock. All PCIe links downstream of the dock are
58+ removed.
59+
5560 The current security level can be read from
5661 ``/sys/bus/thunderbolt/devices/domainX/security`` where ``domainX`` is
5762 the Thunderbolt domain the host controller manages. There is typically
Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt+49−0
@@ -0,0 +1,49 @@
1+Samsung micro-USB 11-pin connector
2+==================================
3+
4+Samsung micro-USB 11-pin connector is an extension of micro-USB connector.
5+It is present in multiple Samsung mobile devices.
6+It has additional pins to route MHL traffic simultanously with USB.
7+
8+The bindings are superset of usb-connector bindings for micro-USB connector[1].
9+
10+Required properties:
11+- compatible: must be: "samsung,usb-connector-11pin", "usb-b-connector",
12+- type: must be "micro".
13+
14+Required nodes:
15+- any data bus to the connector should be modeled using the OF graph bindings
16+ specified in bindings/graph.txt, unless the bus is between parent node and
17+ the connector. Since single connector can have multpile data buses every bus
18+ has assigned OF graph port number as follows:
19+ 0: High Speed (HS),
20+ 3: Mobile High-Definition Link (MHL), specific to 11-pin Samsung micro-USB.
21+
22+[1]: bindings/connector/usb-connector.txt
23+
24+Example
25+-------
26+
27+Micro-USB connector with HS lines routed via controller (MUIC) and MHL lines
28+connected to HDMI-MHL bridge (sii8620):
29+
30+muic-max77843@66 {
31+ ...
32+ usb_con: connector {
33+ compatible = "samsung,usb-connector-11pin", "usb-b-connector";
34+ label = "micro-USB";
35+ type = "micro";
36+
37+ ports {
38+ #address-cells = <1>;
39+ #size-cells = <0>;
40+
41+ port@3 {
42+ reg = <3>;
43+ usb_con_mhl: endpoint {
44+ remote-endpoint = <&sii8620_mhl>;
45+ };
46+ };
47+ };
48+ };
49+};
Documentation/devicetree/bindings/connector/usb-connector.txt+75−0
@@ -0,0 +1,75 @@
1+USB Connector
2+=============
3+
4+USB connector node represents physical USB connector. It should be
5+a child of USB interface controller.
6+
7+Required properties:
8+- compatible: describes type of the connector, must be one of:
9+ "usb-a-connector",
10+ "usb-b-connector",
11+ "usb-c-connector".
12+
13+Optional properties:
14+- label: symbolic name for the connector,
15+- type: size of the connector, should be specified in case of USB-A, USB-B
16+ non-fullsize connectors: "mini", "micro".
17+
18+Required nodes:
19+- any data bus to the connector should be modeled using the OF graph bindings
20+ specified in bindings/graph.txt, unless the bus is between parent node and
21+ the connector. Since single connector can have multpile data buses every bus
22+ has assigned OF graph port number as follows:
23+ 0: High Speed (HS), present in all connectors,
24+ 1: Super Speed (SS), present in SS capable connectors,
25+ 2: Sideband use (SBU), present in USB-C.
26+
27+Examples
28+--------
29+
30+1. Micro-USB connector with HS lines routed via controller (MUIC):
31+
32+muic-max77843@66 {
33+ ...
34+ usb_con: connector {
35+ compatible = "usb-b-connector";
36+ label = "micro-USB";
37+ type = "micro";
38+ };
39+};
40+
41+2. USB-C connector attached to CC controller (s2mm005), HS lines routed
42+to companion PMIC (max77865), SS lines to USB3 PHY and SBU to DisplayPort.
43+DisplayPort video lines are routed to the connector via SS mux in USB3 PHY.
44+
45+ccic: s2mm005@33 {
46+ ...
47+ usb_con: connector {
48+ compatible = "usb-c-connector";
49+ label = "USB-C";
50+
51+ ports {
52+ #address-cells = <1>;
53+ #size-cells = <0>;
54+
55+ port@0 {
56+ reg = <0>;
57+ usb_con_hs: endpoint {
58+ remote-endpoint = <&max77865_usbc_hs>;
59+ };
60+ };
61+ port@1 {
62+ reg = <1>;
63+ usb_con_ss: endpoint {
64+ remote-endpoint = <&usbdrd_phy_ss>;
65+ };
66+ };
67+ port@2 {
68+ reg = <2>;
69+ usb_con_sbu: endpoint {
70+ remote-endpoint = <&dp_aux>;
71+ };
72+ };
73+ };
74+ };
75+};
Documentation/devicetree/bindings/fsi/fsi.txt+151−0
@@ -0,0 +1,151 @@
1+FSI bus & engine generic device tree bindings
2+=============================================
3+
4+The FSI bus is probe-able, so the OS is able to enumerate FSI slaves, and
5+engines within those slaves. However, we have a facility to match devicetree
6+nodes to probed engines. This allows for fsi engines to expose non-probeable
7+busses, which are then exposed by the device tree. For example, an FSI engine
8+that is an I2C master - the I2C bus can be described by the device tree under
9+the engine's device tree node.
10+
11+FSI masters may require their own DT nodes (to describe the master HW itself);
12+that requirement is defined by the master's implementation, and is described by
13+the fsi-master-* binding specifications.
14+
15+Under the masters' nodes, we can describe the bus topology using nodes to
16+represent the FSI slaves and their slave engines. As a basic outline:
17+
18+ fsi-master {
19+ /* top-level of FSI bus topology, bound to an FSI master driver and
20+ * exposes an FSI bus */
21+
22+ fsi-slave@<link,id> {
23+ /* this node defines the FSI slave device, and is handled
24+ * entirely with FSI core code */
25+
26+ fsi-slave-engine@<addr> {
27+ /* this node defines the engine endpoint & address range, which
28+ * is bound to the relevant fsi device driver */
29+ ...
30+ };
31+
32+ fsi-slave-engine@<addr> {
33+ ...
34+ };
35+
36+ };
37+ };
38+
39+Note that since the bus is probe-able, some (or all) of the topology may
40+not be described; this binding only provides an optional facility for
41+adding subordinate device tree nodes as children of FSI engines.
42+
43+FSI masters
44+-----------
45+
46+FSI master nodes declare themselves as such with the "fsi-master" compatible
47+value. It's likely that an implementation-specific compatible value will
48+be needed as well, for example:
49+
50+ compatible = "fsi-master-gpio", "fsi-master";
51+
52+Since the master nodes describe the top-level of the FSI topology, they also
53+need to declare the FSI-standard addressing scheme. This requires two cells for
54+addresses (link index and slave ID), and no size:
55+
56+ #address-cells = <2>;
57+ #size-cells = <0>;
58+
59+An optional boolean property can be added to indicate that a particular master
60+should not scan for connected devices at initialization time. This is
61+necessary in cases where a scan could cause arbitration issues with other
62+masters that may be present on the bus.
63+
64+ no-scan-on-init;
65+
66+FSI slaves
67+----------
68+
69+Slaves are identified by a (link-index, slave-id) pair, so require two cells
70+for an address identifier. Since these are not a range, no size cells are
71+required. For an example, a slave on link 1, with ID 2, could be represented
72+as:
73+
74+ cfam@1,2 {
75+ reg = <1 2>;
76+ [...];
77+ }
78+
79+Each slave provides an address-space, under which the engines are accessible.
80+That address space has a maximum of 23 bits, so we use one cell to represent
81+addresses and sizes in the slave address space:
82+
83+ #address-cells = <1>;
84+ #size-cells = <1>;
85+
86+
87+FSI engines (devices)
88+---------------------
89+
90+Engines are identified by their address under the slaves' address spaces. We
91+use a single cell for address and size. Engine nodes represent the endpoint
92+FSI device, and are passed to those FSI device drivers' ->probe() functions.
93+
94+For example, for a slave using a single 0x400-byte page starting at address
95+0xc00:
96+
97+ engine@c00 {
98+ reg = <0xc00 0x400>;
99+ };
100+
101+
102+Full example
103+------------
104+
105+Here's an example that illustrates:
106+ - an FSI master
107+ - connected to an FSI slave
108+ - that contains an engine that is an I2C master
109+ - connected to an I2C EEPROM
110+
111+The FSI master may be connected to additional slaves, and slaves may have
112+additional engines, but they don't necessarily need to be describe in the
113+device tree if no extra platform information is required.
114+
115+ /* The GPIO-based FSI master node, describing the top level of the
116+ * FSI bus
117+ */
118+ gpio-fsi {
119+ compatible = "fsi-master-gpio", "fsi-master";
120+ #address-cells = <2>;
121+ #size-cells = <0>;
122+
123+ /* A FSI slave (aka. CFAM) at link 0, ID 0. */
124+ cfam@0,0 {
125+ reg = <0 0>;
126+ #address-cells = <1>;
127+ #size-cells = <1>;
128+
129+ /* FSI engine at 0xc00, using a single page. In this example,
130+ * it's an I2C master controller, so subnodes describe the
131+ * I2C bus.
132+ */
133+ i2c-controller@c00 {
134+ reg = <0xc00 0x400>;
135+
136+ /* Engine-specific data. In this case, we're describing an
137+ * I2C bus, so we're conforming to the generic I2C binding
138+ */
139+ compatible = "some-vendor,fsi-i2c-controller";
140+ #address-cells = <1>;
141+ #size-cells = <1>;
142+
143+ /* I2C endpoint device: an Atmel EEPROM */
144+ eeprom@50 {
145+ compatible = "atmel,24c256";
146+ reg = <0x50>;
147+ pagesize = <64>;
148+ };
149+ };
150+ };
151+ };
Documentation/devicetree/bindings/mfd/aspeed-lpc.txt+41−0
@@ -109,9 +109,50 @@ lpc: lpc@1e789000 { · 108 unmodified lines
109109 };
110110 };
111111
112+BMC Node Children
113+==================
114+
115+
112116 Host Node Children
113117 ==================
114118
119+LPC Host Interface Controller
120+-------------------
121+
122+The LPC Host Interface Controller manages functions exposed to the host such as
123+LPC firmware hub cycles, configuration of the LPC-to-AHB mapping, UART
124+management and bus snoop configuration.
125+
126+Required properties:
127+
128+- compatible: One of:
129+ "aspeed,ast2400-lpc-ctrl";
130+ "aspeed,ast2500-lpc-ctrl";
131+
132+- reg: contains offset/length values of the host interface controller
133+ memory regions
134+
135+- clocks: contains a phandle to the syscon node describing the clocks.
136+ There should then be one cell representing the clock to use
137+
138+- memory-region: A phandle to a reserved_memory region to be used for the LPC
139+ to AHB mapping
140+
141+- flash: A phandle to the SPI flash controller containing the flash to
142+ be exposed over the LPC to AHB mapping
143+
144+Example:
145+
146+lpc-host@80 {
147+ lpc_ctrl: lpc-ctrl@0 {
148+ compatible = "aspeed,ast2500-lpc-ctrl";
149+ reg = <0x0 0x80>;
150+ clocks = <&syscon ASPEED_CLK_GATE_LCLK>;
151+ memory-region = <&flash_memory>;
152+ flash = <&spi>;
153+ };
154+};
155+
115156 LPC Host Controller
116157 -------------------
117158
Documentation/devicetree/bindings/nvmem/imx-ocotp.txt+19−4
@@ -11,17 +11,32 @@ Required properties: · 10 unmodified lines
1111 "fsl,imx6ul-ocotp" (i.MX6UL),
1212 "fsl,imx7d-ocotp" (i.MX7D/S),
1313 followed by "syscon".
14+- #address-cells : Should be 1
15+- #size-cells : Should be 1
1416 - reg: Should contain the register base and length.
1517 - clocks: Should contain a phandle pointing to the gated peripheral clock.
1618
1719 Optional properties:
1820 - read-only: disable write access
1921
20−Example:
22+Optional Child nodes:
23+
24+- Data cells of ocotp:
25+ Detailed bindings are described in bindings/nvmem/nvmem.txt
2126
27+Example:
2228 ocotp: ocotp@21bc000 {
23− compatible = "fsl,imx6q-ocotp", "syscon";
29+ #address-cells = <1>;
30+ #size-cells = <1>;
31+ compatible = "fsl,imx6sx-ocotp", "syscon";
2432 reg = <0x021bc000 0x4000>;
25− clocks = <&clks IMX6QDL_CLK_IIM>;
26− read-only;
33+ clocks = <&clks IMX6SX_CLK_OCOTP>;
34+
35+ tempmon_calib: calib@38 {
36+ reg = <0x38 4>;
37+ };
38+
39+ tempmon_temp_grade: temp-grade@20 {
40+ reg = <0x20 4>;
41+ };
2742 };
Documentation/devicetree/bindings/nvmem/snvs-lpgpr.txt+2−1
@@ -1,5 +1,5 @@
11 Device tree bindings for Low Power General Purpose Register found in i.MX6Q/D
2−Secure Non-Volatile Storage.
2+and i.MX7 Secure Non-Volatile Storage.
33
44 This DT node should be represented as a sub-node of a "syscon",
55 "simple-mfd" node.
@@ -8,6 +8,7 @@ Required properties: · 2 unmodified lines
88 - compatible: should be one of the fallowing variants:
99 "fsl,imx6q-snvs-lpgpr" for Freescale i.MX6Q/D/DL/S
1010 "fsl,imx6ul-snvs-lpgpr" for Freescale i.MX6UL
11+ "fsl,imx7d-snvs-lpgpr" for Freescale i.MX7D/S
1112
1213 Example:
1314 snvs: snvs@020cc000 {
Documentation/driver-api/uio-howto.rst+5−0
@@ -709,6 +709,11 @@ The vmbus device regions are mapped into uio device resources: · 708 unmodified lines
709709 3) Network receive buffer region
710710 4) Network send buffer region
711711
712+If a subchannel is created by a request to host, then the uio_hv_generic
713+device driver will create a sysfs binary file for the per-channel ring buffer.
714+For example:
715+ /sys/bus/vmbus/devices/3811fe4d-0fa0-4b62-981a-74fc1084c757/channels/21/ring
716+
712717 Further information
713718 ===================
714719
MAINTAINERS+6−1
@@ -6212,6 +6212,11 @@ F: Documentation/hw_random.txt · 6211 unmodified lines
62126212 F: drivers/char/hw_random/
62136213 F: include/linux/hw_random.h
62146214
6215+HARDWARE TRACING FACILITIES
6216+M: Alexander Shishkin <alexander.shishkin@linux.intel.com>
6217+S: Maintained
6218+F: drivers/hwtracing/
6219+
62156220 HARDWARE SPINLOCK CORE
62166221 M: Ohad Ben-Cohen <ohad@wizery.com>
62176222 M: Bjorn Andersson <bjorn.andersson@linaro.org>
@@ -8140,7 +8145,7 @@ F: drivers/*/*/*pasemi* · 1922 unmodified lines
81408145 LINUX KERNEL DUMP TEST MODULE (LKDTM)
81418146 M: Kees Cook <keescook@chromium.org>
81428147 S: Maintained
8143−F: drivers/misc/lkdtm*
8148+F: drivers/misc/lkdtm/*
81448149
81458150 LINUX KERNEL MEMORY CONSISTENCY MODEL (LKMM)
81468151 M: Alan Stern <stern@rowland.harvard.edu>
arch/x86/entry/entry_32.S+3−0
@@ -902,6 +902,9 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR, · 901 unmodified lines
902902 BUILD_INTERRUPT3(hyperv_reenlightenment_vector, HYPERV_REENLIGHTENMENT_VECTOR,
903903 hyperv_reenlightenment_intr)
904904
905+BUILD_INTERRUPT3(hv_stimer0_callback_vector, HYPERV_STIMER0_VECTOR,
906+ hv_stimer0_vector_handler)
907+
905908 #endif /* CONFIG_HYPERV */
906909
907910 ENTRY(page_fault)
arch/x86/entry/entry_64.S+3−0
@@ -1140,6 +1140,9 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \ · 1139 unmodified lines
11401140
11411141 apicinterrupt3 HYPERV_REENLIGHTENMENT_VECTOR \
11421142 hyperv_reenlightenment_vector hyperv_reenlightenment_intr
1143+
1144+apicinterrupt3 HYPERV_STIMER0_VECTOR \
1145+ hv_stimer0_callback_vector hv_stimer0_vector_handler
11431146 #endif /* CONFIG_HYPERV */
11441147
11451148 idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
arch/x86/include/asm/hardirq.h+1−0
@@ -40,6 +40,7 @@ typedef struct { · 39 unmodified lines
4040 #endif
4141 #if IS_ENABLED(CONFIG_HYPERV)
4242 unsigned int irq_hv_reenlightenment_count;
43+ unsigned int hyperv_stimer0_count;
4344 #endif
4445 } ____cacheline_aligned irq_cpustat_t;
4546
arch/x86/include/asm/irq_vectors.h+2−1
@@ -106,9 +106,10 @@ · 105 unmodified lines
106106
107107 #if IS_ENABLED(CONFIG_HYPERV)
108108 #define HYPERV_REENLIGHTENMENT_VECTOR 0xee
109+#define HYPERV_STIMER0_VECTOR 0xed
109110 #endif
110111
111−#define LOCAL_TIMER_VECTOR 0xed
112+#define LOCAL_TIMER_VECTOR 0xec
112113
113114 #define NR_VECTORS 256
114115
arch/x86/include/asm/mshyperv.h+13−0
@@ -173,6 +173,19 @@ void hv_remove_kexec_handler(void); · 172 unmodified lines
173173 void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs));
174174 void hv_remove_crash_handler(void);
175175
176+/*
177+ * Routines for stimer0 Direct Mode handling.
178+ * On x86/x64, there are no percpu actions to take.
179+ */
180+void hv_stimer0_vector_handler(struct pt_regs *regs);
181+void hv_stimer0_callback_vector(void);
182+int hv_setup_stimer0_irq(int *irq, int *vector, void (*handler)(void));
183+void hv_remove_stimer0_irq(int irq);
184+
185+static inline void hv_enable_stimer0_percpu_irq(int irq) {}
186+static inline void hv_disable_stimer0_percpu_irq(int irq) {}
187+
188+
176189 #if IS_ENABLED(CONFIG_HYPERV)
177190 extern struct clocksource *hyperv_cs;
178191 extern void *hv_hypercall_pg;
arch/x86/include/uapi/asm/hyperv.h+3−0
@@ -77,6 +77,9 @@ · 76 unmodified lines
7777 /* Crash MSR available */
7878 #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE (1 << 10)
7979
80+/* stimer Direct Mode is available */
81+#define HV_X64_STIMER_DIRECT_MODE_AVAILABLE (1 << 19)
82+
8083 /*
8184 * Feature identification: EBX indicates which flags were specified at
8285 * partition creation. The format is the same as the partition creation
arch/x86/kernel/cpu/mshyperv.c+40−0
@@ -37,6 +37,7 @@ EXPORT_SYMBOL_GPL(ms_hyperv); · 36 unmodified lines
3737
3838 #if IS_ENABLED(CONFIG_HYPERV)
3939 static void (*vmbus_handler)(void);
40+static void (*hv_stimer0_handler)(void);
4041 static void (*hv_kexec_handler)(void);
4142 static void (*hv_crash_handler)(struct pt_regs *regs);
4243
@@ -69,6 +70,41 @@ void hv_remove_vmbus_irq(void) · 26 unmodified lines
6970 EXPORT_SYMBOL_GPL(hv_setup_vmbus_irq);
7071 EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq);
7172
73+/*
74+ * Routines to do per-architecture handling of stimer0
75+ * interrupts when in Direct Mode
76+ */
77+
78+__visible void __irq_entry hv_stimer0_vector_handler(struct pt_regs *regs)
79+{
80+ struct pt_regs *old_regs = set_irq_regs(regs);
81+
82+ entering_irq();
83+ inc_irq_stat(hyperv_stimer0_count);
84+ if (hv_stimer0_handler)
85+ hv_stimer0_handler();
86+ ack_APIC_irq();
87+
88+ exiting_irq();
89+ set_irq_regs(old_regs);
90+}
91+
92+int hv_setup_stimer0_irq(int *irq, int *vector, void (*handler)(void))
93+{
94+ *vector = HYPERV_STIMER0_VECTOR;
95+ *irq = 0; /* Unused on x86/x64 */
96+ hv_stimer0_handler = handler;
97+ return 0;
98+}
99+EXPORT_SYMBOL_GPL(hv_setup_stimer0_irq);
100+
101+void hv_remove_stimer0_irq(int irq)
102+{
103+ /* We have no way to deallocate the interrupt gate */
104+ hv_stimer0_handler = NULL;
105+}
106+EXPORT_SYMBOL_GPL(hv_remove_stimer0_irq);
107+
72108 void hv_setup_kexec_handler(void (*handler)(void))
73109 {
74110 hv_kexec_handler = handler;
@@ -257,6 +293,10 @@ static void __init ms_hyperv_init_platform(void) · 182 unmodified lines
257293 alloc_intr_gate(HYPERV_REENLIGHTENMENT_VECTOR,
258294 hyperv_reenlightenment_vector);
259295
296+ /* Setup the IDT for stimer0 */
297+ if (ms_hyperv.misc_features & HV_X64_STIMER_DIRECT_MODE_AVAILABLE)
298+ alloc_intr_gate(HYPERV_STIMER0_VECTOR,
299+ hv_stimer0_callback_vector);
260300 #endif
261301 }
262302
arch/x86/kernel/irq.c+7−0
@@ -150,6 +150,13 @@ int arch_show_interrupts(struct seq_file *p, int prec) · 149 unmodified lines
150150 irq_stats(j)->irq_hv_reenlightenment_count);
151151 seq_puts(p, " Hyper-V reenlightenment interrupts\n");
152152 }
153+ if (test_bit(HYPERV_STIMER0_VECTOR, system_vectors)) {
154+ seq_printf(p, "%*s: ", prec, "HVS");
155+ for_each_online_cpu(j)
156+ seq_printf(p, "%10u ",
157+ irq_stats(j)->hyperv_stimer0_count);
158+ seq_puts(p, " Hyper-V stimer0 interrupts\n");
159+ }
153160 #endif
154161 seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
155162 #if defined(CONFIG_X86_IO_APIC)
block/genhd.c+11−8
@@ -308,19 +308,22 @@ void blkdev_show(struct seq_file *seqf, off_t offset) · 307 unmodified lines
308308 /**
309309 * register_blkdev - register a new block device
310310 *
311− * @major: the requested major device number [1..255]. If @major = 0, try to
312− * allocate any unused major number.
311+ * @major: the requested major device number [1..BLKDEV_MAJOR_MAX-1]. If
312+ * @major = 0, try to allocate any unused major number.
313313 * @name: the name of the new block device as a zero terminated string
314314 *
315315 * The @name must be unique within the system.
316316 *
317317 * The return value depends on the @major input parameter:
318318 *
319− * - if a major device number was requested in range [1..255] then the
320− * function returns zero on success, or a negative error code
319+ * - if a major device number was requested in range [1..BLKDEV_MAJOR_MAX-1]
320+ * then the function returns zero on success, or a negative error code
321321 * - if any unused major number was requested with @major = 0 parameter
322322 * then the return value is the allocated major number in range
323− * [1..255] or a negative error code otherwise
323+ * [1..BLKDEV_MAJOR_MAX-1] or a negative error code otherwise
324+ *
325+ * See Documentation/admin-guide/devices.txt for the list of allocated
326+ * major numbers.
324327 */
325328 int register_blkdev(unsigned int major, const char *name)
326329 {
@@ -347,8 +350,8 @@ int register_blkdev(unsigned int major, const char *name) · 20 unmodified lines
347350 }
348351
349352 if (major >= BLKDEV_MAJOR_MAX) {
350− pr_err("register_blkdev: major requested (%d) is greater than the maximum (%d) for %s\n",
351− major, BLKDEV_MAJOR_MAX, name);
353+ pr_err("register_blkdev: major requested (%u) is greater than the maximum (%u) for %s\n",
354+ major, BLKDEV_MAJOR_MAX-1, name);
352355
353356 ret = -EINVAL;
354357 goto out;
@@ -375,7 +378,7 @@ int register_blkdev(unsigned int major, const char *name) · 20 unmodified lines
375378 ret = -EBUSY;
376379
377380 if (ret < 0) {
378− printk("register_blkdev: cannot get major %d for %s\n",
381+ printk("register_blkdev: cannot get major %u for %s\n",
379382 major, name);
380383 kfree(p);
381384 }
drivers/Kconfig+1−3
@@ -199,9 +199,7 @@ source "drivers/dax/Kconfig" · 198 unmodified lines
199199
200200 source "drivers/nvmem/Kconfig"
201201
202−source "drivers/hwtracing/stm/Kconfig"
203−
204−source "drivers/hwtracing/intel_th/Kconfig"
202+source "drivers/hwtracing/Kconfig"
205203
206204 source "drivers/fpga/Kconfig"
207205
drivers/char/Kconfig+1−1
@@ -236,7 +236,7 @@ source "drivers/char/hw_random/Kconfig" · 235 unmodified lines
236236
237237 config NVRAM
238238 tristate "/dev/nvram support"
239− depends on ATARI || X86 || (ARM && RTC_DRV_CMOS) || GENERIC_NVRAM
239+ depends on ATARI || X86 || GENERIC_NVRAM
240240 ---help---
241241 If you say Y here and create a character special file /dev/nvram
242242 with major number 10 and minor number 144 using mknod ("man mknod"),
drivers/char/mem.c+3−3
@@ -137,7 +137,7 @@ static ssize_t read_mem(struct file *file, char __user *buf, · 136 unmodified lines
137137
138138 while (count > 0) {
139139 unsigned long remaining;
140− int allowed;
140+ int allowed, probe;
141141
142142 sz = size_inside_page(p, count);
143143
@@ -160,9 +160,9 @@ static ssize_t read_mem(struct file *file, char __user *buf, · 16 unmodified lines
160160 if (!ptr)
161161 goto failed;
162162
163− err = probe_kernel_read(bounce, ptr, sz);
163+ probe = probe_kernel_read(bounce, ptr, sz);
164164 unxlate_dev_mem_ptr(p, ptr);
165− if (err)
165+ if (probe)
166166 goto failed;
167167
168168 remaining = copy_to_user(buf, bounce, sz);
drivers/char/xillybus/xillybus_pcie.c+0−1
@@ -24,7 +24,6 @@ MODULE_LICENSE("GPL v2"); · 23 unmodified lines
2424
2525 #define PCI_DEVICE_ID_XILLYBUS 0xebeb
2626
27−#define PCI_VENDOR_ID_ALTERA 0x1172
2827 #define PCI_VENDOR_ID_ACTEL 0x11aa
2928 #define PCI_VENDOR_ID_LATTICE 0x1204
3029
drivers/extcon/extcon-gpio.c+45−58
@@ -18,8 +18,6 @@ · 17 unmodified lines
1818 */
1919
2020 #include <linux/extcon-provider.h>
21−#include <linux/extcon/extcon-gpio.h>
22−#include <linux/gpio.h>
2321 #include <linux/gpio/consumer.h>
2422 #include <linux/init.h>
2523 #include <linux/interrupt.h>
@@ -29,14 +27,30 @@ · 3 unmodified lines
2927 #include <linux/slab.h>
3028 #include <linux/workqueue.h>
3129
30+/**
31+ * struct gpio_extcon_data - A simple GPIO-controlled extcon device state container.
32+ * @edev: Extcon device.
33+ * @irq: Interrupt line for the external connector.
34+ * @work: Work fired by the interrupt.
35+ * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce
36+ * value.
37+ * @gpiod: GPIO descriptor for this external connector.
38+ * @extcon_id: The unique id of specific external connector.
39+ * @debounce: Debounce time for GPIO IRQ in ms.
40+ * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW).
41+ * @check_on_resume: Boolean describing whether to check the state of gpio
42+ * while resuming from sleep.
43+ */
3244 struct gpio_extcon_data {
3345 struct extcon_dev *edev;
3446 int irq;
3547 struct delayed_work work;
3648 unsigned long debounce_jiffies;
37−
38− struct gpio_desc *id_gpiod;
39− struct gpio_extcon_pdata *pdata;
49+ struct gpio_desc *gpiod;
50+ unsigned int extcon_id;
51+ unsigned long debounce;
52+ unsigned long irq_flags;
53+ bool check_on_resume;
4054 };
4155
4256 static void gpio_extcon_work(struct work_struct *work)
@@ -46,11 +60,8 @@ static void gpio_extcon_work(struct work_struct *work) · 3 unmodified lines
4660 container_of(to_delayed_work(work), struct gpio_extcon_data,
4761 work);
4862
49− state = gpiod_get_value_cansleep(data->id_gpiod);
50− if (data->pdata->gpio_active_low)
51− state = !state;
52−
53− extcon_set_state_sync(data->edev, data->pdata->extcon_id, state);
63+ state = gpiod_get_value_cansleep(data->gpiod);
64+ extcon_set_state_sync(data->edev, data->extcon_id, state);
5465 }
5566
5667 static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
@@ -62,65 +73,41 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id) · 5 unmodified lines
6273 return IRQ_HANDLED;
6374 }
6475
65−static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data)
66−{
67− struct gpio_extcon_pdata *pdata = data->pdata;
68− int ret;
69−
70− ret = devm_gpio_request_one(dev, pdata->gpio, GPIOF_DIR_IN,
71− dev_name(dev));
72− if (ret < 0)
73− return ret;
74−
75− data->id_gpiod = gpio_to_desc(pdata->gpio);
76− if (!data->id_gpiod)
77− return -EINVAL;
78−
79− if (pdata->debounce) {
80− ret = gpiod_set_debounce(data->id_gpiod,
81− pdata->debounce * 1000);
82− if (ret < 0)
83− data->debounce_jiffies =
84− msecs_to_jiffies(pdata->debounce);
85− }
86−
87− data->irq = gpiod_to_irq(data->id_gpiod);
88− if (data->irq < 0)
89− return data->irq;
90−
91− return 0;
92−}
93−
9476 static int gpio_extcon_probe(struct platform_device *pdev)
9577 {
96− struct gpio_extcon_pdata *pdata = dev_get_platdata(&pdev->dev);
9778 struct gpio_extcon_data *data;
79+ struct device *dev = &pdev->dev;
9880 int ret;
9981
100− if (!pdata)
101− return -EBUSY;
102− if (!pdata->irq_flags || pdata->extcon_id > EXTCON_NONE)
103− return -EINVAL;
104−
105− data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_extcon_data),
106− GFP_KERNEL);
82+ data = devm_kzalloc(dev, sizeof(struct gpio_extcon_data), GFP_KERNEL);
10783 if (!data)
10884 return -ENOMEM;
109− data->pdata = pdata;
11085
111− /* Initialize the gpio */
112− ret = gpio_extcon_init(&pdev->dev, data);
113− if (ret < 0)
114− return ret;
86+ /*
87+ * FIXME: extcon_id represents the unique identifier of external
88+ * connectors such as EXTCON_USB, EXTCON_DISP_HDMI and so on. extcon_id
89+ * is necessary to register the extcon device. But, it's not yet
90+ * developed to get the extcon id from device-tree or others.
91+ * On later, it have to be solved.
92+ */
93+ if (!data->irq_flags || data->extcon_id > EXTCON_NONE)
94+ return -EINVAL;
95+
96+ data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN);
97+ if (IS_ERR(data->gpiod))
98+ return PTR_ERR(data->gpiod);
99+ data->irq = gpiod_to_irq(data->gpiod);
100+ if (data->irq <= 0)
101+ return data->irq;
115102
116103 /* Allocate the memory of extcon devie and register extcon device */
117− data->edev = devm_extcon_dev_allocate(&pdev->dev, &pdata->extcon_id);
104+ data->edev = devm_extcon_dev_allocate(dev, &data->extcon_id);
118105 if (IS_ERR(data->edev)) {
119− dev_err(&pdev->dev, "failed to allocate extcon device\n");
106+ dev_err(dev, "failed to allocate extcon device\n");
120107 return -ENOMEM;
121108 }
122109
123− ret = devm_extcon_dev_register(&pdev->dev, data->edev);
110+ ret = devm_extcon_dev_register(dev, data->edev);
124111 if (ret < 0)
125112 return ret;
126113
@@ -130,8 +117,8 @@ static int gpio_extcon_probe(struct platform_device *pdev) · 3 unmodified lines
130117 * Request the interrupt of gpio to detect whether external connector
131118 * is attached or detached.
132119 */
133− ret = devm_request_any_context_irq(&pdev->dev, data->irq,
134− gpio_irq_handler, pdata->irq_flags,
120+ ret = devm_request_any_context_irq(dev, data->irq,
121+ gpio_irq_handler, data->irq_flags,
135122 pdev->name, data);
136123 if (ret < 0)
137124 return ret;
@@ -158,7 +145,7 @@ static int gpio_extcon_resume(struct device *dev) · 20 unmodified lines
158145 struct gpio_extcon_data *data;
159146
160147 data = dev_get_drvdata(dev);
161− if (data->pdata->check_on_resume)
148+ if (data->check_on_resume)
162149 queue_delayed_work(system_power_efficient_wq,
163150 &data->work, data->debounce_jiffies);
164151
drivers/extcon/extcon-intel-cht-wc.c+7−4
@@ -66,6 +66,8 @@ · 65 unmodified lines
6666
6767 #define CHT_WC_VBUS_GPIO_CTLO 0x6e2d
6868 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT BIT(0)
69+#define CHT_WC_VBUS_GPIO_CTLO_DRV_OD BIT(4)
70+#define CHT_WC_VBUS_GPIO_CTLO_DIR_OUT BIT(5)
6971
7072 enum cht_wc_usb_id {
7173 USB_ID_OTG,
@@ -183,14 +185,15 @@ static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext, · 111 unmodified lines
183185 {
184186 int ret, val;
185187
186− val = enable ? CHT_WC_VBUS_GPIO_CTLO_OUTPUT : 0;
187−
188188 /*
189189 * The 5V boost converter is enabled through a gpio on the PMIC, since
190190 * there currently is no gpio driver we access the gpio reg directly.
191191 */
192− ret = regmap_update_bits(ext->regmap, CHT_WC_VBUS_GPIO_CTLO,
193− CHT_WC_VBUS_GPIO_CTLO_OUTPUT, val);
192+ val = CHT_WC_VBUS_GPIO_CTLO_DRV_OD | CHT_WC_VBUS_GPIO_CTLO_DIR_OUT;
193+ if (enable)
194+ val |= CHT_WC_VBUS_GPIO_CTLO_OUTPUT;
195+
196+ ret = regmap_write(ext->regmap, CHT_WC_VBUS_GPIO_CTLO, val);
194197 if (ret)
195198 dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
196199 }
drivers/extcon/extcon-intel-int3496.c+5−4
@@ -50,7 +50,11 @@ static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, fal · 49 unmodified lines
5050 static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };
5151
5252 static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
53− { "id-gpios", &id_gpios, 1 },
53+ /*
54+ * Some platforms have a bug in ACPI GPIO description making IRQ
55+ * GPIO to be output only. Ask the GPIO core to ignore this limit.
56+ */
57+ { "id-gpios", &id_gpios, 1, ACPI_GPIO_QUIRK_NO_IO_RESTRICTION },
5458 { "vbus-gpios", &vbus_gpios, 1 },
5559 { "mux-gpios", &mux_gpios, 1 },
5660 { },
@@ -112,9 +116,6 @@ static int int3496_probe(struct platform_device *pdev) · 55 unmodified lines
112116 ret = PTR_ERR(data->gpio_usb_id);
113117 dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
114118 return ret;
115− } else if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) {
116− dev_warn(dev, FW_BUG "USB ID GPIO not in input mode, fixing\n");
117− gpiod_direction_input(data->gpio_usb_id);
118119 }
119120
120121 data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
drivers/extcon/extcon.c+34−10
@@ -1336,6 +1336,28 @@ void extcon_dev_unregister(struct extcon_dev *edev) · 1335 unmodified lines
13361336 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
13371337
13381338 #ifdef CONFIG_OF
1339+
1340+/*
1341+ * extcon_find_edev_by_node - Find the extcon device from devicetree.
1342+ * @node : OF node identifying edev
1343+ *
1344+ * Return the pointer of extcon device if success or ERR_PTR(err) if fail.
1345+ */
1346+struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
1347+{
1348+ struct extcon_dev *edev;
1349+
1350+ mutex_lock(&extcon_dev_list_lock);
1351+ list_for_each_entry(edev, &extcon_dev_list, entry)
1352+ if (edev->dev.parent && edev->dev.parent->of_node == node)
1353+ goto out;
1354+ edev = ERR_PTR(-EPROBE_DEFER);
1355+out:
1356+ mutex_unlock(&extcon_dev_list_lock);
1357+
1358+ return edev;
1359+}
1360+
13391361 /*
13401362 * extcon_get_edev_by_phandle - Get the extcon device from devicetree.
13411363 * @dev : the instance to the given device
@@ -1363,25 +1385,27 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) · 21 unmodified lines
13631385 return ERR_PTR(-ENODEV);
13641386 }
13651387
1366− mutex_lock(&extcon_dev_list_lock);
1367− list_for_each_entry(edev, &extcon_dev_list, entry) {
1368− if (edev->dev.parent && edev->dev.parent->of_node == node) {
1369− mutex_unlock(&extcon_dev_list_lock);
1370− of_node_put(node);
1371− return edev;
1372− }
1373− }
1374− mutex_unlock(&extcon_dev_list_lock);
1388+ edev = extcon_find_edev_by_node(node);
13751389 of_node_put(node);
13761390
1377− return ERR_PTR(-EPROBE_DEFER);
1391+ return edev;
13781392 }
1393+
13791394 #else
1395+
1396+struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
1397+{
1398+ return ERR_PTR(-ENOSYS);
1399+}
1400+
13801401 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
13811402 {
13821403 return ERR_PTR(-ENOSYS);
13831404 }
1405+
13841406 #endif /* CONFIG_OF */
1407+
1408+EXPORT_SYMBOL_GPL(extcon_find_edev_by_node);
13851409 EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
13861410
13871411 /**
drivers/fpga/altera-cvp.c+0−2
@@ -384,8 +384,6 @@ static int altera_cvp_probe(struct pci_dev *pdev, · 383 unmodified lines
384384 const struct pci_device_id *dev_id);
385385 static void altera_cvp_remove(struct pci_dev *pdev);
386386
387−#define PCI_VENDOR_ID_ALTERA 0x1172
388−
389387 static struct pci_device_id altera_cvp_id_tbl[] = {
390388 { PCI_VDEVICE(ALTERA, PCI_ANY_ID) },
391389 { }
drivers/fsi/Kconfig+1−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44
55 menuconfig FSI
66 tristate "FSI support"
7+ depends on OF
78 select CRC4
89 ---help---
910 FSI - the FRU Support Interface - is a simple bus for low-level
drivers/fsi/fsi-core.c+120−9
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/fsi.h>
1919 #include <linux/idr.h>
2020 #include <linux/module.h>
21+#include <linux/of.h>
2122 #include <linux/slab.h>
2223 #include <linux/bitops.h>
2324
@@ -142,6 +143,7 @@ static void fsi_device_release(struct device *_device) · 118 unmodified lines
142143 {
143144 struct fsi_device *device = to_fsi_dev(_device);
144145
146+ of_node_put(device->dev.of_node);
145147 kfree(device);
146148 }
147149
@@ -205,7 +207,7 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) · 57 unmodified lines
205207 if (rc)
206208 return rc;
207209
208− dev_info(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n",
210+ dev_dbg(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n",
209211 be32_to_cpu(stat), be32_to_cpu(irq));
210212
211213 /* clear interrupts */
@@ -334,6 +336,57 @@ extern void fsi_slave_release_range(struct fsi_slave *slave, · 122 unmodified lines
334336 }
335337 EXPORT_SYMBOL_GPL(fsi_slave_release_range);
336338
339+static bool fsi_device_node_matches(struct device *dev, struct device_node *np,
340+ uint32_t addr, uint32_t size)
341+{
342+ unsigned int len, na, ns;
343+ const __be32 *prop;
344+ uint32_t psize;
345+
346+ na = of_n_addr_cells(np);
347+ ns = of_n_size_cells(np);
348+
349+ if (na != 1 || ns != 1)
350+ return false;
351+
352+ prop = of_get_property(np, "reg", &len);
353+ if (!prop || len != 8)
354+ return false;
355+
356+ if (of_read_number(prop, 1) != addr)
357+ return false;
358+
359+ psize = of_read_number(prop + 1, 1);
360+ if (psize != size) {
361+ dev_warn(dev,
362+ "node %s matches probed address, but not size (got 0x%x, expected 0x%x)",
363+ of_node_full_name(np), psize, size);
364+ }
365+
366+ return true;
367+}
368+
369+/* Find a matching node for the slave engine at @address, using @size bytes
370+ * of space. Returns NULL if not found, or a matching node with refcount
371+ * already incremented.
372+ */
373+static struct device_node *fsi_device_find_of_node(struct fsi_device *dev)
374+{
375+ struct device_node *parent, *np;
376+
377+ parent = dev_of_node(&dev->slave->dev);
378+ if (!parent)
379+ return NULL;
380+
381+ for_each_child_of_node(parent, np) {
382+ if (fsi_device_node_matches(&dev->dev, np,
383+ dev->addr, dev->size))
384+ return np;
385+ }
386+
387+ return NULL;
388+}
389+
337390 static int fsi_slave_scan(struct fsi_slave *slave)
338391 {
339392 uint32_t engine_addr;
@@ -402,6 +455,7 @@ static int fsi_slave_scan(struct fsi_slave *slave) · 62 unmodified lines
402455 dev_set_name(&dev->dev, "%02x:%02x:%02x:%02x",
403456 slave->master->idx, slave->link,
404457 slave->id, i - 2);
458+ dev->dev.of_node = fsi_device_find_of_node(dev);
405459
406460 rc = device_register(&dev->dev);
407461 if (rc) {
@@ -558,9 +612,53 @@ static void fsi_slave_release(struct device *dev) · 150 unmodified lines
558612 {
559613 struct fsi_slave *slave = to_fsi_slave(dev);
560614
615+ of_node_put(dev->of_node);
561616 kfree(slave);
562617 }
563618
619+static bool fsi_slave_node_matches(struct device_node *np,
620+ int link, uint8_t id)
621+{
622+ unsigned int len, na, ns;
623+ const __be32 *prop;
624+
625+ na = of_n_addr_cells(np);
626+ ns = of_n_size_cells(np);
627+
628+ /* Ensure we have the correct format for addresses and sizes in
629+ * reg properties
630+ */
631+ if (na != 2 || ns != 0)
632+ return false;
633+
634+ prop = of_get_property(np, "reg", &len);
635+ if (!prop || len != 8)
636+ return false;
637+
638+ return (of_read_number(prop, 1) == link) &&
639+ (of_read_number(prop + 1, 1) == id);
640+}
641+
642+/* Find a matching node for the slave at (link, id). Returns NULL if none
643+ * found, or a matching node with refcount already incremented.
644+ */
645+static struct device_node *fsi_slave_find_of_node(struct fsi_master *master,
646+ int link, uint8_t id)
647+{
648+ struct device_node *parent, *np;
649+
650+ parent = dev_of_node(&master->dev);
651+ if (!parent)
652+ return NULL;
653+
654+ for_each_child_of_node(parent, np) {
655+ if (fsi_slave_node_matches(np, link, id))
656+ return np;
657+ }
658+
659+ return NULL;
660+}
661+
564662 static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
565663 {
566664 uint32_t chip_id, llmode;
@@ -589,7 +687,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) · 22 unmodified lines
589687 return -EIO;
590688 }
591689
592− dev_info(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n",
690+ dev_dbg(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n",
593691 chip_id, master->idx, link, id);
594692
595693 rc = fsi_slave_set_smode(master, link, id);
@@ -623,6 +721,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) · 27 unmodified lines
623721
624722 slave->master = master;
625723 slave->dev.parent = &master->dev;
724+ slave->dev.of_node = fsi_slave_find_of_node(master, link, id);
626725 slave->dev.release = fsi_slave_release;
627726 slave->link = link;
628727 slave->id = id;
@@ -656,10 +755,13 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) · 27 unmodified lines
656755 /* FSI master support */
657756 static int fsi_check_access(uint32_t addr, size_t size)
658757 {
659− if (size != 1 && size != 2 && size != 4)
660− return -EINVAL;
661−
662− if ((addr & 0x3) != (size & 0x3))
758+ if (size == 4) {
759+ if (addr & 0x3)
760+ return -EINVAL;
761+ } else if (size == 2) {
762+ if (addr & 0x1)
763+ return -EINVAL;
764+ } else if (size != 1)
663765 return -EINVAL;
664766
665767 return 0;
@@ -762,14 +864,20 @@ static void fsi_master_unscan(struct fsi_master *master) · 96 unmodified lines
762864 device_for_each_child(&master->dev, NULL, fsi_master_remove_slave);
763865 }
764866
867+int fsi_master_rescan(struct fsi_master *master)
868+{
869+ fsi_master_unscan(master);
870+ return fsi_master_scan(master);
871+}
872+EXPORT_SYMBOL_GPL(fsi_master_rescan);
873+
765874 static ssize_t master_rescan_store(struct device *dev,
766875 struct device_attribute *attr, const char *buf, size_t count)
767876 {
768877 struct fsi_master *master = to_fsi_master(dev);
769878 int rc;
770879
771− fsi_master_unscan(master);
772− rc = fsi_master_scan(master);
880+ rc = fsi_master_rescan(master);
773881 if (rc < 0)
774882 return rc;
775883
@@ -793,6 +901,7 @@ static DEVICE_ATTR(break, 0200, NULL, master_break_store); · 17 unmodified lines
793901 int fsi_master_register(struct fsi_master *master)
794902 {
795903 int rc;
904+ struct device_node *np;
796905
797906 if (!master)
798907 return -EINVAL;
@@ -820,7 +929,9 @@ int fsi_master_register(struct fsi_master *master) · 21 unmodified lines
820929 return rc;
821930 }
822931
823− fsi_master_scan(master);
932+ np = dev_of_node(&master->dev);
933+ if (!of_property_read_bool(np, "no-scan-on-init"))
934+ fsi_master_scan(master);
824935
825936 return 0;
826937 }
drivers/fsi/fsi-master-gpio.c+87−2
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/gpio/consumer.h>
1010 #include <linux/io.h>
1111 #include <linux/module.h>
12+#include <linux/of.h>
1213 #include <linux/platform_device.h>
1314 #include <linux/slab.h>
1415 #include <linux/spinlock.h>
@@ -59,6 +60,7 @@ struct fsi_master_gpio { · 44 unmodified lines
5960 struct gpio_desc *gpio_trans; /* Voltage translator */
6061 struct gpio_desc *gpio_enable; /* FSI enable */
6162 struct gpio_desc *gpio_mux; /* Mux control */
63+ bool external_mode;
6264 };
6365
6466 #define CREATE_TRACE_POINTS
@@ -411,6 +413,12 @@ static int fsi_master_gpio_xfer(struct fsi_master_gpio *master, uint8_t slave, · 346 unmodified lines
411413 int rc;
412414
413415 spin_lock_irqsave(&master->cmd_lock, flags);
416+
417+ if (master->external_mode) {
418+ spin_unlock_irqrestore(&master->cmd_lock, flags);
419+ return -EBUSY;
420+ }
421+
414422 serial_out(master, cmd);
415423 echo_delay(master);
416424 rc = poll_for_response(master, slave, resp_len, resp);
@@ -461,12 +469,18 @@ static int fsi_master_gpio_term(struct fsi_master *_master, · 44 unmodified lines
461469 static int fsi_master_gpio_break(struct fsi_master *_master, int link)
462470 {
463471 struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
472+ unsigned long flags;
464473
465474 if (link != 0)
466475 return -ENODEV;
467476
468477 trace_fsi_master_gpio_break(master);
469478
479+ spin_lock_irqsave(&master->cmd_lock, flags);
480+ if (master->external_mode) {
481+ spin_unlock_irqrestore(&master->cmd_lock, flags);
482+ return -EBUSY;
483+ }
470484 set_sda_output(master, 1);
471485 sda_out(master, 1);
472486 clock_toggle(master, FSI_PRE_BREAK_CLOCKS);
@@ -475,6 +489,7 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link) · 2 unmodified lines
475489 echo_delay(master);
476490 sda_out(master, 1);
477491 clock_toggle(master, FSI_POST_BREAK_CLOCKS);
492+ spin_unlock_irqrestore(&master->cmd_lock, flags);
478493
479494 /* Wait for logic reset to take effect */
480495 udelay(200);
@@ -494,21 +509,84 @@ static void fsi_master_gpio_init(struct fsi_master_gpio *master) · 13 unmodified lines
494509 clock_zeros(master, FSI_INIT_CLOCKS);
495510 }
496511
512+static void fsi_master_gpio_init_external(struct fsi_master_gpio *master)
513+{
514+ gpiod_direction_output(master->gpio_mux, 0);
515+ gpiod_direction_output(master->gpio_trans, 0);
516+ gpiod_direction_output(master->gpio_enable, 1);
517+ gpiod_direction_input(master->gpio_clk);
518+ gpiod_direction_input(master->gpio_data);
519+}
520+
497521 static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
498522 {
499523 struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
524+ unsigned long flags;
525+ int rc = -EBUSY;
500526
501527 if (link != 0)
502528 return -ENODEV;
503− gpiod_set_value(master->gpio_enable, 1);
504529
505− return 0;
530+ spin_lock_irqsave(&master->cmd_lock, flags);
531+ if (!master->external_mode) {
532+ gpiod_set_value(master->gpio_enable, 1);
533+ rc = 0;
534+ }
535+ spin_unlock_irqrestore(&master->cmd_lock, flags);
536+
537+ return rc;
538+}
539+
540+static ssize_t external_mode_show(struct device *dev,
541+ struct device_attribute *attr, char *buf)
542+{
543+ struct fsi_master_gpio *master = dev_get_drvdata(dev);
544+
545+ return snprintf(buf, PAGE_SIZE - 1, "%u\n",
546+ master->external_mode ? 1 : 0);
506547 }
507548
549+static ssize_t external_mode_store(struct device *dev,
550+ struct device_attribute *attr, const char *buf, size_t count)
551+{
552+ struct fsi_master_gpio *master = dev_get_drvdata(dev);
553+ unsigned long flags, val;
554+ bool external_mode;
555+ int err;
556+
557+ err = kstrtoul(buf, 0, &val);
558+ if (err)
559+ return err;
560+
561+ external_mode = !!val;
562+
563+ spin_lock_irqsave(&master->cmd_lock, flags);
564+
565+ if (external_mode == master->external_mode) {
566+ spin_unlock_irqrestore(&master->cmd_lock, flags);
567+ return count;
568+ }
569+
570+ master->external_mode = external_mode;
571+ if (master->external_mode)
572+ fsi_master_gpio_init_external(master);
573+ else
574+ fsi_master_gpio_init(master);
575+ spin_unlock_irqrestore(&master->cmd_lock, flags);
576+
577+ fsi_master_rescan(&master->master);
578+
579+ return count;
580+}
581+
582+static DEVICE_ATTR(external_mode, 0664,
583+ external_mode_show, external_mode_store);
584+
508585 static int fsi_master_gpio_probe(struct platform_device *pdev)
509586 {
510587 struct fsi_master_gpio *master;
511588 struct gpio_desc *gpio;
589+ int rc;
512590
513591 master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
514592 if (!master)
@@ -516,6 +594,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) · 1 unmodified line
516594
517595 master->dev = &pdev->dev;
518596 master->master.dev.parent = master->dev;
597+ master->master.dev.of_node = of_node_get(dev_of_node(master->dev));
519598
520599 gpio = devm_gpiod_get(&pdev->dev, "clock", 0);
521600 if (IS_ERR(gpio)) {
@@ -565,6 +644,10 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) · 43 unmodified lines
565644
566645 fsi_master_gpio_init(master);
567646
647+ rc = device_create_file(&pdev->dev, &dev_attr_external_mode);
648+ if (rc)
649+ return rc;
650+
568651 return fsi_master_register(&master->master);
569652 }
570653
@@ -583,6 +666,8 @@ static int fsi_master_gpio_remove(struct platform_device *pdev) · 12 unmodified lines
583666 devm_gpiod_put(&pdev->dev, master->gpio_mux);
584667 fsi_master_unregister(&master->master);
585668
669+ of_node_put(master->master.dev.of_node);
670+
586671 return 0;
587672 }
588673
drivers/fsi/fsi-master-hub.c+23−4
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/delay.h>
1717 #include <linux/fsi.h>
1818 #include <linux/module.h>
19+#include <linux/of.h>
1920 #include <linux/slab.h>
2021
2122 #include "fsi-master.h"
@@ -253,7 +254,7 @@ static int hub_master_probe(struct device *dev) · 231 unmodified lines
253254
254255 reg = be32_to_cpu(__reg);
255256 links = (reg >> 8) & 0xff;
256− dev_info(dev, "hub version %08x (%d links)\n", reg, links);
257+ dev_dbg(dev, "hub version %08x (%d links)\n", reg, links);
257258
258259 rc = fsi_slave_claim_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET,
259260 FSI_HUB_LINK_SIZE * links);
@@ -274,6 +275,7 @@ static int hub_master_probe(struct device *dev) · 14 unmodified lines
274275
275276 hub->master.dev.parent = dev;
276277 hub->master.dev.release = hub_master_release;
278+ hub->master.dev.of_node = of_node_get(dev_of_node(dev));
277279
278280 hub->master.n_links = links;
279281 hub->master.read = hub_master_read;
@@ -286,10 +288,19 @@ static int hub_master_probe(struct device *dev) · 6 unmodified lines
286288 hub_master_init(hub);
287289
288290 rc = fsi_master_register(&hub->master);
289− if (!rc)
290− return 0;
291+ if (rc)
292+ goto err_release;
293+
294+ /* At this point, fsi_master_register performs the device_initialize(),
295+ * and holds the sole reference on master.dev. This means the device
296+ * will be freed (via ->release) during any subsequent call to
297+ * fsi_master_unregister. We add our own reference to it here, so we
298+ * can perform cleanup (in _remove()) without it being freed before
299+ * we're ready.
300+ */
301+ get_device(&hub->master.dev);
302+ return 0;
291303
292− kfree(hub);
293304 err_release:
294305 fsi_slave_release_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET,
295306 FSI_HUB_LINK_SIZE * links);
@@ -302,6 +313,14 @@ static int hub_master_remove(struct device *dev) · 6 unmodified lines
302313
303314 fsi_master_unregister(&hub->master);
304315 fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size);
316+ of_node_put(hub->master.dev.of_node);
317+
318+ /*
319+ * master.dev will likely be ->release()ed after this, which free()s
320+ * the hub
321+ */
322+ put_device(&hub->master.dev);
323+
305324 return 0;
306325 }
307326
drivers/fsi/fsi-master.h+17−0
@@ -37,7 +37,24 @@ struct fsi_master { · 36 unmodified lines
3737
3838 #define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev)
3939
40+/**
41+ * fsi_master registration & lifetime: the fsi_master_register() and
42+ * fsi_master_unregister() functions will take ownership of the master, and
43+ * ->dev in particular. The registration path performs a get_device(), which
44+ * takes the first reference on the device. Similarly, the unregistration path
45+ * performs a put_device(), which may well drop the last reference.
46+ *
47+ * This means that master implementations *may* need to hold their own
48+ * reference (via get_device()) on master->dev. In particular, if the device's
49+ * ->release callback frees the fsi_master, then fsi_master_unregister will
50+ * invoke this free if no other reference is held.
51+ *
52+ * The same applies for the error path of fsi_master_register; if the call
53+ * fails, dev->release will have been invoked.
54+ */
4055 extern int fsi_master_register(struct fsi_master *master);
4156 extern void fsi_master_unregister(struct fsi_master *master);
4257
58+extern int fsi_master_rescan(struct fsi_master *master);
59+
4360 #endif /* DRIVERS_FSI_MASTER_H */
drivers/gpu/drm/bridge/sil-sii8620.c+94−3
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717
1818 #include <linux/clk.h>
1919 #include <linux/delay.h>
20+#include <linux/extcon.h>
2021 #include <linux/gpio/consumer.h>
2122 #include <linux/i2c.h>
2223 #include <linux/interrupt.h>
@@ -25,6 +26,7 @@ · 2 unmodified lines
2526 #include <linux/list.h>
2627 #include <linux/module.h>
2728 #include <linux/mutex.h>
29+#include <linux/of_graph.h>
2830 #include <linux/regulator/consumer.h>
2931 #include <linux/slab.h>
3032
@@ -81,6 +83,10 @@ struct sii8620 { · 50 unmodified lines
8183 struct edid *edid;
8284 unsigned int gen2_write_burst:1;
8385 enum sii8620_mt_state mt_state;
86+ struct extcon_dev *extcon;
87+ struct notifier_block extcon_nb;
88+ struct work_struct extcon_wq;
89+ int cable_state;
8490 struct list_head mt_queue;
8591 struct {
8692 int r_size;
@@ -2170,6 +2176,77 @@ static void sii8620_init_rcp_input_dev(struct sii8620 *ctx) · 2083 unmodified lines
21702176 ctx->rc_dev = rc_dev;
21712177 }
21722178
2179+static void sii8620_cable_out(struct sii8620 *ctx)
2180+{
2181+ disable_irq(to_i2c_client(ctx->dev)->irq);
2182+ sii8620_hw_off(ctx);
2183+}
2184+
2185+static void sii8620_extcon_work(struct work_struct *work)
2186+{
2187+ struct sii8620 *ctx =
2188+ container_of(work, struct sii8620, extcon_wq);
2189+ int state = extcon_get_state(ctx->extcon, EXTCON_DISP_MHL);
2190+
2191+ if (state == ctx->cable_state)
2192+ return;
2193+
2194+ ctx->cable_state = state;
2195+
2196+ if (state > 0)
2197+ sii8620_cable_in(ctx);
2198+ else
2199+ sii8620_cable_out(ctx);
2200+}
2201+
2202+static int sii8620_extcon_notifier(struct notifier_block *self,
2203+ unsigned long event, void *ptr)
2204+{
2205+ struct sii8620 *ctx =
2206+ container_of(self, struct sii8620, extcon_nb);
2207+
2208+ schedule_work(&ctx->extcon_wq);
2209+
2210+ return NOTIFY_DONE;
2211+}
2212+
2213+static int sii8620_extcon_init(struct sii8620 *ctx)
2214+{
2215+ struct extcon_dev *edev;
2216+ struct device_node *musb, *muic;
2217+ int ret;
2218+
2219+ /* get micro-USB connector node */
2220+ musb = of_graph_get_remote_node(ctx->dev->of_node, 1, -1);
2221+ /* next get micro-USB Interface Controller node */
2222+ muic = of_get_next_parent(musb);
2223+
2224+ if (!muic) {
2225+ dev_info(ctx->dev, "no extcon found, switching to 'always on' mode\n");
2226+ return 0;
2227+ }
2228+
2229+ edev = extcon_find_edev_by_node(muic);
2230+ of_node_put(muic);
2231+ if (IS_ERR(edev)) {
2232+ if (PTR_ERR(edev) == -EPROBE_DEFER)
2233+ return -EPROBE_DEFER;
2234+ dev_err(ctx->dev, "Invalid or missing extcon\n");
2235+ return PTR_ERR(edev);
2236+ }
2237+
2238+ ctx->extcon = edev;
2239+ ctx->extcon_nb.notifier_call = sii8620_extcon_notifier;
2240+ INIT_WORK(&ctx->extcon_wq, sii8620_extcon_work);
2241+ ret = extcon_register_notifier(edev, EXTCON_DISP_MHL, &ctx->extcon_nb);
2242+ if (ret) {
2243+ dev_err(ctx->dev, "failed to register notifier for MHL\n");
2244+ return ret;
2245+ }
2246+
2247+ return 0;
2248+}
2249+
21732250 static inline struct sii8620 *bridge_to_sii8620(struct drm_bridge *bridge)
21742251 {
21752252 return container_of(bridge, struct sii8620, bridge);
@@ -2302,13 +2379,20 @@ static int sii8620_probe(struct i2c_client *client, · 126 unmodified lines
23022379 if (ret)
23032380 return ret;
23042381
2382+ ret = sii8620_extcon_init(ctx);
2383+ if (ret < 0) {
2384+ dev_err(ctx->dev, "failed to initialize EXTCON\n");
2385+ return ret;
2386+ }
2387+
23052388 i2c_set_clientdata(client, ctx);
23062389
23072390 ctx->bridge.funcs = &sii8620_bridge_funcs;
23082391 ctx->bridge.of_node = dev->of_node;
23092392 drm_bridge_add(&ctx->bridge);
23102393
2311− sii8620_cable_in(ctx);
2394+ if (!ctx->extcon)
2395+ sii8620_cable_in(ctx);
23122396
23132397 return 0;
23142398 }
@@ -2317,8 +2401,15 @@ static int sii8620_remove(struct i2c_client *client) · 2 unmodified lines
23172401 {
23182402 struct sii8620 *ctx = i2c_get_clientdata(client);
23192403
2320− disable_irq(to_i2c_client(ctx->dev)->irq);
2321− sii8620_hw_off(ctx);
2404+ if (ctx->extcon) {
2405+ extcon_unregister_notifier(ctx->extcon, EXTCON_DISP_MHL,
2406+ &ctx->extcon_nb);
2407+ flush_work(&ctx->extcon_wq);
2408+ if (ctx->cable_state > 0)
2409+ sii8620_cable_out(ctx);
2410+ } else {
2411+ sii8620_cable_out(ctx);
2412+ }
23222413 drm_bridge_remove(&ctx->bridge);
23232414
23242415 return 0;
drivers/hv/Kconfig+2−0
@@ -1,3 +1,5 @@
1+# SPDX-License-Identifier: GPL-2.0
2+
13 menu "Microsoft Hyper-V guest support"
24
35 config HYPERV
drivers/hv/Makefile+1−0
@@ -4,6 +4,7 @@ obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o · 3 unmodified lines
44 obj-$(CONFIG_HYPERV_BALLOON) += hv_balloon.o
55
66 CFLAGS_hv_trace.o = -I$(src)
7+CFLAGS_hv_balloon.o = -I$(src)
78
89 hv_vmbus-y := vmbus_drv.o \
910 hv.o connection.o channel.o \
drivers/hv/channel_mgmt.c+3−5
@@ -71,7 +71,7 @@ static const struct vmbus_device vmbus_devs[] = { · 70 unmodified lines
7171 /* PCIE */
7272 { .dev_type = HV_PCIE,
7373 HV_PCIE_GUID,
74− .perf_device = true,
74+ .perf_device = false,
7575 },
7676
7777 /* Synthetic Frame Buffer */
@@ -596,10 +596,8 @@ static int next_numa_node_id; · 518 unmodified lines
596596 /*
597597 * Starting with Win8, we can statically distribute the incoming
598598 * channel interrupt load by binding a channel to VCPU.
599− * We do this in a hierarchical fashion:
600− * First distribute the primary channels across available NUMA nodes
601− * and then distribute the subchannels amongst the CPUs in the NUMA
602− * node assigned to the primary channel.
599+ * We distribute the interrupt loads to one or more NUMA nodes based on
600+ * the channel's affinity_policy.
603601 *
604602 * For pre-win8 hosts or non-performance critical channels we assign the
605603 * first CPU in the first NUMA node.
drivers/hv/hv.c+58−6
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #include <linux/vmalloc.h>
2828 #include <linux/hyperv.h>
2929 #include <linux/version.h>
30−#include <linux/interrupt.h>
30+#include <linux/random.h>
3131 #include <linux/clockchips.h>
3232 #include <asm/hyperv.h>
3333 #include <asm/mshyperv.h>
@@ -38,6 +38,17 @@ struct hv_context hv_context = { · 4 unmodified lines
3838 .synic_initialized = false,
3939 };
4040
41+/*
42+ * If false, we're using the old mechanism for stimer0 interrupts
43+ * where it sends a VMbus message when it expires. The old
44+ * mechanism is used when running on older versions of Hyper-V
45+ * that don't support Direct Mode. While Hyper-V provides
46+ * four stimer's per CPU, Linux uses only stimer0.
47+ */
48+static bool direct_mode_enabled;
49+static int stimer0_irq;
50+static int stimer0_vector;
51+
4152 #define HV_TIMER_FREQUENCY (10 * 1000 * 1000) /* 100ns period */
4253 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
4354 #define HV_MIN_DELTA_TICKS 1
@@ -53,6 +64,8 @@ int hv_init(void) · 9 unmodified lines
5364 if (!hv_context.cpu_context)
5465 return -ENOMEM;
5566
67+ direct_mode_enabled = ms_hyperv.misc_features &
68+ HV_X64_STIMER_DIRECT_MODE_AVAILABLE;
5669 return 0;
5770 }
5871
@@ -91,6 +104,21 @@ int hv_post_message(union hv_connection_id connection_id, · 32 unmodified lines
91104 return status & 0xFFFF;
92105 }
93106
107+/*
108+ * ISR for when stimer0 is operating in Direct Mode. Direct Mode
109+ * does not use VMbus or any VMbus messages, so process here and not
110+ * in the VMbus driver code.
111+ */
112+
113+static void hv_stimer0_isr(void)
114+{
115+ struct hv_per_cpu_context *hv_cpu;
116+
117+ hv_cpu = this_cpu_ptr(hv_context.cpu_context);
118+ hv_cpu->clk_evt->event_handler(hv_cpu->clk_evt);
119+ add_interrupt_randomness(stimer0_vector, 0);
120+}
121+
94122 static int hv_ce_set_next_event(unsigned long delta,
95123 struct clock_event_device *evt)
96124 {
@@ -108,6 +136,8 @@ static int hv_ce_shutdown(struct clock_event_device *evt) · 11 unmodified lines
108136 {
109137 hv_init_timer(HV_X64_MSR_STIMER0_COUNT, 0);
110138 hv_init_timer_config(HV_X64_MSR_STIMER0_CONFIG, 0);
139+ if (direct_mode_enabled)
140+ hv_disable_stimer0_percpu_irq(stimer0_irq);
111141
112142 return 0;
113143 }
@@ -116,11 +146,26 @@ static int hv_ce_set_oneshot(struct clock_event_device *evt) · 2 unmodified lines
116146 {
117147 union hv_timer_config timer_cfg;
118148
149+ timer_cfg.as_uint64 = 0;
119150 timer_cfg.enable = 1;
120151 timer_cfg.auto_enable = 1;
121− timer_cfg.sintx = VMBUS_MESSAGE_SINT;
152+ if (direct_mode_enabled) {
153+ /*
154+ * When it expires, the timer will directly interrupt
155+ * on the specified hardware vector/IRQ.
156+ */
157+ timer_cfg.direct_mode = 1;
158+ timer_cfg.apic_vector = stimer0_vector;
159+ hv_enable_stimer0_percpu_irq(stimer0_irq);
160+ } else {
161+ /*
162+ * When it expires, the timer will generate a VMbus message,
163+ * to be handled by the normal VMbus interrupt handler.
164+ */
165+ timer_cfg.direct_mode = 0;
166+ timer_cfg.sintx = VMBUS_MESSAGE_SINT;
167+ }
122168 hv_init_timer_config(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
123−
124169 return 0;
125170 }
126171
@@ -147,7 +192,7 @@ int hv_synic_alloc(void) · 20 unmodified lines
147192 int cpu;
148193
149194 hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
150− GFP_ATOMIC);
195+ GFP_KERNEL);
151196 if (hv_context.hv_numa_map == NULL) {
152197 pr_err("Unable to allocate NUMA map\n");
153198 goto err;
@@ -191,6 +236,11 @@ int hv_synic_alloc(void) · 37 unmodified lines
191236 INIT_LIST_HEAD(&hv_cpu->chan_list);
192237 }
193238
239+ if (direct_mode_enabled &&
240+ hv_setup_stimer0_irq(&stimer0_irq, &stimer0_vector,
241+ hv_stimer0_isr))
242+ goto err;
243+
194244 return 0;
195245 err:
196246 return -ENOMEM;
@@ -217,7 +267,7 @@ void hv_synic_free(void) · 20 unmodified lines
217267 }
218268
219269 /*
220− * hv_synic_init - Initialize the Synthethic Interrupt Controller.
270+ * hv_synic_init - Initialize the Synthetic Interrupt Controller.
221271 *
222272 * If it is already initialized by another entity (ie x2v shim), we need to
223273 * retrieve the initialized message and event pages. Otherwise, we create and
@@ -252,7 +302,6 @@ int hv_synic_init(unsigned int cpu) · 28 unmodified lines
252302 hv_get_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT,
253303 shared_sint.as_uint64);
254304
255− shared_sint.as_uint64 = 0;
256305 shared_sint.vector = HYPERVISOR_CALLBACK_VECTOR;
257306 shared_sint.masked = false;
258307 if (ms_hyperv.hints & HV_X64_DEPRECATING_AEOI_RECOMMENDED)
@@ -292,6 +341,9 @@ void hv_synic_clockevents_cleanup(void) · 33 unmodified lines
292341 if (!(ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE))
293342 return;
294343
344+ if (direct_mode_enabled)
345+ hv_remove_stimer0_irq(stimer0_irq);
346+
295347 for_each_present_cpu(cpu) {
296348 struct hv_per_cpu_context *hv_cpu
297349 = per_cpu_ptr(hv_context.cpu_context, cpu);
drivers/hv/hv_balloon.c+83−38
@@ -34,6 +34,9 @@ · 33 unmodified lines
3434
3535 #include <linux/hyperv.h>
3636
37+#define CREATE_TRACE_POINTS
38+#include "hv_trace_balloon.h"
39+
3740 /*
3841 * We begin with definitions supporting the Dynamic Memory protocol
3942 * with the host.
@@ -576,11 +579,65 @@ static struct hv_dynmem_device dm_device; · 536 unmodified lines
576579 static void post_status(struct hv_dynmem_device *dm);
577580
578581 #ifdef CONFIG_MEMORY_HOTPLUG
582+static inline bool has_pfn_is_backed(struct hv_hotadd_state *has,
583+ unsigned long pfn)
584+{
585+ struct hv_hotadd_gap *gap;
586+
587+ /* The page is not backed. */
588+ if ((pfn < has->covered_start_pfn) || (pfn >= has->covered_end_pfn))
589+ return false;
590+
591+ /* Check for gaps. */
592+ list_for_each_entry(gap, &has->gap_list, list) {
593+ if ((pfn >= gap->start_pfn) && (pfn < gap->end_pfn))
594+ return false;
595+ }
596+
597+ return true;
598+}
599+
600+static unsigned long hv_page_offline_check(unsigned long start_pfn,
601+ unsigned long nr_pages)
602+{
603+ unsigned long pfn = start_pfn, count = 0;
604+ struct hv_hotadd_state *has;
605+ bool found;
606+
607+ while (pfn < start_pfn + nr_pages) {
608+ /*
609+ * Search for HAS which covers the pfn and when we find one
610+ * count how many consequitive PFNs are covered.
611+ */
612+ found = false;
613+ list_for_each_entry(has, &dm_device.ha_region_list, list) {
614+ while ((pfn >= has->start_pfn) &&
615+ (pfn < has->end_pfn) &&
616+ (pfn < start_pfn + nr_pages)) {
617+ found = true;
618+ if (has_pfn_is_backed(has, pfn))
619+ count++;
620+ pfn++;
621+ }
622+ }
623+
624+ /*
625+ * This PFN is not in any HAS (e.g. we're offlining a region
626+ * which was present at boot), no need to account for it. Go
627+ * to the next one.
628+ */
629+ if (!found)
630+ pfn++;
631+ }
632+
633+ return count;
634+}
635+
579636 static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
580637 void *v)
581638 {
582639 struct memory_notify *mem = (struct memory_notify *)v;
583− unsigned long flags;
640+ unsigned long flags, pfn_count;
584641
585642 switch (val) {
586643 case MEM_ONLINE:
@@ -593,7 +650,19 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, · 6 unmodified lines
593650
594651 case MEM_OFFLINE:
595652 spin_lock_irqsave(&dm_device.ha_lock, flags);
596− dm_device.num_pages_onlined -= mem->nr_pages;
653+ pfn_count = hv_page_offline_check(mem->start_pfn,
654+ mem->nr_pages);
655+ if (pfn_count <= dm_device.num_pages_onlined) {
656+ dm_device.num_pages_onlined -= pfn_count;
657+ } else {
658+ /*
659+ * We're offlining more pages than we managed to online.
660+ * This is unexpected. In any case don't let
661+ * num_pages_onlined wrap around zero.
662+ */
663+ WARN_ON_ONCE(1);
664+ dm_device.num_pages_onlined = 0;
665+ }
597666 spin_unlock_irqrestore(&dm_device.ha_lock, flags);
598667 break;
599668 case MEM_GOING_ONLINE:
@@ -612,30 +681,9 @@ static struct notifier_block hv_memory_nb = { · 12 unmodified lines
612681 /* Check if the particular page is backed and can be onlined and online it. */
613682 static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg)
614683 {
615− unsigned long cur_start_pgp;
616− unsigned long cur_end_pgp;
617− struct hv_hotadd_gap *gap;
618−
619− cur_start_pgp = (unsigned long)pfn_to_page(has->covered_start_pfn);
620− cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn);
621−
622− /* The page is not backed. */
623− if (((unsigned long)pg < cur_start_pgp) ||
624− ((unsigned long)pg >= cur_end_pgp))
684+ if (!has_pfn_is_backed(has, page_to_pfn(pg)))
625685 return;
626686
627− /* Check for gaps. */
628− list_for_each_entry(gap, &has->gap_list, list) {
629− cur_start_pgp = (unsigned long)
630− pfn_to_page(gap->start_pfn);
631− cur_end_pgp = (unsigned long)
632− pfn_to_page(gap->end_pfn);
633− if (((unsigned long)pg >= cur_start_pgp) &&
634− ((unsigned long)pg < cur_end_pgp)) {
635− return;
636− }
637− }
638−
639687 /* This frame is currently backed; online the page. */
640688 __online_page_set_limits(pg);
641689 __online_page_increment_counters(pg);
@@ -691,7 +739,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, · 49 unmodified lines
691739 (HA_CHUNK << PAGE_SHIFT));
692740
693741 if (ret) {
694− pr_warn("hot_add memory failed error is %d\n", ret);
742+ pr_err("hot_add memory failed error is %d\n", ret);
695743 if (ret == -EEXIST) {
696744 /*
697745 * This error indicates that the error
@@ -726,19 +774,13 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, · 28 unmodified lines
726774 static void hv_online_page(struct page *pg)
727775 {
728776 struct hv_hotadd_state *has;
729− unsigned long cur_start_pgp;
730− unsigned long cur_end_pgp;
731777 unsigned long flags;
778+ unsigned long pfn = page_to_pfn(pg);
732779
733780 spin_lock_irqsave(&dm_device.ha_lock, flags);
734781 list_for_each_entry(has, &dm_device.ha_region_list, list) {
735− cur_start_pgp = (unsigned long)
736− pfn_to_page(has->start_pfn);
737− cur_end_pgp = (unsigned long)pfn_to_page(has->end_pfn);
738−
739782 /* The page belongs to a different HAS. */
740− if (((unsigned long)pg < cur_start_pgp) ||
741− ((unsigned long)pg >= cur_end_pgp))
783+ if ((pfn < has->start_pfn) || (pfn >= has->end_pfn))
742784 continue;
743785
744786 hv_page_online_one(has, pg);
@@ -1014,7 +1056,7 @@ static void hot_add_req(struct work_struct *dummy) · 269 unmodified lines
10141056 resp.result = 0;
10151057
10161058 if (!do_hot_add || (resp.page_count == 0))
1017− pr_info("Memory hot add failed\n");
1059+ pr_err("Memory hot add failed\n");
10181060
10191061 dm->state = DM_INITIALIZED;
10201062 resp.hdr.trans_id = atomic_inc_return(&trans_id);
@@ -1041,7 +1083,7 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg) · 20 unmodified lines
10411083
10421084 break;
10431085 default:
1044− pr_info("Received Unknown type: %d\n", info_hdr->type);
1086+ pr_warn("Received Unknown type: %d\n", info_hdr->type);
10451087 }
10461088 }
10471089
@@ -1120,6 +1162,9 @@ static void post_status(struct hv_dynmem_device *dm) · 72 unmodified lines
11201162 dm->num_pages_added - dm->num_pages_onlined : 0) +
11211163 compute_balloon_floor();
11221164
1165+ trace_balloon_status(status.num_avail, status.num_committed,
1166+ vm_memory_committed(), dm->num_pages_ballooned,
1167+ dm->num_pages_added, dm->num_pages_onlined);
11231168 /*
11241169 * If our transaction ID is no longer current, just don't
11251170 * send the status. This can happen if we were interrupted
@@ -1290,7 +1335,7 @@ static void balloon_up(struct work_struct *dummy) · 164 unmodified lines
12901335 /*
12911336 * Free up the memory we allocatted.
12921337 */
1293− pr_info("Balloon response failed\n");
1338+ pr_err("Balloon response failed\n");
12941339
12951340 for (i = 0; i < bl_resp->range_count; i++)
12961341 free_balloon_pages(&dm_device,
@@ -1421,7 +1466,7 @@ static void cap_resp(struct hv_dynmem_device *dm, · 124 unmodified lines
14211466 struct dm_capabilities_resp_msg *cap_resp)
14221467 {
14231468 if (!cap_resp->is_accepted) {
1424− pr_info("Capabilities not accepted by host\n");
1469+ pr_err("Capabilities not accepted by host\n");
14251470 dm->state = DM_INIT_ERROR;
14261471 }
14271472 complete(&dm->host_event);
@@ -1508,7 +1553,7 @@ static void balloon_onchannelcallback(void *context) · 80 unmodified lines
15081553 break;
15091554
15101555 default:
1511− pr_err("Unhandled message: type: %d\n", dm_hdr->type);
1556+ pr_warn("Unhandled message: type: %d\n", dm_hdr->type);
15121557
15131558 }
15141559 }
drivers/hv/hv_trace.c+2−0
@@ -1,3 +1,5 @@
1+// SPDX-License-Identifier: GPL-2.0
2+
13 #include "hyperv_vmbus.h"
24
35 #define CREATE_TRACE_POINTS
drivers/hv/hv_trace.h+2−0
@@ -1,3 +1,5 @@
1+// SPDX-License-Identifier: GPL-2.0
2+
13 #undef TRACE_SYSTEM
24 #define TRACE_SYSTEM hyperv
35
drivers/hv/hv_trace_balloon.h+48−0
@@ -0,0 +1,48 @@
1+#undef TRACE_SYSTEM
2+#define TRACE_SYSTEM hyperv
3+
4+#if !defined(_HV_TRACE_BALLOON_H) || defined(TRACE_HEADER_MULTI_READ)
5+#define _HV_TRACE_BALLOON_H
6+
7+#include <linux/tracepoint.h>
8+
9+TRACE_EVENT(balloon_status,
10+ TP_PROTO(u64 available, u64 committed,
11+ unsigned long vm_memory_committed,
12+ unsigned long pages_ballooned,
13+ unsigned long pages_added,
14+ unsigned long pages_onlined),
15+ TP_ARGS(available, committed, vm_memory_committed,
16+ pages_ballooned, pages_added, pages_onlined),
17+ TP_STRUCT__entry(
18+ __field(u64, available)
19+ __field(u64, committed)
20+ __field(unsigned long, vm_memory_committed)
21+ __field(unsigned long, pages_ballooned)
22+ __field(unsigned long, pages_added)
23+ __field(unsigned long, pages_onlined)
24+ ),
25+ TP_fast_assign(
26+ __entry->available = available;
27+ __entry->committed = committed;
28+ __entry->vm_memory_committed = vm_memory_committed;
29+ __entry->pages_ballooned = pages_ballooned;
30+ __entry->pages_added = pages_added;
31+ __entry->pages_onlined = pages_onlined;
32+ ),
33+ TP_printk("available %lld, committed %lld; vm_memory_committed %ld;"
34+ " pages_ballooned %ld, pages_added %ld, pages_onlined %ld",
35+ __entry->available, __entry->committed,
36+ __entry->vm_memory_committed, __entry->pages_ballooned,
37+ __entry->pages_added, __entry->pages_onlined
38+ )
39+ );
40+
41+#undef TRACE_INCLUDE_PATH
42+#define TRACE_INCLUDE_PATH .
43+#undef TRACE_INCLUDE_FILE
44+#define TRACE_INCLUDE_FILE hv_trace_balloon
45+#endif /* _HV_TRACE_BALLOON_H */
46+
47+/* This part must be outside protection */
48+#include <trace/define_trace.h>
drivers/hv/hyperv_vmbus.h+3−1
@@ -57,7 +57,9 @@ union hv_timer_config { · 56 unmodified lines
5757 u64 periodic:1;
5858 u64 lazy:1;
5959 u64 auto_enable:1;
60− u64 reserved_z0:12;
60+ u64 apic_vector:8;
61+ u64 direct_mode:1;
62+ u64 reserved_z0:3;
6163 u64 sintx:4;
6264 u64 reserved_z1:44;
6365 };
drivers/hwtracing/Kconfig+7−0
@@ -0,0 +1,7 @@
1+menu "HW tracing support"
2+
3+source "drivers/hwtracing/stm/Kconfig"
4+
5+source "drivers/hwtracing/intel_th/Kconfig"
6+
7+endmenu
drivers/hwtracing/coresight/coresight-cpu-debug.c+1−1
@@ -315,7 +315,7 @@ static void debug_dump_regs(struct debug_drvdata *drvdata) · 314 unmodified lines
315315 }
316316
317317 pc = debug_adjust_pc(drvdata);
318− dev_emerg(dev, " EDPCSR: [<%p>] %pS\n", (void *)pc, (void *)pc);
318+ dev_emerg(dev, " EDPCSR: [<%px>] %pS\n", (void *)pc, (void *)pc);
319319
320320 if (drvdata->edcidsr_present)
321321 dev_emerg(dev, " EDCIDSR: %08x\n", drvdata->edcidsr);
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c+2−2
@@ -1780,7 +1780,7 @@ static ssize_t ctxid_masks_store(struct device *dev, · 1779 unmodified lines
17801780 */
17811781 for (j = 0; j < 8; j++) {
17821782 if (maskbyte & 1)
1783− config->ctxid_pid[i] &= ~(0xFF << (j * 8));
1783+ config->ctxid_pid[i] &= ~(0xFFUL << (j * 8));
17841784 maskbyte >>= 1;
17851785 }
17861786 /* Select the next ctxid comparator mask value */
@@ -1963,7 +1963,7 @@ static ssize_t vmid_masks_store(struct device *dev, · 176 unmodified lines
19631963 */
19641964 for (j = 0; j < 8; j++) {
19651965 if (maskbyte & 1)
1966− config->vmid_val[i] &= ~(0xFF << (j * 8));
1966+ config->vmid_val[i] &= ~(0xFFUL << (j * 8));
19671967 maskbyte >>= 1;
19681968 }
19691969 /* Select the next vmid comparator mask value */
drivers/hwtracing/intel_th/Kconfig+12−0
@@ -25,6 +25,18 @@ config INTEL_TH_PCI · 24 unmodified lines
2525
2626 Say Y here to enable PCI Intel TH support.
2727
28+config INTEL_TH_ACPI
29+ tristate "Intel(R) Trace Hub ACPI controller"
30+ depends on ACPI
31+ help
32+ Intel(R) Trace Hub may exist as an ACPI device. This option enables
33+ support glue layer for ACPI-based Intel TH. This typically implies
34+ 'host debugger' mode, that is, the trace configuration and capture
35+ is handled by an external debug host and corresponding controls will
36+ not be available on the target.
37+
38+ Say Y here to enable ACPI Intel TH support.
39+
2840 config INTEL_TH_GTH
2941 tristate "Intel(R) Trace Hub Global Trace Hub"
3042 help
drivers/hwtracing/intel_th/Makefile+3−0
@@ -6,6 +6,9 @@ intel_th-$(CONFIG_INTEL_TH_DEBUG) += debug.o · 5 unmodified lines
66 obj-$(CONFIG_INTEL_TH_PCI) += intel_th_pci.o
77 intel_th_pci-y := pci.o
88
9+obj-$(CONFIG_INTEL_TH_ACPI) += intel_th_acpi.o
10+intel_th_acpi-y := acpi.o
11+
912 obj-$(CONFIG_INTEL_TH_GTH) += intel_th_gth.o
1013 intel_th_gth-y := gth.o
1114
drivers/hwtracing/intel_th/acpi.c+79−0
@@ -0,0 +1,79 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Intel(R) Trace Hub ACPI driver
4+ *
5+ * Copyright (C) 2017 Intel Corporation.
6+ */
7+
8+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9+
10+#include <linux/types.h>
11+#include <linux/module.h>
12+#include <linux/device.h>
13+#include <linux/sysfs.h>
14+#include <linux/platform_device.h>
15+#include <linux/acpi.h>
16+
17+#include "intel_th.h"
18+
19+#define DRIVER_NAME "intel_th_acpi"
20+
21+static const struct intel_th_drvdata intel_th_acpi_pch = {
22+ .host_mode_only = 1,
23+};
24+
25+static const struct intel_th_drvdata intel_th_acpi_uncore = {
26+ .host_mode_only = 1,
27+};
28+
29+static const struct acpi_device_id intel_th_acpi_ids[] = {
30+ { "INTC1000", (kernel_ulong_t)&intel_th_acpi_uncore },
31+ { "INTC1001", (kernel_ulong_t)&intel_th_acpi_pch },
32+ { "", 0 },
33+};
34+
35+MODULE_DEVICE_TABLE(acpi, intel_th_acpi_ids);
36+
37+static int intel_th_acpi_probe(struct platform_device *pdev)
38+{
39+ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
40+ const struct acpi_device_id *id;
41+ struct intel_th *th;
42+
43+ id = acpi_match_device(intel_th_acpi_ids, &pdev->dev);
44+ if (!id)
45+ return -ENODEV;
46+
47+ th = intel_th_alloc(&pdev->dev, (void *)id->driver_data,
48+ pdev->resource, pdev->num_resources, -1);
49+ if (IS_ERR(th))
50+ return PTR_ERR(th);
51+
52+ adev->driver_data = th;
53+
54+ return 0;
55+}
56+
57+static int intel_th_acpi_remove(struct platform_device *pdev)
58+{
59+ struct intel_th *th = platform_get_drvdata(pdev);
60+
61+ intel_th_free(th);
62+
63+ return 0;
64+}
65+
66+static struct platform_driver intel_th_acpi_driver = {
67+ .probe = intel_th_acpi_probe,
68+ .remove = intel_th_acpi_remove,
69+ .driver = {
70+ .name = DRIVER_NAME,
71+ .acpi_match_table = intel_th_acpi_ids,
72+ },
73+};
74+
75+module_platform_driver(intel_th_acpi_driver);
76+
77+MODULE_LICENSE("GPL v2");
78+MODULE_DESCRIPTION("Intel(R) Trace Hub ACPI controller driver");
79+MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");
drivers/hwtracing/intel_th/core.c+18−13
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub driver core
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -638,7 +630,8 @@ intel_th_subdevice_alloc(struct intel_th *th, · 621 unmodified lines
638630 thdev->output.port = -1;
639631 thdev->output.scratchpad = subdev->scrpd;
640632 } else if (subdev->type == INTEL_TH_SWITCH) {
641− thdev->host_mode = host_mode;
633+ thdev->host_mode =
634+ INTEL_TH_CAP(th, host_mode_only) ? true : host_mode;
642635 th->hub = thdev;
643636 }
644637
@@ -737,7 +730,8 @@ static int intel_th_populate(struct intel_th *th) · 92 unmodified lines
737730 struct intel_th_device *thdev;
738731
739732 /* only allow SOURCE and SWITCH devices in host mode */
740− if (host_mode && subdev->type == INTEL_TH_OUTPUT)
733+ if ((INTEL_TH_CAP(th, host_mode_only) || host_mode) &&
734+ subdev->type == INTEL_TH_OUTPUT)
741735 continue;
742736
743737 /*
@@ -813,7 +807,14 @@ intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata, · 69 unmodified lines
813807 struct resource *devres, unsigned int ndevres, int irq)
814808 {
815809 struct intel_th *th;
816− int err;
810+ int err, r;
811+
812+ if (irq == -1)
813+ for (r = 0; r < ndevres; r++)
814+ if (devres[r].flags & IORESOURCE_IRQ) {
815+ irq = devres[r].start;
816+ break;
817+ }
817818
818819 th = kzalloc(sizeof(*th), GFP_KERNEL);
819820 if (!th)
@@ -935,9 +936,13 @@ EXPORT_SYMBOL_GPL(intel_th_trace_disable); · 115 unmodified lines
935936 int intel_th_set_output(struct intel_th_device *thdev,
936937 unsigned int master)
937938 {
938− struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
939+ struct intel_th_device *hub = to_intel_th_hub(thdev);
939940 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
940941
942+ /* In host mode, this is up to the external debugger, do nothing. */
943+ if (hub->host_mode)
944+ return 0;
945+
941946 if (!hubdrv->set_output)
942947 return -ENOTSUPP;
943948
drivers/hwtracing/intel_th/debug.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub driver debugging
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #include <linux/types.h>
drivers/hwtracing/intel_th/debug.h+1−9
@@ -1,16 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Intel(R) Trace Hub driver debugging
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_DEBUG_H__
drivers/hwtracing/intel_th/gth.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub Global Trace Hub
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/hwtracing/intel_th/gth.h+1−9
@@ -1,16 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Intel(R) Trace Hub Global Trace Hub (GTH) data structures
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_GTH_H__
drivers/hwtracing/intel_th/intel_th.h+4−10
@@ -1,16 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Intel(R) Trace Hub data structures
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_H__
@@ -50,9 +42,11 @@ struct intel_th_output { · 33 unmodified lines
5042 /**
5143 * struct intel_th_drvdata - describes hardware capabilities and quirks
5244 * @tscu_enable: device needs SW to enable time stamping unit
45+ * @host_mode_only: device can only operate in 'host debugger' mode
5346 */
5447 struct intel_th_drvdata {
55− unsigned int tscu_enable : 1;
48+ unsigned int tscu_enable : 1,
49+ host_mode_only : 1;
5650 };
5751
5852 #define INTEL_TH_CAP(_th, _cap) ((_th)->drvdata ? (_th)->drvdata->_cap : 0)
drivers/hwtracing/intel_th/msu.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub Memory Storage Unit
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/hwtracing/intel_th/msu.h+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub Memory Storage Unit (MSU) data structures
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_MSU_H__
drivers/hwtracing/intel_th/pci.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub pci driver
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/hwtracing/intel_th/pti.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub PTI output driver
34 *
45 * Copyright (C) 2014-2016 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/hwtracing/intel_th/pti.h+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub PTI output data structures
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_STH_H__
drivers/hwtracing/intel_th/sth.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel(R) Trace Hub Software Trace Hub support
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/hwtracing/intel_th/sth.h+1−9
@@ -1,16 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Intel(R) Trace Hub Software Trace Hub (STH) data structures
34 *
45 * Copyright (C) 2014-2015 Intel Corporation.
5− *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
146 */
157
168 #ifndef __INTEL_TH_STH_H__
drivers/hwtracing/stm/console.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Simple kernel console driver for STM devices
34 * Copyright (c) 2014, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * STM console will send kernel messages over STM devices to a trace host.
157 */
168
drivers/hwtracing/stm/core.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * System Trace Module (STM) infrastructure
34 * Copyright (c) 2014, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * STM class implements generic infrastructure for System Trace Module devices
157 * as defined in MIPI STPv2 specification.
168 */
drivers/hwtracing/stm/dummy_stm.c+22−12
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * A dummy STM device for stm/stm_source class testing.
34 * Copyright (c) 2014, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * STM class implements generic infrastructure for System Trace Module devices
157 * as defined in MIPI STPv2 specification.
168 */
@@ -20,6 +12,7 @@ · 3 unmodified lines
2012 #include <linux/module.h>
2113 #include <linux/slab.h>
2214 #include <linux/stm.h>
15+#include <uapi/linux/stm.h>
2316
2417 static ssize_t notrace
2518 dummy_stm_packet(struct stm_data *stm_data, unsigned int master,
@@ -52,6 +45,18 @@ static unsigned int fail_mode; · 26 unmodified lines
5245
5346 module_param(fail_mode, int, 0600);
5447
48+static unsigned int master_min;
49+
50+module_param(master_min, int, 0400);
51+
52+static unsigned int master_max = STP_MASTER_MAX;
53+
54+module_param(master_max, int, 0400);
55+
56+static unsigned int nr_channels = STP_CHANNEL_MAX;
57+
58+module_param(nr_channels, int, 0400);
59+
5560 static int dummy_stm_link(struct stm_data *data, unsigned int master,
5661 unsigned int channel)
5762 {
@@ -68,14 +73,19 @@ static int dummy_stm_init(void) · 10 unmodified lines
6873 if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX)
6974 return -EINVAL;
7075
76+ if (master_min > master_max ||
77+ master_max > STP_MASTER_MAX ||
78+ nr_channels > STP_CHANNEL_MAX)
79+ return -EINVAL;
80+
7181 for (i = 0; i < nr_dummies; i++) {
7282 dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i);
7383 if (!dummy_stm[i].name)
7484 goto fail_unregister;
7585
76− dummy_stm[i].sw_start = 0x0000;
77− dummy_stm[i].sw_end = 0xffff;
78− dummy_stm[i].sw_nchannels = 0xffff;
86+ dummy_stm[i].sw_start = master_min;
87+ dummy_stm[i].sw_end = master_max;
88+ dummy_stm[i].sw_nchannels = nr_channels;
7989 dummy_stm[i].packet = dummy_stm_packet;
8090 dummy_stm[i].link = dummy_stm_link;
8191
drivers/hwtracing/stm/heartbeat.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Simple heartbeat STM source driver
34 * Copyright (c) 2016, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * Heartbeat STM source will send repetitive messages over STM devices to a
157 * trace host.
168 */
drivers/hwtracing/stm/policy.c+1−9
@@ -1,16 +1,8 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * System Trace Module (STM) master/channel allocation policy management
34 * Copyright (c) 2014, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * A master/channel allocation policy allows mapping string identifiers to
157 * master and channel ranges, where allocation can be done.
168 */
drivers/hwtracing/stm/stm.h+1−9
@@ -1,16 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * System Trace Module (STM) infrastructure
34 * Copyright (c) 2014, Intel Corporation.
45 *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
13− *
146 * STM class implements generic infrastructure for System Trace Module devices
157 * as defined in MIPI STPv2 specification.
168 */
drivers/mcb/mcb-pci.c+1−0
@@ -117,6 +117,7 @@ static void mcb_pci_remove(struct pci_dev *pdev) · 116 unmodified lines
117117
118118 static const struct pci_device_id mcb_pci_tbl[] = {
119119 { PCI_DEVICE(PCI_VENDOR_ID_MEN, PCI_DEVICE_ID_MEN_CHAMELEON) },
120+ { PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_MEN_CHAMELEON) },
120121 { 0 },
121122 };
122123 MODULE_DEVICE_TABLE(pci, mcb_pci_tbl);
drivers/misc/Kconfig+0−1
@@ -75,7 +75,6 @@ config ATMEL_TCB_CLKSRC · 74 unmodified lines
7575 config ATMEL_TCB_CLKSRC_BLOCK
7676 int
7777 depends on ATMEL_TCB_CLKSRC
78− prompt "TC Block" if CPU_AT32AP700X
7978 default 0
8079 range 0 1
8180 help
drivers/misc/Makefile+1−19
@@ -12,7 +12,7 @@ obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o · 11 unmodified lines
1212 obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
1313 obj-$(CONFIG_DUMMY_IRQ) += dummy-irq.o
1414 obj-$(CONFIG_ICS932S401) += ics932s401.o
15−obj-$(CONFIG_LKDTM) += lkdtm.o
15+obj-$(CONFIG_LKDTM) += lkdtm/
1616 obj-$(CONFIG_TIFM_CORE) += tifm_core.o
1717 obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
1818 obj-$(CONFIG_PHANTOM) += phantom.o
@@ -57,21 +57,3 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o · 38 unmodified lines
5757 obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o
5858 obj-$(CONFIG_OCXL) += ocxl/
5959 obj-$(CONFIG_MISC_RTSX) += cardreader/
60−
61−lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o
62−lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o
63−lkdtm-$(CONFIG_LKDTM) += lkdtm_heap.o
64−lkdtm-$(CONFIG_LKDTM) += lkdtm_perms.o
65−lkdtm-$(CONFIG_LKDTM) += lkdtm_refcount.o
66−lkdtm-$(CONFIG_LKDTM) += lkdtm_rodata_objcopy.o
67−lkdtm-$(CONFIG_LKDTM) += lkdtm_usercopy.o
68−
69−KCOV_INSTRUMENT_lkdtm_rodata.o := n
70−
71−OBJCOPYFLAGS :=
72−OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
73− --set-section-flags .text=alloc,readonly \
74− --rename-section .text=.rodata
75−targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o
76−$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE
77− $(call if_changed,objcopy)
drivers/misc/aspeed-lpc-ctrl.c+39−5
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 * 2 of the License, or (at your option) any later version.
88 */
99
10+#include <linux/clk.h>
1011 #include <linux/mfd/syscon.h>
1112 #include <linux/miscdevice.h>
1213 #include <linux/mm.h>
@@ -20,12 +21,17 @@ · 7 unmodified lines
2021
2122 #define DEVICE_NAME "aspeed-lpc-ctrl"
2223
24+#define HICR5 0x0
25+#define HICR5_ENL2H BIT(8)
26+#define HICR5_ENFWH BIT(10)
27+
2328 #define HICR7 0x8
2429 #define HICR8 0xc
2530
2631 struct aspeed_lpc_ctrl {
2732 struct miscdevice miscdev;
2833 struct regmap *regmap;
34+ struct clk *clk;
2935 phys_addr_t mem_base;
3036 resource_size_t mem_size;
3137 u32 pnor_size;
@@ -153,8 +159,18 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd, · 121 unmodified lines
153159 if (rc)
154160 return rc;
155161
156− return regmap_write(lpc_ctrl->regmap, HICR8,
157− (~(map.size - 1)) | ((map.size >> 16) - 1));
162+ rc = regmap_write(lpc_ctrl->regmap, HICR8,
163+ (~(map.size - 1)) | ((map.size >> 16) - 1));
164+ if (rc)
165+ return rc;
166+
167+ /*
168+ * Enable LPC FHW cycles. This is required for the host to
169+ * access the regions specified.
170+ */
171+ return regmap_update_bits(lpc_ctrl->regmap, HICR5,
172+ HICR5_ENFWH | HICR5_ENL2H,
173+ HICR5_ENFWH | HICR5_ENL2H);
158174 }
159175
160176 return -EINVAL;
@@ -221,16 +237,33 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev) · 60 unmodified lines
221237 return -ENODEV;
222238 }
223239
240+ lpc_ctrl->clk = devm_clk_get(dev, NULL);
241+ if (IS_ERR(lpc_ctrl->clk)) {
242+ dev_err(dev, "couldn't get clock\n");
243+ return PTR_ERR(lpc_ctrl->clk);
244+ }
245+ rc = clk_prepare_enable(lpc_ctrl->clk);
246+ if (rc) {
247+ dev_err(dev, "couldn't enable clock\n");
248+ return rc;
249+ }
250+
224251 lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR;
225252 lpc_ctrl->miscdev.name = DEVICE_NAME;
226253 lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops;
227254 lpc_ctrl->miscdev.parent = dev;
228255 rc = misc_register(&lpc_ctrl->miscdev);
229− if (rc)
256+ if (rc) {
230257 dev_err(dev, "Unable to register device\n");
231− else
232− dev_info(dev, "Loaded at %pr\n", &resm);
258+ goto err;
259+ }
260+
261+ dev_info(dev, "Loaded at %pr\n", &resm);
262+
263+ return 0;
233264
265+err:
266+ clk_disable_unprepare(lpc_ctrl->clk);
234267 return rc;
235268 }
236269
@@ -239,6 +272,7 @@ static int aspeed_lpc_ctrl_remove(struct platform_device *pdev) · 2 unmodified lines
239272 struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev);
240273
241274 misc_deregister(&lpc_ctrl->miscdev);
275+ clk_disable_unprepare(lpc_ctrl->clk);
242276
243277 return 0;
244278 }
drivers/misc/cardreader/rts5260.c+6−6
@@ -388,17 +388,17 @@ static void rts5260_disable_ocp(struct rtsx_pcr *pcr) · 387 unmodified lines
388388 OC_POWER_DOWN);
389389 }
390390
391−int rts5260_get_ocpstat(struct rtsx_pcr *pcr, u8 *val)
391+static int rts5260_get_ocpstat(struct rtsx_pcr *pcr, u8 *val)
392392 {
393393 return rtsx_pci_read_register(pcr, REG_OCPSTAT, val);
394394 }
395395
396−int rts5260_get_ocpstat2(struct rtsx_pcr *pcr, u8 *val)
396+static int rts5260_get_ocpstat2(struct rtsx_pcr *pcr, u8 *val)
397397 {
398398 return rtsx_pci_read_register(pcr, REG_DV3318_OCPSTAT, val);
399399 }
400400
401−void rts5260_clear_ocpstat(struct rtsx_pcr *pcr)
401+static void rts5260_clear_ocpstat(struct rtsx_pcr *pcr)
402402 {
403403 u8 mask = 0;
404404 u8 val = 0;
@@ -418,7 +418,7 @@ void rts5260_clear_ocpstat(struct rtsx_pcr *pcr) · 13 unmodified lines
418418 DV3318_OCP_INT_CLR | DV3318_OCP_CLR, 0);
419419 }
420420
421−void rts5260_process_ocp(struct rtsx_pcr *pcr)
421+static void rts5260_process_ocp(struct rtsx_pcr *pcr)
422422 {
423423 if (!pcr->option.ocp_en)
424424 return;
@@ -449,7 +449,7 @@ void rts5260_process_ocp(struct rtsx_pcr *pcr) · 24 unmodified lines
449449 }
450450 }
451451
452−int rts5260_init_hw(struct rtsx_pcr *pcr)
452+static int rts5260_init_hw(struct rtsx_pcr *pcr)
453453 {
454454 int err;
455455
@@ -620,7 +620,7 @@ static int rts5260_extra_init_hw(struct rtsx_pcr *pcr) · 164 unmodified lines
620620 return 0;
621621 }
622622
623−void rts5260_set_aspm(struct rtsx_pcr *pcr, bool enable)
623+static void rts5260_set_aspm(struct rtsx_pcr *pcr, bool enable)
624624 {
625625 struct rtsx_cr_option *option = &pcr->option;
626626 u8 val = 0;
drivers/misc/eeprom/at24.c+156−137
@@ -1,14 +1,11 @@
1+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * at24.c - handle most I2C EEPROMs
34 *
45 * Copyright (C) 2005-2007 David Brownell
56 * Copyright (C) 2008 Wolfram Sang, Pengutronix
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; either version 2 of the License, or
10− * (at your option) any later version.
117 */
8+
129 #include <linux/kernel.h>
1310 #include <linux/init.h>
1411 #include <linux/module.h>
@@ -63,8 +60,6 @@ struct at24_client { · 48 unmodified lines
6360 };
6461
6562 struct at24_data {
66− struct at24_platform_data chip;
67−
6863 /*
6964 * Lock protects against activities from other Linux tasks,
7065 * but not from changes by other I2C masters.
@@ -75,7 +70,10 @@ struct at24_data { · 4 unmodified lines
7570 unsigned int num_addresses;
7671 unsigned int offset_adj;
7772
78− struct nvmem_config nvmem_config;
73+ u32 byte_len;
74+ u16 page_size;
75+ u8 flags;
76+
7977 struct nvmem_device *nvmem;
8078
8179 struct gpio_desc *wp_gpio;
@@ -239,8 +237,6 @@ static const struct acpi_device_id at24_acpi_ids[] = { · 157 unmodified lines
239237 };
240238 MODULE_DEVICE_TABLE(acpi, at24_acpi_ids);
241239
242−/*-------------------------------------------------------------------------*/
243−
244240 /*
245241 * This routine supports chips which consume multiple I2C addresses. It
246242 * computes the addressing information to be used for a given r/w request.
@@ -255,7 +251,7 @@ static struct at24_client *at24_translate_offset(struct at24_data *at24, · 8 unmodified lines
255251 {
256252 unsigned int i;
257253
258− if (at24->chip.flags & AT24_FLAG_ADDR16) {
254+ if (at24->flags & AT24_FLAG_ADDR16) {
259255 i = *offset >> 16;
260256 *offset &= 0xffff;
261257 } else {
@@ -266,6 +262,11 @@ static struct at24_client *at24_translate_offset(struct at24_data *at24, · 4 unmodified lines
266262 return &at24->client[i];
267263 }
268264
265+static struct device *at24_base_client_dev(struct at24_data *at24)
266+{
267+ return &at24->client[0].client->dev;
268+}
269+
269270 static size_t at24_adjust_read_count(struct at24_data *at24,
270271 unsigned int offset, size_t count)
271272 {
@@ -277,8 +278,8 @@ static size_t at24_adjust_read_count(struct at24_data *at24, · 5 unmodified lines
277278 * the next slave address: truncate the count to the slave boundary,
278279 * so that the read never straddles slaves.
279280 */
280− if (at24->chip.flags & AT24_FLAG_NO_RDROL) {
281− bits = (at24->chip.flags & AT24_FLAG_ADDR16) ? 16 : 8;
281+ if (at24->flags & AT24_FLAG_NO_RDROL) {
282+ bits = (at24->flags & AT24_FLAG_ADDR16) ? 16 : 8;
282283 remainder = BIT(bits) - offset;
283284 if (count > remainder)
284285 count = remainder;
@@ -337,7 +338,7 @@ static size_t at24_adjust_write_count(struct at24_data *at24, · 52 unmodified lines
337338 count = at24->write_max;
338339
339340 /* Never roll over backwards, to the start of this page */
340− next_page = roundup(offset + 1, at24->chip.page_size);
341+ next_page = roundup(offset + 1, at24->page_size);
341342 if (offset + count > next_page)
342343 count = next_page - offset;
343344
@@ -371,15 +372,18 @@ static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf, · 27 unmodified lines
371372
372373 static int at24_read(void *priv, unsigned int off, void *val, size_t count)
373374 {
374− struct at24_data *at24 = priv;
375− struct device *dev = &at24->client[0].client->dev;
375+ struct at24_data *at24;
376+ struct device *dev;
376377 char *buf = val;
377378 int ret;
378379
380+ at24 = priv;
381+ dev = at24_base_client_dev(at24);
382+
379383 if (unlikely(!count))
380384 return count;
381385
382− if (off + count > at24->chip.byte_len)
386+ if (off + count > at24->byte_len)
383387 return -EINVAL;
384388
385389 ret = pm_runtime_get_sync(dev);
@@ -395,17 +399,15 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) · 9 unmodified lines
395399 mutex_lock(&at24->lock);
396400
397401 while (count) {
398− int status;
399−
400− status = at24_regmap_read(at24, buf, off, count);
401− if (status < 0) {
402+ ret = at24_regmap_read(at24, buf, off, count);
403+ if (ret < 0) {
402404 mutex_unlock(&at24->lock);
403405 pm_runtime_put(dev);
404− return status;
406+ return ret;
405407 }
406− buf += status;
407− off += status;
408− count -= status;
408+ buf += ret;
409+ off += ret;
410+ count -= ret;
409411 }
410412
411413 mutex_unlock(&at24->lock);
@@ -417,15 +419,18 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) · 5 unmodified lines
417419
418420 static int at24_write(void *priv, unsigned int off, void *val, size_t count)
419421 {
420− struct at24_data *at24 = priv;
421− struct device *dev = &at24->client[0].client->dev;
422+ struct at24_data *at24;
423+ struct device *dev;
422424 char *buf = val;
423425 int ret;
424426
427+ at24 = priv;
428+ dev = at24_base_client_dev(at24);
429+
425430 if (unlikely(!count))
426431 return -EINVAL;
427432
428− if (off + count > at24->chip.byte_len)
433+ if (off + count > at24->byte_len)
429434 return -EINVAL;
430435
431436 ret = pm_runtime_get_sync(dev);
@@ -442,18 +447,16 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) · 10 unmodified lines
442447 gpiod_set_value_cansleep(at24->wp_gpio, 0);
443448
444449 while (count) {
445− int status;
446−
447− status = at24_regmap_write(at24, buf, off, count);
448− if (status < 0) {
450+ ret = at24_regmap_write(at24, buf, off, count);
451+ if (ret < 0) {
449452 gpiod_set_value_cansleep(at24->wp_gpio, 1);
450453 mutex_unlock(&at24->lock);
451454 pm_runtime_put(dev);
452− return status;
455+ return ret;
453456 }
454− buf += status;
455− off += status;
456− count -= status;
457+ buf += ret;
458+ off += ret;
459+ count -= ret;
457460 }
458461
459462 gpiod_set_value_cansleep(at24->wp_gpio, 1);
@@ -464,7 +467,8 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) · 4 unmodified lines
464467 return 0;
465468 }
466469
467−static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip)
470+static void at24_properties_to_pdata(struct device *dev,
471+ struct at24_platform_data *chip)
468472 {
469473 int err;
470474 u32 val;
@@ -491,6 +495,43 @@ static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip) · 20 unmodified lines
491495 }
492496 }
493497
498+static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
499+{
500+ struct device_node *of_node = dev->of_node;
501+ const struct at24_chip_data *cdata;
502+ const struct i2c_device_id *id;
503+ struct at24_platform_data *pd;
504+
505+ pd = dev_get_platdata(dev);
506+ if (pd) {
507+ memcpy(pdata, pd, sizeof(*pdata));
508+ return 0;
509+ }
510+
511+ id = i2c_match_id(at24_ids, to_i2c_client(dev));
512+
513+ /*
514+ * The I2C core allows OF nodes compatibles to match against the
515+ * I2C device ID table as a fallback, so check not only if an OF
516+ * node is present but also if it matches an OF device ID entry.
517+ */
518+ if (of_node && of_match_device(at24_of_match, dev))
519+ cdata = of_device_get_match_data(dev);
520+ else if (id)
521+ cdata = (void *)&id->driver_data;
522+ else
523+ cdata = acpi_device_get_match_data(dev);
524+
525+ if (!cdata)
526+ return -ENODEV;
527+
528+ pdata->byte_len = cdata->byte_len;
529+ pdata->flags = cdata->flags;
530+ at24_properties_to_pdata(dev, pdata);
531+
532+ return 0;
533+}
534+
494535 static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len)
495536 {
496537 if (flags & AT24_FLAG_MAC) {
@@ -514,102 +555,83 @@ static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len) · 17 unmodified lines
514555 }
515556 }
516557
517−static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
558+static int at24_probe(struct i2c_client *client)
518559 {
519− struct at24_platform_data chip = { 0 };
520− const struct at24_chip_data *cd = NULL;
521− bool writable;
522− struct at24_data *at24;
523− int err;
524− unsigned int i, num_addresses;
525560 struct regmap_config regmap_config = { };
561+ struct nvmem_config nvmem_config = { };
562+ struct at24_platform_data pdata = { };
563+ struct device *dev = &client->dev;
564+ bool i2c_fn_i2c, i2c_fn_block;
565+ unsigned int i, num_addresses;
566+ struct at24_data *at24;
567+ struct regmap *regmap;
568+ size_t at24_size;
569+ bool writable;
526570 u8 test_byte;
571+ int err;
527572
528− if (client->dev.platform_data) {
529− chip = *(struct at24_platform_data *)client->dev.platform_data;
530− } else {
531− /*
532− * The I2C core allows OF nodes compatibles to match against the
533− * I2C device ID table as a fallback, so check not only if an OF
534− * node is present but also if it matches an OF device ID entry.
535− */
536− if (client->dev.of_node &&
537− of_match_device(at24_of_match, &client->dev)) {
538− cd = of_device_get_match_data(&client->dev);
539− } else if (id) {
540− cd = (void *)id->driver_data;
541− } else {
542− const struct acpi_device_id *aid;
543−
544− aid = acpi_match_device(at24_acpi_ids, &client->dev);
545− if (aid)
546− cd = (void *)aid->driver_data;
547− }
548− if (!cd)
549− return -ENODEV;
573+ i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
574+ i2c_fn_block = i2c_check_functionality(client->adapter,
575+ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
550576
551− chip.byte_len = cd->byte_len;
552− chip.flags = cd->flags;
553− at24_get_pdata(&client->dev, &chip);
554− }
577+ err = at24_get_pdata(dev, &pdata);
578+ if (err)
579+ return err;
580+
581+ if (!i2c_fn_i2c && !i2c_fn_block)
582+ pdata.page_size = 1;
555583
556− if (!is_power_of_2(chip.byte_len))
557− dev_warn(&client->dev,
558− "byte_len looks suspicious (no power of 2)!\n");
559− if (!chip.page_size) {
560− dev_err(&client->dev, "page_size must not be 0!\n");
584+ if (!pdata.page_size) {
585+ dev_err(dev, "page_size must not be 0!\n");
561586 return -EINVAL;
562587 }
563− if (!is_power_of_2(chip.page_size))
564− dev_warn(&client->dev,
565− "page_size looks suspicious (no power of 2)!\n");
566588
567− if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
568− !i2c_check_functionality(client->adapter,
569− I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
570− chip.page_size = 1;
589+ if (!is_power_of_2(pdata.page_size))
590+ dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
571591
572− if (chip.flags & AT24_FLAG_TAKE8ADDR)
592+ if (pdata.flags & AT24_FLAG_TAKE8ADDR)
573593 num_addresses = 8;
574594 else
575− num_addresses = DIV_ROUND_UP(chip.byte_len,
576− (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
595+ num_addresses = DIV_ROUND_UP(pdata.byte_len,
596+ (pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
597+
598+ if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) {
599+ dev_err(dev,
600+ "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
601+ return -EINVAL;
602+ }
577603
578604 regmap_config.val_bits = 8;
579− regmap_config.reg_bits = (chip.flags & AT24_FLAG_ADDR16) ? 16 : 8;
605+ regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8;
606+ regmap_config.disable_locking = true;
580607
581− at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
582− num_addresses * sizeof(struct at24_client), GFP_KERNEL);
608+ regmap = devm_regmap_init_i2c(client, &regmap_config);
609+ if (IS_ERR(regmap))
610+ return PTR_ERR(regmap);
611+
612+ at24_size = sizeof(*at24) + num_addresses * sizeof(struct at24_client);
613+ at24 = devm_kzalloc(dev, at24_size, GFP_KERNEL);
583614 if (!at24)
584615 return -ENOMEM;
585616
586617 mutex_init(&at24->lock);
587− at24->chip = chip;
618+ at24->byte_len = pdata.byte_len;
619+ at24->page_size = pdata.page_size;
620+ at24->flags = pdata.flags;
588621 at24->num_addresses = num_addresses;
589− at24->offset_adj = at24_get_offset_adj(chip.flags, chip.byte_len);
622+ at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len);
623+ at24->client[0].client = client;
624+ at24->client[0].regmap = regmap;
590625
591− at24->wp_gpio = devm_gpiod_get_optional(&client->dev,
592− "wp", GPIOD_OUT_HIGH);
626+ at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH);
593627 if (IS_ERR(at24->wp_gpio))
594628 return PTR_ERR(at24->wp_gpio);
595629
596− at24->client[0].client = client;
597− at24->client[0].regmap = devm_regmap_init_i2c(client, &regmap_config);
598− if (IS_ERR(at24->client[0].regmap))
599− return PTR_ERR(at24->client[0].regmap);
600−
601− if ((chip.flags & AT24_FLAG_SERIAL) && (chip.flags & AT24_FLAG_MAC)) {
602− dev_err(&client->dev,
603− "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
604− return -EINVAL;
605− }
606−
607− writable = !(chip.flags & AT24_FLAG_READONLY);
630+ writable = !(pdata.flags & AT24_FLAG_READONLY);
608631 if (writable) {
609632 at24->write_max = min_t(unsigned int,
610− chip.page_size, at24_io_limit);
611− if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
612− at24->write_max > I2C_SMBUS_BLOCK_MAX)
633+ pdata.page_size, at24_io_limit);
634+ if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)
613635 at24->write_max = I2C_SMBUS_BLOCK_MAX;
614636 }
615637
@@ -618,8 +640,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 2 unmodified lines
618640 at24->client[i].client = i2c_new_dummy(client->adapter,
619641 client->addr + i);
620642 if (!at24->client[i].client) {
621− dev_err(&client->dev, "address 0x%02x unavailable\n",
622− client->addr + i);
643+ dev_err(dev, "address 0x%02x unavailable\n",
644+ client->addr + i);
623645 err = -EADDRINUSE;
624646 goto err_clients;
625647 }
@@ -635,48 +657,47 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) · 9 unmodified lines
635657 i2c_set_clientdata(client, at24);
636658
637659 /* enable runtime pm */
638− pm_runtime_set_active(&client->dev);
639− pm_runtime_enable(&client->dev);
660+ pm_runtime_set_active(dev);
661+ pm_runtime_enable(dev);
640662
641663 /*
642664 * Perform a one-byte test read to verify that the
643665 * chip is functional.
644666 */
645667 err = at24_read(at24, 0, &test_byte, 1);
646− pm_runtime_idle(&client->dev);
668+ pm_runtime_idle(dev);
647669 if (err) {
648670 err = -ENODEV;
649671 goto err_clients;
650672 }
651673
652− at24->nvmem_config.name = dev_name(&client->dev);
653− at24->nvmem_config.dev = &client->dev;
654− at24->nvmem_config.read_only = !writable;
655− at24->nvmem_config.root_only = true;
656− at24->nvmem_config.owner = THIS_MODULE;
657− at24->nvmem_config.compat = true;
658− at24->nvmem_config.base_dev = &client->dev;
659− at24->nvmem_config.reg_read = at24_read;
660− at24->nvmem_config.reg_write = at24_write;
661− at24->nvmem_config.priv = at24;
662− at24->nvmem_config.stride = 1;
663− at24->nvmem_config.word_size = 1;
664− at24->nvmem_config.size = chip.byte_len;
665−
666− at24->nvmem = nvmem_register(&at24->nvmem_config);
667−
674+ nvmem_config.name = dev_name(dev);
675+ nvmem_config.dev = dev;
676+ nvmem_config.read_only = !writable;
677+ nvmem_config.root_only = true;
678+ nvmem_config.owner = THIS_MODULE;
679+ nvmem_config.compat = true;
680+ nvmem_config.base_dev = dev;
681+ nvmem_config.reg_read = at24_read;
682+ nvmem_config.reg_write = at24_write;
683+ nvmem_config.priv = at24;
684+ nvmem_config.stride = 1;
685+ nvmem_config.word_size = 1;
686+ nvmem_config.size = pdata.byte_len;
687+
688+ at24->nvmem = nvmem_register(&nvmem_config);
668689 if (IS_ERR(at24->nvmem)) {
669690 err = PTR_ERR(at24->nvmem);
670691 goto err_clients;
671692 }
672693
673− dev_info(&client->dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
674− chip.byte_len, client->name,
675− writable ? "writable" : "read-only", at24->write_max);
694+ dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
695+ pdata.byte_len, client->name,
696+ writable ? "writable" : "read-only", at24->write_max);
676697
677698 /* export data to kernel code */
678− if (chip.setup)
679− chip.setup(at24->nvmem, chip.context);
699+ if (pdata.setup)
700+ pdata.setup(at24->nvmem, pdata.context);
680701
681702 return 0;
682703
@@ -685,7 +706,7 @@ err_clients: · 2 unmodified lines
685706 if (at24->client[i].client)
686707 i2c_unregister_device(at24->client[i].client);
687708
688− pm_runtime_disable(&client->dev);
709+ pm_runtime_disable(dev);
689710
690711 return err;
691712 }
@@ -708,15 +729,13 @@ static int at24_remove(struct i2c_client *client) · 16 unmodified lines
708729 return 0;
709730 }
710731
711−/*-------------------------------------------------------------------------*/
712−
713732 static struct i2c_driver at24_driver = {
714733 .driver = {
715734 .name = "at24",
716735 .of_match_table = at24_of_match,
717736 .acpi_match_table = ACPI_PTR(at24_acpi_ids),
718737 },
719− .probe = at24_probe,
738+ .probe_new = at24_probe,
720739 .remove = at24_remove,
721740 .id_table = at24_ids,
722741 };
drivers/misc/eeprom/at25.c+1−1
@@ -102,7 +102,7 @@ static int at25_ee_read(void *priv, unsigned int offset, · 101 unmodified lines
102102 }
103103
104104 spi_message_init(&m);
105− memset(t, 0, sizeof t);
105+ memset(t, 0, sizeof(t));
106106
107107 t[0].tx_buf = command;
108108 t[0].len = at25->addrlen + 1;
drivers/misc/lkdtm/Makefile+20−0
@@ -0,0 +1,20 @@
1+# SPDX-License-Identifier: GPL-2.0
2+obj-$(CONFIG_LKDTM) += lkdtm.o
3+
4+lkdtm-$(CONFIG_LKDTM) += core.o
5+lkdtm-$(CONFIG_LKDTM) += bugs.o
6+lkdtm-$(CONFIG_LKDTM) += heap.o
7+lkdtm-$(CONFIG_LKDTM) += perms.o
8+lkdtm-$(CONFIG_LKDTM) += refcount.o
9+lkdtm-$(CONFIG_LKDTM) += rodata_objcopy.o
10+lkdtm-$(CONFIG_LKDTM) += usercopy.o
11+
12+KCOV_INSTRUMENT_rodata.o := n
13+
14+OBJCOPYFLAGS :=
15+OBJCOPYFLAGS_rodata_objcopy.o := \
16+ --set-section-flags .text=alloc,readonly \
17+ --rename-section .text=.rodata
18+targets += rodata.o rodata_objcopy.o
19+$(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE
20+ $(call if_changed,objcopy)
drivers/misc/lkdtm/bugs.crenamed from drivers/misc/lkdtm_bugs.c+0−0

File renamed without changes.

drivers/misc/lkdtm/core.crenamed from drivers/misc/lkdtm_core.c+0−0

File renamed without changes.

drivers/misc/lkdtm/heap.crenamed from drivers/misc/lkdtm_heap.c+0−0

File renamed without changes.

drivers/misc/lkdtm/lkdtm.hrenamed from drivers/misc/lkdtm.h+0−0

File renamed without changes.

drivers/misc/lkdtm/perms.crenamed from drivers/misc/lkdtm_perms.c+0−0

File renamed without changes.

drivers/misc/lkdtm/refcount.crenamed from drivers/misc/lkdtm_refcount.c+1−0
@@ -1,3 +1,4 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * This is for all the tests related to refcount bugs (e.g. overflow,
34 * underflow, reaching zero untested, etc).
drivers/misc/lkdtm/rodata.crenamed from drivers/misc/lkdtm_rodata.c+0−0

File renamed without changes.

drivers/misc/lkdtm/usercopy.crenamed from drivers/misc/lkdtm_usercopy.c+0−0

File renamed without changes.

drivers/misc/mei/bus.c+51−32
@@ -74,6 +74,23 @@ ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, · 73 unmodified lines
7474 goto out;
7575 }
7676
77+ while (cl->tx_cb_queued >= bus->tx_queue_limit) {
78+ mutex_unlock(&bus->device_lock);
79+ rets = wait_event_interruptible(cl->tx_wait,
80+ cl->writing_state == MEI_WRITE_COMPLETE ||
81+ (!mei_cl_is_connected(cl)));
82+ mutex_lock(&bus->device_lock);
83+ if (rets) {
84+ if (signal_pending(current))
85+ rets = -EINTR;
86+ goto out;
87+ }
88+ if (!mei_cl_is_connected(cl)) {
89+ rets = -ENODEV;
90+ goto out;
91+ }
92+ }
93+
7794 cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, NULL);
7895 if (!cb) {
7996 rets = -ENOMEM;
@@ -449,6 +466,29 @@ bool mei_cldev_enabled(struct mei_cl_device *cldev) · 369 unmodified lines
449466 }
450467 EXPORT_SYMBOL_GPL(mei_cldev_enabled);
451468
469+/**
470+ * mei_cl_bus_module_get - acquire module of the underlying
471+ * hw driver.
472+ *
473+ * @cldev: mei client device
474+ *
475+ * Return: true on success; false if the module was removed.
476+ */
477+static bool mei_cl_bus_module_get(struct mei_cl_device *cldev)
478+{
479+ return try_module_get(cldev->bus->dev->driver->owner);
480+}
481+
482+/**
483+ * mei_cl_bus_module_put - release the underlying hw module.
484+ *
485+ * @cldev: mei client device
486+ */
487+static void mei_cl_bus_module_put(struct mei_cl_device *cldev)
488+{
489+ module_put(cldev->bus->dev->driver->owner);
490+}
491+
452492 /**
453493 * mei_cldev_enable - enable me client device
454494 * create connection with me client
@@ -487,9 +527,17 @@ int mei_cldev_enable(struct mei_cl_device *cldev) · 32 unmodified lines
487527 goto out;
488528 }
489529
530+ if (!mei_cl_bus_module_get(cldev)) {
531+ dev_err(&cldev->dev, "get hw module failed");
532+ ret = -ENODEV;
533+ goto out;
534+ }
535+
490536 ret = mei_cl_connect(cl, cldev->me_cl, NULL);
491− if (ret < 0)
537+ if (ret < 0) {
492538 dev_err(&cldev->dev, "cannot connect\n");
539+ mei_cl_bus_module_put(cldev);
540+ }
493541
494542 out:
495543 mutex_unlock(&bus->device_lock);
@@ -553,6 +601,8 @@ int mei_cldev_disable(struct mei_cl_device *cldev) · 57 unmodified lines
553601 dev_err(bus->dev, "Could not disconnect from the ME client\n");
554602
555603 out:
604+ mei_cl_bus_module_put(cldev);
605+
556606 /* Flush queues and remove any pending read */
557607 mei_cl_flush_queues(cl, NULL);
558608 mei_cl_unlink(cl);
@@ -562,37 +612,6 @@ out: · 3 unmodified lines
562612 }
563613 EXPORT_SYMBOL_GPL(mei_cldev_disable);
564614
565−/**
566− * mei_cl_bus_module_get - acquire module of the underlying
567− * hw module.
568− *
569− * @cl: host client
570− *
571− * Return: true on success; false if the module was removed.
572− */
573−bool mei_cl_bus_module_get(struct mei_cl *cl)
574−{
575− struct mei_cl_device *cldev = cl->cldev;
576−
577− if (!cldev)
578− return true;
579−
580− return try_module_get(cldev->bus->dev->driver->owner);
581−}
582−
583−/**
584− * mei_cl_bus_module_put - release the underlying hw module.
585− *
586− * @cl: host client
587− */
588−void mei_cl_bus_module_put(struct mei_cl *cl)
589−{
590− struct mei_cl_device *cldev = cl->cldev;
591−
592− if (cldev)
593− module_put(cldev->bus->dev->driver->owner);
594−}
595−
596615 /**
597616 * mei_cl_device_find - find matching entry in the driver id table
598617 *
drivers/misc/mei/client.c+50−37
@@ -349,6 +349,36 @@ void mei_io_cb_free(struct mei_cl_cb *cb) · 348 unmodified lines
349349 kfree(cb);
350350 }
351351
352+/**
353+ * mei_tx_cb_queue - queue tx callback
354+ *
355+ * Locking: called under "dev->device_lock" lock
356+ *
357+ * @cb: mei callback struct
358+ * @head: an instance of list to queue on
359+ */
360+static inline void mei_tx_cb_enqueue(struct mei_cl_cb *cb,
361+ struct list_head *head)
362+{
363+ list_add_tail(&cb->list, head);
364+ cb->cl->tx_cb_queued++;
365+}
366+
367+/**
368+ * mei_tx_cb_dequeue - dequeue tx callback
369+ *
370+ * Locking: called under "dev->device_lock" lock
371+ *
372+ * @cb: mei callback struct to dequeue and free
373+ */
374+static inline void mei_tx_cb_dequeue(struct mei_cl_cb *cb)
375+{
376+ if (!WARN_ON(cb->cl->tx_cb_queued == 0))
377+ cb->cl->tx_cb_queued--;
378+
379+ mei_io_cb_free(cb);
380+}
381+
352382 /**
353383 * mei_io_cb_init - allocate and initialize io callback
354384 *
@@ -377,49 +407,37 @@ static struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, · 22 unmodified lines
377407 }
378408
379409 /**
380− * __mei_io_list_flush_cl - removes and frees cbs belonging to cl.
410+ * mei_io_list_flush_cl - removes cbs belonging to the cl.
381411 *
382412 * @head: an instance of our list structure
383− * @cl: host client, can be NULL for flushing the whole list
384− * @free: whether to free the cbs
413+ * @cl: host client
385414 */
386−static void __mei_io_list_flush_cl(struct list_head *head,
387− const struct mei_cl *cl, bool free)
415+static void mei_io_list_flush_cl(struct list_head *head,
416+ const struct mei_cl *cl)
388417 {
389418 struct mei_cl_cb *cb, *next;
390419
391− /* enable removing everything if no cl is specified */
392420 list_for_each_entry_safe(cb, next, head, list) {
393− if (!cl || mei_cl_cmp_id(cl, cb->cl)) {
421+ if (mei_cl_cmp_id(cl, cb->cl))
394422 list_del_init(&cb->list);
395− if (free)
396− mei_io_cb_free(cb);
397− }
398423 }
399424 }
400425
401426 /**
402− * mei_io_list_flush_cl - removes list entry belonging to cl.
427+ * mei_io_tx_list_free_cl - removes cb belonging to the cl and free them
403428 *
404429 * @head: An instance of our list structure
405430 * @cl: host client
406431 */
407−static inline void mei_io_list_flush_cl(struct list_head *head,
408− const struct mei_cl *cl)
432+static void mei_io_tx_list_free_cl(struct list_head *head,
433+ const struct mei_cl *cl)
409434 {
410− __mei_io_list_flush_cl(head, cl, false);
411−}
435+ struct mei_cl_cb *cb, *next;
412436
413−/**
414− * mei_io_list_free_cl - removes cb belonging to cl and free them
415− *
416− * @head: An instance of our list structure
417− * @cl: host client
418− */
419−static inline void mei_io_list_free_cl(struct list_head *head,
420− const struct mei_cl *cl)
421−{
422− __mei_io_list_flush_cl(head, cl, true);
437+ list_for_each_entry_safe(cb, next, head, list) {
438+ if (mei_cl_cmp_id(cl, cb->cl))
439+ mei_tx_cb_dequeue(cb);
440+ }
423441 }
424442
425443 /**
@@ -538,8 +556,8 @@ int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp) · 112 unmodified lines
538556 dev = cl->dev;
539557
540558 cl_dbg(dev, cl, "remove list entry belonging to cl\n");
541− mei_io_list_free_cl(&cl->dev->write_list, cl);
542− mei_io_list_free_cl(&cl->dev->write_waiting_list, cl);
559+ mei_io_tx_list_free_cl(&cl->dev->write_list, cl);
560+ mei_io_tx_list_free_cl(&cl->dev->write_waiting_list, cl);
543561 mei_io_list_flush_cl(&cl->dev->ctrl_wr_list, cl);
544562 mei_io_list_flush_cl(&cl->dev->ctrl_rd_list, cl);
545563 mei_io_list_free_fp(&cl->rd_pending, fp);
@@ -756,8 +774,8 @@ static void mei_cl_set_disconnected(struct mei_cl *cl) · 210 unmodified lines
756774 return;
757775
758776 cl->state = MEI_FILE_DISCONNECTED;
759− mei_io_list_free_cl(&dev->write_list, cl);
760− mei_io_list_free_cl(&dev->write_waiting_list, cl);
777+ mei_io_tx_list_free_cl(&dev->write_list, cl);
778+ mei_io_tx_list_free_cl(&dev->write_waiting_list, cl);
761779 mei_io_list_flush_cl(&dev->ctrl_rd_list, cl);
762780 mei_io_list_flush_cl(&dev->ctrl_wr_list, cl);
763781 mei_cl_wake_all(cl);
@@ -765,8 +783,6 @@ static void mei_cl_set_disconnected(struct mei_cl *cl) · 1 unmodified line
765783 cl->tx_flow_ctrl_creds = 0;
766784 cl->timer_count = 0;
767785
768− mei_cl_bus_module_put(cl);
769−
770786 if (!cl->me_cl)
771787 return;
772788
@@ -1076,9 +1092,6 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl, · 303 unmodified lines
10761092
10771093 dev = cl->dev;
10781094
1079− if (!mei_cl_bus_module_get(cl))
1080− return -ENODEV;
1081−
10821095 rets = mei_cl_set_connecting(cl, me_cl);
10831096 if (rets)
10841097 goto nortpm;
@@ -1698,9 +1711,9 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) · 613 unmodified lines
16981711
16991712 out:
17001713 if (mei_hdr.msg_complete)
1701− list_add_tail(&cb->list, &dev->write_waiting_list);
1714+ mei_tx_cb_enqueue(cb, &dev->write_waiting_list);
17021715 else
1703− list_add_tail(&cb->list, &dev->write_list);
1716+ mei_tx_cb_enqueue(cb, &dev->write_list);
17041717
17051718 cb = NULL;
17061719 if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) {
@@ -1746,7 +1759,7 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb) · 39 unmodified lines
17461759
17471760 switch (cb->fop_type) {
17481761 case MEI_FOP_WRITE:
1749− mei_io_cb_free(cb);
1762+ mei_tx_cb_dequeue(cb);
17501763 cl->writing_state = MEI_WRITE_COMPLETE;
17511764 if (waitqueue_active(&cl->tx_wait)) {
17521765 wake_up_interruptible(&cl->tx_wait);
drivers/misc/mei/debugfs.c+4−3
@@ -97,7 +97,7 @@ static ssize_t mei_dbgfs_read_active(struct file *fp, char __user *ubuf, · 96 unmodified lines
9797 int pos = 0;
9898 int ret;
9999
100−#define HDR " |me|host|state|rd|wr|\n"
100+#define HDR " |me|host|state|rd|wr|wrq\n"
101101
102102 if (!dev)
103103 return -ENODEV;
@@ -130,9 +130,10 @@ static ssize_t mei_dbgfs_read_active(struct file *fp, char __user *ubuf, · 26 unmodified lines
130130 list_for_each_entry(cl, &dev->file_list, link) {
131131
132132 pos += scnprintf(buf + pos, bufsz - pos,
133− "%3d|%2d|%4d|%5d|%2d|%2d|\n",
133+ "%3d|%2d|%4d|%5d|%2d|%2d|%3u\n",
134134 i, mei_cl_me_id(cl), cl->host_client_id, cl->state,
135− !list_empty(&cl->rd_completed), cl->writing_state);
135+ !list_empty(&cl->rd_completed), cl->writing_state,
136+ cl->tx_cb_queued);
136137 i++;
137138 }
138139 out:
drivers/misc/mei/init.c+1−0
@@ -383,6 +383,7 @@ void mei_device_init(struct mei_device *dev, · 382 unmodified lines
383383 INIT_LIST_HEAD(&dev->write_waiting_list);
384384 INIT_LIST_HEAD(&dev->ctrl_wr_list);
385385 INIT_LIST_HEAD(&dev->ctrl_rd_list);
386+ dev->tx_queue_limit = MEI_TX_QUEUE_LIMIT_DEFAULT;
386387
387388 INIT_DELAYED_WORK(&dev->timer_work, mei_timer);
388389 INIT_WORK(&dev->reset_work, mei_reset_work);
drivers/misc/mei/main.c+65−1
@@ -291,6 +291,27 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, · 290 unmodified lines
291291 goto out;
292292 }
293293
294+ while (cl->tx_cb_queued >= dev->tx_queue_limit) {
295+ if (file->f_flags & O_NONBLOCK) {
296+ rets = -EAGAIN;
297+ goto out;
298+ }
299+ mutex_unlock(&dev->device_lock);
300+ rets = wait_event_interruptible(cl->tx_wait,
301+ cl->writing_state == MEI_WRITE_COMPLETE ||
302+ (!mei_cl_is_connected(cl)));
303+ mutex_lock(&dev->device_lock);
304+ if (rets) {
305+ if (signal_pending(current))
306+ rets = -EINTR;
307+ goto out;
308+ }
309+ if (!mei_cl_is_connected(cl)) {
310+ rets = -ENODEV;
311+ goto out;
312+ }
313+ }
314+
294315 *offset = 0;
295316 cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, file);
296317 if (!cb) {
@@ -507,7 +528,6 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) · 210 unmodified lines
507528 break;
508529
509530 default:
510− dev_err(dev->dev, ": unsupported ioctl %d.\n", cmd);
511531 rets = -ENOIOCTLCMD;
512532 }
513533
@@ -580,6 +600,12 @@ static __poll_t mei_poll(struct file *file, poll_table *wait) · 66 unmodified lines
580600 mei_cl_read_start(cl, mei_cl_mtu(cl), file);
581601 }
582602
603+ if (req_events & (POLLOUT | POLLWRNORM)) {
604+ poll_wait(file, &cl->tx_wait, wait);
605+ if (cl->tx_cb_queued < dev->tx_queue_limit)
606+ mask |= POLLOUT | POLLWRNORM;
607+ }
608+
583609 out:
584610 mutex_unlock(&dev->device_lock);
585611 return mask;
@@ -749,10 +775,48 @@ static ssize_t hbm_ver_drv_show(struct device *device, · 163 unmodified lines
749775 }
750776 static DEVICE_ATTR_RO(hbm_ver_drv);
751777
778+static ssize_t tx_queue_limit_show(struct device *device,
779+ struct device_attribute *attr, char *buf)
780+{
781+ struct mei_device *dev = dev_get_drvdata(device);
782+ u8 size = 0;
783+
784+ mutex_lock(&dev->device_lock);
785+ size = dev->tx_queue_limit;
786+ mutex_unlock(&dev->device_lock);
787+
788+ return snprintf(buf, PAGE_SIZE, "%u\n", size);
789+}
790+
791+static ssize_t tx_queue_limit_store(struct device *device,
792+ struct device_attribute *attr,
793+ const char *buf, size_t count)
794+{
795+ struct mei_device *dev = dev_get_drvdata(device);
796+ u8 limit;
797+ unsigned int inp;
798+ int err;
799+
800+ err = kstrtouint(buf, 10, &inp);
801+ if (err)
802+ return err;
803+ if (inp > MEI_TX_QUEUE_LIMIT_MAX || inp < MEI_TX_QUEUE_LIMIT_MIN)
804+ return -EINVAL;
805+ limit = inp;
806+
807+ mutex_lock(&dev->device_lock);
808+ dev->tx_queue_limit = limit;
809+ mutex_unlock(&dev->device_lock);
810+
811+ return count;
812+}
813+static DEVICE_ATTR_RW(tx_queue_limit);
814+
752815 static struct attribute *mei_attrs[] = {
753816 &dev_attr_fw_status.attr,
754817 &dev_attr_hbm_ver.attr,
755818 &dev_attr_hbm_ver_drv.attr,
819+ &dev_attr_tx_queue_limit.attr,
756820 NULL
757821 };
758822 ATTRIBUTE_GROUPS(mei);
drivers/misc/mei/mei_dev.h+8−2
@@ -210,6 +210,7 @@ struct mei_cl_cb { · 209 unmodified lines
210210 * @timer_count: watchdog timer for operation completion
211211 * @notify_en: notification - enabled/disabled
212212 * @notify_ev: pending notification event
213+ * @tx_cb_queued: number of tx callbacks in queue
213214 * @writing_state: state of the tx
214215 * @rd_pending: pending read credits
215216 * @rd_completed: completed read
@@ -234,6 +235,7 @@ struct mei_cl { · 18 unmodified lines
234235 u8 timer_count;
235236 u8 notify_en;
236237 u8 notify_ev;
238+ u8 tx_cb_queued;
237239 enum mei_file_transaction_states writing_state;
238240 struct list_head rd_pending;
239241 struct list_head rd_completed;
@@ -241,6 +243,10 @@ struct mei_cl { · 1 unmodified line
241243 struct mei_cl_device *cldev;
242244 };
243245
246+#define MEI_TX_QUEUE_LIMIT_DEFAULT 50
247+#define MEI_TX_QUEUE_LIMIT_MAX 255
248+#define MEI_TX_QUEUE_LIMIT_MIN 30
249+
244250 /**
245251 * struct mei_hw_ops - hw specific ops
246252 *
@@ -315,8 +321,6 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, · 68 unmodified lines
315321 bool mei_cl_bus_rx_event(struct mei_cl *cl);
316322 bool mei_cl_bus_notify_event(struct mei_cl *cl);
317323 void mei_cl_bus_remove_devices(struct mei_device *bus);
318−bool mei_cl_bus_module_get(struct mei_cl *cl);
319−void mei_cl_bus_module_put(struct mei_cl *cl);
320324 int mei_cl_bus_init(void);
321325 void mei_cl_bus_exit(void);
322326
@@ -361,6 +365,7 @@ const char *mei_pg_state_str(enum mei_pg_state state); · 38 unmodified lines
361365 * @write_waiting_list : write completion list
362366 * @ctrl_wr_list : pending control write list
363367 * @ctrl_rd_list : pending control read list
368+ * @tx_queue_limit: tx queues per client linit
364369 *
365370 * @file_list : list of opened handles
366371 * @open_handle_count: number of opened handles
@@ -425,6 +430,7 @@ struct mei_device { · 58 unmodified lines
425430 struct list_head write_waiting_list;
426431 struct list_head ctrl_wr_list;
427432 struct list_head ctrl_rd_list;
433+ u8 tx_queue_limit;
428434
429435 struct list_head file_list;
430436 long open_handle_count;
drivers/misc/mic/bus/vop_bus.c+4−2
@@ -135,7 +135,9 @@ EXPORT_SYMBOL_GPL(vop_unregister_driver); · 134 unmodified lines
135135
136136 static void vop_release_dev(struct device *d)
137137 {
138− put_device(d);
138+ struct vop_device *dev = dev_to_vop(d);
139+
140+ kfree(dev);
139141 }
140142
141143 struct vop_device *
@@ -174,7 +176,7 @@ vop_register_device(struct device *pdev, int id, · 32 unmodified lines
174176 goto free_vdev;
175177 return vdev;
176178 free_vdev:
177− kfree(vdev);
179+ put_device(&vdev->dev);
178180 return ERR_PTR(ret);
179181 }
180182 EXPORT_SYMBOL_GPL(vop_register_device);
drivers/misc/ocxl/pci.c+1−1
@@ -519,7 +519,7 @@ static struct ocxl_fn *init_function(struct pci_dev *dev) · 518 unmodified lines
519519 rc = device_register(&fn->dev);
520520 if (rc) {
521521 deconfigure_function(fn);
522− device_unregister(&fn->dev);
522+ put_device(&fn->dev);
523523 return ERR_PTR(rc);
524524 }
525525 return fn;
drivers/nvmem/Kconfig+2−2
@@ -167,10 +167,10 @@ config MESON_MX_EFUSE · 166 unmodified lines
167167
168168 config NVMEM_SNVS_LPGPR
169169 tristate "Support for Low Power General Purpose Register"
170− depends on SOC_IMX6 || COMPILE_TEST
170+ depends on SOC_IMX6 || SOC_IMX7D || COMPILE_TEST
171171 help
172172 This is a driver for Low Power General Purpose Register (LPGPR) available on
173− i.MX6 SoCs in Secure Non-Volatile Storage (SNVS) of this chip.
173+ i.MX6 and i.MX7 SoCs in Secure Non-Volatile Storage (SNVS) of this chip.
174174
175175 This driver can also be built as a module. If so, the module
176176 will be called nvmem-snvs-lpgpr.
drivers/nvmem/bcm-ocotp.c+2−13
@@ -262,8 +262,7 @@ static int bcm_otpc_probe(struct platform_device *pdev) · 261 unmodified lines
262262 else if (of_device_is_compatible(dev->of_node, "brcm,ocotp-v2"))
263263 priv->map = &otp_map_v2;
264264 else {
265− dev_err(&pdev->dev,
266− "%s otpc config map not defined\n", __func__);
265+ dev_err(dev, "%s otpc config map not defined\n", __func__);
267266 return -EINVAL;
268267 }
269268
@@ -302,27 +301,17 @@ static int bcm_otpc_probe(struct platform_device *pdev) · 32 unmodified lines
302301
303302 priv->config = &bcm_otpc_nvmem_config;
304303
305− nvmem = nvmem_register(&bcm_otpc_nvmem_config);
304+ nvmem = devm_nvmem_register(dev, &bcm_otpc_nvmem_config);
306305 if (IS_ERR(nvmem)) {
307306 dev_err(dev, "error registering nvmem config\n");
308307 return PTR_ERR(nvmem);
309308 }
310309
311− platform_set_drvdata(pdev, nvmem);
312−
313310 return 0;
314311 }
315312
316−static int bcm_otpc_remove(struct platform_device *pdev)
317−{
318− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
319−
320− return nvmem_unregister(nvmem);
321−}
322−
323313 static struct platform_driver bcm_otpc_driver = {
324314 .probe = bcm_otpc_probe,
325− .remove = bcm_otpc_remove,
326315 .driver = {
327316 .name = "brcm-otpc",
328317 .of_match_table = bcm_otpc_dt_ids,
drivers/nvmem/core.c+67−3
@@ -473,9 +473,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) · 472 unmodified lines
473473 nvmem->reg_read = config->reg_read;
474474 nvmem->reg_write = config->reg_write;
475475 nvmem->dev.of_node = config->dev->of_node;
476− dev_set_name(&nvmem->dev, "%s%d",
477− config->name ? : "nvmem",
478− config->name ? config->id : nvmem->id);
476+
477+ if (config->id == -1 && config->name) {
478+ dev_set_name(&nvmem->dev, "%s", config->name);
479+ } else {
480+ dev_set_name(&nvmem->dev, "%s%d",
481+ config->name ? : "nvmem",
482+ config->name ? config->id : nvmem->id);
483+ }
479484
480485 nvmem->read_only = device_property_present(config->dev, "read-only") |
481486 config->read_only;
@@ -544,6 +549,65 @@ int nvmem_unregister(struct nvmem_device *nvmem) · 62 unmodified lines
544549 }
545550 EXPORT_SYMBOL_GPL(nvmem_unregister);
546551
552+static void devm_nvmem_release(struct device *dev, void *res)
553+{
554+ WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
555+}
556+
557+/**
558+ * devm_nvmem_register() - Register a managed nvmem device for given
559+ * nvmem_config.
560+ * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem
561+ *
562+ * @config: nvmem device configuration with which nvmem device is created.
563+ *
564+ * Return: Will be an ERR_PTR() on error or a valid pointer to nvmem_device
565+ * on success.
566+ */
567+struct nvmem_device *devm_nvmem_register(struct device *dev,
568+ const struct nvmem_config *config)
569+{
570+ struct nvmem_device **ptr, *nvmem;
571+
572+ ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL);
573+ if (!ptr)
574+ return ERR_PTR(-ENOMEM);
575+
576+ nvmem = nvmem_register(config);
577+
578+ if (!IS_ERR(nvmem)) {
579+ *ptr = nvmem;
580+ devres_add(dev, ptr);
581+ } else {
582+ devres_free(ptr);
583+ }
584+
585+ return nvmem;
586+}
587+EXPORT_SYMBOL_GPL(devm_nvmem_register);
588+
589+static int devm_nvmem_match(struct device *dev, void *res, void *data)
590+{
591+ struct nvmem_device **r = res;
592+
593+ return *r == data;
594+}
595+
596+/**
597+ * devm_nvmem_unregister() - Unregister previously registered managed nvmem
598+ * device.
599+ *
600+ * @nvmem: Pointer to previously registered nvmem device.
601+ *
602+ * Return: Will be an negative on error or a zero on success.
603+ */
604+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
605+{
606+ return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem);
607+}
608+EXPORT_SYMBOL(devm_nvmem_unregister);
609+
610+
547611 static struct nvmem_device *__nvmem_device_get(struct device_node *np,
548612 struct nvmem_cell **cellp,
549613 const char *cell_id)
drivers/nvmem/imx-iim.c+3−15
@@ -125,7 +125,7 @@ static int imx_iim_probe(struct platform_device *pdev) · 124 unmodified lines
125125
126126 drvdata = of_id->data;
127127
128− iim->clk = devm_clk_get(&pdev->dev, NULL);
128+ iim->clk = devm_clk_get(dev, NULL);
129129 if (IS_ERR(iim->clk))
130130 return PTR_ERR(iim->clk);
131131
@@ -138,25 +138,13 @@ static int imx_iim_probe(struct platform_device *pdev) · 6 unmodified lines
138138 cfg.size = drvdata->nregs;
139139 cfg.priv = iim;
140140
141− nvmem = nvmem_register(&cfg);
142− if (IS_ERR(nvmem))
143− return PTR_ERR(nvmem);
141+ nvmem = devm_nvmem_register(dev, &cfg);
144142
145− platform_set_drvdata(pdev, nvmem);
146−
147− return 0;
148−}
149−
150−static int imx_iim_remove(struct platform_device *pdev)
151−{
152− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
153−
154− return nvmem_unregister(nvmem);
143+ return PTR_ERR_OR_ZERO(nvmem);
155144 }
156145
157146 static struct platform_driver imx_iim_driver = {
158147 .probe = imx_iim_probe,
159− .remove = imx_iim_remove,
160148 .driver = {
161149 .name = "imx-iim",
162150 .of_match_table = imx_iim_dt_ids,
drivers/nvmem/imx-ocotp.c+2−16
@@ -439,7 +439,6 @@ MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); · 438 unmodified lines
439439
440440 static int imx_ocotp_probe(struct platform_device *pdev)
441441 {
442− const struct of_device_id *of_id;
443442 struct device *dev = &pdev->dev;
444443 struct resource *res;
445444 struct ocotp_priv *priv;
@@ -460,32 +459,19 @@ static int imx_ocotp_probe(struct platform_device *pdev) · 14 unmodified lines
460459 if (IS_ERR(priv->clk))
461460 return PTR_ERR(priv->clk);
462461
463− of_id = of_match_device(imx_ocotp_dt_ids, dev);
464462 priv->params = of_device_get_match_data(&pdev->dev);
465463 imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
466464 imx_ocotp_nvmem_config.dev = dev;
467465 imx_ocotp_nvmem_config.priv = priv;
468466 priv->config = &imx_ocotp_nvmem_config;
469− nvmem = nvmem_register(&imx_ocotp_nvmem_config);
467+ nvmem = devm_nvmem_register(dev, &imx_ocotp_nvmem_config);
470468
471− if (IS_ERR(nvmem))
472− return PTR_ERR(nvmem);
473469
474− platform_set_drvdata(pdev, nvmem);
475−
476− return 0;
477−}
478−
479−static int imx_ocotp_remove(struct platform_device *pdev)
480−{
481− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
482−
483− return nvmem_unregister(nvmem);
470+ return PTR_ERR_OR_ZERO(nvmem);
484471 }
485472
486473 static struct platform_driver imx_ocotp_driver = {
487474 .probe = imx_ocotp_probe,
488− .remove = imx_ocotp_remove,
489475 .driver = {
490476 .name = "imx_ocotp",
491477 .of_match_table = imx_ocotp_dt_ids,
drivers/nvmem/lpc18xx_otp.c+2−14
@@ -86,20 +86,9 @@ static int lpc18xx_otp_probe(struct platform_device *pdev) · 85 unmodified lines
8686 lpc18xx_otp_nvmem_config.dev = &pdev->dev;
8787 lpc18xx_otp_nvmem_config.priv = otp;
8888
89− nvmem = nvmem_register(&lpc18xx_otp_nvmem_config);
90− if (IS_ERR(nvmem))
91− return PTR_ERR(nvmem);
89+ nvmem = devm_nvmem_register(&pdev->dev, &lpc18xx_otp_nvmem_config);
9290
93− platform_set_drvdata(pdev, nvmem);
94−
95− return 0;
96−}
97−
98−static int lpc18xx_otp_remove(struct platform_device *pdev)
99−{
100− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
101−
102− return nvmem_unregister(nvmem);
91+ return PTR_ERR_OR_ZERO(nvmem);
10392 }
10493
10594 static const struct of_device_id lpc18xx_otp_dt_ids[] = {
@@ -110,7 +99,6 @@ MODULE_DEVICE_TABLE(of, lpc18xx_otp_dt_ids); · 4 unmodified lines
11099
111100 static struct platform_driver lpc18xx_otp_driver = {
112101 .probe = lpc18xx_otp_probe,
113− .remove = lpc18xx_otp_remove,
114102 .driver = {
115103 .name = "lpc18xx_otp",
116104 .of_match_table = lpc18xx_otp_dt_ids,
drivers/nvmem/meson-efuse.c+2−14
@@ -60,25 +60,13 @@ static int meson_efuse_probe(struct platform_device *pdev) · 59 unmodified lines
6060 econfig.reg_read = meson_efuse_read;
6161 econfig.size = size;
6262
63− nvmem = nvmem_register(&econfig);
64− if (IS_ERR(nvmem))
65− return PTR_ERR(nvmem);
63+ nvmem = devm_nvmem_register(&pdev->dev, &econfig);
6664
67− platform_set_drvdata(pdev, nvmem);
68−
69− return 0;
70−}
71−
72−static int meson_efuse_remove(struct platform_device *pdev)
73−{
74− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
75−
76− return nvmem_unregister(nvmem);
65+ return PTR_ERR_OR_ZERO(nvmem);
7766 }
7867
7968 static struct platform_driver meson_efuse_driver = {
8069 .probe = meson_efuse_probe,
81− .remove = meson_efuse_remove,
8270 .driver = {
8371 .name = "meson-efuse",
8472 .of_match_table = meson_efuse_match,
drivers/nvmem/meson-mx-efuse.c+2−14
@@ -233,25 +233,13 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) · 232 unmodified lines
233233 return PTR_ERR(efuse->core_clk);
234234 }
235235
236− efuse->nvmem = nvmem_register(&efuse->config);
237− if (IS_ERR(efuse->nvmem))
238− return PTR_ERR(efuse->nvmem);
236+ efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config);
239237
240− platform_set_drvdata(pdev, efuse);
241−
242− return 0;
243−}
244−
245−static int meson_mx_efuse_remove(struct platform_device *pdev)
246−{
247− struct meson_mx_efuse *efuse = platform_get_drvdata(pdev);
248−
249− return nvmem_unregister(efuse->nvmem);
238+ return PTR_ERR_OR_ZERO(efuse->nvmem);
250239 }
251240
252241 static struct platform_driver meson_mx_efuse_driver = {
253242 .probe = meson_mx_efuse_probe,
254− .remove = meson_mx_efuse_remove,
255243 .driver = {
256244 .name = "meson-mx-efuse",
257245 .of_match_table = meson_mx_efuse_match,
drivers/nvmem/mtk-efuse.c+2−14
@@ -72,20 +72,9 @@ static int mtk_efuse_probe(struct platform_device *pdev) · 71 unmodified lines
7272 econfig.size = resource_size(res);
7373 econfig.priv = priv;
7474 econfig.dev = dev;
75− nvmem = nvmem_register(&econfig);
76− if (IS_ERR(nvmem))
77− return PTR_ERR(nvmem);
75+ nvmem = devm_nvmem_register(dev, &econfig);
7876
79− platform_set_drvdata(pdev, nvmem);
80−
81− return 0;
82−}
83−
84−static int mtk_efuse_remove(struct platform_device *pdev)
85−{
86− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
87−
88− return nvmem_unregister(nvmem);
77+ return PTR_ERR_OR_ZERO(nvmem);
8978 }
9079
9180 static const struct of_device_id mtk_efuse_of_match[] = {
@@ -97,7 +86,6 @@ MODULE_DEVICE_TABLE(of, mtk_efuse_of_match); · 5 unmodified lines
9786
9887 static struct platform_driver mtk_efuse_driver = {
9988 .probe = mtk_efuse_probe,
100− .remove = mtk_efuse_remove,
10189 .driver = {
10290 .name = "mediatek,efuse",
10391 .of_match_table = mtk_efuse_of_match,
drivers/nvmem/qfprom.c+2−14
@@ -47,13 +47,6 @@ static int qfprom_reg_write(void *context, · 46 unmodified lines
4747 return 0;
4848 }
4949
50−static int qfprom_remove(struct platform_device *pdev)
51−{
52− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
53−
54− return nvmem_unregister(nvmem);
55−}
56−
5750 static struct nvmem_config econfig = {
5851 .name = "qfprom",
5952 .stride = 1,
@@ -82,13 +75,9 @@ static int qfprom_probe(struct platform_device *pdev) · 22 unmodified lines
8275 econfig.dev = dev;
8376 econfig.priv = priv;
8477
85− nvmem = nvmem_register(&econfig);
86− if (IS_ERR(nvmem))
87− return PTR_ERR(nvmem);
88−
89− platform_set_drvdata(pdev, nvmem);
78+ nvmem = devm_nvmem_register(dev, &econfig);
9079
91− return 0;
80+ return PTR_ERR_OR_ZERO(nvmem);
9281 }
9382
9483 static const struct of_device_id qfprom_of_match[] = {
@@ -99,7 +88,6 @@ MODULE_DEVICE_TABLE(of, qfprom_of_match); · 4 unmodified lines
9988
10089 static struct platform_driver qfprom_driver = {
10190 .probe = qfprom_probe,
102− .remove = qfprom_remove,
10391 .driver = {
10492 .name = "qcom,qfprom",
10593 .of_match_table = qfprom_of_match,
drivers/nvmem/rockchip-efuse.c+10−22
@@ -259,55 +259,43 @@ static int rockchip_efuse_probe(struct platform_device *pdev) · 258 unmodified lines
259259 struct resource *res;
260260 struct nvmem_device *nvmem;
261261 struct rockchip_efuse_chip *efuse;
262− const struct of_device_id *match;
262+ const void *data;
263263 struct device *dev = &pdev->dev;
264264
265− match = of_match_device(dev->driver->of_match_table, dev);
266− if (!match || !match->data) {
265+ data = of_device_get_match_data(dev);
266+ if (!data) {
267267 dev_err(dev, "failed to get match data\n");
268268 return -EINVAL;
269269 }
270270
271− efuse = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_efuse_chip),
271+ efuse = devm_kzalloc(dev, sizeof(struct rockchip_efuse_chip),
272272 GFP_KERNEL);
273273 if (!efuse)
274274 return -ENOMEM;
275275
276276 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
277− efuse->base = devm_ioremap_resource(&pdev->dev, res);
277+ efuse->base = devm_ioremap_resource(dev, res);
278278 if (IS_ERR(efuse->base))
279279 return PTR_ERR(efuse->base);
280280
281− efuse->clk = devm_clk_get(&pdev->dev, "pclk_efuse");
281+ efuse->clk = devm_clk_get(dev, "pclk_efuse");
282282 if (IS_ERR(efuse->clk))
283283 return PTR_ERR(efuse->clk);
284284
285− efuse->dev = &pdev->dev;
285+ efuse->dev = dev;
286286 if (of_property_read_u32(dev->of_node, "rockchip,efuse-size",
287287 &econfig.size))
288288 econfig.size = resource_size(res);
289− econfig.reg_read = match->data;
289+ econfig.reg_read = data;
290290 econfig.priv = efuse;
291291 econfig.dev = efuse->dev;
292− nvmem = nvmem_register(&econfig);
293− if (IS_ERR(nvmem))
294− return PTR_ERR(nvmem);
292+ nvmem = devm_nvmem_register(dev, &econfig);
295293
296− platform_set_drvdata(pdev, nvmem);
297−
298− return 0;
299−}
300−
301−static int rockchip_efuse_remove(struct platform_device *pdev)
302−{
303− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
304−
305− return nvmem_unregister(nvmem);
294+ return PTR_ERR_OR_ZERO(nvmem);
306295 }
307296
308297 static struct platform_driver rockchip_efuse_driver = {
309298 .probe = rockchip_efuse_probe,
310− .remove = rockchip_efuse_remove,
311299 .driver = {
312300 .name = "rockchip-efuse",
313301 .of_match_table = rockchip_efuse_match,
drivers/nvmem/snvs_lpgpr.c+28−25
@@ -14,15 +14,21 @@ · 13 unmodified lines
1414 #include <linux/regmap.h>
1515
1616 #define IMX6Q_SNVS_HPLR 0x00
17−#define IMX6Q_GPR_SL BIT(5)
1817 #define IMX6Q_SNVS_LPLR 0x34
19−#define IMX6Q_GPR_HL BIT(5)
2018 #define IMX6Q_SNVS_LPGPR 0x68
2119
20+#define IMX7D_SNVS_HPLR 0x00
21+#define IMX7D_SNVS_LPLR 0x34
22+#define IMX7D_SNVS_LPGPR 0x90
23+
24+#define IMX_GPR_SL BIT(5)
25+#define IMX_GPR_HL BIT(5)
26+
2227 struct snvs_lpgpr_cfg {
2328 int offset;
2429 int offset_hplr;
2530 int offset_lplr;
31+ int size;
2632 };
2733
2834 struct snvs_lpgpr_priv {
@@ -36,6 +42,14 @@ static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx6q = { · 7 unmodified lines
3642 .offset = IMX6Q_SNVS_LPGPR,
3743 .offset_hplr = IMX6Q_SNVS_HPLR,
3844 .offset_lplr = IMX6Q_SNVS_LPLR,
45+ .size = 4,
46+};
47+
48+static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx7d = {
49+ .offset = IMX7D_SNVS_LPGPR,
50+ .offset_hplr = IMX7D_SNVS_HPLR,
51+ .offset_lplr = IMX7D_SNVS_LPLR,
52+ .size = 16,
3953 };
4054
4155 static int snvs_lpgpr_write(void *context, unsigned int offset, void *val,
@@ -50,14 +64,14 @@ static int snvs_lpgpr_write(void *context, unsigned int offset, void *val, · 8 unmodified lines
5064 if (ret < 0)
5165 return ret;
5266
53− if (lock_reg & IMX6Q_GPR_SL)
67+ if (lock_reg & IMX_GPR_SL)
5468 return -EPERM;
5569
5670 ret = regmap_read(priv->regmap, dcfg->offset_lplr, &lock_reg);
5771 if (ret < 0)
5872 return ret;
5973
60− if (lock_reg & IMX6Q_GPR_HL)
74+ if (lock_reg & IMX_GPR_HL)
6175 return -EPERM;
6276
6377 return regmap_bulk_write(priv->regmap, dcfg->offset + offset, val,
@@ -110,40 +124,29 @@ static int snvs_lpgpr_probe(struct platform_device *pdev) · 46 unmodified lines
110124 cfg->priv = priv;
111125 cfg->name = dev_name(dev);
112126 cfg->dev = dev;
113− cfg->stride = 4,
114− cfg->word_size = 4,
115− cfg->size = 4,
116− cfg->owner = THIS_MODULE,
117− cfg->reg_read = snvs_lpgpr_read,
118− cfg->reg_write = snvs_lpgpr_write,
119−
120− nvmem = nvmem_register(cfg);
121− if (IS_ERR(nvmem))
122− return PTR_ERR(nvmem);
127+ cfg->stride = 4;
128+ cfg->word_size = 4;
129+ cfg->size = dcfg->size,
130+ cfg->owner = THIS_MODULE;
131+ cfg->reg_read = snvs_lpgpr_read;
132+ cfg->reg_write = snvs_lpgpr_write;
123133
124− platform_set_drvdata(pdev, nvmem);
125−
126− return 0;
127−}
128−
129−static int snvs_lpgpr_remove(struct platform_device *pdev)
130−{
131− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
134+ nvmem = devm_nvmem_register(dev, cfg);
132135
133− return nvmem_unregister(nvmem);
136+ return PTR_ERR_OR_ZERO(nvmem);
134137 }
135138
136139 static const struct of_device_id snvs_lpgpr_dt_ids[] = {
137140 { .compatible = "fsl,imx6q-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx6q },
138141 { .compatible = "fsl,imx6ul-snvs-lpgpr",
139142 .data = &snvs_lpgpr_cfg_imx6q },
143+ { .compatible = "fsl,imx7d-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx7d },
140144 { },
141145 };
142146 MODULE_DEVICE_TABLE(of, snvs_lpgpr_dt_ids);
143147
144148 static struct platform_driver snvs_lpgpr_driver = {
145149 .probe = snvs_lpgpr_probe,
146− .remove = snvs_lpgpr_remove,
147150 .driver = {
148151 .name = "snvs_lpgpr",
149152 .of_match_table = snvs_lpgpr_dt_ids,
@@ -152,5 +155,5 @@ static struct platform_driver snvs_lpgpr_driver = { · 2 unmodified lines
152155 module_platform_driver(snvs_lpgpr_driver);
153156
154157 MODULE_AUTHOR("Oleksij Rempel <o.rempel@pengutronix.de>");
155−MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 Secure Non-Volatile Storage");
158+MODULE_DESCRIPTION("Low Power General Purpose Register in i.MX6 and i.MX7 Secure Non-Volatile Storage");
156159 MODULE_LICENSE("GPL v2");
drivers/nvmem/sunxi_sid.c+50−21
@@ -85,13 +85,14 @@ static int sunxi_sid_read(void *context, unsigned int offset, · 84 unmodified lines
8585 }
8686
8787 static int sun8i_sid_register_readout(const struct sunxi_sid *sid,
88− const unsigned int word)
88+ const unsigned int offset,
89+ u32 *out)
8990 {
9091 u32 reg_val;
9192 int ret;
9293
9394 /* Set word, lock access, and set read command */
94− reg_val = (word & SUN8I_SID_OFFSET_MASK)
95+ reg_val = (offset & SUN8I_SID_OFFSET_MASK)
9596 << SUN8I_SID_OFFSET_SHIFT;
9697 reg_val |= SUN8I_SID_OP_LOCK | SUN8I_SID_READ;
9798 writel(reg_val, sid->base + SUN8I_SID_PRCTL);
@@ -101,7 +102,49 @@ static int sun8i_sid_register_readout(const struct sunxi_sid *sid, · 3 unmodified lines
101102 if (ret)
102103 return ret;
103104
105+ if (out)
106+ *out = readl(sid->base + SUN8I_SID_RDKEY);
107+
104108 writel(0, sid->base + SUN8I_SID_PRCTL);
109+
110+ return 0;
111+}
112+
113+/*
114+ * On Allwinner H3, the value on the 0x200 offset of the SID controller seems
115+ * to be not reliable at all.
116+ * Read by the registers instead.
117+ */
118+static int sun8i_sid_read_byte_by_reg(const struct sunxi_sid *sid,
119+ const unsigned int offset,
120+ u8 *out)
121+{
122+ u32 word;
123+ int ret;
124+
125+ ret = sun8i_sid_register_readout(sid, offset & ~0x03, &word);
126+
127+ if (ret)
128+ return ret;
129+
130+ *out = (word >> ((offset & 0x3) * 8)) & 0xff;
131+
132+ return 0;
133+}
134+
135+static int sun8i_sid_read_by_reg(void *context, unsigned int offset,
136+ void *val, size_t bytes)
137+{
138+ struct sunxi_sid *sid = context;
139+ u8 *buf = val;
140+ int ret;
141+
142+ while (bytes--) {
143+ ret = sun8i_sid_read_byte_by_reg(sid, offset++, buf++);
144+ if (ret)
145+ return ret;
146+ }
147+
105148 return 0;
106149 }
107150
@@ -131,26 +174,12 @@ static int sunxi_sid_probe(struct platform_device *pdev) · 23 unmodified lines
131174
132175 size = cfg->size;
133176
134− if (cfg->need_register_readout) {
135− /*
136− * H3's SID controller have a bug that the value at 0x200
137− * offset is not the correct value when the hardware is reseted.
138− * However, after doing a register-based read operation, the
139− * value become right.
140− * Do a full read operation here, but ignore its value
141− * (as it's more fast to read by direct MMIO value than
142− * with registers)
143− */
144− for (i = 0; i < (size >> 2); i++) {
145− ret = sun8i_sid_register_readout(sid, i);
146− if (ret)
147− return ret;
148− }
149− }
150−
151177 econfig.size = size;
152178 econfig.dev = dev;
153− econfig.reg_read = sunxi_sid_read;
179+ if (cfg->need_register_readout)
180+ econfig.reg_read = sun8i_sid_read_by_reg;
181+ else
182+ econfig.reg_read = sunxi_sid_read;
154183 econfig.priv = sid;
155184 nvmem = nvmem_register(&econfig);
156185 if (IS_ERR(nvmem))
@@ -163,7 +192,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) · 6 unmodified lines
163192 }
164193
165194 for (i = 0; i < size; i++)
166− randomness[i] = sunxi_sid_read_byte(sid, i);
195+ econfig.reg_read(sid, i, &randomness[i], 1);
167196
168197 add_device_randomness(randomness, size);
169198 kfree(randomness);
drivers/nvmem/uniphier-efuse.c+2−14
@@ -60,20 +60,9 @@ static int uniphier_efuse_probe(struct platform_device *pdev) · 59 unmodified lines
6060 econfig.size = resource_size(res);
6161 econfig.priv = priv;
6262 econfig.dev = dev;
63− nvmem = nvmem_register(&econfig);
64− if (IS_ERR(nvmem))
65− return PTR_ERR(nvmem);
63+ nvmem = devm_nvmem_register(dev, &econfig);
6664
67− platform_set_drvdata(pdev, nvmem);
68−
69− return 0;
70−}
71−
72−static int uniphier_efuse_remove(struct platform_device *pdev)
73−{
74− struct nvmem_device *nvmem = platform_get_drvdata(pdev);
75−
76− return nvmem_unregister(nvmem);
65+ return PTR_ERR_OR_ZERO(nvmem);
7766 }
7867
7968 static const struct of_device_id uniphier_efuse_of_match[] = {
@@ -84,7 +73,6 @@ MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match); · 4 unmodified lines
8473
8574 static struct platform_driver uniphier_efuse_driver = {
8675 .probe = uniphier_efuse_probe,
87− .remove = uniphier_efuse_remove,
8876 .driver = {
8977 .name = "uniphier-efuse",
9078 .of_match_table = uniphier_efuse_of_match,
drivers/nvmem/vf610-ocotp.c+5−19
@@ -217,21 +217,13 @@ static const struct of_device_id ocotp_of_match[] = { · 216 unmodified lines
217217 };
218218 MODULE_DEVICE_TABLE(of, ocotp_of_match);
219219
220−static int vf610_ocotp_remove(struct platform_device *pdev)
221−{
222− struct vf610_ocotp *ocotp_dev = platform_get_drvdata(pdev);
223−
224− return nvmem_unregister(ocotp_dev->nvmem);
225−}
226−
227220 static int vf610_ocotp_probe(struct platform_device *pdev)
228221 {
229222 struct device *dev = &pdev->dev;
230223 struct resource *res;
231224 struct vf610_ocotp *ocotp_dev;
232225
233− ocotp_dev = devm_kzalloc(&pdev->dev,
234− sizeof(struct vf610_ocotp), GFP_KERNEL);
226+ ocotp_dev = devm_kzalloc(dev, sizeof(struct vf610_ocotp), GFP_KERNEL);
235227 if (!ocotp_dev)
236228 return -ENOMEM;
237229
@@ -246,26 +238,20 @@ static int vf610_ocotp_probe(struct platform_device *pdev) · 8 unmodified lines
246238 PTR_ERR(ocotp_dev->clk));
247239 return PTR_ERR(ocotp_dev->clk);
248240 }
241+ ocotp_dev->dev = dev;
242+ ocotp_dev->timing = vf610_ocotp_calculate_timing(ocotp_dev);
249243
250244 ocotp_config.size = resource_size(res);
251245 ocotp_config.priv = ocotp_dev;
252246 ocotp_config.dev = dev;
253247
254− ocotp_dev->nvmem = nvmem_register(&ocotp_config);
255− if (IS_ERR(ocotp_dev->nvmem))
256− return PTR_ERR(ocotp_dev->nvmem);
248+ ocotp_dev->nvmem = devm_nvmem_register(dev, &ocotp_config);
257249
258− ocotp_dev->dev = dev;
259− platform_set_drvdata(pdev, ocotp_dev);
260−
261− ocotp_dev->timing = vf610_ocotp_calculate_timing(ocotp_dev);
262−
263− return 0;
250+ return PTR_ERR_OR_ZERO(ocotp_dev->nvmem);
264251 }
265252
266253 static struct platform_driver vf610_ocotp_driver = {
267254 .probe = vf610_ocotp_probe,
268− .remove = vf610_ocotp_remove,
269255 .driver = {
270256 .name = "vf610-ocotp",
271257 .of_match_table = ocotp_of_match,
drivers/parport/parport_ax88796.c+3−5
@@ -273,18 +273,16 @@ static int parport_ax88796_probe(struct platform_device *pdev) · 272 unmodified lines
273273 {
274274 struct device *_dev = &pdev->dev;
275275 struct ax_drvdata *dd;
276− struct parport *pp = NULL;
276+ struct parport *pp;
277277 struct resource *res;
278278 unsigned long size;
279279 int spacing;
280280 int irq;
281281 int ret;
282282
283− dd = kzalloc(sizeof(struct ax_drvdata), GFP_KERNEL);
284− if (dd == NULL) {
285− dev_err(_dev, "no memory for private data\n");
283+ dd = kzalloc(sizeof(*dd), GFP_KERNEL);
284+ if (!dd)
286285 return -ENOMEM;
287− }
288286
289287 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
290288 if (res == NULL) {
drivers/parport/parport_pc.c+4−0
@@ -2646,6 +2646,7 @@ enum parport_pc_pci_cards { · 2645 unmodified lines
26462646 netmos_9901,
26472647 netmos_9865,
26482648 quatech_sppxp100,
2649+ wch_ch382l,
26492650 };
26502651
26512652
@@ -2708,6 +2709,7 @@ static struct parport_pc_pci { · 56 unmodified lines
27082709 /* netmos_9901 */ { 1, { { 0, -1 }, } },
27092710 /* netmos_9865 */ { 1, { { 0, -1 }, } },
27102711 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } },
2712+ /* wch_ch382l */ { 1, { { 2, -1 }, } },
27112713 };
27122714
27132715 static const struct pci_device_id parport_pc_pci_tbl[] = {
@@ -2797,6 +2799,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = { · 83 unmodified lines
27972799 /* Quatech SPPXP-100 Parallel port PCI ExpressCard */
27982800 { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100,
27992801 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 },
2802+ /* WCH CH382L PCI-E single parallel port card */
2803+ { 0x1c00, 0x3050, 0x1c00, 0x3050, 0, 0, wch_ch382l },
28002804 { 0, } /* terminate list */
28012805 };
28022806 MODULE_DEVICE_TABLE(pci, parport_pc_pci_tbl);
drivers/parport/parport_serial.c+46−76
@@ -1,30 +1,24 @@
1+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Support for common PCI multi-I/O cards (which is most of them)
34 *
45 * Copyright (C) 2001 Tim Waugh <twaugh@redhat.com>
56 *
6− * This program is free software; you can redistribute it and/or
7− * modify it under the terms of the GNU General Public License
8− * as published by the Free Software Foundation; either version
9− * 2 of the License, or (at your option) any later version.
10− *
11− *
127 * Multi-function PCI cards are supposed to present separate logical
138 * devices on the bus. A common thing to do seems to be to just use
149 * one logical device with lots of base address registers for both
1510 * parallel ports and serial ports. This driver is for dealing with
1611 * that.
17− *
1812 */
1913
20−#include <linux/types.h>
21−#include <linux/module.h>
22−#include <linux/init.h>
23−#include <linux/slab.h>
24−#include <linux/pci.h>
2514 #include <linux/interrupt.h>
15+#include <linux/module.h>
2616 #include <linux/parport.h>
2717 #include <linux/parport_pc.h>
18+#include <linux/pci.h>
19+#include <linux/slab.h>
20+#include <linux/types.h>
21+
2822 #include <linux/8250_pci.h>
2923
3024 enum parport_pc_pci_cards {
@@ -65,6 +59,7 @@ enum parport_pc_pci_cards { · 34 unmodified lines
6559 wch_ch353_1s1p,
6660 wch_ch353_2s1p,
6761 wch_ch382_2s1p,
62+ brainboxes_5s1p,
6863 sunix_2s1p,
6964 };
7065
@@ -153,6 +148,7 @@ static struct parport_pc_pci cards[] = { · 82 unmodified lines
153148 /* wch_ch353_1s1p*/ { 1, { { 1, -1}, } },
154149 /* wch_ch353_2s1p*/ { 1, { { 2, -1}, } },
155150 /* wch_ch382_2s1p*/ { 1, { { 2, -1}, } },
151+ /* brainboxes_5s1p */ { 1, { { 3, -1 }, } },
156152 /* sunix_2s1p */ { 1, { { 3, -1 }, } },
157153 };
158154
@@ -258,6 +254,10 @@ static struct pci_device_id parport_serial_pci_tbl[] = { · 99 unmodified lines
258254 { 0x4348, 0x7053, 0x4348, 0x3253, 0, 0, wch_ch353_2s1p},
259255 { 0x1c00, 0x3250, 0x1c00, 0x3250, 0, 0, wch_ch382_2s1p},
260256
257+ /* BrainBoxes PX272/PX306 MIO card */
258+ { PCI_VENDOR_ID_INTASHIELD, 0x4100,
259+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, brainboxes_5s1p },
260+
261261 /*
262262 * More SUNIX variations. At least one of these has part number
263263 * '5079A but subdevice 0x102. That board reports 0x0708 as
@@ -501,6 +501,12 @@ static struct pciserial_board pci_parport_serial_boards[] = { · 237 unmodified lines
501501 .uart_offset = 8,
502502 .first_offset = 0xC0,
503503 },
504+ [brainboxes_5s1p] = {
505+ .flags = FL_BASE2,
506+ .num_ports = 5,
507+ .base_baud = 921600,
508+ .uart_offset = 8,
509+ },
504510 [sunix_2s1p] = {
505511 .flags = FL_BASE0|FL_BASE_BARS,
506512 .num_ports = 2,
@@ -524,12 +530,10 @@ static int serial_register(struct pci_dev *dev, const struct pci_device_id *id) · 17 unmodified lines
524530 struct serial_private *serial;
525531
526532 board = &pci_parport_serial_boards[id->driver_data];
527−
528533 if (board->num_ports == 0)
529534 return 0;
530535
531536 serial = pciserial_init_ports(dev, board);
532−
533537 if (IS_ERR(serial))
534538 return PTR_ERR(serial);
535539
@@ -558,10 +562,9 @@ static int parport_register(struct pci_dev *dev, const struct pci_device_id *id) · 22 unmodified lines
558562 int irq;
559563
560564 if (priv->num_par == ARRAY_SIZE (priv->port)) {
561− printk (KERN_WARNING
562− "parport_serial: %s: only %zu parallel ports "
563− "supported (%d reported)\n", pci_name (dev),
564− ARRAY_SIZE(priv->port), card->numports);
565+ dev_warn(&dev->dev,
566+ "only %zu parallel ports supported (%d reported)\n",
567+ ARRAY_SIZE(priv->port), card->numports);
565568 break;
566569 }
567570
@@ -577,12 +580,12 @@ static int parport_register(struct pci_dev *dev, const struct pci_device_id *id) · 9 unmodified lines
577580 irq = dev->irq;
578581 if (irq == IRQ_NONE) {
579582 dev_dbg(&dev->dev,
580− "PCI parallel port detected: I/O at %#lx(%#lx)\n",
583+ "PCI parallel port detected: I/O at %#lx(%#lx)\n",
581584 io_lo, io_hi);
582585 irq = PARPORT_IRQ_NONE;
583586 } else {
584587 dev_dbg(&dev->dev,
585− "PCI parallel port detected: I/O at %#lx(%#lx), IRQ %d\n",
588+ "PCI parallel port detected: I/O at %#lx(%#lx), IRQ %d\n",
586589 io_lo, io_hi, irq);
587590 }
588591 port = parport_pc_probe_port (io_lo, io_hi, irq,
@@ -605,28 +608,26 @@ static int parport_serial_pci_probe(struct pci_dev *dev, · 16 unmodified lines
605608 struct parport_serial_private *priv;
606609 int err;
607610
608− priv = kzalloc (sizeof *priv, GFP_KERNEL);
611+ priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
609612 if (!priv)
610613 return -ENOMEM;
614+
611615 pci_set_drvdata (dev, priv);
612616
613− err = pci_enable_device (dev);
614− if (err) {
615− kfree (priv);
617+ err = pcim_enable_device(dev);
618+ if (err)
616619 return err;
617− }
618620
619− if (parport_register (dev, id)) {
620− kfree (priv);
621− return -ENODEV;
622− }
621+ err = parport_register(dev, id);
622+ if (err)
623+ return err;
623624
624− if (serial_register (dev, id)) {
625+ err = serial_register(dev, id);
626+ if (err) {
625627 int i;
626628 for (i = 0; i < priv->num_par; i++)
627629 parport_pc_unregister_port (priv->port[i]);
628− kfree (priv);
629− return -ENODEV;
630+ return err;
630631 }
631632
632633 return 0;
@@ -645,78 +646,47 @@ static void parport_serial_pci_remove(struct pci_dev *dev) · 12 unmodified lines
645646 for (i = 0; i < priv->num_par; i++)
646647 parport_pc_unregister_port (priv->port[i]);
647648
648− kfree (priv);
649649 return;
650650 }
651651
652−#ifdef CONFIG_PM
653−static int parport_serial_pci_suspend(struct pci_dev *dev, pm_message_t state)
652+static int __maybe_unused parport_serial_pci_suspend(struct device *dev)
654653 {
655− struct parport_serial_private *priv = pci_get_drvdata(dev);
654+ struct pci_dev *pdev = to_pci_dev(dev);
655+ struct parport_serial_private *priv = pci_get_drvdata(pdev);
656656
657657 if (priv->serial)
658658 pciserial_suspend_ports(priv->serial);
659659
660660 /* FIXME: What about parport? */
661−
662− pci_save_state(dev);
663− pci_set_power_state(dev, pci_choose_state(dev, state));
664661 return 0;
665662 }
666663
667−static int parport_serial_pci_resume(struct pci_dev *dev)
664+static int __maybe_unused parport_serial_pci_resume(struct device *dev)
668665 {
669− struct parport_serial_private *priv = pci_get_drvdata(dev);
670− int err;
671−
672− pci_set_power_state(dev, PCI_D0);
673− pci_restore_state(dev);
674−
675− /*
676− * The device may have been disabled. Re-enable it.
677− */
678− err = pci_enable_device(dev);
679− if (err) {
680− printk(KERN_ERR "parport_serial: %s: error enabling "
681− "device for resume (%d)\n", pci_name(dev), err);
682− return err;
683− }
666+ struct pci_dev *pdev = to_pci_dev(dev);
667+ struct parport_serial_private *priv = pci_get_drvdata(pdev);
684668
685669 if (priv->serial)
686670 pciserial_resume_ports(priv->serial);
687671
688672 /* FIXME: What about parport? */
689−
690673 return 0;
691674 }
692−#endif
675+
676+static SIMPLE_DEV_PM_OPS(parport_serial_pm_ops,
677+ parport_serial_pci_suspend, parport_serial_pci_resume);
693678
694679 static struct pci_driver parport_serial_pci_driver = {
695680 .name = "parport_serial",
696681 .id_table = parport_serial_pci_tbl,
697682 .probe = parport_serial_pci_probe,
698683 .remove = parport_serial_pci_remove,
699−#ifdef CONFIG_PM
700− .suspend = parport_serial_pci_suspend,
701− .resume = parport_serial_pci_resume,
702−#endif
684+ .driver = {
685+ .pm = &parport_serial_pm_ops,
686+ },
703687 };
704−
705−
706−static int __init parport_serial_init (void)
707−{
708− return pci_register_driver (&parport_serial_pci_driver);
709−}
710−
711−static void __exit parport_serial_exit (void)
712−{
713− pci_unregister_driver (&parport_serial_pci_driver);
714− return;
715−}
688+module_pci_driver(parport_serial_pci_driver);
716689
717690 MODULE_AUTHOR("Tim Waugh <twaugh@redhat.com>");
718691 MODULE_DESCRIPTION("Driver for common parallel+serial multi-I/O PCI cards");
719692 MODULE_LICENSE("GPL");
720−
721−module_init(parport_serial_init);
722−module_exit(parport_serial_exit);
drivers/pps/clients/pps_parport.c+18−3
@@ -49,6 +49,7 @@ MODULE_PARM_DESC(clear_wait, · 48 unmodified lines
4949 " zero turns clear edge capture off entirely");
5050 module_param(clear_wait, uint, 0);
5151
52+static DEFINE_IDA(pps_client_index);
5253
5354 /* internal per port structure */
5455 struct pps_client_pp {
@@ -56,6 +57,7 @@ struct pps_client_pp { · 1 unmodified line
5657 struct pps_device *pps; /* PPS device */
5758 unsigned int cw; /* port clear timeout */
5859 unsigned int cw_err; /* number of timeouts */
60+ int index; /* device number */
5961 };
6062
6163 static inline int signal_is_set(struct parport *port)
@@ -136,6 +138,8 @@ out_both: · 74 unmodified lines
136138
137139 static void parport_attach(struct parport *port)
138140 {
141+ struct pardev_cb pps_client_cb;
142+ int index;
139143 struct pps_client_pp *device;
140144 struct pps_source_info info = {
141145 .name = KBUILD_MODNAME,
@@ -154,8 +158,15 @@ static void parport_attach(struct parport *port) · 12 unmodified lines
154158 return;
155159 }
156160
157− device->pardev = parport_register_device(port, KBUILD_MODNAME,
158− NULL, NULL, parport_irq, PARPORT_FLAG_EXCL, device);
161+ index = ida_simple_get(&pps_client_index, 0, 0, GFP_KERNEL);
162+ memset(&pps_client_cb, 0, sizeof(pps_client_cb));
163+ pps_client_cb.private = device;
164+ pps_client_cb.irq_func = parport_irq;
165+ pps_client_cb.flags = PARPORT_FLAG_EXCL;
166+ device->pardev = parport_register_dev_model(port,
167+ KBUILD_MODNAME,
168+ &pps_client_cb,
169+ index);
159170 if (!device->pardev) {
160171 pr_err("couldn't register with %s\n", port->name);
161172 goto err_free;
@@ -176,6 +187,7 @@ static void parport_attach(struct parport *port) · 14 unmodified lines
176187 device->cw = clear_wait;
177188
178189 port->ops->enable_irq(port);
190+ device->index = index;
179191
180192 pr_info("attached to %s\n", port->name);
181193
@@ -186,6 +198,7 @@ err_release_dev: · 4 unmodified lines
186198 err_unregister_dev:
187199 parport_unregister_device(device->pardev);
188200 err_free:
201+ ida_simple_remove(&pps_client_index, index);
189202 kfree(device);
190203 }
191204
@@ -205,13 +218,15 @@ static void parport_detach(struct parport *port) · 13 unmodified lines
205218 pps_unregister_source(device->pps);
206219 parport_release(pardev);
207220 parport_unregister_device(pardev);
221+ ida_simple_remove(&pps_client_index, device->index);
208222 kfree(device);
209223 }
210224
211225 static struct parport_driver pps_parport_driver = {
212226 .name = KBUILD_MODNAME,
213− .attach = parport_attach,
227+ .match_port = parport_attach,
214228 .detach = parport_detach,
229+ .devmodel = true,
215230 };
216231
217232 /* module staff */
drivers/pps/generators/pps_gen_parport.c+9−3
@@ -192,13 +192,18 @@ static inline ktime_t next_intr_time(struct pps_generator_pp *dev) · 191 unmodified lines
192192
193193 static void parport_attach(struct parport *port)
194194 {
195+ struct pardev_cb pps_cb;
196+
195197 if (attached) {
196198 /* we already have a port */
197199 return;
198200 }
199201
200− device.pardev = parport_register_device(port, KBUILD_MODNAME,
201− NULL, NULL, NULL, PARPORT_FLAG_EXCL, &device);
202+ memset(&pps_cb, 0, sizeof(pps_cb));
203+ pps_cb.private = &device;
204+ pps_cb.flags = PARPORT_FLAG_EXCL;
205+ device.pardev = parport_register_dev_model(port, KBUILD_MODNAME,
206+ &pps_cb, 0);
202207 if (!device.pardev) {
203208 pr_err("couldn't register with %s\n", port->name);
204209 return;
@@ -236,8 +241,9 @@ static void parport_detach(struct parport *port) · 31 unmodified lines
236241
237242 static struct parport_driver pps_gen_parport_driver = {
238243 .name = KBUILD_MODNAME,
239− .attach = parport_attach,
244+ .match_port = parport_attach,
240245 .detach = parport_detach,
246+ .devmodel = true,
241247 };
242248
243249 /* module staff */
drivers/siox/siox-core.c+1−1
@@ -594,7 +594,7 @@ static ssize_t device_add_store(struct device *dev, · 593 unmodified lines
594594 size_t inbytes = 0, outbytes = 0;
595595 u8 statustype = 0;
596596
597− ret = sscanf(buf, "%20s %zu %zu %hhu", type, &inbytes,
597+ ret = sscanf(buf, "%19s %zu %zu %hhu", type, &inbytes,
598598 &outbytes, &statustype);
599599 if (ret != 3 && ret != 4)
600600 return -EINVAL;
drivers/slimbus/core.c+1−1
@@ -141,7 +141,7 @@ static struct slim_device *slim_alloc_device(struct slim_controller *ctrl, · 140 unmodified lines
141141 sbdev->e_addr = *eaddr;
142142 ret = slim_add_device(ctrl, sbdev, node);
143143 if (ret) {
144− kfree(sbdev);
144+ put_device(&sbdev->dev);
145145 return NULL;
146146 }
147147
drivers/thunderbolt/dma_port.c+13−15
@@ -170,24 +170,22 @@ static int dma_port_write(struct tb_ctl *ctl, const void *buffer, u64 route, · 169 unmodified lines
170170
171171 static int dma_find_port(struct tb_switch *sw)
172172 {
173− int port, ret;
174− u32 type;
173+ static const int ports[] = { 3, 5, 7 };
174+ int i;
175175
176176 /*
177− * The DMA (NHI) port is either 3 or 5 depending on the
178− * controller. Try both starting from 5 which is more common.
177+ * The DMA (NHI) port is either 3, 5 or 7 depending on the
178+ * controller. Try all of them.
179179 */
180− port = 5;
181− ret = dma_port_read(sw->tb->ctl, &type, tb_route(sw), port, 2, 1,
182− DMA_PORT_TIMEOUT);
183− if (!ret && (type & 0xffffff) == TB_TYPE_NHI)
184− return port;
185−
186− port = 3;
187− ret = dma_port_read(sw->tb->ctl, &type, tb_route(sw), port, 2, 1,
188− DMA_PORT_TIMEOUT);
189− if (!ret && (type & 0xffffff) == TB_TYPE_NHI)
190− return port;
180+ for (i = 0; i < ARRAY_SIZE(ports); i++) {
181+ u32 type;
182+ int ret;
183+
184+ ret = dma_port_read(sw->tb->ctl, &type, tb_route(sw), ports[i],
185+ 2, 1, DMA_PORT_TIMEOUT);
186+ if (!ret && (type & 0xffffff) == TB_TYPE_NHI)
187+ return ports[i];
188+ }
191189
192190 return -ENODEV;
193191 }
drivers/thunderbolt/domain.c+129−1
@@ -117,23 +117,151 @@ static const char * const tb_security_names[] = { · 116 unmodified lines
117117 [TB_SECURITY_USER] = "user",
118118 [TB_SECURITY_SECURE] = "secure",
119119 [TB_SECURITY_DPONLY] = "dponly",
120+ [TB_SECURITY_USBONLY] = "usbonly",
120121 };
121122
123+static ssize_t boot_acl_show(struct device *dev, struct device_attribute *attr,
124+ char *buf)
125+{
126+ struct tb *tb = container_of(dev, struct tb, dev);
127+ uuid_t *uuids;
128+ ssize_t ret;
129+ int i;
130+
131+ uuids = kcalloc(tb->nboot_acl, sizeof(uuid_t), GFP_KERNEL);
132+ if (!uuids)
133+ return -ENOMEM;
134+
135+ if (mutex_lock_interruptible(&tb->lock)) {
136+ ret = -ERESTARTSYS;
137+ goto out;
138+ }
139+ ret = tb->cm_ops->get_boot_acl(tb, uuids, tb->nboot_acl);
140+ if (ret) {
141+ mutex_unlock(&tb->lock);
142+ goto out;
143+ }
144+ mutex_unlock(&tb->lock);
145+
146+ for (ret = 0, i = 0; i < tb->nboot_acl; i++) {
147+ if (!uuid_is_null(&uuids[i]))
148+ ret += snprintf(buf + ret, PAGE_SIZE - ret, "%pUb",
149+ &uuids[i]);
150+
151+ ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s",
152+ i < tb->nboot_acl - 1 ? "," : "\n");
153+ }
154+
155+out:
156+ kfree(uuids);
157+ return ret;
158+}
159+
160+static ssize_t boot_acl_store(struct device *dev, struct device_attribute *attr,
161+ const char *buf, size_t count)
162+{
163+ struct tb *tb = container_of(dev, struct tb, dev);
164+ char *str, *s, *uuid_str;
165+ ssize_t ret = 0;
166+ uuid_t *acl;
167+ int i = 0;
168+
169+ /*
170+ * Make sure the value is not bigger than tb->nboot_acl * UUID
171+ * length + commas and optional "\n". Also the smallest allowable
172+ * string is tb->nboot_acl * ",".
173+ */
174+ if (count > (UUID_STRING_LEN + 1) * tb->nboot_acl + 1)
175+ return -EINVAL;
176+ if (count < tb->nboot_acl - 1)
177+ return -EINVAL;
178+
179+ str = kstrdup(buf, GFP_KERNEL);
180+ if (!str)
181+ return -ENOMEM;
182+
183+ acl = kcalloc(tb->nboot_acl, sizeof(uuid_t), GFP_KERNEL);
184+ if (!acl) {
185+ ret = -ENOMEM;
186+ goto err_free_str;
187+ }
188+
189+ uuid_str = strim(str);
190+ while ((s = strsep(&uuid_str, ",")) != NULL && i < tb->nboot_acl) {
191+ size_t len = strlen(s);
192+
193+ if (len) {
194+ if (len != UUID_STRING_LEN) {
195+ ret = -EINVAL;
196+ goto err_free_acl;
197+ }
198+ ret = uuid_parse(s, &acl[i]);
199+ if (ret)
200+ goto err_free_acl;
201+ }
202+
203+ i++;
204+ }
205+
206+ if (s || i < tb->nboot_acl) {
207+ ret = -EINVAL;
208+ goto err_free_acl;
209+ }
210+
211+ if (mutex_lock_interruptible(&tb->lock)) {
212+ ret = -ERESTARTSYS;
213+ goto err_free_acl;
214+ }
215+ ret = tb->cm_ops->set_boot_acl(tb, acl, tb->nboot_acl);
216+ mutex_unlock(&tb->lock);
217+
218+err_free_acl:
219+ kfree(acl);
220+err_free_str:
221+ kfree(str);
222+
223+ return ret ?: count;
224+}
225+static DEVICE_ATTR_RW(boot_acl);
226+
122227 static ssize_t security_show(struct device *dev, struct device_attribute *attr,
123228 char *buf)
124229 {
125230 struct tb *tb = container_of(dev, struct tb, dev);
231+ const char *name = "unknown";
126232
127− return sprintf(buf, "%s\n", tb_security_names[tb->security_level]);
233+ if (tb->security_level < ARRAY_SIZE(tb_security_names))
234+ name = tb_security_names[tb->security_level];
235+
236+ return sprintf(buf, "%s\n", name);
128237 }
129238 static DEVICE_ATTR_RO(security);
130239
131240 static struct attribute *domain_attrs[] = {
241+ &dev_attr_boot_acl.attr,
132242 &dev_attr_security.attr,
133243 NULL,
134244 };
135245
246+static umode_t domain_attr_is_visible(struct kobject *kobj,
247+ struct attribute *attr, int n)
248+{
249+ struct device *dev = container_of(kobj, struct device, kobj);
250+ struct tb *tb = container_of(dev, struct tb, dev);
251+
252+ if (attr == &dev_attr_boot_acl.attr) {
253+ if (tb->nboot_acl &&
254+ tb->cm_ops->get_boot_acl &&
255+ tb->cm_ops->set_boot_acl)
256+ return attr->mode;
257+ return 0;
258+ }
259+
260+ return attr->mode;
261+}
262+
136263 static struct attribute_group domain_attr_group = {
264+ .is_visible = domain_attr_is_visible,
137265 .attrs = domain_attrs,
138266 };
139267
drivers/thunderbolt/icm.c+685−79
@@ -41,7 +41,8 @@ · 40 unmodified lines
4141 #define PHY_PORT_CS1_LINK_STATE_MASK GENMASK(29, 26)
4242 #define PHY_PORT_CS1_LINK_STATE_SHIFT 26
4343
44−#define ICM_TIMEOUT 5000 /* ms */
44+#define ICM_TIMEOUT 5000 /* ms */
45+#define ICM_APPROVE_TIMEOUT 10000 /* ms */
4546 #define ICM_MAX_LINK 4
4647 #define ICM_MAX_DEPTH 6
4748
@@ -55,9 +56,11 @@ · 7 unmodified lines
5556 * @vnd_cap: Vendor defined capability where PCIe2CIO mailbox resides
5657 * (only set when @upstream_port is not %NULL)
5758 * @safe_mode: ICM is in safe mode
59+ * @max_boot_acl: Maximum number of preboot ACL entries (%0 if not supported)
5860 * @is_supported: Checks if we can support ICM on this controller
5961 * @get_mode: Read and return the ICM firmware mode (optional)
6062 * @get_route: Find a route string for given switch
63+ * @driver_ready: Send driver ready message to ICM
6164 * @device_connected: Handle device connected ICM message
6265 * @device_disconnected: Handle device disconnected ICM message
6366 * @xdomain_connected - Handle XDomain connected ICM message
@@ -67,11 +70,15 @@ struct icm { · 3 unmodified lines
6770 struct mutex request_lock;
6871 struct delayed_work rescan_work;
6972 struct pci_dev *upstream_port;
73+ size_t max_boot_acl;
7074 int vnd_cap;
7175 bool safe_mode;
7276 bool (*is_supported)(struct tb *tb);
7377 int (*get_mode)(struct tb *tb);
7478 int (*get_route)(struct tb *tb, u8 link, u8 depth, u64 *route);
79+ int (*driver_ready)(struct tb *tb,
80+ enum tb_security_level *security_level,
81+ size_t *nboot_acl);
7582 void (*device_connected)(struct tb *tb,
7683 const struct icm_pkg_header *hdr);
7784 void (*device_disconnected)(struct tb *tb,
@@ -111,6 +118,12 @@ static inline u64 get_route(u32 route_hi, u32 route_lo) · 33 unmodified lines
111118 return (u64)route_hi << 32 | route_lo;
112119 }
113120
121+static inline u64 get_parent_route(u64 route)
122+{
123+ int depth = tb_route_length(route);
124+ return depth ? route & ~(0xffULL << (depth - 1) * TB_ROUTE_SHIFT) : 0;
125+}
126+
114127 static bool icm_match(const struct tb_cfg_request *req,
115128 const struct ctl_pkg *pkg)
116129 {
@@ -245,6 +258,28 @@ err_free: · 128 unmodified lines
245258 return ret;
246259 }
247260
261+static int
262+icm_fr_driver_ready(struct tb *tb, enum tb_security_level *security_level,
263+ size_t *nboot_acl)
264+{
265+ struct icm_fr_pkg_driver_ready_response reply;
266+ struct icm_pkg_driver_ready request = {
267+ .hdr.code = ICM_DRIVER_READY,
268+ };
269+ int ret;
270+
271+ memset(&reply, 0, sizeof(reply));
272+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
273+ 1, ICM_TIMEOUT);
274+ if (ret)
275+ return ret;
276+
277+ if (security_level)
278+ *security_level = reply.security_level & ICM_FR_SLEVEL_MASK;
279+
280+ return 0;
281+}
282+
248283 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw)
249284 {
250285 struct icm_fr_pkg_approve_device request;
@@ -260,7 +295,7 @@ static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) · 9 unmodified lines
260295 memset(&reply, 0, sizeof(reply));
261296 /* Use larger timeout as establishing tunnels can take some time */
262297 ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
263− 1, 10000);
298+ 1, ICM_APPROVE_TIMEOUT);
264299 if (ret)
265300 return ret;
266301
@@ -374,6 +409,59 @@ static int icm_fr_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd) · 107 unmodified lines
374409 return 0;
375410 }
376411
412+static void add_switch(struct tb_switch *parent_sw, u64 route,
413+ const uuid_t *uuid, u8 connection_id, u8 connection_key,
414+ u8 link, u8 depth, enum tb_security_level security_level,
415+ bool authorized, bool boot)
416+{
417+ struct tb_switch *sw;
418+
419+ sw = tb_switch_alloc(parent_sw->tb, &parent_sw->dev, route);
420+ if (!sw)
421+ return;
422+
423+ sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL);
424+ sw->connection_id = connection_id;
425+ sw->connection_key = connection_key;
426+ sw->link = link;
427+ sw->depth = depth;
428+ sw->authorized = authorized;
429+ sw->security_level = security_level;
430+ sw->boot = boot;
431+
432+ /* Link the two switches now */
433+ tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw);
434+ tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw);
435+
436+ if (tb_switch_add(sw)) {
437+ tb_port_at(tb_route(sw), parent_sw)->remote = NULL;
438+ tb_switch_put(sw);
439+ return;
440+ }
441+}
442+
443+static void update_switch(struct tb_switch *parent_sw, struct tb_switch *sw,
444+ u64 route, u8 connection_id, u8 connection_key,
445+ u8 link, u8 depth, bool boot)
446+{
447+ /* Disconnect from parent */
448+ tb_port_at(tb_route(sw), parent_sw)->remote = NULL;
449+ /* Re-connect via updated port*/
450+ tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw);
451+
452+ /* Update with the new addressing information */
453+ sw->config.route_hi = upper_32_bits(route);
454+ sw->config.route_lo = lower_32_bits(route);
455+ sw->connection_id = connection_id;
456+ sw->connection_key = connection_key;
457+ sw->link = link;
458+ sw->depth = depth;
459+ sw->boot = boot;
460+
461+ /* This switch still exists */
462+ sw->is_unplugged = false;
463+}
464+
377465 static void remove_switch(struct tb_switch *sw)
378466 {
379467 struct tb_switch *parent_sw;
@@ -383,15 +471,52 @@ static void remove_switch(struct tb_switch *sw) · 3 unmodified lines
383471 tb_switch_remove(sw);
384472 }
385473
474+static void add_xdomain(struct tb_switch *sw, u64 route,
475+ const uuid_t *local_uuid, const uuid_t *remote_uuid,
476+ u8 link, u8 depth)
477+{
478+ struct tb_xdomain *xd;
479+
480+ xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid);
481+ if (!xd)
482+ return;
483+
484+ xd->link = link;
485+ xd->depth = depth;
486+
487+ tb_port_at(route, sw)->xdomain = xd;
488+
489+ tb_xdomain_add(xd);
490+}
491+
492+static void update_xdomain(struct tb_xdomain *xd, u64 route, u8 link)
493+{
494+ xd->link = link;
495+ xd->route = route;
496+ xd->is_unplugged = false;
497+}
498+
499+static void remove_xdomain(struct tb_xdomain *xd)
500+{
501+ struct tb_switch *sw;
502+
503+ sw = tb_to_switch(xd->dev.parent);
504+ tb_port_at(xd->route, sw)->xdomain = NULL;
505+ tb_xdomain_remove(xd);
506+}
507+
386508 static void
387509 icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr)
388510 {
389511 const struct icm_fr_event_device_connected *pkg =
390512 (const struct icm_fr_event_device_connected *)hdr;
513+ enum tb_security_level security_level;
391514 struct tb_switch *sw, *parent_sw;
392515 struct icm *icm = tb_priv(tb);
393516 bool authorized = false;
517+ struct tb_xdomain *xd;
394518 u8 link, depth;
519+ bool boot;
395520 u64 route;
396521 int ret;
397522
@@ -399,6 +524,15 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 1 unmodified line
399524 depth = (pkg->link_info & ICM_LINK_INFO_DEPTH_MASK) >>
400525 ICM_LINK_INFO_DEPTH_SHIFT;
401526 authorized = pkg->link_info & ICM_LINK_INFO_APPROVED;
527+ security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >>
528+ ICM_FLAGS_SLEVEL_SHIFT;
529+ boot = pkg->link_info & ICM_LINK_INFO_BOOT;
530+
531+ if (pkg->link_info & ICM_LINK_INFO_REJECTED) {
532+ tb_info(tb, "switch at %u.%u was rejected by ICM firmware because topology limit exceeded\n",
533+ link, depth);
534+ return;
535+ }
402536
403537 ret = icm->get_route(tb, link, depth, &route);
404538 if (ret) {
@@ -425,16 +559,8 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 20 unmodified lines
425559 */
426560 if (sw->depth == depth && sw_phy_port == phy_port &&
427561 !!sw->authorized == authorized) {
428− tb_port_at(tb_route(sw), parent_sw)->remote = NULL;
429− tb_port_at(route, parent_sw)->remote =
430− tb_upstream_port(sw);
431− sw->config.route_hi = upper_32_bits(route);
432− sw->config.route_lo = lower_32_bits(route);
433− sw->connection_id = pkg->connection_id;
434− sw->connection_key = pkg->connection_key;
435− sw->link = link;
436− sw->depth = depth;
437− sw->is_unplugged = false;
562+ update_switch(parent_sw, sw, route, pkg->connection_id,
563+ pkg->connection_key, link, depth, boot);
438564 tb_switch_put(sw);
439565 return;
440566 }
@@ -467,6 +593,13 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 26 unmodified lines
467593 tb_switch_put(sw);
468594 }
469595
596+ /* Remove existing XDomain connection if found */
597+ xd = tb_xdomain_find_by_link_depth(tb, link, depth);
598+ if (xd) {
599+ remove_xdomain(xd);
600+ tb_xdomain_put(xd);
601+ }
602+
470603 parent_sw = tb_switch_find_by_link_depth(tb, link, depth - 1);
471604 if (!parent_sw) {
472605 tb_err(tb, "failed to find parent switch for %u.%u\n",
@@ -474,30 +607,10 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 1 unmodified line
474607 return;
475608 }
476609
477− sw = tb_switch_alloc(tb, &parent_sw->dev, route);
478− if (!sw) {
479− tb_switch_put(parent_sw);
480− return;
481− }
482−
483− sw->uuid = kmemdup(&pkg->ep_uuid, sizeof(pkg->ep_uuid), GFP_KERNEL);
484− sw->connection_id = pkg->connection_id;
485− sw->connection_key = pkg->connection_key;
486− sw->link = link;
487− sw->depth = depth;
488− sw->authorized = authorized;
489− sw->security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >>
490− ICM_FLAGS_SLEVEL_SHIFT;
491−
492− /* Link the two switches now */
493− tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw);
494− tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw);
610+ add_switch(parent_sw, route, &pkg->ep_uuid, pkg->connection_id,
611+ pkg->connection_key, link, depth, security_level,
612+ authorized, boot);
495613
496− ret = tb_switch_add(sw);
497− if (ret) {
498− tb_port_at(tb_route(sw), parent_sw)->remote = NULL;
499− tb_switch_put(sw);
500− }
501614 tb_switch_put(parent_sw);
502615 }
503616
@@ -529,15 +642,6 @@ icm_fr_device_disconnected(struct tb *tb, const struct icm_pkg_header *hdr) · 25 unmodified lines
529642 tb_switch_put(sw);
530643 }
531644
532−static void remove_xdomain(struct tb_xdomain *xd)
533−{
534− struct tb_switch *sw;
535−
536− sw = tb_to_switch(xd->dev.parent);
537− tb_port_at(xd->route, sw)->xdomain = NULL;
538− tb_xdomain_remove(xd);
539−}
540−
541645 static void
542646 icm_fr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr)
543647 {
@@ -577,9 +681,7 @@ icm_fr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 33 unmodified lines
577681 phy_port = phy_port_from_route(route, depth);
578682
579683 if (xd->depth == depth && xd_phy_port == phy_port) {
580− xd->link = link;
581− xd->route = route;
582− xd->is_unplugged = false;
684+ update_xdomain(xd, route, link);
583685 tb_xdomain_put(xd);
584686 return;
585687 }
@@ -629,19 +731,8 @@ icm_fr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 43 unmodified lines
629731 return;
630732 }
631733
632− xd = tb_xdomain_alloc(sw->tb, &sw->dev, route,
633− &pkg->local_uuid, &pkg->remote_uuid);
634− if (!xd) {
635− tb_switch_put(sw);
636− return;
637− }
638−
639− xd->link = link;
640− xd->depth = depth;
641−
642− tb_port_at(route, sw)->xdomain = xd;
643−
644− tb_xdomain_add(xd);
734+ add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link,
735+ depth);
645736 tb_switch_put(sw);
646737 }
647738
@@ -664,6 +755,351 @@ icm_fr_xdomain_disconnected(struct tb *tb, const struct icm_pkg_header *hdr) · 16 unmodified lines
664755 }
665756 }
666757
758+static int
759+icm_tr_driver_ready(struct tb *tb, enum tb_security_level *security_level,
760+ size_t *nboot_acl)
761+{
762+ struct icm_tr_pkg_driver_ready_response reply;
763+ struct icm_pkg_driver_ready request = {
764+ .hdr.code = ICM_DRIVER_READY,
765+ };
766+ int ret;
767+
768+ memset(&reply, 0, sizeof(reply));
769+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
770+ 1, 20000);
771+ if (ret)
772+ return ret;
773+
774+ if (security_level)
775+ *security_level = reply.info & ICM_TR_INFO_SLEVEL_MASK;
776+ if (nboot_acl)
777+ *nboot_acl = (reply.info & ICM_TR_INFO_BOOT_ACL_MASK) >>
778+ ICM_TR_INFO_BOOT_ACL_SHIFT;
779+ return 0;
780+}
781+
782+static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw)
783+{
784+ struct icm_tr_pkg_approve_device request;
785+ struct icm_tr_pkg_approve_device reply;
786+ int ret;
787+
788+ memset(&request, 0, sizeof(request));
789+ memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid));
790+ request.hdr.code = ICM_APPROVE_DEVICE;
791+ request.route_lo = sw->config.route_lo;
792+ request.route_hi = sw->config.route_hi;
793+ request.connection_id = sw->connection_id;
794+
795+ memset(&reply, 0, sizeof(reply));
796+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
797+ 1, ICM_APPROVE_TIMEOUT);
798+ if (ret)
799+ return ret;
800+
801+ if (reply.hdr.flags & ICM_FLAGS_ERROR) {
802+ tb_warn(tb, "PCIe tunnel creation failed\n");
803+ return -EIO;
804+ }
805+
806+ return 0;
807+}
808+
809+static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw)
810+{
811+ struct icm_tr_pkg_add_device_key_response reply;
812+ struct icm_tr_pkg_add_device_key request;
813+ int ret;
814+
815+ memset(&request, 0, sizeof(request));
816+ memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid));
817+ request.hdr.code = ICM_ADD_DEVICE_KEY;
818+ request.route_lo = sw->config.route_lo;
819+ request.route_hi = sw->config.route_hi;
820+ request.connection_id = sw->connection_id;
821+ memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE);
822+
823+ memset(&reply, 0, sizeof(reply));
824+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
825+ 1, ICM_TIMEOUT);
826+ if (ret)
827+ return ret;
828+
829+ if (reply.hdr.flags & ICM_FLAGS_ERROR) {
830+ tb_warn(tb, "Adding key to switch failed\n");
831+ return -EIO;
832+ }
833+
834+ return 0;
835+}
836+
837+static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw,
838+ const u8 *challenge, u8 *response)
839+{
840+ struct icm_tr_pkg_challenge_device_response reply;
841+ struct icm_tr_pkg_challenge_device request;
842+ int ret;
843+
844+ memset(&request, 0, sizeof(request));
845+ memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid));
846+ request.hdr.code = ICM_CHALLENGE_DEVICE;
847+ request.route_lo = sw->config.route_lo;
848+ request.route_hi = sw->config.route_hi;
849+ request.connection_id = sw->connection_id;
850+ memcpy(request.challenge, challenge, TB_SWITCH_KEY_SIZE);
851+
852+ memset(&reply, 0, sizeof(reply));
853+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
854+ 1, ICM_TIMEOUT);
855+ if (ret)
856+ return ret;
857+
858+ if (reply.hdr.flags & ICM_FLAGS_ERROR)
859+ return -EKEYREJECTED;
860+ if (reply.hdr.flags & ICM_FLAGS_NO_KEY)
861+ return -ENOKEY;
862+
863+ memcpy(response, reply.response, TB_SWITCH_KEY_SIZE);
864+
865+ return 0;
866+}
867+
868+static int icm_tr_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd)
869+{
870+ struct icm_tr_pkg_approve_xdomain_response reply;
871+ struct icm_tr_pkg_approve_xdomain request;
872+ int ret;
873+
874+ memset(&request, 0, sizeof(request));
875+ request.hdr.code = ICM_APPROVE_XDOMAIN;
876+ request.route_hi = upper_32_bits(xd->route);
877+ request.route_lo = lower_32_bits(xd->route);
878+ request.transmit_path = xd->transmit_path;
879+ request.transmit_ring = xd->transmit_ring;
880+ request.receive_path = xd->receive_path;
881+ request.receive_ring = xd->receive_ring;
882+ memcpy(&request.remote_uuid, xd->remote_uuid, sizeof(*xd->remote_uuid));
883+
884+ memset(&reply, 0, sizeof(reply));
885+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
886+ 1, ICM_TIMEOUT);
887+ if (ret)
888+ return ret;
889+
890+ if (reply.hdr.flags & ICM_FLAGS_ERROR)
891+ return -EIO;
892+
893+ return 0;
894+}
895+
896+static int icm_tr_xdomain_tear_down(struct tb *tb, struct tb_xdomain *xd,
897+ int stage)
898+{
899+ struct icm_tr_pkg_disconnect_xdomain_response reply;
900+ struct icm_tr_pkg_disconnect_xdomain request;
901+ int ret;
902+
903+ memset(&request, 0, sizeof(request));
904+ request.hdr.code = ICM_DISCONNECT_XDOMAIN;
905+ request.stage = stage;
906+ request.route_hi = upper_32_bits(xd->route);
907+ request.route_lo = lower_32_bits(xd->route);
908+ memcpy(&request.remote_uuid, xd->remote_uuid, sizeof(*xd->remote_uuid));
909+
910+ memset(&reply, 0, sizeof(reply));
911+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
912+ 1, ICM_TIMEOUT);
913+ if (ret)
914+ return ret;
915+
916+ if (reply.hdr.flags & ICM_FLAGS_ERROR)
917+ return -EIO;
918+
919+ return 0;
920+}
921+
922+static int icm_tr_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd)
923+{
924+ int ret;
925+
926+ ret = icm_tr_xdomain_tear_down(tb, xd, 1);
927+ if (ret)
928+ return ret;
929+
930+ usleep_range(10, 50);
931+ return icm_tr_xdomain_tear_down(tb, xd, 2);
932+}
933+
934+static void
935+icm_tr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr)
936+{
937+ const struct icm_tr_event_device_connected *pkg =
938+ (const struct icm_tr_event_device_connected *)hdr;
939+ enum tb_security_level security_level;
940+ struct tb_switch *sw, *parent_sw;
941+ struct tb_xdomain *xd;
942+ bool authorized, boot;
943+ u64 route;
944+
945+ /*
946+ * Currently we don't use the QoS information coming with the
947+ * device connected message so simply just ignore that extra
948+ * packet for now.
949+ */
950+ if (pkg->hdr.packet_id)
951+ return;
952+
953+ /*
954+ * After NVM upgrade adding root switch device fails because we
955+ * initiated reset. During that time ICM might still send device
956+ * connected message which we ignore here.
957+ */
958+ if (!tb->root_switch)
959+ return;
960+
961+ route = get_route(pkg->route_hi, pkg->route_lo);
962+ authorized = pkg->link_info & ICM_LINK_INFO_APPROVED;
963+ security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >>
964+ ICM_FLAGS_SLEVEL_SHIFT;
965+ boot = pkg->link_info & ICM_LINK_INFO_BOOT;
966+
967+ if (pkg->link_info & ICM_LINK_INFO_REJECTED) {
968+ tb_info(tb, "switch at %llx was rejected by ICM firmware because topology limit exceeded\n",
969+ route);
970+ return;
971+ }
972+
973+ sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid);
974+ if (sw) {
975+ /* Update the switch if it is still in the same place */
976+ if (tb_route(sw) == route && !!sw->authorized == authorized) {
977+ parent_sw = tb_to_switch(sw->dev.parent);
978+ update_switch(parent_sw, sw, route, pkg->connection_id,
979+ 0, 0, 0, boot);
980+ tb_switch_put(sw);
981+ return;
982+ }
983+
984+ remove_switch(sw);
985+ tb_switch_put(sw);
986+ }
987+
988+ /* Another switch with the same address */
989+ sw = tb_switch_find_by_route(tb, route);
990+ if (sw) {
991+ remove_switch(sw);
992+ tb_switch_put(sw);
993+ }
994+
995+ /* XDomain connection with the same address */
996+ xd = tb_xdomain_find_by_route(tb, route);
997+ if (xd) {
998+ remove_xdomain(xd);
999+ tb_xdomain_put(xd);
1000+ }
1001+
1002+ parent_sw = tb_switch_find_by_route(tb, get_parent_route(route));
1003+ if (!parent_sw) {
1004+ tb_err(tb, "failed to find parent switch for %llx\n", route);
1005+ return;
1006+ }
1007+
1008+ add_switch(parent_sw, route, &pkg->ep_uuid, pkg->connection_id,
1009+ 0, 0, 0, security_level, authorized, boot);
1010+
1011+ tb_switch_put(parent_sw);
1012+}
1013+
1014+static void
1015+icm_tr_device_disconnected(struct tb *tb, const struct icm_pkg_header *hdr)
1016+{
1017+ const struct icm_tr_event_device_disconnected *pkg =
1018+ (const struct icm_tr_event_device_disconnected *)hdr;
1019+ struct tb_switch *sw;
1020+ u64 route;
1021+
1022+ route = get_route(pkg->route_hi, pkg->route_lo);
1023+
1024+ sw = tb_switch_find_by_route(tb, route);
1025+ if (!sw) {
1026+ tb_warn(tb, "no switch exists at %llx, ignoring\n", route);
1027+ return;
1028+ }
1029+
1030+ remove_switch(sw);
1031+ tb_switch_put(sw);
1032+}
1033+
1034+static void
1035+icm_tr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr)
1036+{
1037+ const struct icm_tr_event_xdomain_connected *pkg =
1038+ (const struct icm_tr_event_xdomain_connected *)hdr;
1039+ struct tb_xdomain *xd;
1040+ struct tb_switch *sw;
1041+ u64 route;
1042+
1043+ if (!tb->root_switch)
1044+ return;
1045+
1046+ route = get_route(pkg->local_route_hi, pkg->local_route_lo);
1047+
1048+ xd = tb_xdomain_find_by_uuid(tb, &pkg->remote_uuid);
1049+ if (xd) {
1050+ if (xd->route == route) {
1051+ update_xdomain(xd, route, 0);
1052+ tb_xdomain_put(xd);
1053+ return;
1054+ }
1055+
1056+ remove_xdomain(xd);
1057+ tb_xdomain_put(xd);
1058+ }
1059+
1060+ /* An existing xdomain with the same address */
1061+ xd = tb_xdomain_find_by_route(tb, route);
1062+ if (xd) {
1063+ remove_xdomain(xd);
1064+ tb_xdomain_put(xd);
1065+ }
1066+
1067+ /*
1068+ * If the user disconnected a switch during suspend and
1069+ * connected another host to the same port, remove the switch
1070+ * first.
1071+ */
1072+ sw = get_switch_at_route(tb->root_switch, route);
1073+ if (sw)
1074+ remove_switch(sw);
1075+
1076+ sw = tb_switch_find_by_route(tb, get_parent_route(route));
1077+ if (!sw) {
1078+ tb_warn(tb, "no switch exists at %llx, ignoring\n", route);
1079+ return;
1080+ }
1081+
1082+ add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0);
1083+ tb_switch_put(sw);
1084+}
1085+
1086+static void
1087+icm_tr_xdomain_disconnected(struct tb *tb, const struct icm_pkg_header *hdr)
1088+{
1089+ const struct icm_tr_event_xdomain_disconnected *pkg =
1090+ (const struct icm_tr_event_xdomain_disconnected *)hdr;
1091+ struct tb_xdomain *xd;
1092+ u64 route;
1093+
1094+ route = get_route(pkg->route_hi, pkg->route_lo);
1095+
1096+ xd = tb_xdomain_find_by_route(tb, route);
1097+ if (xd) {
1098+ remove_xdomain(xd);
1099+ tb_xdomain_put(xd);
1100+ }
1101+}
1102+
6671103 static struct pci_dev *get_upstream_port(struct pci_dev *pdev)
6681104 {
6691105 struct pci_dev *parent;
@@ -728,14 +1164,14 @@ static bool icm_ar_is_supported(struct tb *tb) · 58 unmodified lines
7281164 static int icm_ar_get_mode(struct tb *tb)
7291165 {
7301166 struct tb_nhi *nhi = tb->nhi;
731− int retries = 5;
1167+ int retries = 60;
7321168 u32 val;
7331169
7341170 do {
7351171 val = ioread32(nhi->iobase + REG_FW_STS);
7361172 if (val & REG_FW_STS_NVM_AUTH_DONE)
7371173 break;
738− msleep(30);
1174+ msleep(50);
7391175 } while (--retries);
7401176
7411177 if (!retries) {
@@ -746,6 +1182,30 @@ static int icm_ar_get_mode(struct tb *tb) · 4 unmodified lines
7461182 return nhi_mailbox_mode(nhi);
7471183 }
7481184
1185+static int
1186+icm_ar_driver_ready(struct tb *tb, enum tb_security_level *security_level,
1187+ size_t *nboot_acl)
1188+{
1189+ struct icm_ar_pkg_driver_ready_response reply;
1190+ struct icm_pkg_driver_ready request = {
1191+ .hdr.code = ICM_DRIVER_READY,
1192+ };
1193+ int ret;
1194+
1195+ memset(&reply, 0, sizeof(reply));
1196+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1197+ 1, ICM_TIMEOUT);
1198+ if (ret)
1199+ return ret;
1200+
1201+ if (security_level)
1202+ *security_level = reply.info & ICM_AR_INFO_SLEVEL_MASK;
1203+ if (nboot_acl && (reply.info & ICM_AR_INFO_BOOT_ACL_SUPPORTED))
1204+ *nboot_acl = (reply.info & ICM_AR_INFO_BOOT_ACL_MASK) >>
1205+ ICM_AR_INFO_BOOT_ACL_SHIFT;
1206+ return 0;
1207+}
1208+
7491209 static int icm_ar_get_route(struct tb *tb, u8 link, u8 depth, u64 *route)
7501210 {
7511211 struct icm_ar_pkg_get_route_response reply;
@@ -768,6 +1228,87 @@ static int icm_ar_get_route(struct tb *tb, u8 link, u8 depth, u64 *route) · 16 unmodified lines
7681228 return 0;
7691229 }
7701230
1231+static int icm_ar_get_boot_acl(struct tb *tb, uuid_t *uuids, size_t nuuids)
1232+{
1233+ struct icm_ar_pkg_preboot_acl_response reply;
1234+ struct icm_ar_pkg_preboot_acl request = {
1235+ .hdr = { .code = ICM_PREBOOT_ACL },
1236+ };
1237+ int ret, i;
1238+
1239+ memset(&reply, 0, sizeof(reply));
1240+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1241+ 1, ICM_TIMEOUT);
1242+ if (ret)
1243+ return ret;
1244+
1245+ if (reply.hdr.flags & ICM_FLAGS_ERROR)
1246+ return -EIO;
1247+
1248+ for (i = 0; i < nuuids; i++) {
1249+ u32 *uuid = (u32 *)&uuids[i];
1250+
1251+ uuid[0] = reply.acl[i].uuid_lo;
1252+ uuid[1] = reply.acl[i].uuid_hi;
1253+
1254+ if (uuid[0] == 0xffffffff && uuid[1] == 0xffffffff) {
1255+ /* Map empty entries to null UUID */
1256+ uuid[0] = 0;
1257+ uuid[1] = 0;
1258+ } else {
1259+ /* Upper two DWs are always one's */
1260+ uuid[2] = 0xffffffff;
1261+ uuid[3] = 0xffffffff;
1262+ }
1263+ }
1264+
1265+ return ret;
1266+}
1267+
1268+static int icm_ar_set_boot_acl(struct tb *tb, const uuid_t *uuids,
1269+ size_t nuuids)
1270+{
1271+ struct icm_ar_pkg_preboot_acl_response reply;
1272+ struct icm_ar_pkg_preboot_acl request = {
1273+ .hdr = {
1274+ .code = ICM_PREBOOT_ACL,
1275+ .flags = ICM_FLAGS_WRITE,
1276+ },
1277+ };
1278+ int ret, i;
1279+
1280+ for (i = 0; i < nuuids; i++) {
1281+ const u32 *uuid = (const u32 *)&uuids[i];
1282+
1283+ if (uuid_is_null(&uuids[i])) {
1284+ /*
1285+ * Map null UUID to the empty (all one) entries
1286+ * for ICM.
1287+ */
1288+ request.acl[i].uuid_lo = 0xffffffff;
1289+ request.acl[i].uuid_hi = 0xffffffff;
1290+ } else {
1291+ /* Two high DWs need to be set to all one */
1292+ if (uuid[2] != 0xffffffff || uuid[3] != 0xffffffff)
1293+ return -EINVAL;
1294+
1295+ request.acl[i].uuid_lo = uuid[0];
1296+ request.acl[i].uuid_hi = uuid[1];
1297+ }
1298+ }
1299+
1300+ memset(&reply, 0, sizeof(reply));
1301+ ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
1302+ 1, ICM_TIMEOUT);
1303+ if (ret)
1304+ return ret;
1305+
1306+ if (reply.hdr.flags & ICM_FLAGS_ERROR)
1307+ return -EIO;
1308+
1309+ return 0;
1310+}
1311+
7711312 static void icm_handle_notification(struct work_struct *work)
7721313 {
7731314 struct icm_notification *n = container_of(work, typeof(*n), work);
@@ -814,23 +1355,18 @@ static void icm_handle_event(struct tb *tb, enum tb_cfg_pkg_type type, · 40 unmodified lines
8141355 }
8151356
8161357 static int
817−__icm_driver_ready(struct tb *tb, enum tb_security_level *security_level)
1358+__icm_driver_ready(struct tb *tb, enum tb_security_level *security_level,
1359+ size_t *nboot_acl)
8181360 {
819− struct icm_pkg_driver_ready_response reply;
820− struct icm_pkg_driver_ready request = {
821− .hdr.code = ICM_DRIVER_READY,
822− };
823− unsigned int retries = 10;
1361+ struct icm *icm = tb_priv(tb);
1362+ unsigned int retries = 50;
8241363 int ret;
8251364
826− memset(&reply, 0, sizeof(reply));
827− ret = icm_request(tb, &request, sizeof(request), &reply, sizeof(reply),
828− 1, ICM_TIMEOUT);
829− if (ret)
1365+ ret = icm->driver_ready(tb, security_level, nboot_acl);
1366+ if (ret) {
1367+ tb_err(tb, "failed to send driver ready to ICM\n");
8301368 return ret;
831−
832− if (security_level)
833− *security_level = reply.security_level & 0xf;
1369+ }
8341370
8351371 /*
8361372 * Hold on here until the switch config space is accessible so
@@ -848,6 +1384,7 @@ __icm_driver_ready(struct tb *tb, enum tb_security_level *security_level) · 11 unmodified lines
8481384 msleep(50);
8491385 } while (--retries);
8501386
1387+ tb_err(tb, "failed to read root switch config space, giving up\n");
8511388 return -ETIMEDOUT;
8521389 }
8531390
@@ -915,6 +1452,9 @@ static int icm_firmware_reset(struct tb *tb, struct tb_nhi *nhi) · 61 unmodified lines
9151452 struct icm *icm = tb_priv(tb);
9161453 u32 val;
9171454
1455+ if (!icm->upstream_port)
1456+ return -ENODEV;
1457+
9181458 /* Put ARC to wait for CIO reset event to happen */
9191459 val = ioread32(nhi->iobase + REG_FW_STS);
9201460 val |= REG_FW_STS_CIO_RESET_REQ;
@@ -1054,6 +1594,9 @@ static int icm_firmware_init(struct tb *tb) · 133 unmodified lines
10541594 break;
10551595
10561596 default:
1597+ if (ret < 0)
1598+ return ret;
1599+
10571600 tb_err(tb, "ICM firmware is in wrong mode: %u\n", ret);
10581601 return -ENODEV;
10591602 }
@@ -1089,7 +1632,18 @@ static int icm_driver_ready(struct tb *tb) · 29 unmodified lines
10891632 return 0;
10901633 }
10911634
1092− return __icm_driver_ready(tb, &tb->security_level);
1635+ ret = __icm_driver_ready(tb, &tb->security_level, &tb->nboot_acl);
1636+ if (ret)
1637+ return ret;
1638+
1639+ /*
1640+ * Make sure the number of supported preboot ACL matches what we
1641+ * expect or disable the whole feature.
1642+ */
1643+ if (tb->nboot_acl > icm->max_boot_acl)
1644+ tb->nboot_acl = 0;
1645+
1646+ return 0;
10931647 }
10941648
10951649 static int icm_suspend(struct tb *tb)
@@ -1185,7 +1739,7 @@ static void icm_complete(struct tb *tb) · 89 unmodified lines
11851739 * Now all existing children should be resumed, start events
11861740 * from ICM to get updated status.
11871741 */
1188− __icm_driver_ready(tb, NULL);
1742+ __icm_driver_ready(tb, NULL, NULL);
11891743
11901744 /*
11911745 * We do not get notifications of devices that have been
@@ -1238,7 +1792,7 @@ static int icm_disconnect_pcie_paths(struct tb *tb) · 46 unmodified lines
12381792 return nhi_mailbox_cmd(tb->nhi, NHI_MAILBOX_DISCONNECT_PCIE_PATHS, 0);
12391793 }
12401794
1241−/* Falcon Ridge and Alpine Ridge */
1795+/* Falcon Ridge */
12421796 static const struct tb_cm_ops icm_fr_ops = {
12431797 .driver_ready = icm_driver_ready,
12441798 .start = icm_start,
@@ -1254,6 +1808,42 @@ static const struct tb_cm_ops icm_fr_ops = { · 9 unmodified lines
12541808 .disconnect_xdomain_paths = icm_fr_disconnect_xdomain_paths,
12551809 };
12561810
1811+/* Alpine Ridge */
1812+static const struct tb_cm_ops icm_ar_ops = {
1813+ .driver_ready = icm_driver_ready,
1814+ .start = icm_start,
1815+ .stop = icm_stop,
1816+ .suspend = icm_suspend,
1817+ .complete = icm_complete,
1818+ .handle_event = icm_handle_event,
1819+ .get_boot_acl = icm_ar_get_boot_acl,
1820+ .set_boot_acl = icm_ar_set_boot_acl,
1821+ .approve_switch = icm_fr_approve_switch,
1822+ .add_switch_key = icm_fr_add_switch_key,
1823+ .challenge_switch_key = icm_fr_challenge_switch_key,
1824+ .disconnect_pcie_paths = icm_disconnect_pcie_paths,
1825+ .approve_xdomain_paths = icm_fr_approve_xdomain_paths,
1826+ .disconnect_xdomain_paths = icm_fr_disconnect_xdomain_paths,
1827+};
1828+
1829+/* Titan Ridge */
1830+static const struct tb_cm_ops icm_tr_ops = {
1831+ .driver_ready = icm_driver_ready,
1832+ .start = icm_start,
1833+ .stop = icm_stop,
1834+ .suspend = icm_suspend,
1835+ .complete = icm_complete,
1836+ .handle_event = icm_handle_event,
1837+ .get_boot_acl = icm_ar_get_boot_acl,
1838+ .set_boot_acl = icm_ar_set_boot_acl,
1839+ .approve_switch = icm_tr_approve_switch,
1840+ .add_switch_key = icm_tr_add_switch_key,
1841+ .challenge_switch_key = icm_tr_challenge_switch_key,
1842+ .disconnect_pcie_paths = icm_disconnect_pcie_paths,
1843+ .approve_xdomain_paths = icm_tr_approve_xdomain_paths,
1844+ .disconnect_xdomain_paths = icm_tr_disconnect_xdomain_paths,
1845+};
1846+
12571847 struct tb *icm_probe(struct tb_nhi *nhi)
12581848 {
12591849 struct icm *icm;
@@ -1272,6 +1862,7 @@ struct tb *icm_probe(struct tb_nhi *nhi) · 12 unmodified lines
12721862 case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
12731863 icm->is_supported = icm_fr_is_supported;
12741864 icm->get_route = icm_fr_get_route;
1865+ icm->driver_ready = icm_fr_driver_ready;
12751866 icm->device_connected = icm_fr_device_connected;
12761867 icm->device_disconnected = icm_fr_device_disconnected;
12771868 icm->xdomain_connected = icm_fr_xdomain_connected;
@@ -1284,14 +1875,29 @@ struct tb *icm_probe(struct tb_nhi *nhi) · 6 unmodified lines
12841875 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_NHI:
12851876 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_NHI:
12861877 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_NHI:
1878+ icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
12871879 icm->is_supported = icm_ar_is_supported;
12881880 icm->get_mode = icm_ar_get_mode;
12891881 icm->get_route = icm_ar_get_route;
1882+ icm->driver_ready = icm_ar_driver_ready;
12901883 icm->device_connected = icm_fr_device_connected;
12911884 icm->device_disconnected = icm_fr_device_disconnected;
12921885 icm->xdomain_connected = icm_fr_xdomain_connected;
12931886 icm->xdomain_disconnected = icm_fr_xdomain_disconnected;
1294− tb->cm_ops = &icm_fr_ops;
1887+ tb->cm_ops = &icm_ar_ops;
1888+ break;
1889+
1890+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
1891+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
1892+ icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
1893+ icm->is_supported = icm_ar_is_supported;
1894+ icm->get_mode = icm_ar_get_mode;
1895+ icm->driver_ready = icm_tr_driver_ready;
1896+ icm->device_connected = icm_tr_device_connected;
1897+ icm->device_disconnected = icm_tr_device_disconnected;
1898+ icm->xdomain_connected = icm_tr_xdomain_connected;
1899+ icm->xdomain_disconnected = icm_tr_xdomain_disconnected;
1900+ tb->cm_ops = &icm_tr_ops;
12951901 break;
12961902 }
12971903
drivers/thunderbolt/nhi.c+4−1
@@ -1036,7 +1036,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 1035 unmodified lines
10361036 */
10371037 tb_domain_put(tb);
10381038 nhi_shutdown(nhi);
1039− return -EIO;
1039+ return res;
10401040 }
10411041 pci_set_drvdata(pdev, tb);
10421042
@@ -1064,6 +1064,7 @@ static const struct dev_pm_ops nhi_pm_ops = { · 21 unmodified lines
10641064 * we just disable hotplug, the
10651065 * pci-tunnels stay alive.
10661066 */
1067+ .thaw_noirq = nhi_resume_noirq,
10671068 .restore_noirq = nhi_resume_noirq,
10681069 .suspend = nhi_suspend,
10691070 .freeze = nhi_suspend,
@@ -1110,6 +1111,8 @@ static struct pci_device_id nhi_ids[] = { · 40 unmodified lines
11101111 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_NHI) },
11111112 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_NHI) },
11121113 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_USBONLY_NHI) },
1114+ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI) },
1115+ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI) },
11131116
11141117 { 0,}
11151118 };
drivers/thunderbolt/nhi.h+5−0
@@ -45,5 +45,10 @@ enum nhi_fw_mode nhi_mailbox_mode(struct tb_nhi *nhi); · 44 unmodified lines
4545 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_USBONLY_NHI 0x15dc
4646 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_USBONLY_NHI 0x15dd
4747 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_USBONLY_NHI 0x15de
48+#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_BRIDGE 0x15e7
49+#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI 0x15e8
50+#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE 0x15ea
51+#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI 0x15eb
52+#define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE 0x15ef
4853
4954 #endif
drivers/thunderbolt/switch.c+60−1
@@ -716,6 +716,13 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) · 715 unmodified lines
716716 if (sw->authorized)
717717 goto unlock;
718718
719+ /*
720+ * Make sure there is no PCIe rescan ongoing when a new PCIe
721+ * tunnel is created. Otherwise the PCIe rescan code might find
722+ * the new tunnel too early.
723+ */
724+ pci_lock_rescan_remove();
725+
719726 switch (val) {
720727 /* Approve switch */
721728 case 1:
@@ -735,6 +742,8 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) · 13 unmodified lines
735742 break;
736743 }
737744
745+ pci_unlock_rescan_remove();
746+
738747 if (!ret) {
739748 sw->authorized = val;
740749 /* Notify status change to the userspace */
@@ -766,6 +775,15 @@ static ssize_t authorized_store(struct device *dev, · 25 unmodified lines
766775 }
767776 static DEVICE_ATTR_RW(authorized);
768777
778+static ssize_t boot_show(struct device *dev, struct device_attribute *attr,
779+ char *buf)
780+{
781+ struct tb_switch *sw = tb_to_switch(dev);
782+
783+ return sprintf(buf, "%u\n", sw->boot);
784+}
785+static DEVICE_ATTR_RO(boot);
786+
769787 static ssize_t device_show(struct device *dev, struct device_attribute *attr,
770788 char *buf)
771789 {
@@ -942,6 +960,7 @@ static DEVICE_ATTR_RO(unique_id); · 170 unmodified lines
942960
943961 static struct attribute *switch_attrs[] = {
944962 &dev_attr_authorized.attr,
963+ &dev_attr_boot.attr,
945964 &dev_attr_device.attr,
946965 &dev_attr_device_name.attr,
947966 &dev_attr_key.attr,
@@ -970,6 +989,10 @@ static umode_t switch_attr_is_visible(struct kobject *kobj, · 22 unmodified lines
970989 if (sw->dma_port)
971990 return attr->mode;
972991 return 0;
992+ } else if (attr == &dev_attr_boot.attr) {
993+ if (tb_route(sw))
994+ return attr->mode;
995+ return 0;
973996 }
974997
975998 return sw->safe_mode ? 0 : attr->mode;
@@ -1028,6 +1051,9 @@ static int tb_switch_get_generation(struct tb_switch *sw) · 52 unmodified lines
10281051 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
10291052 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
10301053 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
1054+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_BRIDGE:
1055+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE:
1056+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE:
10311057 return 3;
10321058
10331059 default:
@@ -1470,6 +1496,7 @@ struct tb_sw_lookup { · 436 unmodified lines
14701496 u8 link;
14711497 u8 depth;
14721498 const uuid_t *uuid;
1499+ u64 route;
14731500 };
14741501
14751502 static int tb_switch_match(struct device *dev, void *data)
@@ -1485,6 +1512,11 @@ static int tb_switch_match(struct device *dev, void *data) · 9 unmodified lines
14851512 if (lookup->uuid)
14861513 return !memcmp(sw->uuid, lookup->uuid, sizeof(*lookup->uuid));
14871514
1515+ if (lookup->route) {
1516+ return sw->config.route_lo == lower_32_bits(lookup->route) &&
1517+ sw->config.route_hi == upper_32_bits(lookup->route);
1518+ }
1519+
14881520 /* Root switch is matched only by depth */
14891521 if (!lookup->depth)
14901522 return !sw->depth;
@@ -1519,7 +1551,7 @@ struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link, u8 depth) · 28 unmodified lines
15191551 }
15201552
15211553 /**
1522− * tb_switch_find_by_link_depth() - Find switch by UUID
1554+ * tb_switch_find_by_uuid() - Find switch by UUID
15231555 * @tb: Domain the switch belongs
15241556 * @uuid: UUID to look for
15251557 *
@@ -1542,6 +1574,33 @@ struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid) · 16 unmodified lines
15421574 return NULL;
15431575 }
15441576
1577+/**
1578+ * tb_switch_find_by_route() - Find switch by route string
1579+ * @tb: Domain the switch belongs
1580+ * @route: Route string to look for
1581+ *
1582+ * Returned switch has reference count increased so the caller needs to
1583+ * call tb_switch_put() when done with the switch.
1584+ */
1585+struct tb_switch *tb_switch_find_by_route(struct tb *tb, u64 route)
1586+{
1587+ struct tb_sw_lookup lookup;
1588+ struct device *dev;
1589+
1590+ if (!route)
1591+ return tb_switch_get(tb->root_switch);
1592+
1593+ memset(&lookup, 0, sizeof(lookup));
1594+ lookup.tb = tb;
1595+ lookup.route = route;
1596+
1597+ dev = bus_find_device(&tb_bus_type, NULL, &lookup, tb_switch_match);
1598+ if (dev)
1599+ return tb_to_switch(dev);
1600+
1601+ return NULL;
1602+}
1603+
15451604 void tb_switch_exit(void)
15461605 {
15471606 ida_destroy(&nvm_ida);
drivers/thunderbolt/tb.h+14−0
@@ -66,6 +66,7 @@ struct tb_switch_nvm { · 65 unmodified lines
6666 * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise)
6767 * @no_nvm_upgrade: Prevent NVM upgrade of this switch
6868 * @safe_mode: The switch is in safe-mode
69+ * @boot: Whether the switch was already authorized on boot or not
6970 * @authorized: Whether the switch is authorized by user or policy
7071 * @work: Work used to automatically authorize a switch
7172 * @security_level: Switch supported security level
@@ -99,6 +100,7 @@ struct tb_switch { · 27 unmodified lines
99100 struct tb_switch_nvm *nvm;
100101 bool no_nvm_upgrade;
101102 bool safe_mode;
103+ bool boot;
102104 unsigned int authorized;
103105 struct work_struct work;
104106 enum tb_security_level security_level;
@@ -198,6 +200,8 @@ struct tb_path { · 93 unmodified lines
198200 * @suspend: Connection manager specific suspend
199201 * @complete: Connection manager specific complete
200202 * @handle_event: Handle thunderbolt event
203+ * @get_boot_acl: Get boot ACL list
204+ * @set_boot_acl: Set boot ACL list
201205 * @approve_switch: Approve switch
202206 * @add_switch_key: Add key to switch
203207 * @challenge_switch_key: Challenge switch using key
@@ -215,6 +219,8 @@ struct tb_cm_ops { · 11 unmodified lines
215219 void (*complete)(struct tb *tb);
216220 void (*handle_event)(struct tb *tb, enum tb_cfg_pkg_type,
217221 const void *buf, size_t size);
222+ int (*get_boot_acl)(struct tb *tb, uuid_t *uuids, size_t nuuids);
223+ int (*set_boot_acl)(struct tb *tb, const uuid_t *uuids, size_t nuuids);
218224 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
219225 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
220226 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
@@ -386,6 +392,14 @@ struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); · 165 unmodified lines
386392 struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link,
387393 u8 depth);
388394 struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid);
395+struct tb_switch *tb_switch_find_by_route(struct tb *tb, u64 route);
396+
397+static inline struct tb_switch *tb_switch_get(struct tb_switch *sw)
398+{
399+ if (sw)
400+ get_device(&sw->dev);
401+ return sw;
402+}
389403
390404 static inline void tb_switch_put(struct tb_switch *sw)
391405 {
drivers/thunderbolt/tb_msgs.h+179−1
@@ -102,6 +102,8 @@ enum icm_pkg_code { · 101 unmodified lines
102102 ICM_ADD_DEVICE_KEY = 0x6,
103103 ICM_GET_ROUTE = 0xa,
104104 ICM_APPROVE_XDOMAIN = 0x10,
105+ ICM_DISCONNECT_XDOMAIN = 0x11,
106+ ICM_PREBOOT_ACL = 0x18,
105107 };
106108
107109 enum icm_event_code {
@@ -122,18 +124,23 @@ struct icm_pkg_header { · 14 unmodified lines
122124 #define ICM_FLAGS_NO_KEY BIT(1)
123125 #define ICM_FLAGS_SLEVEL_SHIFT 3
124126 #define ICM_FLAGS_SLEVEL_MASK GENMASK(4, 3)
127+#define ICM_FLAGS_WRITE BIT(7)
125128
126129 struct icm_pkg_driver_ready {
127130 struct icm_pkg_header hdr;
128131 };
129132
130−struct icm_pkg_driver_ready_response {
133+/* Falcon Ridge only messages */
134+
135+struct icm_fr_pkg_driver_ready_response {
131136 struct icm_pkg_header hdr;
132137 u8 romver;
133138 u8 ramver;
134139 u16 security_level;
135140 };
136141
142+#define ICM_FR_SLEVEL_MASK 0xf
143+
137144 /* Falcon Ridge & Alpine Ridge common messages */
138145
139146 struct icm_fr_pkg_get_topology {
@@ -176,6 +183,8 @@ struct icm_fr_event_device_connected { · 36 unmodified lines
176183 #define ICM_LINK_INFO_DEPTH_SHIFT 4
177184 #define ICM_LINK_INFO_DEPTH_MASK GENMASK(7, 4)
178185 #define ICM_LINK_INFO_APPROVED BIT(8)
186+#define ICM_LINK_INFO_REJECTED BIT(9)
187+#define ICM_LINK_INFO_BOOT BIT(10)
179188
180189 struct icm_fr_pkg_approve_device {
181190 struct icm_pkg_header hdr;
@@ -270,6 +279,18 @@ struct icm_fr_pkg_approve_xdomain_response { · 88 unmodified lines
270279
271280 /* Alpine Ridge only messages */
272281
282+struct icm_ar_pkg_driver_ready_response {
283+ struct icm_pkg_header hdr;
284+ u8 romver;
285+ u8 ramver;
286+ u16 info;
287+};
288+
289+#define ICM_AR_INFO_SLEVEL_MASK GENMASK(3, 0)
290+#define ICM_AR_INFO_BOOT_ACL_SHIFT 7
291+#define ICM_AR_INFO_BOOT_ACL_MASK GENMASK(11, 7)
292+#define ICM_AR_INFO_BOOT_ACL_SUPPORTED BIT(13)
293+
273294 struct icm_ar_pkg_get_route {
274295 struct icm_pkg_header hdr;
275296 u16 reserved;
@@ -284,6 +305,163 @@ struct icm_ar_pkg_get_route_response { · 8 unmodified lines
284305 u32 route_lo;
285306 };
286307
308+struct icm_ar_boot_acl_entry {
309+ u32 uuid_lo;
310+ u32 uuid_hi;
311+};
312+
313+#define ICM_AR_PREBOOT_ACL_ENTRIES 16
314+
315+struct icm_ar_pkg_preboot_acl {
316+ struct icm_pkg_header hdr;
317+ struct icm_ar_boot_acl_entry acl[ICM_AR_PREBOOT_ACL_ENTRIES];
318+};
319+
320+struct icm_ar_pkg_preboot_acl_response {
321+ struct icm_pkg_header hdr;
322+ struct icm_ar_boot_acl_entry acl[ICM_AR_PREBOOT_ACL_ENTRIES];
323+};
324+
325+/* Titan Ridge messages */
326+
327+struct icm_tr_pkg_driver_ready_response {
328+ struct icm_pkg_header hdr;
329+ u16 reserved1;
330+ u16 info;
331+ u32 nvm_version;
332+ u16 device_id;
333+ u16 reserved2;
334+};
335+
336+#define ICM_TR_INFO_SLEVEL_MASK GENMASK(2, 0)
337+#define ICM_TR_INFO_BOOT_ACL_SHIFT 7
338+#define ICM_TR_INFO_BOOT_ACL_MASK GENMASK(12, 7)
339+
340+struct icm_tr_event_device_connected {
341+ struct icm_pkg_header hdr;
342+ uuid_t ep_uuid;
343+ u32 route_hi;
344+ u32 route_lo;
345+ u8 connection_id;
346+ u8 reserved;
347+ u16 link_info;
348+ u32 ep_name[55];
349+};
350+
351+struct icm_tr_event_device_disconnected {
352+ struct icm_pkg_header hdr;
353+ u32 route_hi;
354+ u32 route_lo;
355+};
356+
357+struct icm_tr_event_xdomain_connected {
358+ struct icm_pkg_header hdr;
359+ u16 reserved;
360+ u16 link_info;
361+ uuid_t remote_uuid;
362+ uuid_t local_uuid;
363+ u32 local_route_hi;
364+ u32 local_route_lo;
365+ u32 remote_route_hi;
366+ u32 remote_route_lo;
367+};
368+
369+struct icm_tr_event_xdomain_disconnected {
370+ struct icm_pkg_header hdr;
371+ u32 route_hi;
372+ u32 route_lo;
373+ uuid_t remote_uuid;
374+};
375+
376+struct icm_tr_pkg_approve_device {
377+ struct icm_pkg_header hdr;
378+ uuid_t ep_uuid;
379+ u32 route_hi;
380+ u32 route_lo;
381+ u8 connection_id;
382+ u8 reserved1[3];
383+};
384+
385+struct icm_tr_pkg_add_device_key {
386+ struct icm_pkg_header hdr;
387+ uuid_t ep_uuid;
388+ u32 route_hi;
389+ u32 route_lo;
390+ u8 connection_id;
391+ u8 reserved[3];
392+ u32 key[8];
393+};
394+
395+struct icm_tr_pkg_challenge_device {
396+ struct icm_pkg_header hdr;
397+ uuid_t ep_uuid;
398+ u32 route_hi;
399+ u32 route_lo;
400+ u8 connection_id;
401+ u8 reserved[3];
402+ u32 challenge[8];
403+};
404+
405+struct icm_tr_pkg_approve_xdomain {
406+ struct icm_pkg_header hdr;
407+ u32 route_hi;
408+ u32 route_lo;
409+ uuid_t remote_uuid;
410+ u16 transmit_path;
411+ u16 transmit_ring;
412+ u16 receive_path;
413+ u16 receive_ring;
414+};
415+
416+struct icm_tr_pkg_disconnect_xdomain {
417+ struct icm_pkg_header hdr;
418+ u8 stage;
419+ u8 reserved[3];
420+ u32 route_hi;
421+ u32 route_lo;
422+ uuid_t remote_uuid;
423+};
424+
425+struct icm_tr_pkg_challenge_device_response {
426+ struct icm_pkg_header hdr;
427+ uuid_t ep_uuid;
428+ u32 route_hi;
429+ u32 route_lo;
430+ u8 connection_id;
431+ u8 reserved[3];
432+ u32 challenge[8];
433+ u32 response[8];
434+};
435+
436+struct icm_tr_pkg_add_device_key_response {
437+ struct icm_pkg_header hdr;
438+ uuid_t ep_uuid;
439+ u32 route_hi;
440+ u32 route_lo;
441+ u8 connection_id;
442+ u8 reserved[3];
443+};
444+
445+struct icm_tr_pkg_approve_xdomain_response {
446+ struct icm_pkg_header hdr;
447+ u32 route_hi;
448+ u32 route_lo;
449+ uuid_t remote_uuid;
450+ u16 transmit_path;
451+ u16 transmit_ring;
452+ u16 receive_path;
453+ u16 receive_ring;
454+};
455+
456+struct icm_tr_pkg_disconnect_xdomain_response {
457+ struct icm_pkg_header hdr;
458+ u8 stage;
459+ u8 reserved[3];
460+ u32 route_hi;
461+ u32 route_lo;
462+ uuid_t remote_uuid;
463+};
464+
287465 /* XDomain messages */
288466
289467 struct tb_xdomain_header {
drivers/thunderbolt/xdomain.c+35−12
@@ -1255,6 +1255,7 @@ struct tb_xdomain_lookup { · 1254 unmodified lines
12551255 const uuid_t *uuid;
12561256 u8 link;
12571257 u8 depth;
1258+ u64 route;
12581259 };
12591260
12601261 static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw,
@@ -1275,9 +1276,13 @@ static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw, · 14 unmodified lines
12751276 if (lookup->uuid) {
12761277 if (uuid_equal(xd->remote_uuid, lookup->uuid))
12771278 return xd;
1278− } else if (lookup->link == xd->link &&
1279+ } else if (lookup->link &&
1280+ lookup->link == xd->link &&
12791281 lookup->depth == xd->depth) {
12801282 return xd;
1283+ } else if (lookup->route &&
1284+ lookup->route == xd->route) {
1285+ return xd;
12811286 }
12821287 } else if (port->remote) {
12831288 xd = switch_find_xdomain(port->remote->sw, lookup);
@@ -1313,12 +1318,7 @@ struct tb_xdomain *tb_xdomain_find_by_uuid(struct tb *tb, const uuid_t *uuid) · 29 unmodified lines
13131318 lookup.uuid = uuid;
13141319
13151320 xd = switch_find_xdomain(tb->root_switch, &lookup);
1316− if (xd) {
1317− get_device(&xd->dev);
1318− return xd;
1319− }
1320−
1321− return NULL;
1321+ return tb_xdomain_get(xd);
13221322 }
13231323 EXPORT_SYMBOL_GPL(tb_xdomain_find_by_uuid);
13241324
@@ -1349,13 +1349,36 @@ struct tb_xdomain *tb_xdomain_find_by_link_depth(struct tb *tb, u8 link, · 24 unmodified lines
13491349 lookup.depth = depth;
13501350
13511351 xd = switch_find_xdomain(tb->root_switch, &lookup);
1352− if (xd) {
1353− get_device(&xd->dev);
1354− return xd;
1355− }
1352+ return tb_xdomain_get(xd);
1353+}
13561354
1357− return NULL;
1355+/**
1356+ * tb_xdomain_find_by_route() - Find an XDomain by route string
1357+ * @tb: Domain where the XDomain belongs to
1358+ * @route: XDomain route string
1359+ *
1360+ * Finds XDomain by walking through the Thunderbolt topology below @tb.
1361+ * The returned XDomain will have its reference count increased so the
1362+ * caller needs to call tb_xdomain_put() when it is done with the
1363+ * object.
1364+ *
1365+ * This will find all XDomains including the ones that are not yet added
1366+ * to the bus (handshake is still in progress).
1367+ *
1368+ * The caller needs to hold @tb->lock.
1369+ */
1370+struct tb_xdomain *tb_xdomain_find_by_route(struct tb *tb, u64 route)
1371+{
1372+ struct tb_xdomain_lookup lookup;
1373+ struct tb_xdomain *xd;
1374+
1375+ memset(&lookup, 0, sizeof(lookup));
1376+ lookup.route = route;
1377+
1378+ xd = switch_find_xdomain(tb->root_switch, &lookup);
1379+ return tb_xdomain_get(xd);
13581380 }
1381+EXPORT_SYMBOL_GPL(tb_xdomain_find_by_route);
13591382
13601383 bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type,
13611384 const void *buf, size_t size)
drivers/uio/uio_hv_generic.c+89−0
@@ -121,6 +121,94 @@ static void hv_uio_rescind(struct vmbus_channel *channel) · 120 unmodified lines
121121 uio_event_notify(&pdata->info);
122122 }
123123
124+/*
125+ * Handle fault when looking for sub channel ring buffer
126+ * Subchannel ring buffer is same as resource 0 which is main ring buffer
127+ * This is derived from uio_vma_fault
128+ */
129+static int hv_uio_vma_fault(struct vm_fault *vmf)
130+{
131+ struct vm_area_struct *vma = vmf->vma;
132+ void *ring_buffer = vma->vm_private_data;
133+ struct page *page;
134+ void *addr;
135+
136+ addr = ring_buffer + (vmf->pgoff << PAGE_SHIFT);
137+ page = virt_to_page(addr);
138+ get_page(page);
139+ vmf->page = page;
140+ return 0;
141+}
142+
143+static const struct vm_operations_struct hv_uio_vm_ops = {
144+ .fault = hv_uio_vma_fault,
145+};
146+
147+/* Sysfs API to allow mmap of the ring buffers */
148+static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj,
149+ struct bin_attribute *attr,
150+ struct vm_area_struct *vma)
151+{
152+ struct vmbus_channel *channel
153+ = container_of(kobj, struct vmbus_channel, kobj);
154+ unsigned long requested_pages, actual_pages;
155+
156+ if (vma->vm_end < vma->vm_start)
157+ return -EINVAL;
158+
159+ /* only allow 0 for now */
160+ if (vma->vm_pgoff > 0)
161+ return -EINVAL;
162+
163+ requested_pages = vma_pages(vma);
164+ actual_pages = 2 * HV_RING_SIZE;
165+ if (requested_pages > actual_pages)
166+ return -EINVAL;
167+
168+ vma->vm_private_data = channel->ringbuffer_pages;
169+ vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
170+ vma->vm_ops = &hv_uio_vm_ops;
171+ return 0;
172+}
173+
174+static struct bin_attribute ring_buffer_bin_attr __ro_after_init = {
175+ .attr = {
176+ .name = "ring",
177+ .mode = 0600,
178+ /* size is set at init time */
179+ },
180+ .mmap = hv_uio_ring_mmap,
181+};
182+
183+/* Callback from VMBUS subystem when new channel created. */
184+static void
185+hv_uio_new_channel(struct vmbus_channel *new_sc)
186+{
187+ struct hv_device *hv_dev = new_sc->primary_channel->device_obj;
188+ struct device *device = &hv_dev->device;
189+ struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
190+ const size_t ring_bytes = HV_RING_SIZE * PAGE_SIZE;
191+ int ret;
192+
193+ /* Create host communication ring */
194+ ret = vmbus_open(new_sc, ring_bytes, ring_bytes, NULL, 0,
195+ hv_uio_channel_cb, pdata);
196+ if (ret) {
197+ dev_err(device, "vmbus_open subchannel failed: %d\n", ret);
198+ return;
199+ }
200+
201+ /* Disable interrupts on sub channel */
202+ new_sc->inbound.ring_buffer->interrupt_mask = 1;
203+ set_channel_read_mode(new_sc, HV_CALL_ISR);
204+
205+ ret = sysfs_create_bin_file(&new_sc->kobj, &ring_buffer_bin_attr);
206+ if (ret) {
207+ dev_err(device, "sysfs create ring bin file failed; %d\n", ret);
208+ vmbus_close(new_sc);
209+ }
210+}
211+
124212 static void
125213 hv_uio_cleanup(struct hv_device *dev, struct hv_uio_private_data *pdata)
126214 {
@@ -236,6 +324,7 @@ hv_uio_probe(struct hv_device *dev, · 109 unmodified lines
236324 }
237325
238326 vmbus_set_chn_rescind_callback(dev->channel, hv_uio_rescind);
327+ vmbus_set_sc_create_callback(dev->channel, hv_uio_new_channel);
239328
240329 hv_set_drvdata(dev, pdata);
241330
drivers/w1/w1.c+1−0
@@ -706,6 +706,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl) · 705 unmodified lines
706706 dev_err(&sl->dev,
707707 "Device registration [%s] failed. err=%d\n",
708708 dev_name(&sl->dev), err);
709+ put_device(&sl->dev);
709710 return err;
710711 }
711712 w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl);
fs/char_dev.c+5−5
@@ -67,18 +67,18 @@ static int find_dynamic_major(void) · 66 unmodified lines
6767 int i;
6868 struct char_device_struct *cd;
6969
70− for (i = ARRAY_SIZE(chrdevs)-1; i > CHRDEV_MAJOR_DYN_END; i--) {
70+ for (i = ARRAY_SIZE(chrdevs)-1; i >= CHRDEV_MAJOR_DYN_END; i--) {
7171 if (chrdevs[i] == NULL)
7272 return i;
7373 }
7474
7575 for (i = CHRDEV_MAJOR_DYN_EXT_START;
76− i > CHRDEV_MAJOR_DYN_EXT_END; i--) {
76+ i >= CHRDEV_MAJOR_DYN_EXT_END; i--) {
7777 for (cd = chrdevs[major_to_index(i)]; cd; cd = cd->next)
7878 if (cd->major == i)
7979 break;
8080
81− if (cd == NULL || cd->major != i)
81+ if (cd == NULL)
8282 return i;
8383 }
8484
@@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, · 36 unmodified lines
121121 }
122122
123123 if (major >= CHRDEV_MAJOR_MAX) {
124− pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n",
125− name, major, CHRDEV_MAJOR_MAX);
124+ pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n",
125+ name, major, CHRDEV_MAJOR_MAX-1);
126126 ret = -EINVAL;
127127 goto out;
128128 }
include/linux/extcon.h+6−0
@@ -230,6 +230,7 @@ extern void devm_extcon_unregister_notifier_all(struct device *dev, · 229 unmodified lines
230230 * Following APIs get the extcon_dev from devicetree or by through extcon name.
231231 */
232232 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
233+extern struct extcon_dev *extcon_find_edev_by_node(struct device_node *node);
233234 extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
234235 int index);
235236
@@ -283,6 +284,11 @@ static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) · 47 unmodified lines
283284 return ERR_PTR(-ENODEV);
284285 }
285286
287+static inline struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
288+{
289+ return ERR_PTR(-ENODEV);
290+}
291+
286292 static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
287293 int index)
288294 {
include/linux/extcon/extcon-gpio.h+0−47
@@ -1,47 +0,0 @@
1−/*
2− * Single-state GPIO extcon driver based on extcon class
3− *
4− * Copyright (C) 2012 Samsung Electronics
5− * Author: MyungJoo Ham <myungjoo.ham@samsung.com>
6− *
7− * based on switch class driver
8− * Copyright (C) 2008 Google, Inc.
9− * Author: Mike Lockwood <lockwood@android.com>
10− *
11− * This software is licensed under the terms of the GNU General Public
12− * License version 2, as published by the Free Software Foundation, and
13− * may be copied, distributed, and modified under those terms.
14− *
15− * This program is distributed in the hope that it will be useful,
16− * but WITHOUT ANY WARRANTY; without even the implied warranty of
17− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18− * GNU General Public License for more details.
19− */
20−#ifndef __EXTCON_GPIO_H__
21−#define __EXTCON_GPIO_H__ __FILE__
22−
23−#include <linux/extcon.h>
24−
25−/**
26− * struct gpio_extcon_pdata - A simple GPIO-controlled extcon device.
27− * @extcon_id: The unique id of specific external connector.
28− * @gpio: Corresponding GPIO.
29− * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0
30− * If true, low state of gpio means active.
31− * If false, high state of gpio means active.
32− * @debounce: Debounce time for GPIO IRQ in ms.
33− * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW).
34− * @check_on_resume: Boolean describing whether to check the state of gpio
35− * while resuming from sleep.
36− */
37−struct gpio_extcon_pdata {
38− unsigned int extcon_id;
39− unsigned gpio;
40− bool gpio_active_low;
41− unsigned long debounce;
42− unsigned long irq_flags;
43−
44− bool check_on_resume;
45−};
46−
47−#endif /* __EXTCON_GPIO_H__ */
include/linux/hyperv.h+1−1
@@ -844,7 +844,7 @@ struct vmbus_channel { · 843 unmodified lines
844844
845845 /*
846846 * NUMA distribution policy:
847− * We support teo policies:
847+ * We support two policies:
848848 * 1) Balanced: Here all performance critical channels are
849849 * distributed evenly amongst all the NUMA nodes.
850850 * This policy will be the default policy.
include/linux/nvmem-provider.h+42−0
@@ -22,6 +22,31 @@ typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset, · 21 unmodified lines
2222 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
2323 void *val, size_t bytes);
2424
25+/**
26+ * struct nvmem_config - NVMEM device configuration
27+ *
28+ * @dev: Parent device.
29+ * @name: Optional name.
30+ * @id: Optional device ID used in full name. Ignored if name is NULL.
31+ * @owner: Pointer to exporter module. Used for refcounting.
32+ * @cells: Optional array of pre-defined NVMEM cells.
33+ * @ncells: Number of elements in cells.
34+ * @read_only: Device is read-only.
35+ * @root_only: Device is accessibly to root only.
36+ * @reg_read: Callback to read data.
37+ * @reg_write: Callback to write data.
38+ * @size: Device size.
39+ * @word_size: Minimum read/write access granularity.
40+ * @stride: Minimum read/write access stride.
41+ * @priv: User context passed to read/write callbacks.
42+ *
43+ * Note: A default "nvmem<id>" name will be assigned to the device if
44+ * no name is specified in its configuration. In such case "<id>" is
45+ * generated with ida_simple_get() and provided id field is ignored.
46+ *
47+ * Note: Specifying name and setting id to -1 implies a unique device
48+ * whose name is provided as-is (kept unaltered).
49+ */
2550 struct nvmem_config {
2651 struct device *dev;
2752 const char *name;
@@ -47,6 +72,11 @@ struct nvmem_config { · 19 unmodified lines
4772 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
4873 int nvmem_unregister(struct nvmem_device *nvmem);
4974
75+struct nvmem_device *devm_nvmem_register(struct device *dev,
76+ const struct nvmem_config *cfg);
77+
78+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
79+
5080 #else
5181
5282 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -59,5 +89,17 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem) · 6 unmodified lines
5989 return -ENOSYS;
6090 }
6191
92+static inline struct nvmem_device *
93+devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
94+{
95+ return nvmem_register(c);
96+}
97+
98+static inline int
99+devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
100+{
101+ return nvmem_unregister(nvmem);
102+}
103+
62104 #endif /* CONFIG_NVMEM */
63105 #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */
include/linux/pci_ids.h+2−0
@@ -1562,6 +1562,8 @@ · 1561 unmodified lines
15621562 #define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227
15631563 #define PCI_DEVICE_ID_SERVERWORKS_HT1100LD 0x0408
15641564
1565+#define PCI_VENDOR_ID_ALTERA 0x1172
1566+
15651567 #define PCI_VENDOR_ID_SBE 0x1176
15661568 #define PCI_DEVICE_ID_SBE_WANXL100 0x0301
15671569 #define PCI_DEVICE_ID_SBE_WANXL200 0x0302
include/linux/stm.h+1−9
@@ -1,15 +1,7 @@
1+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * System Trace Module (STM) infrastructure apis
34 * Copyright (C) 2014 Intel Corporation.
4− *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms and conditions of the GNU General Public License,
7− * version 2, as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope it will be useful, but WITHOUT
10− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12− * more details.
135 */
146
157 #ifndef _STM_H_
include/linux/thunderbolt.h+19−0
@@ -45,12 +45,16 @@ enum tb_cfg_pkg_type { · 44 unmodified lines
4545 * @TB_SECURITY_USER: User approval required at minimum
4646 * @TB_SECURITY_SECURE: One time saved key required at minimum
4747 * @TB_SECURITY_DPONLY: Only tunnel Display port (and USB)
48+ * @TB_SECURITY_USBONLY: Only tunnel USB controller of the connected
49+ * Thunderbolt dock (and Display Port). All PCIe
50+ * links downstream of the dock are removed.
4851 */
4952 enum tb_security_level {
5053 TB_SECURITY_NONE,
5154 TB_SECURITY_USER,
5255 TB_SECURITY_SECURE,
5356 TB_SECURITY_DPONLY,
57+ TB_SECURITY_USBONLY,
5458 };
5559
5660 /**
@@ -65,6 +69,7 @@ enum tb_security_level { · 8 unmodified lines
6569 * @cm_ops: Connection manager specific operations vector
6670 * @index: Linux assigned domain number
6771 * @security_level: Current security level
72+ * @nboot_acl: Number of boot ACLs the domain supports
6873 * @privdata: Private connection manager specific data
6974 */
7075 struct tb {
@@ -77,6 +82,7 @@ struct tb { · 6 unmodified lines
7782 const struct tb_cm_ops *cm_ops;
7883 int index;
7984 enum tb_security_level security_level;
85+ size_t nboot_acl;
8086 unsigned long privdata[0];
8187 };
8288
@@ -237,6 +243,7 @@ int tb_xdomain_enable_paths(struct tb_xdomain *xd, u16 transmit_path, · 154 unmodified lines
237243 u16 receive_ring);
238244 int tb_xdomain_disable_paths(struct tb_xdomain *xd);
239245 struct tb_xdomain *tb_xdomain_find_by_uuid(struct tb *tb, const uuid_t *uuid);
246+struct tb_xdomain *tb_xdomain_find_by_route(struct tb *tb, u64 route);
240247
241248 static inline struct tb_xdomain *
242249 tb_xdomain_find_by_uuid_locked(struct tb *tb, const uuid_t *uuid)
@@ -250,6 +257,18 @@ tb_xdomain_find_by_uuid_locked(struct tb *tb, const uuid_t *uuid) · 7 unmodified lines
250257 return xd;
251258 }
252259
260+static inline struct tb_xdomain *
261+tb_xdomain_find_by_route_locked(struct tb *tb, u64 route)
262+{
263+ struct tb_xdomain *xd;
264+
265+ mutex_lock(&tb->lock);
266+ xd = tb_xdomain_find_by_route(tb, route);
267+ mutex_unlock(&tb->lock);
268+
269+ return xd;
270+}
271+
253272 static inline struct tb_xdomain *tb_xdomain_get(struct tb_xdomain *xd)
254273 {
255274 if (xd)
include/uapi/linux/stm.h+4−9
@@ -3,15 +3,6 @@ · 2 unmodified lines
33 * System Trace Module (STM) userspace interfaces
44 * Copyright (c) 2014, Intel Corporation.
55 *
6− * This program is free software; you can redistribute it and/or modify it
7− * under the terms and conditions of the GNU General Public License,
8− * version 2, as published by the Free Software Foundation.
9− *
10− * This program is distributed in the hope it will be useful, but WITHOUT
11− * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12− * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13− * more details.
14− *
156 * STM class implements generic infrastructure for System Trace Module devices
167 * as defined in MIPI STPv2 specification.
178 */
@@ -21,6 +12,10 @@ · 3 unmodified lines
2112
2213 #include <linux/types.h>
2314
15+/* Maximum allowed master and channel values */
16+#define STP_MASTER_MAX 0xffff
17+#define STP_CHANNEL_MAX 0xffff
18+
2419 /**
2520 * struct stp_policy_id - identification for the STP policy
2621 * @size: size of the structure including real id[] length
lib/devres.c+38−40
@@ -5,6 +5,12 @@ · 4 unmodified lines
55 #include <linux/gfp.h>
66 #include <linux/export.h>
77
8+enum devm_ioremap_type {
9+ DEVM_IOREMAP = 0,
10+ DEVM_IOREMAP_NC,
11+ DEVM_IOREMAP_WC,
12+};
13+
814 void devm_ioremap_release(struct device *dev, void *res)
915 {
1016 iounmap(*(void __iomem **)res);
@@ -15,24 +21,28 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data) · 4 unmodified lines
1521 return *(void **)res == match_data;
1622 }
1723
18−/**
19− * devm_ioremap - Managed ioremap()
20− * @dev: Generic device to remap IO address for
21− * @offset: Resource address to map
22− * @size: Size of map
23− *
24− * Managed ioremap(). Map is automatically unmapped on driver detach.
25− */
26−void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
27− resource_size_t size)
24+static void __iomem *__devm_ioremap(struct device *dev, resource_size_t offset,
25+ resource_size_t size,
26+ enum devm_ioremap_type type)
2827 {
29− void __iomem **ptr, *addr;
28+ void __iomem **ptr, *addr = NULL;
3029
3130 ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
3231 if (!ptr)
3332 return NULL;
3433
35− addr = ioremap(offset, size);
34+ switch (type) {
35+ case DEVM_IOREMAP:
36+ addr = ioremap(offset, size);
37+ break;
38+ case DEVM_IOREMAP_NC:
39+ addr = ioremap_nocache(offset, size);
40+ break;
41+ case DEVM_IOREMAP_WC:
42+ addr = ioremap_wc(offset, size);
43+ break;
44+ }
45+
3646 if (addr) {
3747 *ptr = addr;
3848 devres_add(dev, ptr);
@@ -41,6 +51,20 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, · 2 unmodified lines
4151
4252 return addr;
4353 }
54+
55+/**
56+ * devm_ioremap - Managed ioremap()
57+ * @dev: Generic device to remap IO address for
58+ * @offset: Resource address to map
59+ * @size: Size of map
60+ *
61+ * Managed ioremap(). Map is automatically unmapped on driver detach.
62+ */
63+void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
64+ resource_size_t size)
65+{
66+ return __devm_ioremap(dev, offset, size, DEVM_IOREMAP);
67+}
4468 EXPORT_SYMBOL(devm_ioremap);
4569
4670 /**
@@ -55,20 +79,7 @@ EXPORT_SYMBOL(devm_ioremap); · 8 unmodified lines
5579 void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
5680 resource_size_t size)
5781 {
58− void __iomem **ptr, *addr;
59−
60− ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
61− if (!ptr)
62− return NULL;
63−
64− addr = ioremap_nocache(offset, size);
65− if (addr) {
66− *ptr = addr;
67− devres_add(dev, ptr);
68− } else
69− devres_free(ptr);
70−
71− return addr;
82+ return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_NC);
7283 }
7384 EXPORT_SYMBOL(devm_ioremap_nocache);
7485
@@ -83,20 +94,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache); · 8 unmodified lines
8394 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
8495 resource_size_t size)
8596 {
86− void __iomem **ptr, *addr;
87−
88− ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
89− if (!ptr)
90− return NULL;
91−
92− addr = ioremap_wc(offset, size);
93− if (addr) {
94− *ptr = addr;
95− devres_add(dev, ptr);
96− } else
97− devres_free(ptr);
98−
99− return addr;
97+ return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_WC);
10098 }
10199 EXPORT_SYMBOL(devm_ioremap_wc);
102100
tools/hv/hv_fcopy_daemon.c+3−1
@@ -21,15 +21,17 @@ · 20 unmodified lines
2121 #include <stdio.h>
2222 #include <stdlib.h>
2323 #include <unistd.h>
24+#include <string.h>
2425 #include <errno.h>
2526 #include <linux/hyperv.h>
27+#include <linux/limits.h>
2628 #include <syslog.h>
2729 #include <sys/stat.h>
2830 #include <fcntl.h>
2931 #include <getopt.h>
3032
3133 static int target_fd;
32−static char target_fname[W_MAX_PATH];
34+static char target_fname[PATH_MAX];
3335 static unsigned long long filesize;
3436
3537 static int hv_start_fcopy(struct hv_start_fcopy *smsg)
tools/hv/hv_kvp_daemon.c+65−73
@@ -634,64 +634,6 @@ static char *kvp_if_name_to_mac(char *if_name) · 633 unmodified lines
634634 return mac_addr;
635635 }
636636
637−
638−/*
639− * Retrieve the interface name given tha MAC address.
640− */
641−
642−static char *kvp_mac_to_if_name(char *mac)
643−{
644− DIR *dir;
645− struct dirent *entry;
646− FILE *file;
647− char *p, *x;
648− char *if_name = NULL;
649− char buf[256];
650− char dev_id[PATH_MAX];
651− unsigned int i;
652−
653− dir = opendir(KVP_NET_DIR);
654− if (dir == NULL)
655− return NULL;
656−
657− while ((entry = readdir(dir)) != NULL) {
658− /*
659− * Set the state for the next pass.
660− */
661− snprintf(dev_id, sizeof(dev_id), "%s%s/address", KVP_NET_DIR,
662− entry->d_name);
663−
664− file = fopen(dev_id, "r");
665− if (file == NULL)
666− continue;
667−
668− p = fgets(buf, sizeof(buf), file);
669− if (p) {
670− x = strchr(p, '\n');
671− if (x)
672− *x = '\0';
673−
674− for (i = 0; i < strlen(p); i++)
675− p[i] = toupper(p[i]);
676−
677− if (!strcmp(p, mac)) {
678− /*
679− * Found the MAC match; return the interface
680− * name. The caller will free the memory.
681− */
682− if_name = strdup(entry->d_name);
683− fclose(file);
684− break;
685− }
686− }
687− fclose(file);
688− }
689−
690− closedir(dir);
691− return if_name;
692−}
693−
694−
695637 static void kvp_process_ipconfig_file(char *cmd,
696638 char *config_buf, unsigned int len,
697639 int element_size, int offset)
@@ -997,6 +939,70 @@ getaddr_done: · 299 unmodified lines
997939 return error;
998940 }
999941
942+/*
943+ * Retrieve the IP given the MAC address.
944+ */
945+static int kvp_mac_to_ip(struct hv_kvp_ipaddr_value *kvp_ip_val)
946+{
947+ char *mac = (char *)kvp_ip_val->adapter_id;
948+ DIR *dir;
949+ struct dirent *entry;
950+ FILE *file;
951+ char *p, *x;
952+ char *if_name = NULL;
953+ char buf[256];
954+ char dev_id[PATH_MAX];
955+ unsigned int i;
956+ int error = HV_E_FAIL;
957+
958+ dir = opendir(KVP_NET_DIR);
959+ if (dir == NULL)
960+ return HV_E_FAIL;
961+
962+ while ((entry = readdir(dir)) != NULL) {
963+ /*
964+ * Set the state for the next pass.
965+ */
966+ snprintf(dev_id, sizeof(dev_id), "%s%s/address", KVP_NET_DIR,
967+ entry->d_name);
968+
969+ file = fopen(dev_id, "r");
970+ if (file == NULL)
971+ continue;
972+
973+ p = fgets(buf, sizeof(buf), file);
974+ fclose(file);
975+ if (!p)
976+ continue;
977+
978+ x = strchr(p, '\n');
979+ if (x)
980+ *x = '\0';
981+
982+ for (i = 0; i < strlen(p); i++)
983+ p[i] = toupper(p[i]);
984+
985+ if (strcmp(p, mac))
986+ continue;
987+
988+ /*
989+ * Found the MAC match.
990+ * A NIC (e.g. VF) matching the MAC, but without IP, is skipped.
991+ */
992+ if_name = entry->d_name;
993+ if (!if_name)
994+ continue;
995+
996+ error = kvp_get_ip_info(0, if_name, KVP_OP_GET_IP_INFO,
997+ kvp_ip_val, MAX_IP_ADDR_SIZE * 2);
998+
999+ if (!error && strlen((char *)kvp_ip_val->ip_addr))
1000+ break;
1001+ }
1002+
1003+ closedir(dir);
1004+ return error;
1005+}
10001006
10011007 static int expand_ipv6(char *addr, int type)
10021008 {
@@ -1472,26 +1478,12 @@ int main(int argc, char *argv[]) · 469 unmodified lines
14721478 switch (op) {
14731479 case KVP_OP_GET_IP_INFO:
14741480 kvp_ip_val = &hv_msg->body.kvp_ip_val;
1475− if_name =
1476− kvp_mac_to_if_name((char *)kvp_ip_val->adapter_id);
14771481
1478− if (if_name == NULL) {
1479− /*
1480− * We could not map the mac address to an
1481− * interface name; return error.
1482− */
1483− hv_msg->error = HV_E_FAIL;
1484− break;
1485− }
1486− error = kvp_get_ip_info(
1487− 0, if_name, KVP_OP_GET_IP_INFO,
1488− kvp_ip_val,
1489− (MAX_IP_ADDR_SIZE * 2));
1482+ error = kvp_mac_to_ip(kvp_ip_val);
14901483
14911484 if (error)
14921485 hv_msg->error = error;
14931486
1494− free(if_name);
14951487 break;
14961488
14971489 case KVP_OP_SET_IP_INFO:
tools/hv/hv_vss_daemon.c+1−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include <sys/poll.h>
2323 #include <sys/ioctl.h>
2424 #include <sys/stat.h>
25+#include <sys/sysmacros.h>
2526 #include <fcntl.h>
2627 #include <stdio.h>
2728 #include <mntent.h>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t