Skip to content

Commit 72a5eb9

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Remove fixed size fields from reports/scmi_event_header
Event reports are used to convey information describing events to the registered user-callbacks: they are necessarily derived from the underlying raw SCMI events' messages but they are not meant to expose or directly mirror any of those messages data layout, which belong to the protocol layer. Using fixed size types for report fields, mirroring messages structure, is at odd with this: get rid of them using more generic, equivalent, typing. Substitute scmi_event_header fixed size fields with generic types too and shuffle around fields definitions to minimize implicit padding while adapting involved functions. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 33ee97f commit 72a5eb9

File tree

9 files changed

+46
-43
lines changed

9 files changed

+46
-43
lines changed

drivers/firmware/arm_scmi/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int scmi_base_set_notify_enabled(const struct scmi_handle *handle,
273273
}
274274

275275
static void *scmi_base_fill_custom_report(const struct scmi_handle *handle,
276-
u8 evt_id, u64 timestamp,
276+
u8 evt_id, ktime_t timestamp,
277277
const void *payld, size_t payld_sz,
278278
void *report, u32 *src_id)
279279
{

drivers/firmware/arm_scmi/driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer)
205205

206206
static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
207207
{
208-
u64 ts;
209208
struct scmi_xfer *xfer;
210209
struct device *dev = cinfo->dev;
211210
struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
212211
struct scmi_xfers_info *minfo = &info->rx_minfo;
212+
ktime_t ts;
213213

214-
ts = ktime_get_boottime_ns();
214+
ts = ktime_get_boottime();
215215
xfer = scmi_xfer_get(cinfo->handle, minfo);
216216
if (IS_ERR(xfer)) {
217217
dev_err(dev, "failed to get free message slot (%ld)\n",

drivers/firmware/arm_scmi/notify.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#include <linux/err.h>
8181
#include <linux/hashtable.h>
8282
#include <linux/kernel.h>
83+
#include <linux/ktime.h>
8384
#include <linux/kfifo.h>
8485
#include <linux/list.h>
8586
#include <linux/mutex.h>
@@ -246,18 +247,18 @@ struct events_queue {
246247
* struct scmi_event_header - A utility header
247248
* @timestamp: The timestamp, in nanoseconds (boottime), which was associated
248249
* to this event as soon as it entered the SCMI RX ISR
249-
* @evt_id: Event ID (corresponds to the Event MsgID for this Protocol)
250250
* @payld_sz: Effective size of the embedded message payload which follows
251+
* @evt_id: Event ID (corresponds to the Event MsgID for this Protocol)
251252
* @payld: A reference to the embedded event payload
252253
*
253254
* This header is prepended to each received event message payload before
254255
* queueing it on the related &struct events_queue.
255256
*/
256257
struct scmi_event_header {
257-
u64 timestamp;
258-
u8 evt_id;
259-
size_t payld_sz;
260-
u8 payld[];
258+
ktime_t timestamp;
259+
size_t payld_sz;
260+
unsigned char evt_id;
261+
unsigned char payld[];
261262
};
262263

263264
struct scmi_registered_event;
@@ -572,7 +573,7 @@ static void scmi_events_dispatcher(struct work_struct *work)
572573
* Return: 0 on Success
573574
*/
574575
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
575-
const void *buf, size_t len, u64 ts)
576+
const void *buf, size_t len, ktime_t ts)
576577
{
577578
struct scmi_registered_event *r_evt;
578579
struct scmi_event_header eh;
@@ -595,7 +596,7 @@ int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
595596
if (kfifo_avail(&r_evt->proto->equeue.kfifo) < sizeof(eh) + len) {
596597
dev_warn(handle->dev,
597598
"queue full, dropping proto_id:%d evt_id:%d ts:%lld\n",
598-
proto_id, evt_id, ts);
599+
proto_id, evt_id, ktime_to_ns(ts));
599600
return -ENOMEM;
600601
}
601602

drivers/firmware/arm_scmi/notify.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _SCMI_NOTIFY_H
1111

1212
#include <linux/device.h>
13+
#include <linux/ktime.h>
1314
#include <linux/types.h>
1415

1516
#define SCMI_PROTO_QUEUE_SZ 4096
@@ -48,8 +49,9 @@ struct scmi_event_ops {
4849
int (*set_notify_enabled)(const struct scmi_handle *handle,
4950
u8 evt_id, u32 src_id, bool enabled);
5051
void *(*fill_custom_report)(const struct scmi_handle *handle,
51-
u8 evt_id, u64 timestamp, const void *payld,
52-
size_t payld_sz, void *report, u32 *src_id);
52+
u8 evt_id, ktime_t timestamp,
53+
const void *payld, size_t payld_sz,
54+
void *report, u32 *src_id);
5355
};
5456

5557
int scmi_notification_init(struct scmi_handle *handle);
@@ -61,6 +63,6 @@ int scmi_register_protocol_events(const struct scmi_handle *handle,
6163
const struct scmi_event *evt, int num_events,
6264
int num_sources);
6365
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
64-
const void *buf, size_t len, u64 ts);
66+
const void *buf, size_t len, ktime_t ts);
6567

