Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp39736rdb; Wed, 20 Dec 2023 05:54:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuh3YSMtzdsfozz9buqjxli7MNuY1tLyFm0moAxmZJ8b7QPoxEKEmYHW6WLeG2CI3W9q1K X-Received: by 2002:a05:6214:c6b:b0:67a:11bb:50ab with SMTP id t11-20020a0562140c6b00b0067a11bb50abmr3792104qvj.23.1703080449991; Wed, 20 Dec 2023 05:54:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703080449; cv=none; d=google.com; s=arc-20160816; b=KI/aB/sQoAES0w2//7Gw41Hux0qZLqgLPf2Tf6O2PbXEBQTBcB2zDHo+QMSRAApc+s V+yDfiHEn0qD7UA1Jy4lQS2ZnXnrHGcc5kHk+7bLe8P+j8pjLBBYahGuc2+wJyvDU93B +mYs+VcHEZFC7n2k/i/eBJNsN/yZzfgKqHmKm6VNmRC7EfkMWt9Q5faEmm29tfBtOzzk 1NBjJS+vjXSW6E5s9VcYamZUk7fZ7nRoFyepdSEC1Gu1TpzMwqpImwQDug0AklUCVuRP kRyO+Oj0YE6/jxHye45/G7+swmWlEhnwVniiOMULSvtgpgOI4aZLf+g5Vues1hD+3+hQ qAfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+oQKwjeNrmhY06Pfwv0+C1DNUwlrrB0GDKSfgdTxLZY=; fh=2Hmk2+MVViEF0KjzxYUiDLGjhYOS+yeUz+iu1Qazwnc=; b=E+XrMXw6lfKkVPfamQLos4NSwKVZMn+gJVZ4JKGnVus8xX1qRLElwvpRJc9PnrCzrP wzm8hQrC5ThHfQPPFan5sQ6BTzj0fJBDHW7M9o0laWLiQRHW+7I9mY2La8P2KDPZwI9I 9+DQGTNvUAL7i+2hzqSYecQ/Ejprz/S0EiiNsGm92SubCSIWBIElG1CIpWdeel/B+aEs McknigMkNBvffpnX+TEIr4wACzkMTVHybFRU7VpAJMPDnVhWo+Vd10OCn+zdNBgJbJzj 69pY3nplHLHktdQg87z+hmJ8+fDrtD2jxh3fNYuzUlS78bzuULvC5lFnNX0Afy11wkAX RHuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CNAclo50; spf=pass (google.com: domain of linux-kernel+bounces-6996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d2-20020a0cdb02000000b0067f2768dfa3si10416591qvk.586.2023.12.20.05.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:54:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CNAclo50; spf=pass (google.com: domain of linux-kernel+bounces-6996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ABF381C229A3 for ; Wed, 20 Dec 2023 13:54:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2A5436B1F; Wed, 20 Dec 2023 13:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CNAclo50" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 9912538DD5; Wed, 20 Dec 2023 13:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d04c097e34so6018415ad.0; Wed, 20 Dec 2023 05:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703080429; x=1703685229; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=+oQKwjeNrmhY06Pfwv0+C1DNUwlrrB0GDKSfgdTxLZY=; b=CNAclo50ZAU12VYHzq4XUUsli/TzLbyMmZ5vLufofmz/VNEQi6GWV2FVA84mmLr41b jhNsPsaGEn6x8wz5Szj458imti8z9YUuGLZq7GodjKWjVgDkBwMdHod9duUouu2DAVmt Tn1OutDAFD8OteUlm6/oN8qRFEJBIMDwx58jXnoSp1A46huXx5iIv+Wh4vwqHe+UKCdM w8dprvYj9wAoJqcS9hcILIPxAnPyEB3uw29zMCBCB2t44IBYSg9doj+VSh0qFzHzYd77 JJ+9TPmI3rLYmDADt+UwebDhNbfvQPVwXP6gbtOFnnTIpFyedF298IOKxGiLJCllpNMH 2ynQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703080429; x=1703685229; h=in-reply-to:content-transfer-encoding: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=+oQKwjeNrmhY06Pfwv0+C1DNUwlrrB0GDKSfgdTxLZY=; b=wZfnlU3rRdztmuJUMrjHHLADRtYZ83VdhqymK9hxQ5Ivnk5R1+O/Wg3lsvKvVeME8F ca6KMlFa+EapNCCt7X4n1Qdmtt9X+n7CDF94XNOlIrgTfDckuaQkd5bSMSAT8sQV2aA5 hONNI5wSVKhVtaTRBTyp+vRC7l/Vzu/lBE4F4U7++oBiGvU50+OX5VJbDcchEQasPcHy 5iBeLJZ4yF2nT4fQPhFQG4yuRkW0ezQUTbKOqJ0RHIpz0rCTiB0HGFLWLBJmlhj2HVhT 9PrLzvqMMiN6FHcNTlWPLB/BZG65IHMLTnsQWvvd78bE3ptbx5EDD75b8QhMcyVZEh7S RTWQ== X-Gm-Message-State: AOJu0Yx7C770pq7XqDQo+AjNApxtQado7WOH1JIo81DJN9aPx1fNHae2 e3udYLsM+QFIY6GqfyeaA8M= X-Received: by 2002:a17:902:8c85:b0:1d0:6ffd:6112 with SMTP id t5-20020a1709028c8500b001d06ffd6112mr2927869plo.52.1703080428720; Wed, 20 Dec 2023 05:53:48 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id s16-20020a170902989000b001bb750189desm23092235plp.255.2023.12.20.05.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:53:48 -0800 (PST) Date: Wed, 20 Dec 2023 21:53:43 +0800 From: Kent Gibson To: Bartosz Golaszewski Cc: Linus Walleij , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, andy@kernel.org Subject: Re: [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device with guards Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Dec 20, 2023 at 02:47:45PM +0100, Bartosz Golaszewski wrote: > On Wed, Dec 20, 2023 at 2:28 PM Kent Gibson wrote: > > > > On Wed, Dec 20, 2023 at 02:19:37PM +0100, Bartosz Golaszewski wrote: > > > On Wed, Dec 20, 2023 at 1:53 PM Kent Gibson wrote: > > > > > > > > On Wed, Dec 20, 2023 at 01:30:57PM +0100, Bartosz Golaszewski wrote: > > > > > On Wed, Dec 20, 2023 at 1:23 PM Kent Gibson wrote: > > > > > > > > > > > > > > > > > > > > > > > > > It would be read and write guards for the gpio_device. > > > > > > cdev would only be using the read flavour. > > > > > > And possibly named something other than read/write as the purpose is to > > > > > > prevent (read) or allow (write) object removal. > > > > > > > > > > > > I though that would be clearer than having to reference gpiolib.h to see > > > > > > what gdev->sem covers, and allow you to change the locking > > > > > > mechanism later and not have to update cdev. > > > > > > > > > > > > > > > > I still prefer open-coded guards here for clarity. I hope that with > > > > > SRCU in gpiolib.c, we'll get rid of locking in cdev entirely anyway. > > > > > > > > > > > > > Ok, it is your object so I should use it the way you want it used. > > > > > > > > Btw, before I go pushing out a v2, do you have an answer on whether > > > > gpio_ioctl() requires a guard, as mentioned in the cover letter? > > > > Is the fact there is an active ioctl on the chardev sufficient in > > > > itself to keep the gpio_device alive? > > > > > > > > > > AFAICT: no. I think it's a bug (good catch!). > > > > The wrappers made that harder to pick up. > > It kind of stood out as the exception after changing the other ioctls > > over to guards - where was the guard for that one? > > > > Yeah, it makes sense. This is precisely why guards are so much better > than hand-coding locks. > > > > Can you extend your > > > series with a backportable bugfix that would come first? > > > > > > > Sure. That would still use the guard(rwsem_read)? > > I mean you don't to go adding a wrapper for the fix, just to > > subsequently remove it, right? > > > > In master - sure. But we definitely do want to backport that to stable > branches and for that we need to use the old wrapper. > Ok, so cleanup.h is too recent for backporting. Adding and then removing a wrapper it is then. Cheers, Kent.