Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4659540pxu; Thu, 10 Dec 2020 02:10:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAYpPuaB+BZCfYAzR3KxqGNYY1jMchNleE5IUeZafyLSJtLgKNB7d3ZL1QluNlFGII6PGJ X-Received: by 2002:a17:906:5386:: with SMTP id g6mr1277023ejo.137.1607595000184; Thu, 10 Dec 2020 02:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607595000; cv=none; d=google.com; s=arc-20160816; b=Fpbfsv1xY2ODYlQELLkuuz55cHkobcTOXqKVHvIMM/rlU8349eG3/XRF1N+CZQaXUs FphuVlWqS13R4kYvn1dLYgixi8gTIY0r5f7bvCs9n7qAnKBcKX4wOBudsbNWdaRYq7og lNXh1j+5CIKQUYjgnHuux4b4MFwnxkKKjVJdwX6DZgiex5FcPBuJpmzasA0K72myDyM/ JEWe55KPykWXiFkiYlaXdMSMUqdHCgYK/HWTG++Bzmy6Bk7GKqguxvdaqQzIk+MkP5zv H79GOYyyFCGXE01F1nHaxzgRjabZ4S6jue+rao+EnRO2cO47DaXtiCQorIEi7+64Keux zxrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=dYyIFuo77eWpup6s+qRK/CtxPzV7SU+lryIdSY50mGQ=; b=J++5zCUol5sa/TiBd5lqOiK0JRm4MNGe3momjZ/zFnJPNW4J5wHoiBopuD6gNK7AL9 5AaC8NOVS5QyfshV1Dc2+6SGbvqv5sf2sfY4rJEvC+h4U/mPz8/LcYzjHK16MCJq4Jyf XjAMd0DJKJJf9dWiwwJ5wWAJqPOf3vJ0LWCmE95CWo8Re7fXkYfFxDsZ+3YDuib73VDE IFnMxeItTl4sKdb7cpiEV1Pz43j75IU5+DjZU1C1gCQ7hOw/4Q1h06rsyfz7JtgHRrqJ yRxvdUx6Yqf7OD8edjujuoDfi0pwNssWxst/iQV3Nhs9S2zIxVWIQN/4unIHk044n7mF ZrjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@essensium.com header.s=google header.b=fMoW9WpJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=essensium.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si2384587edj.256.2020.12.10.02.09.36; Thu, 10 Dec 2020 02:10:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@essensium.com header.s=google header.b=fMoW9WpJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=essensium.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbgLJKHZ (ORCPT + 99 others); Thu, 10 Dec 2020 05:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbgLJKHD (ORCPT ); Thu, 10 Dec 2020 05:07:03 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4013CC0617A6 for ; Thu, 10 Dec 2020 02:05:50 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id u19so4856401edx.2 for ; Thu, 10 Dec 2020 02:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=dYyIFuo77eWpup6s+qRK/CtxPzV7SU+lryIdSY50mGQ=; b=fMoW9WpJONRgpIZYXCjDHfmKvhovPVeZATproWZn8soyVYcHQZqUuUFJgQBW7BOaDk EO9jBzeCo/ZnMhYbTHpGp1xCgx4aneOAQYBk9Y+91nwFg21FcagHbDDiQdZojfST2cB8 mOBTMStJ5m8cwiKByMJsQfwTUXOHh7fJd1vAgZ1rExdAl/RyID9j0fPQRpPx4Xcz0fPv tpXXjx6H+hZjPCKQc9pEf4fwzMK8Oh2OooicNfr23ZwSKelG6MaGwV50cRDlzV5H8g+U aeQxIid8MWyx6+ereqGZIF8rUDx9Iwon2+7rkL4c7dzht3Nwxf5gqQ+qz7erPowmyEhM PiDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dYyIFuo77eWpup6s+qRK/CtxPzV7SU+lryIdSY50mGQ=; b=n+vVvazheDz9ZeRF9sKLwkzP7IoZEgcH4muKyqUJfi+zd7lJx7xUePsDLe0Ndkuk8P pNsxVF03vZCPb/b5iRv2UsCLP6Pb+K/EBO2M7GYvXlRtkn/nlk17SxM0AeHM0sfmdTK4 yRFiNQilgisuzuiQSDUzLUF/cRg6EKGmYXU22vWL6rAXynSxC28wOGdZYFtDKtOFEcxA 2EvzcOdrZBN25bHWGFHAvcsZbjpwe3l+j9z28T7opw5WQ4RxSxewhQOv3vn3bhRiwyV6 RF7Rxq7kfEu48aCVgpBKy9jk72maerCl+evjkFAoMIgDp7gasX5CTnrIeltt5sZoOkeg CRtg== X-Gm-Message-State: AOAM533iEEZo3KlTMOHXatGbqFtnQKuKXmdk59zTjw+6A/PeBUdBOuJG hZmcZE13ZsYg+mKcXrTDV91ZSt1LqJhcQw== X-Received: by 2002:a05:6402:610:: with SMTP id n16mr5860805edv.172.1607594748563; Thu, 10 Dec 2020 02:05:48 -0800 (PST) Received: from [192.168.1.16] (77.109.117.213.adsl.dyn.edpnet.net. [77.109.117.213]) by smtp.gmail.com with ESMTPSA id oq7sm4103032ejb.63.2020.12.10.02.05.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Dec 2020 02:05:47 -0800 (PST) Subject: Re: [PATCH net 1/4] net: freescale/fman: Split the main resource region reservation To: Madalin Bucur , "David S. Miller" , Jakub Kicinski , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20201203135039.31474-1-patrick.havelange@essensium.com> <20201203135039.31474-2-patrick.havelange@essensium.com> <8c28d03a-8831-650c-cf17-9a744d084479@essensium.com> <9a118a8d-ce39-c71b-9efe-3a4fc86041ee@essensium.com> From: Patrick Havelange Message-ID: <51b57945-c238-0c58-ef12-562911a56f8a@essensium.com> Date: Thu, 10 Dec 2020 11:05:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-10 10:05, Madalin Bucur wrote: >> -----Original Message----- >> From: Patrick Havelange [snipped] >> >> But then that change would not be compatible with the existing device >> trees in already existing hardware. I'm not sure how to handle that case >> properly. > > One needs to be backwards compatible with the old device trees, so we do not > really have a simple answer, I know. > >>> If we want to hack it, >>> instead of splitting ioremaps, we can reserve 4 kB in the FMan driver, >>> and keep the ioremap as it is now, with the benefit of less code churn. >> >> but then the ioremap and the memory reservation do not match. Why bother >> at all then with the mem reservation, just ioremap only and be done with >> it. What I'm saying is, I don't see the point of having a "fake" >> reservation call if it does not correspond that what is being used. > > The reservation is not fake, it just covering the first portion of the ioremap. > Another hypothetical FMan driver would presumably reserve and ioremap starting > from the same point, thus the desired error would be met. > > Regarding removing reservation altogether, yes, we can do that, in the child > device drivers. That will fix that use after free issue you've found and align > with the custom, hierarchical structure of the FMan devices/drivers. But would > leave them without the double use guard we have when using the reservation. > >>> In the end, what the reservation is trying to achieve is to make sure >> there >>> is a single driver controlling a certain peripeheral, and this basic >>> requirement would be addressed by that change plus devm_of_iomap() for >> child >>> devices (ports, MACs). >> >> Again, correct me if I'm wrong, but with the fake mem reservation, it >> would *not* make sure that a single driver is controlling a certain >> peripheral. > > Actually, it would. If the current FMan driver reserves the first part of the FMan > memory, then another FMan driver (I do not expect a random driver trying to map the > FMan register area) Ha!, now I understand your point. I still think it is not a clean solution, as the reservation do not match the ioremap usage. > would likely try to use that same part (with the same or > a different size, it does not matter, there will be an error anyway) and the > reservation attempt will fail. If we fix the child device drivers, then they > will have normal mappings and reservations. > >> My point is, either have a *correct* mem reservation, or don't have one >> at all. There is no point in trying to cheat the system. > > Now we do not have correct reservations for the child devices because the > parent takes it all for himself. Reduce the parent reservation and make room > for correct reservations for the child. The two-sections change you've made may > try to be correct but it's overkill for the purpose of detecting double use. But it is not overkill if we want to detect potential subdrivers mapping sections that would not start at the main fman region (but still part of the main fman region). > And I also find the patch to obfuscate the already not so readable code so I'd > opt for a simpler fix. As said already, I'm not in favor of having a reservation that do not match the real usage. And in my opinion, having a mismatch with the mem reservation and the mem usage is also the kind of obfuscation that we want to avoid. Yes now the code is slightly more complex, but it is also slightly more correct. I'm not seeing currently another way on how to make it simpler *and* correct at the same time. Patrick H. > > Madalin >