From: Songwei Chai <songwei.chai@oss.qualcomm.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
andersson@kernel.org, alexander.shishkin@linux.intel.com,
mike.leach@linaro.org, suzuki.poulose@arm.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
Subject: Re: [PATCH v10 3/7] qcom-tgu: Add signal priority support
Date: Tue, 27 Jan 2026 10:23:53 +0800 [thread overview]
Message-ID: <bcc3547c-b7d5-41a3-b291-4669c11d7f1c@oss.qualcomm.com> (raw)
In-Reply-To: <f34abcca-6b09-4f6c-96f3-e2295a82284e@oss.qualcomm.com>
On 1/13/2026 7:09 PM, Konrad Dybcio wrote:
> On 1/9/26 3:11 AM, Songwei Chai wrote:
>> Like circuit of a Logic analyzer, in TGU, the requirement could be
>> configured in each step and the trigger will be created once the
>> requirements are met. Add priority functionality here to sort the
>> signals into different priorities. The signal which is wanted could
>> be configured in each step's priority node, the larger number means
>> the higher priority and the signal with higher priority will be sensed
>> more preferentially.
>>
>> Signed-off-by: Songwei Chai <songwei.chai@oss.qualcomm.com>
>> ---
>
> [...]
>
>> +static ssize_t tgu_dataset_store(struct device *dev,
>> + struct device_attribute *attr,
>> + const char *buf, size_t size)
>> +{
>> + struct tgu_drvdata *tgu_drvdata = dev_get_drvdata(dev);
>> + struct tgu_attribute *tgu_attr =
>> + container_of(attr, struct tgu_attribute, attr);
>> + unsigned long val;
>> + int index;
>> +
>> + ret = kstrtoul(buf, 0, &val);
>> + if (ret)
>> + return ret;
>> +
>> + guard(spinlock)(&tgu_drvdata->lock);
>> + index = calculate_array_location(tgu_drvdata, tgu_attr->step_index,
>> + tgu_attr->operation_index,
>> + tgu_attr->reg_num);
>> +
>> + tgu_drvdata->value_table->priority[index] = val;
>> + return size;
>
> Style: some functions have a \n before return, some don't. The former
> is preferred
Sure, Konrad.
I will update and pay more attention next time.
>
>> +static umode_t tgu_node_visible(struct kobject *kobject,
>> + struct attribute *attr,
>> + int n)
>> +{
>> + struct device *dev = kobj_to_dev(kobject);
>> + struct tgu_drvdata *drvdata = dev_get_drvdata(dev);
>> + struct device_attribute *dev_attr =
>> + container_of(attr, struct device_attribute, attr);
>> + struct tgu_attribute *tgu_attr =
>> + container_of(dev_attr, struct tgu_attribute, attr);
>> + int ret = SYSFS_GROUP_INVISIBLE;
>> +
>> + if (tgu_attr->step_index < drvdata->max_step) {
>> + ret = (tgu_attr->reg_num < drvdata->max_reg) ?
>> + attr->mode : 0;
>> + }
>> + return ret;
>
> This is very convoluted
>
> How about:
>
> if (tgu_attr->step_index >= drvdata->max_step)
> return 0;
>
> if (tgu_attr->reg_num >= drvdata->max_reg)
> return 0;
>
> return attr->mode;
>
> ?
>
> [...]
>
I agree that the expanded form is clearer step-by-step, but I
intentionally kept the current version as it keeps the bounds checks
localized and avoids multiple early returns in this simple case.
I find the conditional expression still reasonably readable here, but
I’m happy to revisit this if you feel strongly about the style.
>> +static void tgu_set_reg_number(struct tgu_drvdata *drvdata)
>> +{
>> + int num_sense_input;
>> + int num_reg;
>> + u32 devid;
>> +
>> + devid = readl(drvdata->base + TGU_DEVID);
>> +
>> + num_sense_input = TGU_DEVID_SENSE_INPUT(devid);
>> + if (((num_sense_input * NUMBER_BITS_EACH_SIGNAL) % LENGTH_REGISTER) == 0)
>> + num_reg = (num_sense_input * NUMBER_BITS_EACH_SIGNAL) / LENGTH_REGISTER;
>> + else
>> + num_reg = ((num_sense_input * NUMBER_BITS_EACH_SIGNAL) / LENGTH_REGISTER) + 1;
>
> num_reg = base case
>
> if (num_sense_input * NUMBER_BITS_EACH_SIGNAL) % LENGTH_REGISTER)
> num_reg++;
>
> ?
>
Marked, will update.
> [...]
>
>> @@ -112,6 +250,8 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id)
>> {
>> struct device *dev = &adev->dev;
>> struct tgu_drvdata *drvdata;
>> + size_t priority_size;
>> + unsigned int *priority;
>
> reverse-Christmas-tree would be nice
>
>
Marked, will update.
>> int ret;
>>
>> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
>> @@ -127,12 +267,32 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id)
>>
>> spin_lock_init(&drvdata->lock);
>>
>> + tgu_set_reg_number(drvdata);
>> + tgu_set_steps(drvdata);
>> +
>> ret = sysfs_create_groups(&dev->kobj, tgu_attr_groups);
>> if (ret) {
>> dev_err(dev, "failed to create sysfs groups: %d\n", ret);
>> return ret;
>> }
>>
>> + drvdata->value_table =
>> + devm_kzalloc(dev, sizeof(*drvdata->value_table), GFP_KERNEL);
>> + if (!drvdata->value_table)
>> + return -ENOMEM;
>> +
>> + priority_size = MAX_PRIORITY * drvdata->max_reg *
>> + drvdata->max_step *
>> + sizeof(*(drvdata->value_table->priority));
>> +
>> + priority = devm_kzalloc(dev, priority_size, GFP_KERNEL);
>> +
>> + if (!priority)
>
> stray \n above
Marked, will update.
>
> [...]
>
>> +#define BMVAL(val, lsb, msb) ((val & GENMASK(msb, lsb)) >> lsb)
>> +#define TGU_DEVID_SENSE_INPUT(devid_val) ((int) BMVAL(devid_val, 10, 17))
>> +#define TGU_DEVID_STEPS(devid_val) ((int)BMVAL(devid_val, 3, 6))
>> +#define NUMBER_BITS_EACH_SIGNAL 4
>
> "TGU_BITS_PER_SIGNAL"
Marked, will update.
>
> Konrad
next prev parent reply other threads:[~2026-01-27 2:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 2:11 [PATCH v10 0/7] Provide support for Trigger Generation Unit Songwei Chai
2026-01-09 2:11 ` [PATCH v10 1/7] dt-bindings: arm: Add support for Qualcomm TGU trace Songwei Chai
2026-01-09 2:11 ` [PATCH v10 2/7] qcom-tgu: Add TGU driver Songwei Chai
2026-01-09 10:27 ` Suzuki K Poulose
2026-01-12 1:43 ` Songwei Chai
2026-01-09 11:28 ` Jie Gan
2026-01-12 1:41 ` Songwei Chai
2026-01-13 10:33 ` Konrad Dybcio
2026-01-27 2:13 ` Songwei Chai
2026-01-27 10:35 ` Konrad Dybcio
2026-01-09 2:11 ` [PATCH v10 3/7] qcom-tgu: Add signal priority support Songwei Chai
2026-01-13 11:09 ` Konrad Dybcio
2026-01-27 2:23 ` Songwei Chai [this message]
2026-01-27 10:30 ` Konrad Dybcio
2026-01-09 2:11 ` [PATCH v10 4/7] qcom-tgu: Add TGU decode support Songwei Chai
2026-01-13 11:13 ` Konrad Dybcio
2026-01-27 2:34 ` Songwei Chai
2026-01-27 10:31 ` Konrad Dybcio
2026-01-09 2:11 ` [PATCH v10 5/7] qcom-tgu: Add support to configure next action Songwei Chai
2026-01-13 11:15 ` Konrad Dybcio
2026-01-27 2:43 ` Songwei Chai
2026-01-27 10:32 ` Konrad Dybcio
2026-01-09 2:11 ` [PATCH v10 6/7] qcom-tgu: Add timer/counter functionality for TGU Songwei Chai
2026-01-13 11:19 ` Konrad Dybcio
2026-01-27 3:02 ` Songwei Chai
2026-01-09 2:11 ` [PATCH v10 7/7] qcom-tgu: Add reset node to initialize Songwei Chai
2026-01-13 11:22 ` Konrad Dybcio
2026-01-27 2:50 ` Songwei Chai
2026-01-13 1:53 ` [PATCH v10 0/7] Provide support for Trigger Generation Unit Songwei Chai
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=bcc3547c-b7d5-41a3-b291-4669c11d7f1c@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=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=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