Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11843267rwl; Tue, 3 Jan 2023 05:39:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXtzc1KG0IEYNyPJpN1E91tY4cS1oTl5K2r6ByP7G8fnu94SDa0yx9Erp53MQqEuzvzZp7dZ X-Received: by 2002:a17:902:9a96:b0:192:c264:7141 with SMTP id w22-20020a1709029a9600b00192c2647141mr8762001plp.54.1672753165324; Tue, 03 Jan 2023 05:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672753165; cv=none; d=google.com; s=arc-20160816; b=lcQrodyplERA6VggyeDRFhvbfOl0EWCF2fxENW6++CrMPUluvd/iOVRZJe4HO4y/O2 E7HB7tBA9nlhSlkyTjwHJoeArwpyVa2W6rhPpPLtLepeqljcuJDz1/7hjCxyMqULTpuC Q4AezBdYkO0MVq9wAPXomYdEiQfkXl6U4Awyzq0/jJo6NEuWPO8u/j5ZyvIy16/SLkwV BjvteJ6NsEBEjvqFJagzNOj3wOLpdD2s0eR3iT0BkA14Ppmhg2Mnu5iAFhZRXoi7tu7P g3bftmmXYLv2v/3GVmHdNSMBICLeX0tEh3jX2No4S2hMVCfHabxVNhWjt0lWU2T0XYwW XpeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=S9jqpPbKN3vLrz//PNtRoKHjimVJyn2iNVTP/1F8XtQ=; b=aC+i6FESI89qte3ujarI44OpFIaZJFLyM+0YNsvS9028USB+kE5Cg+NdpQepY4IFUy 0loZK8rJGhN788+oYQYo+XKiyEn8tWGwc0wCzt+MCp6b364EbXB1ElzlcQScXcxEryN+ oDQ8Yn64U21rzOUvrvx8mZsXHqJ4UAkKc3X/yhB/fn9F82Fdm+RoojDeWLxtnUG/H+zb Ywsnsevluy6Q2DYHlnEIS6Tf3Y6EKO568oiBlUbfwCAoA3isLKO7mDKZgVuNLGRzx+Ts QeNGxNnEY8G/oZP+XqLNtpY2RZc5rghtcZ2geXGnWrf1+tDpWB+Lr2qLstj2j8gdEUQ0 2cRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nDmlgxbF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a170902db0900b00186e8c3782esi32265531plx.386.2023.01.03.05.39.03; Tue, 03 Jan 2023 05:39:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nDmlgxbF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237116AbjACNXT (ORCPT + 60 others); Tue, 3 Jan 2023 08:23:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbjACNXO (ORCPT ); Tue, 3 Jan 2023 08:23:14 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7852010B47 for ; Tue, 3 Jan 2023 05:23:13 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id s22so31778631ljp.5 for ; Tue, 03 Jan 2023 05:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=S9jqpPbKN3vLrz//PNtRoKHjimVJyn2iNVTP/1F8XtQ=; b=nDmlgxbF9MBDZZnFae13gQDk61Rdv2jzrWtXcCaaTtCvrkYOaDZ+QsB9uo2mQR7aaV gtGyWvTHKeGI566rnLnH66AT8KTqibaD25YIRF/Zra4GbpZJprjOKtCmXrkE6ZblDyzL /rP9U6CFwvn2mnjNF52mBZcnBsD+71xVez8AAOzfSYI+B/r9U6QJEURHOs65HXsZj09p qMGyrQ8seJLP/MXkDFr11Kq3tljPpUhymaVDNqx9s6Up3pHi1oKv8fFmb0zuLGnfwE7l HSaSZGdaWxZSox1bGspXcfZsJhhUFW5K13L9+I1i2IZsDlhetW6XXKSFFznyNZAdA4DY O1Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc: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=S9jqpPbKN3vLrz//PNtRoKHjimVJyn2iNVTP/1F8XtQ=; b=6cZFHjqybjd3w6xy9Yoz7n3NofddGMe4DIcAYFkvaQp/ld3S0MOZMlXwNSzE+pclRx R+V3q005Vcx64O8Jscs1Y96ND27akei4GmBkG2WbLy1xd6+wyBzHoTDhnpJKjH40dU2P 5pOQ79Em3+TrottNXJvB6B3izEnosV+VjIRxhkQk3CqtqCEgIQDILwBkioizB477CAM3 VgbsMLrid9/UbbRkSoNv0Iq/j+95jih4mDSca8wQu0HsnzVTOmTWXBRZq/4qWEN+eJU3 NYfHsHunRB+lAoTCF4kjM5EUZePWmUq/pwUNWcn/gYTdwMKOQfJttowbIowwjnGKKBQO EqYw== X-Gm-Message-State: AFqh2koPgAybJH1o+yOGnFVWGUgs0hecK/djWF6LZIuPdS+nnVTOTPtm iEp4etBJ5o6nzkfO1yFpV58dvg== X-Received: by 2002:a2e:b531:0:b0:27f:c774:1369 with SMTP id z17-20020a2eb531000000b0027fc7741369mr9286128ljm.7.1672752191789; Tue, 03 Jan 2023 05:23:11 -0800 (PST) Received: from [192.168.0.20] (088156142067.dynamic-2-waw-k-3-2-0.vectranet.pl. [88.156.142.67]) by smtp.gmail.com with ESMTPSA id q10-20020a2eb4aa000000b0027fd72dd6a1sm1489435ljm.70.2023.01.03.05.23.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 05:23:10 -0800 (PST) Message-ID: Date: Tue, 3 Jan 2023 14:23:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: RFC on drivers/memory vs drivers/edac memory mapping for DDR Controller Content-Language: en-US To: "Shenhar, Talel" , bp@alien8.de Cc: talelshenhar@gmail.com, shellykz@amazon.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org References: <2511c7aa-8ce6-a803-a1ea-6121df79c677@amazon.com> <8b844f3a-e9b0-28d5-200a-611fe3068bc0@linaro.org> <4bd90224-d09a-1f21-92e6-51c967d68a39@amazon.com> <21c6dd41-3e6f-26c6-d6ca-25102e992c18@linaro.org> <567f14ef-7940-25c5-9323-c673b98e585a@amazon.com> <60d2899e-aed3-a98d-4f3e-8203918a23f9@linaro.org> <4c91989c-8b63-410b-e06f-99d99ddbb390@amazon.com> From: Krzysztof Kozlowski In-Reply-To: <4c91989c-8b63-410b-e06f-99d99ddbb390@amazon.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2023 14:12, Shenhar, Talel wrote: > > On 1/2/2023 6:25 PM, Krzysztof Kozlowski wrote: >> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. >> >> >> >> On 02/01/2023 17:21, Shenhar, Talel wrote: >>> On 1/2/2023 3:59 PM, Krzysztof Kozlowski wrote: >>>> On 02/01/2023 14:44, Shenhar, Talel wrote: >>>>> On 1/2/2023 2:47 PM, Krzysztof Kozlowski wrote: >>>>>> On 02/01/2023 13:17, Shenhar, Talel wrote: >>>>>> >>>>>>> Things we had in mind: >>>>>>> 1) map more specific region to avoid conflict (we don't need the same >>>>>>> registers on both entity so if we do very specific multiple mapping this >>>>>>> shall be resolved) >>>>>>> 2) use other kernel API for mapping that doesn't do request_mem_region >>>>>>> (or use the reserve only for one of them) >>>>>>> 3) have single driver (edac mc) handle also the refresh rate >>>>>>> 4) export edac_mc.h and have the drivers/memory have all the needed code >>>>>>> to do both edac and refresh rate under drivers/memory >>>>>> None of these address the core problem - possibly inaccurate hardware >>>>>> description... >>>>> Can you elaborate on this inaccurate hardware description? >>>> I explained - using same IO address suggests you used Linux driver >>>> structure in your hardware description. I assume we talk here about >>>> Devicetree. If not, that's quite different case... then I guess ACPI, >>>> which I do not care - I am not it's maintainer. >>>> >>>>> Also, I'd like to write down my understanding of your response from above: >>>>> >>>>> it seems you see as possible solution both using different API that >>>>> allow overlapping (solution 2) and also for splitting the IO address >>>>> space to finer pieces to achieve full HW description (solution 1) >>>> No. Sorry, we probably talk about two different things. >>>> >>>> You started writing that you have a hardware described as one IO address >>>> space and now have a problem developing drivers for it. >>>> >>>> The driver model for this is entirely different problem than problem of >>>> accurate hardware description. Whether you described HW correct or not, >>>> I don't know. You did not provide any details here, like DTS or bindings >>>> (if we talk about Devicetree). >>>> >>>> Having multiple drivers using similar resources is already solved many >>>> times (MFD, syscon). >>>> >>>> Whether the solution is correct or not is one more (third) topic: poking >>>> to same IO address space from two different drivers is error-prone. This >>>> one is solvable with splitting IO address space. >>>> >>>> Best regards, >>>> Krzysztof >>> >>> You are right. >>> >>> Let me elaborate on this. >>> >>> We will write down the hardware description via device tree. >>> >>> Then we will write the driver which will honor that binding. >>> >>> So the question is what is the best practice there assuming there is no >>> shared registers however there is overlapping. >> The correct solution is to describe hardware. The hardware is memory >> controller. There is no hardware called "scaller of memory controller". >> There is no hardware called "EDAC" because that's purely a Linux term. >> >> Your DTS should accurately describe the hardware, not drivers. Then >> drivers can do whatever they want with it - have safe, non-concurrent >> access or keep poking same registers and break things... > > The way the HW shall be described in DT is tightly coupled to the way > the drivers will work on mapping the IO addresses. No, that's not true and such DT description will get probably Rob's or mine comments. The HW shall be described without tying to one, specific driver implementation. Otherwise why do you make it tightly coupled to Linux, but ignore BSD, firmware and bootloaders? Don't tightly couple DT with your drivers. > > There are 3 ways to describe the HW as far as I see it from address > point of view: (actually 2 as option 3 is not really sane) > > 1) one big chunk of registers > > 2) smaller chunk of registers aiming to have each chunk describe a > subset of the HW capablity (e.g. RAS, e.g. Refresh-rate, ...) > > 3) describe each register with its name > > Each option dictate how driver shall map the address space. Again, the driver does not matter. You have one device, describe properly one device. DT is not to describe drivers. You did not Cc relevant here mailing addresses (DT and Rob), so this discussion might miss their feedback. How the drivers map IO address space is independent question and should not determine the hardware description. You want to say that hardware changes depending on OS? One OS means hardware is like that and on other OS it's different? > > > If option 1 is chosen, then we shall have 2 drivers with same reg > description. Drivers are not related to DT bindings and DTS. Two different things. > > For that case, they can both remap the whole space or each one can try > to map only the section it needs. > > If option 2 is chosen, then each driver can use DT to know exactly what > it needs to map and do it in safer manner. Best regards, Krzysztof