Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4004969ybz; Tue, 28 Apr 2020 04:12:40 -0700 (PDT) X-Google-Smtp-Source: APiQypJjnyMfAto85UHzWKrFeONIntrP3izvsdzYHOis8TmMAqa1SbrAEu7Vo0rJZ4pQgY9E0KSk X-Received: by 2002:a17:906:2d4a:: with SMTP id e10mr24774484eji.222.1588072360667; Tue, 28 Apr 2020 04:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588072360; cv=none; d=google.com; s=arc-20160816; b=wxtRBAgvUlYkVbQRnm6L1CzRVbkhuIwWTG+T1VeER+gxo+Nc9kU7B5qz6it1GDGfV6 dFAEgZeyIqUrdQ3kEp7MyNBFPPLB8XkI6THltdkfec6osZYTLoleuiEwyDCQSkO/Xwld hPBuQbYV3v8bJTwVNmPzdrSiWd09OhFFfmD0b2LD8bCVzANBlsnM3CjpiON+hOFHFWa8 VN8LS1St28AmmNghvY2fU4q7ssGeeFg1jVY5jqjwPlKGB9zR2osHmlnmEWXH4anHjOLc mcXftfxPtNpNRjr/shOF9SAWpkordjGrFtBdo4S2fTxy1EOQpoGEb5FHokPjcVtBYknU QlwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:references:cc:to:subject:from:dkim-signature; bh=VPJ7zElmu1fDMecgiDY6nmp40JbRN8763I+n2XOKcx8=; b=b3j1nTyvlDdV4/uOMZQOeZ1uAvO1SICw3bC8OjWaN0hypdoZr3wbiKnNgVp1mnXipJ +YUrorj+KhOlubiUGowd1T5imuwIJrunpgW0rwu19hyk5JlKwcAL9CtEqqP4qEPsVy6j c4MHfpSG8a4t+kffnVKHUh27tQ9lJzyGkQ7GCiU7cE6/gkLMU9h4xYFi37CmSOM+E4DP 9TL+PNeVJCB8dOdjQmjBrxspleRPGlITEhVxfpwTDrIw/OZHjnIas5Cy8E8OxYKNP1Vh lJZEvTCFK11Hxw6i5G/7IOKhcGTokhCglvQHlPTP7fNSgQ2e0mdIEp+oQ43/0REAUC4w G95A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="eQvn/AC2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si1524074ejb.184.2020.04.28.04.12.16; Tue, 28 Apr 2020 04:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="eQvn/AC2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgD1LKZ (ORCPT + 99 others); Tue, 28 Apr 2020 07:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbgD1LKY (ORCPT ); Tue, 28 Apr 2020 07:10:24 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7840C03C1A9; Tue, 28 Apr 2020 04:10:23 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id s10so24178326wrr.0; Tue, 28 Apr 2020 04:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VPJ7zElmu1fDMecgiDY6nmp40JbRN8763I+n2XOKcx8=; b=eQvn/AC2lcMkF4QSUTuEI+jLFcYi+FGIV97UXglyGL6UHbzUxmYeMN54Jl+rEes0cg FYGNpQDypfR3JBWSplsorENXeCSdG8gxJ/fXceOutQYC1VX3piOsQykiu2gDaoWv6WTK /rhb2vOTgZwD0iFx46SnsH942KRApUTQzN6/bn3ZQYPMA2d+avEipmJb6kpG0kl0u7Kw 0l6GWCYHalD93vqYUEqbg65g9nPCN1QdfcOoQG203Mcp7wG76LNgoaG+e7EP5N4F70Sc utOzm2V+izsh4Z8qpBs9MYKs3N35pHASTI8dPponvAVY9cg+Q4EuQGDXU/BqDsYgbAQ5 EJDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=VPJ7zElmu1fDMecgiDY6nmp40JbRN8763I+n2XOKcx8=; b=D8cmT7WA8V245j6fMlEX6a/zSJY6ITd9o3HoM11r9zPzfwqO5lxm+K4pw9l4gZQJsU Mh5pmZvJM40EBn76B44XdJK7Ns+Ij1AmANNtQuJyBnn8YLgHadZzQa7Vv9Wyg9Vq5WgA SHMuoW+9yNW8H18umZzdBR5PslMa9cahbOF1LOpYViC7IzhhuMfyNn96ZzPIyy2/3if+ /eVjz3TaZi9zDMfjbxGfTcr8IVASGBxLNBmfq6Lu+k6K107sO7mJiVCZLUkuAoKMBu+B ntqgBADPd1ez6qEIXSQuQq5N4aPCcVx47kIORDDJUYEcLEXMxyqnGTnDYkU7R4relKRT kOmA== X-Gm-Message-State: AGi0PubFtkwUhMh4OciFcXgxLgdAsfFIe7FLr/rrlqBU01ETCwFEFwEJ n2lsfQL49fDSZHJRFqLYJj0= X-Received: by 2002:adf:f450:: with SMTP id f16mr32536199wrp.346.1588072222245; Tue, 28 Apr 2020 04:10:22 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io ([2001:16b8:55e5:7101:cff:b6ab:5886:a72a]) by smtp.gmail.com with ESMTPSA id l19sm2887431wmj.14.2020.04.28.04.10.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Apr 2020 04:10:21 -0700 (PDT) From: Daniel Schwierzeck Subject: Re: [PATCH 1/4] spi: lantiq: Synchronize interrupt handlers and transfers To: Dilip Kota , broonie@kernel.org, robh@kernel.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, hauke@hauke-m.de, andriy.shevchenko@intel.com, cheol.yong.kim@intel.com, chuanhua.lei@linux.intel.com, qi-ming.wu@intel.com References: <3bf88d24b9cad9f3df1da8ed65bf55c05693b0f2.1587702428.git.eswara.kota@linux.intel.com> Autocrypt: addr=daniel.schwierzeck@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFiCxHwBEACqCqGeCoJ4eA3iVPRzFal3opTtAIqztUJvSqXzCFBaFOJeD5sLkxfhj9BQ +UTHfOmyt+1zBNmOWeaWYpHtpFhoTxu9slIxsbr7GbAy0aGqOCcg4W3TlUgfTMyWEo6XaCR1 /4nQ5kEsMubjI3mdExnLgUE/JIJ71Nj5lbwQN7MLKfXwq8DT9EKCeW/X5hxbb/MUzHzI6UQN 0egYB0dGiqmSwTCauaCnJetGqYSConkTtOMewpMwIRxhaEiqL2qdKPX5EwMLAe0ls0Vze5EQ GNI855ybRnF33wuszIYgOYAb0/yakTkjfVcPLRTtPmzBkLtNyREEdij1sFD73aRuN6dLZrmi 3e5ieIO4/kHoT6LF/l+WzTS05c3M7rSwzFuBf3SX8PSe+ubEbZSfJzoOoo/L8wtPfd8liOJI XpHI/iYSIt/sJZtEhNPErUUajpIuHznIeAHbJAUdDJFwuNzlTisgOwfvg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mn4dKmZwSUuoxdnnN IrJ0e56kObjJY37n1swCfHQVH1OwatR0lOHE4D8V3t0YoKpJlrApT3Dkn0cWAt/sbZ3jFU4F E1NQZC4XxZ/f5/6SnWN5v+6/+HvaVJDHpbS5xR6/27CvWUup4qefAkMgfNzTjm2J2vYT4Lbz sdz9LeGTgI9maYvq/nvFNNtqC5VfQO6dbpzAO+Lytiah569dxtYDqGPm0V3E2U2CJxbRDo99 QlxLj6Y19OcOezK6hJ/qyHe2VvdGkGPLDJZccvNmb1L1q3s5B4MZU6/G9U8mM7kUwjBjD6pP tZor7Hr6d0zVB5JnGvvN1XXZnEaCP6ochfpLIbR2TygzOo1aWJgI5x97BjnQvJOh2sc/wlQa wD8t7NvqilPcpPnfaQzlMtO0v1wkuwubIxEG9PUZdarQ6D00gUfRarIUXMcBQryGrMJ3rxqf XdaQwC7Es8AKVlLSetZFk1QLOooVLdbk4s602fHBsjaOo1TJh2FD2vXyZ4mtJ/rlqLwsl38A ymBWdr+OK+rfiw8= Message-ID: <310ca761-e7ae-1192-99fd-a1960697806b@gmail.com> Date: Tue, 28 Apr 2020 13:10:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <3bf88d24b9cad9f3df1da8ed65bf55c05693b0f2.1587702428.git.eswara.kota@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 24.04.20 um 12:42 schrieb Dilip Kota: > Synchronize tx, rx and error interrupts by registering to the > same interrupt handler. Interrupt handler will recognize and process > the appropriate interrupt on the basis of interrupt status register. > Also, establish synchronization between the interrupt handler and > transfer operation by taking the locks and registering the interrupt > handler as thread IRQ which avoids the bottom half. actually there is no real bottom half. Reading or writing the FIFOs is fast and is therefore be done in hard IRQ context. But as the comment for lantiq_ssc_bussy_work() state, the driver needs some busy-waiting after the last interrupt. I don't think it's worth to replace this with threaded interrupts which add more runtime overhead and likely decrease the maximum transfer speed. > Fixes the wrongly populated interrupt register offsets too. > > Fixes: 17f84b793c01 ("spi: lantiq-ssc: add support for Lantiq SSC SPI controller") > Fixes: ad2fca0721d1 ("spi: lantiq-ssc: add LTQ_ prefix to defines") > Signed-off-by: Dilip Kota > --- > drivers/spi/spi-lantiq-ssc.c | 89 ++++++++++++++++++++++---------------------- > 1 file changed, 45 insertions(+), 44 deletions(-) > > diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c > index 1fd7ee53d451..b67f5925bcb0 100644 > --- a/drivers/spi/spi-lantiq-ssc.c > +++ b/drivers/spi/spi-lantiq-ssc.c > @@ -6,6 +6,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -13,7 +14,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -50,8 +50,8 @@ > #define LTQ_SPI_RXCNT 0x84 > #define LTQ_SPI_DMACON 0xec > #define LTQ_SPI_IRNEN 0xf4 > -#define LTQ_SPI_IRNICR 0xf8 > -#define LTQ_SPI_IRNCR 0xfc > +#define LTQ_SPI_IRNCR 0xf8 > +#define LTQ_SPI_IRNICR 0xfc the values are matching the datasheets for Danube and VRX200 family. AFAICS the registers have been swapped for some newer SoCs like GRX330 or GRX550. It didn't matter until now because those registers were unused by the driver. So if you want to use those registers, you have to deal somehow with the register offset swap in struct lantiq_ssc_hwcfg. > > #define LTQ_SPI_CLC_SMC_S 16 /* Clock divider for sleep mode */ > #define LTQ_SPI_CLC_SMC_M (0xFF << LTQ_SPI_CLC_SMC_S) > @@ -171,9 +171,7 @@ struct lantiq_ssc_spi { > struct clk *fpi_clk; > const struct lantiq_ssc_hwcfg *hwcfg; > > - spinlock_t lock; > - struct workqueue_struct *wq; > - struct work_struct work; > + struct mutex lock; > > const u8 *tx; > u8 *rx; > @@ -186,6 +184,8 @@ struct lantiq_ssc_spi { > unsigned int base_cs; > }; > > +static void lantiq_ssc_busy_wait(struct lantiq_ssc_spi *spi); > + > static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg) > { > return __raw_readl(spi->regbase + reg); > @@ -464,8 +464,6 @@ static int lantiq_ssc_unprepare_message(struct spi_master *master, > { > struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); > > - flush_workqueue(spi->wq); > - > /* Disable transmitter and receiver while idle */ > lantiq_ssc_maskl(spi, 0, LTQ_SPI_CON_TXOFF | LTQ_SPI_CON_RXOFF, > LTQ_SPI_CON); > @@ -610,10 +608,8 @@ static void rx_request(struct lantiq_ssc_spi *spi) > lantiq_ssc_writel(spi, rxreq, LTQ_SPI_RXREQ); > } > > -static irqreturn_t lantiq_ssc_xmit_interrupt(int irq, void *data) > +static irqreturn_t lantiq_ssc_xmit_interrupt(struct lantiq_ssc_spi *spi) > { > - struct lantiq_ssc_spi *spi = data; > - > if (spi->tx) { > if (spi->rx && spi->rx_todo) > rx_fifo_read_full_duplex(spi); > @@ -638,19 +634,15 @@ static irqreturn_t lantiq_ssc_xmit_interrupt(int irq, void *data) > return IRQ_HANDLED; > > completed: > - queue_work(spi->wq, &spi->work); > + lantiq_ssc_busy_wait(spi); > > return IRQ_HANDLED; > } > > -static irqreturn_t lantiq_ssc_err_interrupt(int irq, void *data) > +static irqreturn_t lantiq_ssc_err_interrupt(struct lantiq_ssc_spi *spi) > { > - struct lantiq_ssc_spi *spi = data; > u32 stat = lantiq_ssc_readl(spi, LTQ_SPI_STAT); > > - if (!(stat & LTQ_SPI_STAT_ERRORS)) > - return IRQ_NONE; > - > if (stat & LTQ_SPI_STAT_RUE) > dev_err(spi->dev, "receive underflow error\n"); > if (stat & LTQ_SPI_STAT_TUE) > @@ -670,17 +662,39 @@ static irqreturn_t lantiq_ssc_err_interrupt(int irq, void *data) > /* set bad status so it can be retried */ > if (spi->master->cur_msg) > spi->master->cur_msg->status = -EIO; > - queue_work(spi->wq, &spi->work); > + > + spi_finalize_current_transfer(spi->master); > > return IRQ_HANDLED; > } > > +static irqreturn_t lantiq_ssc_isr(int irq, void *data) > +{ > + struct lantiq_ssc_spi *spi = data; > + const struct lantiq_ssc_hwcfg *hwcfg = spi->hwcfg; > + irqreturn_t ret = IRQ_NONE; > + u32 val; > + > + mutex_lock(&spi->lock); > + val = lantiq_ssc_readl(spi, LTQ_SPI_IRNCR); > + lantiq_ssc_maskl(spi, val, 0, LTQ_SPI_IRNEN); > + > + if (val & LTQ_SPI_IRNEN_E) > + ret = lantiq_ssc_err_interrupt(spi); > + > + if ((val & hwcfg->irnen_t) || (val & hwcfg->irnen_r)) > + ret = lantiq_ssc_xmit_interrupt(spi); > + > + lantiq_ssc_maskl(spi, 0, val, LTQ_SPI_IRNEN); > + mutex_unlock(&spi->lock); > + > + return ret; > +} > + > static int transfer_start(struct lantiq_ssc_spi *spi, struct spi_device *spidev, > struct spi_transfer *t) > { > - unsigned long flags; > - > - spin_lock_irqsave(&spi->lock, flags); > + mutex_lock(&spi->lock); > > spi->tx = t->tx_buf; > spi->rx = t->rx_buf; > @@ -700,7 +714,7 @@ static int transfer_start(struct lantiq_ssc_spi *spi, struct spi_device *spidev, > rx_request(spi); > } > > - spin_unlock_irqrestore(&spi->lock, flags); > + mutex_unlock(&spi->lock); > > return t->len; > } > @@ -712,14 +726,11 @@ static int transfer_start(struct lantiq_ssc_spi *spi, struct spi_device *spidev, > * write the last word to the wire, not when it is finished. Do busy > * waiting till it finishes. > */ > -static void lantiq_ssc_bussy_work(struct work_struct *work) > +static void lantiq_ssc_busy_wait(struct lantiq_ssc_spi *spi) > { > - struct lantiq_ssc_spi *spi; > unsigned long long timeout = 8LL * 1000LL; > unsigned long end; > > - spi = container_of(work, typeof(*spi), work); > - > do_div(timeout, spi->speed_hz); > timeout += timeout + 100; /* some tolerance */ > > @@ -838,18 +849,18 @@ static int lantiq_ssc_probe(struct platform_device *pdev) > goto err_master_put; > } > > - err = devm_request_irq(dev, rx_irq, lantiq_ssc_xmit_interrupt, > - 0, LTQ_SPI_RX_IRQ_NAME, spi); > + err = devm_request_threaded_irq(dev, rx_irq, NULL, lantiq_ssc_isr, > + IRQF_ONESHOT, LTQ_SPI_RX_IRQ_NAME, spi); > if (err) > goto err_master_put; > > - err = devm_request_irq(dev, tx_irq, lantiq_ssc_xmit_interrupt, > - 0, LTQ_SPI_TX_IRQ_NAME, spi); > + err = devm_request_threaded_irq(dev, tx_irq, NULL, lantiq_ssc_isr, > + IRQF_ONESHOT, LTQ_SPI_TX_IRQ_NAME, spi); > if (err) > goto err_master_put; > > - err = devm_request_irq(dev, err_irq, lantiq_ssc_err_interrupt, > - 0, LTQ_SPI_ERR_IRQ_NAME, spi); > + err = devm_request_threaded_irq(dev, err_irq, NULL, lantiq_ssc_isr, > + IRQF_ONESHOT, LTQ_SPI_ERR_IRQ_NAME, spi); > if (err) > goto err_master_put; > > @@ -882,7 +893,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev) > spi->base_cs = 1; > of_property_read_u32(pdev->dev.of_node, "base-cs", &spi->base_cs); > > - spin_lock_init(&spi->lock); > + mutex_init(&spi->lock); > spi->bits_per_word = 8; > spi->speed_hz = 0; > > @@ -899,13 +910,6 @@ static int lantiq_ssc_probe(struct platform_device *pdev) > master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) | > SPI_BPW_MASK(16) | SPI_BPW_MASK(32); > > - spi->wq = alloc_ordered_workqueue(dev_name(dev), 0); > - if (!spi->wq) { > - err = -ENOMEM; > - goto err_clk_put; > - } > - INIT_WORK(&spi->work, lantiq_ssc_bussy_work); > - > id = lantiq_ssc_readl(spi, LTQ_SPI_ID); > spi->tx_fifo_size = (id & LTQ_SPI_ID_TXFS_M) >> LTQ_SPI_ID_TXFS_S; > spi->rx_fifo_size = (id & LTQ_SPI_ID_RXFS_M) >> LTQ_SPI_ID_RXFS_S; > @@ -921,13 +925,11 @@ static int lantiq_ssc_probe(struct platform_device *pdev) > err = devm_spi_register_master(dev, master); > if (err) { > dev_err(dev, "failed to register spi_master\n"); > - goto err_wq_destroy; > + goto err_clk_put; > } > > return 0; > > -err_wq_destroy: > - destroy_workqueue(spi->wq); > err_clk_put: > clk_put(spi->fpi_clk); > err_clk_disable: > @@ -948,7 +950,6 @@ static int lantiq_ssc_remove(struct platform_device *pdev) > tx_fifo_flush(spi); > hw_enter_config_mode(spi); > > - destroy_workqueue(spi->wq); > clk_disable_unprepare(spi->spi_clk); > clk_put(spi->fpi_clk); > > -- - Daniel