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

intel_th: Support Host Debugger mode of operation

This patch adds a 'host_mode' module option to enable host-driven
operational mode in the driver. In this mode, the driver does not
perform trace configuration or enable trace capture, but still
provides all the means necessary for software trace sources to
write their data to the Trace Hub. This means that the debug host
takes care of all the configuration and enabling and we do not
interfere.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>

+22 -8
+18 -8
drivers/hwtracing/intel_th/core.c
··· 29 29 #include "intel_th.h" 30 30 #include "debug.h" 31 31 32 + static bool host_mode __read_mostly; 33 + module_param(host_mode, bool, 0444); 34 + 32 35 static DEFINE_IDA(intel_th_ida); 33 36 34 37 static int intel_th_match(struct device *dev, struct device_driver *driver) ··· 530 527 { 531 528 struct resource res[3]; 532 529 unsigned int req = 0; 533 - int i, err; 530 + int src, dst, err; 534 531 535 532 /* create devices for each intel_th_subdevice */ 536 - for (i = 0; i < ARRAY_SIZE(intel_th_subdevices); i++) { 537 - struct intel_th_subdevice *subdev = &intel_th_subdevices[i]; 533 + for (src = 0, dst = 0; src < ARRAY_SIZE(intel_th_subdevices); src++) { 534 + const struct intel_th_subdevice *subdev = 535 + &intel_th_subdevices[src]; 538 536 struct intel_th_device *thdev; 539 537 int r; 538 + 539 + /* only allow SOURCE and SWITCH devices in host mode */ 540 + if (host_mode && subdev->type == INTEL_TH_OUTPUT) 541 + continue; 540 542 541 543 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, 542 544 subdev->id); ··· 585 577 } 586 578 587 579 if (subdev->type == INTEL_TH_OUTPUT) { 588 - thdev->dev.devt = MKDEV(th->major, i); 580 + thdev->dev.devt = MKDEV(th->major, dst); 589 581 thdev->output.type = subdev->otype; 590 582 thdev->output.port = -1; 591 583 thdev->output.scratchpad = subdev->scrpd; 584 + } else if (subdev->type == INTEL_TH_SWITCH) { 585 + thdev->host_mode = host_mode; 592 586 } 593 587 594 588 err = device_add(&thdev->dev); ··· 607 597 req++; 608 598 } 609 599 610 - th->thdev[i] = thdev; 600 + th->thdev[dst++] = thdev; 611 601 } 612 602 613 603 return 0; 614 604 615 605 kill_subdevs: 616 - for (i-- ; i >= 0; i--) 617 - intel_th_device_remove(th->thdev[i]); 606 + for (; dst >= 0; dst--) 607 + intel_th_device_remove(th->thdev[dst]); 618 608 619 609 return err; 620 610 } ··· 727 717 728 718 intel_th_request_hub_module_flush(th); 729 719 for (i = 0; i < TH_SUBDEVICE_MAX; i++) 730 - if (th->thdev[i] != th->hub) 720 + if (th->thdev[i] && th->thdev[i] != th->hub) 731 721 intel_th_device_remove(th->thdev[i]); 732 722 733 723 intel_th_device_remove(th->hub);
+4
drivers/hwtracing/intel_th/intel_th.h
··· 54 54 * @num_resources: number of resources in @resource array 55 55 * @type: INTEL_TH_{SOURCE,OUTPUT,SWITCH} 56 56 * @id: device instance or -1 57 + * @host_mode: Intel TH is controlled by an external debug host 57 58 * @output: output descriptor for INTEL_TH_OUTPUT devices 58 59 * @name: device name to match the driver 59 60 */ ··· 64 63 unsigned int num_resources; 65 64 unsigned int type; 66 65 int id; 66 + 67 + /* INTEL_TH_SWITCH specific */ 68 + bool host_mode; 67 69 68 70 /* INTEL_TH_OUTPUT specific */ 69 71 struct intel_th_output output;