Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp414128rdb; Wed, 20 Dec 2023 00:17:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlWOLzuMveyT1kq3uCeD+7rFEmr4Gn53emmwyKC6PLEjoTFa5pg+fFwRvYvT6eyJ8G4kGb X-Received: by 2002:a9d:7cc3:0:b0:6da:54b3:740f with SMTP id r3-20020a9d7cc3000000b006da54b3740fmr7550555otn.77.1703060243557; Wed, 20 Dec 2023 00:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703060243; cv=none; d=google.com; s=arc-20160816; b=tDgxonB9mufYUDj20U5WoFwkUBxsmh/LXpQX/xOGY9V9QiJZWE21SK/rNIU9PEjrne wEpLKWK/SHHDmzJ3PZ3ENyH0dxpGq2NhJRsRRt1BaWY8xM6munW+DajyxB9JIAYcr6wQ OguOfWQgRfyYCFo/bRWZqPAbZKRTJiQR+PqF4dOYpWr65hmIhKKjYf3D930hxkO6nA11 p4Ge8Yaf38cEeu00H8Rbes8tbEtcFgJLA8WJjaJFUyUMpcJxhYDw+idd4iyygJHVzQ0L f+zb8ur4jTP0AFqrvO7WDhYY2Nsjj/DJDpD4D9HzVu2DhJNqUWdi77vEMv4qwQMqThLO huiA== 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=gdtLFukSYKWmYynS80QImJw0tgI06bZ4ZKFg+X9Mqb0=; fh=NA2IZTsBFwjREUcds8Nt2e3faPWWUm3ShfnoxYpp9Xc=; b=pu66D5lNGGKy21RNJGAdYHKPUuQgBkh6EENuz9njChfUzcsKpYGNjaY7vanMN9m9eC uP+uKYyX0hO9nqo0/Pz9tVA1lyHS8/mDhN9xuh/Vuo7CLEYnoTUImVK7OaP0d+xOZNuj MjbINVeso7ej+9kFDRpQUg5CmKiTUezj1W9Dg7dH/06DOegWiOgBZgcZA92v/0gIUiqc MonafPGLaY8R2BFisHQra46WxcbdoGHS6JjiU/QwlBP5FIAY6iahCj1HtWPTFBeRJ+PD 64WdEuPvG+giczb5vqXUle9PSSZuwfo/seZqHmXP2AWZ+glvdOnY/cfX79gWsQJo5zNw ggDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=v8ILWJwy; spf=pass (google.com: domain of linux-kernel+bounces-6553-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6553-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o7-20020a656a47000000b005c1b323da1bsi22268513pgu.695.2023.12.20.00.17.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 00:17:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6553-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=v8ILWJwy; spf=pass (google.com: domain of linux-kernel+bounces-6553-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6553-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4EF10B254F9 for ; Wed, 20 Dec 2023 08:16:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 023231A582; Wed, 20 Dec 2023 08:16:32 +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="v8ILWJwy" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (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 BABE51DA33 for ; Wed, 20 Dec 2023 08:16:29 +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-f180.google.com with SMTP id 71dfb90a1353d-4b6c3a37ddeso675901e0c.0 for ; Wed, 20 Dec 2023 00:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1703060188; x=1703664988; 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=gdtLFukSYKWmYynS80QImJw0tgI06bZ4ZKFg+X9Mqb0=; b=v8ILWJwyawDOgm4me8Su39pXdXkp44E9sP1g2CMQ6X+ZLaASBt/mL2N67iedsV/FRt ULyupbONBo18qIRFQ4mEiEk0rjBo0jiIDuK30pIYJml1QHLaeXGdl1HgCctHEPR+flou vyjQA4V+LVXdingX3rZF+pXxMRIzTG/mB2Mw8UBI3N4NaP106NuJkKqFV2t3R12Jr6vQ S0GEKRebRS9H+hJK9PtXUOr7gIxeVSNaLCwRGOuWr78Qpaa3tweGMyOgAanhOvS0fsPs 5c9zpTkcQiMSujAhOPqUFVtw1R7Yc+OP/EdWTl6D9H3O5lY3z8M0z/yp8lRxIPqZtaT/ +rGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703060188; x=1703664988; 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=gdtLFukSYKWmYynS80QImJw0tgI06bZ4ZKFg+X9Mqb0=; b=uNQTMdJegWDXcrhJXKbzY0BQ+1GWwAGRIMaHvVayHbl3PNTKBe4huszrfvY3EaVt3h 0DJ8+435SrD9lJfhzrR2WuzpaWnmTTJ1O1eXefvBbHOurhPfqMuuXrgvtEL8tqWvW0wh uM8jyGyx4J6jaSIAr215oeTecFwMpHWkDHJX7gUJqOsU3jFLpR6AqqOcVFgYytMAYDQU 5CPlvv2rCdsUlejFMnbYJpuRYXiSA0sxORiPL2Wjoyx1L3m8a2iGVsWs0cL9wAeIxcQA pJsGXeE4TG+yaHmjZk2g9Yi/V3CF5khQpOoAZ03WGXoL4H1H/gmLmlRHwhNsl2R9vVdy UJbA== X-Gm-Message-State: AOJu0Yz/ranwz9KJ8pscT3qKHC/7QT1x5hfzPat1tNiSz69+KEfemQRn Po0bzcrYZScjFvrJeisBiERFRqD8xTizdHOWRJwQ8BDdYDmcauDQP6A= X-Received: by 2002:ac5:cc49:0:b0:4b6:cdb7:9818 with SMTP id l9-20020ac5cc49000000b004b6cdb79818mr1809694vkm.8.1703060188540; Wed, 20 Dec 2023 00:16:28 -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 09:16:17 +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 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 flexibl= e > > array and use __counted_by() to control its size. > > How big is the struct gpio_device? Unifying like this might provoke subtl= e > errors on very fragmented memory, where k*alloc() might not find enough f= ree > 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. Bart > -- > With Best Regards, > Andy Shevchenko > >