Received: by 2002:a05:7412:9886:b0:f7:18da:975a with SMTP id ji6csp3210493rdb; Wed, 20 Dec 2023 04:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0k3+5glDElOuhbfTGFo7kkG/ydCwmhnCNghpVRVWF745vWTNRj+CGvY9LdmUKRJj3Ke0D X-Received: by 2002:a17:90a:8503:b0:28b:35ce:7d4f with SMTP id l3-20020a17090a850300b0028b35ce7d4fmr5129540pjn.37.1703075767578; Wed, 20 Dec 2023 04:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703075767; cv=none; d=google.com; s=arc-20160816; b=XpLAgvXVlR4iZqi6svtbRFNizBXmAAvQsr5VziJRVfxlrQ/GZiilzhngyoUPvldC77 QhnRSLVq7MQG4glHX6h4SSQaHBFPjmj6vtVDM54upOAspaMN0rFcPJKlGRjbDHYwPVoW qvawdNXOp3BJHocniwgFBjdeyif1mpFXSgDS2RNi9BPBfT9mR+ocD9IC7MdDn/vR8EHD 8dUJ37kiNKC9ZIODLv+z5KsxcvvhaoQlIzuSjJbO9BFN5QRSdNGULpdWKIx97hh6oKj8 K6koes9vZnvZ5a39yF5+nq6rz8JtluWxC1f+8VXkYU5QPTpe8Y/SfHd2vuun1B0pRhEc 3Iwg== 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=z5q57e0yI1dw2nfIkLVz7L+kM2nw1Ddm91mJrAmwHjE=; fh=NA2IZTsBFwjREUcds8Nt2e3faPWWUm3ShfnoxYpp9Xc=; b=jUuzGgZ3dJ9KpA4o6OejGPeEuWZUeKAWEMH2ULRh5DzE2OxuKVJ7IkyGDgsDA4SsWY vS51tfZVGNNZcSvy4rD9p9mNnAZHbBizasZZ4rPUQTCk/bIw6ZVIjppXzoIdNFZ4MsHX 1JNByOx1VskD1NyMFX5KLjUrq4xIJJ+jMfP7QyJWmnSv+eva+FaxrLDbaphON2BpVAZM x3RFE9WN8nkUxOlhDtNzvlDFddKuMCnZPHhu5P5R19m5gqJ9dVVGh7Cl7ZQW2V8tSofL lVj4EcSzvDgtl03ZA6CeSh5GRe9+teedwJXeMxvqW5hykJNr7h1Di7j6GnpBw9vSaTTf EnXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=dhxn1kBD; spf=pass (google.com: domain of linux-kernel+bounces-6901-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6901-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q2-20020a17090a304200b0028ac35ad2e5si3038334pjl.183.2023.12.20.04.36.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 04:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6901-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=dhxn1kBD; spf=pass (google.com: domain of linux-kernel+bounces-6901-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6901-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3A13A286550 for ; Wed, 20 Dec 2023 12:36:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27CC624A02; Wed, 20 Dec 2023 12:35:51 +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="dhxn1kBD" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (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 2442C25550 for ; Wed, 20 Dec 2023 12:35:48 +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-vs1-f44.google.com with SMTP id ada2fe7eead31-466c7eae53bso21794137.0 for ; Wed, 20 Dec 2023 04:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1703075748; x=1703680548; 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=z5q57e0yI1dw2nfIkLVz7L+kM2nw1Ddm91mJrAmwHjE=; b=dhxn1kBDrX+hmPW3UKzfEKizBj0QPltSytVrrNvJU5MVSA83zb6waxKAIcK+DROwL8 NS7Nevf6izB2BSiTnjbcJAnurKs9ezdFISh8lT+Jq94r58qKO86KAxDCtkZrE5rdPszn 7gvnZ/V20jsEjSOvdUBdm3jt+Dw0n+pSQdSpvsSMwjesG5h4PDgZr3xWjjg0DofMzNvR l4MAg6ii9BxFKcV2MktfVGC/vFT+ro0Rx8kH5xqb+zAs3Il2gWIYrkj4eYttRghSp82n qn0+Dnzf50wgSvYy21YhkSxunctGf89wdy+qXGP/8DHIOyvXIJb0Mqh/Foc3kB2DcqKC leQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703075748; x=1703680548; 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=z5q57e0yI1dw2nfIkLVz7L+kM2nw1Ddm91mJrAmwHjE=; b=sDeNeW3q3XpjjN4+RxEy8cl7ZT0bdnZ7LMQU9+VNlBmcgvUIK2dTnvBo1Ce8yDhRfk NO2HfjSq+DyDrRDUWWm/62CX4kbZJvij0nnDcWfDKup8ninXiXoxWdS1S+ILNMHD/rh5 8rmRnu4IEFhgGVvlJ0+DzpU6/beVQdX8YcX7DAtJ9/YYSVcnR5BHByjo7fWm5fAqgM97 ZNwcu8a7UFGX/8LTERKlC1umKMgyeukdcyri7U5+r4bUK7eYDc5vc2Pkmu30E0GdUd3q 8/L6ZtVTx3MP5BxO6WbUl/8sxKwUrHIER/kW9yCQ6Avm1Vd5IfnAoDZE8EjAtqMfaqbL FJvg== X-Gm-Message-State: AOJu0YxESK36d0UXkQdi3od78KrpONOXpg3iFMcGogzH1vKLAxouHNPF 2XwTBXZzxN0l/+Kn88l+4i3vqWS/jdVx6Ii0w5yWEKi9+0jpxQn4 X-Received: by 2002:a05:6102:4b17:b0:466:9d92:786c with SMTP id ia23-20020a0561024b1700b004669d92786cmr3279485vsb.8.1703075748043; Wed, 20 Dec 2023 04:35:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231219125706.23284-1-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 20 Dec 2023 13:35:37 +0100 Message-ID: Subject: Re: [PATCH] gpiolib: use __counted_by() for GPIO descriptors To: Andy Shevchenko Cc: Linus Walleij , Kent Gibson , 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 Wed, Dec 20, 2023 at 9:16=E2=80=AFAM Bartosz Golaszewski = wrote: > > On Tue, Dec 19, 2023 at 4:12=E2=80=AFPM Andy Shevchenko > wrote: > > > > On Tue, Dec 19, 2023 at 01:57:06PM +0100, Bartosz Golaszewski wrote: > > > From: Bartosz Golaszewski > > > > > > Pull the array of GPIO descriptors into struct gpio_device as a flexi= ble > > > array and use __counted_by() to control its size. > > > > How big is the struct gpio_device? Unifying like this might provoke sub= tle > > errors on very fragmented memory, where k*alloc() might not find enough= free > > space. Note, k*alloc() guarantees finding only memory for a single page= . > > With PAGE_SIZE =3D 4k, this might be an issue. > > > > I would suggest, if nothing prevents us from switching, to use kvmalloc= (). > > > > That's a good point but there's another thing. We need to call > gpiochip_get_ngpios() before the allocation. I need to revisit this > one. > It's trickier than I thought. We need the struct device to exist (have its software node assigned) before we check the property but we cannot allocate gdev (embedding struct device) + descs before we have read it. Eh, maybe it's not worth it and let's keep the two allocations separate. Bart > Bart > > > -- > > With Best Regards, > > Andy Shevchenko > > > >