Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1713394rdb; Wed, 31 Jan 2024 07:05:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYQWMsHcBiFTuhIkA6geBda4gO3DM3vVy4Kbj/cCq2sXagQY80Ug1P9QBIdwAslbxp5z/n X-Received: by 2002:aa7:ca47:0:b0:55e:e9f3:4f7f with SMTP id j7-20020aa7ca47000000b0055ee9f34f7fmr1366791edt.9.1706713515282; Wed, 31 Jan 2024 07:05:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706713515; cv=pass; d=google.com; s=arc-20160816; b=lyaVZu/y7HdYNKIvAib46J7tgwTCwF3baglQmZgeuRAPvdhdqqkwMd5gYCzAPYc4FC EutOdpRTVvofR4F1B0sS+pg1q+laGywy87qsk7ZzTCZcqbrlK8ZJW9uNWHD4/Bx9HpCk YE6VS5FbWwRznRQ5hfbXHZkurRRPwqmn9naeh+mETIMv5E57hgqS7qv7xoo7aRroqhca 6nXScsv+ouBveaQUl4G2br96YpYYVwuPAcYzGEz3Oe7d7TvH0lAuyxvGxpSrgVhkzOmL cKRu6+loevgQhbOM+G3jPcTWxtQFiohz699CIKcXOaXGUUmjwt1A471//8GTfU0PcuzW laSg== 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=xJgiomH/cxhNerklilkmo8Jkr30cyTGtYIstcEbnxwI=; fh=If9uvHmiXEM+0pZQFhc+sDshYx31hdj9ONJ1L5Of0uU=; b=FZSi2D1PVGC6EUAFAgCP3a1FvZ6PFDOb47sZpr9F7xGWjHfLvmR0QNNLu2H/+44/9M 3DNEWhgIWn1Mu8rcpw1iwxk61e3DVtLhDJoZMWDYDiPvlatVElqzGK4IKCLTsOPdWZ1x vMEj3u4M3HcIBsybqPEO5dfa3MeiwZAmDx2GkhF9a0QOw9H5SadHcUxFKZ/A07yesQEZ JMxci4sMA1Sz4IdPRkRtPDGPbHAupCaA9fv+/yvCODRlBT8CsacGPgywxYC/oHI0Tgkf KthwBX3e/2/XkfHVkAF9MsbkNLCdP7cHJWQuK71y2f/ksCiWIIe+NCMGBiC3Ff8VW5EV obZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KrbaMlF/"; 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-46678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46678-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; AJvYcCXapMUYFcOEPC9P51Prwu1itg1Yw6ujgc6n4pkn5n5nnQ1R841xi+ktlbxkL07YFbXaasfUVMGTN4w5HBpt31tEfZHv9vBtOjlEilolcQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c4-20020a509f84000000b0055efaddbf06si3263067edf.492.2024.01.31.07.05.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 07:05:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KrbaMlF/"; 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-46678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46678-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0D2A21F21C5A for ; Wed, 31 Jan 2024 15:05:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7475A12AAC5; Wed, 31 Jan 2024 15:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KrbaMlF/" Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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 1859712A14D for ; Wed, 31 Jan 2024 15:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706713315; cv=none; b=oV4btj4ZCLh0pHlNdWWSJh3FcjvFxBcbSp9840KjpoERosrUuwNepmDwBfcxzdvIs/Qwky6G7pnn+jCMoHtAtU3NuIRf6K9nJpZwpssnWkU3QwcOVrxPZXjWlljigFVj/bJuN1jlCPh/7IZBUCBhcL9KSga1vTHttQyuF6at0ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706713315; c=relaxed/simple; bh=xJgiomH/cxhNerklilkmo8Jkr30cyTGtYIstcEbnxwI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=paPQHjpsEK3HV7GCPCdpMJLopyO0tV9f+6JI6pIH4k88mOiUFELL6SVhXV/an8veUKNc5GdaCEsrJqU8FpC2C0rfXZKAKDQZgHhQo4kkWKkKxHb927m28YdR2In+UF7XkDfi3Tv0UCbPYvN5gp53geZq72ezTeiNXQO4L9zG0Ng= 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=KrbaMlF/; arc=none smtp.client-ip=209.85.219.175 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-yb1-f175.google.com with SMTP id 3f1490d57ef6-dbed0710c74so5183330276.1 for ; Wed, 31 Jan 2024 07:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706713313; x=1707318113; 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=xJgiomH/cxhNerklilkmo8Jkr30cyTGtYIstcEbnxwI=; b=KrbaMlF//G6hmQx4cZpWswyDatjoEljWjUg+WbI41nmM1NgeXskmHV01TBv6dceIoR BuH7BbxtebIhYOe7Q+qb29jseht6htGJMnUfgj0941kmQqrf/pdPRGvGC1YU/hK5Ka3h zdt+U0C4xvqjK3bFJL9/rT89FN32DiK/maQ8u+fFy9WE+9tmSGHV4O1mgKS3TcC5CSB9 YYkrrjU78MHOpXUZ3l07Yi3a41aCiNhpbjm+53IOq7/NEVy1p/M/cwLkhioEq/Tb4P+e 3pGfNMxIZlltnB66QCXalWjSiDh6GH7cjqczJx8mHMwWcHWXmcLcPppdEvf6DI8hsMFE TQCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706713313; x=1707318113; 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=xJgiomH/cxhNerklilkmo8Jkr30cyTGtYIstcEbnxwI=; b=KeUkvsCWBwX/MI1daWfLBKgIR1XPLz6vPdzgxlh6sZ5O6pTYaH0K2G5vVHD/YfwTBA F8m6Act5gaSaOR/tFmB1VHxgBzMA7Xm3+kzTtb0yMV7bjvQuLmc3daWi4KKq6vLbhxqB sA9zBIfSkPLQN4GF4AhC9X+Grkjl7wgLuL5kCSInwnkkUiQuOLG9N7B9AhS1h69XqaC8 225epYQhaYfrFwC6GxnWKpxWl/nvAJvia4KSzZUw38xqilWCEAGGp6wz9UymAZcXf9DC umPRbZOYIS51y58q2wOf86fFqbPFstUloCZ3eDDDK27NC2uEavjWkTfp/w7BOp5wQ13O n31w== X-Gm-Message-State: AOJu0YzsAv8nGdIDbT4lPEqR4BPgSGo5/qNjpjy22IACr8H8icNRwlf7 vCLNIKGw2wlUjqCNHYJ8AOAlEQF2RGF1Ti1I9kG39lAe9yIg0BYpHcIFHQv20eawX40iUkPIHqR s5rClNPTmLvX9wNCk1DgNT4L7Yeysqa9QHv7QAw== X-Received: by 2002:a25:790d:0:b0:dbe:ac3a:9d07 with SMTP id u13-20020a25790d000000b00dbeac3a9d07mr2023767ybc.1.1706713312776; Wed, 31 Jan 2024 07:01:52 -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-2-brgl@bgdev.pl> In-Reply-To: <20240130124828.14678-2-brgl@bgdev.pl> From: Linus Walleij Date: Wed, 31 Jan 2024 16:01:40 +0100 Message-ID: Subject: Re: [PATCH 01/22] gpio: protect the list of GPIO devices 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 > > We're working towards removing the "multi-function" GPIO spinlock that's > implemented terribly wrong. We tried using an RW-semaphore to protect > the list of GPIO devices but it turned out that we still have old code > using legacy GPIO calls that need to translate the global GPIO number to > the address of the associated descriptor and - to that end - traverse > the list while holding the lock. If we change the spinlock to a sleeping > lock then we'll end up with "scheduling while atomic" bugs. > > Let's allow lockless traversal of the list using SRCU and only use the > mutex when modyfing the list. > > While at it: let's protect the period between when we start the lookup > and when we finally request the descriptor (increasing the reference > count of the GPIO device) with the SRCU read lock. > > Signed-off-by: Bartosz Golaszewski This looks to be doing the right thing to my RCU-untrained eye, so: Reviewed-by: Linus Walleij Yours, Linus Walleij