Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1221934imm; Fri, 28 Sep 2018 14:21:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61WBfvnsJNk7AswS1y5K9/kW9vrxaNg4I70DmDbwOixZLRPwHhDFeIpiphG9wlW1y+QBB+d X-Received: by 2002:a63:2bc9:: with SMTP id r192-v6mr375566pgr.386.1538169667997; Fri, 28 Sep 2018 14:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538169667; cv=none; d=google.com; s=arc-20160816; b=Z6YI6vo0UIID/yfIuJUq8M2tb+6YMtM2WyNcoiXOSsNuaBTzKfYinNSFAmeeIGB6XQ p5dJi3gBtO5tM5OH9sIaHH+n7LZJtPOVKsskw/xNKMhUFCAJRULPCDTg0w3cfCKhaJb5 YmqAhYro3qpFAzJqC79A2AEd5x+w5+o+/7Di4vS0D8Y3JFdMrPLwkhuKoNsLyP4igcTK j1y6LJv6aGFRu9Znq9EMeRZPuT6uwlfBFNRq679A+QkpoutfboPyCF9Pc5I3BatZwb4h e0SYpCI+iSJnoRISDZ4uPsWzA8NszCW8d/Z1kSesJ4bupXQwI4/6+N8x0JnrANNi599C rsmw== 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; bh=IVJ1BzTPqVwuEsAYNRRGQSay6V5VghQOpTKMdwNYelU=; b=XiWmta1M9y6j7hYSQDA3v2V8/Yhi/53BSCvITZ7jOep248uQlvAALYZiUKXwcC7xvp VfuKrk2bCpnQvUP/AODGmsRFxUcoXySkg6PFvVLKxbbNbf39/GRJ0sa1FvhznfjwzOp7 xI5WXeGo79oRZ8HyH5b8xczrrKFeshSa7GMfLrYNVqjUFfiRRW5vBXesHORR8b0j5fYY FP4n264pzvJaxom341pJ4IaU7xT7cGXqtCJ83vztrAnTQHhtM2wxWHSlWwXx+Xq8GD9/ RfzJ9XEmwLAqT91unxmb1lHH7Lw5JiK0Aj3AKu5cHQ8orK3nY0NKzMtfd7uVPoyoQ4UK f8Xw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24-v6si3738552pgv.242.2018.09.28.14.20.52; Fri, 28 Sep 2018 14:21:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727284AbeI2DpB (ORCPT + 99 others); Fri, 28 Sep 2018 23:45:01 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45386 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbeI2DpA (ORCPT ); Fri, 28 Sep 2018 23:45:00 -0400 Received: by mail-ot1-f66.google.com with SMTP id b43-v6so2941819otd.12; Fri, 28 Sep 2018 14:19:25 -0700 (PDT) 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=IVJ1BzTPqVwuEsAYNRRGQSay6V5VghQOpTKMdwNYelU=; b=cvff++gfMog8f8PbOE1x7qy2VrcU8Slh7ldbsai12YoQIDi6iD3xwhBZEZkIJzhNNm +XrYAy6R5hb5QcIGFs+gv2E4xIzDCMezDbNJFdaqAS9l8r0/MiU/0EdtbFXoNHo49KEV 2KMGCarDGJJAw+6orjghfQGeKY6KskLD02t7aQyqPNHmdbECOT1kWaq3xTd0YPj3KgK0 VrbNNyZnCeHoiduU/w/gxXrPpyGvd0aN06hdBbj1pv0tBZngj8C+Ief/cgkjqNJ8pOhI VIX+lSv38cgSPg3D8BFiJ5F1QmFm+sdWSDoDAUxX2Bcp86DbAtgvr7WZkJuiO6+2guO9 BHvw== X-Gm-Message-State: ABuFfoiVImQDGxBW56tX5AIN6AbcR5kcPqMljSrx+EUvszf29BwNSrOf PWUUrM+hKUHSInjinDFQhBulE837GUE= X-Received: by 2002:a9d:5f03:: with SMTP id f3-v6mr320691oti.166.1538169565271; Fri, 28 Sep 2018 14:19:25 -0700 (PDT) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com. [209.85.210.44]) by smtp.gmail.com with ESMTPSA id l60-v6sm2091395otl.52.2018.09.28.14.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 14:19:25 -0700 (PDT) Received: by mail-ot1-f44.google.com with SMTP id m23-v6so7419945otf.0; Fri, 28 Sep 2018 14:19:24 -0700 (PDT) X-Received: by 2002:a9d:1ab:: with SMTP id e40-v6mr290858ote.68.1538169564711; Fri, 28 Sep 2018 14:19:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Li Yang Date: Fri, 28 Sep 2018 16:19:13 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: drivers binding to device node with multiple compatible strings To: Rob Herring Cc: Grant Likely , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , lkml , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , frowand.list@gmail.com 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:00 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. Also a specific PHY > "ethernet-phy-idAAAA.BBBB" with generic "ethernet-phy-ieee802.3-c45". The ethernet-phy issue is not related to the general device binding framework, it should be an issue with the of_mdio framework. But it is still a inalignment with the device tree recommendation. Regards, Leo