Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp296902rdb; Wed, 17 Jan 2024 02:10:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwAJDw/QA0fcqc9X0aE+0soisMs2MuOFcSuJ7e/3G5U37afvabid5U4P11v/g2YqEV2tfI X-Received: by 2002:a05:6214:31a1:b0:681:5629:487 with SMTP id lb33-20020a05621431a100b0068156290487mr6272190qvb.60.1705486206628; Wed, 17 Jan 2024 02:10:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705486206; cv=pass; d=google.com; s=arc-20160816; b=hZY4PcVD49Vj4MR/YrrRZBCgnhta5OQ8djav94WpQtM9eA1YE9w8VpZ88SgMbh4pSL ljXvUEslxvO0sRGi/bxI2KdHxdZiIFeIBZlnz1D5pySNUL2918DHS0enENWxnxD5DPbf tBFP4AkXcNbvCTlxS4JOn6QHUECjLW4fNX4VR69ZCuSP54NxZtjxDqwqMs0ACeV6Phfk LnSS9HBmnebXuJ2QrlG0GYaT+nbtuPgpWI2ZY7m5zNJhx436KbKuw+VBcdwSeXX2elJY xePQxJ7zOEKu5rboGRAGmBnM1fcPnwRgCgF9vjkuUrvbj3LIpghLr6RiiB71AE4Qe0rH PG1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Nbvt6okzEg9mCFzPVV+6Uem9oajRPBMKXyYL6WqdVzs=; fh=j2oDST2XW650ZSAPnw3epJHyjersjBcBDqJ0OE3HJ1E=; b=ljc7SnCYC6O9VggNAgNDL2Od4+etVhVpLW5wslBzmOc7OBlf4Jigc7AF7GzlPmSuvk XhMxdSHCctsjh6F57ELYJnZSO956sRvAx09iH9btbbUm9TaH+1vVjUTcLLIFsurXRreS qHjyHS84RpcdAjp6xSexZueYDY8EOlOTuVNKCYCHU7HjiFNQVBTC2LjakBmQDS2H1jeg VGsAXjD+91mKPHbnKlxyUsOjtpsTdR6Yg5Ctn/eiVGryLLFCNPKZrF9QIAS3KCfqCiJU fHSfdVLQ0a7cb9wUa+Hlyqc0lTLKDXJgsh6JaGxa0n7mf062l7iW0Psh9NWvvlOODiBe gEIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=uzjjQqqL; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-28663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28663-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n5-20020a0c9d45000000b0068063dc1d64si7191284qvf.589.2024.01.17.02.10.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 02:10:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=uzjjQqqL; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-28663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28663-linux.lists.archive=gmail.com@vger.kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 509B81C21FB2 for ; Wed, 17 Jan 2024 08:52:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6D8213FFB; Wed, 17 Jan 2024 08:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="uzjjQqqL" Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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 0C99313FEB for ; Wed, 17 Jan 2024 08:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705481519; cv=none; b=I3P61K66Wnp42nyOzbDZ72TFXuCC9BoQqsuWbuXulLQIOUERKnxE+tZJGhyB6IGl4lsVrrpONYYZpSs6vmU3114OIN5QIh1WvvsSQ/MHEvSG0IYSoAP/0EKKWZunfn1LNkAGrMa8im9PVkOz58zgtCqIPkiWkY7rTPlA6f9s2eY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705481519; c=relaxed/simple; bh=4SwlpHGcSWP6z2rcXR2s81UgwIGytxJ8hc/Rkdcy0OI=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=jhK5KVv0X77+fSAzNMQGyNtaxoKhkHfI+2U5LNa2FAmWNi2gLBx34WAAM1C8Ipkgvnh0fLWEQVtTR/o6XsHRX6722DVG0kXb+OSObP2pe6FY+4QLyk9ZcuIHymt7r7YroKT6BvY0pTxBNKJcPHV/NHTZ+jXaVOSgUzSaXr0EwiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=uzjjQqqL; arc=none smtp.client-ip=209.85.222.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-ua1-f43.google.com with SMTP id a1e0cc1a2514c-7cc92a83200so2487524241.3 for ; Wed, 17 Jan 2024 00:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1705481517; x=1706086317; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Nbvt6okzEg9mCFzPVV+6Uem9oajRPBMKXyYL6WqdVzs=; b=uzjjQqqLfv2JFhJ900nSVMLEUe45fuIE7mx1jqD467PJYRhbZIAhFihafdPflSs7N5 E7arFFOH75jJn/1VaUtD5nDY+JEAhAZRhFQcZeiYbGWu8XkQWBvZH0dmjIYZFwcFHYFD VV1bUD5q2VsMZJHmnEu6ERRCNLa5yHbd7A7LkljdSiLR7Uav6enOSxiaA6wnNoJSAc9S zAlx3oFSik4exwLnHUoN2tb5I7KDfSj2uvatGCBPS+lDLMmb91YDR6CLADHwA36NJnmy AaB6pTnN2HW00BRzvlvG/6yeG907DhjPvixS5C/r4sCKZeMgEr4d2ZVJhjaotjvvP2Mw pcQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705481517; x=1706086317; h=content-transfer-encoding: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=Nbvt6okzEg9mCFzPVV+6Uem9oajRPBMKXyYL6WqdVzs=; b=DQ2oDhSmRNlsH/EhktTzFsQUDAUM/HgOPZ7R8yAILhv08J+LbjWtl6DD//k6BEwieV EqZZLb/p8LaQMhZrG75xkH6HWon9QU3+1dmzGOdUONAmyExoK8zpNHBDF28crmkerrkF nYTjXKA8tm2esZfEO2SY1zTm2af7ikJ6WT9v3RJzPt6GmoZSMHoPjN+7CeaagX+eno5J FKGtbY2bBmeCnUHHZsJLB9zvL7+jNTH/mR6lzqbiSettk4yHLVHqG3qLXXvB6g15lbLi Bm+E/y6tzRSy56kyi+KQlOji6RTyr3RQ0zv7MaTzqxwE4HzTn9QtuKAqz4bHyd7u9vVz 3DUw== X-Gm-Message-State: AOJu0Yx70WBe8AA0qrYmWAYixxEgcDbs4iGreiRLqwFXJbPv/FELN6Yu qgDaxVTg/0YuNwPnjJZMqbkYXecP0FZ4a//hi2xzO2EAv2YTeQ== X-Received: by 2002:a05:6122:1690:b0:4b6:ba77:5a9f with SMTP id 16-20020a056122169000b004b6ba775a9fmr3440748vkl.13.1705481516865; Wed, 17 Jan 2024 00:51:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231219201102.41639-1-brgl@bgdev.pl> <19dca2a9-36e1-4a6b-9b65-db4c0a163d56@roeck-us.net> <76bd483b-e48c-4697-8cbd-05a0346090b7@roeck-us.net> In-Reply-To: <76bd483b-e48c-4697-8cbd-05a0346090b7@roeck-us.net> From: Bartosz Golaszewski Date: Wed, 17 Jan 2024 09:51:45 +0100 Message-ID: Subject: Re: [RFC PATCH] gpiolib: remove extra_checks To: Guenter Roeck Cc: Linus Walleij , Andy Shevchenko , Kent Gibson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 16, 2024 at 11:34=E2=80=AFPM Guenter Roeck = wrote: > > On 1/16/24 13:41, Bartosz Golaszewski wrote: > > On Tue, Jan 16, 2024 at 7:23=E2=80=AFPM Guenter Roeck wrote: > >> > >> Hi, > >> > >> On Tue, Dec 19, 2023 at 09:11:02PM +0100, Bartosz Golaszewski wrote: > >>> From: Bartosz Golaszewski > >>> > >>> extra_checks is only used in a few places. It also depends on > >>> a non-standard DEBUG define one needs to add to the source file. The > >>> overhead of removing it should be minimal (we already use pure > >>> might_sleep() in the code anyway) so drop it. > >>> > >>> Signed-off-by: Bartosz Golaszewski > >> > >> This patch triggers (exposes) the following backtrace. > >> > >> BUG: sleeping function called from invalid context at drivers/gpio/gpi= olib.c:3738 > >> in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 7, name: kwor= ker/0:0 > >> preempt_count: 1, expected: 0 > >> RCU nest depth: 0, expected: 0 > >> 3 locks held by kworker/0:0/7: > >> #0: c181b3a4 ((wq_completion)events_freezable){+.+.}-{0:0}, at: proc= ess_scheduled_works+0x23c/0x644 > >> #1: c883df28 ((work_completion)(&(&host->detect)->work)){+.+.}-{0:0}= , at: process_scheduled_works+0x23c/0x644 > >> #2: c24e1720 (&host->lock){-...}-{2:2}, at: sdhci_check_ro+0x14/0xd4 > >> irq event stamp: 2916 > >> hardirqs last enabled at (2915): [] _raw_spin_unlock_irqres= tore+0x70/0x84 > >> hardirqs last disabled at (2916): [] _raw_spin_lock_irqsave+= 0x74/0x78 > >> softirqs last enabled at (2360): [] __do_softirq+0x28c/0x4b= 0 > >> softirqs last disabled at (2347): [] __irq_exit_rcu+0x15c/0x= 1a4 > >> CPU: 0 PID: 7 Comm: kworker/0:0 Tainted: G N 6.7.0-099= 28-g052d534373b7 #1 > >> Hardware name: Freescale i.MX25 (Device Tree Support) > >> Workqueue: events_freezable mmc_rescan > >> unwind_backtrace from show_stack+0x10/0x18 > >> show_stack from dump_stack_lvl+0x34/0x54 > >> dump_stack_lvl from __might_resched+0x188/0x274 > >> __might_resched from gpiod_get_value_cansleep+0x14/0x60 > >> gpiod_get_value_cansleep from mmc_gpio_get_ro+0x20/0x30 > > > > When getting GPIO value with a spinlock taken the driver *must* use > > the non-sleeping variant of this function: gpiod_get_value(). If the > > underlying driver can sleep then the developer seriously borked. The > > API contract has always been this way so I wouldn't treat it as a > > regression. > > > > I said > > "This patch triggers (exposes) the following backtrace" > > and > > "It isn't really surprising since sdhci_check_ro() calls the gpio code un= der > spin_lock_irqsave(). > " > > I didn't (intend to) claim that this would be a regression. It was > supposed to be a report. My apologies if it came along the wrong way. > No worries, I'm just stating that before someone wants a revert. This has been a bug all along in MMC code. Bartosz