Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp490116rdb; Thu, 1 Feb 2024 14:58:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNTFOdHzWC4GUI0v9tLcNclGXQ+gA5Dl9rQBlZ7GVqlf6s156v8yeMuo7WfzOOEkn+0kJy X-Received: by 2002:a05:6e02:786:b0:363:acf8:7700 with SMTP id q6-20020a056e02078600b00363acf87700mr1014506ils.14.1706828337801; Thu, 01 Feb 2024 14:58:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706828337; cv=pass; d=google.com; s=arc-20160816; b=gPSTeGHC+QYrQPGowcllDiPRCifx/y3tvgOiRw8jy9SP+jpeSzMH8LdlGIooDeyLUg awtNYEJGwPUAU5sU2bddK9onNLYfgeu6otwsL/yaQPwPqXWrCm3cSZEHfuAOAIT/Rr3o P0sqgMKFjuTv1cCk7PeaC2ET3Ovqsd5lSdYJ6RirWnQe4U0rBcUJUFSOT4DUNYJ2XnSt 9u7GY43FMel/0jv5lXR2QjK0UzYZyR880dPB80HFpQLJInoTw3Wl400GoHZX6R1bD3nf PsjXy3bPvoqDrXv7lSZHol/tHqKULRwsrmsi37oec81k4G2ZcUCOdNZPoB7sl6ULKgvd 18pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=OdsnChKuomg6j4pblO0liMjiO73rsaOwpJVo7hYzRr4=; fh=q1ZyNcmN+n2+fhpAArvjMpa3kmcXcUJ5hp+VHpLJQdA=; b=UpSSDukXWEenrNhjelmfq+F028OWMtZSfUdHHNqe4LI4eC5zmlJ+QDGHTwv2FiO/Oa GUxLPtev8EiNQ1RXr8gzJd95knTqmYRDBLfTQlchH+NVt2iy5yWgijdjNq9QyUt+Xbg+ V+G9mcZOSlBAr+f7D/9GlqrPT6UwMXPnJ2Zui4PjTfICddZOGlxUHSBmR1mzcYO2sVI2 j/+LB6sP4pSZCjMbOLPEpAw5RknpVg9eC27HCQSzt/A7kHCiWAbfVywZ914jDALBsU1r fT7pUu2TBw5ssMfBxfLi4gSgXpL2QuJZMuF0BRJGE0Q4CFIZCChZg9Y68GuISN5pbvW/ Tmmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EiW1VHAB; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-48968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCUOV0NFOYjyuTZ8v5JUZiqAARTEPacLMbL7DtJna5tVvimF96PU+vROm5TaiMfd4B1zPWT6PsTN1K4wDgjPlD/mUF1f1eNC+xH7BawMUA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b24-20020a63eb58000000b005c66a3f3f5bsi443209pgk.745.2024.02.01.14.58.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:58:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EiW1VHAB; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-48968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A3211B22612 for ; Thu, 1 Feb 2024 22:57:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6AD246425; Thu, 1 Feb 2024 22:57:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EiW1VHAB" Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38BE545BE6 for ; Thu, 1 Feb 2024 22:57:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706828235; cv=none; b=XSg72oEqv6ljnZZ7/uuc4HPxUWRVAH3AZT8sQbEBFtW2cPPQEXwn3jnfMrsdGHlAK7V0OKzlnobLmdOZDD/SwmfWUrZNZYtat/ZhNoWgaGi7AZWJosq3P06VGd8/vCWCZQI6sI86SgaKVztl1Lxxrj7AUkcZxigIVNGNK/Lsn30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706828235; c=relaxed/simple; bh=ZlrLcIjeqRNOlSZ3HB/cwib/SPm5jN/0suNYrWYybrY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XpOZWv/NWldGkkbYgnMEEBBJkcky9J4iNopiZd5yBeZRhVvYrUziaU6sYfGSDaLNpnIWMH2Tuc4/mysQtYind9a/aiaeMki/2cRBJrpVCVxjBUher3fOS3gZ75RsRtNwwaKdevzN0LArh/TJC2KjzDHIBiUW9I6JbMmVMOmxHLw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EiW1VHAB; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-604191522daso14859107b3.1 for ; Thu, 01 Feb 2024 14:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706828233; x=1707433033; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OdsnChKuomg6j4pblO0liMjiO73rsaOwpJVo7hYzRr4=; b=EiW1VHABL0+atG6siOeo2hxBPqqTtplABWhtHEwlmI0JNWsZ02X2AtBqHbNp7uueTo 21gufUe2G7LS0mTmk5Qs40SlMWdhfv0bVUAYK4nL4dvj16qeVp1SghpAyTkeOxQInuq6 WHTrJYxCr5MdAMGp8B1p75S39OG2fGpl4sQOiyqs0dkQDwTy/VW34yANqRexQfCXvTuT uwSg/B6Lj1uUEPRnaYQv3oUP2sjnntArj1JWWoi7GE2P5GIpHDj9A8ndtoZ4/yOvjQRz WftEQy/OL7FxP9KRaedKq2I+qJV/0zOx5WqKNO1rgHCGXWZI832wQk7o3HluGBJKvRQz MQYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706828233; x=1707433033; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OdsnChKuomg6j4pblO0liMjiO73rsaOwpJVo7hYzRr4=; b=OwVI4HLbDzsYBB9ynRD33bYRBErCaMHl/XGmLHHMm3iEgm/T45x83DKEUugo5KTFzm 06bn1UyUkhK5p99/kFrqPXX9JEoD8e8UaIu5guLzzwe2yC+oOp1UgZtsjwD+LiCuXAu8 EpkIDOBH0hRfXPj6NjoX8Mti4Knc44UhSxHyetuAx/Kau3Tt1FstgPOOKEq8d2tA1g+r kca4tgEYabAs4hlgUxBHMaLyrcOnbdDhb1TbGKpieyDh6o0ahNwU9XJg4dLli3aVbmLz vojlNZdiFV2R2Uw+nOhajb/PYtL0I8tj7UlUWPYVQS+XJ21CNLhQbT0AdI+j4uJwoL9J KnoA== X-Gm-Message-State: AOJu0YwT0Ar8gv1k3el7MMuBOfTjMpCtAgYknTYAmNG6AlvZWe3x7WJc F4O8E58x9ndy7xQOGWPTBQYV+FEC+lHE36guxvUy/fBntrJAc//hm1L86FpSaN/8gG+KIrfJ9fw zpK+jyiSKeaV0vYi202pi8OhTiS3P/GiBLc9eFA== X-Received: by 2002:a0d:e28a:0:b0:5f6:d2ee:2686 with SMTP id l132-20020a0de28a000000b005f6d2ee2686mr7022815ywe.2.1706828233099; Thu, 01 Feb 2024 14:57:13 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240126190110.148599-1-afd@ti.com> In-Reply-To: From: Ulf Hansson Date: Thu, 1 Feb 2024 23:56:37 +0100 Message-ID: Subject: Re: [PATCH] mmc: pwrseq: Use proper reboot notifier path To: Andrew Davis Cc: Marek Szyprowski , Yangtao Li , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Oleksij Rempel Content-Type: text/plain; charset="UTF-8" + Oleksij On Thu, 1 Feb 2024 at 17:20, Andrew Davis wrote: > > On 1/30/24 6:04 AM, Ulf Hansson wrote: > > On Fri, 26 Jan 2024 at 20:01, Andrew Davis wrote: > >> > >> This driver registers itself as a reboot handler, which means it claims > >> it can reboot the system. It does this so it is called during the system > >> reboot sequence. The correct way to be notified during the reboot > >> sequence is to register a notifier with register_reboot_notifier(). > >> Do this here. > >> > >> Note this will be called during normal reboots but not emergency reboots. > >> This is the expected behavior, emergency reboot means emergency, not go > >> do some cleanup with emmc pins.. The reboot notifiers are intentionally > >> not called in the emergency path for a reason and working around that by > >> pretending to be a reboot handler is a hack. > > > > I understand the reason for the $subject patch, but it will not work, > > unfortunately. > > > > For eMMC we need to manage emergency reboots too. The fiddling with > > GPIOs isn't a "cleanup", but tries to move the eMMC into a clean reset > > state. > > That is by definition a "cleanup", even if the cleanup is really important. > > > This is needed on some platforms with broken bootloaders (ROM > > code), that is expecting the eMMC to always start in a clean reset > > state. > > > > I understand the reason, I don't agree with the method used to get > the result. > > > So, we need both parts, as was discussed here [1] too. > > > > In this thread I see a lot of discussion about the priority of the > handler. You want this to run before any real reboot handlers > are run. Luckily for you, all reboot "notifiers" are run before > any "handlers" are run. So if you register as a "notifier" as > this patch does, you will be run first, no super high priority > settings needed. Right, I didn't say the solution we use for mmc is perfect, but it was the easiest solution at hand at the introduction. > > The real issue is you want to be called even in the > emergency_restart() path, which is fine. But from the > docs for that function this type of restart is done: > > > Without shutting down any hardware > > So we have two options: > > 1. Add a new notifier list that *does* get called in the > emergency_restart() path. Then register this driver with > with that. > > 2. Remove emergency_restart() from the kernel. It only has a > couple of callers, and most of those callers look like they > should instead be using hw_protection_reboot() or panic(). > That way all reboot paths activate the reboot notifiers. > Kinda wondering why you think you need to handle the > emergency_restart() case at all, will even be a thing on > your hardware, i.e. is this a real problem at all? The "emergency reset" is needed, due to broken bootloaders, as I pointed out earlier. That said, I don't have any strong opinions around this, whatever option you pick to rework the code is fine by me. The important point is that we can continue to support the use cases we need for MMC. BTW, there was a recent related discussion [1] that you may want to catch up with too, before you start doing the restructuring of the restart/reboot code. See the link below. > > Having this driver claim to be a real reboot handler to sneak > around doing one of the above is preventing some cleanup I am > working on. So if either of the above two options work for you > just let me know, I'll help out in implementing them for you. That would be great, thanks! > > Thanks, > Andrew Kind regards Uffe [1] PATCH v1 0/3] introduce priority-based shutdown support] https://lore.kernel.org/lkml/2023112520-paper-image-ef5d@gregkh/T/#mb45749c3bc9b89caecfeca6e66da8721d920191b