From patchwork Thu Mar 28 20:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 784016 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (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 616C17FBB0 for ; Thu, 28 Mar 2024 20:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659170; cv=none; b=GGzBsxwb6tgiJjW3/sg0LuOEiYV1BhU7FIGTWPkOl6BhjOdh0JgFGuti8jRKry/BKd3oraBcTk1Ef65l1SVeM4b5talJOCIFnGNfx5ALbet4klmTcynZtZX25csUWIs/sV13+7W9ZEx68FuYWM78bxnzqzG5/aBNdOQVugU49zY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659170; c=relaxed/simple; bh=GeMYE1tfKAVoMVZLat41QykjcobP/pX5nbPP5nlFDmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oFWAvXcY98qtpsIvvTMSW7+cItOs+U3IEJvw6quwQbhhjZkBFW/iZ3nkqpPydx/Swbotl0qd+qYI65uSIKIY+EVX4zI3xYBSFLxF+q1HpbqhiXkzihoZQWV07cpiwEtYWPXH1O61QVGSzmiSXpXYmZX5BU2gnEH/5D/Nrmnvz1A= 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=PaSNHWG5; arc=none smtp.client-ip=209.85.161.53 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="PaSNHWG5" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5a5272035d3so755765eaf.1 for ; Thu, 28 Mar 2024 13:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1711659167; x=1712263967; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=02QukKA7rGv689sMEnY5Waa2GxmfCRYMmefB+eiHwtw=; b=PaSNHWG5HD6j+WPHD8wLgj5iRrFYweQ8S76xWWlZ9HpMEXUGlrGH1MGOv62UrKFVYW e+2gQOcAR7TxKun9CqicBWPPzFB8zSDYPdfl8N4ykmg1t31DUDLjfdhm6pXHXRDqR6nU SnDzxl9+t+dgyZHUCGlIIwbyVhPXxVkTKKEFDi3nxa28sBEsDHphnCsTTsQjEMtXHluF Q/BVX3Hlzl5Iuhml51uyFojHWZB5NTkmOxd06SsvSeMBGPPbTxcz9N0fgffpmXaFR5O7 IXec/hpknlPHjva+gmKYt5beOTKQ6x/LIuJll0KaM/jEpFYooxNB7tOFuLsaakZaHrNZ rJiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711659167; x=1712263967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=02QukKA7rGv689sMEnY5Waa2GxmfCRYMmefB+eiHwtw=; b=k2CDFz166B418BQFKGVe1pqg/gZyYiuaArW3Ie3SPMt3B0UKIh5O0mN9PAQXMPoLDN W9lOE2kiU2cxF9am9zVjiruonpwlXNLES4mr4R59SoWG2caEz97rg+zp1faVS6dhKjOd k+XHPX1uZMLzSgpsKmHRkKjyzhVFL8RKnc/4lvFqnOGYU5osEl9hmiqckP9IUdlupT3n s5y6PgPIDf+cCVHBL2vE/27ArF89X+pPN9xEsCsQrh/RvvpmyA44E+9VWusylfqvOb0p MnHKB6j6f5lgrNbZpzw11GyD37AJxb+yB+mVEF6vCpqvj/aKeta9ZybLAxVw8tFud7il N+6Q== X-Forwarded-Encrypted: i=1; AJvYcCXmxQTB41hoqaArol3iHOb5tt/iCFiQ0IDftEpq1WmZz5+hDZNNq+3ymq5dixe5ucGty98AN2YTP4Rt+fFl3t+2afvWork5g2Jc X-Gm-Message-State: AOJu0YzzZF22a1zeTss0jZLi1e1FtMHppRhU47Fzd2okgyv9k4t533GV Au+n0I7fmC5ly/FIZs3/JFWNjsxexMEnD4uK2WNPmEsztk16ekeDJk/TehhG3xA= X-Google-Smtp-Source: AGHT+IGxxiP+qq0jVjWIwgc+9slYwS5wp9XffdmBw/yeJyXyzaCNvqDCbJlkHDpqDAINcXYxMa9pFA== X-Received: by 2002:a05:6870:96a4:b0:229:f2a0:5f4d with SMTP id o36-20020a05687096a400b00229f2a05f4dmr378247oaq.1.1711659167493; Thu, 28 Mar 2024 13:52:47 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id g16-20020a9d6c50000000b006e7011fea78sm293335otq.41.2024.03.28.13.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 13:52:46 -0700 (PDT) From: David Lechner To: Mark Brown Cc: David Lechner , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] spi: au1550: t->{tx,rx}_dma checks Date: Thu, 28 Mar 2024 15:51:45 -0500 Message-ID: <20240328-spi-more-tx-rx-buf-cleanup-v1-1-9ec1ceedf08c@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240328-spi-more-tx-rx-buf-cleanup-v1-0-9ec1ceedf08c@baylibre.com> References: <20240328-spi-more-tx-rx-buf-cleanup-v1-0-9ec1ceedf08c@baylibre.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 There are no more peripheral drivers that set t->tx_dma or t->rx_dma so these will always == 0. Therefore, we can remove these checks since they are always true. Signed-off-by: David Lechner --- drivers/spi/spi-au1550.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c index 825d2f1cdff8..16f200bb3d17 100644 --- a/drivers/spi/spi-au1550.c +++ b/drivers/spi/spi-au1550.c @@ -314,11 +314,8 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) hw->tx = t->tx_buf; hw->rx = t->rx_buf; - dma_tx_addr = t->tx_dma; - dma_rx_addr = t->rx_dma; /* - * check if buffers are already dma mapped, map them otherwise: * - first map the TX buffer, so cache data gets written to memory * - then map the RX buffer, so that cache entries (with * soon-to-be-stale data) get removed @@ -326,23 +323,17 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) * use temp rx buffer (preallocated or realloc to fit) for rx dma */ if (t->tx_buf) { - if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ - dma_tx_addr = dma_map_single(hw->dev, - (void *)t->tx_buf, - t->len, DMA_TO_DEVICE); - if (dma_mapping_error(hw->dev, dma_tx_addr)) - dev_err(hw->dev, "tx dma map error\n"); - } + dma_tx_addr = dma_map_single(hw->dev, (void *)t->tx_buf, + t->len, DMA_TO_DEVICE); + if (dma_mapping_error(hw->dev, dma_tx_addr)) + dev_err(hw->dev, "tx dma map error\n"); } if (t->rx_buf) { - if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ - dma_rx_addr = dma_map_single(hw->dev, - (void *)t->rx_buf, - t->len, DMA_FROM_DEVICE); - if (dma_mapping_error(hw->dev, dma_rx_addr)) - dev_err(hw->dev, "rx dma map error\n"); - } + dma_rx_addr = dma_map_single(hw->dev, (void *)t->rx_buf, + t->len, DMA_FROM_DEVICE); + if (dma_mapping_error(hw->dev, dma_rx_addr)) + dev_err(hw->dev, "rx dma map error\n"); } else { if (t->len > hw->dma_rx_tmpbuf_size) { int ret; @@ -398,10 +389,10 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) DMA_FROM_DEVICE); } /* unmap buffers if mapped above */ - if (t->rx_buf && t->rx_dma == 0) + if (t->rx_buf) dma_unmap_single(hw->dev, dma_rx_addr, t->len, DMA_FROM_DEVICE); - if (t->tx_buf && t->tx_dma == 0) + if (t->tx_buf) dma_unmap_single(hw->dev, dma_tx_addr, t->len, DMA_TO_DEVICE); From patchwork Thu Mar 28 20:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 784730 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.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 4254B12F5A4 for ; Thu, 28 Mar 2024 20:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659170; cv=none; b=ePbNYjOFh40iiNj73kGQyaLNojPFq9GlwkHYHfzxXxofIpiK5gDbjEgRx3Md20Vntr57Znshi/OOf5LsalwmOOvkQ0AHw00Pgz4RgJCrorFZ4us/Que9PoQE0z/VsPc+5GSaVzQtPOy3OZM+PrK8J3O+xSUflpD7pI4edThL1tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711659170; c=relaxed/simple; bh=/oZlhHR3Fe5C5+nFubO4bjXi7uClg732tgrtOLEBKSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TlT6an8xjv2z+qb6xloZdW6F0rhdrgigsiVJGkJhXr7lXKV2Wu+JOGE/vZ14yd5qNEb+WEJ7g8f9VMkEPxM8R2V94STO8P/9EUA39HvxjBrLjzLncGs1tTSOBjfPYC2g7W2kxT39oe9FWVjhWI1+Rs03tleTKC2f6eHEzqgssqA= 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=qCzEOCiM; arc=none smtp.client-ip=209.85.210.44 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="qCzEOCiM" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e6b582d266so756675a34.3 for ; Thu, 28 Mar 2024 13:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1711659168; x=1712263968; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DBEq55br988pgVGk8t6++pKUK9LVnHaNQ5jojqkYPqA=; b=qCzEOCiMFCPRDDnLJ0xH3XL3pAoBdCT8YRwycZCPi0XlcopTyJMR9lXBD/NRE2/DNp pzonrdwhbopYayQsYL+Ma9E0xEfbC1eGUmr/d7LmmX7GTiHKbqcaXmwNWgEU+LeKP3oc b8c4paFZJ7zPt2h3AQbFYE7yr99wDpUcRl3m1FPSWZgm63ZafjY+WX7JOKCHPka5L2rX I4yUEfuHJst+h7rEQLtHM67VYvXNlSz3Txp9NNGkBgz4n8/rVs8stSzKkOS1Mo8lOM+3 fItX5n+iii5L1DyUepxeYLNH3vw+4J/YRyg0RLb2V+g6oQMjh6Kr6LvUXuQoF7uv6LQp 6ocw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711659168; x=1712263968; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DBEq55br988pgVGk8t6++pKUK9LVnHaNQ5jojqkYPqA=; b=SzD4FiB+18/zOldwBcHJ9fvN6ZSCkW9pkEOrHiYeJBtdQwzP5737LlIFqGzwZYkLBK gWsMuwiPgF1aKWP9Qd/xXOINn2xdCiayDL4crlNFfHc6jUb6aeIFDxl4L7Y9U5Qc7tkL oriXIjn8luX5aCuiGnA6YBCjRmhAg5Yjz3DilLaG9t0w4ZIIGFh4XgQVrOHfSg9zDVcM Y1V5xljh79q8XZLDKT6bTF2L6rOVU6qynuSMKKB/0RvJ5fQqxPvFv5P+lhuIP0nXrkrZ e3tiwmj/PFiEC2Xg6PGbvnI5OFY7s9VJ/gmsgBLCdyTz2jOD9YPgKoqA+oSA7O3Zq8sv TtvA== X-Forwarded-Encrypted: i=1; AJvYcCWOVf1qM79uijlVQ7fuNGK+O/mgdHGf7TAI/t0qurY/zzgjc3CHDhO3LLU09jbrNPIaPu4RtMrd5OfP9ffV6fI1ZNIPIwiDzHFR X-Gm-Message-State: AOJu0YxhL+P0DJl1sbpJjuNfnmO8q7/rNj8eh+jWJY8B6t7S3t2GXFxf ugsixPyekKm4cD5KjlOwZfEVuTEhvf2z75waJF1SjlUCMc40uAagtf5E7Ltm7+k= X-Google-Smtp-Source: AGHT+IEmEL1r8wlWIJURkQSMYpFviTs6Wn7DnMl5Mnb79+gecW5uwLdfX23dBt2/jeBx2wmULPT0ww== X-Received: by 2002:a9d:7dd0:0:b0:6e6:7b61:1dd6 with SMTP id k16-20020a9d7dd0000000b006e67b611dd6mr381215otn.1.1711659168438; Thu, 28 Mar 2024 13:52:48 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id g16-20020a9d6c50000000b006e7011fea78sm293335otq.41.2024.03.28.13.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 13:52:47 -0700 (PDT) From: David Lechner To: Mark Brown Cc: David Lechner , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] spi: fsl: remove is_dma_mapped checks Date: Thu, 28 Mar 2024 15:51:46 -0500 Message-ID: <20240328-spi-more-tx-rx-buf-cleanup-v1-2-9ec1ceedf08c@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240328-spi-more-tx-rx-buf-cleanup-v1-0-9ec1ceedf08c@baylibre.com> References: <20240328-spi-more-tx-rx-buf-cleanup-v1-0-9ec1ceedf08c@baylibre.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 There are no more peripheral drivers that set t->tx_dma or t->rx_dma. Therefore, is_dma_mapped is always false and can be removed. Signed-off-by: David Lechner --- drivers/spi/spi-fsl-cpm.c | 14 ++++---------- drivers/spi/spi-fsl-cpm.h | 5 ++--- drivers/spi/spi-fsl-spi.c | 7 +++---- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c index 47c7a5c6257f..e335132080bf 100644 --- a/drivers/spi/spi-fsl-cpm.c +++ b/drivers/spi/spi-fsl-cpm.c @@ -98,19 +98,13 @@ static void fsl_spi_cpm_bufs_start(struct mpc8xxx_spi *mspi) mpc8xxx_spi_write_reg(®_base->command, SPCOM_STR); } -int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, - struct spi_transfer *t, bool is_dma_mapped) +int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t) { struct device *dev = mspi->dev; struct fsl_spi_reg __iomem *reg_base = mspi->reg_base; - if (is_dma_mapped) { - mspi->map_tx_dma = 0; - mspi->map_rx_dma = 0; - } else { - mspi->map_tx_dma = 1; - mspi->map_rx_dma = 1; - } + mspi->map_tx_dma = 1; + mspi->map_rx_dma = 1; if (!t->tx_buf) { mspi->tx_dma = mspi->dma_dummy_tx; @@ -147,7 +141,7 @@ int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, return -ENOMEM; } } else if (t->tx_buf) { - mspi->tx_dma = t->tx_dma; + mspi->tx_dma = 0; } if (mspi->map_rx_dma) { diff --git a/drivers/spi/spi-fsl-cpm.h b/drivers/spi/spi-fsl-cpm.h index 160f999708b6..e012abba055f 100644 --- a/drivers/spi/spi-fsl-cpm.h +++ b/drivers/spi/spi-fsl-cpm.h @@ -20,7 +20,7 @@ #ifdef CONFIG_FSL_SOC extern void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi); extern int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, - struct spi_transfer *t, bool is_dma_mapped); + struct spi_transfer *t); extern void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi); extern void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events); extern int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi); @@ -28,8 +28,7 @@ extern void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi); #else static inline void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi) { } static inline int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, - struct spi_transfer *t, - bool is_dma_mapped) { return 0; } + struct spi_transfer *t) { return 0; } static inline void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi) { } static inline void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events) { } static inline int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) { return 0; } diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 97faf984801f..997e07c0a24a 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -249,8 +249,7 @@ static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi, return 0; } -static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, - bool is_dma_mapped) +static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t) { struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(spi->controller); struct fsl_spi_reg __iomem *reg_base; @@ -274,7 +273,7 @@ static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, reinit_completion(&mpc8xxx_spi->done); if (mpc8xxx_spi->flags & SPI_CPM_MODE) - ret = fsl_spi_cpm_bufs(mpc8xxx_spi, t, is_dma_mapped); + ret = fsl_spi_cpm_bufs(mpc8xxx_spi, t); else ret = fsl_spi_cpu_bufs(mpc8xxx_spi, t, len); if (ret) @@ -353,7 +352,7 @@ static int fsl_spi_transfer_one(struct spi_controller *controller, if (status < 0) return status; if (t->len) - status = fsl_spi_bufs(spi, t, !!t->tx_dma || !!t->rx_dma); + status = fsl_spi_bufs(spi, t); if (status > 0) return -EMSGSIZE;