Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp602110rdb; Tue, 23 Jan 2024 08:58:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFo2t6wwUJJIYzvyVLY83Ij2NrnYe5DVzFY2CWVMzKznUeTlOya0WMieVCiAf0Zx/svuPaj X-Received: by 2002:a05:620a:4052:b0:783:72be:ad7b with SMTP id i18-20020a05620a405200b0078372bead7bmr9393443qko.49.1706029085782; Tue, 23 Jan 2024 08:58:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706029085; cv=pass; d=google.com; s=arc-20160816; b=ko4u7s7jPhGx6E5HZqFMb9kNwSk4N0qbJ6Zc07OLmBSzIUMe8joshCfykjS+YpdLL1 QmJJrL2/CXWf81Z+bD+0fN4s/2jfvzz2p8i1wWibUlUrUNQ+Wof7Hfjxvd5gj7w3y24d eyBieHdhic/05v7YMrRcWy6UxPMKakgxafh39t6mmwvFMDpRBaC7dqRO+rshx+IZByeX A4fS9906UyqFM4pvFdqcq8PucF3RLdMLFKstkR4DfPhsyo/72jjqMNz+4BCvmoRHSW1h +BVo2vP69qaQPJBwleMQZleCtxi3NO1Lofnl79QMCloFFPwOvxOY2jA9tCF14mVwRs/t FP3A== 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=Z/d5m76wt4OsGM3BZpBnIBiif9rXJ89dqo98BB5XGUk=; fh=TFVv0+aHCJuqahw+yNbE9bthr1v0PiJMqYZ9US7qXT8=; b=Pin0UmjtHuGuHC8EgvWfq4x266p7gb9PNboYHr6scpmX2DB+4Gu52fML0kVsI6fq8M OR3JH7etS0ThoZLa/WQaQTZxxShZEB9JAKq56UcNq4OPQl1FftjgkuPlX0VWH1JF9m/7 GJ7bUqqLTPCiTTd6Xs3CqBUQPXOwQ84CPGLWRx/j7G/V6ghV6Z7EC1x8SryuszRUWOVZ MywAtUqCFyxTQ1hfxrMXkLuV5M5wkTjkhUvGjG8lUAHmFMaVyZ7oODH4LYT0uY5Tx1/t WKNvvnlO9YKG1bb7n+8SdX7R5TwnICOmifAiT8N1liXrrcNWTictX3krIYcM32qKa4fu xXPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UAzgYyft; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-35718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pi48-20020a05620a37b000b0078397ce1a38si6710559qkn.266.2024.01.23.08.58.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UAzgYyft; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-35718-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7574E1C2621D for ; Tue, 23 Jan 2024 16:58:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F353080028; Tue, 23 Jan 2024 16:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UAzgYyft" Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 D736B5FF0C; Tue, 23 Jan 2024 16:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028636; cv=none; b=MaVwAQJ82PXOipfno96vmDiOptrrEXOh6gnP7RASdb7GkdLUoNTDdnOf0mYv1PN/USjUNOm2FxllEmUkIPl60ga+X/eg9eZiPmD2wM9hroRqNhvjI1rncjxaVfKdHHCZmzzXmcqmxKc3fjbi2mk39nJpHL3ujH1cBpEKnUjiXUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706028636; c=relaxed/simple; bh=a88Zmqp4njTtxWiCg25rinX9YmeD6CxdtUTfyxUVraw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WJjgct4W7ITlvlzLuq9p7lsn8E78Bog8hWzflKFONA9pD9iaF+zKJPrQSuriR2Xkmqg18XlExEfG+XQFL3REhuT2D1eU0Uw1UqLhWmCbgrfYXuKdtXFaPbC5JaGnRvrJuytvMLCXJ7a8J89nrwOyxvKHNZEyfBZA+g/XeIF3S3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UAzgYyft; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so3871870a12.1; Tue, 23 Jan 2024 08:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706028634; x=1706633434; 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=Z/d5m76wt4OsGM3BZpBnIBiif9rXJ89dqo98BB5XGUk=; b=UAzgYyftjDM1qC7oDcXUT9vb/SgUrspTABZouLUUIDpGPHXRewSmV+DtNRpFQidMLe D7Xqakc4+9geOAJRlrZbj66McHy+Gso39eDesJkQt2OlNGqSYlDlelJPl2N3/iI9lywS A0HvgN2IRMqVpJwbMRP8tdidZDTgk7BNMshLUKf0y3X2uM+hzGyqg/fiR+4DYVy5BAhM EsJ050BJjJ/Jchv1EeAOu7NJKy+B7UQbASonEdlfiAS6APDrJmouBBhK1JKY16awSc26 gumx4pUYOt8hKMDRYMtULYb5KX3Ow8b9qhMLqP7MOAv+1uVVqKZ6h+3piLPz5IBjazBn OYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706028634; x=1706633434; 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=Z/d5m76wt4OsGM3BZpBnIBiif9rXJ89dqo98BB5XGUk=; b=aV361/hZzruCuB6ufKGH2wvnDQIqn4Ug2cG+pp1F3xoObfjcoS9P3R18yeVBPji8nb xmT9BGsD9j/rMAAY94DkKe4y25y2vXiuabL6XUMadfcSzefwfVleprSgYM5yXt8M3Qn6 SIu9NQdz4E8VtA3qikWB06TOO+nyKKmqv0Q8pu72vv5jhK9vcOuennC6ROK0A4iWtQm3 ja7LJQ694dVZrXn6EOKJJjpwBlNzbHfzWMt5RV5+bxjBJZZNRCPv8922xR3i/vyDP1tg 8tdLdqyiURW7weMJ7Q4NugkgSLvRwaNinKu3julN4j5ofTu/sFKuuICISp0lLxbfRrzJ /0PA== X-Gm-Message-State: AOJu0YzD/4PFqYONdYNxHG8rtJZqibIuyRfTqwOpfO2i5uvnLWfrpWLe n04J19YA3083gycalxWPrHw+0wc9qOqxT/cx+ZV8iq9ByVEdWNV9Uo4qC2lFFIDejIVzdmalqBD XOL1ImFnKwx1Wov1unWJnYgE5AYLd39/xSWL60g== X-Received: by 2002:a17:90a:f0d7:b0:28e:8787:9ab7 with SMTP id fa23-20020a17090af0d700b0028e87879ab7mr7137333pjb.38.1706028633969; Tue, 23 Jan 2024 08:50:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240122-spi-multi-cs-max-v1-1-a7e98cd5f6c7@kernel.org> <20240123120430.75c7ace0@bootlin.com> <93385fc2-7596-4f66-b0c1-07d7d5c9ed8d@csgroup.eu> <49b52941-6205-48bd-b2ae-e334018ac5cd@sirena.org.uk> In-Reply-To: <49b52941-6205-48bd-b2ae-e334018ac5cd@sirena.org.uk> From: Jonas Gorski Date: Tue, 23 Jan 2024 17:50:22 +0100 Message-ID: Subject: Re: [PATCH] spi: Raise limit on number of chip selects To: Mark Brown Cc: Christophe Leroy , Herve Codina , Amit Kumar Mahapatra , Guenter Roeck , "linux-spi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Thomas Petazzoni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Tue, 23 Jan 2024 at 14:56, Mark Brown wrote: > > On Tue, Jan 23, 2024 at 01:26:04PM +0000, Christophe Leroy wrote: > > Le 23/01/2024 =C3=A0 14:18, Mark Brown a =C3=A9crit : > > > On Tue, Jan 23, 2024 at 12:04:30PM +0100, Herve Codina wrote: > > > >> Moving the SPI_CS_CNT_MAX value from 4 to 8 is not enough to handle = my case. > > >> Tested moving SPI_CS_CNT_MAX to 16 and it was ok. > > > > OK, I've also heard 12 as a number which this would cover. > > > By the way the comment in include/linux/spi/spi.h is confusing. This > > SPI_CS_CNT_MAX is really not the max number of CS supported per SPI > > device but the max number of CS supported per SPI controller. > > Well, it's a combination of the comment being confusing and the > implementation being a bit broken - we simply shouldn't be limiting the > number of chip selects per controller, the per device limit is much more > reasonable. So ideally the code would be changed to reflect the > comment. At a first glance at all places using SPI_CS_CNT_MAX I don't see anything being broken / reading out of bounds if a controller has more chipselects than SPI_CS_CNT_MAX. So I think the check of ctrl->num_chipselect in of_spi_parse_dt() is bogus/unnecessary and is in the wrong place, as this is for parsing a spi device node and not a controller node. The following check for the amount of chip selects defined for the spi device should just check against SPI_CS_CNT_MAX instead of ctrl->num_chipselects. __spi_add_device() later will ensure that any chip selects are valid chip selects, so no need for of_spi_parse_dt() to check that either. But I didn't do a very thorough read, or even tested it, so I might have easily missed something. Best Regards, Jonas