6668
#endif /* _SCMI_NOTIFY_H */

drivers/firmware/arm_scmi/perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ static int scmi_perf_set_notify_enabled(const struct scmi_handle *handle,
780780
}
781781

782782
static void *scmi_perf_fill_custom_report(const struct scmi_handle *handle,
783-
u8 evt_id, u64 timestamp,
783+
u8 evt_id, ktime_t timestamp,
784784
const void *payld, size_t payld_sz,
785785
void *report, u32 *src_id)
786786
{

drivers/firmware/arm_scmi/power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int scmi_power_set_notify_enabled(const struct scmi_handle *handle,
227227
}
228228

229229
static void *scmi_power_fill_custom_report(const struct scmi_handle *handle,
230-
u8 evt_id, u64 timestamp,
230+
u8 evt_id, ktime_t timestamp,
231231
const void *payld, size_t payld_sz,
232232
void *report, u32 *src_id)
233233
{

drivers/firmware/arm_scmi/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static int scmi_reset_set_notify_enabled(const struct scmi_handle *handle,
240240
}
241241

242242
static void *scmi_reset_fill_custom_report(const struct scmi_handle *handle,
243-
u8 evt_id, u64 timestamp,
243+
u8 evt_id, ktime_t timestamp,
244244
const void *payld, size_t payld_sz,
245245
void *report, u32 *src_id)
246246
{

drivers/firmware/arm_scmi/sensors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
296296
}
297297

298298
static void *scmi_sensor_fill_custom_report(const struct scmi_handle *handle,
299-
u8 evt_id, u64 timestamp,
299+
u8 evt_id, ktime_t timestamp,
300300
const void *payld, size_t payld_sz,
301301
void *report, u32 *src_id)
302302
{

include/linux/scmi_protocol.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -381,47 +381,47 @@ enum scmi_notification_events {
381381
};
382382

383383
struct scmi_power_state_changed_report {
384-
u64 timestamp;
385-
u32 agent_id;
386-
u32 domain_id;
387-
u32 power_state;
384+
ktime_t timestamp;
385+
unsigned int agent_id;
386+
unsigned int domain_id;
387+
unsigned int power_state;
388388
};
389389

390390
struct scmi_perf_limits_report {
391-
u64 timestamp;
392-
u32 agent_id;
393-
u32 domain_id;
394-
u32 range_max;
395-
u32 range_min;
391+
ktime_t timestamp;
392+
unsigned int agent_id;
393+
unsigned int domain_id;
394+
unsigned int range_max;
395+
unsigned int range_min;
396396
};
397397

398398
struct scmi_perf_level_report {
399-
u64 timestamp;
400-
u32 agent_id;
401-
u32 domain_id;
402-
u32 performance_level;
399+
ktime_t timestamp;
400+
unsigned int agent_id;
401+
unsigned int domain_id;
402+
unsigned int performance_level;
403403
};
404404

405405
struct scmi_sensor_trip_point_report {
406-
u64 timestamp;
407-
u32 agent_id;
408-
u32 sensor_id;
409-
u32 trip_point_desc;
406+
ktime_t timestamp;
407+
unsigned int agent_id;
408+
unsigned int sensor_id;
409+
unsigned int trip_point_desc;
410410
};
411411

412412
struct scmi_reset_issued_report {
413-
u64 timestamp;
414-
u32 agent_id;
415-
u32 domain_id;
416-
u32 reset_state;
413+
ktime_t timestamp;
414+
unsigned int agent_id;
415+
unsigned int domain_id;
416+
unsigned int reset_state;
417417
};
418418

419419
struct scmi_base_error_report {
420-
u64 timestamp;
421-
u32 agent_id;
422-
bool fatal;
423-
u16 cmd_count;
424-
u64 reports[];
420+
ktime_t timestamp;
421+
unsigned int agent_id;
422+
bool fatal;
423+
unsigned int cmd_count;
424+
unsigned long long reports[];
425425
};
426426

427427
#endif /* _LINUX_SCMI_PROTOCOL_H */

0 commit comments

Comments
 (0)