Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1B7BC74A5B for ; Fri, 17 Mar 2023 14:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbjCQOTy (ORCPT ); Fri, 17 Mar 2023 10:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjCQOTo (ORCPT ); Fri, 17 Mar 2023 10:19:44 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F1EAA729 for ; Fri, 17 Mar 2023 07:19:21 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id ek18so20981581edb.6 for ; Fri, 17 Mar 2023 07:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679062757; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=a6UGZ1j5YRGIf++SOvuEvf0e/rChiAlxEglEcWXrI2w=; b=REjKmlFEGmcll6US1J3Fjy2eVZPzYE79Zxt6zU0wgJvPLI7pghhh0qSBZi/9pQIQbW LYBgYDutldhhhvbTgkt4p3ajRS62P2evYQ0/wtRtaLRIwJZLBKQABWAdYP1Nkw+za3Ms p2UQKQj8CXbThEFh2kWQTmLh1EaN2CPHSNVhtRHMnK8u0VulujPDzwDSIzG7dUfQz8bd jSPLipQ8iXKN+o4mrDdrg+lQP/Owb96c9Vfy2CoTCnQJq8JGHv1u8QElkfGgTBEaKnL7 k15Cqe8TEUEGrtOVyAQ0GMb3kxsJ9oURsbN6KoeCQW6O9k/wIaXVFTNkyGvaXQzWMieW 0VYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679062757; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a6UGZ1j5YRGIf++SOvuEvf0e/rChiAlxEglEcWXrI2w=; b=KlUZEm0c0nte4/GcXTLvr6gbrsydWCo3OJ9tX1EbrAivmhojRoioWv1aw0YDG8hmRL oRsBWYdAD5bCX/ZNpKm1CqEndoa+YxP5L3tQgyqiR8oT4oUmkK7w9ZUlGvcCsqiPplB3 JKhTvAaSkdEm+KN4cD7wZNyVIc1BNGDlacXqBR1GaUmnos2Bbk6so5fOuip9PCPy+Pn0 DVSSLRwZrtrrOXGav+8uBzfBRZGBqVO2kkQ9ZOIJYjwdGdQSY+D9upM3WjSt7QSkU3Ky sO6WHUO3UW2JwSpZIGCvNP/2lUhmlF8CYozynXRJovlI7mdKrMs26PBEyRbx4xC9fG+G ELUQ== X-Gm-Message-State: AO0yUKXMU318a27caSCLw/uW0eE5qASh2brtdsI9fSlE67ufN4zNVS0K /lo1Ev0BjDVx61nc9+Jc61kUfw== X-Google-Smtp-Source: AK7set9CQKALE1nJSPxCGWqo6FPkmjxZdLykShuvvS32DIAJUqhvKbNqm5KYD0e8JHNU/6SCZ193Ig== X-Received: by 2002:a17:906:702:b0:913:ff28:59bd with SMTP id y2-20020a170906070200b00913ff2859bdmr14499758ejb.52.1679062756938; Fri, 17 Mar 2023 07:19:16 -0700 (PDT) Received: from [192.168.2.107] ([79.115.63.78]) by smtp.gmail.com with ESMTPSA id z9-20020a1709067e4900b0092be390b51asm1024602ejr.113.2023.03.17.07.19.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Mar 2023 07:19:16 -0700 (PDT) Message-ID: <33ad964e-edfd-a894-5399-1e870cb36112@linaro.org> Date: Fri, 17 Mar 2023 14:19:15 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: Probing devices by their less-specific "compatible" bindings (here: brcmnand) Content-Language: en-US To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Brian Norris , Linux Kernel Mailing List , "devicetree@vger.kernel.org" , MTD Maling List References: <399d2f43-5cad-6c51-fe3a-623950e2151a@gmail.com> From: Tudor Ambarus In-Reply-To: <399d2f43-5cad-6c51-fe3a-623950e2151a@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/17/23 10:02, Rafał Miłecki wrote: > Hi, I just spent few hours debugging hidden hw lockup and I need to > consult driver core code behaviour. > > I have a BCM4908 SoC based board with a NAND controller on it. > > > ### Hardware binding > > Hardware details: > arch/arm64/boot/dts/broadcom/bcmbca/bcm4908.dtsi > > Relevant part: > nand-controller@1800 { >     compatible = "brcm,nand-bcm63138", "brcm,brcmnand-v7.1", > "brcm,brcmnand"; >     reg = <0x1800 0x600>, <0x2000 0x10>; >     reg-names = "nand", "nand-int-base"; > }: > > Above binding is based on the documentation: > Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml > > > ### Linux drivers > > Linux has separated drivers for few Broadcom's NAND controller bindings: > > 1. drivers/mtd/nand/raw/brcmnand/bcm63138_nand.c for: > brcm,nand-bcm63138 > > 2. drivers/mtd/nand/raw/brcmnand/brcmnand.c for: > brcm,brcmnand-v2.1 > brcm,brcmnand-v2.2 > brcm,brcmnand-v4.0 > brcm,brcmnand-v5.0 > brcm,brcmnand-v6.0 > brcm,brcmnand-v6.1 > brcm,brcmnand-v6.2 > brcm,brcmnand-v7.0 > brcm,brcmnand-v7.1 > brcm,brcmnand-v7.2 > brcm,brcmnand-v7.3 > > 3. drivers/mtd/nand/raw/brcmnand/brcmstb_nand.c for: > brcm,brcmnand > > > ### Problem > > As first Linux probes my hardware using the "brcm,nand-bcm63138" > compatibility string driver bcm63138_nand.c. That's good. > > It that fails however (.probe() returns an error) then Linux core starts > probing using drivers for less specific bindings. > > In my case probing with the "brcm,brcmnand" string driver brcmstb_nand.c > results in ignoring SoC specific bits and causes a hardware lockup. Hw > isn't initialized properly and writel_relaxed(0x00000009, base + 0x04) > just make it hang. > > That obviously isn't an acceptable behavior for me. So I'm wondering > what's going on wrong here. > > Should Linux avoid probing with less-specific compatible strings? No. It's quite common to have a list of compatibles. An use case is that you have a new IP that works with an existing compatible, but this IP also has new features that are not supported by the existing compatible and by the hardware for which the existing compatible was created. So people introduce a new compatible for the existing IP in order to differentiate from the older versions. If the new compatible is not yet defined in the driver, the second compatible from the list is used and you get the IP working but with a reduced function set. > Or should I not claim hw to be "brcm,brcmnand" compatible if it REQUIRES > SoC-specific handling? Correct. Cheers, ta