Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Md Sadre Alam <quic_mdalam@quicinc.com>
To: Stephan Gerhold <stephan.gerhold@linaro.org>
Cc: <vkoul@kernel.org>, <ulf.hansson@linaro.org>,
	<robin.murphy@arm.com>, <kees@kernel.org>,
	<u.kleine-koenig@baylibre.com>, <linux-arm-msm@vger.kernel.org>,
	<av2082000@gmail.com>, <dmaengine@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <djakov@kernel.org>,
	<quic_varada@quicinc.com>, <quic_srichara@quicinc.com>
Subject: Re: [PATCH] dmaengine: qcom: bam_dma: Fix BAM_RIVISON register handling
Date: Fri, 10 Jan 2025 16:38:18 +0530	[thread overview]
Message-ID: <1a5fc7e9-39fe-e527-efc3-1ea990bbb53b@quicinc.com> (raw)
In-Reply-To: <Z4DzHs0gtbTPxq2_@linaro.org>



On 1/10/2025 3:45 PM, Stephan Gerhold wrote:
> On Fri, Jan 10, 2025 at 10:44:09AM +0530, Md Sadre Alam wrote:
>> This patch fixes a bug introduced in the previous commit where the
>> BAM_DESC_CNT_TRSHLD register was conditionally written based on BAM-NDP
>> mode. Additionally, it addresses an issue where reading the BAM_REVISION
>> register hangs if num-ees is not zero. A check has been added to prevent
>> this.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 57a7138d0627 ("dmaengine: qcom: bam_dma: Avoid writing unavailable register")
>> Reported-by: Georgi Djakov <djakov@kernel.org>
>> Link: https://lore.kernel.org/lkml/9ef3daa8-cdb1-49f2-8d19-a72d6210ff3a@kernel.org/
>> Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
>> ---
>>   drivers/dma/qcom/bam_dma.c | 23 ++++++++++++++++-------
>>   1 file changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
>> index c14557efd577..2b88b27f2f91 100644
>> --- a/drivers/dma/qcom/bam_dma.c
>> +++ b/drivers/dma/qcom/bam_dma.c
>> @@ -445,11 +445,15 @@ static void bam_reset(struct bam_device *bdev)
>>   	writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL));
>>   
>>   	/* set descriptor threshold, start with 4 bytes */
>> -	if (in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
>> -		     BAM_NDP_REVISION_END))
>> +	if (!bdev->num_ees && in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
>> +				       BAM_NDP_REVISION_END))
>>   		writel_relaxed(DEFAULT_CNT_THRSHLD,
>>   			       bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
>>   
>> +	if (bdev->num_ees && !bdev->bam_revision)
>> +		writel_relaxed(DEFAULT_CNT_THRSHLD, bam_addr(bdev, 0,
>> +							     BAM_DESC_CNT_TRSHLD));
>> +
>>   	/* Enable default set of h/w workarounds, ie all except BAM_FULL_PIPE */
>>   	writel_relaxed(BAM_CNFG_BITS_DEFAULT, bam_addr(bdev, 0, BAM_CNFG_BITS));
>>   
>> @@ -1006,10 +1010,14 @@ static void bam_apply_new_config(struct bam_chan *bchan,
>>   			maxburst = bchan->slave.src_maxburst;
>>   		else
>>   			maxburst = bchan->slave.dst_maxburst;
>> -		if (in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
>> -			     BAM_NDP_REVISION_END))
>> +		if (!bdev->num_ees && in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
>> +					       BAM_NDP_REVISION_END))
>>   			writel_relaxed(maxburst,
>>   				       bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
>> +
>> +		if (bdev->num_ees && !bdev->bam_revision)
>> +			writel_relaxed(DEFAULT_CNT_THRSHLD, bam_addr(bdev, 0,
>> +								     BAM_DESC_CNT_TRSHLD));
> 
> I guess you meant writel_relaxed(maxburst, ...) here?
> 
> This patch is quite confusing. We shouldn't duplicate the register
> writes here just to have different handling for if (bdev->num_ees) and
> if (!bdev->num_ees).
> 
> Also, num-ees is unrelated to the question if the BAM is BAM-NDP or
> BAM-Lite. Typically we specify qcom,num-ees in the device tree for a BAM
> if the BAM is either:
> 
>   - Controlled remotely (= powered on and initialized outside of Linux)
>     This is the case for the SLIMbus BAM Georgi mentioned.
> 
>   - Powered remotely (= powered on outside of Linux, but must be
>     initialized inside Linux)
> 
> Reading BAM_REVISION in these cases will hang in bam_init(), because we
> cannot guarantee the BAM is already powered on when the bam_dma driver
> is being loaded in Linux. We need to delay reading the register until
> the BAM is up.
> 
> Given that these writes happen only for the !bdev->controlled_remotely
> case, you could fix this more cleanly by reading the BAM revision inside
> bam_reset().
Thank you for review and suggestion. Will clean up in next revision.

Thanks,
Alam.

      reply	other threads:[~2025-01-10 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10  5:14 [PATCH] dmaengine: qcom: bam_dma: Fix BAM_RIVISON register handling Md Sadre Alam
2025-01-10 10:15 ` Stephan Gerhold
2025-01-10 11:08   ` Md Sadre Alam [this message]

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=1a5fc7e9-39fe-e527-efc3-1ea990bbb53b@quicinc.com \
    --to=quic_mdalam@quicinc.com \
    --cc=av2082000@gmail.com \
    --cc=djakov@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=robin.murphy@arm.com \
    --cc=stephan.gerhold@linaro.org \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vkoul@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