Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1379206imm; Tue, 2 Oct 2018 07:20:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV62U6XCshAYEunqEH4p4eieD6OKu5+166E8nUiAUsB+C53PclCBuL75eG7CIhAhEdoCGGOzD X-Received: by 2002:a17:902:8a89:: with SMTP id p9-v6mr17404359plo.183.1538490013276; Tue, 02 Oct 2018 07:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538490013; cv=none; d=google.com; s=arc-20160816; b=h6Eys17EWOkLf90eRiy0tpsQCzwRed2Zyc59Zs52QXkpq5I9C7NmnJ53BS89xnKczz 9zm6+oWInA+lpqSCg2OudKSwL9rB0U2vaxvkGRXMcKtGiDF0pdB7U0zIc2u6Je8yimnE EtpOwL60X279mcn5n2qPHN3n+YRZGDTn5snsCF1y3A5lXPSSbqcXZC6kPIaEp+pNba0Y FEPsSYJAC9c608nFMaJvzNfJ++zg7mnvAtR2B94ly4tQfWKcyAhkUB+6Ko4qzXBI/yeL OpPlOIaZgPZ6x3k+coa2R8wTofBuX6OTNAC3dho6U0LNpx4i7bXraS6YUFV1fNYs1/Bk sW5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h22SwhoQWx7bVJ7AzK4UVUt5ai6Rfv1k4VE5eeQLtL8=; b=K7g8t8hQG9JDy9smmPOUlY9Frc4hztgzqv6qyvqfFrTxI8v1kxsAjVclIJt7KylifK /pO4KMjbOcCQZH0Pbl4U9CSPiat4YDd+ue9tvcPYWSsCCV6mWn/fMP+rDG6f8mDUpW3w gKpOhphJO7dLy7hXwwMW4j9PQUNGdCP8NHaplhL3M7cBv85/sZX1pgr1lhdq3nChlPOQ oppDJvLWWVnCAm5Mf7oKkgdZ5ZWOxUyyv4sAsvSA6PBkYgvrXOSbW2LxQml9Z0ZsRn2z 12QaeA1YMwl1aFE0nZaWBAvc+qkHq5r5oiQixfXlFj4eNWlltZpsrpcwoNCNQSpanBPX jmtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1ehDr+Ag; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15-v6si9053896pfj.68.2018.10.02.07.19.57; Tue, 02 Oct 2018 07:20:13 -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=@kernel.org header.s=default header.b=1ehDr+Ag; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726905AbeJBVD2 (ORCPT + 99 others); Tue, 2 Oct 2018 17:03:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:45132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbeJBVD2 (ORCPT ); Tue, 2 Oct 2018 17:03:28 -0400 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3591A208D9; Tue, 2 Oct 2018 14:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538489990; bh=s0OGTJ3+GT4oO+ZgJdmyKPsZdh5UZA1ymz6LotmV5sI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=1ehDr+AgSAff7uue5ggkZd4lW1X2PMaYMuZVG1NuE0IErsGwZS90BXK+JaxBwLE6o +gejNUgDS5SLjt9d+JKIuTNbDwfyOd3TYwceeolzFLpLdTo0RAfN0Nma+GyNIzdqp8 jP7JOHoe5UfRV4i9YHrleOn6N/Yi4BnbuZHauxvg= Received: by mail-qt1-f177.google.com with SMTP id l2-v6so2044055qtr.12; Tue, 02 Oct 2018 07:19:50 -0700 (PDT) X-Gm-Message-State: ABuFfoisWT75zaL1QgLqfvo0dk3UXmrYbFrri8eIEONA+TC+1mK+Z6gS IR3UrbkwmmEu7QzV5aQ18mp+Txvtu/slYONrww== X-Received: by 2002:aed:3983:: with SMTP id m3-v6mr12859979qte.164.1538489989351; Tue, 02 Oct 2018 07:19:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rob Herring Date: Tue, 2 Oct 2018 09:19:37 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: drivers binding to device node with multiple compatible strings To: Yang-Leo Li Cc: Grant Likely , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , Frank Rowand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 28, 2018 at 4:01 PM Li Yang wrote: > > On Fri, Sep 28, 2018 at 3:07 PM Rob Herring wrote: > > > > On Thu, Sep 27, 2018 at 5:25 PM Li Yang wrote: > > > > > > Hi Rob and Grant, > > > > > > Various device tree specs are recommending to include all the > > > potential compatible strings in the device node, with the order from > > > most specific to most general. But it looks like Linux kernel doesn't > > > provide a way to bind the device to the most specific driver, however, > > > the first registered compatible driver will be bound. > > > > > > As more and more generic drivers are added to the Linux kernel, they > > > are competing with the more specific vendor drivers and causes problem > > > when both are built into the kernel. I'm wondering if there is a > > > generic solution (or in plan) to make the most specific driver bound > > > to the device. Or we have to disable the more general driver or > > > remove the more general compatible string from the device tree? > > > > It's been a known limitation for a long time. However, in practice it > > doesn't seem to be a common problem. Perhaps folks just remove the > > less specific compatible from their DT (though that's not ideal). For > > most modern bindings, there's so many other resources beyond > > compatible (clocks, resets, pinctrl, etc.) that there are few generic > > drivers that can work. > > > > I guess if we want to fix this, we'd need to have weighted matching in > > the driver core and unbind drivers when we get a better match. Though > > it could get messy if the better driver probe fails. Then we've got to > > rebind to the original driver. > > Probably we can populate the platform devices from device tree after > the device_init phase? So that all built-in drivers are already > registered when the devices are created and we can try find the best > match in one go? For more specific loadable modules we probably need > to unbind from the old driver and bind to the new one. But I agree > with you that it could be messy. > > > > > Do you have a specific case where you hit this? > > Maybe not a new issue but "snps,dw-pcie" is competing with various > "fsl,-pcie" compatibles. Having "snps,dw-pcie" is pretty useless IMO. There's lots of versions of the IP and variations on how it is integrated by various SoC vendors. > Also a specific PHY > "ethernet-phy-idAAAA.BBBB" with generic "ethernet-phy-ieee802.3-c45". MDIO device probing works a bit differently, so I don't think there's a problem there. Drivers for specific phys should have a .match_phy_device() callback. I could be wrong as I'm not all that familiar with the MDIO bus code. Rob