stm class/intel_th: Updates for v5.14
Alexander Shishkin
maintainercover stm class/intel_th: Updates for v5.14
Hi Greg,
Here are a few patches that I have for v5.14 merge window. Andy provided his reviewed-bys. Please consider applying. Thanks!
Alexander Shishkin (2):
intel_th: msu: Make contiguous buffers uncached
intel_th: Wait until port is in reset before programming it
Randy Dunlap (1):
stm class: Spelling fix
Uwe Kleine-König (1):
intel_th: Remove an unused exit point from intel_th_remove()
drivers/hwtracing/intel_th/core.c | 29 +++++++++++++--- drivers/hwtracing/intel_th/gth.c | 16 +++++++++ drivers/hwtracing/intel_th/intel_th.h | 3 ++ drivers/hwtracing/intel_th/msu.c | 48 ++++++++++++++++++--------- include/linux/stm.h | 2 +- 5 files changed, 76 insertions(+), 22 deletions(-)
Signature · 1 line
2.30.2
Alexander Shishkin
maintainerPATCH 1/4 stm class: Spelling fix
From: Randy Dunlap <[email protected]>
Drop the repeated word "the" in a comment.
--- include/linux/stm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/stm.h +1 -1
@@ -57,7 +57,7 @@ struct stm_device;* * Normally, an STM device will have a range of masters available to software * and the rest being statically assigned to various hardware trace sources. -* The former is defined by the the range [@sw_start..@sw_end] of the device +* The former is defined by the range [@sw_start..@sw_end] of the device * description. That is, the lowest master that can be allocated to software * writers is @sw_start and data from this writer will appear is @sw_start * master in the STP stream.
Signature · 1 line
2.30.2
Alexander Shishkin
maintainerPATCH 2/4 intel_th: Remove an unused exit point from intel_th_remove()
In reply to Alexander ShishkinFrom: Uwe Kleine-König <[email protected]>
As described in the added comment device_for_each_child() never returns a non-zero value. So remove the corresponding error check.
This simplifies the quest to make struct bus_type::remove() return void.
--- drivers/hwtracing/intel_th/core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/hwtracing/intel_th/core.c +7 -5
@@ -100,16 +100,18 @@ static int intel_th_remove(struct device *dev)struct intel_th_driver *thdrv =to_intel_th_driver (dev->driver);struct intel_th_device *thdev =to_intel_th_device (dev);struct intel_th_device *hub =to_intel_th_hub (thdev); -int err;if (thdev->type ==INTEL_TH_SWITCH ) {struct intel_th *th =to_intel_th (hub);int i, lowest; -/* disconnect outputs */ - err =device_for_each_child (dev, thdev, intel_th_child_remove); -if (err) -return err; +/* +* disconnect outputs +* +* intel_th_child_remove returns 0 unconditionally, so there is +* no need to check the return value of device_for_each_child. +*/ +device_for_each_child (dev, thdev, intel_th_child_remove);/* * Remove outputs, that is, hub's children: they are created
Signature · 1 line
2.30.2
Alexander Shishkin
maintainerPATCH 3/4 intel_th: msu: Make contiguous buffers uncached
In reply to Alexander ShishkinWe already keep the multiblock mode buffers uncached, but forget the single mode. Address this.
--- drivers/hwtracing/intel_th/msu.c | 48 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-)
drivers/hwtracing/intel_th/msu.c +32 -16
@@ -1024,33 +1024,49 @@ static int __msc_buffer_win_alloc(struct msc_window *win, }#ifdef CONFIG_X86 -static void msc_buffer_set_uc (struct msc_window *win,unsigned int nr_segs) +static void msc_buffer_set_uc (struct msc *msc) {struct scatterlist *sg_ptr; +struct msc_window *win;int i; -for_each_sg (win->sgt->sgl, sg_ptr, nr_segs, i) { -/* Set the page as uncached */ -set_memory_uc ((unsigned long )sg_virt (sg_ptr), -PFN_DOWN (sg_ptr->length)); +if (msc->mode ==MSC_MODE_SINGLE ) { +set_memory_uc ((unsigned long )msc->base, msc->nr_pages); +return ; + } + +list_for_each_entry (win, &msc->win_list, entry) { +for_each_sg (win->sgt->sgl, sg_ptr, win->nr_segs, i) { +/* Set the page as uncached */ +set_memory_uc ((unsigned long )sg_virt (sg_ptr), +PFN_DOWN (sg_ptr->length)); + } } } -static void msc_buffer_set_wb (struct msc_window *win) +static void msc_buffer_set_wb (struct msc *msc) {struct scatterlist *sg_ptr; +struct msc_window *win;int i; -for_each_sg (win->sgt->sgl, sg_ptr, win->nr_segs, i) { -/* Reset the page to write-back */ -set_memory_wb ((unsigned long )sg_virt (sg_ptr), -PFN_DOWN (sg_ptr->length)); +if (msc->mode ==MSC_MODE_SINGLE ) { +set_memory_wb ((unsigned long )msc->base, msc->nr_pages); +return ; + } + +list_for_each_entry (win, &msc->win_list, entry) { +for_each_sg (win->sgt->sgl, sg_ptr, win->nr_segs, i) { +/* Reset the page to write-back */ +set_memory_wb ((unsigned long )sg_virt (sg_ptr), +PFN_DOWN (sg_ptr->length)); + } } }#else /* !X86 */ static inline void -msc_buffer_set_uc (struct msc_window *win,unsigned int nr_segs) {} -static inline void msc_buffer_set_wb (struct msc_window *win) {} +msc_buffer_set_uc (struct msc *msc) {} +static inline void msc_buffer_set_wb (struct msc *msc) {}#endif /* CONFIG_X86 */ /**
@@ -1097,8 +1113,6 @@ static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)if (ret <=0 ) goto err_nomem; -msc_buffer_set_uc (win, ret); - win->nr_segs = ret; win->nr_blocks = nr_blocks;
@@ -1152,8 +1166,6 @@ static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) msc->base_addr =0 ; } -msc_buffer_set_wb (win); -if (msc->mbuf && msc->mbuf->free_window) msc->mbuf->free_window (msc->mbuf_priv, win->sgt);else
@@ -1260,6 +1272,8 @@ static int msc_buffer_multi_alloc(struct msc *msc, unsigned long *nr_pages,*/ static void msc_buffer_free (struct msc *msc) { +msc_buffer_set_wb (msc); +if (msc->mode ==MSC_MODE_SINGLE )msc_buffer_contig_free (msc);else if (msc->mode ==MSC_MODE_MULTI )
@@ -1303,6 +1317,8 @@ static int msc_buffer_alloc(struct msc *msc, unsigned long *nr_pages, }if (!ret) { +msc_buffer_set_uc (msc); +/* allocation should be visible before the counter goes to 0 */ smp_mb__before_atomic ();
Signature · 1 line
2.30.2
Alexander Shishkin
maintainerPATCH 4/4 intel_th: Wait until port is in reset before programming it
In reply to Alexander ShishkinSome devices don't drain their pipelines if we don't make sure that the corresponding output port is in reset before programming it for a new trace capture, resulting in bits of old trace appearing in the new trace capture. Fix that by explicitly making sure the reset is asserted before programming new trace capture.
--- drivers/hwtracing/intel_th/core.c | 17 +++++++++++++++++ drivers/hwtracing/intel_th/gth.c | 16 ++++++++++++++++ drivers/hwtracing/intel_th/intel_th.h | 3 +++ 3 files changed, 36 insertions(+)
drivers/hwtracing/intel_th/core.c +17 -0
@@ -217,6 +217,22 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RO (port); +static void intel_th_trace_prepare (struct intel_th_device *thdev) +{ +struct intel_th_device *hub =to_intel_th_hub (thdev); +struct intel_th_driver *hubdrv =to_intel_th_driver (hub->dev.driver); + +if (hub->type !=INTEL_TH_SWITCH ) +return ; + +if (thdev->type !=INTEL_TH_OUTPUT ) +return ; + +pm_runtime_get_sync (&thdev->dev); + hubdrv->prepare (hub, &thdev->output); +pm_runtime_put (&thdev->dev); +} +static int intel_th_output_activate (struct intel_th_device *thdev) { struct intel_th_driver *thdrv =
@@ -237,6 +253,7 @@ static int intel_th_output_activate(struct intel_th_device *thdev)if (ret) goto fail_put; +intel_th_trace_prepare (thdev);if (thdrv->activate) ret = thdrv->activate (thdev);else
drivers/hwtracing/intel_th/gth.c +16 -0
@@ -564,6 +564,21 @@ static void gth_tscu_resync(struct gth_device *gth)iowrite32 (reg, gth->base +REG_TSCU_TSUCTRL ); } +static void intel_th_gth_prepare (struct intel_th_device *thdev, +struct intel_th_output *output) +{ +struct gth_device *gth =dev_get_drvdata (&thdev->dev); +int count; + +/* +* Wait until the output port is in reset before we start +* programming it. +*/ +for (count =GTH_PLE_WAITLOOP_DEPTH ; + count && !(gth_output_get (gth, output->port) &BIT (5 )); count--) +cpu_relax (); +} +/** * intel_th_gth_enable() - enable tracing to an output device * @thdev: GTH device
@@ -815,6 +830,7 @@ static struct intel_th_driver intel_th_gth_driver = { .assign = intel_th_gth_assign, .unassign = intel_th_gth_unassign, .set_output = intel_th_gth_set_output, + .prepare = intel_th_gth_prepare, .enable = intel_th_gth_enable, .trig_switch = intel_th_gth_switch, .disable = intel_th_gth_disable,
drivers/hwtracing/intel_th/intel_th.h +3 -0
@@ -143,6 +143,7 @@ intel_th_output_assigned(struct intel_th_device *thdev)* @remove: remove method * @assign: match a given output type device against available outputs * @unassign: deassociate an output type device from an output port +* @prepare: prepare output port for tracing * @enable: enable tracing for a given output device * @disable: disable tracing for a given output device * @irq: interrupt callback
@@ -164,6 +165,8 @@ struct intel_th_driver { struct intel_th_device *othdev);void (*unassign)(struct intel_th_device *thdev,struct intel_th_device *othdev); +void (*prepare)(struct intel_th_device *thdev, +struct intel_th_output *output);void (*enable)(struct intel_th_device *thdev,struct intel_th_output *output); void (*trig_switch)(struct intel_th_device *thdev,
Signature · 1 line
2.30.2