0005-surface-sam.patch 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. From 49d4e0f3885582fbc2a49dd6cb858ccd2d16a1bc Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Sat, 5 Nov 2022 21:23:53 +0100
  4. Subject: [PATCH] platform/surface: aggregator: Improve documentation and
  5. handling of message target and source IDs
  6. The `tid_in` and `tid_out` fields of the serial hub protocol command
  7. struct (struct ssh_command) are actually source and target IDs,
  8. indicating the peer from which the message originated and the peer for
  9. which it is intended.
  10. Change the naming of those fields accordingly and improve the protocol
  11. documenation. Additionally, introduce an enum containing all currently
  12. known peers, i.e. targets and sources.
  13. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  14. Patchset: surface-sam
  15. ---
  16. .../driver-api/surface_aggregator/client.rst | 4 +-
  17. .../driver-api/surface_aggregator/ssh.rst | 36 +++++++++--------
  18. .../platform/surface/aggregator/controller.c | 12 +++---
  19. .../platform/surface/aggregator/ssh_msgb.h | 4 +-
  20. include/linux/surface_aggregator/controller.h | 4 +-
  21. include/linux/surface_aggregator/serial_hub.h | 40 +++++++++++++------
  22. 6 files changed, 58 insertions(+), 42 deletions(-)
  23. diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
  24. index 27f95abdbe99..9d7411223a84 100644
  25. --- a/Documentation/driver-api/surface_aggregator/client.rst
  26. +++ b/Documentation/driver-api/surface_aggregator/client.rst
  27. @@ -191,7 +191,7 @@ data received from it is converted from little-endian to host endianness.
  28. * they do not correspond to an actual SAM/EC request.
  29. */
  30. rqst.target_category = SSAM_SSH_TC_SAM;
  31. - rqst.target_id = 0x01;
  32. + rqst.target_id = SSAM_SSH_TID_SAM;
  33. rqst.command_id = 0x02;
  34. rqst.instance_id = 0x03;
  35. rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
  36. @@ -241,7 +241,7 @@ one of the generator macros, for example via:
  37. SSAM_DEFINE_SYNC_REQUEST_W(__ssam_tmp_perf_mode_set, __le32, {
  38. .target_category = SSAM_SSH_TC_TMP,
  39. - .target_id = 0x01,
  40. + .target_id = SSAM_SSH_TID_SAM,
  41. .command_id = 0x03,
  42. .instance_id = 0x00,
  43. });
  44. diff --git a/Documentation/driver-api/surface_aggregator/ssh.rst b/Documentation/driver-api/surface_aggregator/ssh.rst
  45. index bf007d6c9873..18fd0f0aee84 100644
  46. --- a/Documentation/driver-api/surface_aggregator/ssh.rst
  47. +++ b/Documentation/driver-api/surface_aggregator/ssh.rst
  48. @@ -13,6 +13,7 @@
  49. .. |DATA_NSQ| replace:: ``DATA_NSQ``
  50. .. |TC| replace:: ``TC``
  51. .. |TID| replace:: ``TID``
  52. +.. |SID| replace:: ``SID``
  53. .. |IID| replace:: ``IID``
  54. .. |RQID| replace:: ``RQID``
  55. .. |CID| replace:: ``CID``
  56. @@ -219,13 +220,13 @@ following fields, packed together and in order:
  57. - |u8|
  58. - Target category.
  59. - * - |TID| (out)
  60. + * - |TID|
  61. - |u8|
  62. - - Target ID for outgoing (host to EC) commands.
  63. + - Target ID for commands/messages.
  64. - * - |TID| (in)
  65. + * - |SID|
  66. - |u8|
  67. - - Target ID for incoming (EC to host) commands.
  68. + - Source ID for commands/messages.
  69. * - |IID|
  70. - |u8|
  71. @@ -286,19 +287,20 @@ general, however, a single target category should map to a single reserved
  72. event request ID.
  73. Furthermore, requests, responses, and events have an associated target ID
  74. -(``TID``). This target ID is split into output (host to EC) and input (EC to
  75. -host) fields, with the respecting other field (e.g. output field on incoming
  76. -messages) set to zero. Two ``TID`` values are known: Primary (``0x01``) and
  77. -secondary (``0x02``). In general, the response to a request should have the
  78. -same ``TID`` value, however, the field (output vs. input) should be used in
  79. -accordance to the direction in which the response is sent (i.e. on the input
  80. -field, as responses are generally sent from the EC to the host).
  81. -
  82. -Note that, even though requests and events should be uniquely identifiable
  83. -by target category and command ID alone, the EC may require specific
  84. -target ID and instance ID values to accept a command. A command that is
  85. -accepted for ``TID=1``, for example, may not be accepted for ``TID=2``
  86. -and vice versa.
  87. +(``TID``) and source ID (``SID``). These two fields indicate where a message
  88. +originates from (``SID``) and what the intended target of the message is
  89. +(``TID``). Note that a response to a specific request therefore has the source
  90. +and target IDs swapped when compared to the original request (i.e. the request
  91. +target is the response source and the request source is the response target).
  92. +See (:c:type:`enum ssh_request_id <ssh_request_id>`) for possible values of
  93. +both.
  94. +
  95. +Note that, even though requests and events should be uniquely identifiable by
  96. +target category and command ID alone, the EC may require specific target ID and
  97. +instance ID values to accept a command. A command that is accepted for
  98. +``TID=1``, for example, may not be accepted for ``TID=2`` and vice versa. While
  99. +this may not always hold in reality, you can think of different target/source
  100. +IDs indicating different physical ECs with potentially different feature sets.
  101. Limitations and Observations
  102. diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
  103. index c6537a1b3a2e..2c99f51ccd4e 100644
  104. --- a/drivers/platform/surface/aggregator/controller.c
  105. +++ b/drivers/platform/surface/aggregator/controller.c
  106. @@ -994,7 +994,7 @@ static void ssam_handle_event(struct ssh_rtl *rtl,
  107. item->rqid = get_unaligned_le16(&cmd->rqid);
  108. item->event.target_category = cmd->tc;
  109. - item->event.target_id = cmd->tid_in;
  110. + item->event.target_id = cmd->sid;
  111. item->event.command_id = cmd->cid;
  112. item->event.instance_id = cmd->iid;
  113. memcpy(&item->event.data[0], data->ptr, data->len);
  114. @@ -1779,35 +1779,35 @@ EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer);
  115. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_get_firmware_version, __le32, {
  116. .target_category = SSAM_SSH_TC_SAM,
  117. - .target_id = 0x01,
  118. + .target_id = SSAM_SSH_TID_SAM,
  119. .command_id = 0x13,
  120. .instance_id = 0x00,
  121. });
  122. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_off, u8, {
  123. .target_category = SSAM_SSH_TC_SAM,
  124. - .target_id = 0x01,
  125. + .target_id = SSAM_SSH_TID_SAM,
  126. .command_id = 0x15,
  127. .instance_id = 0x00,
  128. });
  129. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_on, u8, {
  130. .target_category = SSAM_SSH_TC_SAM,
  131. - .target_id = 0x01,
  132. + .target_id = SSAM_SSH_TID_SAM,
  133. .command_id = 0x16,
  134. .instance_id = 0x00,
  135. });
  136. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_exit, u8, {
  137. .target_category = SSAM_SSH_TC_SAM,
  138. - .target_id = 0x01,
  139. + .target_id = SSAM_SSH_TID_SAM,
  140. .command_id = 0x33,
  141. .instance_id = 0x00,
  142. });
  143. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_entry, u8, {
  144. .target_category = SSAM_SSH_TC_SAM,
  145. - .target_id = 0x01,
  146. + .target_id = SSAM_SSH_TID_SAM,
  147. .command_id = 0x34,
  148. .instance_id = 0x00,
  149. });
  150. diff --git a/drivers/platform/surface/aggregator/ssh_msgb.h b/drivers/platform/surface/aggregator/ssh_msgb.h
  151. index f3ecad92eefd..438873e06098 100644
  152. --- a/drivers/platform/surface/aggregator/ssh_msgb.h
  153. +++ b/drivers/platform/surface/aggregator/ssh_msgb.h
  154. @@ -189,8 +189,8 @@ static inline void msgb_push_cmd(struct msgbuf *msgb, u8 seq, u16 rqid,
  155. __msgb_push_u8(msgb, SSH_PLD_TYPE_CMD); /* Payload type. */
  156. __msgb_push_u8(msgb, rqst->target_category); /* Target category. */
  157. - __msgb_push_u8(msgb, rqst->target_id); /* Target ID (out). */
  158. - __msgb_push_u8(msgb, 0x00); /* Target ID (in). */
  159. + __msgb_push_u8(msgb, rqst->target_id); /* Target ID. */
  160. + __msgb_push_u8(msgb, SSAM_SSH_TID_HOST); /* Source ID. */
  161. __msgb_push_u8(msgb, rqst->instance_id); /* Instance ID. */
  162. __msgb_push_u16(msgb, rqid); /* Request ID. */
  163. __msgb_push_u8(msgb, rqst->command_id); /* Command ID. */
  164. diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
  165. index d11a1c6e3186..8932bc0bae18 100644
  166. --- a/include/linux/surface_aggregator/controller.h
  167. +++ b/include/linux/surface_aggregator/controller.h
  168. @@ -912,10 +912,10 @@ enum ssam_event_mask {
  169. })
  170. #define SSAM_EVENT_REGISTRY_SAM \
  171. - SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, 0x01, 0x0b, 0x0c)
  172. + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, SSAM_SSH_TID_SAM, 0x0b, 0x0c)
  173. #define SSAM_EVENT_REGISTRY_KIP \
  174. - SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, 0x02, 0x27, 0x28)
  175. + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, SSAM_SSH_TID_KIP, 0x27, 0x28)
  176. #define SSAM_EVENT_REGISTRY_REG(tid)\
  177. SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, tid, 0x01, 0x02)
  178. diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h
  179. index 45501b6e54e8..5c4ae1a26183 100644
  180. --- a/include/linux/surface_aggregator/serial_hub.h
  181. +++ b/include/linux/surface_aggregator/serial_hub.h
  182. @@ -83,23 +83,21 @@ enum ssh_payload_type {
  183. /**
  184. * struct ssh_command - Payload of a command-type frame.
  185. - * @type: The type of the payload. See &enum ssh_payload_type. Should be
  186. - * SSH_PLD_TYPE_CMD for this struct.
  187. - * @tc: Command target category.
  188. - * @tid_out: Output target ID. Should be zero if this an incoming (EC to host)
  189. - * message.
  190. - * @tid_in: Input target ID. Should be zero if this is an outgoing (host to
  191. - * EC) message.
  192. - * @iid: Instance ID.
  193. - * @rqid: Request ID. Used to match requests with responses and differentiate
  194. - * between responses and events.
  195. - * @cid: Command ID.
  196. + * @type: The type of the payload. See &enum ssh_payload_type. Should be
  197. + * SSH_PLD_TYPE_CMD for this struct.
  198. + * @tc: Command target category.
  199. + * @tid: Target ID. Indicates the target of the message.
  200. + * @sid: Source ID. Indicates the source of the message.
  201. + * @iid: Instance ID.
  202. + * @rqid: Request ID. Used to match requests with responses and differentiate
  203. + * between responses and events.
  204. + * @cid: Command ID.
  205. */
  206. struct ssh_command {
  207. u8 type;
  208. u8 tc;
  209. - u8 tid_out;
  210. - u8 tid_in;
  211. + u8 tid;
  212. + u8 sid;
  213. u8 iid;
  214. __le16 rqid;
  215. u8 cid;
  216. @@ -280,6 +278,22 @@ struct ssam_span {
  217. size_t len;
  218. };
  219. +/**
  220. + * enum ssam_ssh_tid - Target/source IDs for Serial Hub messages.
  221. + * @SSAM_SSH_TID_HOST: We as the kernel Serial Hub driver.
  222. + * @SSAM_SSH_TID_SAM: The Surface Aggregator EC.
  223. + * @SSAM_SSH_TID_KIP: Keyboard and perihperal controller.
  224. + * @SSAM_SSH_TID_DEBUG: Debug connector.
  225. + * @SSAM_SSH_TID_SURFLINK: SurfLink connector.
  226. + */
  227. +enum ssam_ssh_tid {
  228. + SSAM_SSH_TID_HOST = 0x00,
  229. + SSAM_SSH_TID_SAM = 0x01,
  230. + SSAM_SSH_TID_KIP = 0x02,
  231. + SSAM_SSH_TID_DEBUG = 0x03,
  232. + SSAM_SSH_TID_SURFLINK = 0x04,
  233. +};
  234. +
  235. /*
  236. * Known SSH/EC target categories.
  237. *
  238. --
  239. 2.39.1
  240. From 7bbedf41c6dc00352b90d84bddc951b2ff429b27 Mon Sep 17 00:00:00 2001
  241. From: Maximilian Luz <luzmaximilian@gmail.com>
  242. Date: Sat, 5 Nov 2022 21:42:19 +0100
  243. Subject: [PATCH] platform/surface: aggregator: Add target and source IDs to
  244. command trace events
  245. Add command source and target IDs to trace events.
  246. Tracing support for the Surface Aggregator driver was originally
  247. implemented at a time when only two peers were known: Host and SAM. We
  248. now know that there are at least five, with three actively being used
  249. (Host, SAM, KIP; four with Debug if you want to count manually enabling
  250. that interface). So it makes sense to also explicitly name the peers
  251. involved when tracing.
  252. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  253. Patchset: surface-sam
  254. ---
  255. drivers/platform/surface/aggregator/trace.h | 73 +++++++++++++++++++--
  256. 1 file changed, 67 insertions(+), 6 deletions(-)
  257. diff --git a/drivers/platform/surface/aggregator/trace.h b/drivers/platform/surface/aggregator/trace.h
  258. index 2a2c17771d01..55cc61bba1da 100644
  259. --- a/drivers/platform/surface/aggregator/trace.h
  260. +++ b/drivers/platform/surface/aggregator/trace.h
  261. @@ -96,6 +96,7 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS);
  262. #define SSAM_SEQ_NOT_APPLICABLE ((u16)-1)
  263. #define SSAM_RQID_NOT_APPLICABLE ((u32)-1)
  264. #define SSAM_SSH_TC_NOT_APPLICABLE 0
  265. +#define SSAM_SSH_TID_NOT_APPLICABLE ((u8)-1)
  266. #ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
  267. #define _SURFACE_AGGREGATOR_TRACE_HELPERS
  268. @@ -150,12 +151,44 @@ static inline u32 ssam_trace_get_request_id(const struct ssh_packet *p)
  269. return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(rqid)]);
  270. }
  271. +/**
  272. + * ssam_trace_get_request_tid() - Read the packet's request target ID.
  273. + * @p: The packet.
  274. + *
  275. + * Return: Returns the packet's request target ID (TID) field if the packet
  276. + * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
  277. + * if not (e.g. flush request, control packet).
  278. + */
  279. +static inline u32 ssam_trace_get_request_tid(const struct ssh_packet *p)
  280. +{
  281. + if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
  282. + return SSAM_SSH_TID_NOT_APPLICABLE;
  283. +
  284. + return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(tid)]);
  285. +}
  286. +
  287. +/**
  288. + * ssam_trace_get_request_sid() - Read the packet's request source ID.
  289. + * @p: The packet.
  290. + *
  291. + * Return: Returns the packet's request source ID (SID) field if the packet
  292. + * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
  293. + * if not (e.g. flush request, control packet).
  294. + */
  295. +static inline u32 ssam_trace_get_request_sid(const struct ssh_packet *p)
  296. +{
  297. + if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
  298. + return SSAM_SSH_TID_NOT_APPLICABLE;
  299. +
  300. + return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(sid)]);
  301. +}
  302. +
  303. /**
  304. * ssam_trace_get_request_tc() - Read the packet's request target category.
  305. * @p: The packet.
  306. *
  307. * Return: Returns the packet's request target category (TC) field if the
  308. - * packet represents a request with command data, or %SSAM_TC_NOT_APPLICABLE
  309. + * packet represents a request with command data, or %SSAM_SSH_TC_NOT_APPLICABLE
  310. * if not (e.g. flush request, control packet).
  311. */
  312. static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
  313. @@ -232,8 +265,18 @@ static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
  314. { SSAM_RQID_NOT_APPLICABLE, "N/A" } \
  315. )
  316. -#define ssam_show_ssh_tc(rqid) \
  317. - __print_symbolic(rqid, \
  318. +#define ssam_show_ssh_tid(tid) \
  319. + __print_symbolic(tid, \
  320. + { SSAM_SSH_TID_NOT_APPLICABLE, "N/A" }, \
  321. + { SSAM_SSH_TID_HOST, "Host" }, \
  322. + { SSAM_SSH_TID_SAM, "SAM" }, \
  323. + { SSAM_SSH_TID_KIP, "KIP" }, \
  324. + { SSAM_SSH_TID_DEBUG, "Debug" }, \
  325. + { SSAM_SSH_TID_SURFLINK, "SurfLink" } \
  326. + )
  327. +
  328. +#define ssam_show_ssh_tc(tc) \
  329. + __print_symbolic(tc, \
  330. { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \
  331. { SSAM_SSH_TC_SAM, "SAM" }, \
  332. { SSAM_SSH_TC_BAT, "BAT" }, \
  333. @@ -313,6 +356,8 @@ DECLARE_EVENT_CLASS(ssam_command_class,
  334. TP_STRUCT__entry(
  335. __field(u16, rqid)
  336. __field(u16, len)
  337. + __field(u8, tid)
  338. + __field(u8, sid)
  339. __field(u8, tc)
  340. __field(u8, cid)
  341. __field(u8, iid)
  342. @@ -320,14 +365,18 @@ DECLARE_EVENT_CLASS(ssam_command_class,
  343. TP_fast_assign(
  344. __entry->rqid = get_unaligned_le16(&cmd->rqid);
  345. + __entry->tid = cmd->tid;
  346. + __entry->sid = cmd->sid;
  347. __entry->tc = cmd->tc;
  348. __entry->cid = cmd->cid;
  349. __entry->iid = cmd->iid;
  350. __entry->len = len;
  351. ),
  352. - TP_printk("rqid=%#06x, tc=%s, cid=%#04x, iid=%#04x, len=%u",
  353. + TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
  354. __entry->rqid,
  355. + ssam_show_ssh_tid(__entry->tid),
  356. + ssam_show_ssh_tid(__entry->sid),
  357. ssam_show_ssh_tc(__entry->tc),
  358. __entry->cid,
  359. __entry->iid,
  360. @@ -430,6 +479,8 @@ DECLARE_EVENT_CLASS(ssam_request_class,
  361. __field(u8, tc)
  362. __field(u16, cid)
  363. __field(u16, iid)
  364. + __field(u8, tid)
  365. + __field(u8, sid)
  366. ),
  367. TP_fast_assign(
  368. @@ -439,16 +490,20 @@ DECLARE_EVENT_CLASS(ssam_request_class,
  369. __entry->state = READ_ONCE(request->state);
  370. __entry->rqid = ssam_trace_get_request_id(p);
  371. ssam_trace_ptr_uid(p, __entry->uid);
  372. + __entry->tid = ssam_trace_get_request_tid(p);
  373. + __entry->sid = ssam_trace_get_request_sid(p);
  374. __entry->tc = ssam_trace_get_request_tc(p);
  375. __entry->cid = ssam_trace_get_command_field_u8(p, cid);
  376. __entry->iid = ssam_trace_get_command_field_u8(p, iid);
  377. ),
  378. - TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s",
  379. + TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
  380. __entry->uid,
  381. ssam_show_request_id(__entry->rqid),
  382. ssam_show_request_type(__entry->state),
  383. ssam_show_request_state(__entry->state),
  384. + ssam_show_ssh_tid(__entry->tid),
  385. + ssam_show_ssh_tid(__entry->sid),
  386. ssam_show_ssh_tc(__entry->tc),
  387. ssam_show_generic_u8_field(__entry->cid),
  388. ssam_show_generic_u8_field(__entry->iid)
  389. @@ -474,6 +529,8 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
  390. __field(u8, tc)
  391. __field(u16, cid)
  392. __field(u16, iid)
  393. + __field(u8, tid)
  394. + __field(u8, sid)
  395. ),
  396. TP_fast_assign(
  397. @@ -484,16 +541,20 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
  398. __entry->rqid = ssam_trace_get_request_id(p);
  399. __entry->status = status;
  400. ssam_trace_ptr_uid(p, __entry->uid);
  401. + __entry->tid = ssam_trace_get_request_tid(p);
  402. + __entry->sid = ssam_trace_get_request_sid(p);
  403. __entry->tc = ssam_trace_get_request_tc(p);
  404. __entry->cid = ssam_trace_get_command_field_u8(p, cid);
  405. __entry->iid = ssam_trace_get_command_field_u8(p, iid);
  406. ),
  407. - TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s, status=%d",
  408. + TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
  409. __entry->uid,
  410. ssam_show_request_id(__entry->rqid),
  411. ssam_show_request_type(__entry->state),
  412. ssam_show_request_state(__entry->state),
  413. + ssam_show_ssh_tid(__entry->tid),
  414. + ssam_show_ssh_tid(__entry->sid),
  415. ssam_show_ssh_tc(__entry->tc),
  416. ssam_show_generic_u8_field(__entry->cid),
  417. ssam_show_generic_u8_field(__entry->iid),
  418. --
  419. 2.39.1
  420. From bdeb5fd1669c2f2235aae296a2ec15d73cd6d160 Mon Sep 17 00:00:00 2001
  421. From: Maximilian Luz <luzmaximilian@gmail.com>
  422. Date: Sat, 5 Nov 2022 21:32:16 +0100
  423. Subject: [PATCH] platform/surface: aggregator_hub: Use target-ID enum instead
  424. of hard-coding values
  425. Instead of hard-coding the target ID, use the respective enum
  426. ssam_ssh_tid value.
  427. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  428. Patchset: surface-sam
  429. ---
  430. drivers/platform/surface/surface_aggregator_hub.c | 4 ++--
  431. 1 file changed, 2 insertions(+), 2 deletions(-)
  432. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  433. index 43061514be38..62f27cdb6ca8 100644
  434. --- a/drivers/platform/surface/surface_aggregator_hub.c
  435. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  436. @@ -214,7 +214,7 @@ static void ssam_hub_remove(struct ssam_device *sdev)
  437. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_query_opmode, u8, {
  438. .target_category = SSAM_SSH_TC_BAS,
  439. - .target_id = 0x01,
  440. + .target_id = SSAM_SSH_TID_SAM,
  441. .command_id = 0x0d,
  442. .instance_id = 0x00,
  443. });
  444. @@ -292,7 +292,7 @@ static const struct ssam_hub_desc base_hub = {
  445. SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_query_state, u8, {
  446. .target_category = SSAM_SSH_TC_KIP,
  447. - .target_id = 0x01,
  448. + .target_id = SSAM_SSH_TID_SAM,
  449. .command_id = 0x2c,
  450. .instance_id = 0x00,
  451. });
  452. --
  453. 2.39.1
  454. From 9b8a09ae48a87958a28d941bc5a3424d93e5ac88 Mon Sep 17 00:00:00 2001
  455. From: Maximilian Luz <luzmaximilian@gmail.com>
  456. Date: Sat, 5 Nov 2022 21:33:26 +0100
  457. Subject: [PATCH] platform/surface: aggregator_tabletsw: Use target-ID enum
  458. instead of hard-coding values
  459. Instead of hard-coding the target ID, use the respective enum
  460. ssam_ssh_tid value.
  461. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  462. Patchset: surface-sam
  463. ---
  464. drivers/platform/surface/surface_aggregator_tabletsw.c | 6 +++---
  465. 1 file changed, 3 insertions(+), 3 deletions(-)
  466. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  467. index 27d95a6a7851..bd8cd453c393 100644
  468. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  469. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  470. @@ -247,7 +247,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 s
  471. SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
  472. .target_category = SSAM_SSH_TC_KIP,
  473. - .target_id = 0x01,
  474. + .target_id = SSAM_SSH_TID_SAM,
  475. .command_id = 0x1d,
  476. .instance_id = 0x00,
  477. });
  478. @@ -371,7 +371,7 @@ static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sour
  479. int status;
  480. rqst.target_category = SSAM_SSH_TC_POS;
  481. - rqst.target_id = 0x01;
  482. + rqst.target_id = SSAM_SSH_TID_SAM;
  483. rqst.command_id = 0x01;
  484. rqst.instance_id = 0x00;
  485. rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
  486. @@ -430,7 +430,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
  487. SSAM_DEFINE_SYNC_REQUEST_WR(__ssam_pos_get_posture_for_source, __le32, __le32, {
  488. .target_category = SSAM_SSH_TC_POS,
  489. - .target_id = 0x01,
  490. + .target_id = SSAM_SSH_TID_SAM,
  491. .command_id = 0x02,
  492. .instance_id = 0x00,
  493. });
  494. --
  495. 2.39.1
  496. From 9b0a4cdd3f96e6004dc34bba3c6ffbdc6bcb746d Mon Sep 17 00:00:00 2001
  497. From: Maximilian Luz <luzmaximilian@gmail.com>
  498. Date: Sat, 5 Nov 2022 21:34:06 +0100
  499. Subject: [PATCH] platform/surface: dtx: Use target-ID enum instead of
  500. hard-coding values
  501. Instead of hard-coding the target ID, use the respective enum
  502. ssam_ssh_tid value.
  503. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  504. Patchset: surface-sam
  505. ---
  506. drivers/platform/surface/surface_dtx.c | 18 +++++++++---------
  507. 1 file changed, 9 insertions(+), 9 deletions(-)
  508. diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
  509. index ed36944467f9..0de76a784a35 100644
  510. --- a/drivers/platform/surface/surface_dtx.c
  511. +++ b/drivers/platform/surface/surface_dtx.c
  512. @@ -71,63 +71,63 @@ static_assert(sizeof(struct ssam_bas_base_info) == 2);
  513. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_lock, {
  514. .target_category = SSAM_SSH_TC_BAS,
  515. - .target_id = 0x01,
  516. + .target_id = SSAM_SSH_TID_SAM,
  517. .command_id = 0x06,
  518. .instance_id = 0x00,
  519. });
  520. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_unlock, {
  521. .target_category = SSAM_SSH_TC_BAS,
  522. - .target_id = 0x01,
  523. + .target_id = SSAM_SSH_TID_SAM,
  524. .command_id = 0x07,
  525. .instance_id = 0x00,
  526. });
  527. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_request, {
  528. .target_category = SSAM_SSH_TC_BAS,
  529. - .target_id = 0x01,
  530. + .target_id = SSAM_SSH_TID_SAM,
  531. .command_id = 0x08,
  532. .instance_id = 0x00,
  533. });
  534. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_confirm, {
  535. .target_category = SSAM_SSH_TC_BAS,
  536. - .target_id = 0x01,
  537. + .target_id = SSAM_SSH_TID_SAM,
  538. .command_id = 0x09,
  539. .instance_id = 0x00,
  540. });
  541. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_heartbeat, {
  542. .target_category = SSAM_SSH_TC_BAS,
  543. - .target_id = 0x01,
  544. + .target_id = SSAM_SSH_TID_SAM,
  545. .command_id = 0x0a,
  546. .instance_id = 0x00,
  547. });
  548. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_cancel, {
  549. .target_category = SSAM_SSH_TC_BAS,
  550. - .target_id = 0x01,
  551. + .target_id = SSAM_SSH_TID_SAM,
  552. .command_id = 0x0b,
  553. .instance_id = 0x00,
  554. });
  555. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_base, struct ssam_bas_base_info, {
  556. .target_category = SSAM_SSH_TC_BAS,
  557. - .target_id = 0x01,
  558. + .target_id = SSAM_SSH_TID_SAM,
  559. .command_id = 0x0c,
  560. .instance_id = 0x00,
  561. });
  562. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_device_mode, u8, {
  563. .target_category = SSAM_SSH_TC_BAS,
  564. - .target_id = 0x01,
  565. + .target_id = SSAM_SSH_TID_SAM,
  566. .command_id = 0x0d,
  567. .instance_id = 0x00,
  568. });
  569. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_latch_status, u8, {
  570. .target_category = SSAM_SSH_TC_BAS,
  571. - .target_id = 0x01,
  572. + .target_id = SSAM_SSH_TID_SAM,
  573. .command_id = 0x11,
  574. .instance_id = 0x00,
  575. });
  576. --
  577. 2.39.1
  578. From 9cc6a8de04a496870726ff69726c004a198530b2 Mon Sep 17 00:00:00 2001
  579. From: Maximilian Luz <luzmaximilian@gmail.com>
  580. Date: Sat, 5 Nov 2022 21:40:06 +0100
  581. Subject: [PATCH] HID: surface-hid: Use target-ID enum instead of hard-coding
  582. values
  583. Instead of hard-coding the target ID, use the respective enum
  584. ssam_ssh_tid value.
  585. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  586. Patchset: surface-sam
  587. ---
  588. drivers/hid/surface-hid/surface_kbd.c | 2 +-
  589. 1 file changed, 1 insertion(+), 1 deletion(-)
  590. diff --git a/drivers/hid/surface-hid/surface_kbd.c b/drivers/hid/surface-hid/surface_kbd.c
  591. index 0635341bc517..42933bf3e925 100644
  592. --- a/drivers/hid/surface-hid/surface_kbd.c
  593. +++ b/drivers/hid/surface-hid/surface_kbd.c
  594. @@ -250,7 +250,7 @@ static int surface_kbd_probe(struct platform_device *pdev)
  595. shid->uid.domain = SSAM_DOMAIN_SERIALHUB;
  596. shid->uid.category = SSAM_SSH_TC_KBD;
  597. - shid->uid.target = 2;
  598. + shid->uid.target = SSAM_SSH_TID_KIP;
  599. shid->uid.instance = 0;
  600. shid->uid.function = 0;
  601. --
  602. 2.39.1
  603. From 54e9685da6a18f97a58838547ad07e3baaa01ebf Mon Sep 17 00:00:00 2001
  604. From: Maximilian Luz <luzmaximilian@gmail.com>
  605. Date: Sat, 5 Nov 2022 21:45:28 +0100
  606. Subject: [PATCH] platform/surface: aggregator: Enforce use of target-ID enum
  607. in device ID macros
  608. Similar to the target category (TC), the target ID (TID) can be one
  609. value out of a small number of choices, given in enum ssam_ssh_tid.
  610. In the device ID macros, SSAM_SDEV() and SSAM_VDEV() we already use text
  611. expansion to, both, remove some textual clutter for the target category
  612. values and enforce that the value belongs to the known set. Now that we
  613. know the names for the target IDs, use the same trick for them as well.
  614. Also rename the SSAM_ANY_x macros to SSAM_SSH_x_ANY to better fit in.
  615. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  616. Patchset: surface-sam
  617. ---
  618. drivers/hid/surface-hid/surface_hid.c | 2 +-
  619. .../platform/surface/surface_aggregator_hub.c | 4 +-
  620. .../surface/surface_aggregator_tabletsw.c | 4 +-
  621. drivers/platform/surface/surface_dtx.c | 2 +-
  622. .../surface/surface_platform_profile.c | 2 +-
  623. drivers/power/supply/surface_battery.c | 4 +-
  624. drivers/power/supply/surface_charger.c | 2 +-
  625. include/linux/surface_aggregator/device.h | 50 +++++++++----------
  626. 8 files changed, 35 insertions(+), 35 deletions(-)
  627. diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
  628. index d4aa8c81903a..aa80d83a83d1 100644
  629. --- a/drivers/hid/surface-hid/surface_hid.c
  630. +++ b/drivers/hid/surface-hid/surface_hid.c
  631. @@ -230,7 +230,7 @@ static void surface_hid_remove(struct ssam_device *sdev)
  632. }
  633. static const struct ssam_device_id surface_hid_match[] = {
  634. - { SSAM_SDEV(HID, SSAM_ANY_TID, SSAM_ANY_IID, 0x00) },
  635. + { SSAM_SDEV(HID, ANY, SSAM_SSH_IID_ANY, 0x00) },
  636. { },
  637. };
  638. MODULE_DEVICE_TABLE(ssam, surface_hid_match);
  639. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  640. index 62f27cdb6ca8..6abd1efe2088 100644
  641. --- a/drivers/platform/surface/surface_aggregator_hub.c
  642. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  643. @@ -348,8 +348,8 @@ static const struct ssam_hub_desc kip_hub = {
  644. /* -- Driver registration. -------------------------------------------------- */
  645. static const struct ssam_device_id ssam_hub_match[] = {
  646. - { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  647. - { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  648. + { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  649. + { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  650. { }
  651. };
  652. MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
  653. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  654. index bd8cd453c393..6147aa887939 100644
  655. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  656. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  657. @@ -510,8 +510,8 @@ static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = {
  658. /* -- Driver registration. -------------------------------------------------- */
  659. static const struct ssam_device_id ssam_tablet_sw_match[] = {
  660. - { SSAM_SDEV(KIP, 0x01, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
  661. - { SSAM_SDEV(POS, 0x01, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
  662. + { SSAM_SDEV(KIP, SAM, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
  663. + { SSAM_SDEV(POS, SAM, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
  664. { },
  665. };
  666. MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match);
  667. diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
  668. index 0de76a784a35..30cbde278c59 100644
  669. --- a/drivers/platform/surface/surface_dtx.c
  670. +++ b/drivers/platform/surface/surface_dtx.c
  671. @@ -1214,7 +1214,7 @@ static void surface_dtx_ssam_remove(struct ssam_device *sdev)
  672. }
  673. static const struct ssam_device_id surface_dtx_ssam_match[] = {
  674. - { SSAM_SDEV(BAS, 0x01, 0x00, 0x00) },
  675. + { SSAM_SDEV(BAS, SAM, 0x00, 0x00) },
  676. { },
  677. };
  678. MODULE_DEVICE_TABLE(ssam, surface_dtx_ssam_match);
  679. diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
  680. index fbf2e11fd6ce..f433a13c3689 100644
  681. --- a/drivers/platform/surface/surface_platform_profile.c
  682. +++ b/drivers/platform/surface/surface_platform_profile.c
  683. @@ -169,7 +169,7 @@ static void surface_platform_profile_remove(struct ssam_device *sdev)
  684. }
  685. static const struct ssam_device_id ssam_platform_profile_match[] = {
  686. - { SSAM_SDEV(TMP, 0x01, 0x00, 0x01) },
  687. + { SSAM_SDEV(TMP, SAM, 0x00, 0x01) },
  688. { },
  689. };
  690. MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match);
  691. diff --git a/drivers/power/supply/surface_battery.c b/drivers/power/supply/surface_battery.c
  692. index 540707882bb0..19d2f8834e56 100644
  693. --- a/drivers/power/supply/surface_battery.c
  694. +++ b/drivers/power/supply/surface_battery.c
  695. @@ -852,8 +852,8 @@ static const struct spwr_psy_properties spwr_psy_props_bat2_sb3 = {
  696. };
  697. static const struct ssam_device_id surface_battery_match[] = {
  698. - { SSAM_SDEV(BAT, 0x01, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
  699. - { SSAM_SDEV(BAT, 0x02, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
  700. + { SSAM_SDEV(BAT, SAM, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
  701. + { SSAM_SDEV(BAT, KIP, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
  702. { },
  703. };
  704. MODULE_DEVICE_TABLE(ssam, surface_battery_match);
  705. diff --git a/drivers/power/supply/surface_charger.c b/drivers/power/supply/surface_charger.c
  706. index 59182d55742d..cabdd8da12d0 100644
  707. --- a/drivers/power/supply/surface_charger.c
  708. +++ b/drivers/power/supply/surface_charger.c
  709. @@ -260,7 +260,7 @@ static const struct spwr_psy_properties spwr_psy_props_adp1 = {
  710. };
  711. static const struct ssam_device_id surface_ac_match[] = {
  712. - { SSAM_SDEV(BAT, 0x01, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
  713. + { SSAM_SDEV(BAT, SAM, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
  714. { },
  715. };
  716. MODULE_DEVICE_TABLE(ssam, surface_ac_match);
  717. diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
  718. index 46c45d1b6368..4da20b7a0ee5 100644
  719. --- a/include/linux/surface_aggregator/device.h
  720. +++ b/include/linux/surface_aggregator/device.h
  721. @@ -68,9 +68,9 @@ struct ssam_device_uid {
  722. * match_flags member of the device ID structure. Do not use them directly
  723. * with struct ssam_device_id or struct ssam_device_uid.
  724. */
  725. -#define SSAM_ANY_TID 0xffff
  726. -#define SSAM_ANY_IID 0xffff
  727. -#define SSAM_ANY_FUN 0xffff
  728. +#define SSAM_SSH_TID_ANY 0xffff
  729. +#define SSAM_SSH_IID_ANY 0xffff
  730. +#define SSAM_SSH_FUN_ANY 0xffff
  731. /**
  732. * SSAM_DEVICE() - Initialize a &struct ssam_device_id with the given
  733. @@ -83,25 +83,25 @@ struct ssam_device_uid {
  734. *
  735. * Initializes a &struct ssam_device_id with the given parameters. See &struct
  736. * ssam_device_uid for details regarding the parameters. The special values
  737. - * %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be used to specify that
  738. + * %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and %SSAM_SSH_FUN_ANY can be used to specify that
  739. * matching should ignore target ID, instance ID, and/or sub-function,
  740. * respectively. This macro initializes the ``match_flags`` field based on the
  741. * given parameters.
  742. *
  743. * Note: The parameters @d and @cat must be valid &u8 values, the parameters
  744. - * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  745. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  746. + * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  747. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
  748. * allowed.
  749. */
  750. #define SSAM_DEVICE(d, cat, tid, iid, fun) \
  751. - .match_flags = (((tid) != SSAM_ANY_TID) ? SSAM_MATCH_TARGET : 0) \
  752. - | (((iid) != SSAM_ANY_IID) ? SSAM_MATCH_INSTANCE : 0) \
  753. - | (((fun) != SSAM_ANY_FUN) ? SSAM_MATCH_FUNCTION : 0), \
  754. + .match_flags = (((tid) != SSAM_SSH_TID_ANY) ? SSAM_MATCH_TARGET : 0) \
  755. + | (((iid) != SSAM_SSH_IID_ANY) ? SSAM_MATCH_INSTANCE : 0) \
  756. + | (((fun) != SSAM_SSH_FUN_ANY) ? SSAM_MATCH_FUNCTION : 0), \
  757. .domain = d, \
  758. .category = cat, \
  759. - .target = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0), \
  760. - .instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0), \
  761. - .function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0)
  762. + .target = __builtin_choose_expr((tid) != SSAM_SSH_TID_ANY, (tid), 0), \
  763. + .instance = __builtin_choose_expr((iid) != SSAM_SSH_IID_ANY, (iid), 0), \
  764. + .function = __builtin_choose_expr((fun) != SSAM_SSH_FUN_ANY, (fun), 0)
  765. /**
  766. * SSAM_VDEV() - Initialize a &struct ssam_device_id as virtual device with
  767. @@ -113,18 +113,18 @@ struct ssam_device_uid {
  768. *
  769. * Initializes a &struct ssam_device_id with the given parameters in the
  770. * virtual domain. See &struct ssam_device_uid for details regarding the
  771. - * parameters. The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and
  772. - * %SSAM_ANY_FUN can be used to specify that matching should ignore target ID,
  773. + * parameters. The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
  774. + * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target ID,
  775. * instance ID, and/or sub-function, respectively. This macro initializes the
  776. * ``match_flags`` field based on the given parameters.
  777. *
  778. * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
  779. - * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  780. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  781. + * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  782. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
  783. * allowed.
  784. */
  785. #define SSAM_VDEV(cat, tid, iid, fun) \
  786. - SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, tid, iid, fun)
  787. + SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
  788. /**
  789. * SSAM_SDEV() - Initialize a &struct ssam_device_id as physical SSH device
  790. @@ -136,18 +136,18 @@ struct ssam_device_uid {
  791. *
  792. * Initializes a &struct ssam_device_id with the given parameters in the SSH
  793. * domain. See &struct ssam_device_uid for details regarding the parameters.
  794. - * The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be
  795. - * used to specify that matching should ignore target ID, instance ID, and/or
  796. - * sub-function, respectively. This macro initializes the ``match_flags``
  797. - * field based on the given parameters.
  798. + * The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
  799. + * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target
  800. + * ID, instance ID, and/or sub-function, respectively. This macro initializes
  801. + * the ``match_flags`` field based on the given parameters.
  802. *
  803. * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
  804. - * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  805. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  806. - * allowed.
  807. + * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  808. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values
  809. + * are not allowed.
  810. */
  811. #define SSAM_SDEV(cat, tid, iid, fun) \
  812. - SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, tid, iid, fun)
  813. + SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
  814. /*
  815. * enum ssam_device_flags - Flags for SSAM client devices.
  816. --
  817. 2.39.1
  818. From 795b4ddb4d3dad38b5123e354b25b327632e0ce5 Mon Sep 17 00:00:00 2001
  819. From: Maximilian Luz <luzmaximilian@gmail.com>
  820. Date: Sat, 5 Nov 2022 21:46:37 +0100
  821. Subject: [PATCH] platform/surface: aggregator_registry: Fix target-ID of
  822. base-hub
  823. The target ID of the base hub is currently set to KIP (keyboard/
  824. peripherals). However, even though it manages such devices with the KIP
  825. target ID, the base hub itself is actually accessed via the SAM target
  826. ID. So set it accordingly.
  827. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  828. Patchset: surface-sam
  829. ---
  830. drivers/platform/surface/surface_aggregator_hub.c | 2 +-
  831. drivers/platform/surface/surface_aggregator_registry.c | 2 +-
  832. 2 files changed, 2 insertions(+), 2 deletions(-)
  833. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  834. index 6abd1efe2088..8b8b80228c14 100644
  835. --- a/drivers/platform/surface/surface_aggregator_hub.c
  836. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  837. @@ -349,7 +349,7 @@ static const struct ssam_hub_desc kip_hub = {
  838. static const struct ssam_device_id ssam_hub_match[] = {
  839. { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  840. - { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  841. + { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  842. { }
  843. };
  844. MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
  845. diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
  846. index 023f126121d7..296f72d52e6a 100644
  847. --- a/drivers/platform/surface/surface_aggregator_registry.c
  848. +++ b/drivers/platform/surface/surface_aggregator_registry.c
  849. @@ -46,7 +46,7 @@ static const struct software_node ssam_node_hub_kip = {
  850. /* Base device hub (devices attached to Surface Book 3 base). */
  851. static const struct software_node ssam_node_hub_base = {
  852. - .name = "ssam:00:00:02:11:00",
  853. + .name = "ssam:00:00:01:11:00",
  854. .parent = &ssam_node_root,
  855. };
  856. --
  857. 2.39.1