Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp960480iob; Fri, 13 May 2022 17:47:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcthmQqOoz9vQZ69MfNm5eAmyEkwvWnkXnIJb1muWxA5agp/MyZTuDD+RDt7JWoPLrEuNM X-Received: by 2002:adf:ef0b:0:b0:20c:9be6:4209 with SMTP id e11-20020adfef0b000000b0020c9be64209mr5916812wro.471.1652489260936; Fri, 13 May 2022 17:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652489260; cv=none; d=google.com; s=arc-20160816; b=k77lEkTFs7HZYaPRIlnZyGB8SVfKd+QosaS9p+hd29XLojcvLOY9Q5vMkYjCLzxHb5 i+X6BrkBbCNQHx/dBo4clo6mv+OSsvCmEFnqqJaTIGPGDzJBl3vwZPC9DTJbzVns2EhU W9e8CNO5w/oknFstbNV+DoBVjJ5Oirp6EvcrPvLvGdTIBJ5ESLD6v8yKu+Urr32udetV k6t9uO1CZvBPaIA9Cw2hZUGFFktKbkfN8tvmE7KLIgl09PhlPRDsiqWWYafyGehVo2pI NM9MiGcnbt95F+Sesf7fjDkuuwvSAg3gmNNBQLQA4O5f8tQQz/inQeg5wNiPknTD0jjj efxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dLYCXboJhrA8iHbOe8qvqS6bwk5poSsYlSV9rrgqfXc=; b=OptQ/SK5JuewsYO5p92H4At5r7iUz0ceOFtMbgIIE0/QQ9o6wtSW2X1B1HvpYzewhl P9YKenz6WbN3l49lxM9EErZ1HhYQ00HaU4kClX6Iu8/dvrpUhpVWxV8m7FMdAuFUYLJE tsLPzw0tFqAEcVsc9qybyRj5S90FmkRe3FFDi3Fj3HKenpMb2wcZaRtuzJRgruXv2NnZ g76x5iqk8UH/B2UU/QZbrBchxqREndUZCgbpwuxiTmaR4KQW+sGVRtJcPcboptU2l96e v6nybdnDVCx4tVOfAAJey4PulBuOyDtgmd0SCm9+bTaBfH4XIorBtzoWpJ/Ljufb5wq/ l2Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p8-20020a5d59a8000000b0020c4d8bc8fcsi3539625wrr.26.2022.05.13.17.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:47:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9BF61336134; Fri, 13 May 2022 16:26:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353751AbiELMbv (ORCPT + 99 others); Thu, 12 May 2022 08:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353763AbiELMbm (ORCPT ); Thu, 12 May 2022 08:31:42 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB904924D for ; Thu, 12 May 2022 05:31:35 -0700 (PDT) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np7yH-00020p-2C; Thu, 12 May 2022 14:31:09 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: mick@ics.forth.gr, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, akpm@linux-foundation.org, wangkefeng.wang@huawei.com, rppt@kernel.org, david@redhat.com, wangborong@cdjrlc.com, twd2.me@gmail.com, seanjc@google.com, alex@ghiti.fr, petr.pavlu@suse.com, atishp@rivosinc.com, linux-riscv@lists.infradead.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, jianghuaming.jhm@alibaba-inc.com, guoren@kernel.org, Xianting Tian , Xianting Tian Subject: Re: [PATCH v2] RISC-V: Mark IORESOURCE_EXCLUSIVE for reserved mem instead of IORESOURCE_BUSY Date: Thu, 12 May 2022 14:31:07 +0200 Message-ID: <2583718.X9hSmTKtgW@diego> In-Reply-To: <20220512060910.601832-1-xianting.tian@linux.alibaba.com> References: <20220512060910.601832-1-xianting.tian@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Am Donnerstag, 12. Mai 2022, 08:09:10 CEST schrieb Xianting Tian: > Commit 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") > marked IORESOURCE_BUSY for reserved memory, which casued resource map typo "caused" resource map > failed in subsequent operations of related driver, so remove the > IORESOURCE_BUSY flag. In order to prohibit userland mapping reserved > memory, mark IORESOURCE_EXCLUSIVE for it. Looking at the comment for IORESOURCE_EXCLUSIVE (/* Userland may not map this resource */) this also looks like the way better match for "no-map" :-) . Reviewed-by: Heiko Stuebner Also on qemu + d1-nezha board Tested-by: Heiko Stuebner Heiko > The code to reproduce the issue, > dts: > mem0: memory@a0000000 { > reg = <0x0 0xa0000000 0 0x1000000>; > no-map; > }; > > &test { > status = "okay"; > memory-region = <&mem0>; > }; > > code: > np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); > ret = of_address_to_resource(np, 0, &r); > base = devm_ioremap_resource(&pdev->dev, &r); > // base = -EBUSY > > Fixes: 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") > Reported-by: Huaming Jiang > Reviewed-by: Guo Ren > Reviewed-by: Nick Kossifidis > Signed-off-by: Xianting Tian > --- > arch/riscv/kernel/setup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c > index 834eb652a7b9..e0a00739bd13 100644 > --- a/arch/riscv/kernel/setup.c > +++ b/arch/riscv/kernel/setup.c > @@ -189,7 +189,7 @@ static void __init init_resources(void) > res = &mem_res[res_idx--]; > > res->name = "Reserved"; > - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; > + res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; > res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > @@ -214,7 +214,7 @@ static void __init init_resources(void) > > if (unlikely(memblock_is_nomap(region))) { > res->name = "Reserved"; > - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; > + res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; > } else { > res->name = "System RAM"; > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; >