From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF480C433F5 for ; Mon, 8 Nov 2021 20:54:24 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F113619E2 for ; Mon, 8 Nov 2021 20:54:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6F113619E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mkBeL-0005hX-64; Mon, 08 Nov 2021 15:53:53 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1mkBeI-0005gZ-Nr for kernelnewbies@kernelnewbies.org; Mon, 08 Nov 2021 15:53:50 -0500 Received: by mail-pg1-x534.google.com with SMTP id e65so16263446pgc.5 for ; Mon, 08 Nov 2021 12:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JVrNt7QzToxdhBnRvcnxDZbYHiutfzla2OyGCgVI+MQ=; b=KXcHr3xcROU/+dKnA1hvEwf2jvxLmAJ/zyEy3h0xfWIpQJoj7t573qNv6iv+Zk8tW6 loU80cNDIZLY0SOYRQMLNfN/Sfq3Ib2QXygBcLyuCOZ9IjkMqmjFcrP8AhevlcuT/28y 4QIg6Q/K7Z3NuEUn5cEHCureP55EGYF0QG5ZPNzBwcwcpZRvnIfrbJC7rx/5VprBa8Mo g/6YNay6Fqv+1G9JcN+VrFL1nC1O5LRxDfT+IbZH8+/+PT2IA95ZhLukVbzdfQPO86kz EE5h+f6AyIDuKW+i3iPoJAfeLkaRziYnecK4NwG1ink0Oh96ioBC0KEvAW0f6PrzZlWS /x+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JVrNt7QzToxdhBnRvcnxDZbYHiutfzla2OyGCgVI+MQ=; b=N/xN5DrTW6O2qto2xuAIhVdwb/JpRmTTNCwT201YBbdlLEXMjFBoHeGmfFaGGKnLn1 cikqo/pGXbZOp/lJenBM0OsdMSfiSIBNEbNFqVp1GkflIWuyfZNCHvu0ucRK/Lk5QNY9 x0YcGAmIJ8w4rc0LXbJxTU0ee8gx4LvM9W58Hv2eScDLLEsnjt76FE5l3a6fJ2yuVntp 2xc67AwRN9TV+HTus3y1Y/5tWEpCUOtqYTFVPy2RW/SC+Ej5KC1JMIpRfhKGpy9fTHyw HVIYwD1TNGUnpdJDiv9WE8wn+SQu/KCYwWwzmKnvNTCfxb11w0xP2DXwNPLiIdeNv6+G FcWg== X-Gm-Message-State: AOAM530ftVJXoS506uKOLit4n8/KGbz22MKoHteX2YOmPQkQK/fdusCA kctAhWT3pxlptkN495RNyhQdyyoSWTtAcEARleoKr0gFncc= X-Google-Smtp-Source: ABdhPJyvb4U3Tx5UHNi5gLiNMDaFKeSWxDh0n4HR1th8UeyMW+XCWA6OxZDB4jqW2qOLodUNRRG57uvCROgyQ7qJPgU= X-Received: by 2002:a05:6a00:1781:b0:44d:faef:f2c0 with SMTP id s1-20020a056a00178100b0044dfaeff2c0mr2169062pfg.68.1636404828332; Mon, 08 Nov 2021 12:53:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Drew Abbott Date: Mon, 8 Nov 2021 14:53:37 -0600 Message-ID: Subject: Re: Kernel module that shuts down the device To: Greg KH Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3893337333150638847==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============3893337333150638847== Content-Type: multipart/alternative; boundary="00000000000080654a05d04d3024" --00000000000080654a05d04d3024 Content-Type: text/plain; charset="UTF-8" > There's a whole bunch of ways to schedule work in the kernel, it doesn't have to be > a heartbeat function. > > Plenty of drivers are split into IRQ and non-IRQ parts (sometimes called the top and > bottom parts of the driver). See how they get info from the IRQ part to the non-IRQ part. I saw that this driver and others use workqueues to run longer functions outside of the irq handlers in the process context, so I tried scheduling a simple work struct that calls kernel_power_off() with this new patch: https://github.com/Abbotta4/linux/commit/008a720d9ffc31d5b60e0ca36f2aad0a04d50f0a after reading up on workqueues a bit here: https://linux-kernel-labs.github.io/refs/heads/master/labs/deferred_work.html#workqueues but the device still seems to hang at the blocking_notifier_call_chain() call. Is there something else I am missing here, other than leaving the irq context? > 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? This change is to help the factory team test the devices before they are fully assembled. There are a series of tests that they run on different components and being able to unplug the device to trigger a shutdown is one of their priorities. I hope that sheds some light on the context of these patches and the strange functionality I am trying to implement. Sorry if it caused any confusion. Thanks, Drew --00000000000080654a05d04d3024 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> There's a whole bunch of ways to= schedule work in the kernel, it doesn't have to be
> a heartbeat= function.
>=C2=A0
> Plenty of drivers are split into IRQ and n= on-IRQ parts (sometimes called the top and
> bottom parts of the driv= er).=C2=A0 See how they get info from the IRQ part to the non-IRQ part.

I saw = that this driver and others use workqueues to run longer functions outside = of the irq handlers in the process context, so I tried scheduling a simple = work struct that calls kernel_power_off() with this new patch:
after reading up on workqueues a bit here:=
but th= e device still seems to hang at the blocking_notifier_call_chain() call. Is= there something=C2=A0else I am missing here, other than leaving the irq co= ntext?

> But step back, why would this driver e= ver want to shut down the machine
> at all?=C2=A0 What problem are yo= u trying to solve by making changes in this
> driver?
<= br>
This change is to help the factory team test the devices befo= re they are fully assembled. There are a series of tests that they run on d= ifferent components and being able to unplug the device to trigger a shutdo= wn is one of their priorities. I hope that sheds some light on the context = of these patches and the strange functionality I am trying to implement. So= rry if it caused any confusion.

Thanks,
= Drew
--00000000000080654a05d04d3024-- --===============3893337333150638847== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============3893337333150638847==--