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/20200710133919.39792-3-cristian.marussi@arm.com Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
33ee97f823
commit
72a5eb9d9c
@ -273,7 +273,7 @@ static int scmi_base_set_notify_enabled(const struct scmi_handle *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *scmi_base_fill_custom_report(const struct scmi_handle *handle,
|
static void *scmi_base_fill_custom_report(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp,
|
u8 evt_id, ktime_t timestamp,
|
||||||
const void *payld, size_t payld_sz,
|
const void *payld, size_t payld_sz,
|
||||||
void *report, u32 *src_id)
|
void *report, u32 *src_id)
|
||||||
{
|
{
|
||||||
|
@ -205,13 +205,13 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer)
|
|||||||
|
|
||||||
static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
|
static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
|
||||||
{
|
{
|
||||||
u64 ts;
|
|
||||||
struct scmi_xfer *xfer;
|
struct scmi_xfer *xfer;
|
||||||
struct device *dev = cinfo->dev;
|
struct device *dev = cinfo->dev;
|
||||||
struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
|
struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
|
||||||
struct scmi_xfers_info *minfo = &info->rx_minfo;
|
struct scmi_xfers_info *minfo = &info->rx_minfo;
|
||||||
|
ktime_t ts;
|
||||||
|
|
||||||
ts = ktime_get_boottime_ns();
|
ts = ktime_get_boottime();
|
||||||
xfer = scmi_xfer_get(cinfo->handle, minfo);
|
xfer = scmi_xfer_get(cinfo->handle, minfo);
|
||||||
if (IS_ERR(xfer)) {
|
if (IS_ERR(xfer)) {
|
||||||
dev_err(dev, "failed to get free message slot (%ld)\n",
|
dev_err(dev, "failed to get free message slot (%ld)\n",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/hashtable.h>
|
#include <linux/hashtable.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/ktime.h>
|
||||||
#include <linux/kfifo.h>
|
#include <linux/kfifo.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
@ -246,18 +247,18 @@ struct events_queue {
|
|||||||
* struct scmi_event_header - A utility header
|
* struct scmi_event_header - A utility header
|
||||||
* @timestamp: The timestamp, in nanoseconds (boottime), which was associated
|
* @timestamp: The timestamp, in nanoseconds (boottime), which was associated
|
||||||
* to this event as soon as it entered the SCMI RX ISR
|
* to this event as soon as it entered the SCMI RX ISR
|
||||||
* @evt_id: Event ID (corresponds to the Event MsgID for this Protocol)
|
|
||||||
* @payld_sz: Effective size of the embedded message payload which follows
|
* @payld_sz: Effective size of the embedded message payload which follows
|
||||||
|
* @evt_id: Event ID (corresponds to the Event MsgID for this Protocol)
|
||||||
* @payld: A reference to the embedded event payload
|
* @payld: A reference to the embedded event payload
|
||||||
*
|
*
|
||||||
* This header is prepended to each received event message payload before
|
* This header is prepended to each received event message payload before
|
||||||
* queueing it on the related &struct events_queue.
|
* queueing it on the related &struct events_queue.
|
||||||
*/
|
*/
|
||||||
struct scmi_event_header {
|
struct scmi_event_header {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u8 evt_id;
|
|
||||||
size_t payld_sz;
|
size_t payld_sz;
|
||||||
u8 payld[];
|
unsigned char evt_id;
|
||||||
|
unsigned char payld[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_registered_event;
|
struct scmi_registered_event;
|
||||||
@ -572,7 +573,7 @@ static void scmi_events_dispatcher(struct work_struct *work)
|
|||||||
* Return: 0 on Success
|
* Return: 0 on Success
|
||||||
*/
|
*/
|
||||||
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
|
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
|
||||||
const void *buf, size_t len, u64 ts)
|
const void *buf, size_t len, ktime_t ts)
|
||||||
{
|
{
|
||||||
struct scmi_registered_event *r_evt;
|
struct scmi_registered_event *r_evt;
|
||||||
struct scmi_event_header eh;
|
struct scmi_event_header eh;
|
||||||
@ -595,7 +596,7 @@ int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
|
|||||||
if (kfifo_avail(&r_evt->proto->equeue.kfifo) < sizeof(eh) + len) {
|
if (kfifo_avail(&r_evt->proto->equeue.kfifo) < sizeof(eh) + len) {
|
||||||
dev_warn(handle->dev,
|
dev_warn(handle->dev,
|
||||||
"queue full, dropping proto_id:%d evt_id:%d ts:%lld\n",
|
"queue full, dropping proto_id:%d evt_id:%d ts:%lld\n",
|
||||||
proto_id, evt_id, ts);
|
proto_id, evt_id, ktime_to_ns(ts));
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define _SCMI_NOTIFY_H
|
#define _SCMI_NOTIFY_H
|
||||||
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/ktime.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
#define SCMI_PROTO_QUEUE_SZ 4096
|
#define SCMI_PROTO_QUEUE_SZ 4096
|
||||||
@ -48,8 +49,9 @@ struct scmi_event_ops {
|
|||||||
int (*set_notify_enabled)(const struct scmi_handle *handle,
|
int (*set_notify_enabled)(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u32 src_id, bool enabled);
|
u8 evt_id, u32 src_id, bool enabled);
|
||||||
void *(*fill_custom_report)(const struct scmi_handle *handle,
|
void *(*fill_custom_report)(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp, const void *payld,
|
u8 evt_id, ktime_t timestamp,
|
||||||
size_t payld_sz, void *report, u32 *src_id);
|
const void *payld, size_t payld_sz,
|
||||||
|
void *report, u32 *src_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
int scmi_notification_init(struct scmi_handle *handle);
|
int scmi_notification_init(struct scmi_handle *handle);
|
||||||
@ -61,6 +63,6 @@ int scmi_register_protocol_events(const struct scmi_handle *handle,
|
|||||||
const struct scmi_event *evt, int num_events,
|
const struct scmi_event *evt, int num_events,
|
||||||
int num_sources);
|
int num_sources);
|
||||||
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
|
int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
|
||||||
const void *buf, size_t len, u64 ts);
|
const void *buf, size_t len, ktime_t ts);
|
||||||
|
|
||||||
#endif /* _SCMI_NOTIFY_H */
|
#endif /* _SCMI_NOTIFY_H */
|
||||||
|
@ -780,7 +780,7 @@ static int scmi_perf_set_notify_enabled(const struct scmi_handle *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *scmi_perf_fill_custom_report(const struct scmi_handle *handle,
|
static void *scmi_perf_fill_custom_report(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp,
|
u8 evt_id, ktime_t timestamp,
|
||||||
const void *payld, size_t payld_sz,
|
const void *payld, size_t payld_sz,
|
||||||
void *report, u32 *src_id)
|
void *report, u32 *src_id)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ static int scmi_power_set_notify_enabled(const struct scmi_handle *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *scmi_power_fill_custom_report(const struct scmi_handle *handle,
|
static void *scmi_power_fill_custom_report(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp,
|
u8 evt_id, ktime_t timestamp,
|
||||||
const void *payld, size_t payld_sz,
|
const void *payld, size_t payld_sz,
|
||||||
void *report, u32 *src_id)
|
void *report, u32 *src_id)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +240,7 @@ static int scmi_reset_set_notify_enabled(const struct scmi_handle *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *scmi_reset_fill_custom_report(const struct scmi_handle *handle,
|
static void *scmi_reset_fill_custom_report(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp,
|
u8 evt_id, ktime_t timestamp,
|
||||||
const void *payld, size_t payld_sz,
|
const void *payld, size_t payld_sz,
|
||||||
void *report, u32 *src_id)
|
void *report, u32 *src_id)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +296,7 @@ static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *scmi_sensor_fill_custom_report(const struct scmi_handle *handle,
|
static void *scmi_sensor_fill_custom_report(const struct scmi_handle *handle,
|
||||||
u8 evt_id, u64 timestamp,
|
u8 evt_id, ktime_t timestamp,
|
||||||
const void *payld, size_t payld_sz,
|
const void *payld, size_t payld_sz,
|
||||||
void *report, u32 *src_id)
|
void *report, u32 *src_id)
|
||||||
{
|
{
|
||||||
|
@ -381,47 +381,47 @@ enum scmi_notification_events {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_power_state_changed_report {
|
struct scmi_power_state_changed_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
u32 domain_id;
|
unsigned int domain_id;
|
||||||
u32 power_state;
|
unsigned int power_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_perf_limits_report {
|
struct scmi_perf_limits_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
u32 domain_id;
|
unsigned int domain_id;
|
||||||
u32 range_max;
|
unsigned int range_max;
|
||||||
u32 range_min;
|
unsigned int range_min;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_perf_level_report {
|
struct scmi_perf_level_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
u32 domain_id;
|
unsigned int domain_id;
|
||||||
u32 performance_level;
|
unsigned int performance_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_sensor_trip_point_report {
|
struct scmi_sensor_trip_point_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
u32 sensor_id;
|
unsigned int sensor_id;
|
||||||
u32 trip_point_desc;
|
unsigned int trip_point_desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_reset_issued_report {
|
struct scmi_reset_issued_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
u32 domain_id;
|
unsigned int domain_id;
|
||||||
u32 reset_state;
|
unsigned int reset_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scmi_base_error_report {
|
struct scmi_base_error_report {
|
||||||
u64 timestamp;
|
ktime_t timestamp;
|
||||||
u32 agent_id;
|
unsigned int agent_id;
|
||||||
bool fatal;
|
bool fatal;
|
||||||
u16 cmd_count;
|
unsigned int cmd_count;
|
||||||
u64 reports[];
|
unsigned long long reports[];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _LINUX_SCMI_PROTOCOL_H */
|
#endif /* _LINUX_SCMI_PROTOCOL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user