Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp742182imm; Thu, 4 Oct 2018 02:33:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV633MIo2kZF6vNH0SGTv3i+WrU9OKmgoUMerg/kBEjQcYCIWTDEJ2j9VGXe4PknnTdYznRAA X-Received: by 2002:a17:902:a989:: with SMTP id bh9-v6mr5555177plb.245.1538645622850; Thu, 04 Oct 2018 02:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538645622; cv=none; d=google.com; s=arc-20160816; b=XN1gdBmktQdiFm3R3bdWoosG7UY2+7h3fdwzFrDtS3OTgVZYWZYwQHEPi083nqdIMJ PJLKKFiohp+i7t7sIJUqNKQOJVBfvPDb8BNfaQLg0dP5Ou+d7ZB/SQlLlUezf3fGmGLq dgm1N2mhnMhuWwciSaD6DGpokEEpH94m4oFP98oovxiROA5u5MfiMG0s712s1WgsnB6J p7kodIN9nmHH/524kJ6xKQbgHFcsfsXGZ34e2WjgtmxL44QVnHLGbDY/evM4P56wIIwd GMttE+EFG6m95u9QBst5v1LiR8lUUuRgsecaDeMRxSs43+7WJ8aNI8NOSVvG/NUpvJSV py2A== 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=sCKH4RQnTBpbeTBBN1euQfMgvs4V7eNXnGtZahTXz9o=; b=IptIpeanIB2IBKhRu9ltof98nc+Tahvl7N/He8teEeQts5iHRKIwsrXEIGB+JVjaqn 8GYeUKPl9pvs/3bvPBxpzOuPJdD6GCQ8bvD4k9AeLZTkkEwkFzNd6D+MjD2x+pFZJacm 9uIUuPfaEUjIcW/e8dLhKgcsggSctt6/v8PlkX3+xKbRuw4e9otAQ+7Wir0P3LS+iyCx lF24gt9PLmzdoAU+9IIQ2U+9xhp7yRah2QpVwO2GDCUn6fyJMFlUkmHIQYtb1aqBrGNJ M90vYKJ/usBI2rgLCOXPrpWTvUgVrVvX46QR+2WBDPdm5DqVrYMZgjQ9WlPfKfErYvLe UUVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@secretlab-ca.20150623.gappssmtp.com header.s=20150623 header.b=RMlBgxlU; 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 d2-v6si4451665plo.210.2018.10.04.02.33.27; Thu, 04 Oct 2018 02:33:42 -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=@secretlab-ca.20150623.gappssmtp.com header.s=20150623 header.b=RMlBgxlU; 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 S1727755AbeJDQZd (ORCPT + 99 others); Thu, 4 Oct 2018 12:25:33 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39229 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbeJDQZc (ORCPT ); Thu, 4 Oct 2018 12:25:32 -0400 Received: by mail-qt1-f194.google.com with SMTP id e22-v6so2048138qto.6 for ; Thu, 04 Oct 2018 02:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretlab-ca.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sCKH4RQnTBpbeTBBN1euQfMgvs4V7eNXnGtZahTXz9o=; b=RMlBgxlURbreXIvdBKCc8WEpGZTsp5EPcsqG5rqIft2HhSRlBjEA7MCj+q9wmhcyTK UjVEWp9nnMwzmSaZkYgV626vgbEWhlqC05dGIhNWlhs/Gz1arFsjNWQNO51ASTEVeKhg V2x2aXqVTJqcb4somx66vMEdK67w4LvQq7hAZvtY2t17z0eribA5YCtqcuVYiIQHCcwY VXFYgR3lsSOYfGUjhb6r2/IFkhBuiNAa4UuAHg7nQgBxrs5PIGUziFeXSKEbyg1cTZZ1 yvEDWjLigph+Vqz+rkz/O7D2yUtJexolqzVy5cPuyeM8rXH6cLhEM5MXGwqx0WOKnBam aFAA== 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=sCKH4RQnTBpbeTBBN1euQfMgvs4V7eNXnGtZahTXz9o=; b=pYwujR9n/zgpDCAqIqnCkL8nEUljGH8CAYVdFs3DkuYvov+feNsKVtJi5daFAdTkGn uGgxQIf3UCFhI2d7eGc0Vrn24tHb6HjblHeFrIBrSkP7/M7SvI/9qgCYP6hk7yslYpX8 RyUAacdsP96yNpPyGPAISo9gHZfDVj36Y4l20JbZyKKaEDzPEUHP1+3d9f57aobw5vvl dsyoQ8wV2nOuKF1f2an9IkPaMjU2F256QxNGyOx2HW6oP2gYenBTZxUrV4HCgXq/CRmV mnxm9+jCw7nxzJoOF+2/v+DGkw9Kb3xh2oTmJcFH3FKSpq8rBgMOcbQhA7y2q4jsPtpJ h+Uw== X-Gm-Message-State: ABuFfoj0f1qOZRaofGrgCzLql5OPMFsPml7T86dAP0vDEpa7K6JmsVnQ aCVivVIMo3e19s+wP4NmQzEBYYEgcpdAjFSrnu1qrQ== X-Received: by 2002:ac8:1b87:: with SMTP id z7-v6mr4513208qtj.321.1538645588379; Thu, 04 Oct 2018 02:33:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Grant Likely Date: Thu, 4 Oct 2018 10:32:56 +0100 Message-ID: Subject: Re: drivers binding to device node with multiple compatible strings To: leoyang.li@nxp.com Cc: Rob Herring , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Linux ARM , linuxppc-dev@lists.ozlabs.org, Frank Rowand , Grant Likely 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 10: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. It's a tradeoff. > > > > > 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. Also a specific PHY > "ethernet-phy-idAAAA.BBBB" with generic "ethernet-phy-ieee802.3-c45". > > Regards, > Leo