public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: cbe-oss-dev@ozlabs.org
Cc: Geoff Levand <geoffrey.levand@am.sony.com>,
	linux-kernel@vger.kernel.org, gregkh@suse.de
Subject: Re: [Cbe-oss-dev] [RFC] Cell: shutdown method for spu_sysdev_class
Date: Tue, 29 May 2007 20:23:49 +0200	[thread overview]
Message-ID: <200705292023.49968.arnd@arndb.de> (raw)
In-Reply-To: <463D1A2F.10708@am.sony.com>

On Sunday 06 May 2007, Geoff Levand wrote:
> --- ps3-linux-dev.orig/arch/powerpc/platforms/cell/spu_base.c
> +++ ps3-linux-dev/arch/powerpc/platforms/cell/spu_base.c
> @@ -463,8 +463,21 @@ void spu_free(struct spu *spu)
>  }
>  EXPORT_SYMBOL_GPL(spu_free);
>
> +static int spu_shutdown(struct sys_device *sysdev)
> +{
> +       struct spu *spu = container_of(sysdev, struct spu, sysdev);
> +
> +       // what else here???
> +
> +       spu_free_irqs(spu);
> +       spu_destroy_spu(spu);
> +       kfree(spu);
> +       return 0;
> +}
> +
>  struct sysdev_class spu_sysdev_class = {
> -       set_kset_name("spu")
> +       set_kset_name("spu"),
> +       .shutdown = spu_shutdown,
>  };
>
>  int spu_add_sysdev_attr(struct sysdev_attribute *attr)

After some debugging, I found that this patch creates an oops when slab
debugging is enabled, the reason for that being that sysdev_shutdown()
iterates over all system devices using list_for_each_entry(), not
list_for_each_entry_safe().

There are two ways of fixing this:

- use list_for_each_entry_safe() to go over all devices so they
  can be freed in their ->shutdown method.
- not free the device, because we know the system is going down
  anyway.

Is it documented or implied somewhere that ->shutdown must not free
the device? If not, the first option is probably the safer choice.

	Arnd <><

       reply	other threads:[~2007-05-29 18:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <463D1A2F.10708@am.sony.com>
2007-05-29 18:23 ` Arnd Bergmann [this message]
2007-05-30  9:58   ` [Cbe-oss-dev] [RFC] Cell: shutdown method for spu_sysdev_class Christoph Hellwig
2007-05-30 11:03     ` Arnd Bergmann

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=200705292023.49968.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=cbe-oss-dev@ozlabs.org \
    --cc=geoffrey.levand@am.sony.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.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