Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1895211rdb; Wed, 31 Jan 2024 12:24:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuuFV+CeOhyuH+/uJ09KI+rYtfqyliU4GbfiFZsO0S34zm73KVzwFVna4cPuZOHdtTXdn4 X-Received: by 2002:a17:902:aa85:b0:1d7:c27:2d3c with SMTP id d5-20020a170902aa8500b001d70c272d3cmr5356982plr.6.1706732648925; Wed, 31 Jan 2024 12:24:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706732648; cv=pass; d=google.com; s=arc-20160816; b=dn7dxomvAXKvZha6zEwGWXdy8wDe2Af/W4wiFvf91ujuO/HQiwc4MswIaTd1+S6O6F M1RVxb9Y0iCezepi8v+6wrLWFh3Co48tbeLSmedOVk1E9LoGTYuYovaCkq6Udn+0PRWs MQ6GMo0bH5B0ccz0b0soeJbJ97qYEJLMJiT4yDCEcqQXBlYD5Wk9/LHh02aUvMRqtDZU K++v2dr0X4yI0SC5g2lOKNq9xrrI9KSz66aqKYuVG05kv9zG4e5lAZie6z5uiTjgK5j6 4G36iQ18alOLMfEGdFAtMcSHO42E2cNCMKUwKWRoT6IKtGbDYX2qt4FOL1ddq523jLa1 HIiw== 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=SEc9m+e3CNgOiYfioXrsW3eDnkw9q57N3o4XcChDGG4=; fh=+2HDKw0klLn0IlLSXFlANKFBbPXaqt0raj4WQcf5QrI=; b=I0oKfFFD2NxwTDKi3toqI1yiXuyyvFDM+UZp5p5peXxSC8zgHyGG0gj5l7LXOZFn9a jFodjOCVcrBIhHYPfyTFUpW00esl88rsFzPbCviNyfRF4Pr+/k0hkB517l+Hec/erXU1 GC9bN9sbIjY7T8VVaKdqiNW4AL7Jeps/ZzZXCRuZfnPe8/P2M6yl/mb5E6OKYtrhiN4u iEeC9qFNV/pyZxVBd5qNkaFNXaCDFnm/AbuGkL3gDO5CVyi68LzsSzbzeyxrjzKXZP/H TaEkInWMYMBZgMrWv45RHP4reqh/Q7ZxEBtamu3jI4eSxVgLFlk/N0gW+lOBSCnR2nkQ bjDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=utAqutq1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-47062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCUDcajKi7PIxR1bewiAxDk3YSxkN51VtbYhkXdvmM9MpxM5pZAPxjjgJ+JqfnqVP0eaq+ZVTTeGVSY6teJ0gpfvUB0f6V2Wix/wT5v6rg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id by9-20020a056a02058900b005dbdcf45386si2083880pgb.390.2024.01.31.12.24.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 12:24:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=utAqutq1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-47062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9AFC828E773 for ; Wed, 31 Jan 2024 20:23:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C97AE3FE37; Wed, 31 Jan 2024 20:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="utAqutq1" Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 619043FB06 for ; Wed, 31 Jan 2024 20:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706732611; cv=none; b=HS0v2/+/Ktc/iwrStDQur39qvHSkiVFhl+Ox6oUeHiXXW90opYn40ttlJu0gtkg7c5KupUv9sVbOZ0spQYySTpvaFizS8+ZZql90voRQ7RrOyuFg6BA8IjF288+UAkJaXMp+9+yCughSmNjQssnt4XB4qVz0ogpdaKsbHC0lVTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706732611; c=relaxed/simple; bh=SEc9m+e3CNgOiYfioXrsW3eDnkw9q57N3o4XcChDGG4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lAaHTC9oTZduGog0O1xPmm2/IPMF4TFYO/MEhuEhj277E23XxMbJ8TN8eDRvMl6IVSathJIYyWFo+4DZlVj2Uk8gv6WFaTx2PZ0dlDROXz3aaMpjKf2ora5rGmOxHCgTvqDAmCTeUXZVyaey5cXGSMWo/RVxmxgeCxatsf7tUP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=utAqutq1; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6029b5946f5so10215847b3.1 for ; Wed, 31 Jan 2024 12:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706732608; x=1707337408; 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=SEc9m+e3CNgOiYfioXrsW3eDnkw9q57N3o4XcChDGG4=; b=utAqutq16Jx/5Dseg1BALD+KUC4JyfW3xDL2gOahiEIJdxUArBEwjsdJBO2L+d7/yJ 7J0S0NC/LlgnQgkkiHTPv3Q/WZxdtKKAqLXj2lWUi4vpjCcMGzvoviecHLXpix7K1N0d 1rUhcgN7crkq8qtBneZG55b1qpsrVSqHdfsbBnKrKJvFsuLR6EEQgL7nBQU6yDR+mY/n UBd05ygOrkYXumiDXka7CopUzjlmVnMnE+LSHbh9V1yDmGD4sjZMXf29ISpIbqGRdhtB GlFQbCQ+W9iV5O9qjQDbQ+rm0YoUBM03IPQp8uvQnigRsdvbbLhgwVGvQE91b8/zdxrf BpTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706732608; x=1707337408; 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=SEc9m+e3CNgOiYfioXrsW3eDnkw9q57N3o4XcChDGG4=; b=X+dNW6m9BiK6JxgiPnl8LorxgGMnNav5z2OoTbM+pa0ZnMlNri0IBka1KvtGipRwTa Ff1X9PoLmG4TnzKubY7/qrrTVVi10DlaIndwbEO3qjB/4WQnPgKsRLor68TwQbIISA+G EFxFUz9PU/egwNeS0tsdfN+GMJhUzPIRA84G0M79xkTuKeP3dIjRHw4jaHnlM1UJpJID AJ+6RPyHGPwnzwPGQpbAlShNs2iq2+EhzIZ19yUKnb+wnE9SwycfU04Y8Kz1g7mwA/ya /xXMOR41XUJ023Ewq1WuAkfJHdJyxWlPN8P6dy9uqvri3nTSntCXVhQJu1g0sTLX+e6V wk9g== X-Gm-Message-State: AOJu0YyAZGom2gilYzSB7UsHnxLbcx6r40V5pgPiu87vDSUffVbCrNKL 2s89Tfa4VP/I0mRdkTygr7KHK179ZXaPu7KJq5mHoS+9bb76CEpq0iYNPR5+kZyox9K1+XFnlz2 cWBmCLtvMjq7pk99Ab4JRS55QXtZsb8tUwImPWQ== X-Received: by 2002:a81:a010:0:b0:602:9fc4:bc82 with SMTP id x16-20020a81a010000000b006029fc4bc82mr1561453ywg.23.1706732608362; Wed, 31 Jan 2024 12:23:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240130124828.14678-1-brgl@bgdev.pl> <20240130124828.14678-21-brgl@bgdev.pl> In-Reply-To: <20240130124828.14678-21-brgl@bgdev.pl> From: Linus Walleij Date: Wed, 31 Jan 2024 21:23:17 +0100 Message-ID: Subject: Re: [PATCH 20/22] gpio: protect the pointer to gpio_chip in gpio_device with SRCU To: Bartosz Golaszewski Cc: Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang , 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 30, 2024 at 1:48=E2=80=AFPM Bartosz Golaszewski = wrote: > From: Bartosz Golaszewski > > Ensure we cannot crash if the GPIO device gets unregistered (and the > chip pointer set to NULL) during any of the API calls. > > To that end: wait for all users of gdev->chip to exit their read-only > SRCU critical sections in gpiochip_remove(). > > For brevity: add a guard class which can be instantiated at the top of > every function requiring read-only access to the chip pointer and use it > in all API calls taking a GPIO descriptor as argument. In places where > we only deal with the GPIO device - use regular guard() helpers and > rcu_dereference() for chip access. Do the same in API calls taking a > const pointer to gpio_desc. > > Signed-off-by: Bartosz Golaszewski The way I read it after this the gpio character device is well protected against the struct gpio_chip going away, good work! Reviewed-by: Linus Walleij I would perhaps slot in some documentation around struct gpio_chip_guard explaining how this works and why it is needed. Yours, Linus Walleij