From nobody Sun Feb 8 12:20:23 2026 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 3788120DD4D for ; Mon, 28 Apr 2025 20:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873986; cv=none; b=KHfAq2J4Ecd8RIxGBfNN895D8/3olaOzJ9msS4hnIaV9j17KQb5Udmm7fhCSgPJs+9EaBaeHHaYRrIY98IymnzdHTsw8+F4e2J3Yji/AbXvcqZxWeIxXrFC2pISINc6tf+eZuLy0AyMA49roQvD3ECX4m+9Oyx6PVFRx8r43FNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873986; c=relaxed/simple; bh=4YUyAmqj6DMqtc0zwouOnq7KPjPXOMqMgSZciQQWnro=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l7ML8fBUKq6QjtQqSkS5fupWweIYOCnXntSgGTH4dKWGVWa1iGbP/XobVxFi0ABt/JGFM6GeggFzit1PnppbN4py182ocSSGSAsuNqQW9imOa4SP49kWoXKsjU0mYUqNH25+wQtxwXMqRwZZ9++dYmsgxlY59CJZ4H82V8yi7C4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=DmLOTPdy; arc=none smtp.client-ip=209.85.210.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="DmLOTPdy" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-7304efb4b3bso2907594a34.0 for ; Mon, 28 Apr 2025 13:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1745873983; x=1746478783; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+6lQOjzQQhFPGZyqHYohzhwr3/IzfWMuRpfSMF+bnRg=; b=DmLOTPdyuKxtpEVOax4fJuIRfwwjBMl9eKm7afA9mQiBB6TF9XtTm4wUHskbQQ1Uks c4PgsNZ1E11eRr7xb+mhiQQj5WStadXiJKNJCI22gG+wAWy8EitEzS7XFgmrPNyu6t5v RiI+6ubi942OAfsLFJFJ7op/WG57P8XEGn89VZCpJV5oBkHOC4opJk+1g22nvQ87Enju XAnQpar2yFWU5bksr9G+WJfc/2uiGhJVDvTB2BS+6CpZCeBL8cWMof1g4nt1UKw6jI2r qd83C0Sha8AbkihvtQt1RE/C3TRRHrdufrRz+Lqws5cF9BftUX+FYwhby4KoTVSDAJyT ysCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745873983; x=1746478783; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+6lQOjzQQhFPGZyqHYohzhwr3/IzfWMuRpfSMF+bnRg=; b=HVFIj9t1Wo/YiULD234HENXq0B5sXuDK7Vl/hrA2blZNVDSvqniTuHgq8V7Rhmi253 PU0nS21SniARTpVU6w8ozXMkf+lFKXJa1T0qdk6yzv5niKwNceIRhJam64VheMOCK6ew h23nSFfz+Bx/IU++owORFU6kqPuG6bqt4xXmh7XJ0FwNJiPQmZqX3gulmhNrE7BGMko+ eZSxnZYRvuvENJT/q77Qc/K0wVqiLGMqEqsaHwXSOugfVO367UVoNEBsE+A7OBznSXti NA/0b3IHsUZb4cgMvVDMLJuWniW54ym5n2IYssw9CZkPGUWcL8eV77JgV+ufvBGGgjPg h20g== X-Forwarded-Encrypted: i=1; AJvYcCWPmwiHdj2/1npwtZIMm+mf6Et75Jy9Cu0qKowkkvacCqm2/KpnVK7sgQGvtXXRc9cbS7ws3gXNCeOfT6Y=@vger.kernel.org X-Gm-Message-State: AOJu0Ywvy3mfhDlzAN7cLuOowTX1cX5EIkSslS7d5qcoD+iEZv1I23ky xiHEldwlqydqXQJOoCe1KO3k4yw2IilK+TOSjqLedjQe/DHCDNnESkJE2/vSOYg= X-Gm-Gg: ASbGnct3fhCKSd21kZfau/WIB6uRXfycMMLu0Z7sBjojzlOoDPgZCvk7VVQ2xuShvhA ojeByw+WjmX2wwhFB1Da9KVIecU+CZTzywSZn2lT/wvmj97GYWgudoD43JsZ722vg2MU8wv89vd eJ9ati/wxfdTHn2UT+KwLPtgPNsibpvgNH2P1zMZf2DnDWi8KJ58nh2PqoGeVxeqkFsV111kU60 opDQk+J9WV9Nq3H34+crMNDGfhcku5O8aHLQ0stDzstp1v4+bLYYWcniVNC815o0+PpQpa8E8Ko v2A8+0U3h7YHaRBXzrjg/7KPBdC0CnFwu9xIVTTCVmJgy/E= X-Google-Smtp-Source: AGHT+IHlJSQkB9+ichJ14rfahl9hWPuKPe33valnFBNvz69hHak5mbInhbEyboqZmxSs35P3xykTfg== X-Received: by 2002:a05:6830:6406:b0:72b:9316:d596 with SMTP id 46e09a7af769-7308a4f129amr197220a34.3.1745873983137; Mon, 28 Apr 2025 13:59:43 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:cff6:9ed0:6e45:1ff9]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7304f056ed8sm1907614a34.0.2025.04.28.13.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 13:59:42 -0700 (PDT) From: David Lechner Date: Mon, 28 Apr 2025 15:58:56 -0500 Subject: [PATCH 1/4] spi: axi-spi-engine: wait for completion in setup 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250428-adi-main-v1-1-4b8a1b88a212@baylibre.com> References: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> In-Reply-To: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> To: Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2117; i=dlechner@baylibre.com; h=from:subject:message-id; bh=4YUyAmqj6DMqtc0zwouOnq7KPjPXOMqMgSZciQQWnro=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoD+wgikM7d41wI70h43Y6kTnzcebvjLzmaVj/T q/8VSAwnR6JATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaA/sIAAKCRDCzCAB/wGP wAIsCACO6ZHobVgzjDmekcnGZALCIK/EXWkkoE/NMYAc7xb0Ud4owkNWJTHEKw1QP5B4mGCN+hi ZrWj/rkiCoOQb1itABa0a5M62SluKm/saalgejkAAwDqrIk4it7PBc3zgBvYdTr47Mo+sUKLOmX 3WaZim/Q8BPMCUpl5uvA8IJT+GKvPYjxsxkNjWkd748tfBc7St6kZ+G7m7UQ1DuvmVHqnPGv+vZ lcfFY3EkihtaEb/QFIeQfgMSVTGDVY4xxc9lK3n/MxuJmskVNzSbmAsVEf4ty5j3YeiL95E/Mng gweqI4hh0GQTtEoS64lFtIN3NCbuCM6vVNGNK06Dws4SHu6X X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add a polling wait for SPI instruction execution to complete in the spi_engine_setup() function. In practice, these instructions complete in a few 10s of nanoseconds, so we never ran into any race conditions, but it is good practice to wait for the completion of the SPI engine instructions before returning from the setup function. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-eng= ine.c index da9840957778579dad3286f493abad87ad8a3bfc..d040deffa9bb9bdcb67bcc8af0a= 1cfad2e4f6041 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -739,12 +740,16 @@ static int spi_engine_setup(struct spi_device *device) { struct spi_controller *host =3D device->controller; struct spi_engine *spi_engine =3D spi_controller_get_devdata(host); + unsigned int reg; =20 if (device->mode & SPI_CS_HIGH) spi_engine->cs_inv |=3D BIT(spi_get_chipselect(device, 0)); else spi_engine->cs_inv &=3D ~BIT(spi_get_chipselect(device, 0)); =20 + writel_relaxed(SPI_ENGINE_CMD_SYNC(0), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + writel_relaxed(SPI_ENGINE_CMD_CS_INV(spi_engine->cs_inv), spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); =20 @@ -755,7 +760,11 @@ static int spi_engine_setup(struct spi_device *device) writel_relaxed(SPI_ENGINE_CMD_ASSERT(0, 0xff), spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); =20 - return 0; + writel_relaxed(SPI_ENGINE_CMD_SYNC(1), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + + return readl_relaxed_poll_timeout(spi_engine->base + SPI_ENGINE_REG_SYNC_= ID, + reg, reg =3D=3D 1, 1, 1000); } =20 static int spi_engine_transfer_one_message(struct spi_controller *host, --=20 2.43.0 From nobody Sun Feb 8 12:20:23 2026 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 E3EDD20E71E for ; Mon, 28 Apr 2025 20:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873988; cv=none; b=Y9jVL22eiJ8sQBKA0XZeRjxQvqj/PRXBH6h6ElwHuQNbTC7/fxJH3ODYmLEiprIp0gg1kf0+o4RFaTiCSXyjyMD0SfU60G1y0Z6T+fCiseuuIFBjZVkMa2RupNj1/mDiGkoKHyIjzLujbsnT0cNo5oOR6iAIlQEeklhdJ2sz+0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873988; c=relaxed/simple; bh=DelXqB0kZspoqygncW6vUyeVFO+EIcLtNSWKTaOCkQo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M5sG0PjQlTnzNc3YCptvQejCmajeBeFTBHxm70Yoj6WC2a8NJZVweAdaoR6EVEED6S5Q/uSODOuvGkNvMc+iE+gCSrZeZjGxCPV+/1XggDJmW0flHrL6kKgp/scng5Uaxxd/cEtJ1LRP5fh9dRd33wHkAXbIB5R3deyruUDua2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=CmQRre3V; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="CmQRre3V" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7306482f958so1883683a34.0 for ; Mon, 28 Apr 2025 13:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1745873985; x=1746478785; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7Hj8neZG0BLKL1cfy93HnA9rg0nDsQm55TmsJP7Yas0=; b=CmQRre3V/ea0D/AAgOcH7h0mgTIZiG3cmLubqSTy9i203rmvkLVNk4j/T3R0zj+nqb 0wRp5LOp9LBm07DoEsDRx12HISi0whGN1lvfRLHLjIYh6WukpoACclZm1M9WPvcOkWXw hV8zId/virL63ZeS3diQY3oJ2PnmRL73zvT+y6ZW5yjg0i5r3a0z2wAa+Ak8ybdkeZkx IlK3Drx4uxN4yaMesPDqPy47tbiwwBok1Xle8N11db++4i1AmbvuXOPUhL4TThm4VZha iC6Zj+KQN2TUVy1HdQyQi7eh6hpiRM3tvRxyUtuF4vY10i82IqrblzRMZW5289IVapeR OQbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745873985; x=1746478785; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Hj8neZG0BLKL1cfy93HnA9rg0nDsQm55TmsJP7Yas0=; b=iiVoR11GGObO/d4ndp+ON7hI9P+l1vtbThW9L3VFBhSId51Hp09ikkjBUWYBQQFLxp g2g6PRp/s53L2bE64ktVmd5tIRGERWcgcYgMOQ5PkIvR3tzAHarsDVIssKSo7IRdQX3D PM8k7o4YZC83fsS3PokVVyVwS/7/FuLfrwBi/FrzqD/my1NLcY8IGZqLeEJR5+lSncad 9dDfvcJzGx5ky36I22g0l4AjAnt46/etV0/ao/p3mv5EdsnaJYUi2uYQgbA+aBrMUha5 Vn9gtIzkDhwhfSG6mvySqHPjA4g2AnGHuptKGUHTIKSoatq4NIlGC3U8nA61hQ6Lkuk5 Tldw== X-Forwarded-Encrypted: i=1; AJvYcCWTILcSFbAtTS6PbKtZ23hgIz0LOVl9ReH3UDZ573RCPfsR4tE5RlsPbgT8MW6+vGhvm1ncKaKQ5sNGzPg=@vger.kernel.org X-Gm-Message-State: AOJu0YziOhJhUvggT0J5ZqQ70LoVXickLcuT4KkMCVsas+yBA6SnCRbY bkjdJdKAha5SozOBLJsglblkWxUUQzM7ESLMetfIDQ0zKpqZpq2QNs2nWfoRGDrWa+6Owkbjqt4 H X-Gm-Gg: ASbGncuvIwIMOqgZwIjx7dI3h1dIqMbGf3xq0GeKnTN4HeQRY9/WiX5mBURoKqOEhEg 9s/Y/f+iX5crR+pxp0Sn33GCD9/lFkSofnFrGMNYZ1Z9w6xm8aIttXstqBNoHqrcMRQm0hZMPGp TJjNgDmdnyVPpygrZ3rHuzLpMsptcpTmbeP2N2cxZdZKcBV+VCPtD7h28GuCn1QxZj5TcKf5wE8 jTR5U+3aAozca1nuAqKuJKWIfwFbZtF66p1etpNgHj8y5OBEg3d1UjgAjyqX+xGdMbOMXlriiJ8 lTxcU33qN1gWmKfLzY0Y+eSEu0c8t7VnPzTRdALot9Ldcn/RwpMrcpY4Tg== X-Google-Smtp-Source: AGHT+IHPXzFGESNGtWPXMMYFKuEbAcfuFQSq+tY06p70W8UYIb1ZbppxXWy49aCkKdbqNVV2dVqjGQ== X-Received: by 2002:a05:6830:7008:b0:727:3f3e:53bb with SMTP id 46e09a7af769-730652484d4mr7554910a34.24.1745873984945; Mon, 28 Apr 2025 13:59:44 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:cff6:9ed0:6e45:1ff9]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7304f056ed8sm1907614a34.0.2025.04.28.13.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 13:59:44 -0700 (PDT) From: David Lechner Date: Mon, 28 Apr 2025 15:58:57 -0500 Subject: [PATCH 2/4] spi: axi-spi-engine: don't repeat mode config for offload 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250428-adi-main-v1-2-4b8a1b88a212@baylibre.com> References: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> In-Reply-To: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> To: Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2855; i=dlechner@baylibre.com; h=from:subject:message-id; bh=DelXqB0kZspoqygncW6vUyeVFO+EIcLtNSWKTaOCkQo=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoD+wnk1x4zDUziAXMKBJGxbZJ++ALElXgHtjSE EWSxK4NEQyJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaA/sJwAKCRDCzCAB/wGP wBdMB/9J7r9hguCa0J/Bnaby+br8PqrHL4r6wyA7ZkJb4nG+Wce9yqgNTEnn1ZEA2FlE1M99LTZ A61+R2SvcrT18kSR1rVEBwMK/lUmPm7MtGT+FAS2qj00sr5V1moXmV3RFoww0qVzfgnk2Yuq9kr hk/XcMTzJ1fSeGb9BIfLH+zaCEYlr0gVi7d8UsLW/DurZ3mNUfmiNLv841UAAL+0QLr8GKFclf0 YIIvH4DSBzKZ9YGBdVDVKXBEcJIoSr/iZQxbzITG7OFA1Pb6Udld2SW6V343Fz6o2tk3QiHrbPd LESpyRfD69A0U7dcz9F0T6h5bjwYagnoD34YgvhcA7kLjbVq X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add an optimization to avoid repeating the config instruction in each SPI message when using SPI offloading. Instead, the instruction is run once when the SPI offload trigger is enabled. This is done to allow higher sample rates for ADCs using this SPI controller. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-eng= ine.c index d040deffa9bb9bdcb67bcc8af0a1cfad2e4f6041..05ef2589f8dc0bdaa1b3bb3a459= 670d174f821a2 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -141,6 +141,7 @@ struct spi_engine_offload { struct spi_engine *spi_engine; unsigned long flags; unsigned int offload_num; + unsigned int spi_mode_config; }; =20 struct spi_engine { @@ -284,6 +285,7 @@ static void spi_engine_compile_message(struct spi_messa= ge *msg, bool dry, { struct spi_device *spi =3D msg->spi; struct spi_controller *host =3D spi->controller; + struct spi_engine_offload *priv; struct spi_transfer *xfer; int clk_div, new_clk_div, inst_ns; bool keep_cs =3D false; @@ -297,9 +299,18 @@ static void spi_engine_compile_message(struct spi_mess= age *msg, bool dry, =20 clk_div =3D 1; =20 - spi_engine_program_add_cmd(p, dry, - SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG, - spi_engine_get_config(spi))); + /* + * As an optimization, SPI offload sets once this when the offload is + * enabled instead of repeating the instruction in each message. + */ + if (msg->offload) { + priv =3D msg->offload->priv; + priv->spi_mode_config =3D spi_engine_get_config(spi); + } else { + spi_engine_program_add_cmd(p, dry, + SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG, + spi_engine_get_config(spi))); + } =20 xfer =3D list_first_entry(&msg->transfers, struct spi_transfer, transfer_= list); spi_engine_gen_cs(p, dry, spi, !xfer->cs_off); @@ -842,6 +853,22 @@ static int spi_engine_trigger_enable(struct spi_offloa= d *offload) struct spi_engine_offload *priv =3D offload->priv; struct spi_engine *spi_engine =3D priv->spi_engine; unsigned int reg; + int ret; + + writel_relaxed(SPI_ENGINE_CMD_SYNC(0), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + + writel_relaxed(SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG, + priv->spi_mode_config), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + + writel_relaxed(SPI_ENGINE_CMD_SYNC(1), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + + ret =3D readl_relaxed_poll_timeout(spi_engine->base + SPI_ENGINE_REG_SYNC= _ID, + reg, reg =3D=3D 1, 1, 1000); + if (ret) + return ret; =20 reg =3D readl_relaxed(spi_engine->base + SPI_ENGINE_REG_OFFLOAD_CTRL(priv->offload_num)); --=20 2.43.0 From nobody Sun Feb 8 12:20:23 2026 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 A042621325A for ; Mon, 28 Apr 2025 20:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873989; cv=none; b=Ui4bdVJTLM05woaB8QyzEU7EpuL+SyrZOd4qmw5nowcjRxnbuejBhgRA3kVsPQxthig7a1dJ/N9bazA7+Uim4mh5eJEz4u74uNrnAJHm3P3ZBUO0w1i77/Ov4AOv2vWaQvXDyG5mKM5Kqfahz8hLR/g6zPl3ou6Ptj0rr5p98Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873989; c=relaxed/simple; bh=ARaJN/laTWSSwP+pW1ygay2pt+8PIw/fbx6nDgGq5XQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mUGEaG3Gsuh7IxE7Pnqz6PGDdvLymZlI6pVPv5yFec1QIEQNFrX6aqtmbzj8elET0FVPsxE3/oEb7QaXxxYaw28qwGoeR87W3NHUd9e79trhE2H8MLHJ4hob9l/X/fpVez55YbcBMUW3daMbl47ypW8rAsjJmtDIjBf42Gt37ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=VZp/b/zH; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="VZp/b/zH" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7302a769534so3673610a34.1 for ; Mon, 28 Apr 2025 13:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1745873985; x=1746478785; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EPm/vbZvGk/XMsHbJko6sUgnPY0qOBeRTAo3Ld3TAjY=; b=VZp/b/zHE/IG86D6caMqm5lx+/raSCj2sXRTtWuG7wtXVOtAbawsEa0KRHazppsNhM +f9TQOfWO8bGZob2RkYETSgjXpe+C3p6cmIqvwMIfgtzKdJN3g7wbDeALKulw/viu9aY X/JUM1N74bUlskgSD7cno/siCWXbI5Fc6X33TmKUbZ88oGZb7brvzkbKP4U9ids1m3TA TzqvSAKf94y6qqm2s9atxoB1dm167YNkQwT/TZbdeh3OfLMppZr8QqY0ebNMKbX8yIzR inmU1btuJ5Xk7Nd/bh7f1OL3eARG/dlaIFZ9fOi6JUxPq3yl0JYBZogX9cOSZRX3/91r p2dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745873985; x=1746478785; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EPm/vbZvGk/XMsHbJko6sUgnPY0qOBeRTAo3Ld3TAjY=; b=eVG5xMx0+x4rVDSbC1kcVdqLp2QTbFC3Bnb27uVGas4y40eqtaH37MS98qtg24+k+A gj+IN/FxwkxFSqpS023mFOfy4KEC1v+AXsce79NrOGcvmbFfo9xFQ6fpvk32oSOFLqm+ M+r6beECaTzLeWHbTyBAWl5CqMfnFnD7kDr2WzAh8y7p0T38upGkJgo83o/5Vjoh8TXb DCTmGyvxfxbivhC44oAxym39CLd8vDainZ/TacXNg604kW8eiqvxmGkOLbrYO0lFLKmj pR/DhkrEX6pQSDwir8Q268jMpaE1PXgBXse7sbaRgkKlPpNyqp6zWoDaBQxajOfI9/26 jQhA== X-Forwarded-Encrypted: i=1; AJvYcCXadjHK18ffnD+io9ypVbWjlxnbPe1ei6t+l0P4FCFT6P00m7OtVw9jrrGySIQuqulqZWCnp8cZqyshCcI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzrpun8Al4D7V86zU0GtR6O4UW9ujnliX6htHDb7+LJQloYCExl YF+aL56nIVFEDbmVrYACUZxT5XlbLtx0pFwS09fBotGu18OxoVoD0FgBzCTI5nQ= X-Gm-Gg: ASbGncsZYc1BdEP/CdWmF687XWbexUVAI3AEn+loceiUIQtjkzJJDJMODqlbi/+K2x7 1DmajtI6jvQ6fBC6TRzRlT4FhDONLoJ/b321U1Wc7IKvqLWLV5GLaC0QQtNUN66exxsnKSF7JK7 I7MaTWmcM8afy4Vvy4RuJjhdBQ7lyMFIUe0oZ3q7oidGmL3Cwuqfa4A3sHBqKkS8quh0vSMl2Ls NSgRfOjP9Sgp0P/mpAWho5wvtiB62GDnqzX2Zvzi2igjgQL/D088MhEWtCg6oAnaX4r49O2Ms1i ga5vDaGcQX+/rUrxTRXcGV/4b4x64pimoInKn63mYEM8Krg= X-Google-Smtp-Source: AGHT+IGtUrL0vdxDI0xO+GerII96y3Pa4pSQsQzyvLDIuSbvj5q60OHBh+zIXpgdsShHxvLkTCZG4A== X-Received: by 2002:a05:6830:6014:b0:72b:a9f0:55 with SMTP id 46e09a7af769-7308a4f12f8mr150300a34.6.1745873985641; Mon, 28 Apr 2025 13:59:45 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:cff6:9ed0:6e45:1ff9]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7304f056ed8sm1907614a34.0.2025.04.28.13.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 13:59:45 -0700 (PDT) From: David Lechner Date: Mon, 28 Apr 2025 15:58:58 -0500 Subject: [PATCH 3/4] spi: axi-spi-engine: optimize bits_per_word for offload 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250428-adi-main-v1-3-4b8a1b88a212@baylibre.com> References: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> In-Reply-To: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> To: Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3108; i=dlechner@baylibre.com; h=from:subject:message-id; bh=ARaJN/laTWSSwP+pW1ygay2pt+8PIw/fbx6nDgGq5XQ=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoD+wtKbrM87Br0iUTrX8PmS0qoypqR5/xwfFbx 5+1urDsIZ+JATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaA/sLQAKCRDCzCAB/wGP wGOQB/4lpOzs4u45Rj068DI3+3h1J80plwy9Pty6NFrRY9Tw+fylYlbbZcG11h3z4W0ivm+bt9U x7tzdi4H1R9LVPUoKkHEvKTPcQopzKNVPbdJNFJJG9+X80j9p08y4hplGSG/xTnKrOdS++xBaED KoSd4sjkHF10JeIpSjwmSiu5eACx1tVzYeVvM++RzPAPe5epKUVh3u1jCX240afaIaW2SKSamaF 3YGTeZFT+gufYSO7CQ9jI56iAKKmtw5Yu4GCmfzbpytdEaoTWAgfOhT4THS07n56yee8uqZOg7f mZsMRlY8B2orYX9vUvAzxAiF+IIpcZOUXdcEnAdYrRwYaYN9 X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add an optimization to avoid repeating bits_per_word instructions in each message when using SPI offload. This only applies when all data xfers in a message have the same bits_per_word. In this case, we can execute the instruction that sets bits_per_word when the offload trigger is enabled. This is useful e.g. for obtaining higher sample rates on ADCs since each message takes less time to execute. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-eng= ine.c index 05ef2589f8dc0bdaa1b3bb3a459670d174f821a2..b54d2e1437c9993d251aa2842d9= 040ec0949a78d 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -142,6 +142,7 @@ struct spi_engine_offload { unsigned long flags; unsigned int offload_num; unsigned int spi_mode_config; + u8 bits_per_word; }; =20 struct spi_engine { @@ -267,6 +268,8 @@ static int spi_engine_precompile_message(struct spi_mes= sage *msg) { unsigned int clk_div, max_hz =3D msg->spi->controller->max_speed_hz; struct spi_transfer *xfer; + u8 min_bits_per_word =3D U8_MAX; + u8 max_bits_per_word =3D 0; =20 list_for_each_entry(xfer, &msg->transfers, transfer_list) { /* If we have an offload transfer, we can't rx to buffer */ @@ -275,6 +278,24 @@ static int spi_engine_precompile_message(struct spi_me= ssage *msg) =20 clk_div =3D DIV_ROUND_UP(max_hz, xfer->speed_hz); xfer->effective_speed_hz =3D max_hz / min(clk_div, 256U); + + if (xfer->len) { + min_bits_per_word =3D min(min_bits_per_word, xfer->bits_per_word); + max_bits_per_word =3D max(max_bits_per_word, xfer->bits_per_word); + } + } + + /* + * If all xfers in the message use the same bits_per_word, we can + * provide some optimization when using SPI offload. + */ + if (msg->offload) { + struct spi_engine_offload *priv =3D msg->offload->priv; + + if (min_bits_per_word =3D=3D max_bits_per_word) + priv->bits_per_word =3D min_bits_per_word; + else + priv->bits_per_word =3D 0; } =20 return 0; @@ -306,6 +327,12 @@ static void spi_engine_compile_message(struct spi_mess= age *msg, bool dry, if (msg->offload) { priv =3D msg->offload->priv; priv->spi_mode_config =3D spi_engine_get_config(spi); + + /* + * If all xfers use the same bits_per_word, it can be optimized + * in the same way. + */ + bits_per_word =3D priv->bits_per_word; } else { spi_engine_program_add_cmd(p, dry, SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG, @@ -862,6 +889,11 @@ static int spi_engine_trigger_enable(struct spi_offloa= d *offload) priv->spi_mode_config), spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); =20 + if (priv->bits_per_word) + writel_relaxed(SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_XFER_BITS, + priv->bits_per_word), + spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); + writel_relaxed(SPI_ENGINE_CMD_SYNC(1), spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); =20 --=20 2.43.0 From nobody Sun Feb 8 12:20:23 2026 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 77DE120FA9E for ; Mon, 28 Apr 2025 20:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873989; cv=none; b=AE3v+A3PqABA0OMBkbbecVwF2WQW4t1/hqAPfwdc9xw2WJ2T6ng17dwwUSpgkcaUdYHdfNWoshmb2zNtmBbuLWol8n/f1gghOUN43qeraAq07c7WgcaI1rx3wa82F6Kj+rFm7KdXNvOQ7qF31bm7+xJVFbJ29e9TVmu7gL5Pi28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745873989; c=relaxed/simple; bh=Hot0Oy29xwQca3fFwNhjd1qoO8ecKD1UEJkmEF7N4c4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TmYtI8Hx6PPOfbrkvYpOJxxjE4w5mD7CZMPVIkjbqSJ4NsT1duQJasGl1la+ANLVIniylw3rEuSYRoFaWL1JjC0PqlZdAKzoQMleQgd5EbgW3F1WLUMOYaqPcHArPfTDurdn/MBRbX1BdpKnO71y0/ZXGbdKB1f/nsKGMpELL3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=itgL0QKg; arc=none smtp.client-ip=209.85.210.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="itgL0QKg" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-72b0626c785so4546204a34.2 for ; Mon, 28 Apr 2025 13:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1745873986; x=1746478786; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cgkMltK7c0hJCGj044bGbv6mIEyEY9fELxtEWcXT/oU=; b=itgL0QKgQ3EwXiXtNZ0zY0P2e4pxyMaUHgh48B6FeSS/60KzGQ5C+tMDBy4qL5/dyd pwca0p3XgvM7xKSpucs9npVeUJFEA7pR0rtuOrrR1pcKGPGO09pIUl48DNd/to2RGH/k SwSHN37Zgjf495bhNkKvrM369WPMTuftoNzbbsPRurkf0TWt9SvLLw+SPft0DBQ4gAXQ 80Z4f01IewNqN3y93G87wUxPxgfhJK/zZL+pDdo+Sz4+lbQlTUD4pz9ECxFBfoZzNNP2 +akBoN2h61O7mwiqSNfRYpz0Sor0PLa9WHD6E/JELUJuE+ymMUH4DbfgNwQMjYEf/GY5 Ak0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745873986; x=1746478786; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cgkMltK7c0hJCGj044bGbv6mIEyEY9fELxtEWcXT/oU=; b=qXxQ5ek3CR6w50/WU8Mlcpy+nr1PYub1rtNo14FW0weciTu0XIOZlzY5tgmzCa0wIU B6JC+Ss5EuHnM1Br57IPp715R3tLpupMcnDd8rTUHGQgxgRFMwMpuZgknpKvlbJGHgr+ TZo3xp3RZ9h8c+rXTnePharQpgV/T1zxKJvA7mAmFSH3nZjWRbNNJlHkmYyAPwPl0I+Z On0jmYeMeO2QFkqgiijAVfI2YXubOE7itvHBz0F7fdquiLPGpeDvlj4SxYHlBo44O55o /jQ0ipZDOr/p5oN/SpFo7cXGW7Km1AzPZK5LRC2Du+NypetIkg9dTgSv6K9S6TUgDJgr ym4Q== X-Forwarded-Encrypted: i=1; AJvYcCWks0t/jTn1D3M2TNB/i1pm3zxe6GVa4sPCbOQvbJkyyErg7D40T/zSjGKSwAttbSKuoCM5XAsZ9jq6ya4=@vger.kernel.org X-Gm-Message-State: AOJu0YwOBq/lZd84llbyrm0pGnx8EQyhJUWU6T/vq24SWc3SjygmI0VW k8Qwq4DPP0fBKSBgZA+LbIgn5LxhBy3H9UPspzybuPiM1/2oSq/owcr2BywhK0I= X-Gm-Gg: ASbGncvob7hfq1fLyl/kuIanTzLl/QQS6QtyZI+94veWS3R1r55In1PTnmwQwDEqu6Q JNoeMRmPpsAXe8htcMbhGGH3WYTIpyF70Ng+2eEmUcO7VxzeW6uPm+7HHK250MoJOiX7gbCY8P8 lf5xkHixhdFxG6T38N/MtyWco1G9LFCXwhjTSFY3UX4PKFkBCfrmclKNFbtyKtBlZabyPx3s3nX Ws0JFM2yBTqsxkxP2TAAdPS6947AWu7O+7/ZrLP04/72o1Wf+yEpd7zbybajqwkyxj69+cs+D0r nQB3GyTfWS6hmIIm1FB/CuhN/YPXLfWIVIWMpOaOV7s7u8c= X-Google-Smtp-Source: AGHT+IHBjFNxaxXK2uTmSjmKOErKMPwPnwLBjXcUoUMiKswS0jvYT4ChJ1QEqctONlEWTN+lPYxlFA== X-Received: by 2002:a05:6830:6409:b0:72b:9f90:56c5 with SMTP id 46e09a7af769-73088c2081dmr736664a34.17.1745873986383; Mon, 28 Apr 2025 13:59:46 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:cff6:9ed0:6e45:1ff9]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7304f056ed8sm1907614a34.0.2025.04.28.13.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 13:59:46 -0700 (PDT) From: David Lechner Date: Mon, 28 Apr 2025 15:58:59 -0500 Subject: [PATCH 4/4] spi: axi-spi-engine: omit SYNC from offload instructions 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250428-adi-main-v1-4-4b8a1b88a212@baylibre.com> References: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> In-Reply-To: <20250428-adi-main-v1-0-4b8a1b88a212@baylibre.com> To: Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2495; i=dlechner@baylibre.com; h=from:subject:message-id; bh=Hot0Oy29xwQca3fFwNhjd1qoO8ecKD1UEJkmEF7N4c4=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoD+w1ncYpjs/q9honQUN28D/IU3WXnD229sq4z jF3zy/aDumJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaA/sNQAKCRDCzCAB/wGP wIC3B/4rdKjJtlFDToqOrIGe5qv6sjXRM3wxFOP9IqRUQMZE8T9KxJaZp0yrem7LI9g9scVAUim 0oxvvokQ4GE+kFm5pCCLzRThx8kdI17Jins1k98bKAH28wrBFNGM9rhcLlnSP98z8V1KUNOSaFs Rvu07RPaoGNETx9Zag6QaaKld9dmpfLTDHX0lGeP/WbyXBXtOLsJQaMZxPMnet+8BBveOZI9Ou2 0OL8pBcQFanO6gLAf7r+dbV5ceQyzxLQ75OZ0nsPWWIymKrciP8P8RY36h/evzZAMuVHmwqsCbU hVY4gRa6aXKPBbNhC2bvQDY5uvrNvzfbq6pRbcVoabo6YNVu X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add optimization to omit SYNC instructions from offload messages. Starting with IP core v1.5.0, the SYNC instruction is no longer required for proper operation when using the offload feature. Omitting the SYNC instruction saves a few clock cycles needed to executed which can e.g. allow achieving higher sample rates on ADCs. Signed-off-by: David Lechner --- drivers/spi/spi-axi-spi-engine.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-eng= ine.c index b54d2e1437c9993d251aa2842d9040ec0949a78d..8cc19934b48b5276f49c4049dcb= 2dbbeb4112871 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -162,6 +162,7 @@ struct spi_engine { unsigned int offload_sdo_mem_size; struct spi_offload *offload; u32 offload_caps; + bool offload_requires_sync; }; =20 static void spi_engine_program_add_cmd(struct spi_engine_program *p, @@ -702,6 +703,8 @@ static void spi_engine_offload_unprepare(struct spi_off= load *offload) =20 static int spi_engine_optimize_message(struct spi_message *msg) { + struct spi_controller *host =3D msg->spi->controller; + struct spi_engine *spi_engine =3D spi_controller_get_devdata(host); struct spi_engine_program p_dry, *p; int ret; =20 @@ -718,8 +721,13 @@ static int spi_engine_optimize_message(struct spi_mess= age *msg) =20 spi_engine_compile_message(msg, false, p); =20 - spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC( - msg->offload ? 0 : AXI_SPI_ENGINE_CUR_MSG_SYNC_ID)); + /* + * Non-offload needs SYNC for completion interrupt. Older versions of + * the IP core also need SYNC for offload to work properly. + */ + if (!msg->offload || spi_engine->offload_requires_sync) + spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC( + msg->offload ? 0 : AXI_SPI_ENGINE_CUR_MSG_SYNC_ID)); =20 msg->opt_state =3D p; =20 @@ -1055,6 +1063,9 @@ static int spi_engine_probe(struct platform_device *p= dev) spi_engine->offload_sdo_mem_size =3D SPI_ENGINE_OFFLOAD_SDO_FIFO_SIZE; } =20 + /* IP v1.5 dropped the requirement for SYNC in offload messages. */ + spi_engine->offload_requires_sync =3D ADI_AXI_PCORE_VER_MINOR(version) < = 5; + writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET); writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); --=20 2.43.0