mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andy Gross <agross@kernel.org>,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Alex Elder <elder@ieee.org>,
	Arnd Bergmann <arnd@arndb.de>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<devicetree@vger.kernel.org>,
	Sibi Sankar <quic_sibis@quicinc.com>,
	"Rajendra Nayak" <quic_rjendra@quicinc.com>
Subject: Re: [PATCH V23 2/3] misc: dcc: Add driver support for Data Capture and Compare unit(DCC)
Date: Thu, 15 Jun 2023 19:17:34 +0530	[thread overview]
Message-ID: <5d9ab90f-4fc3-26c6-141e-e9388ac2f0cf@quicinc.com> (raw)
In-Reply-To: <2023061515-unbuckled-consonant-e207@gregkh>



On 6/15/2023 6:20 PM, Greg Kroah-Hartman wrote:
> On Thu, Jun 15, 2023 at 06:13:53PM +0530, Souradeep Chowdhury wrote:
>>
>>
>> On 6/15/2023 4:03 PM, Greg Kroah-Hartman wrote:
>>> On Thu, May 04, 2023 at 11:36:22PM -0700, Souradeep Chowdhury wrote:
>>>> +/**
>>>> + * struct dcc_config_entry - configuration information related to each dcc instruction
>>>> + * @base:                    Base address of the register to be configured in dcc
>>>
>>> Why is this a u32 and not a bigger size?
>>
>> Currently only 32 bit register addresses are supported for DCC
>> configuration.
>>
>>>
>>>> + * @offset:                  Offset to the base address to be configured in dcc
>>>> + * @len:                     Length of the address in words to be configured in dcc
>>>
>>> What is a "word" here, 16 bits?
>>
>> Each word is 4 bytes(32 bits)
> 
> See, I guess wrong, you should say what this is :)

Ack

> 
>>>> + * @loop_cnt:                The number of times to loop on the register address in case
>>>> +				of loop instructions
>>>> + * @write_val:               The value to be written on the register address in case of
>>>> +				write instructions
>>>> + * @mask:                    Mask corresponding to the value to be written in case of
>>>> +				write instructions
>>>> + * @apb_bus:                 Type of bus to be used for the instruction, can be either
>>>> +				'apb' or 'ahb'
>>>
>>> How can a bool be either "apb" or "ahb"?
>>
>> 1 stands for apb and 0 for ahb. Will update the same here.
> 
> Why not have an enum?  Will there ever be another "bus"?

No, only these two are supported for dcc.

> 
>>>> +static ssize_t ready_read(struct file *filp, char __user *userbuf,
>>>> +			  size_t count, loff_t *ppos)
>>>> +{
>>>> +	int ret = 0;
>>>> +	char *buf;
>>>> +	struct dcc_drvdata *drvdata = filp->private_data;
>>>> +
>>>> +	mutex_lock(&drvdata->mutex);
>>>> +
>>>> +	if (!is_dcc_enabled(drvdata)) {
>>>> +		ret = -EINVAL;
>>>> +		goto out_unlock;
>>>> +	}
>>>> +
>>>> +	if (!FIELD_GET(BIT(1), readl(drvdata->base + dcc_status(drvdata->mem_map_ver))))
>>>> +		buf = "Y\n";
>>>> +	else
>>>> +		buf = "N\n";
>>>> +out_unlock:
>>>> +	mutex_unlock(&drvdata->mutex);
>>>> +
>>>> +	if (ret < 0)
>>>> +		return -EINVAL;
>>>> +	else
>>>
>>> You do the "lock, get a value, unlock, do something with the value"
>>> thing a bunch, but what prevents the value from changing after the lock
>>> happens?  So why is the lock needed at all?
>>
>> The lock is used to prevent concurrent accesses of the drv_data when
>> scripts are being run from userspace.
> 
> How would that matter?  The state can change instantly after the lock is
> given up, and then the returned value is now incorrect.  So no need for
> a lock at all as you really aren't "protecting" anything, or am I
> missing something else?

This lock is needed to protect the access to the global instance of 
drv_data structure instantiated at probe time within each individual 
callbacks of debugfs.

> 
> thanks,
> 
> greg k-h

  reply	other threads:[~2023-06-15 13:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05  6:36 [PATCH V23 0/3] misc: " Souradeep Chowdhury
2023-05-05  6:36 ` [PATCH V23 1/3] dt-bindings: misc: qcom,dcc: Add the dtschema Souradeep Chowdhury
2023-05-05  6:36 ` [PATCH V23 2/3] misc: dcc: Add driver support for Data Capture and Compare unit(DCC) Souradeep Chowdhury
2023-05-24  5:10   ` Trilok Soni
2023-05-31 16:17     ` Trilok Soni
2023-06-15 10:33   ` Greg Kroah-Hartman
2023-06-15 12:43     ` Souradeep Chowdhury
2023-06-15 12:50       ` Greg Kroah-Hartman
2023-06-15 13:47         ` Souradeep Chowdhury [this message]
2023-06-15 14:06           ` Greg Kroah-Hartman
2023-06-21  9:18             ` Souradeep Chowdhury
2023-05-05  6:36 ` [PATCH V23 3/3] MAINTAINERS: Add the entry for DCC(Data Capture and Compare) driver support Souradeep Chowdhury
2023-05-24  4:55 ` [PATCH V23 0/3] misc: Add driver support for Data Capture and Compare unit(DCC) Souradeep Chowdhury
2023-06-07  5:26 ` Souradeep Chowdhury
2023-06-15 10:26 ` Greg Kroah-Hartman

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=5d9ab90f-4fc3-26c6-141e-e9388ac2f0cf@quicinc.com \
    --to=quic_schowdhu@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=elder@ieee.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@somainline.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_rjendra@quicinc.com \
    --cc=quic_sibis@quicinc.com \
    --cc=robh+dt@kernel.org \
    /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®