Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4649503pxb; Sat, 12 Feb 2022 12:57:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZ4g1FPZEsO0fgD++u9X3mLFnsvcgcK6MUAY7W58c+tFSjo4HWOgvUfqPNdjozmGtUgHGe X-Received: by 2002:a63:1002:: with SMTP id f2mr6015871pgl.388.1644699423614; Sat, 12 Feb 2022 12:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644699423; cv=none; d=google.com; s=arc-20160816; b=zlzU4JrLrpze5Ke64BuoItl8h9005cuL3Z0bnKRhhf0sOd4jFBVUMcf9C3nxxXp+AX QQtlzPl/7ntWIcIHXUJ5g03G+8UL5KVmeMy0W9tYXkz2PqMJ3Q0ArScM8Xo8K1+OwWr4 88MaAui2RoPS+YtDX+a1mFpwDz7jr2oPMXsMKjpYhkKpSYSDMShutczDBHnMsAGFoD0o Hw0ZFLi8trBfd+Amgrg2nFI993yH57uaeL4DZfau+04O4ozBrWBgE+ixAMLryC+gvZFZ 49aUzXTFEoQkmfSOhhWWP3cwBJlvtlNSJn/oXu3N6UBVHOHIFLXeEPgJmixPtx4wzNpk GeoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=ihArlHjS/Wfm+9ieK7AzTeyUT4KunV6n7Q59sXAdDMU=; b=MJ2b7FYKB0zWi+78A959kKVDFU4hZwabScfPpx3tritnQ6Pm58cLIMA5KQGj1ma+Qo DB3ieVISTwmBdGhIriwdmRICxDjsAoMqTqd/f6SDVhFXu0dePwdHfQ6eekJLcYmu6hN1 CSLWihHdm/yyHqLYouzgPKn35Z6WTp/o+XyzLdEw0OQpo+wVjpPAXIKDh1e3k6Gw7tq9 Z7oPtvzhbempm8z7FnFSK8fv5LQGARu1zCaJN9Bn5LMcu1gzbIi2jk7saV9fGIWka39+ Dt+3XrkesmsmZ45tlc2ge32ODdWwnbAwIs2IovPNsyqK2wh9CNxsoD+/G5y4AHudsuaV 3v6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f+i8gncs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2si8334501plz.170.2022.02.12.12.56.46; Sat, 12 Feb 2022 12:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f+i8gncs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237187AbiBLQUx (ORCPT + 99 others); Sat, 12 Feb 2022 11:20:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbiBLQUv (ORCPT ); Sat, 12 Feb 2022 11:20:51 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA5C181; Sat, 12 Feb 2022 08:20:47 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id o9so11612354ljq.4; Sat, 12 Feb 2022 08:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:references:in-reply-to:content-transfer-encoding; bh=ihArlHjS/Wfm+9ieK7AzTeyUT4KunV6n7Q59sXAdDMU=; b=f+i8gncsi2xlxtI+VVw8FQCZvWruHA3H/AyGu3DtBn1eqR1FzczGri9XYXB8tItxaL dAiq71kqKY/HOngidbGqfSAIKv6FOUq5hAJlh1XhG38X3fsnTHT/K4v0j7N0T7REnjEi 1QmDl+f2HHoSzNzCAY/dRFX+yPYRUae23F8NXWOhEcXK6Te+OA0auONMzM7/NfgtBgrG LZy3jcRic3oy3FR+NCNPMjZQHHf72+NW3RB6VP/LmH1rCYN1AuRMehKIu5mf6KEcQFbG IRBHmni+iuJzw/d/6W+aJOyYQ+zmMhc089Poj2xMpibKsVtX3Xnl0L2at75kGOfT4JKt shHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to :content-transfer-encoding; bh=ihArlHjS/Wfm+9ieK7AzTeyUT4KunV6n7Q59sXAdDMU=; b=CSOECOgnV5Yr/to0nPBrNTow/55zz0WADJArEuLRKvxYD8G8g5QJdbxFlisKV62tAx LiqjiCTGs9x25uNP+P77oOrjqCWtylE1PWwWbV41PHFCG5IjqI0NpQztXWEX0pnvT1CN TurMWrniMUCp/OarZhLDm3IMdTmpe3u8F0uwyE+/VzIOS9Ug2UI0zayeLGUbMls19O9L hH2g+d+oa6JXsVZUIWVBumPY1Fhsa5sP5ZlU6/35MB7GQP0th1ADPztXuL7MSGIOJgVf Uf2M5HKmp3vVYI1blYnWGwRTynmxelCBcKQxK9YyIeoYGNt3LITpbvP9Y+tk4fky5L9X lRsQ== X-Gm-Message-State: AOAM532/VXaoM+MWW5JplQfvmLHimozGqI7q99y/rBdUsYLlYYGmHcfU EaRrY6jzoZ6vOUxVm4R8VTg= X-Received: by 2002:a2e:530c:: with SMTP id h12mr4039182ljb.521.1644682845747; Sat, 12 Feb 2022 08:20:45 -0800 (PST) Received: from [192.168.2.145] (109-252-138-165.dynamic.spd-mgts.ru. [109.252.138.165]) by smtp.googlemail.com with ESMTPSA id f9sm1474643lfk.265.2022.02.12.08.20.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Feb 2022 08:20:45 -0800 (PST) Message-ID: Date: Sat, 12 Feb 2022 19:20:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH RESEND] i2c: tegra: Add SMBus block read function Content-Language: en-US From: Dmitry Osipenko To: Akhil R , "christian.koenig@amd.com" , Jonathan Hunter , Laxman Dewangan , "linux-i2c@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" , Mikko Perttunen , "p.zabel@pengutronix.de" , "sumit.semwal@linaro.org" , "thierry.reding@gmail.com" , Svyatoslav Ryhel , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= References: <20220210153603.61894-1-akhilrajeev@nvidia.com> <94fc8b11-6149-56ca-a028-cf7f39930992@gmail.com> In-Reply-To: <94fc8b11-6149-56ca-a028-cf7f39930992@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 12.02.2022 19:15, Dmitry Osipenko пишет: > 11.02.2022 12:11, Akhil R пишет: >>> 10.02.2022 18:36, Akhil R пишет: >>>> Emulate SMBus block read using ContinueXfer to read the length byte >>>> >>>> Signed-off-by: Akhil R >>>> --- >>>> drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- >>>> 1 file changed, 16 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c >>>> index 03cea102ab76..2941e42aa6a0 100644 >>>> --- a/drivers/i2c/busses/i2c-tegra.c >>>> +++ b/drivers/i2c/busses/i2c-tegra.c >>>> @@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev >>> *i2c_dev, >>>> return err; >>>> >>>> i2c_dev->msg_buf = msg->buf; >>>> + >>>> + /* The condition true implies smbus block read and len is already read */ >>>> + if (msg->flags & I2C_M_RECV_LEN && end_state != >>> MSG_END_CONTINUE) >>>> + i2c_dev->msg_buf = msg->buf + 1; >>>> + >>>> i2c_dev->msg_buf_remaining = msg->len; >>>> i2c_dev->msg_err = I2C_ERR_NONE; >>>> i2c_dev->msg_read = !!(msg->flags & I2C_M_RD); >>>> @@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, >>> struct i2c_msg msgs[], >>>> else >>>> end_type = MSG_END_REPEAT_START; >>>> } >>>> + /* If M_RECV_LEN use ContinueXfer to read the first byte */ >>>> + if (msgs[i].flags & I2C_M_RECV_LEN) { >>>> + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], >>> MSG_END_CONTINUE); >>>> + if (ret) >>>> + break; >>>> + /* Set the read byte as msg len */ >>>> + msgs[i].len = msgs[i].buf[0]; >>>> + dev_dbg(i2c_dev->dev, "reading %d bytes\n", msgs[i].len); >>>> + } >>>> ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type); >>>> if (ret) >>>> break; >>>> @@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter >>> *adap) >>>> { >>>> struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap); >>>> u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & >>> ~I2C_FUNC_SMBUS_QUICK) | >>>> - I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; >>>> + I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; >>>> >>>> if (i2c_dev->hw->has_continue_xfer_support) >>>> - ret |= I2C_FUNC_NOSTART; >>>> + ret |= I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_READ_BLOCK_DATA; >>>> >>>> return ret; >>>> } >>> >>> Please describe how this was tested. >> This is tested using an I2C EEPROM to emulate SMBus block read in which >> we read the first byte as the length of bytes to read. This is an expected >> feature for NVIDIA Grace chipset where there will be an actual SMBus device. > > We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried > your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any > idea why it doesn't work? > > [1] > https://github.com/grate-driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0 Ah, I see now that I2C_FUNC_SMBUS_WRITE_BLOCK_DATA not supported, we should check again without the write then.