All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Drew Abbott <abbotta4@gmail.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: Kernel module that shuts down the device
Date: Mon, 8 Nov 2021 07:12:07 +0100	[thread overview]
Message-ID: <YYi/twivgx6PvJ9+@kroah.com> (raw)
In-Reply-To: <CALY-g84qJTMyQAXc+7-kN_tGgQ6D5kbMCDU1xUp8S=obHHijxA@mail.gmail.com>

On Sun, Nov 07, 2021 at 06:16:55PM -0600, Drew Abbott wrote:
> >  Where are you calling it from?  Don't call it from irq context, which is
> the context that USB urbs are called from.
> 
> I am currently calling it from an irq context, in the fusb302_irq_work()
> function of the in-tree fusb302.c driver. My relevant patch is below.

Ah, then do not do that :)

>  > Do you have a link to your driver code so it can be reviewed?
> 
> The relevant change is here:
> https://github.com/Abbotta4/linux/commit/fbfbb1db54d6bd1b10d56c9e86d08d0ecfe9abdc
> You mentioned that this shouldn't be called in an irq context, but the
> unplug event is detected with an irq. Where should I be calling
> kernel_power_off() if not in the irq context? I think one way of doing this
> would be to set a value that a heartbeat function reads in the irq, and
> then the heartbeat function calls the shutdown, but this driver doesn't use
> a heartbeat. Where else would I handle this?

As Vladis says, there are many many ways to do this.

But step back, why would this driver ever want to shut down the machine
at all?  What problem are you trying to solve by making changes in this
driver?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2021-11-08  6:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-07  0:54 Kernel module that shuts down the device Drew Abbott
2021-11-07  8:31 ` Greg KH
2021-11-08  0:16   ` Drew Abbott
2021-11-08  0:38     ` Valdis Klētnieks
2021-11-08  6:12     ` Greg KH [this message]
2021-11-08 20:53       ` Drew Abbott
2021-11-09  6:23         ` Greg KH

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=YYi/twivgx6PvJ9+@kroah.com \
    --to=greg@kroah.com \
    --cc=abbotta4@gmail.com \
    --cc=kernelnewbies@kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.