Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4089322ybi; Tue, 18 Jun 2019 11:35:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUVzuxud2O/u5HU3JerWqkwDQbMdR38UYJ3aPAJYVUHIr3uOCHNakUPtHKOG8cRJJPk4Wh X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr6724650pjb.2.1560882908269; Tue, 18 Jun 2019 11:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560882908; cv=none; d=google.com; s=arc-20160816; b=OcTv0yxJW2W0t5BmxHvZSxMMAR3hvYo2bOkSDKaeEm9Oe9U8ecx87zuLqA6HwrKz/y z99WbD7CrNK3MbKLIz6GRrLp9rcdngrwZULtS9rI7+sJeuI9vwdguKsYLqflEd8nh2bT WQRJJ2iCy1eUv5dkqPL6QPeVRERI43XVMJBfOV7mhK4qWABnT85sW6Y2IolxYgz5unOJ QcDNuoaITMYqyl4SeV56vZKhb/nqATux7s+D/95D1GOMnrHgr2DvuVp3MbfEhMFGnevL IQgde0w9DQnxNstAO/5hVQQEgXkHv9r6yG4nja3zHVLByXXNCId50aNoEDHSFZdbVacU l1bA== 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:from:references:cc:to:subject:dkim-signature; bh=LUTcC8R+5dFr9R0YY+BhHcC1Z9+J2f6PapOJUQzgkSs=; b=MFtzPsIkZ1m/SmWpzvIuGr/gYub18BnDuQOQcMcJ27I7rqksyIbB11OsNdofLuSxjC slb5E7dBOq8Ro28bHsXI0UP8JGtWep8l5356zz4jXIABL96xwOj0EmJHeurg5PZQ1Z4i it0oJAycTZ6RItm1yDbF59tqD8PkSe1iLy6oZmZ729+YvH+7C12krVpnT8fWlOXUxWt8 41ZUoSLQgU+zBAk6iEgs0gp6wTACHnVmyvQ+a2iTV4t1BYK0BFPvGM7R700gx1mNHpP6 Wq5LPbjXUeyT9WBzzgCun7APxmoEfIfg+mlyOEJmT4yqAAZCq3sN2F77gJ7OkBj347Yu uFNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DAlZdM4C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id w65si833423pgw.6.2019.06.18.11.34.52; Tue, 18 Jun 2019 11:35:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DAlZdM4C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730453AbfFRSeM (ORCPT + 99 others); Tue, 18 Jun 2019 14:34:12 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38424 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729642AbfFRSeM (ORCPT ); Tue, 18 Jun 2019 14:34:12 -0400 Received: by mail-lj1-f195.google.com with SMTP id r9so568603ljg.5; Tue, 18 Jun 2019 11:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=LUTcC8R+5dFr9R0YY+BhHcC1Z9+J2f6PapOJUQzgkSs=; b=DAlZdM4CzRLCjdt8CtdqrU2BUOC0C2LJP2ZSloK1/ylQ8IApeYFnaQuSmIcYq2W3ny M0lzE7674VSrYkq1Qyff0punD6tR9xtE7+F+Z8STbBxP+M+/izpIxQOa5MtYBK19okQq Jpx0XcywJlMf8ERGPCjJV86UKlfUvhXegjIpYgRgZyUjHIMCKQ+9WpbdxPt1EyLDgAB/ 61/r9ftEtynbLQpOpshnYdeHnFltFZQZrKmfaibN2o73F5OXj88m9RN9P/zMsdVusbEO IHy6Uyb3nwNXyC050fVkvWfwjm66VfCy8vCYQD1llUCrHjTf+yibrlzd/MUlf+9GQJLY 7Apw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LUTcC8R+5dFr9R0YY+BhHcC1Z9+J2f6PapOJUQzgkSs=; b=hMM3ragAd8rxhwDFZ0YA6IhqeMq8EGSSrFOr4dhOpF0nXtQC0eYx7/8mcC0d5CL13n JhGOey924T4Jh8sngwxes998BnUIHw5ExuI++JusFA4MK+YQZRojqltb8cXLiGtuOBD7 3qNW5v+YmtmEqbiSKBcpM/jh7Sc+7RrfYKltibq9O4NsBGOuo9IiwHlEyWcZ+IpxTxZt Hhlpuuece8DReD+UdWT5m+E6Xj9TI8VUQw2g99xV5vTS4msOUt76sNhY0qHnboO7ZV+L JTP2WkTXUAbW/JrUFJdbbhcMV1f7J5fOyLTuw0stvZPn2EgC7htSbs8exyJTOWKoEcLc sZKA== X-Gm-Message-State: APjAAAVYN2Fk5QGA/7SpOfb0PF5SKBHQ2Z3gNa4+QtNNijUsJD6Gxbj3 g8k1B9dDk6JJPGb98OyfRso= X-Received: by 2002:a2e:89ca:: with SMTP id c10mr4868002ljk.106.1560882850067; Tue, 18 Jun 2019 11:34:10 -0700 (PDT) Received: from [192.168.2.145] (ppp91-79-162-197.pppoe.mtu-net.ru. [91.79.162.197]) by smtp.googlemail.com with ESMTPSA id l15sm3031426ljh.0.2019.06.18.11.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jun 2019 11:34:09 -0700 (PDT) Subject: Re: [PATCH V2] i2c: tegra: disable irq in tegra_i2c_xfer_msg To: Jon Hunter , Bitan Biswas , Laxman Dewangan , Thierry Reding , linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Rosin , Wolfram Sang Cc: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik References: <1560847368-16069-1-git-send-email-bbiswas@nvidia.com> <61c2dbcd-85f2-2094-7596-78ac01f55421@nvidia.com> From: Dmitry Osipenko Message-ID: <28cd06ca-3bd4-87e1-6d52-504cd00e1adb@gmail.com> Date: Tue, 18 Jun 2019 21:34:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <61c2dbcd-85f2-2094-7596-78ac01f55421@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 18.06.2019 12:13, Jon Hunter пишет: > > On 18/06/2019 09:42, Bitan Biswas wrote: >> tegra_i2c_xfer_msg initiates the I2C transfer in DMA >> or PIO mode. It involves steps that need FIFO register >> access, DMA API calls like dma_sync_single_for_device, etc. >> Tegra I2C ISR has calls to tegra_i2c_empty_rx_fifo in PIO mode >> and in DMA/PIO mode writes different I2C registers including >> I2C interrupt status. ISR cannot start processing >> before the preparation step at tegra_i2c_xfer_msg is complete. >> Hence, a synchronization between ISR and tegra_i2c_xfer_msg >> is in place today using spinlock. >> >> Spinlock busy waits and can add avoidable delays. >> >> In this patch needed synchronization is achieved by disabling >> I2C interrupt during preparation step and enabling interrupt >> once preparation is over and spinlock is no longer needed. > Sorry but I still don't understand the problem you are trying to solve. > Yes spinlocks are busy waits but is this busy wait an actual problem? If > so what is the problem with this? There is no real problem here, the intent is to clean up the code more and that should be mentioned in the commit message for clarity. This was actually my suggestion that Bitan is now started to implement, which is very nice! It should be a good result in the end. > It appears that the spinlock was added to prevent error interrupts > occurring until the transfer has started. If this is for error cases, > then probably it is not often that the CPU is stuck busy waiting on the > spinlock. > > Furthermore, in addition to the spinlock we also have calls to > tegra_i2c_unmask_irq/tegra_i2c_mask_irq. Therefore, if we are going to > change this it would seem like a good idea to consolidate the > masking/unmasking of IRQs and the spinlock, if possible. > > Finally, I still see that we have a spinlock in the downstream kernels > we are shipping and so I would prefer to see such a change also be > tested in the downstream kernels we are releasing.