mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Songwei.Chai" <songwei.chai@oss.qualcomm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
	andersson@kernel.org, alexander.shishkin@linux.intel.com,
	mike.leach@linaro.org, konrad.dybcio@oss.qualcomm.com,
	james.clark@arm.com, krzk+dt@kernel.org, conor+dt@kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, coresight@lists.linaro.org,
	devicetree@vger.kernel.org, gregkh@linuxfoundation.org,
	songchai@qti.qualcomm.com, Jie Gan <jie.gan@oss.qualcomm.com>
Subject: Re: [PATCH v18 5/8] qcom-tgu: Add TGU decode support
Date: Tue, 17 Nov 2026 14:52:47 +0800	[thread overview]
Message-ID: <4bdb2999-d8c9-400e-8a23-d950a95e43b4@oss.qualcomm.com> (raw)
In-Reply-To: <e621c3a7-5633-4d03-9494-a6fa45daea02@arm.com>


On 11/16/2026 7:43 PM, Suzuki K Poulose wrote:
> On 16/11/2026 07:41, Songwei Chai wrote:
>> Decoding is when all the potential pieces for creating a trigger
>> are brought together for a given step. Example - there may be a
>> counter keeping track of some occurrences and a priority-group that
>> is being used to detect a pattern on the sense inputs. These 2
>> inputs to condition_decode must be programmed, for a given step,
>> to establish the condition for the trigger, or movement to another
>> steps.
>>
>> Reviewed-by: Jie Gan <jie.gan@oss.qualcomm.com>
>> Signed-off-by: Songwei Chai <songwei.chai@oss.qualcomm.com>
>> ---
>>   .../ABI/testing/sysfs-bus-amba-devices-tgu    |   7 +
>>   drivers/hwtracing/qcom/tgu.c                  | 200 +++++++++++++++---
>>   drivers/hwtracing/qcom/tgu.h                  |  35 ++-
>>   3 files changed, 214 insertions(+), 28 deletions(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu 
>> b/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu
>> index 3be0b912c937..c7e6f13da83d 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu
>> +++ b/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu
>> @@ -14,3 +14,10 @@ KernelVersion:    7.5
>>   Contact:    Jinlong Mao <jinlong.mao@oss.qualcomm.com>, Songwei 
>> Chai <songwei.chai@oss.qualcomm.com>
>>   Description:
>>           (RW) Set/Get the sensed signal with specific step and 
>> priority for TGU.
>> +
>> +What: 
>> /sys/bus/amba/devices/<tgu-name>/step[0:7]_condition_decode/reg[0:3]
>> +Date:        November 2026
>> +KernelVersion:    7.5
>> +Contact:    Jinlong Mao <jinlong.mao@oss.qualcomm.com>, Songwei Chai 
>> <songwei.chai@oss.qualcomm.com>
>> +Description:
>> +        (RW) Set/Get the decode mode with specific step for TGU.
>> diff --git a/drivers/hwtracing/qcom/tgu.c b/drivers/hwtracing/qcom/tgu.c
>> index 917d506cddf9..1809cca4a94f 100644
>> --- a/drivers/hwtracing/qcom/tgu.c
>> +++ b/drivers/hwtracing/qcom/tgu.c
>> @@ -18,8 +18,8 @@
>>     struct tgu_attribute {
>>       struct device_attribute attr;
>> +    enum operation_index operation_index;
>>       u8 step_index;
>> -    u8 priority;
>>       u8 reg_num;
>>   };
>>   @@ -27,11 +27,36 @@ struct tgu_attribute {
>>    * drvdata->priority is a flat [priority][step][reg] array.
>>    */
>>   static int calculate_array_location(struct tgu_drvdata *drvdata,
>> -                    int step_index, int priority,
>> +                    int step_index, int operation_index,
>>                       int reg_index)
>>   {
>> -    return priority * (drvdata->num_step) * (drvdata->num_reg) +
>> -        step_index * (drvdata->num_reg) + reg_index;
>> +    switch (operation_index) {
>> +    case TGU_PRIORITY0:
>> +    case TGU_PRIORITY1:
>> +    case TGU_PRIORITY2:
>> +    case TGU_PRIORITY3:
>> +        return operation_index * (drvdata->num_step) *
>> +            (drvdata->num_reg) +
>> +            step_index * (drvdata->num_reg) + reg_index;
>> +    case TGU_CONDITION_DECODE:
>> +        return step_index * (drvdata->num_condition_decode) +
>> +            reg_index;
>> +    default:
>> +        break;
>> +    }
>
> > +
> > +    if (result == -EINVAL)
> > +        dev_err(drvdata->dev, "check array location - Fail\n");
>
> see more below
confirmed.
>
>> +
>> +    return -EINVAL;
>> +}
>> +
>> +static int check_array_location(struct tgu_drvdata *drvdata, int step,
>> +                int ops, int reg)
>> +{
>> +    int result = calculate_array_location(drvdata, step, ops, reg);
>> +
>> +    if (result == -EINVAL)
>> +        dev_err(drvdata->dev, "check array location - Fail\n");
>> +
>> +    return result;
>
> Could we not fold this check in to calculate_array_location as shown
> above ?
>
confirmed.
>
>
> ...
>
>
>> index d769379b8421..7d88ad8e730f 100644
>> --- a/drivers/hwtracing/qcom/tgu.h
>> +++ b/drivers/hwtracing/qcom/tgu.h
>> @@ -16,7 +16,8 @@
>>       ((int)FIELD_GET(GENMASK(17, 10), devid_val))
>>   #define TGU_DEVID_STEPS(devid_val) \
>>       ((int)FIELD_GET(GENMASK(6, 3), devid_val))
>> -
>> +#define TGU_DEVID_CONDITIONS(devid_val) \
>> +    ((int)FIELD_GET(GENMASK(2, 0), devid_val))
>>   #define TGU_BITS_PER_SIGNAL    4
>>   #define LENGTH_REGISTER        32
>>   @@ -44,6 +45,7 @@
>>    */
>>   #define STEP_SIZE        0x1D8
>>   #define PRIORITY0_OFFSET    0x0074
>> +#define CONDITION_DECODE_OFFSET    0x0050
>
> nit: s/CONDITION_DECODE_BASE    0x50

confirmed,

use "#define CONDITION_DECODE_BASE 0x0010" as offset is relative to the 
start of the step's block.

>
>>   #define PRIORITY_STRIDE        0x0060
>>   #define REG_SIZE        0x4
>>   @@ -54,6 +56,7 @@
>>    *
>>    *   TGU_MAX_STEPS         matches the static step0..step7 sysfs 
>> tables.
>>    *   TGU_MAX_PRIORITY_REGS matches the static reg0..reg23 sysfs 
>> tables.
>> + *   TGU_MAX_CONDITION_DECODE decode region 0x50..0x5F holds 4 u32 
>> registers
>>    *
>>    * Each priority level's block spans a full PRIORITY_STRIDE (0x60 
>> bytes),
>>    * i.e. PRIORITY_STRIDE / REG_SIZE = 24 registers, all of them 
>> implemented.
>> @@ -61,15 +64,40 @@
>>     #define TGU_MAX_STEPS                  8
>>   #define TGU_MAX_PRIORITY_REGS          24
>> +#define TGU_MAX_CONDITION_DECODE       4
>>     /* Maximum priority that TGU supports */
>>   #define MAX_PRIORITY                   4
>>   +/*
>> + * Values for struct tgu_attribute.operation_index: TGU_PRIORITY0..
>> + * TGU_PRIORITY3 select a priority level, TGU_CONDITION_DECODE 
>> selects the
>> + * condition decode registers instead.
>> + */
>> +enum operation_index {
>> +    TGU_PRIORITY0,
>> +    TGU_PRIORITY1,
>> +    TGU_PRIORITY2,
>> +    TGU_PRIORITY3,
>> +    TGU_CONDITION_DECODE,
>> +};
>> +
>>   /* Calculate compare step addresses */
>>   #define PRIORITY_REG_STEP(step, priority, reg)\
>>       (PRIORITY0_OFFSET + PRIORITY_STRIDE * priority +\
>>        REG_SIZE * reg + STEP_SIZE * step)
>>   +#define CONDITION_DECODE_STEP(step, decode) \
>> +    (CONDITION_DECODE_OFFSET + REG_SIZE * decode + STEP_SIZE * step)
>
> Please
>
> #define CONDITION_DECODE_OFFSET(step, reg)        \
>     (STEP_OFFSET(step) + CONDITIION_DECODE_BASE + REG_SIZE * reg)
confirmed.
>
>
>> +
>> +/*
>> + * Neutral ('NOT') value for the condition decode registers. This is 
>> the
>> + * driver's default so that, before userspace programs a real 
>> decode, an
>> + * enabled step does not spuriously match. Used both when seeding 
>> the shadow
>> + * table at probe and when clearing it via reset_tgu.
>> + */
>> +#define TGU_CONDITION_DECODE_NOT 0x1000000
>
> minor nit: TGU_CONDITION_DECODE_DEFAULT 0x1000000 ?
I think |NOT| reflects the hardware-defined decode operation rather than 
an arbitrary driver default,
so I’d lean towards keeping the current name. But I’m happy to change it 
to |_DEFAULT| if you prefer.

>
>
>
>> +
>>   /**
>>    * struct tgu_drvdata - Data structure for a TGU (Trigger 
>> Generation Unit)
>>    * @base: Memory-mapped base address of the TGU device
>> @@ -79,8 +107,11 @@
>>    * @enabled: Flag indicating whether the TGU device is enabled
>>    * @priority: Per-step, per-priority-level, per-register values 
>> staged by
>>    *            sysfs writes and flushed to hardware by tgu_enable()
>> + * @condition_decode: Per-step, per-register decode values staged by 
>> sysfs
>> + *                     writes and flushed to hardware by tgu_enable()
>
>
>>    * @num_reg: Number of priority registers implemented per priority 
>> level
>
> This now looks awkwardly generic with other registers coming in. Should
> we name it num_prio_regs from the beginning ?
confirmed.
>
> Suzuki
>
>>    * @num_step: Number of steps implemented
>> + * @num_condition_decode: Maximum number of condition_decode
>>    *
>>    * This structure defines the data associated with a TGU device,
>>    * including its base address, device pointer, the lock serialising
>> @@ -92,8 +123,10 @@ struct tgu_drvdata {
>>       struct mutex lock;
>>       bool enabled;
>>       unsigned int priority[TGU_MAX_STEPS * MAX_PRIORITY * 
>> TGU_MAX_PRIORITY_REGS];
>> +    unsigned int condition_decode[TGU_MAX_STEPS * 
>> TGU_MAX_CONDITION_DECODE];
>>       int num_reg;
>>       int num_step;
>> +    int num_condition_decode;
>>   };
>>     #endif
>

  reply	other threads:[~2026-11-17  6:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  7:41 [PATCH v18 0/8] Provide support for Trigger Generation Unit Songwei Chai
2026-11-16  7:41 ` [PATCH v18 1/8] dt-bindings: arm: Add support for Qualcomm TGU trace Songwei Chai
2026-11-16  7:41 ` [PATCH v18 2/8] coresight: Move CoreSight management register defs to linux/coresight.h Songwei Chai
2026-11-16  7:41 ` [PATCH v18 3/8] qcom-tgu: Add TGU driver Songwei Chai
2026-11-16  7:41 ` [PATCH v18 4/8] qcom-tgu: Add signal priority support Songwei Chai
2026-11-16 11:16   ` Suzuki K Poulose
2026-11-17  3:16     ` Songwei.Chai
2026-11-16  7:41 ` [PATCH v18 5/8] qcom-tgu: Add TGU decode support Songwei Chai
2026-11-16 11:43   ` Suzuki K Poulose
2026-11-17  6:52     ` Songwei.Chai [this message]
2026-11-16  7:41 ` [PATCH v18 6/8] qcom-tgu: Add support to configure next action Songwei Chai
2026-11-16  7:41 ` [PATCH v18 7/8] qcom-tgu: Add timer/counter functionality for TGU Songwei Chai
2026-11-16  7:41 ` [PATCH v18 8/8] qcom-tgu: Add reset node to initialize Songwei Chai
2026-11-16  9:25 ` [PATCH v18 0/8] Provide support for Trigger Generation Unit Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4bdb2999-d8c9-400e-8a23-d950a95e43b4@oss.qualcomm.com \
    --to=songwei.chai@oss.qualcomm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=coresight@lists.linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.clark@arm.com \
    --cc=jie.gan@oss.qualcomm.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=songchai@qti.qualcomm.com \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®