Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5380862rdb; Wed, 13 Dec 2023 07:11:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpk/lTwvLVB2jWrnT8IU4PKBbBEL6zu+jxMJ/yflX0qW2ZaC2YORMZAhLeytyBvPxbgm11 X-Received: by 2002:a05:6a20:6a03:b0:18f:97c:4f4b with SMTP id p3-20020a056a206a0300b0018f097c4f4bmr4134134pzk.87.1702480305565; Wed, 13 Dec 2023 07:11:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702480305; cv=none; d=google.com; s=arc-20160816; b=zn5DjdIq6SGA5rDvoj3u/tiHm/XqOgOYLTqIJc4QH+6kQw989F9t3ezK21sDjhul4x 4rYoImt8gVDgNHdHolG9sm+vtL89P7eJiMEnFApN0Qnb1rWFZtlSIOJvag9fGqgURAkN V3vdxL2XKBEJlzJi6OPLpmx7l1Mf7WWlG2kNxHVZZQk9nOKwHubNxylo/qX5A99iOTlg q+oQQct7RMYOcth6fWClO5agN9s9UJWWNwIiAgGij2BJsaQ6tOE4+d2jzLTkn4X2Nmpr rNHkkWKsj6LBvS9sxfqXGaecQf4mHEn9ls0/ogXCGCMWlD11UrLAfD1zdAy8ajtaveC5 XKbw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MVoGj2D2DMUo44xl6GAyPl6zTtJUXg2mVSdeTOQeduo=; fh=w3yeO0Q+7yApRIBQ5jppSTwFcTlt1VKBrJmqR4dAHYY=; b=0WWOT1eKARi3MXD2iwn0DySqC3+NvFQDieA4XATMsUoURXGl9xvOEE9ZEsuzYpOMO7 SJkUfyi8ZA+gEoX4lSGSiwI2kILWPJNrvnk06wkO+Ye6bpJaCH5RSS6Ghj0Z8A76p+w9 HiqSdpr3X3ccsTmRVA/CSFArwfP1zONj9Qdq0EZ8q6xS9CvMftLP6sozIXELBloeZ1my xQVm5nx7xYK8N7ehHbGOlPK+lhqcZpkXbmvWc/+uD3mUFPDxfPTLtsfOETOwRU0uRjDc yc1u2PSzVxr7bLrwenORdJmq7w8SZMckeHTmZw46N2NaHOQrrn5EFTXgLZQPijXoEX6K oK0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bwI9BR7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n10-20020a6563ca000000b005c66240925dsi9549182pgv.546.2023.12.13.07.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:11:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bwI9BR7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9697A8031AED; Wed, 13 Dec 2023 07:11:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442457AbjLMPLe (ORCPT + 99 others); Wed, 13 Dec 2023 10:11:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442451AbjLMPLd (ORCPT ); Wed, 13 Dec 2023 10:11:33 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C49CA0; Wed, 13 Dec 2023 07:11:40 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ce9c8c45a7so4399286b3a.0; Wed, 13 Dec 2023 07:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702480300; x=1703085100; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MVoGj2D2DMUo44xl6GAyPl6zTtJUXg2mVSdeTOQeduo=; b=bwI9BR7zEVOMYzoiLHbLanlPztr52jbM8D9MdL6cbYztUnsShcnsq9T6I8Sno/kCml b4JJh1/wtmHm1Y0vZXLEZ5FxIVktOwJ5o5s8+SFqFFFYWKqcdTDj/NvMSIqCCWB4o3wX vjnMpglXXx686FnV6h5SL+KHvoBNWKuKwsNs+TmkHuWAw/Z0Eh28K1izubToTEy8dMRZ BDJS4/ryb54dlD1mbhoGediJ1A5LAVdDaAvsdFGZ9K1uu61Ip6aVEYT3Bt0Ln0kuCpsX g+RmNGbOECBgo6hHktt/Sqyr/qjYkkreyhX/dxS149W+AAX7UDY2bCC9qvHulwR2U368 Svkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702480300; x=1703085100; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MVoGj2D2DMUo44xl6GAyPl6zTtJUXg2mVSdeTOQeduo=; b=ufoXCNeFt7UiygDe0cyFse08d8VKq0VORAIA9PS27w22oTOJRTZh9CVQorFTIvJCWW NwL3jzcHfxiz927lzVprjg32Q1o2V8r1oKTAQpU9FabU0kzRf4yEh3RF4EmkVHk+JhvB FL2QvuBboPmT10aKjXbnzo7/LriUG+1VoCwbveciCOgR/JkWtXEwBuXia2GAmknGTdX6 visR2HPsljn3YyeOSiK06YwvnvwTaQ3cDKHqXSx4c1yjo3feGW74X/bkvLTuIexPdwIx lBqLZ4Ue66nUNQ1YZBGZGBEw5lk/ndPOk36lIjVMfdU29q51jiWgdeGwnPm9GGFLe5ip j9Iw== X-Gm-Message-State: AOJu0YxM1DQK2hUVLl3OUGe5QRs0ftgWBCjXfOMyFUE/wtk5ZP6PRpWr TFa7C/1UqN7pkOlS4wrfmxF7ook8B70= X-Received: by 2002:aa7:88c8:0:b0:6ce:53f6:1eee with SMTP id k8-20020aa788c8000000b006ce53f61eeemr4612365pff.31.1702480299807; Wed, 13 Dec 2023 07:11:39 -0800 (PST) Received: from rigel (194-223-186-106.tpgi.com.au. [194.223.186.106]) by smtp.gmail.com with ESMTPSA id u13-20020a056a00098d00b006ce455a7faasm10154893pfg.150.2023.12.13.07.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:11:39 -0800 (PST) Date: Wed, 13 Dec 2023 23:11:34 +0800 From: Kent Gibson To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Subject: Re: [PATCH 3/4] gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() Message-ID: References: <20231212054253.50094-1-warthog618@gmail.com> <20231212054253.50094-4-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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]); Wed, 13 Dec 2023 07:11:44 -0800 (PST) On Wed, Dec 13, 2023 at 10:07:28PM +0800, Kent Gibson wrote: > On Wed, Dec 13, 2023 at 03:56:27PM +0200, Andy Shevchenko wrote: > > On Tue, Dec 12, 2023 at 01:42:52PM +0800, Kent Gibson wrote: > > > Reduce the time holding the gpio_lock by snapshotting the desc flags, > > > rather than testing them individually while holding the lock. > > > > > > Accept that the calculation of the used field is inherently racy, and > > > only check the availabilty of the line from pinctrl if other checks > > > pass, so avoiding the check for lines that are otherwise in use. > > > > ... > > > > > - bool ok_for_pinctrl; > > > - unsigned long flags; > > > + unsigned long iflags, dflags; > > > > With a preliminary conversion to cleanup.h this whole change becomes cleaner, > > no? > > > > You mean the scoped guards? Dunno - haven't used them. > Care to provide more detail? > Ok, so changing the spin_lock/unlock to scoped_guard(spinlock_irqsave, &gpio_lock) { ... } you no longer need the iflags at all, and can rename dflags to flags. Got it. Cheers, Kent.