Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp560730ybi; Fri, 31 May 2019 05:47:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBNsIDSl92hy/O7mOSCHqs/olXeNT9pDBIBi3QCsQpAX+FMcmRuArTX79ydMnM8rUchJur X-Received: by 2002:a17:90a:be0b:: with SMTP id a11mr9169913pjs.88.1559306864368; Fri, 31 May 2019 05:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559306864; cv=none; d=google.com; s=arc-20160816; b=Qzd+0rKm3Vbhd8OoodNYUeiTQo4kn/m7C9NWaMyPMHb9v7EdfKvMQwnT79m8/2IiHK qGslTYUFFAQMZnNbEnpNW3svoQ7ng+S27Ft8iZCOM14/xE0uviOCORa5MT1LARUn4/nW 3wdqCMMOWHCMesDeVoCufmfgM2+9J0EgX+LfEWh2PGBBSSSY65gbwEo1sl05y3A7gSgW z96a3JZl+XjwLwea4If2JdvnacxZaxF9YEAquVQKYaTVKaqOPxJTW142MmoMS9hF94Dk +Wsis9+/SI84DbctSTQwzI58h/ZIgnnyvnE0H7Nl12IqzRMDqzSi0cTFtprxYsDHDRaV OxBA== 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=Qv8Gl69nP262ZkQFCl6BnDomj+l1WagsjrnxTyxwFmo=; b=rw/NfzrmxCLLZa5KVNscv48Yid0XPUMz1vn58nXnCF+Ezjm2LcN+FY6U20BoyJd/FF 88NFJklKQbIpdcWfmapmIqHefq6Iv3KUwAOLOD+abkWpGOSfy3etlkDvXxbAjjlEyT47 70u2GOYW8P6lvZnnMq5VlRpLa8X/DI4p3Tb66xHIUJKlkU5eM53Jv9CZc90wwrzeOVNN mkgd6isVdVwScO4ERLn1ERb2d6rxNO4eK7JWKDdpUIkcGBAsqcuiq42kmXUHk82s4sXQ bc+7cO+XWXuHZUTQ9o+5J8byR83CV6gVrL++/cyNAW7iFM2JFe1vnFSV066JxdW55gz5 7Fgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JCIQQzF2; 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 l13si5665032pjq.69.2019.05.31.05.47.27; Fri, 31 May 2019 05:47:44 -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=JCIQQzF2; 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 S1727354AbfEaMpH (ORCPT + 99 others); Fri, 31 May 2019 08:45:07 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42018 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbfEaMpG (ORCPT ); Fri, 31 May 2019 08:45:06 -0400 Received: by mail-lj1-f193.google.com with SMTP id y15so6266085ljd.9; Fri, 31 May 2019 05:45:04 -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=Qv8Gl69nP262ZkQFCl6BnDomj+l1WagsjrnxTyxwFmo=; b=JCIQQzF2pbauh1aXmVxIwQBz8di8WN+wWx8fOFZ8KZt0IAKUhsPYQD4E9UNf+R608x 77GfrCT/ZvCAmMbYjjck7h0ugNJbFOSZiMUhTU8S+luENk+d73cjvC3BDb+02VcIshh6 ydeBCd4zAw3NLt3bpWVTjM3v84rJSqVvU5p7v+QVUu84gvWt+VctQDkr6tNRT0DL5jbS Ld1lGFDj+fEgVqHaiGtXFhqgOe7EpNZM5HtlO5SH5R/JeEitjEkxg6AcE+v/QDHCWTP+ 7b69UhEsvbNVe3vGAISuMmePN4PWLwhX1Igffux6TefoV+MZh+YrN0FmGRerBFyZxQ9W 7kZA== 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=Qv8Gl69nP262ZkQFCl6BnDomj+l1WagsjrnxTyxwFmo=; b=mACvh+DDxBgmgXsvEQ9rGErPsaSOuXiJUChkk0qRZkKuNd0RV10737uq9bHBAkEIG2 WMGLU2qsLa0rs/oXtUnlS0fVOMlx5ZP17POgoEBLVGZ7nMa+Ui3ITFepFr36U9eG/oLw ZffEKqbNdft15dkhRB1RxgJgYiphcCe/1dLCAnbfYu3wrVj4V/Kipr+PVzr1RY2sDaxR 6rwQZT6VuP14vibzeflApSQ2zXXfK/ROdk8eMwuCD8BNZmfi0Wq8cyov7TdZtxjYsszh /pSn+GcdbpHgrq2C5gURO7hnQtCgTZmLAy88sHTOzToiYgyrRYqks0ib7vRPoG/TaE9v eqSg== X-Gm-Message-State: APjAAAVpjP9mFLlBjR8aVah8IFqh627M9IHtbEl/0JYm1ntfaba5CdzZ l3FcKKDIyEmEIhYdfRtGPin3xl9T X-Received: by 2002:a2e:9112:: with SMTP id m18mr5961730ljg.181.1559306704152; Fri, 31 May 2019 05:45:04 -0700 (PDT) Received: from [192.168.2.145] ([94.29.35.141]) by smtp.googlemail.com with ESMTPSA id r3sm1201949ljr.76.2019.05.31.05.45.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 05:45:03 -0700 (PDT) Subject: Re: [PATCH V1] i2c: busses: tegra: Add suspend-resume support To: Bitan Biswas , Laxman Dewangan , Thierry Reding , Jonathan Hunter , linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik References: <1559195718-6693-1-git-send-email-bbiswas@nvidia.com> <9142282b-ab76-53a0-13ce-c43b8adc575f@nvidia.com> From: Dmitry Osipenko Message-ID: <4f14a218-332c-0263-c6c5-73a13b2446f0@gmail.com> Date: Fri, 31 May 2019 15:43:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <9142282b-ab76-53a0-13ce-c43b8adc575f@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 31.05.2019 11:50, Bitan Biswas пишет: > > > On 5/30/19 4:27 AM, Dmitry Osipenko wrote: >> 30.05.2019 8:55, Bitan Biswas пишет: >>> Post suspend I2C registers have power on reset values. Before any >>> transfer initialize I2C registers to prevent I2C transfer timeout >>> and implement suspend and resume callbacks needed. Fix below errors >>> post suspend: >>> >>> 1) Tegra I2C transfer timeout during jetson tx2 resume: >>> >>> [   27.520613] pca953x 1-0074: calling pca953x_resume+0x0/0x1b0 @ >>> 2939, parent: i2c-1 >>> [   27.633623] tegra-i2c 3160000.i2c: i2c transfer timed out >>> [   27.639162] pca953x 1-0074: Unable to sync registers 0x3-0x5. -110 >>> [   27.645336] pca953x 1-0074: Failed to sync GPIO dir registers: -110 >>> [   27.651596] PM: dpm_run_callback(): pca953x_resume+0x0/0x1b0 >>> returns -110 >>> [   27.658375] pca953x 1-0074: pca953x_resume+0x0/0x1b0 returned -110 >>> after 127152 usecs >>> [   27.666194] PM: Device 1-0074 failed to resume: error -110 >>> >>> 2) Tegra I2C transfer timeout error on jetson Xavier post resume. >>> >>> Signed-off-by: Bitan Biswas >>> --- >>>   drivers/i2c/busses/i2c-tegra.c | 24 ++++++++++++++++++++++++ >>>   1 file changed, 24 insertions(+) >>> >>> diff --git a/drivers/i2c/busses/i2c-tegra.c >>> b/drivers/i2c/busses/i2c-tegra.c >>> index ebaa78d..f6a377f 100644 >>> --- a/drivers/i2c/busses/i2c-tegra.c >>> +++ b/drivers/i2c/busses/i2c-tegra.c >>> @@ -1687,9 +1687,33 @@ static int tegra_i2c_remove(struct >>> platform_device *pdev) >>>   } >>>     #ifdef CONFIG_PM_SLEEP >>> +static int tegra_i2c_suspend(struct device *dev) >>> +{ >>> +    struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); >>> + >>> +    i2c_mark_adapter_suspended(&i2c_dev->adapter); >>> + >>> +    return 0; >>> +} >>> + >>> +static int tegra_i2c_resume(struct device *dev) >>> +{ >>> +    struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); >>> +    int ret; >>> + >>> +    i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER); >>> +    ret = tegra_i2c_init(i2c_dev, false); >>> +    i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER); >> >> Why the locking is needed here? > > async resume could result in stress test issues if some client accesses > the i2c instance. This ensures the i2c instance is locked till the > initialization is complete. 1) This doesn't make much sense.. if client could access I2C during of tegra_i2c_init execution, then what stops it to perform the access before the lock is taken? 2) The whole point of the i2c_mark_adapter_* API is to catch those faulty clients that have a broken suspend-resume sequence. Client will get a -ESHUTDOWN on trying to issue I2C transfer while controller is marked as suspended. 3) Please don't use async suspend-resume where it doesn't make sense. Corollary: you should drop the locking because it doesn't do anything useful.