Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2633576rdh; Mon, 30 Oct 2023 03:14:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjkkUcx3Jo1+Kr8km2CnNZSLSj8R/ArFt2MMefTxU8rXzDkb1JDTyX186+IG6Q4dloIz8n X-Received: by 2002:a05:6a00:93a0:b0:6bb:def8:b09c with SMTP id ka32-20020a056a0093a000b006bbdef8b09cmr7947774pfb.1.1698660898395; Mon, 30 Oct 2023 03:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698660898; cv=none; d=google.com; s=arc-20160816; b=tehkjwBaiKuNeCIceOEjdVHn1Z5ls456c7ZMD1dJ1UibpLz4V9cX1fP26wp7uWVH9n 5TXTvhdHv6AKDtElaXaF1Ji6INjvV5uxjeQHa4ChukOYXVKUVNlGh6k8Y/jzkI56skJy pBcrmUK1Gf9io2NJK9dh/bANFP0ZcxRLCUwinTM+++wNw+GHdHW0RmerwiFSrm47q6Nf oebKEcUgDuDxWmVY4RBkBbOwOaOAnVHxUpxsTWwnLvnqrpzDLYcZ0rKPI9xbrc5KhvLb Qf1+rqkkfysNfCW/eztIXwMWjfcirQo/AkRl5EIH0zdD240aVWeBsjRz8/mws8Q0vM1n 6Hig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7lO5+taRGYUV3utFVgJLnLNjNxmtaBHkPbnYDUDIen4=; fh=gs5Ca2Pm2HjjtfjDl5SRKddX4w6nlfz+7vN7wN7EBUI=; b=nbrdb2f5Lrwtcu0QQnp/uICU3yszOqE9IDdpKpsbGgWTrtJWhwNcg7fg3wkYTYmOiP uZyNqgu/FtA+FOO6sBF3c487fOKvYy7zAIr+/etJUrThoEkihwRgXp8f2Fc/xB4jnVc8 2W9ANwdDPPBSBZ8X5RODgiqK/ywFbafp3JHABTGJX3BeNb4DoRlEH7BSrRJSHeYckM8l eKMReBWB+Umd9XFGBQqt9bpz3OreLr1xDZrV4YRcWodnsl06WeYNA7eLtQQx8Cr3zLju UMOqct2fPAcRILPIzLw9IOXweDmCmhl1NiWvPTECElQnQkgpmZnlIa890Fet1M7VCqW+ Ow4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yVdYBjrL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id z9-20020aa79489000000b006bf2ef1717csi4692795pfk.255.2023.10.30.03.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 03:14:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yVdYBjrL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1BEAC804C535; Mon, 30 Oct 2023 03:14:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232517AbjJ3KOg (ORCPT + 99 others); Mon, 30 Oct 2023 06:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232563AbjJ3KOX (ORCPT ); Mon, 30 Oct 2023 06:14:23 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 216B73247 for ; Mon, 30 Oct 2023 03:02:04 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-59b5484fbe6so37590727b3.1 for ; Mon, 30 Oct 2023 03:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698660122; x=1699264922; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7lO5+taRGYUV3utFVgJLnLNjNxmtaBHkPbnYDUDIen4=; b=yVdYBjrLvwjTXp7omK711ie9w37RWbSKUmoDEJhGgXABJwRz+0Eb2x1hfUwRJPhC7f 8WyHsWJYEd1quoXRsEe+E2u3mntyDGK+ORAwSEXOQlgowFTs45kciBFGHDzVXRRXNUbG DUiTBWrzpOs+A49jVwMJ9yuTPt0GUoANhFUvJGC9EWLzZEg2LmyY3f6jf9RqbkE+SXRy YaGKt4qMdy28tcDkepwQULLjiL4jz8kXqB6IJK5LIxBr+ce168hX0ZoJmnSGZu/LATpo zZPjPXB//UxO+VnWqeevICuBpZcDYiAMdYG4+dXq0qlRUd7qWr3bW0hliqUqjiKOTSKU Tx9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698660122; x=1699264922; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7lO5+taRGYUV3utFVgJLnLNjNxmtaBHkPbnYDUDIen4=; b=XScrF++SLol4bmVZujKr+oG1bFKYCS5whHZlRo0ziaHDkMBs9sfx8YyZD3XuXOFnV9 BQ3BdL1pjLzDTdy+QNji5XkVmb1UkFRPfTr8b1DsFJHgxA89c8Y47x9VwU1X/ViqbXYu 3FfwUhcV2c+r8RhLTi0kj81tVuziBg0Zz43ibFs24DqkhWzeFKojEvx/p1dm+jbLR4sG ftigdWucHRojd/1LITC1KOnC5ONGkhxbdWyCNi+0mIFoLKk0qswo+/qNkROh28oIp5or MCq3VpU9+1kzNsP+f2PXuK6v63Iz0CHpnubOi26VB4PJn25g6e6zu6OrOZ1k8BqNfqtc Y4yA== X-Gm-Message-State: AOJu0YxP+9Eq/52qDkrppve1WpC37mzzO59Q7SABsL25MEprHs7WXAYN nIjXcPf3qvDoQnzLV/3KIMDxfrc697G8LBjzML/Z5u6z+1MfgwModEaOg+6k X-Received: by 2002:a81:4413:0:b0:59b:eab8:7ac6 with SMTP id r19-20020a814413000000b0059beab87ac6mr9995171ywa.42.1698660122684; Mon, 30 Oct 2023 03:02:02 -0700 (PDT) MIME-Version: 1.0 References: <20231029194607.379459-1-suijingfeng@loongson.cn> <20231029194607.379459-3-suijingfeng@loongson.cn> <3ccb9600-6990-4ec7-81de-0d7b4e1294eb@loongson.cn> In-Reply-To: <3ccb9600-6990-4ec7-81de-0d7b4e1294eb@loongson.cn> From: Dmitry Baryshkov Date: Mon, 30 Oct 2023 12:01:51 +0200 Message-ID: Subject: Re: [PATCH 2/8] drm/loongson: Introduce a drm bridge driver for it66121 HDMI transmitter To: Sui Jingfeng Cc: Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 30 Oct 2023 03:14:54 -0700 (PDT) On Mon, 30 Oct 2023 at 11:42, Sui Jingfeng wrote: > > Hi, > > > On 2023/10/30 06:53, Dmitry Baryshkov wrote: > > On Sun, 29 Oct 2023 at 21:46, Sui Jingfeng wrote: > >> The IT66121 is a DVO to HDMI converter, LS3A5000+LS7A1000 ML5A_MB use this > >> chip to support HDMI output. Thus add a drm bridge based driver for it. > >> This patch is developed with drivers/gpu/drm/bridge/ite-it66121.c as base. > > Please use the original bridge driver instead of adding a new one. > > I'm agree with the spirit of code sharing, but this is nearly impossible for non-DT system. > > Because the original bridge driver(say it66121.ko) is fully dependent on the DT. I can not agree here. It doesn't depend on DT. It has fully populated i2c_device_id structures, so it will work with bare I2C buses. Most likely you will have to change of calls into fwnode calls, that's it. > UEFI+ACPI based system can not use with it. > > Our I2C adapter is created by the drm/loongson.ko on the runtime. > The potential problem is that *cyclic dependency* ! > > I2C adapter driver is depend on drm/loongson > drm/loongson depend on drm bridge driver (say it66121.ko) > drm bridge driver (say it66121.ko) depend on I2C adapter to setup. > > This plus the defer probe mechanism is totally a trap, > incurring troubles and don't work. Welcome. We had this kind of issue for DP AUX buses. I can suggest the following approach: - In the root probe function you can create an i2c bus and populate it with the i2c devices. - I have not checked whether you use components or not. If not, please use an auxiliary or a platform device for the main DRM functionality. - In the subdevice probe / bind function you check for the next bridge. Then you get one of the following:drm_bridge pointer, -EPROBE_DEFER, or any other error case. Your driver can react accordingly. Basically duplicating the existing driver code is not really a way to go. Consider somebody adding a new feature or fixing a bug in your driver copy. Then they have to check if the fix applies to the driver at drivers/gpu/drm/bridge/ite-it66121.c. And vice versa. After fixing an issue in the standard driver one has to keep in mind to check your private copy. So, please, use the OF code as an inspiration and register all your devices in the device tree. Yes, this requires some effort from your side. Yes, this pays off in the longer distance. > > If > > it needs to be changed in any way, please help everyone else by > > improving it instead of introducing new driver. > > > >> Signed-off-by: Sui Jingfeng > >> --- > >> drivers/gpu/drm/loongson/Kconfig | 1 + > >> drivers/gpu/drm/loongson/Makefile | 2 + > >> drivers/gpu/drm/loongson/ite_it66121.c | 749 ++++++++++++++++++++ > >> drivers/gpu/drm/loongson/ite_it66121.h | 19 + > >> drivers/gpu/drm/loongson/ite_it66121_regs.h | 268 +++++++ > >> 5 files changed, 1039 insertions(+) > >> create mode 100644 drivers/gpu/drm/loongson/ite_it66121.c > >> create mode 100644 drivers/gpu/drm/loongson/ite_it66121.h > >> create mode 100644 drivers/gpu/drm/loongson/ite_it66121_regs.h -- With best wishes Dmitry