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 6F9BAC433EF for ; Tue, 9 Nov 2021 06:24:46 +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 0AEA5610A2 for ; Tue, 9 Nov 2021 06:24:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0AEA5610A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kroah.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 1mkKYL-0005xt-F6; Tue, 09 Nov 2021 01:24:17 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mkKYI-0005t1-Qw for kernelnewbies@kernelnewbies.org; Tue, 09 Nov 2021 01:24:15 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F39FF5C0243; Tue, 9 Nov 2021 01:24:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 09 Nov 2021 01:24:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=8x8Txd952lJrlCEA/ddhpZoYQ0U T5DK1WEJYEdlRZo8=; b=IS/BXYEZsYsQH/HvMaQ9+ckldq67rBMx5BH28Omj7PG F+/EZ7b5FlbnneCc+Kv4IC7PW/GPD6ygFHygj5N2jvBtzofvcCXSXRl3Gc81oMNF macvOHiADalhsY7FhNEK2r9b51y7QIaS7XNYHjD3cv0Xteq3O2Lql7rChjFPH2BS y3deog4Kmk4WwP5cb++UThFk/lbpcNquENOpWWHE+HUqk6S6CACc60JFhsGqUfpa 82lAcf3/SVP5r8p1SPCTeDziC1vFUrmU9KJge08wG2QUXaAkMk38xzUO0VYvS05j vPCEP6NcXt1Ku4QMl85MASmy0fb5toz0fDSZaNZSBuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=8x8Txd 952lJrlCEA/ddhpZoYQ0UT5DK1WEJYEdlRZo8=; b=jJIAZN3KCgFlLMXiHD9r4K 8W/vrpGg0wPovxMb73grRduwYN3xi07m+dNAH8y+kig+jHDDffEEwtingwkpMDnI 9rK5bACMy51MrxfcAaffmK91tps18z8FNX44wh5MzAFDI3sCqW0hSXX/pQKVkQl5 RROQvnsuKrPiVKcixc8QdCWn9Nc2yRS/eclqGICVqyAyvlEKM/JKmgnDiVHufGs+ 3/hIbBvNLpBMfxKmrCax7vWeTSRxvj24pr0pPZn688/1azww5ciW85IjrL425CNk s3DsPrtYv9ykNYEh+s1JW1n/GdPdjBbsEmFnD12BUQ38+Nqy3Tt/qcbGS11gKqSg == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudefgdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpeffhffvuffkfhggtggujges thdtredttddtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtg homheqnecuggftrfgrthhtvghrnhepieelvdfhteejledtteekhfdtueehveejkefgudej gedvjefghfevgeffgffggeelnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpghhith hhuhgsrdhiohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Nov 2021 01:24:08 -0500 (EST) Date: Tue, 9 Nov 2021 07:23:58 +0100 From: Greg KH To: Drew Abbott Subject: Re: Kernel module that shuts down the device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Mon, Nov 08, 2021 at 02:53:37PM -0600, Drew Abbott wrote: > > 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? I do not know, I'm not going to dig around on random web sites for patches, sorry :) > > 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. Why are you trying to do this in the typec driver? You should be able to do all of this in userspace, just use libusb to get a list of devices connected and when one is removed, reboot the machine. There should not be any need to write kernel code at all here. Or, if you really want to write kernel code, do so for when you remove the actual USB device itself, not in the typec code, so write a USB driver for the USB device, not controller. thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies