Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1083614rdf; Sat, 4 Nov 2023 06:05:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFdDGsGlUDRe8SyC3cs72iTf8PRdT+NhbehJkUOg3SZ24Uigikax5l7CgPE/v32ny+S0tM X-Received: by 2002:a05:6e02:1c07:b0:357:f5f8:2245 with SMTP id l7-20020a056e021c0700b00357f5f82245mr5622471ilh.13.1699103115221; Sat, 04 Nov 2023 06:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699103115; cv=none; d=google.com; s=arc-20160816; b=MWRqVFgCQQxgRsbupXf23AXCT7A3Ixq+7Re3+8o2v4G4+mDj05sBU/B7BB2OOgHHOH vIBFGwuPX626WUsN1BAU3ycnyR9b0Z+kDW6G2QJvOGEhEVOEbpMrPQNQGftep2F2/jzh Qg6XEg56t94aAyqg4dMwiXDJhmW/jOV8vaufvvLHFUBmoxKJLKHkPjptQ3+b/RI+0mTp hH44pt9wR/Du4/P20jv2WoUcbOf9Zkrqn0koQAhluTj234qQuMSxqQUE17vyj3du2WA4 GZRtVae4zqGa1ONJd0oEginzdEc2aHKYk011kbeWDiyG8lsr6wgMLGPsBD39OzK6kBHp GidQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LQ6LrjTd/q7PTKi4dejXoa8k6gjmuwt1kUk0reFE/qw=; fh=2gwpQAc5Iek5AbxmeV4VdfQfZjna0jANfGwquzyqCLY=; b=Xmh3kv9UNQ5VPeFIU5VSykU12HlV3B7tWmbpSpsRJOTmRbFNpyOGuEGb9j8GfGN24y z7Mi3PI1rla9+5zBXMITfAoEbTeS2bkdVrzk2eTQabq6amdZjhMOXN4FSKfM707QwaR+ v0+x368jANFBhOqIBl2bvfhwDVJ9FbOaltRHWfv26b06WasuxoH6YA+Ca/FZq7dofour gXX1QvrJUfIo9SWiK8/4i24uIKOqS/hKM2cjiRRD59NW9cX6jfYbLBCqgAupt/P+0DhR OhYoYn6qUStTKcmKzaMtTp0aP+pQqpC9ilwrglSiEYepVjEhrnUatUWaQ4zD4hIilT3J mdJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LolMM84e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i8-20020a056e0212c800b003513f3cf6efsi1669917ilm.129.2023.11.04.06.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 06:05:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LolMM84e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0AAC38059E70; Sat, 4 Nov 2023 06:05:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbjKDNFN (ORCPT + 99 others); Sat, 4 Nov 2023 09:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231473AbjKDNFM (ORCPT ); Sat, 4 Nov 2023 09:05:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21C3194 for ; Sat, 4 Nov 2023 06:05:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23A68C433C8; Sat, 4 Nov 2023 13:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699103109; bh=NS3d8mZHUuCBEyhTLAwhKBb5EQ4I3qlp0HRGJG3BCMw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LolMM84ex/eh6rDO21O8YysdjwP65FGQ3BR60t8tWwjy521i5pNkRI8++1UTfjTde pfSAh6RPHvXeVeKsVFBIiczIhto0BGvPdb32MI3MZ66eiDnf6f5C88KV60SiZA+Dq6 H1EqAmjaIO9xYNGU8grrfLTCbzJdHw0qBnsduxKg= Date: Sat, 4 Nov 2023 14:05:02 +0100 From: Greg Kroah-Hartman To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Zhangjin Wu , Willy Tarreau , Yuan Tan Subject: Re: [PATCH RFC] misc/pvpanic: add support for normal shutdowns Message-ID: <2023110407-unselect-uptight-b96d@gregkh> References: <20231104-pvpanic-shutdown-v1-1-5ee7c9b3e301@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231104-pvpanic-shutdown-v1-1-5ee7c9b3e301@weissschuh.net> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 06:05:14 -0700 (PDT) On Sat, Nov 04, 2023 at 12:29:30PM +0100, Thomas Wei?schuh wrote: > Shutdown requests are normally hardware dependent. > By extending pvpanic to also handle shutdown requests, guests can > submit such requests with an easily implementable and cross-platform > mechanism. > > Signed-off-by: Thomas Wei?schuh > --- > The corresponding patch to qemu has also been submitted[0]. > General discussions about the feature should happen on the other thread. > > [0] https://lore.kernel.org/qemu-devel/20231104-pvpanic-shutdown-v1-0-02353157891b@t-8ch.de/ > --- > drivers/misc/pvpanic/pvpanic.c | 19 +++++++++++++++++-- > include/uapi/misc/pvpanic.h | 1 + > 2 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c > index 305b367e0ce3..d7d807f5e47a 100644 > --- a/drivers/misc/pvpanic/pvpanic.c > +++ b/drivers/misc/pvpanic/pvpanic.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -74,6 +75,13 @@ static struct notifier_block pvpanic_panic_nb = { > .priority = INT_MAX, > }; > > +static int pvpanic_sys_off(struct sys_off_data *data) > +{ > + pvpanic_send_event(PVPANIC_SHUTDOWN); > + > + return NOTIFY_DONE; > +} > + > static void pvpanic_remove(void *param) > { > struct pvpanic_instance *pi_cur, *pi_next; > @@ -152,7 +160,7 @@ int devm_pvpanic_probe(struct device *dev, void __iomem *base) > return -ENOMEM; > > pi->base = base; > - pi->capability = PVPANIC_PANICKED | PVPANIC_CRASH_LOADED; > + pi->capability = PVPANIC_PANICKED | PVPANIC_CRASH_LOADED | PVPANIC_SHUTDOWN; > > /* initlize capability by RDPT */ > pi->capability &= ioread8(base); > @@ -168,12 +176,18 @@ int devm_pvpanic_probe(struct device *dev, void __iomem *base) > } > EXPORT_SYMBOL_GPL(devm_pvpanic_probe); > > +static struct sys_off_handler *sys_off_handler; > + > static int pvpanic_init(void) > { > INIT_LIST_HEAD(&pvpanic_list); > spin_lock_init(&pvpanic_lock); > > atomic_notifier_chain_register(&panic_notifier_list, &pvpanic_panic_nb); > + sys_off_handler = register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT, > + pvpanic_sys_off, NULL); > + if (IS_ERR(sys_off_handler)) > + sys_off_handler = NULL; Why are you allowing this to succeed? Shouldn't you be returning the error instead? > return 0; > } > @@ -182,6 +196,7 @@ module_init(pvpanic_init); > static void pvpanic_exit(void) > { > atomic_notifier_chain_unregister(&panic_notifier_list, &pvpanic_panic_nb); > - > + if (sys_off_handler) > + unregister_sys_off_handler(sys_off_handler); > } > module_exit(pvpanic_exit); > diff --git a/include/uapi/misc/pvpanic.h b/include/uapi/misc/pvpanic.h > index 54b7485390d3..82fc618bfbcf 100644 > --- a/include/uapi/misc/pvpanic.h > +++ b/include/uapi/misc/pvpanic.h > @@ -5,5 +5,6 @@ > > #define PVPANIC_PANICKED (1 << 0) > #define PVPANIC_CRASH_LOADED (1 << 1) > +#define PVPANIC_SHUTDOWN (1 << 2) Why are these in a uapi file? And if they need to be here, why not use the proper BIT() macro for it? thanks, greg k-h