Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2921792rwl; Mon, 27 Mar 2023 07:06:16 -0700 (PDT) X-Google-Smtp-Source: AKy350awkC8m2aPnI4fQwytJMHKqv9kze4zWqQjRTalrIyLEhYeSC3N60BeqbMlVWDkxbJ8UooQd X-Received: by 2002:aa7:c490:0:b0:4ac:bde4:ff14 with SMTP id m16-20020aa7c490000000b004acbde4ff14mr12913876edq.42.1679925975738; Mon, 27 Mar 2023 07:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679925975; cv=none; d=google.com; s=arc-20160816; b=infc2j1hKoOTM/f8HzETR9tQfxoSy8PT4MVLE0Htz99Qm7JloMOxwtJ0fTugyeOHtv er6VjFJedjssGB/DawjnxM1hO0OYeBLOXGxkG5MHQclWfjK+8fxAyhopNe7OIQteN9AN BucpSzZtWDnLL1s2za83dDGNPgJnqKn7cLUDri+g8Kbum+1kYJrmyXp3xsSw2uO+wrJ6 3R7DOrSzvm1zmakHk6Hnb+CkjGbXBT96/I5VOEkUwA5mtQ4QYg8A+wIkcQMhX1/6yTDb OmOU8CKq8/nd2ZEYYUb7qsxDjZTLzKoTKQCVMR84Y14CC1WD8krGEXF9FR0xQBM/O9yS XkMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=j6S8aoTE4XnnRICI4Cgexe87+BA2EHTmrbOrkOlGf2A=; b=kBrnCJyyfNCEDYOHyhjN7FqR693P2TF9Jd6uP7gjSIGZ26+Bx5DIXHNRyBxJ09CtoD vnhPy7Ir0TikrQhK3alYqujEPlVnWgDsxM5oGO5sn5xN6PFVmm7kkgHlYfnvpFuvYnhh QzICiDUIjeU6q+ayGpre0akbd5/2v6Nl4kwO/QiKa6CNZ8A635WL8x5lAZNeHCQ/+j26 yq0vurS43Oxfv3eFKywh9KIJVx4OWFK+z/tTQ9xemdCIsXBUza0RBU9dHvsPPlRIr7dk 2r96vkYaIxDYn6p5Ry7PdQjewzezePAmv4TMZrneeI8kh1mITu2cSEZ96vlj8ayTM4BK ljOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MeGA2aX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dy27-20020a05640231fb00b004fe95a9e4f6si26369069edb.493.2023.03.27.07.05.31; Mon, 27 Mar 2023 07:06:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MeGA2aX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbjC0N6t (ORCPT + 99 others); Mon, 27 Mar 2023 09:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232829AbjC0N62 (ORCPT ); Mon, 27 Mar 2023 09:58:28 -0400 Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825BE40C6; Mon, 27 Mar 2023 06:58:27 -0700 (PDT) Received: by mail-ua1-x931.google.com with SMTP id ay14so6371275uab.13; Mon, 27 Mar 2023 06:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679925506; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=j6S8aoTE4XnnRICI4Cgexe87+BA2EHTmrbOrkOlGf2A=; b=MeGA2aX8swVDI8IPhdkrhlR6D4VrY8TSanhpNBzqCzAluqH7Vjsf475BEzj4Y68VU2 IK4fySExIoLx9D+GhhKkaXQ6N1/WHi8ztzvXxA/VQq3xxWmwQb9xoIS8sOqleTv2kqPa DoNVh+eFi0eEuToRiGZd62Mz3IuLc8s6GkCUppnLsptvxdoHaCv8+y6ClhW3ukmW3hqY nykWW6FKmy+nPRkRCQnwlIunRNqoxXR4lQLIed2JodP495nRWmn+6yq1H1PlBZqFhGL3 P/qB/deBFt3fGujcdWC6GWQDjwdDjr3n6iSybxJTnOB/051TO7XlTBwKZ5n6jHRPR8Gh dIFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679925506; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j6S8aoTE4XnnRICI4Cgexe87+BA2EHTmrbOrkOlGf2A=; b=D7hqRv2T3DPcdwi+RvBAtSkt+n+iguS0f4KDO5MG+tSH28hb6R99KKnY0v8SLr9x7K bv3EwIU30X0kSjIhXl4yVmXCHCQdlC1PfZkVr+MlYSUCltLQmivMrpdQ7Z18V8hq8rOG jsduEETX2bHtzoPB/kqXj7WqDnIQAgpZ1GIdX0XttnLYa6OGseZ/Isds5K00leTyuNSV EZV7g8hV1IesJd1Igl0VfQRs1xQp8aJ9Dx3ERy5mhIFw17EyjbeR+gJ/Bvuy0Ev9Eie7 0XHdeA8Cyg1p4REE5yyKSl5AkU8RWVAGOoyeOxQ6vI4bSuHMVrMf84bhxeQeeee58cFt nT3w== X-Gm-Message-State: AAQBX9cXtBWPLbij+kRZXWzjRvKZEqNifrYV6Kgr7x6wKctu/poKwDc4 0ai3OxV7X1yX6WdKT9L7caU= X-Received: by 2002:a05:6122:c9c:b0:436:ec6:8840 with SMTP id ba28-20020a0561220c9c00b004360ec68840mr4932371vkb.0.1679925506502; Mon, 27 Mar 2023 06:58:26 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id 135-20020a1f198d000000b004367f3393b8sm2731072vkz.28.2023.03.27.06.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 06:58:26 -0700 (PDT) From: Benjamin Bara Date: Mon, 27 Mar 2023 15:57:44 +0200 Subject: [PATCH v3 2/4] i2c: core: run atomic i2c xfer when !preemptible MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230327-tegra-pmic-reboot-v3-2-3c0ee3567e14@skidata.com> References: <20230327-tegra-pmic-reboot-v3-0-3c0ee3567e14@skidata.com> In-Reply-To: <20230327-tegra-pmic-reboot-v3-0-3c0ee3567e14@skidata.com> To: Wolfram Sang , Lee Jones , rafael.j.wysocki@intel.com Cc: dmitry.osipenko@collabora.com, jonathanh@nvidia.com, richard.leitner@linux.dev, treding@nvidia.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, Benjamin Bara , stable@vger.kernel.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Benjamin Bara A panic() calls preempt_disable_notrace() before calling emergency_restart(). If an i2c device is used for the restart, the xfer should not schedule out (to avoid warnings like): [ 12.667612] WARNING: CPU: 1 PID: 1 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x33c/0x6b0 [ 12.676926] Voluntary context switch within RCU read-side critical section! ... [ 12.742376] schedule_timeout from wait_for_completion_timeout+0x90/0x114 [ 12.749179] wait_for_completion_timeout from tegra_i2c_wait_completion+0x40/0x70 ... [ 12.994527] atomic_notifier_call_chain from machine_restart+0x34/0x58 [ 13.001050] machine_restart from panic+0x2a8/0x32c Therefore, not only check for disabled IRQs but also for preemptible. Cc: stable@vger.kernel.org # v5.2+ Suggested-by: Dmitry Osipenko Signed-off-by: Benjamin Bara --- drivers/i2c/i2c-core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 1247e6e6e975..05b8b8dfa9bd 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -29,7 +29,7 @@ int i2c_dev_irq_from_resources(const struct resource *resources, */ static inline bool i2c_in_atomic_xfer_mode(void) { - return system_state > SYSTEM_RUNNING && irqs_disabled(); + return system_state > SYSTEM_RUNNING && !preemptible(); } static inline int __i2c_lock_bus_helper(struct i2c_adapter *adap) -- 2.34.1