From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 939D2C433B4 for ; Mon, 17 May 2021 20:17:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DC3D6135D for ; Mon, 17 May 2021 20:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238569AbhEQUSk (ORCPT ); Mon, 17 May 2021 16:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238337AbhEQUSg (ORCPT ); Mon, 17 May 2021 16:18:36 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E392DC061573 for ; Mon, 17 May 2021 13:17:19 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id h21so5855122qtu.5 for ; Mon, 17 May 2021 13:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vLJpaxOqtbI+Qb2zKdqGEkILQIDGWpq1zNOEwsHFtPQ=; b=ZrQnlImcr9WmIFORVAFZEDpXisiakdk1c7hJMqPolW1P1zOfpLXZ3jX5JU9XArrkzs G34/AQNfxUiOIu9TsyBjCX92VuSpj1TU4tm1DDgZ1LYT+tZzk7hX8XHH+P0xYvW8BNO5 78J1WTzrDq24zp159QAD+LFEZPxjmaEHktb1o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vLJpaxOqtbI+Qb2zKdqGEkILQIDGWpq1zNOEwsHFtPQ=; b=UrMilbeJkdbySpXVKEU213a+dWX9Kh4v50t4gRz6DuysrquCA1YkG6/OCwTKKrWTn4 HTbBivKYPh2FoCzbXfHPPfKOGvchNtvC0CpBX9f0ZkZguXZKyVj2QZjqUNjaWiuKqYXU useO1x/skX5RpdDqIvAZiUBep/MseeEw2lMh+y0tVUy7y8ZJoWSnbza6ejeEHMwG/H1m RGCbF4YwFNkqTnJOF4JsWMfXVXfrrVPlZFf771lY00lQjGArUQpNPXYRRkkbfHEiGMOn HFc26eLeZZ/vQCWOa+/5mA1dNIR7czfx3euMvaGyW2Bj2ggfAwv1yVkHjO72iXI+WXcT ZWVw== X-Gm-Message-State: AOAM530bo9XgKkUFUHrjnjDLGMtF0wveN7GqgM+9Oxea4knMNbshoinh eiQee6YCe/tLpqFpE2U0RQW2C+8GauBSVQ== X-Google-Smtp-Source: ABdhPJwnROUYxs3aohEReDo+k0lKuWnhfeiAg3MC5V9pfIf8GDvQ/F6XhqMWHO57ZvE/suiahBdpyA== X-Received: by 2002:ac8:5649:: with SMTP id 9mr1279927qtt.148.1621282639236; Mon, 17 May 2021 13:17:19 -0700 (PDT) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id 123sm11458318qkg.0.2021.05.17.13.17.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 May 2021 13:17:06 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id i4so10270035ybe.2 for ; Mon, 17 May 2021 13:17:00 -0700 (PDT) X-Received: by 2002:a25:aad4:: with SMTP id t78mr2151750ybi.343.1621282601374; Mon, 17 May 2021 13:16:41 -0700 (PDT) MIME-Version: 1.0 References: <20210503215844.2996320-1-dianders@chromium.org> <20210503145750.v6.1.Ib7e3a4af2f3e2cb3bd8e4adbac3bcfc966f27791@changeid> In-Reply-To: <20210503145750.v6.1.Ib7e3a4af2f3e2cb3bd8e4adbac3bcfc966f27791@changeid> From: Doug Anderson Date: Mon, 17 May 2021 13:16:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 1/5] i2c: i2c-core-of: Fix corner case of finding adapter by node To: Wolfram Sang Cc: Lyude Paul , Steev Klimaszewski , Stephen Boyd , Bjorn Andersson , linux-arm-msm , Stanislav Lisovskiy , Linus W , Rob Clark , Maarten Lankhorst , Thierry Reding , linux-i2c , dri-devel , LKML , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, May 3, 2021 at 2:59 PM Douglas Anderson wrote: > > The of_find_i2c_adapter_by_node() could end up failing to find an > adapter in certain conditions. Specifically it's possible that > of_dev_or_parent_node_match() could end up finding an I2C client in > the list and cause bus_find_device() to stop early even though an I2C > adapter was present later in the list. > > Let's move the i2c_verify_adapter() into the predicate function to > prevent this. Now we'll properly skip over the I2C client and be able > to find the I2C adapter. > > This issue has always been a potential problem if a single device tree > node could represent both an I2C client and an adapter. I believe this > is a sane thing to do if, for instance, an I2C-connected DP bridge > chip is present. The bridge chip is an I2C client but it can also > provide an I2C adapter (DDC tunneled over AUX channel). We don't want > to have to create a sub-node just so a panel can link to it with the > "ddc-i2c-bus" property. > > I believe that this problem got worse, however, with commit > e814e688413a ("i2c: of: Try to find an I2C adapter matching the > parent"). Starting at that commit it would be even easier to > accidentally miss finding the adapter. > > Signed-off-by: Douglas Anderson > Reviewed-by: Bjorn Andersson > --- > Later patches in this series won't work right without this one, but > they won't crash. If we can't find the i2c bus we'll just fall back to > the hardcoded panel modes which, at least today, all panels have. > > I'll also note that part of me wonders if we should actually fix this > further to run two passes through everything: first look to see if we > find an exact match and only look at the parent pointer if there is no > match. I don't currently have a need for that and it's a slightly > bigger change, but it seems conceivable that it could affect someone? > > (no changes since v1) > > drivers/i2c/i2c-core-of.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) FYI that I've just posted v7 of this series and I've dropped ${SUBJECT} patch from my series. I think that ${SUBJECT} patch is still correct and could be useful to land, but it's no longer needed by my series since I'm getting access to the DDC bus in a different way. If this patch needs to be spun, please let me know. ...or, feel free to land it! :-) -Doug