Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1521168ybg; Tue, 2 Jun 2020 12:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1JRKacZsqMboAPe5Uf15nZBFw90mXvRTXV23ZCMbRc8F7glbE9vMuaTIkcojVqEd5b0bY X-Received: by 2002:a50:eb01:: with SMTP id y1mr8846225edp.85.1591125292247; Tue, 02 Jun 2020 12:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591125292; cv=none; d=google.com; s=arc-20160816; b=nmchFYCBFkQbJEv1SHHXZ+K0GpAz62aM/OX+8quVCXglB5uKPumsrZrsG/NX3jlo6k waCCZswWe9QfzP3qi/HB/jpAj2ls+Q7G7M0NqL4tmmbcTItaS6CzUKiz8WCsw701jYIR TlPNd5pvkfQYEKui836K/WyjweAl9RSeIdn3LxnqlrwMdPNkxTvYOiSID+w1H0rS/jhG sbjnucjWnfeDhW3DhPb5OcpW0E3Ee9yHWn7PNND5uztJWSgNKT9tAEiRXoubJ7oxQjKL 4CJ0mBpTi4Ic+Q0y5A5r2vGOf50h6BBY/15t9JWh488dYTEoDl8OZWLng7UdZDyY89g5 LVKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=+VK2vEB1itO2UsjdNThZamFMdVuR0tSpQfwCuJ8m4Hw=; b=UgA6+r0rhyXFhQZngJiFHz98gXsadaQ24Z4B3Zf/M30ulxO45EW3abKU6A7uIGTpSu v9GRaekCZCnfwDx6ZSrjjRLW8lcU64Z+98JZCXZbk/SCwwqMqRuimxCd6dmYP/C5VOfL wGnJUrgduJLTq47mODwGY2nk17PVeWYOo/G8ouMIpvKKWOxut/hlEL7fDTq2GDRBzNDX ZsEpeMtkiy2mD8Ujh7kB7xzuDTAzynDCfEr+rV6tosMHtsRRbyF53Y+T2hiv+xcIYp+O MOdZ9tVyrKPGLPBtbihTbP95AGNZQ5RJluOecyLwCU58QEXMHW+ZpWDxuGSH5FEEqyfq 5jTQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si2070357edy.62.2020.06.02.12.14.28; Tue, 02 Jun 2020 12:14:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgFBTKj (ORCPT + 99 others); Tue, 2 Jun 2020 15:10:39 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:57056 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgFBTKj (ORCPT ); Tue, 2 Jun 2020 15:10:39 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id E897C8030835; Tue, 2 Jun 2020 19:10:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IvgS6PU79JwH; Tue, 2 Jun 2020 22:10:27 +0300 (MSK) Date: Tue, 2 Jun 2020 22:10:25 +0300 From: Serge Semin To: Lars Povlsen CC: Serge Semin , Mark Brown , SoC Team , , Alexandre Belloni , , , Microchip Linux Driver Support , Subject: Re: [PATCH 01/10] spi: dw: Add support for polled operation via no IRQ specified in DT Message-ID: <20200602191025.ywo77nslrgswh6sw@mobilestation> References: <20200513140031.25633-1-lars.povlsen@microchip.com> <20200513140031.25633-2-lars.povlsen@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200513140031.25633-2-lars.povlsen@microchip.com> X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 04:00:22PM +0200, Lars Povlsen wrote: > With this change a SPI controller can be added without having a IRQ > associated, and causing all transfers to be polled. For SPI controllers > without DMA, this can significantly improve performance by less > interrupt handling overhead. > > Reviewed-by: Alexandre Belloni > Signed-off-by: Lars Povlsen > --- > drivers/spi/spi-dw.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c > index 31e3f866d11a7..e572eb34a3c1a 100644 > --- a/drivers/spi/spi-dw.c > +++ b/drivers/spi/spi-dw.c > @@ -19,6 +19,8 @@ > #include > #endif > > +#define VALID_IRQ(i) (i >= 0) Mark and Andy are right. It is a good candidate to be in a generic IRQ-related code as Anyd suggested: > > drivers/rtc/rtc-cmos.c:95:#define is_valid_irq(n) ((n) > 0) > > Candidate to be in include/linux/irq.h ? So if you feel like to author additional useful patch integrated into the kernel, this one is a good chance for it. > + > /* Slave spi_dev related */ > struct chip_data { > u8 tmode; /* TR/TO/RO/EEPROM */ > @@ -359,7 +361,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, > spi_enable_chip(dws, 1); > return ret; > } > - } else if (!chip->poll_mode) { > + } else if (!chip->poll_mode && VALID_IRQ(dws->irq)) { > txlevel = min_t(u16, dws->fifo_len / 2, dws->len / dws->n_bytes); > dw_writel(dws, DW_SPI_TXFLTR, txlevel); > > @@ -379,7 +381,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, > return ret; > } > > - if (chip->poll_mode) > + if (chip->poll_mode || !VALID_IRQ(dws->irq)) > return poll_transfer(dws); Please note. The chip->poll and the poll_transfer() methods've been discarded from the driver, since commit 1ceb09717e98 ("spi: dw: remove cs_control and poll_mode members from chip_data"). So you gonna have to get the poll_transfer-like method back. -Sergey > > return 1; > @@ -487,11 +489,13 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) > > spi_controller_set_devdata(master, dws); > > - ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev), > - master); > - if (ret < 0) { > - dev_err(dev, "can not get IRQ\n"); > - goto err_free_master; > + if (VALID_IRQ(dws->irq)) { > + ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, > + dev_name(dev), master); > + if (ret < 0) { > + dev_err(dev, "can not get IRQ\n"); > + goto err_free_master; > + } > } > > master->use_gpio_descriptors = true; > @@ -539,7 +543,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) > if (dws->dma_ops && dws->dma_ops->dma_exit) > dws->dma_ops->dma_exit(dws); > spi_enable_chip(dws, 0); > - free_irq(dws->irq, master); > + if (VALID_IRQ(dws->irq)) > + free_irq(dws->irq, master); > err_free_master: > spi_controller_put(master); > return ret; > -- > 2.26.2 > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel