linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: Scott Wood <scottwood@freescale.com>,
	linuxppc-dev@ozlabs.org, Timur Tabi <timur@freescale.com>
Subject: Re: [PATCH 2/5] powerpc/qe: Make qe_reset() code path safe for repeated invocation
Date: Fri, 28 Aug 2009 19:11:04 +0400	[thread overview]
Message-ID: <20090828151104.GA20329@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <A4A4F2A7-4F4C-48A9-A598-6BFB0982656A@kernel.crashing.org>

On Fri, Aug 28, 2009 at 12:34:50AM -0500, Kumar Gala wrote:
[...]
> >static int qe_sdma_init(void)
> >{
> >	struct sdma __iomem *sdma = &qe_immr->sdma;
> >-	unsigned long sdma_buf_offset;
> >+	static unsigned long sdma_buf_offset;
> >
> >	if (!sdma)
> >		return -ENODEV;
> >
> >	/* allocate 2 internal temporary buffers (512 bytes size each) for
> >	 * the SDMA */
> >- 	sdma_buf_offset = qe_muram_alloc(512 * 2, 4096);
> >-	if (IS_ERR_VALUE(sdma_buf_offset))
> >-		return -ENOMEM;
> >+	if (!sdma_buf_offset) {
> >+		sdma_buf_offset = qe_muram_alloc(512 * 2, 4096);
> >+		if (IS_ERR_VALUE(sdma_buf_offset))
> 
> shouldn't we zero out sdma_buf_offset otherwise if we call this
> again we'll think its set.

Technically, no. If qe_sdma_init() fails, kernel will panic:

void __init qe_reset(void)
{
        ...
        if (qe_sdma_init())
                panic("sdma init failed!");
}

But I see your point, it isn't obvious and may lead to a bug if
we'll decide to not panic later on. Therefore I'd better make the
change.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

      reply	other threads:[~2009-08-28 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-27 17:30 [PATCH 2/5] powerpc/qe: Make qe_reset() code path safe for repeated invocation Anton Vorontsov
2009-08-28  5:34 ` Kumar Gala
2009-08-28 15:11   ` Anton Vorontsov [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=20090828151104.GA20329@oksana.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.com \
    --cc=timur@freescale.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;
as well as URLs for NNTP newsgroup(s).