linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: "Heiko Stübner" <heiko@sntech.de>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/9] misc: sram: fix enabled clock leak on error path
Date: Sun, 24 May 2015 23:12:25 +0300	[thread overview]
Message-ID: <556230A9.8030307@mentor.com> (raw)
In-Reply-To: <1432121401.4466.60.camel@pengutronix.de>

Hi Philipp,

On 20.05.2015 14:30, Philipp Zabel wrote:
> Hi Vladimir,
> 
> Am Dienstag, den 19.05.2015, 16:11 +0300 schrieb Vladimir Zapolskiy:
>> Hi Philipp,
>>
>> On 19.05.2015 13:41, Philipp Zabel wrote:
>>> Am Montag, den 18.05.2015, 22:08 +0300 schrieb Vladimir Zapolskiy:
>>>> If devm_gen_pool_create() fails, the previously enabled sram->clk is
>>>> not disabled on probe() exit.
>>>>
>>>> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
>>>> ---
>>>>  drivers/misc/sram.c | 9 +++++----
>>>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
>>>> index eeaaf5f..b44a423 100644
>>>> --- a/drivers/misc/sram.c
>>>> +++ b/drivers/misc/sram.c
>>>> @@ -90,16 +90,17 @@ static int sram_probe(struct platform_device *pdev)
>>>>  	if (!sram)
>>>>  		return -ENOMEM;
>>>>  
>>>> +	sram->pool = devm_gen_pool_create(&pdev->dev,
>>>> +					  ilog2(SRAM_GRANULARITY), -1);
>>>> +	if (!sram->pool)
>>>> +		return -ENOMEM;
>>>> +
>>>>  	sram->clk = devm_clk_get(&pdev->dev, NULL);
>>>>  	if (IS_ERR(sram->clk))
>>>>  		sram->clk = NULL;
>>>>  	else
>>>>  		clk_prepare_enable(sram->clk);
>>>
>>> Here you move sram->clk around, and later in patch 7 it gets moved
>>> again. To me it looks like the two should be squashed together.
>>
>> I agree with you, instead of moving sram->pool up it is better to place
>> sram->clk right at the end of probe(), in other words this patch can be
>> safely merged with patch 7 and the series becomes a bit shorter.
>>
>> Thank you for the finding, I'm going to resend the change, please let me
>> know your opinion about "%pa" vs "0x%llx", if it is needed to be changed
>> or not.
> 
> I'd prefer to use %pa for the phys_addr_t types. You could argue that
> %pa is inappropriate as those are addresses relative to the SRAM region,
> not physical addresses as seen by the CPU. But following that argument,
> using phys_addr_t in the first place would not be correct either.

The driver utilizes genalloc gen_pool_add_virt() function, whose
corresponding argument is of phys_addr_t type (and it is correct in my
opinion), the interface to this function dictates the type of its
arguments on client's side.

> Which leads me to question whether we will see larger than 4 GiB SRAM
> regions in the foreseeable future?

The question is not only about SRAM region size, but mainly it is about
the base address of SRAM, and don't want to exclude a situation, when
some kind of SRAM device is found outside of u32 addressable memory
space. Actually I believe an arbitrary physical memory region may be
claimed as it were a "SRAM device" and the driver still works fine.

If phys_addr_t arguments are accepted, then back to "%pa" vs "0x%llx"
question:

From: Philipp Zabel <p.zabel@pengutronix.de>
Date: Tue, 19 May 2015 12:38:37 +0200
In-Reply-To:
<1431976122-4228-4-git-send-email-vladimir_zapolskiy@mentor.com>

> Now that block->start is of type phys_addr_t, is there a reason
> not to use %pa ?

[snip]

>> -		dev_dbg(&pdev->dev, "adding chunk 0x%lx-0x%lx\n",
>> -			cur_start, cur_start + cur_size);
>> +		dev_dbg(&pdev->dev, "adding chunk 0x%llx-0x%llx\n",
>> +			(unsigned long long)cur_start,
>> +			(unsigned long long)cur_start + cur_size);
>
>		dev_dbg(&pdev->dev, "adding chunk 0x%pa-0x%pa\n",
>			&cur_start, &block->start);
>

I see that the change preserves the functionality, so I'll change printk
format to "%pa", will resend the series tomorrow.

--
With best wishes,
Vladimir


  reply	other threads:[~2015-05-24 20:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 19:08 [PATCH v3 0/9] misc: sram: minor fixes and clean up Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 1/9] misc: sram: fix enabled clock leak on error path Vladimir Zapolskiy
2015-05-19 10:41   ` Philipp Zabel
2015-05-19 13:11     ` Vladimir Zapolskiy
2015-05-20 11:30       ` Philipp Zabel
2015-05-24 20:12         ` Vladimir Zapolskiy [this message]
2015-05-26  8:54           ` Philipp Zabel
2015-05-29 11:31             ` Vladimir Zapolskiy
2015-05-29 15:38               ` Philipp Zabel
2015-05-18 19:08 ` [PATCH v3 2/9] misc: sram: fix device node reference leak on error Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 3/9] misc: sram: use phys_addr_t instead of u32 for physical address Vladimir Zapolskiy
2015-05-19 10:38   ` Philipp Zabel
2015-05-19 12:30     ` Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 4/9] misc: sram: bump error message level on unclean driver unbinding Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 5/9] misc: sram: report correct SRAM pool size Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 6/9] misc: sram: add private struct device and virt_base members Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 7/9] misc: sram: simplify probe error path Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 8/9] misc: sram: move reserved block logic out of probe function Vladimir Zapolskiy
2015-05-18 19:08 ` [PATCH v3 9/9] misc: sram: sort and clean up included headers Vladimir Zapolskiy

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=556230A9.8030307@mentor.com \
    --to=vladimir_zapolskiy@mentor.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).