Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4782362rdb; Tue, 12 Dec 2023 09:09:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHTwljCvrZf4fRWomKi5jHsArYd+2ee6ier+cSWYrZBYYEUidRqtKmk5oDm4O60++r2dQ1 X-Received: by 2002:a05:6a00:4b4a:b0:6ce:7faa:29ad with SMTP id kr10-20020a056a004b4a00b006ce7faa29admr2992935pfb.10.1702400959307; Tue, 12 Dec 2023 09:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702400959; cv=none; d=google.com; s=arc-20160816; b=TkT25MBfsWq1Bw6OX6+TFfaEDNvb7HQOMLFLDTqqLbCgwRMstNwYT1ZRnGBC7jJ7or PZ28wo0+KCav67obeeNzqU4o9LkZ15W7UlDfYXJBh+DLtdPXVMwu0KwYZZ9ZeV22HOr8 py5ptpgs6n09RFdrXjCdwE5z7VOJhtyYLr+h86IPOt5VJZ+xjv//gKlclWWu4ooMFJW/ fmdwWvs/WEmiVNAc3eNsMakR/1zowxiorrGuZrFFcD7kTztst87DPYQOqV2UlOP2trim L5JxA7LuspZp8nL/PmzCPHH7DovcbsfxhPE8AhOwieMgjhHVOjz8AQw/sXLzkuMJscMd nLDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=upBnebOqwsJ597ZlmCLWx528Yzi3Wcu30Pu2fcleukU=; fh=erCAZt8TqRv2/z+YQ9HTYE4a5f7Y9g1zasafOXpHI3M=; b=RGzrpM5XN7CVPZIaPy2/0LacRJi19qa6LXrj/ET2BSGQO2v10dsY3Du80yvzwhFx1E K7S5nXiR+lYY7h6vzV2N/HEXSddOrUCSbGcPMfZn2NHHbA4YQZV2GxR27iMuiX2XPhT3 gP77FwN16eicpbQUmgoKMP/KQ38H9Gon8PltqJXQI/ViOsBitXFjnCn3lEKQgL7xEcds 4aewlphPbk15bPoqJ/zx51xtq+jbV3fmm9q+JfMPVmWR0/QRdb97Bkr6SWcy85nSdW6/ adaBJBif92y92jqtNxHPD/WmFNUG6rftqvoAkYadqrKFPyJDCBqF3kB33rzrCvIyuD9L H/dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=rAWyGhEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b9-20020a63eb49000000b00565db2812a0si8065272pgk.60.2023.12.12.09.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:09:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=rAWyGhEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4A71E804868C; Tue, 12 Dec 2023 09:09:18 -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 S232911AbjLLRJJ (ORCPT + 99 others); Tue, 12 Dec 2023 12:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbjLLRJH (ORCPT ); Tue, 12 Dec 2023 12:09:07 -0500 Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA3EA8 for ; Tue, 12 Dec 2023 09:09:12 -0800 (PST) Received: by mail-ua1-x933.google.com with SMTP id a1e0cc1a2514c-7c522ea69e8so1521697241.0 for ; Tue, 12 Dec 2023 09:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1702400951; x=1703005751; 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=upBnebOqwsJ597ZlmCLWx528Yzi3Wcu30Pu2fcleukU=; b=rAWyGhEl5QZfENy+2tW1KWXOJt9iy4tJAm3F8/l0IKbulyyqMgyS5WlFH2XYZN9ph4 yXM+LTOPpboux6iMsqxOlKiI2A3LOrn2aAwpdOph9tJ51eptXZcBkYw3VRH5TZYBIjk6 IwiPxV0dn9/wKrj8bOFzpxKiLuy+ZIQjz7owiV2GbGoh/HuaaUBmNtndOZiHUtqBYOIJ RufYfAN/rbvMYFxEXcThRSGZf8qGSERM2mMEomhH9WBcbMSaYCdXCQQ1RHmJ2gMAp3z8 qaC1Ucy4rN79qHxJCz9pxxqkwB8NOhICKOR+i89PxyuUzPBczjXki6m6OT/VDmMcUoSN 7iAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702400951; x=1703005751; 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=upBnebOqwsJ597ZlmCLWx528Yzi3Wcu30Pu2fcleukU=; b=w2eOoAxXsLjdO2S9bKMW/3FizMvvDKyRXbc88CK46dle3PVIHrIRzg1aiVOXBvEgvJ tAKJtL2UVOMz9+8QtGHHekgw7djEd0I6xcOSNgmpb8xpCQnYK/QF5a3dZHnii+BtiXKP wFtid9UceeRewr+Aj+NuysQwX+h07QnQUg8JZaCmsHN1vljwb08a34q8hJ793cryCXy1 7+R4YvFRtvrUK9tV7jf4wp4SHDgVoreyTBvZ4igAoGfppJo5ViVTOMQCVJgNfSgRvwb2 x4eFGdOcLQV/RoWFcCUNaMc+3zmAvF1Es0Zov8wb0nzHRFHzvu0umFS3qci96b+GJotj /vXA== X-Gm-Message-State: AOJu0Yw4OFSVXk9DQeNM7ijlReVKCsGmiZEVzL8W61Wx93nozn9OsjtC MQpNIb0Iy4LvEHizpcPVnmM61Ce7mPI99dVAjjLxAQ== X-Received: by 2002:a05:6122:2897:b0:4b2:acda:e1e4 with SMTP id fl23-20020a056122289700b004b2acdae1e4mr5776460vkb.6.1702400951144; Tue, 12 Dec 2023 09:09:11 -0800 (PST) MIME-Version: 1.0 References: <20231212054253.50094-1-warthog618@gmail.com> In-Reply-To: <20231212054253.50094-1-warthog618@gmail.com> From: Bartosz Golaszewski Date: Tue, 12 Dec 2023 18:09:00 +0100 Message-ID: Subject: Re: [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us To: Kent Gibson Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linus.walleij@linaro.org, andy@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 09:09:18 -0800 (PST) On Tue, Dec 12, 2023 at 6:43=E2=80=AFAM Kent Gibson = wrote: > > This series contains minor improvements to gpiolib-cdev. > > The banner change is relocating the debounce_period_us from gpiolib's > struct gpio_desc to cdev's struct line. The first patch stores the > field locally in cdev. The second removes the now unused field from > gpiolib. > > The third patch is somewhat related and removes a FIXME from > gpio_desc_to_lineinfo(). The FIXME relates to a race condition in > the calculation of the used flag, but I would assert that from > the userspace perspective the read operation itself is inherently racy. > The line being reported as unused in the info provides no guarantee - > it just an indicator that requesting the line is likely to succeed - > assuming the line is not otherwise requested in the meantime. > Give the overall operation is racy, trying to stamp out an unlikely > race within the operation is pointless. Accept it as a possibility > that has negligible side-effects and reduce the number of locks held > simultaneously and the duration that the gpio_lock is held. > > The fourth patch is unrelated to debounce or info, but addresses Andy's > recent assertion that the linereq get/set values functions are confusing > and under documented. Figured I may as well add that while I was in > there. > > Kent Gibson (4): > gpiolib: cdev: relocate debounce_period_us from struct gpio_desc > gpiolib: remove debounce_period_us from struct gpio_desc > gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() > gpiolib: cdev: improve documentation of get/set values > > drivers/gpio/gpiolib-cdev.c | 257 ++++++++++++++++++++++++++++-------- > drivers/gpio/gpiolib.c | 3 - > drivers/gpio/gpiolib.h | 5 - > 3 files changed, 201 insertions(+), 64 deletions(-) > > -- > 2.39.2 > Patches 2-4 look fine, I was about to review patch 1 in detail but I thought I'd just throw this one in here before we commit to a specific solution. For some reason I thought this would not work but I'm now considering it as an alternative approach: is there anything wrong with adding struct kref to struct line, allocating it separately per-line when gpio_chardev_data is created, referencing it from struct linereq when the line is being requested, and dropping the reference from gpio_chardev_data and linereq when either is being removed? Other than the increased number of allocations? Bartosz