0006-surface-sam.patch 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575
  1. From 5c5fa1a9414a4b1ae16bc7af5c0940b53257237e Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Fri, 2 Dec 2022 23:33:20 +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. documentation. 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. Link: https://lore.kernel.org/r/20221202223327.690880-3-luzmaximilian@gmail.com
  15. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  16. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  17. Patchset: surface-sam
  18. ---
  19. .../driver-api/surface_aggregator/client.rst | 4 +-
  20. .../driver-api/surface_aggregator/ssh.rst | 36 +++++++++--------
  21. .../platform/surface/aggregator/controller.c | 12 +++---
  22. .../platform/surface/aggregator/ssh_msgb.h | 4 +-
  23. .../surface/aggregator/ssh_request_layer.c | 11 ++---
  24. include/linux/surface_aggregator/controller.h | 4 +-
  25. include/linux/surface_aggregator/serial_hub.h | 40 +++++++++++++------
  26. 7 files changed, 64 insertions(+), 47 deletions(-)
  27. diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
  28. index 27f95abdbe99..9d7411223a84 100644
  29. --- a/Documentation/driver-api/surface_aggregator/client.rst
  30. +++ b/Documentation/driver-api/surface_aggregator/client.rst
  31. @@ -191,7 +191,7 @@ data received from it is converted from little-endian to host endianness.
  32. * they do not correspond to an actual SAM/EC request.
  33. */
  34. rqst.target_category = SSAM_SSH_TC_SAM;
  35. - rqst.target_id = 0x01;
  36. + rqst.target_id = SSAM_SSH_TID_SAM;
  37. rqst.command_id = 0x02;
  38. rqst.instance_id = 0x03;
  39. rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
  40. @@ -241,7 +241,7 @@ one of the generator macros, for example via:
  41. SSAM_DEFINE_SYNC_REQUEST_W(__ssam_tmp_perf_mode_set, __le32, {
  42. .target_category = SSAM_SSH_TC_TMP,
  43. - .target_id = 0x01,
  44. + .target_id = SSAM_SSH_TID_SAM,
  45. .command_id = 0x03,
  46. .instance_id = 0x00,
  47. });
  48. diff --git a/Documentation/driver-api/surface_aggregator/ssh.rst b/Documentation/driver-api/surface_aggregator/ssh.rst
  49. index bf007d6c9873..18fd0f0aee84 100644
  50. --- a/Documentation/driver-api/surface_aggregator/ssh.rst
  51. +++ b/Documentation/driver-api/surface_aggregator/ssh.rst
  52. @@ -13,6 +13,7 @@
  53. .. |DATA_NSQ| replace:: ``DATA_NSQ``
  54. .. |TC| replace:: ``TC``
  55. .. |TID| replace:: ``TID``
  56. +.. |SID| replace:: ``SID``
  57. .. |IID| replace:: ``IID``
  58. .. |RQID| replace:: ``RQID``
  59. .. |CID| replace:: ``CID``
  60. @@ -219,13 +220,13 @@ following fields, packed together and in order:
  61. - |u8|
  62. - Target category.
  63. - * - |TID| (out)
  64. + * - |TID|
  65. - |u8|
  66. - - Target ID for outgoing (host to EC) commands.
  67. + - Target ID for commands/messages.
  68. - * - |TID| (in)
  69. + * - |SID|
  70. - |u8|
  71. - - Target ID for incoming (EC to host) commands.
  72. + - Source ID for commands/messages.
  73. * - |IID|
  74. - |u8|
  75. @@ -286,19 +287,20 @@ general, however, a single target category should map to a single reserved
  76. event request ID.
  77. Furthermore, requests, responses, and events have an associated target ID
  78. -(``TID``). This target ID is split into output (host to EC) and input (EC to
  79. -host) fields, with the respecting other field (e.g. output field on incoming
  80. -messages) set to zero. Two ``TID`` values are known: Primary (``0x01``) and
  81. -secondary (``0x02``). In general, the response to a request should have the
  82. -same ``TID`` value, however, the field (output vs. input) should be used in
  83. -accordance to the direction in which the response is sent (i.e. on the input
  84. -field, as responses are generally sent from the EC to the host).
  85. -
  86. -Note that, even though requests and events should be uniquely identifiable
  87. -by target category and command ID alone, the EC may require specific
  88. -target ID and instance ID values to accept a command. A command that is
  89. -accepted for ``TID=1``, for example, may not be accepted for ``TID=2``
  90. -and vice versa.
  91. +(``TID``) and source ID (``SID``). These two fields indicate where a message
  92. +originates from (``SID``) and what the intended target of the message is
  93. +(``TID``). Note that a response to a specific request therefore has the source
  94. +and target IDs swapped when compared to the original request (i.e. the request
  95. +target is the response source and the request source is the response target).
  96. +See (:c:type:`enum ssh_request_id <ssh_request_id>`) for possible values of
  97. +both.
  98. +
  99. +Note that, even though requests and events should be uniquely identifiable by
  100. +target category and command ID alone, the EC may require specific target ID and
  101. +instance ID values to accept a command. A command that is accepted for
  102. +``TID=1``, for example, may not be accepted for ``TID=2`` and vice versa. While
  103. +this may not always hold in reality, you can think of different target/source
  104. +IDs indicating different physical ECs with potentially different feature sets.
  105. Limitations and Observations
  106. diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
  107. index c6537a1b3a2e..2c99f51ccd4e 100644
  108. --- a/drivers/platform/surface/aggregator/controller.c
  109. +++ b/drivers/platform/surface/aggregator/controller.c
  110. @@ -994,7 +994,7 @@ static void ssam_handle_event(struct ssh_rtl *rtl,
  111. item->rqid = get_unaligned_le16(&cmd->rqid);
  112. item->event.target_category = cmd->tc;
  113. - item->event.target_id = cmd->tid_in;
  114. + item->event.target_id = cmd->sid;
  115. item->event.command_id = cmd->cid;
  116. item->event.instance_id = cmd->iid;
  117. memcpy(&item->event.data[0], data->ptr, data->len);
  118. @@ -1779,35 +1779,35 @@ EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer);
  119. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_get_firmware_version, __le32, {
  120. .target_category = SSAM_SSH_TC_SAM,
  121. - .target_id = 0x01,
  122. + .target_id = SSAM_SSH_TID_SAM,
  123. .command_id = 0x13,
  124. .instance_id = 0x00,
  125. });
  126. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_off, u8, {
  127. .target_category = SSAM_SSH_TC_SAM,
  128. - .target_id = 0x01,
  129. + .target_id = SSAM_SSH_TID_SAM,
  130. .command_id = 0x15,
  131. .instance_id = 0x00,
  132. });
  133. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_on, u8, {
  134. .target_category = SSAM_SSH_TC_SAM,
  135. - .target_id = 0x01,
  136. + .target_id = SSAM_SSH_TID_SAM,
  137. .command_id = 0x16,
  138. .instance_id = 0x00,
  139. });
  140. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_exit, u8, {
  141. .target_category = SSAM_SSH_TC_SAM,
  142. - .target_id = 0x01,
  143. + .target_id = SSAM_SSH_TID_SAM,
  144. .command_id = 0x33,
  145. .instance_id = 0x00,
  146. });
  147. SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_entry, u8, {
  148. .target_category = SSAM_SSH_TC_SAM,
  149. - .target_id = 0x01,
  150. + .target_id = SSAM_SSH_TID_SAM,
  151. .command_id = 0x34,
  152. .instance_id = 0x00,
  153. });
  154. diff --git a/drivers/platform/surface/aggregator/ssh_msgb.h b/drivers/platform/surface/aggregator/ssh_msgb.h
  155. index f3ecad92eefd..438873e06098 100644
  156. --- a/drivers/platform/surface/aggregator/ssh_msgb.h
  157. +++ b/drivers/platform/surface/aggregator/ssh_msgb.h
  158. @@ -189,8 +189,8 @@ static inline void msgb_push_cmd(struct msgbuf *msgb, u8 seq, u16 rqid,
  159. __msgb_push_u8(msgb, SSH_PLD_TYPE_CMD); /* Payload type. */
  160. __msgb_push_u8(msgb, rqst->target_category); /* Target category. */
  161. - __msgb_push_u8(msgb, rqst->target_id); /* Target ID (out). */
  162. - __msgb_push_u8(msgb, 0x00); /* Target ID (in). */
  163. + __msgb_push_u8(msgb, rqst->target_id); /* Target ID. */
  164. + __msgb_push_u8(msgb, SSAM_SSH_TID_HOST); /* Source ID. */
  165. __msgb_push_u8(msgb, rqst->instance_id); /* Instance ID. */
  166. __msgb_push_u16(msgb, rqid); /* Request ID. */
  167. __msgb_push_u8(msgb, rqst->command_id); /* Command ID. */
  168. diff --git a/drivers/platform/surface/aggregator/ssh_request_layer.c b/drivers/platform/surface/aggregator/ssh_request_layer.c
  169. index 69132976d297..90634dcacabf 100644
  170. --- a/drivers/platform/surface/aggregator/ssh_request_layer.c
  171. +++ b/drivers/platform/surface/aggregator/ssh_request_layer.c
  172. @@ -920,13 +920,14 @@ static void ssh_rtl_rx_command(struct ssh_ptl *p, const struct ssam_span *data)
  173. * Check if the message was intended for us. If not, drop it.
  174. *
  175. * Note: We will need to change this to handle debug messages. On newer
  176. - * generation devices, these seem to be sent to tid_out=0x03. We as
  177. - * host can still receive them as they can be forwarded via an override
  178. - * option on SAM, but doing so does not change tid_out=0x00.
  179. + * generation devices, these seem to be sent to SSAM_SSH_TID_DEBUG. We
  180. + * as host can still receive them as they can be forwarded via an
  181. + * override option on SAM, but doing so does not change the target ID
  182. + * to SSAM_SSH_TID_HOST.
  183. */
  184. - if (command->tid_out != 0x00) {
  185. + if (command->tid != SSAM_SSH_TID_HOST) {
  186. rtl_warn(rtl, "rtl: dropping message not intended for us (tid = %#04x)\n",
  187. - command->tid_out);
  188. + command->tid);
  189. return;
  190. }
  191. diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
  192. index d11a1c6e3186..8932bc0bae18 100644
  193. --- a/include/linux/surface_aggregator/controller.h
  194. +++ b/include/linux/surface_aggregator/controller.h
  195. @@ -912,10 +912,10 @@ enum ssam_event_mask {
  196. })
  197. #define SSAM_EVENT_REGISTRY_SAM \
  198. - SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, 0x01, 0x0b, 0x0c)
  199. + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, SSAM_SSH_TID_SAM, 0x0b, 0x0c)
  200. #define SSAM_EVENT_REGISTRY_KIP \
  201. - SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, 0x02, 0x27, 0x28)
  202. + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, SSAM_SSH_TID_KIP, 0x27, 0x28)
  203. #define SSAM_EVENT_REGISTRY_REG(tid)\
  204. SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, tid, 0x01, 0x02)
  205. diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h
  206. index 45501b6e54e8..5c4ae1a26183 100644
  207. --- a/include/linux/surface_aggregator/serial_hub.h
  208. +++ b/include/linux/surface_aggregator/serial_hub.h
  209. @@ -83,23 +83,21 @@ enum ssh_payload_type {
  210. /**
  211. * struct ssh_command - Payload of a command-type frame.
  212. - * @type: The type of the payload. See &enum ssh_payload_type. Should be
  213. - * SSH_PLD_TYPE_CMD for this struct.
  214. - * @tc: Command target category.
  215. - * @tid_out: Output target ID. Should be zero if this an incoming (EC to host)
  216. - * message.
  217. - * @tid_in: Input target ID. Should be zero if this is an outgoing (host to
  218. - * EC) message.
  219. - * @iid: Instance ID.
  220. - * @rqid: Request ID. Used to match requests with responses and differentiate
  221. - * between responses and events.
  222. - * @cid: Command ID.
  223. + * @type: The type of the payload. See &enum ssh_payload_type. Should be
  224. + * SSH_PLD_TYPE_CMD for this struct.
  225. + * @tc: Command target category.
  226. + * @tid: Target ID. Indicates the target of the message.
  227. + * @sid: Source ID. Indicates the source of the message.
  228. + * @iid: Instance ID.
  229. + * @rqid: Request ID. Used to match requests with responses and differentiate
  230. + * between responses and events.
  231. + * @cid: Command ID.
  232. */
  233. struct ssh_command {
  234. u8 type;
  235. u8 tc;
  236. - u8 tid_out;
  237. - u8 tid_in;
  238. + u8 tid;
  239. + u8 sid;
  240. u8 iid;
  241. __le16 rqid;
  242. u8 cid;
  243. @@ -280,6 +278,22 @@ struct ssam_span {
  244. size_t len;
  245. };
  246. +/**
  247. + * enum ssam_ssh_tid - Target/source IDs for Serial Hub messages.
  248. + * @SSAM_SSH_TID_HOST: We as the kernel Serial Hub driver.
  249. + * @SSAM_SSH_TID_SAM: The Surface Aggregator EC.
  250. + * @SSAM_SSH_TID_KIP: Keyboard and perihperal controller.
  251. + * @SSAM_SSH_TID_DEBUG: Debug connector.
  252. + * @SSAM_SSH_TID_SURFLINK: SurfLink connector.
  253. + */
  254. +enum ssam_ssh_tid {
  255. + SSAM_SSH_TID_HOST = 0x00,
  256. + SSAM_SSH_TID_SAM = 0x01,
  257. + SSAM_SSH_TID_KIP = 0x02,
  258. + SSAM_SSH_TID_DEBUG = 0x03,
  259. + SSAM_SSH_TID_SURFLINK = 0x04,
  260. +};
  261. +
  262. /*
  263. * Known SSH/EC target categories.
  264. *
  265. --
  266. 2.39.1
  267. From 13cf1fcdfafe787ff673f96e3fa8ce196c5c466e Mon Sep 17 00:00:00 2001
  268. From: Maximilian Luz <luzmaximilian@gmail.com>
  269. Date: Fri, 2 Dec 2022 23:33:21 +0100
  270. Subject: [PATCH] platform/surface: aggregator: Add target and source IDs to
  271. command trace events
  272. Add command source and target IDs to trace events.
  273. Tracing support for the Surface Aggregator driver was originally
  274. implemented at a time when only two peers were known: Host and SAM. We
  275. now know that there are at least five, with three actively being used
  276. (Host, SAM, KIP; four with Debug if you want to count manually enabling
  277. that interface). So it makes sense to also explicitly name the peers
  278. involved when tracing.
  279. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  280. Link: https://lore.kernel.org/r/20221202223327.690880-4-luzmaximilian@gmail.com
  281. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  282. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  283. Patchset: surface-sam
  284. ---
  285. drivers/platform/surface/aggregator/trace.h | 73 +++++++++++++++++++--
  286. 1 file changed, 67 insertions(+), 6 deletions(-)
  287. diff --git a/drivers/platform/surface/aggregator/trace.h b/drivers/platform/surface/aggregator/trace.h
  288. index 2a2c17771d01..55cc61bba1da 100644
  289. --- a/drivers/platform/surface/aggregator/trace.h
  290. +++ b/drivers/platform/surface/aggregator/trace.h
  291. @@ -96,6 +96,7 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS);
  292. #define SSAM_SEQ_NOT_APPLICABLE ((u16)-1)
  293. #define SSAM_RQID_NOT_APPLICABLE ((u32)-1)
  294. #define SSAM_SSH_TC_NOT_APPLICABLE 0
  295. +#define SSAM_SSH_TID_NOT_APPLICABLE ((u8)-1)
  296. #ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
  297. #define _SURFACE_AGGREGATOR_TRACE_HELPERS
  298. @@ -150,12 +151,44 @@ static inline u32 ssam_trace_get_request_id(const struct ssh_packet *p)
  299. return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(rqid)]);
  300. }
  301. +/**
  302. + * ssam_trace_get_request_tid() - Read the packet's request target ID.
  303. + * @p: The packet.
  304. + *
  305. + * Return: Returns the packet's request target ID (TID) field if the packet
  306. + * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
  307. + * if not (e.g. flush request, control packet).
  308. + */
  309. +static inline u32 ssam_trace_get_request_tid(const struct ssh_packet *p)
  310. +{
  311. + if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
  312. + return SSAM_SSH_TID_NOT_APPLICABLE;
  313. +
  314. + return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(tid)]);
  315. +}
  316. +
  317. +/**
  318. + * ssam_trace_get_request_sid() - Read the packet's request source ID.
  319. + * @p: The packet.
  320. + *
  321. + * Return: Returns the packet's request source ID (SID) field if the packet
  322. + * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
  323. + * if not (e.g. flush request, control packet).
  324. + */
  325. +static inline u32 ssam_trace_get_request_sid(const struct ssh_packet *p)
  326. +{
  327. + if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
  328. + return SSAM_SSH_TID_NOT_APPLICABLE;
  329. +
  330. + return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(sid)]);
  331. +}
  332. +
  333. /**
  334. * ssam_trace_get_request_tc() - Read the packet's request target category.
  335. * @p: The packet.
  336. *
  337. * Return: Returns the packet's request target category (TC) field if the
  338. - * packet represents a request with command data, or %SSAM_TC_NOT_APPLICABLE
  339. + * packet represents a request with command data, or %SSAM_SSH_TC_NOT_APPLICABLE
  340. * if not (e.g. flush request, control packet).
  341. */
  342. static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
  343. @@ -232,8 +265,18 @@ static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
  344. { SSAM_RQID_NOT_APPLICABLE, "N/A" } \
  345. )
  346. -#define ssam_show_ssh_tc(rqid) \
  347. - __print_symbolic(rqid, \
  348. +#define ssam_show_ssh_tid(tid) \
  349. + __print_symbolic(tid, \
  350. + { SSAM_SSH_TID_NOT_APPLICABLE, "N/A" }, \
  351. + { SSAM_SSH_TID_HOST, "Host" }, \
  352. + { SSAM_SSH_TID_SAM, "SAM" }, \
  353. + { SSAM_SSH_TID_KIP, "KIP" }, \
  354. + { SSAM_SSH_TID_DEBUG, "Debug" }, \
  355. + { SSAM_SSH_TID_SURFLINK, "SurfLink" } \
  356. + )
  357. +
  358. +#define ssam_show_ssh_tc(tc) \
  359. + __print_symbolic(tc, \
  360. { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \
  361. { SSAM_SSH_TC_SAM, "SAM" }, \
  362. { SSAM_SSH_TC_BAT, "BAT" }, \
  363. @@ -313,6 +356,8 @@ DECLARE_EVENT_CLASS(ssam_command_class,
  364. TP_STRUCT__entry(
  365. __field(u16, rqid)
  366. __field(u16, len)
  367. + __field(u8, tid)
  368. + __field(u8, sid)
  369. __field(u8, tc)
  370. __field(u8, cid)
  371. __field(u8, iid)
  372. @@ -320,14 +365,18 @@ DECLARE_EVENT_CLASS(ssam_command_class,
  373. TP_fast_assign(
  374. __entry->rqid = get_unaligned_le16(&cmd->rqid);
  375. + __entry->tid = cmd->tid;
  376. + __entry->sid = cmd->sid;
  377. __entry->tc = cmd->tc;
  378. __entry->cid = cmd->cid;
  379. __entry->iid = cmd->iid;
  380. __entry->len = len;
  381. ),
  382. - TP_printk("rqid=%#06x, tc=%s, cid=%#04x, iid=%#04x, len=%u",
  383. + TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
  384. __entry->rqid,
  385. + ssam_show_ssh_tid(__entry->tid),
  386. + ssam_show_ssh_tid(__entry->sid),
  387. ssam_show_ssh_tc(__entry->tc),
  388. __entry->cid,
  389. __entry->iid,
  390. @@ -430,6 +479,8 @@ DECLARE_EVENT_CLASS(ssam_request_class,
  391. __field(u8, tc)
  392. __field(u16, cid)
  393. __field(u16, iid)
  394. + __field(u8, tid)
  395. + __field(u8, sid)
  396. ),
  397. TP_fast_assign(
  398. @@ -439,16 +490,20 @@ DECLARE_EVENT_CLASS(ssam_request_class,
  399. __entry->state = READ_ONCE(request->state);
  400. __entry->rqid = ssam_trace_get_request_id(p);
  401. ssam_trace_ptr_uid(p, __entry->uid);
  402. + __entry->tid = ssam_trace_get_request_tid(p);
  403. + __entry->sid = ssam_trace_get_request_sid(p);
  404. __entry->tc = ssam_trace_get_request_tc(p);
  405. __entry->cid = ssam_trace_get_command_field_u8(p, cid);
  406. __entry->iid = ssam_trace_get_command_field_u8(p, iid);
  407. ),
  408. - TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s",
  409. + TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
  410. __entry->uid,
  411. ssam_show_request_id(__entry->rqid),
  412. ssam_show_request_type(__entry->state),
  413. ssam_show_request_state(__entry->state),
  414. + ssam_show_ssh_tid(__entry->tid),
  415. + ssam_show_ssh_tid(__entry->sid),
  416. ssam_show_ssh_tc(__entry->tc),
  417. ssam_show_generic_u8_field(__entry->cid),
  418. ssam_show_generic_u8_field(__entry->iid)
  419. @@ -474,6 +529,8 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
  420. __field(u8, tc)
  421. __field(u16, cid)
  422. __field(u16, iid)
  423. + __field(u8, tid)
  424. + __field(u8, sid)
  425. ),
  426. TP_fast_assign(
  427. @@ -484,16 +541,20 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
  428. __entry->rqid = ssam_trace_get_request_id(p);
  429. __entry->status = status;
  430. ssam_trace_ptr_uid(p, __entry->uid);
  431. + __entry->tid = ssam_trace_get_request_tid(p);
  432. + __entry->sid = ssam_trace_get_request_sid(p);
  433. __entry->tc = ssam_trace_get_request_tc(p);
  434. __entry->cid = ssam_trace_get_command_field_u8(p, cid);
  435. __entry->iid = ssam_trace_get_command_field_u8(p, iid);
  436. ),
  437. - TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s, status=%d",
  438. + TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
  439. __entry->uid,
  440. ssam_show_request_id(__entry->rqid),
  441. ssam_show_request_type(__entry->state),
  442. ssam_show_request_state(__entry->state),
  443. + ssam_show_ssh_tid(__entry->tid),
  444. + ssam_show_ssh_tid(__entry->sid),
  445. ssam_show_ssh_tc(__entry->tc),
  446. ssam_show_generic_u8_field(__entry->cid),
  447. ssam_show_generic_u8_field(__entry->iid),
  448. --
  449. 2.39.1
  450. From 7558c159d840b408065804b66d740ff52fd3825c Mon Sep 17 00:00:00 2001
  451. From: Maximilian Luz <luzmaximilian@gmail.com>
  452. Date: Fri, 2 Dec 2022 23:33:22 +0100
  453. Subject: [PATCH] platform/surface: aggregator_hub: Use target-ID enum instead
  454. of hard-coding values
  455. Instead of hard-coding the target ID, use the respective enum
  456. ssam_ssh_tid value.
  457. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  458. Link: https://lore.kernel.org/r/20221202223327.690880-5-luzmaximilian@gmail.com
  459. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  460. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  461. Patchset: surface-sam
  462. ---
  463. drivers/platform/surface/surface_aggregator_hub.c | 4 ++--
  464. 1 file changed, 2 insertions(+), 2 deletions(-)
  465. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  466. index 43061514be38..62f27cdb6ca8 100644
  467. --- a/drivers/platform/surface/surface_aggregator_hub.c
  468. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  469. @@ -214,7 +214,7 @@ static void ssam_hub_remove(struct ssam_device *sdev)
  470. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_query_opmode, u8, {
  471. .target_category = SSAM_SSH_TC_BAS,
  472. - .target_id = 0x01,
  473. + .target_id = SSAM_SSH_TID_SAM,
  474. .command_id = 0x0d,
  475. .instance_id = 0x00,
  476. });
  477. @@ -292,7 +292,7 @@ static const struct ssam_hub_desc base_hub = {
  478. SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_query_state, u8, {
  479. .target_category = SSAM_SSH_TC_KIP,
  480. - .target_id = 0x01,
  481. + .target_id = SSAM_SSH_TID_SAM,
  482. .command_id = 0x2c,
  483. .instance_id = 0x00,
  484. });
  485. --
  486. 2.39.1
  487. From b57521c09754e523fff0b1fce8a351d061380377 Mon Sep 17 00:00:00 2001
  488. From: Maximilian Luz <luzmaximilian@gmail.com>
  489. Date: Fri, 2 Dec 2022 23:33:23 +0100
  490. Subject: [PATCH] platform/surface: aggregator_tabletsw: Use target-ID enum
  491. instead of hard-coding values
  492. Instead of hard-coding the target ID, use the respective enum
  493. ssam_ssh_tid value.
  494. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  495. Link: https://lore.kernel.org/r/20221202223327.690880-6-luzmaximilian@gmail.com
  496. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  497. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  498. Patchset: surface-sam
  499. ---
  500. drivers/platform/surface/surface_aggregator_tabletsw.c | 6 +++---
  501. 1 file changed, 3 insertions(+), 3 deletions(-)
  502. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  503. index 27d95a6a7851..bd8cd453c393 100644
  504. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  505. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  506. @@ -247,7 +247,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 s
  507. SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
  508. .target_category = SSAM_SSH_TC_KIP,
  509. - .target_id = 0x01,
  510. + .target_id = SSAM_SSH_TID_SAM,
  511. .command_id = 0x1d,
  512. .instance_id = 0x00,
  513. });
  514. @@ -371,7 +371,7 @@ static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sour
  515. int status;
  516. rqst.target_category = SSAM_SSH_TC_POS;
  517. - rqst.target_id = 0x01;
  518. + rqst.target_id = SSAM_SSH_TID_SAM;
  519. rqst.command_id = 0x01;
  520. rqst.instance_id = 0x00;
  521. rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
  522. @@ -430,7 +430,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
  523. SSAM_DEFINE_SYNC_REQUEST_WR(__ssam_pos_get_posture_for_source, __le32, __le32, {
  524. .target_category = SSAM_SSH_TC_POS,
  525. - .target_id = 0x01,
  526. + .target_id = SSAM_SSH_TID_SAM,
  527. .command_id = 0x02,
  528. .instance_id = 0x00,
  529. });
  530. --
  531. 2.39.1
  532. From ac38b3ca24a7a17ec55fc364c992c06cdad8011c Mon Sep 17 00:00:00 2001
  533. From: Maximilian Luz <luzmaximilian@gmail.com>
  534. Date: Fri, 2 Dec 2022 23:33:24 +0100
  535. Subject: [PATCH] platform/surface: dtx: Use target-ID enum instead of
  536. hard-coding values
  537. Instead of hard-coding the target ID, use the respective enum
  538. ssam_ssh_tid value.
  539. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  540. Link: https://lore.kernel.org/r/20221202223327.690880-7-luzmaximilian@gmail.com
  541. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  542. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  543. Patchset: surface-sam
  544. ---
  545. drivers/platform/surface/surface_dtx.c | 18 +++++++++---------
  546. 1 file changed, 9 insertions(+), 9 deletions(-)
  547. diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
  548. index ed36944467f9..0de76a784a35 100644
  549. --- a/drivers/platform/surface/surface_dtx.c
  550. +++ b/drivers/platform/surface/surface_dtx.c
  551. @@ -71,63 +71,63 @@ static_assert(sizeof(struct ssam_bas_base_info) == 2);
  552. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_lock, {
  553. .target_category = SSAM_SSH_TC_BAS,
  554. - .target_id = 0x01,
  555. + .target_id = SSAM_SSH_TID_SAM,
  556. .command_id = 0x06,
  557. .instance_id = 0x00,
  558. });
  559. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_unlock, {
  560. .target_category = SSAM_SSH_TC_BAS,
  561. - .target_id = 0x01,
  562. + .target_id = SSAM_SSH_TID_SAM,
  563. .command_id = 0x07,
  564. .instance_id = 0x00,
  565. });
  566. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_request, {
  567. .target_category = SSAM_SSH_TC_BAS,
  568. - .target_id = 0x01,
  569. + .target_id = SSAM_SSH_TID_SAM,
  570. .command_id = 0x08,
  571. .instance_id = 0x00,
  572. });
  573. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_confirm, {
  574. .target_category = SSAM_SSH_TC_BAS,
  575. - .target_id = 0x01,
  576. + .target_id = SSAM_SSH_TID_SAM,
  577. .command_id = 0x09,
  578. .instance_id = 0x00,
  579. });
  580. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_heartbeat, {
  581. .target_category = SSAM_SSH_TC_BAS,
  582. - .target_id = 0x01,
  583. + .target_id = SSAM_SSH_TID_SAM,
  584. .command_id = 0x0a,
  585. .instance_id = 0x00,
  586. });
  587. SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_cancel, {
  588. .target_category = SSAM_SSH_TC_BAS,
  589. - .target_id = 0x01,
  590. + .target_id = SSAM_SSH_TID_SAM,
  591. .command_id = 0x0b,
  592. .instance_id = 0x00,
  593. });
  594. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_base, struct ssam_bas_base_info, {
  595. .target_category = SSAM_SSH_TC_BAS,
  596. - .target_id = 0x01,
  597. + .target_id = SSAM_SSH_TID_SAM,
  598. .command_id = 0x0c,
  599. .instance_id = 0x00,
  600. });
  601. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_device_mode, u8, {
  602. .target_category = SSAM_SSH_TC_BAS,
  603. - .target_id = 0x01,
  604. + .target_id = SSAM_SSH_TID_SAM,
  605. .command_id = 0x0d,
  606. .instance_id = 0x00,
  607. });
  608. SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_latch_status, u8, {
  609. .target_category = SSAM_SSH_TC_BAS,
  610. - .target_id = 0x01,
  611. + .target_id = SSAM_SSH_TID_SAM,
  612. .command_id = 0x11,
  613. .instance_id = 0x00,
  614. });
  615. --
  616. 2.39.1
  617. From a3658f509048591fcce462c4fa7a69030f5f2a2f Mon Sep 17 00:00:00 2001
  618. From: Maximilian Luz <luzmaximilian@gmail.com>
  619. Date: Fri, 2 Dec 2022 23:33:26 +0100
  620. Subject: [PATCH] platform/surface: aggregator: Enforce use of target-ID enum
  621. in device ID macros
  622. Similar to the target category (TC), the target ID (TID) can be one
  623. value out of a small number of choices, given in enum ssam_ssh_tid.
  624. In the device ID macros, SSAM_SDEV() and SSAM_VDEV() we already use text
  625. expansion to, both, remove some textual clutter for the target category
  626. values and enforce that the value belongs to the known set. Now that we
  627. know the names for the target IDs, use the same trick for them as well.
  628. Also rename the SSAM_ANY_x macros to SSAM_SSH_x_ANY to better fit in.
  629. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  630. Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
  631. Link: https://lore.kernel.org/r/20221202223327.690880-9-luzmaximilian@gmail.com
  632. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  633. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  634. Patchset: surface-sam
  635. ---
  636. drivers/hid/surface-hid/surface_hid.c | 2 +-
  637. .../platform/surface/surface_aggregator_hub.c | 4 +-
  638. .../surface/surface_aggregator_tabletsw.c | 4 +-
  639. drivers/platform/surface/surface_dtx.c | 2 +-
  640. .../surface/surface_platform_profile.c | 2 +-
  641. drivers/power/supply/surface_battery.c | 4 +-
  642. drivers/power/supply/surface_charger.c | 2 +-
  643. include/linux/surface_aggregator/device.h | 50 +++++++++----------
  644. 8 files changed, 35 insertions(+), 35 deletions(-)
  645. diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
  646. index d4aa8c81903a..aa80d83a83d1 100644
  647. --- a/drivers/hid/surface-hid/surface_hid.c
  648. +++ b/drivers/hid/surface-hid/surface_hid.c
  649. @@ -230,7 +230,7 @@ static void surface_hid_remove(struct ssam_device *sdev)
  650. }
  651. static const struct ssam_device_id surface_hid_match[] = {
  652. - { SSAM_SDEV(HID, SSAM_ANY_TID, SSAM_ANY_IID, 0x00) },
  653. + { SSAM_SDEV(HID, ANY, SSAM_SSH_IID_ANY, 0x00) },
  654. { },
  655. };
  656. MODULE_DEVICE_TABLE(ssam, surface_hid_match);
  657. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  658. index 62f27cdb6ca8..6abd1efe2088 100644
  659. --- a/drivers/platform/surface/surface_aggregator_hub.c
  660. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  661. @@ -348,8 +348,8 @@ static const struct ssam_hub_desc kip_hub = {
  662. /* -- Driver registration. -------------------------------------------------- */
  663. static const struct ssam_device_id ssam_hub_match[] = {
  664. - { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  665. - { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  666. + { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  667. + { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  668. { }
  669. };
  670. MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
  671. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  672. index bd8cd453c393..6147aa887939 100644
  673. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  674. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  675. @@ -510,8 +510,8 @@ static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = {
  676. /* -- Driver registration. -------------------------------------------------- */
  677. static const struct ssam_device_id ssam_tablet_sw_match[] = {
  678. - { SSAM_SDEV(KIP, 0x01, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
  679. - { SSAM_SDEV(POS, 0x01, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
  680. + { SSAM_SDEV(KIP, SAM, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
  681. + { SSAM_SDEV(POS, SAM, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
  682. { },
  683. };
  684. MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match);
  685. diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
  686. index 0de76a784a35..30cbde278c59 100644
  687. --- a/drivers/platform/surface/surface_dtx.c
  688. +++ b/drivers/platform/surface/surface_dtx.c
  689. @@ -1214,7 +1214,7 @@ static void surface_dtx_ssam_remove(struct ssam_device *sdev)
  690. }
  691. static const struct ssam_device_id surface_dtx_ssam_match[] = {
  692. - { SSAM_SDEV(BAS, 0x01, 0x00, 0x00) },
  693. + { SSAM_SDEV(BAS, SAM, 0x00, 0x00) },
  694. { },
  695. };
  696. MODULE_DEVICE_TABLE(ssam, surface_dtx_ssam_match);
  697. diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
  698. index fbf2e11fd6ce..f433a13c3689 100644
  699. --- a/drivers/platform/surface/surface_platform_profile.c
  700. +++ b/drivers/platform/surface/surface_platform_profile.c
  701. @@ -169,7 +169,7 @@ static void surface_platform_profile_remove(struct ssam_device *sdev)
  702. }
  703. static const struct ssam_device_id ssam_platform_profile_match[] = {
  704. - { SSAM_SDEV(TMP, 0x01, 0x00, 0x01) },
  705. + { SSAM_SDEV(TMP, SAM, 0x00, 0x01) },
  706. { },
  707. };
  708. MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match);
  709. diff --git a/drivers/power/supply/surface_battery.c b/drivers/power/supply/surface_battery.c
  710. index 540707882bb0..19d2f8834e56 100644
  711. --- a/drivers/power/supply/surface_battery.c
  712. +++ b/drivers/power/supply/surface_battery.c
  713. @@ -852,8 +852,8 @@ static const struct spwr_psy_properties spwr_psy_props_bat2_sb3 = {
  714. };
  715. static const struct ssam_device_id surface_battery_match[] = {
  716. - { SSAM_SDEV(BAT, 0x01, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
  717. - { SSAM_SDEV(BAT, 0x02, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
  718. + { SSAM_SDEV(BAT, SAM, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
  719. + { SSAM_SDEV(BAT, KIP, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
  720. { },
  721. };
  722. MODULE_DEVICE_TABLE(ssam, surface_battery_match);
  723. diff --git a/drivers/power/supply/surface_charger.c b/drivers/power/supply/surface_charger.c
  724. index 59182d55742d..cabdd8da12d0 100644
  725. --- a/drivers/power/supply/surface_charger.c
  726. +++ b/drivers/power/supply/surface_charger.c
  727. @@ -260,7 +260,7 @@ static const struct spwr_psy_properties spwr_psy_props_adp1 = {
  728. };
  729. static const struct ssam_device_id surface_ac_match[] = {
  730. - { SSAM_SDEV(BAT, 0x01, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
  731. + { SSAM_SDEV(BAT, SAM, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
  732. { },
  733. };
  734. MODULE_DEVICE_TABLE(ssam, surface_ac_match);
  735. diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
  736. index 46c45d1b6368..4da20b7a0ee5 100644
  737. --- a/include/linux/surface_aggregator/device.h
  738. +++ b/include/linux/surface_aggregator/device.h
  739. @@ -68,9 +68,9 @@ struct ssam_device_uid {
  740. * match_flags member of the device ID structure. Do not use them directly
  741. * with struct ssam_device_id or struct ssam_device_uid.
  742. */
  743. -#define SSAM_ANY_TID 0xffff
  744. -#define SSAM_ANY_IID 0xffff
  745. -#define SSAM_ANY_FUN 0xffff
  746. +#define SSAM_SSH_TID_ANY 0xffff
  747. +#define SSAM_SSH_IID_ANY 0xffff
  748. +#define SSAM_SSH_FUN_ANY 0xffff
  749. /**
  750. * SSAM_DEVICE() - Initialize a &struct ssam_device_id with the given
  751. @@ -83,25 +83,25 @@ struct ssam_device_uid {
  752. *
  753. * Initializes a &struct ssam_device_id with the given parameters. See &struct
  754. * ssam_device_uid for details regarding the parameters. The special values
  755. - * %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be used to specify that
  756. + * %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and %SSAM_SSH_FUN_ANY can be used to specify that
  757. * matching should ignore target ID, instance ID, and/or sub-function,
  758. * respectively. This macro initializes the ``match_flags`` field based on the
  759. * given parameters.
  760. *
  761. * Note: The parameters @d and @cat must be valid &u8 values, the parameters
  762. - * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  763. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  764. + * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  765. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
  766. * allowed.
  767. */
  768. #define SSAM_DEVICE(d, cat, tid, iid, fun) \
  769. - .match_flags = (((tid) != SSAM_ANY_TID) ? SSAM_MATCH_TARGET : 0) \
  770. - | (((iid) != SSAM_ANY_IID) ? SSAM_MATCH_INSTANCE : 0) \
  771. - | (((fun) != SSAM_ANY_FUN) ? SSAM_MATCH_FUNCTION : 0), \
  772. + .match_flags = (((tid) != SSAM_SSH_TID_ANY) ? SSAM_MATCH_TARGET : 0) \
  773. + | (((iid) != SSAM_SSH_IID_ANY) ? SSAM_MATCH_INSTANCE : 0) \
  774. + | (((fun) != SSAM_SSH_FUN_ANY) ? SSAM_MATCH_FUNCTION : 0), \
  775. .domain = d, \
  776. .category = cat, \
  777. - .target = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0), \
  778. - .instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0), \
  779. - .function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0)
  780. + .target = __builtin_choose_expr((tid) != SSAM_SSH_TID_ANY, (tid), 0), \
  781. + .instance = __builtin_choose_expr((iid) != SSAM_SSH_IID_ANY, (iid), 0), \
  782. + .function = __builtin_choose_expr((fun) != SSAM_SSH_FUN_ANY, (fun), 0)
  783. /**
  784. * SSAM_VDEV() - Initialize a &struct ssam_device_id as virtual device with
  785. @@ -113,18 +113,18 @@ struct ssam_device_uid {
  786. *
  787. * Initializes a &struct ssam_device_id with the given parameters in the
  788. * virtual domain. See &struct ssam_device_uid for details regarding the
  789. - * parameters. The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and
  790. - * %SSAM_ANY_FUN can be used to specify that matching should ignore target ID,
  791. + * parameters. The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
  792. + * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target ID,
  793. * instance ID, and/or sub-function, respectively. This macro initializes the
  794. * ``match_flags`` field based on the given parameters.
  795. *
  796. * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
  797. - * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  798. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  799. + * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  800. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
  801. * allowed.
  802. */
  803. #define SSAM_VDEV(cat, tid, iid, fun) \
  804. - SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, tid, iid, fun)
  805. + SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
  806. /**
  807. * SSAM_SDEV() - Initialize a &struct ssam_device_id as physical SSH device
  808. @@ -136,18 +136,18 @@ struct ssam_device_uid {
  809. *
  810. * Initializes a &struct ssam_device_id with the given parameters in the SSH
  811. * domain. See &struct ssam_device_uid for details regarding the parameters.
  812. - * The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be
  813. - * used to specify that matching should ignore target ID, instance ID, and/or
  814. - * sub-function, respectively. This macro initializes the ``match_flags``
  815. - * field based on the given parameters.
  816. + * The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
  817. + * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target
  818. + * ID, instance ID, and/or sub-function, respectively. This macro initializes
  819. + * the ``match_flags`` field based on the given parameters.
  820. *
  821. * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
  822. - * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
  823. - * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
  824. - * allowed.
  825. + * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
  826. + * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values
  827. + * are not allowed.
  828. */
  829. #define SSAM_SDEV(cat, tid, iid, fun) \
  830. - SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, tid, iid, fun)
  831. + SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
  832. /*
  833. * enum ssam_device_flags - Flags for SSAM client devices.
  834. --
  835. 2.39.1
  836. From ce70c31c9612629949d933d5ba4086309a7b940f Mon Sep 17 00:00:00 2001
  837. From: Maximilian Luz <luzmaximilian@gmail.com>
  838. Date: Fri, 2 Dec 2022 23:33:27 +0100
  839. Subject: [PATCH] platform/surface: aggregator_registry: Fix target-ID of
  840. base-hub
  841. The target ID of the base hub is currently set to KIP (keyboard/
  842. peripherals). However, even though it manages such devices with the KIP
  843. target ID, the base hub itself is actually accessed via the SAM target
  844. ID. So set it accordingly.
  845. Note that the target ID of the hub can be chosen arbitrarily and does
  846. not directly correspond to any physical or virtual component of the EC.
  847. This change is only a code improvement intended for consistency and
  848. clarity, it does not fix an actual bug.
  849. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  850. Link: https://lore.kernel.org/r/20221202223327.690880-10-luzmaximilian@gmail.com
  851. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  852. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  853. Patchset: surface-sam
  854. ---
  855. drivers/platform/surface/surface_aggregator_hub.c | 2 +-
  856. drivers/platform/surface/surface_aggregator_registry.c | 2 +-
  857. 2 files changed, 2 insertions(+), 2 deletions(-)
  858. diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
  859. index 6abd1efe2088..8b8b80228c14 100644
  860. --- a/drivers/platform/surface/surface_aggregator_hub.c
  861. +++ b/drivers/platform/surface/surface_aggregator_hub.c
  862. @@ -349,7 +349,7 @@ static const struct ssam_hub_desc kip_hub = {
  863. static const struct ssam_device_id ssam_hub_match[] = {
  864. { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
  865. - { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  866. + { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
  867. { }
  868. };
  869. MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
  870. diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
  871. index 023f126121d7..296f72d52e6a 100644
  872. --- a/drivers/platform/surface/surface_aggregator_registry.c
  873. +++ b/drivers/platform/surface/surface_aggregator_registry.c
  874. @@ -46,7 +46,7 @@ static const struct software_node ssam_node_hub_kip = {
  875. /* Base device hub (devices attached to Surface Book 3 base). */
  876. static const struct software_node ssam_node_hub_base = {
  877. - .name = "ssam:00:00:02:11:00",
  878. + .name = "ssam:00:00:01:11:00",
  879. .parent = &ssam_node_root,
  880. };
  881. --
  882. 2.39.1
  883. From d48e58e62f0cf34197267f1905b7f98259ca5a6e Mon Sep 17 00:00:00 2001
  884. From: Maximilian Luz <luzmaximilian@gmail.com>
  885. Date: Tue, 20 Dec 2022 18:56:08 +0100
  886. Subject: [PATCH] platform/surface: aggregator: Rename top-level request
  887. functions to avoid ambiguities
  888. We currently have a struct ssam_request_sync and a function
  889. ssam_request_sync(). While this is valid C, there are some downsides to
  890. it.
  891. One of these is that current Sphinx versions (>= 3.0) cannot
  892. disambiguate between the two (see disucssion and pull request linked
  893. below). It instead emits a "WARNING: Duplicate C declaration" and links
  894. for the struct and function in the resulting documentation link to the
  895. same entry (i.e. both to either function or struct documentation)
  896. instead of their respective own entries.
  897. While we could just ignore that and wait for a fix, there's also a point
  898. to be made that the current naming can be somewhat confusing when
  899. searching (e.g. via grep) or trying to understand the levels of
  900. abstraction at play:
  901. We currently have struct ssam_request_sync and associated functions
  902. ssam_request_sync_[alloc|free|init|wait|...]() operating on this struct.
  903. However, function ssam_request_sync() is one abstraction level above
  904. this. Similarly, ssam_request_sync_with_buffer() is not a function
  905. operating on struct ssam_request_sync, but rather a sibling to
  906. ssam_request_sync(), both using the struct under the hood.
  907. Therefore, rename the top level request functions:
  908. ssam_request_sync() -> ssam_request_do_sync()
  909. ssam_request_sync_with_buffer() -> ssam_request_do_sync_with_buffer()
  910. ssam_request_sync_onstack() -> ssam_request_do_sync_onstack()
  911. Link: https://lore.kernel.org/all/085e0ada65c11da9303d07e70c510dc45f21315b.1656756450.git.mchehab@kernel.org/
  912. Link: https://github.com/sphinx-doc/sphinx/pull/8313
  913. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  914. Link: https://lore.kernel.org/r/20221220175608.1436273-2-luzmaximilian@gmail.com
  915. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  916. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  917. Patchset: surface-sam
  918. ---
  919. .../driver-api/surface_aggregator/client.rst | 8 +--
  920. drivers/hid/surface-hid/surface_hid.c | 6 +-
  921. drivers/hid/surface-hid/surface_kbd.c | 6 +-
  922. drivers/platform/surface/aggregator/bus.c | 6 +-
  923. .../platform/surface/aggregator/controller.c | 32 +++++------
  924. .../platform/surface/surface_acpi_notify.c | 2 +-
  925. .../surface/surface_aggregator_cdev.c | 6 +-
  926. .../surface/surface_aggregator_tabletsw.c | 2 +-
  927. include/linux/surface_aggregator/controller.h | 56 +++++++++----------
  928. include/linux/surface_aggregator/device.h | 8 +--
  929. 10 files changed, 66 insertions(+), 66 deletions(-)
  930. diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
  931. index 9d7411223a84..e100ab0a24cc 100644
  932. --- a/Documentation/driver-api/surface_aggregator/client.rst
  933. +++ b/Documentation/driver-api/surface_aggregator/client.rst
  934. @@ -19,7 +19,7 @@
  935. .. |ssam_notifier_unregister| replace:: :c:func:`ssam_notifier_unregister`
  936. .. |ssam_device_notifier_register| replace:: :c:func:`ssam_device_notifier_register`
  937. .. |ssam_device_notifier_unregister| replace:: :c:func:`ssam_device_notifier_unregister`
  938. -.. |ssam_request_sync| replace:: :c:func:`ssam_request_sync`
  939. +.. |ssam_request_do_sync| replace:: :c:func:`ssam_request_do_sync`
  940. .. |ssam_event_mask| replace:: :c:type:`enum ssam_event_mask <ssam_event_mask>`
  941. @@ -209,12 +209,12 @@ data received from it is converted from little-endian to host endianness.
  942. * with the SSAM_REQUEST_HAS_RESPONSE flag set in the specification
  943. * above.
  944. */
  945. - status = ssam_request_sync(ctrl, &rqst, &resp);
  946. + status = ssam_request_do_sync(ctrl, &rqst, &resp);
  947. /*
  948. * Alternatively use
  949. *
  950. - * ssam_request_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
  951. + * ssam_request_do_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
  952. *
  953. * to perform the request, allocating the message buffer directly
  954. * on the stack as opposed to allocation via kzalloc().
  955. @@ -230,7 +230,7 @@ data received from it is converted from little-endian to host endianness.
  956. return status;
  957. }
  958. -Note that |ssam_request_sync| in its essence is a wrapper over lower-level
  959. +Note that |ssam_request_do_sync| in its essence is a wrapper over lower-level
  960. request primitives, which may also be used to perform requests. Refer to its
  961. implementation and documentation for more details.
  962. diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
  963. index aa80d83a83d1..61e5814b0ad7 100644
  964. --- a/drivers/hid/surface-hid/surface_hid.c
  965. +++ b/drivers/hid/surface-hid/surface_hid.c
  966. @@ -80,7 +80,7 @@ static int ssam_hid_get_descriptor(struct surface_hid_device *shid, u8 entry, u8
  967. rsp.length = 0;
  968. - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
  969. + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp,
  970. sizeof(*slice));
  971. if (status)
  972. return status;
  973. @@ -131,7 +131,7 @@ static int ssam_hid_set_raw_report(struct surface_hid_device *shid, u8 rprt_id,
  974. buf[0] = rprt_id;
  975. - return ssam_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
  976. + return ssam_retry(ssam_request_do_sync, shid->ctrl, &rqst, NULL);
  977. }
  978. static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len)
  979. @@ -151,7 +151,7 @@ static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id,
  980. rsp.length = 0;
  981. rsp.pointer = buf;
  982. - return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id));
  983. + return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id));
  984. }
  985. static u32 ssam_hid_event_fn(struct ssam_event_notifier *nf, const struct ssam_event *event)
  986. diff --git a/drivers/hid/surface-hid/surface_kbd.c b/drivers/hid/surface-hid/surface_kbd.c
  987. index 0635341bc517..7ca8038026ce 100644
  988. --- a/drivers/hid/surface-hid/surface_kbd.c
  989. +++ b/drivers/hid/surface-hid/surface_kbd.c
  990. @@ -49,7 +49,7 @@ static int ssam_kbd_get_descriptor(struct surface_hid_device *shid, u8 entry, u8
  991. rsp.length = 0;
  992. rsp.pointer = buf;
  993. - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry));
  994. + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry));
  995. if (status)
  996. return status;
  997. @@ -75,7 +75,7 @@ static int ssam_kbd_set_caps_led(struct surface_hid_device *shid, bool value)
  998. rqst.length = sizeof(value_u8);
  999. rqst.payload = &value_u8;
  1000. - return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8));
  1001. + return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8));
  1002. }
  1003. static int ssam_kbd_get_feature_report(struct surface_hid_device *shid, u8 *buf, size_t len)
  1004. @@ -97,7 +97,7 @@ static int ssam_kbd_get_feature_report(struct surface_hid_device *shid, u8 *buf,
  1005. rsp.length = 0;
  1006. rsp.pointer = buf;
  1007. - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload));
  1008. + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload));
  1009. if (status)
  1010. return status;
  1011. diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
  1012. index de539938896e..7004eb4a63a2 100644
  1013. --- a/drivers/platform/surface/aggregator/bus.c
  1014. +++ b/drivers/platform/surface/aggregator/bus.c
  1015. @@ -136,9 +136,9 @@ int ssam_device_add(struct ssam_device *sdev)
  1016. * is always valid and can be used for requests as long as the client
  1017. * device we add here is registered as child under it. This essentially
  1018. * guarantees that the client driver can always expect the preconditions
  1019. - * for functions like ssam_request_sync (controller has to be started
  1020. - * and is not suspended) to hold and thus does not have to check for
  1021. - * them.
  1022. + * for functions like ssam_request_do_sync() (controller has to be
  1023. + * started and is not suspended) to hold and thus does not have to check
  1024. + * for them.
  1025. *
  1026. * Note that for this to work, the controller has to be a parent device.
  1027. * If it is not a direct parent, care has to be taken that the device is
  1028. diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
  1029. index 2c99f51ccd4e..535581c0471c 100644
  1030. --- a/drivers/platform/surface/aggregator/controller.c
  1031. +++ b/drivers/platform/surface/aggregator/controller.c
  1032. @@ -1674,7 +1674,7 @@ int ssam_request_sync_submit(struct ssam_controller *ctrl,
  1033. EXPORT_SYMBOL_GPL(ssam_request_sync_submit);
  1034. /**
  1035. - * ssam_request_sync() - Execute a synchronous request.
  1036. + * ssam_request_do_sync() - Execute a synchronous request.
  1037. * @ctrl: The controller via which the request will be submitted.
  1038. * @spec: The request specification and payload.
  1039. * @rsp: The response buffer.
  1040. @@ -1686,9 +1686,9 @@ EXPORT_SYMBOL_GPL(ssam_request_sync_submit);
  1041. *
  1042. * Return: Returns the status of the request or any failure during setup.
  1043. */
  1044. -int ssam_request_sync(struct ssam_controller *ctrl,
  1045. - const struct ssam_request *spec,
  1046. - struct ssam_response *rsp)
  1047. +int ssam_request_do_sync(struct ssam_controller *ctrl,
  1048. + const struct ssam_request *spec,
  1049. + struct ssam_response *rsp)
  1050. {
  1051. struct ssam_request_sync *rqst;
  1052. struct ssam_span buf;
  1053. @@ -1722,10 +1722,10 @@ int ssam_request_sync(struct ssam_controller *ctrl,
  1054. ssam_request_sync_free(rqst);
  1055. return status;
  1056. }
  1057. -EXPORT_SYMBOL_GPL(ssam_request_sync);
  1058. +EXPORT_SYMBOL_GPL(ssam_request_do_sync);
  1059. /**
  1060. - * ssam_request_sync_with_buffer() - Execute a synchronous request with the
  1061. + * ssam_request_do_sync_with_buffer() - Execute a synchronous request with the
  1062. * provided buffer as back-end for the message buffer.
  1063. * @ctrl: The controller via which the request will be submitted.
  1064. * @spec: The request specification and payload.
  1065. @@ -1738,17 +1738,17 @@ EXPORT_SYMBOL_GPL(ssam_request_sync);
  1066. * SSH_COMMAND_MESSAGE_LENGTH() macro can be used to compute the required
  1067. * message buffer size.
  1068. *
  1069. - * This function does essentially the same as ssam_request_sync(), but instead
  1070. - * of dynamically allocating the request and message data buffer, it uses the
  1071. - * provided message data buffer and stores the (small) request struct on the
  1072. - * heap.
  1073. + * This function does essentially the same as ssam_request_do_sync(), but
  1074. + * instead of dynamically allocating the request and message data buffer, it
  1075. + * uses the provided message data buffer and stores the (small) request struct
  1076. + * on the heap.
  1077. *
  1078. * Return: Returns the status of the request or any failure during setup.
  1079. */
  1080. -int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
  1081. - const struct ssam_request *spec,
  1082. - struct ssam_response *rsp,
  1083. - struct ssam_span *buf)
  1084. +int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl,
  1085. + const struct ssam_request *spec,
  1086. + struct ssam_response *rsp,
  1087. + struct ssam_span *buf)
  1088. {
  1089. struct ssam_request_sync rqst;
  1090. ssize_t len;
  1091. @@ -1772,7 +1772,7 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
  1092. return status;
  1093. }
  1094. -EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer);
  1095. +EXPORT_SYMBOL_GPL(ssam_request_do_sync_with_buffer);
  1096. /* -- Internal SAM requests. ------------------------------------------------ */
  1097. @@ -1864,7 +1864,7 @@ static int __ssam_ssh_event_request(struct ssam_controller *ctrl,
  1098. result.length = 0;
  1099. result.pointer = &buf;
  1100. - status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
  1101. + status = ssam_retry(ssam_request_do_sync_onstack, ctrl, &rqst, &result,
  1102. sizeof(params));
  1103. return status < 0 ? status : buf;
  1104. diff --git a/drivers/platform/surface/surface_acpi_notify.c b/drivers/platform/surface/surface_acpi_notify.c
  1105. index 50500e562963..897cdd9c3aae 100644
  1106. --- a/drivers/platform/surface/surface_acpi_notify.c
  1107. +++ b/drivers/platform/surface/surface_acpi_notify.c
  1108. @@ -590,7 +590,7 @@ static acpi_status san_rqst(struct san_data *d, struct gsb_buffer *buffer)
  1109. return san_rqst_fixup_suspended(d, &rqst, buffer);
  1110. }
  1111. - status = __ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
  1112. + status = __ssam_retry(ssam_request_do_sync_onstack, SAN_REQUEST_NUM_TRIES,
  1113. d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
  1114. if (!status) {
  1115. diff --git a/drivers/platform/surface/surface_aggregator_cdev.c b/drivers/platform/surface/surface_aggregator_cdev.c
  1116. index 492c82e69182..07f0ed658369 100644
  1117. --- a/drivers/platform/surface/surface_aggregator_cdev.c
  1118. +++ b/drivers/platform/surface/surface_aggregator_cdev.c
  1119. @@ -302,8 +302,8 @@ static long ssam_cdev_request(struct ssam_cdev_client *client, struct ssam_cdev_
  1120. * theoretical maximum (SSH_COMMAND_MAX_PAYLOAD_SIZE) of the
  1121. * underlying protocol (note that nothing remotely this size
  1122. * should ever be allocated in any normal case). This size is
  1123. - * validated later in ssam_request_sync(), for allocation the
  1124. - * bound imposed by u16 should be enough.
  1125. + * validated later in ssam_request_do_sync(), for allocation
  1126. + * the bound imposed by u16 should be enough.
  1127. */
  1128. spec.payload = kzalloc(spec.length, GFP_KERNEL);
  1129. if (!spec.payload) {
  1130. @@ -342,7 +342,7 @@ static long ssam_cdev_request(struct ssam_cdev_client *client, struct ssam_cdev_
  1131. }
  1132. /* Perform request. */
  1133. - status = ssam_request_sync(client->cdev->ctrl, &spec, &rsp);
  1134. + status = ssam_request_do_sync(client->cdev->ctrl, &spec, &rsp);
  1135. if (status)
  1136. goto out;
  1137. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  1138. index 6147aa887939..9fed800c7cc0 100644
  1139. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  1140. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  1141. @@ -382,7 +382,7 @@ static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sour
  1142. rsp.length = 0;
  1143. rsp.pointer = (u8 *)sources;
  1144. - status = ssam_retry(ssam_request_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0);
  1145. + status = ssam_retry(ssam_request_do_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0);
  1146. if (status)
  1147. return status;
  1148. diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
  1149. index 8932bc0bae18..cb7980805920 100644
  1150. --- a/include/linux/surface_aggregator/controller.h
  1151. +++ b/include/linux/surface_aggregator/controller.h
  1152. @@ -207,17 +207,17 @@ static inline int ssam_request_sync_wait(struct ssam_request_sync *rqst)
  1153. return rqst->status;
  1154. }
  1155. -int ssam_request_sync(struct ssam_controller *ctrl,
  1156. - const struct ssam_request *spec,
  1157. - struct ssam_response *rsp);
  1158. +int ssam_request_do_sync(struct ssam_controller *ctrl,
  1159. + const struct ssam_request *spec,
  1160. + struct ssam_response *rsp);
  1161. -int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
  1162. - const struct ssam_request *spec,
  1163. - struct ssam_response *rsp,
  1164. - struct ssam_span *buf);
  1165. +int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl,
  1166. + const struct ssam_request *spec,
  1167. + struct ssam_response *rsp,
  1168. + struct ssam_span *buf);
  1169. /**
  1170. - * ssam_request_sync_onstack - Execute a synchronous request on the stack.
  1171. + * ssam_request_do_sync_onstack - Execute a synchronous request on the stack.
  1172. * @ctrl: The controller via which the request is submitted.
  1173. * @rqst: The request specification.
  1174. * @rsp: The response buffer.
  1175. @@ -227,7 +227,7 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
  1176. * fully initializes it via the provided request specification, submits it,
  1177. * and finally waits for its completion before returning its status. This
  1178. * helper macro essentially allocates the request message buffer on the stack
  1179. - * and then calls ssam_request_sync_with_buffer().
  1180. + * and then calls ssam_request_do_sync_with_buffer().
  1181. *
  1182. * Note: The @payload_len parameter specifies the maximum payload length, used
  1183. * for buffer allocation. The actual payload length may be smaller.
  1184. @@ -235,12 +235,12 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
  1185. * Return: Returns the status of the request or any failure during setup, i.e.
  1186. * zero on success and a negative value on failure.
  1187. */
  1188. -#define ssam_request_sync_onstack(ctrl, rqst, rsp, payload_len) \
  1189. +#define ssam_request_do_sync_onstack(ctrl, rqst, rsp, payload_len) \
  1190. ({ \
  1191. u8 __data[SSH_COMMAND_MESSAGE_LENGTH(payload_len)]; \
  1192. struct ssam_span __buf = { &__data[0], ARRAY_SIZE(__data) }; \
  1193. \
  1194. - ssam_request_sync_with_buffer(ctrl, rqst, rsp, &__buf); \
  1195. + ssam_request_do_sync_with_buffer(ctrl, rqst, rsp, &__buf); \
  1196. })
  1197. /**
  1198. @@ -349,7 +349,7 @@ struct ssam_request_spec_md {
  1199. * zero on success and negative on failure. The ``ctrl`` parameter is the
  1200. * controller via which the request is being sent.
  1201. *
  1202. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1203. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1204. * the generated function.
  1205. */
  1206. #define SSAM_DEFINE_SYNC_REQUEST_N(name, spec...) \
  1207. @@ -366,7 +366,7 @@ struct ssam_request_spec_md {
  1208. rqst.length = 0; \
  1209. rqst.payload = NULL; \
  1210. \
  1211. - return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \
  1212. + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \
  1213. }
  1214. /**
  1215. @@ -389,7 +389,7 @@ struct ssam_request_spec_md {
  1216. * parameter is the controller via which the request is sent. The request
  1217. * argument is specified via the ``arg`` pointer.
  1218. *
  1219. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1220. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1221. * the generated function.
  1222. */
  1223. #define SSAM_DEFINE_SYNC_REQUEST_W(name, atype, spec...) \
  1224. @@ -406,8 +406,8 @@ struct ssam_request_spec_md {
  1225. rqst.length = sizeof(atype); \
  1226. rqst.payload = (u8 *)arg; \
  1227. \
  1228. - return ssam_request_sync_onstack(ctrl, &rqst, NULL, \
  1229. - sizeof(atype)); \
  1230. + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \
  1231. + sizeof(atype)); \
  1232. }
  1233. /**
  1234. @@ -430,7 +430,7 @@ struct ssam_request_spec_md {
  1235. * the controller via which the request is sent. The request's return value is
  1236. * written to the memory pointed to by the ``ret`` parameter.
  1237. *
  1238. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1239. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1240. * the generated function.
  1241. */
  1242. #define SSAM_DEFINE_SYNC_REQUEST_R(name, rtype, spec...) \
  1243. @@ -453,7 +453,7 @@ struct ssam_request_spec_md {
  1244. rsp.length = 0; \
  1245. rsp.pointer = (u8 *)ret; \
  1246. \
  1247. - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \
  1248. + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \
  1249. if (status) \
  1250. return status; \
  1251. \
  1252. @@ -491,7 +491,7 @@ struct ssam_request_spec_md {
  1253. * request argument is specified via the ``arg`` pointer. The request's return
  1254. * value is written to the memory pointed to by the ``ret`` parameter.
  1255. *
  1256. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1257. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1258. * the generated function.
  1259. */
  1260. #define SSAM_DEFINE_SYNC_REQUEST_WR(name, atype, rtype, spec...) \
  1261. @@ -514,7 +514,7 @@ struct ssam_request_spec_md {
  1262. rsp.length = 0; \
  1263. rsp.pointer = (u8 *)ret; \
  1264. \
  1265. - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
  1266. + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
  1267. if (status) \
  1268. return status; \
  1269. \
  1270. @@ -550,7 +550,7 @@ struct ssam_request_spec_md {
  1271. * parameter is the controller via which the request is sent, ``tid`` the
  1272. * target ID for the request, and ``iid`` the instance ID.
  1273. *
  1274. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1275. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1276. * the generated function.
  1277. */
  1278. #define SSAM_DEFINE_SYNC_REQUEST_MD_N(name, spec...) \
  1279. @@ -567,7 +567,7 @@ struct ssam_request_spec_md {
  1280. rqst.length = 0; \
  1281. rqst.payload = NULL; \
  1282. \
  1283. - return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \
  1284. + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \
  1285. }
  1286. /**
  1287. @@ -592,7 +592,7 @@ struct ssam_request_spec_md {
  1288. * ``tid`` the target ID for the request, and ``iid`` the instance ID. The
  1289. * request argument is specified via the ``arg`` pointer.
  1290. *
  1291. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1292. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1293. * the generated function.
  1294. */
  1295. #define SSAM_DEFINE_SYNC_REQUEST_MD_W(name, atype, spec...) \
  1296. @@ -609,7 +609,7 @@ struct ssam_request_spec_md {
  1297. rqst.length = sizeof(atype); \
  1298. rqst.payload = (u8 *)arg; \
  1299. \
  1300. - return ssam_request_sync_onstack(ctrl, &rqst, NULL, \
  1301. + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \
  1302. sizeof(atype)); \
  1303. }
  1304. @@ -635,7 +635,7 @@ struct ssam_request_spec_md {
  1305. * the target ID for the request, and ``iid`` the instance ID. The request's
  1306. * return value is written to the memory pointed to by the ``ret`` parameter.
  1307. *
  1308. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1309. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1310. * the generated function.
  1311. */
  1312. #define SSAM_DEFINE_SYNC_REQUEST_MD_R(name, rtype, spec...) \
  1313. @@ -658,7 +658,7 @@ struct ssam_request_spec_md {
  1314. rsp.length = 0; \
  1315. rsp.pointer = (u8 *)ret; \
  1316. \
  1317. - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \
  1318. + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \
  1319. if (status) \
  1320. return status; \
  1321. \
  1322. @@ -698,7 +698,7 @@ struct ssam_request_spec_md {
  1323. * The request argument is specified via the ``arg`` pointer. The request's
  1324. * return value is written to the memory pointed to by the ``ret`` parameter.
  1325. *
  1326. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1327. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1328. * the generated function.
  1329. */
  1330. #define SSAM_DEFINE_SYNC_REQUEST_MD_WR(name, atype, rtype, spec...) \
  1331. @@ -722,7 +722,7 @@ struct ssam_request_spec_md {
  1332. rsp.length = 0; \
  1333. rsp.pointer = (u8 *)ret; \
  1334. \
  1335. - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
  1336. + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
  1337. if (status) \
  1338. return status; \
  1339. \
  1340. diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
  1341. index 4da20b7a0ee5..1545e5567b15 100644
  1342. --- a/include/linux/surface_aggregator/device.h
  1343. +++ b/include/linux/surface_aggregator/device.h
  1344. @@ -456,7 +456,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
  1345. * device of the request and by association the controller via which the
  1346. * request is sent.
  1347. *
  1348. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1349. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1350. * the generated function.
  1351. */
  1352. #define SSAM_DEFINE_SYNC_REQUEST_CL_N(name, spec...) \
  1353. @@ -490,7 +490,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
  1354. * which the request is sent. The request's argument is specified via the
  1355. * ``arg`` pointer.
  1356. *
  1357. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1358. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1359. * the generated function.
  1360. */
  1361. #define SSAM_DEFINE_SYNC_REQUEST_CL_W(name, atype, spec...) \
  1362. @@ -524,7 +524,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
  1363. * the request is sent. The request's return value is written to the memory
  1364. * pointed to by the ``ret`` parameter.
  1365. *
  1366. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1367. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1368. * the generated function.
  1369. */
  1370. #define SSAM_DEFINE_SYNC_REQUEST_CL_R(name, rtype, spec...) \
  1371. @@ -560,7 +560,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
  1372. * specified via the ``arg`` pointer. The request's return value is written to
  1373. * the memory pointed to by the ``ret`` parameter.
  1374. *
  1375. - * Refer to ssam_request_sync_onstack() for more details on the behavior of
  1376. + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
  1377. * the generated function.
  1378. */
  1379. #define SSAM_DEFINE_SYNC_REQUEST_CL_WR(name, atype, rtype, spec...) \
  1380. --
  1381. 2.39.1
  1382. From 60580e724335386ff17b69a9aaf4ef33866ce04f Mon Sep 17 00:00:00 2001
  1383. From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  1384. Date: Wed, 18 Jan 2023 11:38:23 +0200
  1385. Subject: [PATCH] platform/surface: Switch to use acpi_evaluate_dsm_typed()
  1386. The acpi_evaluate_dsm_typed() provides a way to check the type of the
  1387. object evaluated by _DSM call. Use it instead of open coded variant.
  1388. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  1389. Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
  1390. Link: https://lore.kernel.org/r/20230118093823.39679-1-andriy.shevchenko@linux.intel.com
  1391. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
  1392. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  1393. Patchset: surface-sam
  1394. ---
  1395. drivers/platform/surface/surface_hotplug.c | 13 +++----------
  1396. 1 file changed, 3 insertions(+), 10 deletions(-)
  1397. diff --git a/drivers/platform/surface/surface_hotplug.c b/drivers/platform/surface/surface_hotplug.c
  1398. index f004a2495201..7b6d887dccdb 100644
  1399. --- a/drivers/platform/surface/surface_hotplug.c
  1400. +++ b/drivers/platform/surface/surface_hotplug.c
  1401. @@ -101,18 +101,12 @@ static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type
  1402. param.type = ACPI_TYPE_INTEGER;
  1403. param.integer.value = value;
  1404. - result = acpi_evaluate_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
  1405. - shps_dsm_fn_for_irq(type), &param);
  1406. -
  1407. + result = acpi_evaluate_dsm_typed(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
  1408. + shps_dsm_fn_for_irq(type), &param, ACPI_TYPE_BUFFER);
  1409. if (!result) {
  1410. dev_err(&pdev->dev, "IRQ notification via DSM failed (irq=%d, gpio=%d)\n",
  1411. type, value);
  1412. - } else if (result->type != ACPI_TYPE_BUFFER) {
  1413. - dev_err(&pdev->dev,
  1414. - "IRQ notification via DSM failed: unexpected result type (irq=%d, gpio=%d)\n",
  1415. - type, value);
  1416. -
  1417. } else if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) {
  1418. dev_err(&pdev->dev,
  1419. "IRQ notification via DSM failed: unexpected result value (irq=%d, gpio=%d)\n",
  1420. @@ -121,8 +115,7 @@ static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type
  1421. mutex_unlock(&sdev->lock[type]);
  1422. - if (result)
  1423. - ACPI_FREE(result);
  1424. + ACPI_FREE(result);
  1425. }
  1426. static irqreturn_t shps_handle_irq(int irq, void *data)
  1427. --
  1428. 2.39.1