Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

intel_th: Update scratchpad bits according to enabled output activity

Intel TH implements a scratchpad register to indicate to the firmware
and external debuggers what trace configuration is enabled so that
everybody plays nicely together. The register is a bit field and the
bit assignment convention is described in the developer's manual.

This patch enables the driver to automatically set scratchpad register
bits according to the output configuration that's enabled.

Based on work by Yann Fouassier.

Signed-off-by: Yann Fouassier <yann.fouassier@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Shishkin and committed by
Greg Kroah-Hartman
4d02ceff c1a327c4

+59 -4
+5
drivers/hwtracing/intel_th/core.c
··· 319 319 unsigned nres; 320 320 unsigned type; 321 321 unsigned otype; 322 + unsigned scrpd; 322 323 int id; 323 324 } intel_th_subdevices[TH_SUBDEVICE_MAX] = { 324 325 { ··· 353 352 .id = 0, 354 353 .type = INTEL_TH_OUTPUT, 355 354 .otype = GTH_MSU, 355 + .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED, 356 356 }, 357 357 { 358 358 .nres = 2, ··· 373 371 .id = 1, 374 372 .type = INTEL_TH_OUTPUT, 375 373 .otype = GTH_MSU, 374 + .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED, 376 375 }, 377 376 { 378 377 .nres = 2, ··· 406 403 .name = "pti", 407 404 .type = INTEL_TH_OUTPUT, 408 405 .otype = GTH_PTI, 406 + .scrpd = SCRPD_PTI_IS_PRIM_DEST, 409 407 }, 410 408 { 411 409 .nres = 1, ··· 481 477 thdev->dev.devt = MKDEV(th->major, i); 482 478 thdev->output.type = subdev->otype; 483 479 thdev->output.port = -1; 480 + thdev->output.scratchpad = subdev->scrpd; 484 481 } 485 482 486 483 err = device_add(&thdev->dev);
+13 -1
drivers/hwtracing/intel_th/gth.c
··· 286 286 if (scratchpad & SCRPD_DEBUGGER_IN_USE) 287 287 return -EBUSY; 288 288 289 + /* Always save/restore STH and TU registers in S0ix entry/exit */ 290 + scratchpad |= SCRPD_STH_IS_ENABLED | SCRPD_TRIGGER_IS_ENABLED; 291 + iowrite32(scratchpad, gth->base + REG_GTH_SCRPD0); 292 + 289 293 /* output ports */ 290 294 for (port = 0; port < 8; port++) { 291 295 if (gth_output_parm_get(gth, port, TH_OUTPUT_PARM(port)) == ··· 492 488 if (!count) 493 489 dev_dbg(&thdev->dev, "timeout waiting for GTH[%d] PLE\n", 494 490 output->port); 491 + 492 + reg = ioread32(gth->base + REG_GTH_SCRPD0); 493 + reg &= ~output->scratchpad; 494 + iowrite32(reg, gth->base + REG_GTH_SCRPD0); 495 495 } 496 496 497 497 /** ··· 510 502 struct intel_th_output *output) 511 503 { 512 504 struct gth_device *gth = dev_get_drvdata(&thdev->dev); 513 - u32 scr = 0xfc0000; 505 + u32 scr = 0xfc0000, scrpd; 514 506 int master; 515 507 516 508 spin_lock(&gth->gth_lock); ··· 524 516 525 517 output->active = true; 526 518 spin_unlock(&gth->gth_lock); 519 + 520 + scrpd = ioread32(gth->base + REG_GTH_SCRPD0); 521 + scrpd |= output->scratchpad; 522 + iowrite32(scrpd, gth->base + REG_GTH_SCRPD0); 527 523 528 524 iowrite32(scr, gth->base + REG_GTH_SCR); 529 525 iowrite32(0, gth->base + REG_GTH_SCR2);
-3
drivers/hwtracing/intel_th/gth.h
··· 57 57 REG_GTH_SCRPD3 = 0xec, /* ScratchPad[3] */ 58 58 }; 59 59 60 - /* Externall debugger is using Intel TH */ 61 - #define SCRPD_DEBUGGER_IN_USE BIT(24) 62 - 63 60 /* waiting for Pipeline Empty bit(s) to assert for GTH */ 64 61 #define GTH_PLE_WAITLOOP_DEPTH 10000 65 62
+41
drivers/hwtracing/intel_th/intel_th.h
··· 30 30 * struct intel_th_output - descriptor INTEL_TH_OUTPUT type devices 31 31 * @port: output port number, assigned by the switch 32 32 * @type: GTH_{MSU,CTP,PTI} 33 + * @scratchpad: scratchpad bits to flag when this output is enabled 33 34 * @multiblock: true for multiblock output configuration 34 35 * @active: true when this output is enabled 35 36 * ··· 42 41 struct intel_th_output { 43 42 int port; 44 43 unsigned int type; 44 + unsigned int scratchpad; 45 45 bool multiblock; 46 46 bool active; 47 47 }; ··· 241 239 GTH_MSU, /* memory/usb */ 242 240 GTH_CTP, /* Common Trace Port */ 243 241 GTH_PTI = 4, /* MIPI-PTI */ 242 + }; 243 + 244 + /* 245 + * Scratchpad bits: tell firmware and external debuggers 246 + * what we are up to. 247 + */ 248 + enum { 249 + /* Memory is the primary destination */ 250 + SCRPD_MEM_IS_PRIM_DEST = BIT(0), 251 + /* XHCI DbC is the primary destination */ 252 + SCRPD_DBC_IS_PRIM_DEST = BIT(1), 253 + /* PTI is the primary destination */ 254 + SCRPD_PTI_IS_PRIM_DEST = BIT(2), 255 + /* BSSB is the primary destination */ 256 + SCRPD_BSSB_IS_PRIM_DEST = BIT(3), 257 + /* PTI is the alternate destination */ 258 + SCRPD_PTI_IS_ALT_DEST = BIT(4), 259 + /* BSSB is the alternate destination */ 260 + SCRPD_BSSB_IS_ALT_DEST = BIT(5), 261 + /* DeepSx exit occurred */ 262 + SCRPD_DEEPSX_EXIT = BIT(6), 263 + /* S4 exit occurred */ 264 + SCRPD_S4_EXIT = BIT(7), 265 + /* S5 exit occurred */ 266 + SCRPD_S5_EXIT = BIT(8), 267 + /* MSU controller 0/1 is enabled */ 268 + SCRPD_MSC0_IS_ENABLED = BIT(9), 269 + SCRPD_MSC1_IS_ENABLED = BIT(10), 270 + /* Sx exit occurred */ 271 + SCRPD_SX_EXIT = BIT(11), 272 + /* Trigger Unit is enabled */ 273 + SCRPD_TRIGGER_IS_ENABLED = BIT(12), 274 + SCRPD_ODLA_IS_ENABLED = BIT(13), 275 + SCRPD_SOCHAP_IS_ENABLED = BIT(14), 276 + SCRPD_STH_IS_ENABLED = BIT(15), 277 + SCRPD_DCIH_IS_ENABLED = BIT(16), 278 + SCRPD_VER_IS_ENABLED = BIT(17), 279 + /* External debugger is using Intel TH */ 280 + SCRPD_DEBUGGER_IN_USE = BIT(24), 244 281 }; 245 282 246 283 #endif