linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V1] i2c: tegra: disable irq in tegra_i2c_xfer_msg
@ 2019-06-18  5:23 Bitan Biswas
  2019-06-18  6:32 ` Jon Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Bitan Biswas @ 2019-06-18  5:23 UTC (permalink / raw)
  To: Laxman Dewangan, Thierry Reding, Jonathan Hunter, linux-i2c,
	linux-tegra, linux-kernel, Peter Rosin, Wolfram Sang,
	Dmitry Osipenko
  Cc: Shardar Mohammed, Sowjanya Komatineni, Mantravadi Karthik, Bitan Biswas

Synchronize ISR and tegra_i2c_xfer_msg execution
by disabling interrupt. This avoids spinlock usage
for same purpose.

Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
---
 drivers/i2c/busses/i2c-tegra.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 6fb545e..ccc7fae 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -240,7 +240,6 @@ struct tegra_i2c_hw_feature {
  * @bus_clk_rate: current I2C bus clock rate
  * @clk_divisor_non_hs_mode: clock divider for non-high-speed modes
  * @is_multimaster_mode: track if I2C controller is in multi-master mode
- * @xfer_lock: lock to serialize transfer submission and processing
  * @tx_dma_chan: DMA transmit channel
  * @rx_dma_chan: DMA receive channel
  * @dma_phys: handle to DMA resources
@@ -270,8 +269,6 @@ struct tegra_i2c_dev {
 	u32 bus_clk_rate;
 	u16 clk_divisor_non_hs_mode;
 	bool is_multimaster_mode;
-	/* xfer_lock: lock to serialize transfer submission and processing */
-	spinlock_t xfer_lock;
 	struct dma_chan *tx_dma_chan;
 	struct dma_chan *rx_dma_chan;
 	dma_addr_t dma_phys;
@@ -835,7 +832,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
 
 	status = i2c_readl(i2c_dev, I2C_INT_STATUS);
 
-	spin_lock(&i2c_dev->xfer_lock);
 	if (status == 0) {
 		dev_warn(i2c_dev->dev, "irq status 0 %08x %08x %08x\n",
 			 i2c_readl(i2c_dev, I2C_PACKET_TRANSFER_STATUS),
@@ -935,7 +931,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
 
 	complete(&i2c_dev->msg_complete);
 done:
-	spin_unlock(&i2c_dev->xfer_lock);
 	return IRQ_HANDLED;
 }
 
@@ -1054,7 +1049,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 	u32 packet_header;
 	u32 int_mask;
 	unsigned long time_left;
-	unsigned long flags;
 	size_t xfer_size;
 	u32 *buffer = NULL;
 	int err = 0;
@@ -1085,7 +1079,10 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 	 */
 	xfer_time += DIV_ROUND_CLOSEST(((xfer_size * 9) + 2) * MSEC_PER_SEC,
 					i2c_dev->bus_clk_rate);
-	spin_lock_irqsave(&i2c_dev->xfer_lock, flags);
+	if (!i2c_dev->irq_disabled) {
+		disable_irq_nosync(i2c_dev->irq);
+		i2c_dev->irq_disabled = true;
+	}
 
 	int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST;
 	tegra_i2c_unmask_irq(i2c_dev, int_mask);
@@ -1180,7 +1177,10 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 		i2c_readl(i2c_dev, I2C_INT_MASK));
 
 unlock:
-	spin_unlock_irqrestore(&i2c_dev->xfer_lock, flags);
+	if (i2c_dev->irq_disabled) {
+		i2c_dev->irq_disabled = false;
+		enable_irq(i2c_dev->irq);
+	}
 
 	if (dma) {
 		if (err)
@@ -1576,7 +1576,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 				I2C_PACKET_HEADER_SIZE;
 	init_completion(&i2c_dev->msg_complete);
 	init_completion(&i2c_dev->dma_complete);
-	spin_lock_init(&i2c_dev->xfer_lock);
 
 	if (!i2c_dev->hw->has_single_clk_source) {
 		fast_clk = devm_clk_get(&pdev->dev, "fast-clk");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V1] i2c: tegra: disable irq in tegra_i2c_xfer_msg
  2019-06-18  5:23 [PATCH V1] i2c: tegra: disable irq in tegra_i2c_xfer_msg Bitan Biswas
@ 2019-06-18  6:32 ` Jon Hunter
  2019-06-18  8:53   ` Bitan Biswas
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Hunter @ 2019-06-18  6:32 UTC (permalink / raw)
  To: Bitan Biswas, Laxman Dewangan, Thierry Reding, linux-i2c,
	linux-tegra, linux-kernel, Peter Rosin, Wolfram Sang,
	Dmitry Osipenko
  Cc: Shardar Mohammed, Sowjanya Komatineni, Mantravadi Karthik


On 18/06/2019 06:23, Bitan Biswas wrote:
> Synchronize ISR and tegra_i2c_xfer_msg execution
> by disabling interrupt. This avoids spinlock usage
> for same purpose.

I think that you need to explain the motivation/benefit of this. It is
not immediately clear to me. Sorry if I have missed some previous
discussion.

Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V1] i2c: tegra: disable irq in tegra_i2c_xfer_msg
  2019-06-18  6:32 ` Jon Hunter
@ 2019-06-18  8:53   ` Bitan Biswas
  0 siblings, 0 replies; 3+ messages in thread
From: Bitan Biswas @ 2019-06-18  8:53 UTC (permalink / raw)
  To: Jon Hunter, Laxman Dewangan, Thierry Reding, linux-i2c,
	linux-tegra, linux-kernel, Peter Rosin, Wolfram Sang,
	Dmitry Osipenko
  Cc: Shardar Mohammed, Sowjanya Komatineni, Mantravadi Karthik



On 6/17/19 11:32 PM, Jon Hunter wrote:
> 
> On 18/06/2019 06:23, Bitan Biswas wrote:
>> Synchronize ISR and tegra_i2c_xfer_msg execution
>> by disabling interrupt. This avoids spinlock usage
>> for same purpose.
> 
> I think that you need to explain the motivation/benefit of this. It is
> not immediately clear to me. Sorry if I have missed some previous
> discussion.
I updated the commit description with details and benefit. Please review 
Patch V2.

-regards,
  Bitan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-18  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18  5:23 [PATCH V1] i2c: tegra: disable irq in tegra_i2c_xfer_msg Bitan Biswas
2019-06-18  6:32 ` Jon Hunter
2019-06-18  8:53   ` Bitan Biswas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).