Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp36837rdb; Wed, 20 Dec 2023 05:48:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz03y+Iu1CdQb9HRxtCqAflVTb25zDHCtKcp423rx1AAB1Ly0XXMVxHAVUlT/adCoonRqH X-Received: by 2002:a05:6808:1511:b0:3b8:b204:b328 with SMTP id u17-20020a056808151100b003b8b204b328mr24017680oiw.8.1703080099132; Wed, 20 Dec 2023 05:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703080099; cv=none; d=google.com; s=arc-20160816; b=J418+eRQru/uGybGTko4sZJUHt7jhCFaq4G3REYpDpG70V/oEFDuo7EZM70sDEvh+V Qc+H1hsQJBnDVJ5ZdMKe4QUoqYPgbARaZHODOXSU1qrxIXxvw3HmfPgIgLeTPL0Ivk0M /zt6HxaxtaufxNkV6hJZNI0H42YsdotiN+gVj87vcBjmMqy3a5oZcxaarX582r/bchvJ p+hlDo4azRCbqj/1dzB6Ul/hh5tzkNHu9Db/p809RfsQXcNC3OcoOv4efn2/3k+jj8u4 14pt7fmFdIVu8j/5UR0QYDpr5foDhCjfLJR2VkJV70yfEVD9dtfupmw0wN4R8A/7P+qb ztOQ== ARC-Message-Signature: i=1; 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=0Rpx86TDGkyKCh1KoU86Rs0GjXZN/8zMfFkGEuBxOWA=; fh=rzYCGcVzjQFPqkySNmUpcDHHUQRjal3ddModzuE5/FY=; b=bysR3hPtPXCM20sX/HYb+fjS9lsakGXIy1B5fyBtO3ZURc3PptAuPqnf3jSmPB5GbU YV/wSKUK0yAWf6ePSpqjaMHo9GjdiCUiZzbi1vJ0ZRxw5lEE6y7TyG+FLzJU4OJjn+wx 8Oa1LCQJk/ZENttg/nzj7G4cjw4OC8ZYp46ye7LntA7x0YH3fpCQrbFsUtQWIjAhvjHp kUEQm5BxVu6+ZMSQYz5BMO7BAOs2LfAgpVkhk4gPSk04JQrdg/y5sDk/ge7yVqgdozdb NL0n1SR0sJse8CV+8wHXcGH8K7Vm//wGnxymus2fMbRH2JIaxwSIvByJNwHWMWlCRHkW 6eIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SOm0uf08; spf=pass (google.com: domain of linux-kernel+bounces-6987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6987-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w8-20020a0c9c48000000b0067f05233e2fsi1877582qve.607.2023.12.20.05.48.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:48:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6987-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=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SOm0uf08; spf=pass (google.com: domain of linux-kernel+bounces-6987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6987-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 DAC221C22913 for ; Wed, 20 Dec 2023 13:48:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59EDE37171; Wed, 20 Dec 2023 13:47:59 +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="SOm0uf08" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (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 4C2F0364B5 for ; Wed, 20 Dec 2023 13:47:57 +0000 (UTC) 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-vk1-f171.google.com with SMTP id 71dfb90a1353d-4b6cdb1729cso745121e0c.1 for ; Wed, 20 Dec 2023 05:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1703080076; x=1703684876; 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=0Rpx86TDGkyKCh1KoU86Rs0GjXZN/8zMfFkGEuBxOWA=; b=SOm0uf08sIy3DftbBrnHwUGa0nC88Pmu7B/snF6HC4bY7itCrNyXE0SKIIcBfdqgH5 sBatMBoijZjyvvRUKtxwOXFbPxPJx5zL8C8k8SR0FFjayiiJQOaaOCzPFCXIeVXUlZ0m EK2x9YmsXVf4PSbMxJAgeBevcsKbDemNa730H+ObJzxWA0jXYoSnf9krz4+B6q597Go9 m7VxKnIh3NKfxN0H0wIdMInoAo2WV6znKPohB4VgOn1LKehkAr8ypxEPAWr6P1m6QMpo 3EJ7oCSf/RSvb7yr/1HBn8acvnrlghpUv15uwCz1a6EEyqaJGWIVHfzh+JqmwuRU94Lz 8+8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703080076; x=1703684876; 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=0Rpx86TDGkyKCh1KoU86Rs0GjXZN/8zMfFkGEuBxOWA=; b=T84d+zoDhvigfMs1s+nW0/VrIA77SW1jLRiZucJ+2HJO5VIX1OvAyz9fQAbQpHiQWP JkhpXSg0Q6o6n2+Lg5MiT/C9/kmTwqV2DBUyTGDTeFckM/bqeRO2laCx+K7ef51ZiWQs 7wh08EDKFc9gok6tlfCvQMThbKaMWJMbUa9r8lPMg02ecqsNGeOnfaQgcQ0J43cbQZ3g rS1dEjU1UU1q5ryjhbblevye04oiR7dYniSkqIbgMQ9aPoFF1RiLCBRlTI/n08BAinzk 6vIRpS2OcpBmxcZtA26WIMZ4SeuZ89OHf1s9yDV/XtSt81CSzItvMuAzWYgrAGGgoJ2l Vt9Q== X-Gm-Message-State: AOJu0Yx1vl0uasW4N7Bc0en7RD5aObn0HHU17+L+dRLJXyxVVBv2uyud YY9J5Qwbw0OFzZmwZ6IB1tljIRHKcsM0Wf9HbxNpng== X-Received: by 2002:a05:6122:1b85:b0:4b6:f13f:8cd7 with SMTP id es5-20020a0561221b8500b004b6f13f8cd7mr938264vkb.15.1703080076171; Wed, 20 Dec 2023 05:47:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220015106.16732-1-warthog618@gmail.com> <20231220015106.16732-5-warthog618@gmail.com> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 20 Dec 2023 14:47:45 +0100 Message-ID: Subject: Re: [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device with guards To: Kent Gibson Cc: Linus Walleij , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, andy@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 20, 2023 at 2:28=E2=80=AFPM Kent Gibson = wrote: > > On Wed, Dec 20, 2023 at 02:19:37PM +0100, Bartosz Golaszewski wrote: > > On Wed, Dec 20, 2023 at 1:53=E2=80=AFPM Kent Gibson wrote: > > > > > > On Wed, Dec 20, 2023 at 01:30:57PM +0100, Bartosz Golaszewski wrote: > > > > On Wed, Dec 20, 2023 at 1:23=E2=80=AFPM 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. Bart > Cheers, > Kent.