Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4939038ybi; Tue, 30 Jul 2019 10:48:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwoALEz6SvlpAIKlFkN9R7q/EVaMco1xzBixtxTq82I/3ClluAJOddTnMpitKYd9UAqOEW X-Received: by 2002:a17:902:684:: with SMTP id 4mr116480711plh.138.1564508905830; Tue, 30 Jul 2019 10:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564508905; cv=none; d=google.com; s=arc-20160816; b=cvFDTvxSXO2e+mxzI+n4rAPZRFjNuLBKsxm807XmarF9OedFSAq8cBC6OJyE2Z+h65 PECs+4HlvchsPV7cxqQvl9WJ7ie3YUPUfbHwiblTeV8dmr8IBLZAes/qQPKlCdzsTEMe 8qtyKME1xcuGqsDq8YRNXwuFQ67jJpyqg6umOmcRSU2ZQtccWoaWlRi+ej2K658Tw+M5 aKBkk2ScPer+0vlgNYYoaM4H4aeOO/ggMUL2wc3YluiKY8cU9uF5t8qXSL4AikA2Kvrs BUkLoKGM5hEpFxjspq4k64tbHBEiRsbqbqXx8RgWdatLgC6ce3nn7v6VIl4WodqkdX08 zFWA== 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:organization:autocrypt:openpgp:from:references:cc:to :subject:dkim-signature; bh=ySoiYclDSeZwytRrL2JIutyMtXbb3MYUEVXKENpqhnU=; b=nzhNWkqYhoF5m5ZeShNcAt8ZoK9IToCUgZKJoX70oi2v4kF9nRDqw7A3UySo5GLVuP Ekdld1eRtD8L9tw4zppuqef8xSOlqI8l8e6YmbEhUF6thsnPF7Wig6TOKzbLGAs/qMso CMBZiZFLykCWFVS9ztIWcTCpLnuQLMYzfwp/G0Qeblhvd2hzoPB96Jky31673O5mA2H1 z6Lm4PzUdJmY6IGf8k6aYMI3WzuWVuxTEchUepYHSIWPjdi6KDyvjSd5aaCemsmEbWkO zHUpLSpeAwzLlL+W95GKOUj8yhA8aZWDfMj+w9KmkUp4LiSVf6Gci25x5vDPthORcFnH CWkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fhF2VQBa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s29si30390945pfd.147.2019.07.30.10.48.11; Tue, 30 Jul 2019 10:48:25 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fhF2VQBa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731204AbfG3Ni1 (ORCPT + 99 others); Tue, 30 Jul 2019 09:38:27 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52560 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfG3Ni1 (ORCPT ); Tue, 30 Jul 2019 09:38:27 -0400 Received: by mail-wm1-f66.google.com with SMTP id s3so57182441wms.2 for ; Tue, 30 Jul 2019 06:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:openpgp:autocrypt:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ySoiYclDSeZwytRrL2JIutyMtXbb3MYUEVXKENpqhnU=; b=fhF2VQBaJsGrcgN+Ys0+/XauSUyKgdE6DH1yLJ6S2DbwmATbj1PNLX9A1ZCvjAYXKn IWX+X2oNsTojknjD+vSzxjCvxmjlUy01fKd3zrCfpUbAJVGQmGFWXZRwB7H5TNQwucRf lOZzvKEC4EUidiQt4NPrH3BPls2JuiC4IYc+2FSe68618fcGe4jil5vxFHiedoWhErB2 qyvwWL3ikacppoLZhYfkaOZO8KxEUYI2xDJ53x5qa3hddovUUs2rCYARo9FCUxBI/pp4 RN94LPiF6Yxl93Id/UV7UsyAIEfugDKMxkzxWW+LoZ92H7vmoc1WseUdjvYnSE6wgYow JogA== 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:openpgp:autocrypt :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ySoiYclDSeZwytRrL2JIutyMtXbb3MYUEVXKENpqhnU=; b=D49Fm/UKNCVMoVAQYE/x7R3N1gUa7kYikmJTVYwm6CjpTD0Z2+USyjJG7QGBylAXIA WSDDHRKcAB8A2rg3aNadB4xwIE4VJ7xO9EtoeJbOdK7xnzsQdt3NxZXm4RZ1xt3ly5rZ F68Jt6wdzayuZtPn8uDL9SnHK8m8dzKY5tHzVC/fCV5DCM+EkD5goTpRUJbeo9K4doJG CrUSOVMlJH7Ly5ETvth58l8RUWrrMxmYUrZo/UQquP+8u4eadset80XLUf0ZY753UZGy S1pXkWkq1MQNfriK/MaUFyy0OAVdxOESbKCFAadfhOyhgu1CtTVOTLuZmLoQ2LrU11aG 1CEw== X-Gm-Message-State: APjAAAWDTJQLdoKoQ6rNSgEIBqJ+EsIZAMk12v/o7fUpVWUcOsbdPKB8 s2w+s//OtdpiwTq3ahRglZFelQ== X-Received: by 2002:a05:600c:224d:: with SMTP id a13mr61076680wmm.62.1564493904725; Tue, 30 Jul 2019 06:38:24 -0700 (PDT) Received: from [10.1.2.12] (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id n12sm67726828wmc.24.2019.07.30.06.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jul 2019 06:38:23 -0700 (PDT) Subject: Re: [PATCH v2] drm/bridge: dw-hdmi: Refuse DDC/CI transfers on the internal I2C controller To: Sean Paul , Matthias Kaehlcke Cc: Andrzej Hajda , Laurent Pinchart , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jose Abreu , Douglas Anderson , Adam Jackson References: <20190722181945.244395-1-mka@chromium.org> <20190722202426.GL104440@art_vandelay> <20190722210207.GZ250418@google.com> <20190725174927.GN104440@art_vandelay> From: Neil Armstrong Openpgp: preference=signencrypt Autocrypt: addr=narmstrong@baylibre.com; prefer-encrypt=mutual; keydata= mQENBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAG0KE5laWwgQXJtc3Ryb25nIDxuYXJtc3Ryb25nQGJheWxpYnJlLmNvbT6JATsEEwEKACUC GyMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheABQJXDO2CAhkBAAoJEBaat7Gkz/iubGIH/iyk RqvgB62oKOFlgOTYCMkYpm2aAOZZLf6VKHKc7DoVwuUkjHfIRXdslbrxi4pk5VKU6ZP9AKsN NtMZntB8WrBTtkAZf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fum9K3iM /4Wh4V2eqGEgpdeSp5K+LdaNyNgaqzMOtt4HYk86LYLSHfFXywdlbGrY9+TqiJ+ZVW4trmui NIJCOku8SYansq34QzYM0x3UFRwff+45zNBEVzctSnremg1mVgrzOfXU8rt+4N1b2MxorPF8 619aCwVP7U16qNSBaqiAJr4e5SNEnoAq18+1Gp8QsFG0ARY8xp+qaKBByWES7lRi3QbqAKZf yOHS6gmYo9gBmuAhc65/VtHMJtxwjpUeN4Bcs9HUpDMDVHdfeRa73wM+wY5potfQ5zkSp0Jp bxnv/cRBH6+c43stTffprd//4Hgz+nJcCgZKtCYIAPkUxABC85ID2CidzbraErVACmRoizhT KR2OiqSLW2x4xdmSiFNcIWkWJB6Qdri0Fzs2dHe8etD1HYaht1ZhZ810s7QOL7JwypO8dscN KTEkyoTGn6cWj0CX+PeP4xp8AR8ot4d0BhtUY34UPzjE1/xyrQFAdnLd0PP4wXxdIUuRs0+n WLY9Aou/vC1LAdlaGsoTVzJ2gX4fkKQIWhX0WVk41BSFeDKQ3RQ2pnuzwedLO94Bf6X0G48O VsbXrP9BZ6snXyHfebPnno/te5XRqZTL9aJOytB/1iUna+1MAwBxGFPvqeEUUyT+gx1l3Acl ZaTUOEkgIor5losDrePdPgE= Organization: Baylibre Message-ID: Date: Tue, 30 Jul 2019 15:38:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190725174927.GN104440@art_vandelay> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 25/07/2019 19:49, Sean Paul wrote: > On Mon, Jul 22, 2019 at 02:02:07PM -0700, Matthias Kaehlcke wrote: >> On Mon, Jul 22, 2019 at 04:24:26PM -0400, Sean Paul wrote: >>> On Mon, Jul 22, 2019 at 11:19:45AM -0700, Matthias Kaehlcke wrote: >>>> The DDC/CI protocol involves sending a multi-byte request to the >>>> display via I2C, which is typically followed by a multi-byte >>>> response. The internal I2C controller only allows single byte >>>> reads/writes or reads of 8 sequential bytes, hence DDC/CI is not >>>> supported when the internal I2C controller is used. The I2C >>> >>> This is very likely a stupid question, but I didn't see an answer for it, so >>> I'll just ask :) >>> >>> If the controller supports xfers of 8 bytes and 1 bytes, could you just split >>> up any of these transactions into len/8+len%8 transactions? >> >> The controller interprets all transfers to be register accesses. It is >> not possible to just send the sequence '0x0a 0x0b 0x0c' as three byte >> transfers, the controller expects an address for each byte and >> (supposedly) sends it over the wire, which typically isn't what you >> want. >> >> Also the 8-byte reads only seem to be supported in certain >> configurations ("when the DWC_HDMI_TX_20 parameter is enabled"). > > Thanks for the detailed answers (both you and Doug)! > > This change looks good to me, but I'll leave it to a dw-hdmi expert to apply. So > fwiw, I'm not qualified as a dw-hdmi expert but until the internal i2c controller is exposed as a "standard" i2c adapter (which is a valuable feature), blacklisting a fixed address is wrong, and we should detect invalid/malformed transactions instead that doesn't fit in the HW model OR really stop emulating an i2c adapter. Moving to drm_do_get_edid() would need to entirely rewrite or refactor communication code to handle the SCDC transactions, since they use an i2c adapter... Neil > > Reviewed-by: Sean Paul > > >> >>>> transfers complete without errors, however the data in the response >>>> is garbage. Abort transfers to/from slave address 0x37 (DDC) with >>>> -EOPNOTSUPP, to make it evident that the communication is failing. >>>> >>>> Signed-off-by: Matthias Kaehlcke >>>> --- >>>> Changes in v2: >>>> - changed DDC_I2C_ADDR to DDC_CI_ADDR >>>> --- >>>> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 8 ++++++++ >>>> 1 file changed, 8 insertions(+) >>>> >>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >>>> index 045b1b13fd0e..28933629f3c7 100644 >>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >>>> @@ -35,6 +35,7 @@ >>>> >>>> #include >>>> >>>> +#define DDC_CI_ADDR 0x37 >>>> #define DDC_SEGMENT_ADDR 0x30 >>>> >>>> #define HDMI_EDID_LEN 512 >>>> @@ -322,6 +323,13 @@ static int dw_hdmi_i2c_xfer(struct i2c_adapter *adap, >>>> u8 addr = msgs[0].addr; >>>> int i, ret = 0; >>>> >>>> + if (addr == DDC_CI_ADDR) >>>> + /* >>>> + * The internal I2C controller does not support the multi-byte >>>> + * read and write operations needed for DDC/CI. >>>> + */ >>>> + return -EOPNOTSUPP; >>>> + >>>> dev_dbg(hdmi->dev, "xfer: num: %d, addr: %#x\n", num, addr); >>>> >>>> for (i = 0; i < num; i++) { >>> >