/** * union coresight_dev_subtype - further characterisation of a type * @sink_subtype: type of sink this component is, as defined * by @coresight_dev_subtype_sink. * @link_subtype: type of link this component is, as defined * by @coresight_dev_subtype_link. * @source_subtype: type of source this component is, as defined * by @coresight_dev_subtype_source. * @helper_subtype: type of helper this component is, as defined * by @coresight_dev_subtype_helper.
*/ union coresight_dev_subtype { /* We have some devices which acts as LINK and SINK */ struct { enum coresight_dev_subtype_sink sink_subtype; enum coresight_dev_subtype_link link_subtype;
}; enum coresight_dev_subtype_source source_subtype; enum coresight_dev_subtype_helper helper_subtype;
};
/** * struct coresight_platform_data - data harvested from the firmware * specification. * * @nr_inconns: Number of elements for the input connections. * @nr_outconns: Number of elements for the output connections. * @out_conns: Array of nr_outconns pointers to connections from this * component. * @in_conns: Sparse array of pointers to input connections. Sparse * because the source device owns the connection so when it's * unloaded the connection leaves an empty slot.
*/ struct coresight_platform_data { int nr_inconns; int nr_outconns; struct coresight_connection **out_conns; struct coresight_connection **in_conns;
};
/** * struct csdev_access - Abstraction of a CoreSight device access. * * @io_mem : True if the device has memory mapped I/O * @base : When io_mem == true, base address of the component * @read : Read from the given "offset" of the given instance. * @write : Write "val" to the given "offset".
*/ struct csdev_access { bool io_mem; union { void __iomem *base; struct {
u64 (*read)(u32 offset, bool relaxed, bool _64bit); void (*write)(u64 val, u32 offset, bool relaxed, bool _64bit);
};
};
};
/** * struct coresight_desc - description of a component required from drivers * @type: as defined by @coresight_dev_type. * @subtype: as defined by @coresight_dev_subtype. * @ops: generic operations for this component, as defined * by @coresight_ops. * @pdata: platform data collected from DT. * @dev: The device entity associated to this component. * @groups: operations specific to this component. These will end up * in the component's sysfs sub-directory. * @name: name for the coresight device, also shown under sysfs. * @access: Describe access to the device
*/ struct coresight_desc { enum coresight_dev_type type; union coresight_dev_subtype subtype; conststruct coresight_ops *ops; struct coresight_platform_data *pdata; struct device *dev; conststruct attribute_group **groups; constchar *name; struct csdev_access access;
};
/** * struct coresight_connection - representation of a single connection * @src_port: a connection's output port number. * @dest_port: destination's input port number @src_port is connected to. * @dest_fwnode: destination component's fwnode handle. * @dest_dev: a @coresight_device representation of the component connected to @src_port. NULL until the device is created * @link: Representation of the connection as a sysfs link. * @filter_src_fwnode: filter source component's fwnode handle. * @filter_src_dev: a @coresight_device representation of the component that needs to be filtered. * * The full connection structure looks like this, where in_conns store * references to same connection as the source device's out_conns. * * +-----------------------------+ +-----------------------------+ * |coresight_device | |coresight_connection | * |-----------------------------| |-----------------------------| * | | | | * | | | dest_dev*|<-- * |pdata->out_conns[nr_outconns]|<->|src_dev* | | * | | | | | * +-----------------------------+ +-----------------------------+ | * | * +-----------------------------+ | * |coresight_device | | * |------------------------------ | * | | | * | pdata->in_conns[nr_inconns]|<-- * | | * +-----------------------------+
*/ struct coresight_connection { int src_port; int dest_port; struct fwnode_handle *dest_fwnode; struct coresight_device *dest_dev; struct coresight_sysfs_link *link; struct coresight_device *src_dev; struct fwnode_handle *filter_src_fwnode; struct coresight_device *filter_src_dev; int src_refcnt; int dest_refcnt;
};
/** * struct coresight_sysfs_link - representation of a connection in sysfs. * @orig: Originating (master) coresight device for the link. * @orig_name: Name to use for the link orig->target. * @target: Target (slave) coresight device for the link. * @target_name: Name to use for the link target->orig.
*/ struct coresight_sysfs_link { struct coresight_device *orig; constchar *orig_name; struct coresight_device *target; constchar *target_name;
};
/* architecturally we have 128 IDs some of which are reserved */ #define CORESIGHT_TRACE_IDS_MAX 128
/** * Trace ID map. * * @used_ids: Bitmap to register available (bit = 0) and in use (bit = 1) IDs. * Initialised so that the reserved IDs are permanently marked as * in use. * @perf_cs_etm_session_active: Number of Perf sessions using this ID map.
*/ struct coresight_trace_id_map {
DECLARE_BITMAP(used_ids, CORESIGHT_TRACE_IDS_MAX);
atomic_t __percpu *cpu_map;
atomic_t perf_cs_etm_session_active;
raw_spinlock_t lock;
};
/** * struct coresight_device - representation of a device as used by the framework * @pdata: Platform data with device connections associated to this device. * @type: as defined by @coresight_dev_type. * @subtype: as defined by @coresight_dev_subtype. * @ops: generic operations for this component, as defined * by @coresight_ops. * @access: Device i/o access abstraction for this device. * @dev: The device entity associated to this component. * @mode: This tracer's mode, i.e sysFS, Perf or disabled. This is * actually an 'enum cs_mode', but is stored in an atomic type. * This is always accessed through local_read() and local_set(), * but wherever it's done from within the Coresight device's lock, * a non-atomic read would also work. This is the main point of * synchronisation between code happening inside the sysfs mode's * coresight_mutex and outside when running in Perf mode. A compare * and exchange swap is done to atomically claim one mode or the * other. * @refcnt: keep track of what is in use. Only access this outside of the * device's spinlock when the coresight_mutex held and mode == * CS_MODE_SYSFS. Otherwise it must be accessed from inside the * spinlock. * @orphan: true if the component has connections that haven't been linked. * @sysfs_sink_activated: 'true' when a sink has been selected for use via sysfs * by writing a 1 to the 'enable_sink' file. A sink can be * activated but not yet enabled. Enabling for a _sink_ happens * when a source has been selected and a path is enabled from * source to that sink. A sink can also become enabled but not * activated if it's used via Perf. * @ea: Device attribute for sink representation under PMU directory. * @def_sink: cached reference to default sink found for this device. * @nr_links: number of sysfs links created to other components from this * device. These will appear in the "connections" group. * @has_conns_grp: Have added a "connections" group for sysfs links. * @feature_csdev_list: List of complex feature programming added to the device. * @config_csdev_list: List of system configurations added to the device. * @cscfg_csdev_lock: Protect the lists of configurations and features. * @active_cscfg_ctxt: Context information for current active system configuration.
*/ struct coresight_device { struct coresight_platform_data *pdata; enum coresight_dev_type type; union coresight_dev_subtype subtype; conststruct coresight_ops *ops; struct csdev_access access; struct device dev;
local_t mode; int refcnt; bool orphan; /* sink specific fields */ bool sysfs_sink_activated; struct dev_ext_attribute *ea; struct coresight_device *def_sink; struct coresight_trace_id_map perf_sink_id_map; /* sysfs links between components */ int nr_links; bool has_conns_grp; /* system configuration and feature lists */ struct list_head feature_csdev_list; struct list_head config_csdev_list;
raw_spinlock_t cscfg_csdev_lock; void *active_cscfg_ctxt;
};
/* * coresight_dev_list - Mapping for devices to "name" index for device * names. * * @nr_idx: Number of entries already allocated. * @pfx: Prefix pattern for device name. * @fwnode_list: Array of fwnode_handles associated with each allocated * index, upto nr_idx entries.
*/ struct coresight_dev_list { int nr_idx; constchar *pfx; struct fwnode_handle **fwnode_list;
};
/** * struct coresight_ops_sink - basic operations for a sink * Operations available for sinks * @enable: enables the sink. * @disable: disables the sink. * @alloc_buffer: initialises perf's ring buffer for trace collection. * @free_buffer: release memory allocated in @get_config. * @update_buffer: update buffer pointers after a trace session.
*/ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev, enum cs_mode mode, void *data); int (*disable)(struct coresight_device *csdev); void *(*alloc_buffer)(struct coresight_device *csdev, struct perf_event *event, void **pages, int nr_pages, bool overwrite); void (*free_buffer)(void *config); unsignedlong (*update_buffer)(struct coresight_device *csdev, struct perf_output_handle *handle, void *sink_config);
};
/** * struct coresight_ops_link - basic operations for a link * Operations available for links. * @enable: enables flow between iport and oport. * @disable: disables flow between iport and oport.
*/ struct coresight_ops_link { int (*enable)(struct coresight_device *csdev, struct coresight_connection *in, struct coresight_connection *out); void (*disable)(struct coresight_device *csdev, struct coresight_connection *in, struct coresight_connection *out);
};
/** * struct coresight_ops_source - basic operations for a source * Operations available for sources. * @cpu_id: returns the value of the CPU number this component * is associated to. * @enable: enables tracing for a source. * @disable: disables tracing for a source. * @resume_perf: resumes tracing for a source in perf session. * @pause_perf: pauses tracing for a source in perf session.
*/ struct coresight_ops_source { int (*cpu_id)(struct coresight_device *csdev); int (*enable)(struct coresight_device *csdev, struct perf_event *event, enum cs_mode mode, struct coresight_path *path); void (*disable)(struct coresight_device *csdev, struct perf_event *event); int (*resume_perf)(struct coresight_device *csdev); void (*pause_perf)(struct coresight_device *csdev);
};
/** * struct coresight_ops_helper - Operations for a helper device. * * All operations could pass in a device specific data, which could * help the helper device to determine what to do. * * @enable : Enable the device * @disable : Disable the device
*/ struct coresight_ops_helper { int (*enable)(struct coresight_device *csdev, enum cs_mode mode, void *data); int (*disable)(struct coresight_device *csdev, void *data);
};
/** * struct coresight_ops_panic - Generic device ops for panic handing * * @sync : Sync the device register state/trace data
*/ struct coresight_ops_panic { int (*sync)(struct coresight_device *csdev);
};
/* * Attempt to find and enable "APB clock" for the given device * * Returns: * * clk - Clock is found and enabled * NULL - Clock is controlled by firmware (ACPI device only) or when managed * by the AMBA bus driver instead * ERROR - Clock is found but failed to enable
*/ staticinlinestruct clk *coresight_get_enable_apb_pclk(struct device *dev)
{ struct clk *pclk = NULL;
/* Firmware controls clocks for an ACPI device. */ if (has_acpi_companion(dev)) return NULL;
if (!dev_is_amba(dev)) {
pclk = devm_clk_get_optional_enabled(dev, "apb_pclk"); if (!pclk)
pclk = devm_clk_get_optional_enabled(dev, "apb");
}
/* * Atomically try to take the device and set a new mode. Returns true on * success, false if the device is already taken by someone else.
*/ staticinlinebool coresight_take_mode(struct coresight_device *csdev, enum cs_mode new_mode)
{ return local_cmpxchg(&csdev->mode, CS_MODE_DISABLED, new_mode) ==
CS_MODE_DISABLED;
}
/* * Changing to a new mode must be done from an already disabled state * unless it's synchronized with coresight_take_mode(). Otherwise the * device is already in use and signifies a locking issue.
*/
WARN(new_mode != CS_MODE_DISABLED && current_mode != CS_MODE_DISABLED &&
current_mode != new_mode, "Device already in use\n");
local_set(&csdev->mode, new_mode);
}
struct coresight_device *coresight_register(struct coresight_desc *desc); void coresight_unregister(struct coresight_device *csdev); int coresight_enable_sysfs(struct coresight_device *csdev); void coresight_disable_sysfs(struct coresight_device *csdev); int coresight_timeout(struct csdev_access *csa, u32 offset, int position, int value); typedefvoid (*coresight_timeout_cb_t) (struct csdev_access *, u32, int, int); int coresight_timeout_action(struct csdev_access *csa, u32 offset, int position, int value,
coresight_timeout_cb_t cb); int coresight_claim_device(struct coresight_device *csdev); int coresight_claim_device_unlocked(struct coresight_device *csdev);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.