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 5EC01C433F5 for ; Mon, 8 Nov 2021 06:12: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 EBF2F60E94 for ; Mon, 8 Nov 2021 06:12:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EBF2F60E94 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 1mjxtB-0004oo-Fl; Mon, 08 Nov 2021 01:12:17 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mjxt9-0004ho-4G for kernelnewbies@kernelnewbies.org; Mon, 08 Nov 2021 01:12:15 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 6CB9B3201D5E; Mon, 8 Nov 2021 01:12:10 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 08 Nov 2021 01:12:10 -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=AKS6x+m8fQsAHFQy7Q/Crt6YHk6 GibMK3W8PHWmXV2c=; b=oZbmdgfNXv8ogYOQvT8j5qWKJxlky2Qm51VbhiI86pQ Q6EdLaG2JgpqTZUuNtTu0AWQCCehI7Unb84vCjEFwlM0eq+deKhy7rYDscZT7M0g Csz6npMiK6EIJQdCPtQbKQZ1YvXkssm3lYPZ/1Edb4Ox7qBuNeFUHLblSLjquDMy BFHQA93mWx+JIJH/h1N15jkwzHw0AiuHOhzuz9yKk8pVwv8STHSAweXAuXhMPlmx xJQ8sebYAPcu0DpfDGO0jKnYQ8NZTodrLRxjX9F+vMlABOepbODRb9OI13o7tTQ2 ghBhZTIu5OM3aJnOxUFPcS+CkTGbOj8/G2nuLxXW89w== 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=AKS6x+ m8fQsAHFQy7Q/Crt6YHk6GibMK3W8PHWmXV2c=; b=lUvH7mS0m65Hzt1f+e+tjA ttHWrqXUJdXW8k4aI8aYhvJQZJgeB+114eRi9EiWHnG3DTcgNs1pqfPjnZgb0DA6 gQWcqN6b6wPac++q7yjhDudrVXixQ9GfVhPSGzcR9yhxmNTzLXDL5wGknikqHwII ysGHXfqi8QKE3WL/WsEsNKwmveshc94VE4a/8gz66AEd0hEYii7jQHQqp8j/Gm9w NzEVdeVgeHdfIvBdMbp3L765HzYDctX/iNWmrOx/M/QdBl+TK2Newk0RkLTdW6pB V0y8EGKtKbJghQCCSKy4P78WlXD0FHXNAO1M2H8BlBgjiIoTfSzanVIjsbFfz8EA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddugdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghgucfm jfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepgfetfeffte dvffeltdegudduteffuddtudevfeevtdeugeeugefgieetheefteefnecuffhomhgrihhn pehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Nov 2021 01:12:09 -0500 (EST) Date: Mon, 8 Nov 2021 07:12:07 +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 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