Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp13559lqb; Fri, 15 Mar 2024 13:22:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBc/MSsWgko8LItX8AHbe8fVzacFodq30PX7VSNmynTOxwEM2M6l+d0Fiui+hz9ym+a3/HyWQhoCY5Oxp9W1ngGVmpD47SZznfOTsVgQ== X-Google-Smtp-Source: AGHT+IEZnmOqfxzVrXlm65zAhro3GP3O9zOKnNtS35fT4G0rdYUpfJX1wW+dwzI0w0kOqv2k6xxT X-Received: by 2002:a05:622a:54d:b0:42e:78b9:84ef with SMTP id m13-20020a05622a054d00b0042e78b984efmr7031953qtx.8.1710534137035; Fri, 15 Mar 2024 13:22:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710534137; cv=pass; d=google.com; s=arc-20160816; b=gLHVrSJ0fZnDfhf1FBBz12OsjbVnEsEhwgAFKuZRePiCZLnNnVbm8DvWQ1gPkT0FTI v8y8plRHj5KuEvMI0mcaB0A0cVJezVutxwFk9sIpsKD4IjDAYsF70+nRZ8bqn+sR40m4 hEjkEhs3R5YM7AObl8xJgbYsuFtKZMqDjBwxR0SgVuk6aZQgII+02YoT49i0tMGkLFn9 NPQxW7+0MpznGpAFojC4mpgpayNWnSgwXBoxuusywWq4lAyyZK9t638tdPied7jnQJjE yvBAGCtsunkAxDdLMPbZQ/aT6VTLadJvoT2m9aoxDb3tJRU7Nt1P2/Wy0jA+1LARIpmt eFOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:message-id:references:in-reply-to:subject:cc:to:from :date:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=//uDqZxww2AW+IIRaNpkx7sG+p6lLha2oCwZuquPjaI=; fh=1x6iDDRqk8I3g5G+TsHaLsQW5DtA/B4fqt5yqYo+/Nw=; b=GJR6e0G0dWcyz2WhHCaoe9um35UiSwppg3WG64DThjC3gwABeqkRMo2J50BgWNwYCw gs3TQnQDLDAAKDqEScRgH8mUEmQSrmmA/EN54QJIIEhZWL2PG0SWCqn/iKY9SvrQgrRw htUxm/nLY+GiJlTXb/WvJ7+m69duNQpVcCD06ig/NBGK6EJrUYttTfzOx3i4TK4sNmVr /hn/+5B0F8e3XhIKLzxuOUYDMJ/uIhdwngA1OPUSgOvREOzVZng8wC5SO/eAjSz8uJSo 45YbZQcQFN2vg+60k7n4GN5dzaIWdnzVGmr4FN7FnAZ3Py4yzit1oRayBC9Xan65kw8L snBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@risingedge.co.za header.s=xneelo header.b=l7YKrnPi; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-104877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104877-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d1-20020ac85ac1000000b0042e8139c8afsi4432605qtd.194.2024.03.15.13.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 13:22:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104877-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=@risingedge.co.za header.s=xneelo header.b=l7YKrnPi; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-104877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104877-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B25AF1C21249 for ; Fri, 15 Mar 2024 20:22:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8502C5473D; Fri, 15 Mar 2024 20:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b="l7YKrnPi" Received: from outgoing6.flk.host-h.net (outgoing6.flk.host-h.net [188.40.0.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB9261F922; Fri, 15 Mar 2024 20:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.0.77 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710534129; cv=none; b=Ldt2MOOIE+zehiyrIep9r0IPo/Ca9ZLxj/evfJj+maLgUaAYURgfdSDbcrK50efKez2s7UwZGsEhBs2JIUKOekdVz0MLlzRSxq1NVKazeobvmLP4iHT8MtvpA4QLZi06wFh+RGCzHKJVN8xuPXg6fjHpTkBlih7oIXd9Oukm3U4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710534129; c=relaxed/simple; bh=SJBU7jhfdzTKjoCJ9KMNg06b4IgZL88IQAtDVxAHtJc=; h=MIME-Version:Content-Type:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID; b=qXINeT2mU/fH8WU7gI/lZ7P9Ke+sFKsjA5C1XgeFuRZ049big30YTfQelZcps/VSX8rvySPQFYOCCoxvzHGeg64O2xFi3aHFo6xpuZNl/Ka0Mwlbq6Kfj5fkxlt8QLz+wSADxEttOneZj32KmtPLDmRtF+cbeg84KB1XxI7r0fM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za; spf=pass smtp.mailfrom=risingedge.co.za; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b=l7YKrnPi; arc=none smtp.client-ip=188.40.0.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=risingedge.co.za DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=risingedge.co.za; s=xneelo; h=Message-ID:References:In-Reply-To:Subject:Cc: To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version:reply-to: sender:bcc; bh=//uDqZxww2AW+IIRaNpkx7sG+p6lLha2oCwZuquPjaI=; b=l7YKrnPiSty71c abFOR8qQpslU+gIwZGk63FdNmEFsrH/KHRm+tGKjIPi198/TPI6drVu901AqP6R5C2HvqvvfuwT8J GUE4PljouU3Za8hOUp/qjuF8pc1V796SRxUSEQkjDK1CdGVexJiJ2IKLgmzCWG7kLn4V+9HDBLfNN Cv1ivY4oSVH1WOKsj8EYJzDFMnhTZtzpWtLtD+XEF1gQuqiT/52zql2gTndEWvxDmPhToRgLrHbxG DGjJ6dM7jREJOeRz74S03BBdlQYQPp6O/gzrPUB4Yr3EDaP9No2rolKwbrlqd1SyX2phJ1h3mM4iC MhRL9X4mhX7Qqh3PQavw==; Received: from www31.flk1.host-h.net ([188.40.1.173]) by antispam2-flk1.host-h.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rlE3v-00BbGs-DE; Fri, 15 Mar 2024 22:21:58 +0200 Received: from roundcubeweb1.flk1.host-h.net ([138.201.244.33] helo=webmail9.konsoleh.co.za) by www31.flk1.host-h.net with esmtpa (Exim 4.92) (envelope-from ) id 1rlE3t-0006wR-JO; Fri, 15 Mar 2024 22:21:53 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 15 Mar 2024 22:21:53 +0200 From: Justin Swartz To: Mark Brown Cc: Matthias Brugger , AngeloGioacchino Del Regno , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] spi: mt7621: allow GPIO chip select lines In-Reply-To: <6c92fddd-f79b-40b5-bd52-61f43d6a7591@sirena.org.uk> References: <20240315015708.13948-1-justin.swartz@risingedge.co.za> <2dbc59c9133542f6f8bc465113d9630b@risingedge.co.za> <6c92fddd-f79b-40b5-bd52-61f43d6a7591@sirena.org.uk> Message-ID: <55c5f2e0723c18384c781e87985f0d22@risingedge.co.za> X-Sender: justin.swartz@risingedge.co.za User-Agent: Roundcube Webmail/1.3.17 X-Authenticated-Sender: justin.swartz@risingedge.co.za X-Virus-Scanned: Clear X-SpamExperts-Domain: risingedge.co.za X-SpamExperts-Username: Authentication-Results: host-h.net; auth=pass (login) smtp.auth=@risingedge.co.za X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.27) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT9/WeCzYiIeYgp7jnAlgaiTPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wCPRB8bAzJcv2cv+UqiTTc2+CpNcmBnO4XM3Sck4bwNogU WCl1nkLBzZX0KuJ9bXiS85Z42w/+2OBolTNFbPomXFWCX8oNdggW7HE9XDTdSejrkEpbuUvwMvHx 3T+KSG//gbuP7hnUK8NQdLwsVWKIss2oH4Yjh6Q4paNNh70vrmKlRYN8+ZW0XX0AH/7tz8lOUWMR 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ine.host-h.net On 2024-03-15 19:47, Mark Brown wrote: > On Fri, Mar 15, 2024 at 06:23:09PM +0200, Justin Swartz wrote: >> On 2024-03-15 16:45, Mark Brown wrote: > >> > The core should handle GPIO chip selects for you? > >> As far as I can tell, it doesn't - at least as far the state >> of spi-mt7621.c is concerned prior to the patch, plus kernel >> configuration choices, device tree definition, and other >> factors I might not be taking into account. > >> But maybe I'm doing something wrong, or perhaps have a >> misconfiguration somewhere. So, if you're able to point out >> something I've done incorrectly, it would be appreciated. > > Look at other drivers that support GPIO chip selects? Of the 43 drivers (of drivers/spi/*.c) that setup the spi_controller's use_gpio_descriptors as true: 39 drivers use the transfer_one hook, and 4 drivers use the transfer_one_message hook. Drivers that use the transfer_one hook benefit from the core taking care of chip selection on their behalf. Drivers that use the transfer_one_message hook handle chip selection on their own, within the function they've pointed the hook at. There's comment prior to the declaration of the spi_controller structure (in include/linux/spi/spi.h) that says the following about the transfer_one* hooks (beginning at line 493): * Note: transfer_one and transfer_one_message are mutually * exclusive; when both are set, the generic subsystem does * not call your transfer_one callback. Considering spi-mt7621.c was implemented using the transfer_one_message() hook, I'd assumed that it made more sense to take the approach of determining whether a chip select was native or GPIO, and then calling a function that is responsible only for the control over a single type of chip select to ensure that I was not influencing the previous native chip select logic in any drastic manner. To me that seems less intrusive, and allows less room for potential breakage for existing users of this driver (who are native chip select users only), than the outright refactoring of the mt7621_spi_transfer_one_message() function into an mt7621_spi_transfer_one() function instead. Based on reading (some of) drivers/spi/spi.c and looking at cflow-generated callgraph of drivers/spi/spi.c, to determine where spi_set_cs() and any gpiod_* functions are called, I believe that only the transfer_one() hook approach leads to SPI core control of the GPIO chip select lines - via the core's own spi_transfer_one_message(). >> To attempt to confirm if the core will handle my desired >> GPIO chip select lines without explicit state toggling, >> I tried to set the value of use_gpio_descriptors to true, >> without any other modifications to spi-mt7621.c as of >> commit 90d35da658da8cff0d4ecbb5113f5fac9d00eb72: > > Please include human readable descriptions of things like commits and > issues being discussed in e-mail in your mails, this makes them much > easier for humans to read especially when they have no internet access. > I do frequently catch up on my mail on flights or while otherwise > travelling so this is even more pressing for me than just being about > making things a bit easier to read. I understand that. The unlabelled commit was: $ git log | grep -A5 90d35da658da8cff0d4ecbb5113f5fac9d00eb72 commit 90d35da658da8cff0d4ecbb5113f5fac9d00eb72 Author: Linus Torvalds Date: Sun Mar 3 13:02:52 2024 -0800 Linux 6.8-rc7 > The core needs to know that the GPIO chip selects are there but once it > knows that they're there things like setting the chip select should > just > work. This seems to be true for transfer_one() hookers only.