Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp993955pxb; Thu, 25 Feb 2021 22:56:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfkpcf6HFx512+pTcmLyNhRtyLJyh2tjjdv6vNo0SpWi9bNgjc1jh+Jc4SmZSQybdNIpV9 X-Received: by 2002:a17:906:32d1:: with SMTP id k17mr1718076ejk.141.1614322618346; Thu, 25 Feb 2021 22:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614322618; cv=none; d=google.com; s=arc-20160816; b=o60r24Fp5iKfqWAFphe2+8DlSpmNO9C+/4vTwWkXWcCEjJSSL1UIaWM2Hqi0pTLN8f lEwgfDVETEhWwOES3scK621mKIV6ZR6qYkrVsN7YsP/KhhNKO8ZtZfGsOUwojDLTqU7j c9Dz0+X4miTNI09wyQyEg/1IUs5r6EntNmDbZZ9qWVhqjvtkfxVtI4fhyUxK1aMZjGK1 3reY5vQP2oDWlF4ZPgA+pariWNS1d/AEPdz5HoP3yFnZjbi+wQIsF4zyuK4f9S/I55HG ZOzfDhFJqk/o5vGDJ1pegvUkX5FoZAvFdZ1BBtTJev/qtBYwEiDKKU6Q/c8LSnUQOoIZ U5GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=i7m4H3xz7cUcEC09O4w9iOsviObRN/Oa4xlAc5IYr8A=; b=TlsldFvBsFepQAVleGp6Zuf4pyjWaWJ9MJS7UffM0HKXMHUFMeVk6WQv/BjXZ7OMW+ 6+/DZXmGyKzEI4Vun+uLxHXrTWw+m4birUOHiOTXZTGo1IhiWHoKshjFHZzuif92bYY0 EH+3EsUwO+YqZsfj7IAJBv7vLGD6Uryroc+dOT0Ff71+TmqCKpXoc2EcJlmlMfok74j0 YgpazjDidQzM7CX62U9H8bHe6rHR0JvBa8naXS2NZs7jgPyspJTY7mesZwOaC8v3iFEP ZXAqRml5W8jh5PLzuVAVjjtj+eesSJmDpb3x8Z/JxOWRje/rNpUts2tNiUMPY4E0Zhb1 5YGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b="AhHnXf8/"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QIDddVgu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f23si5439322ejw.202.2021.02.25.22.56.35; Thu, 25 Feb 2021 22:56:58 -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=@flygoat.com header.s=fm1 header.b="AhHnXf8/"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QIDddVgu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbhBZGxx (ORCPT + 99 others); Fri, 26 Feb 2021 01:53:53 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33293 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbhBZGxw (ORCPT ); Fri, 26 Feb 2021 01:53:52 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2AB935C00C4; Fri, 26 Feb 2021 01:53:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 26 Feb 2021 01:53:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=i 7m4H3xz7cUcEC09O4w9iOsviObRN/Oa4xlAc5IYr8A=; b=AhHnXf8/jOqDcDiR5 SuWIOji93zDqi4rYcGnDFqGWTC+D/mI25KUgr9dWJ6vRI7TvrLnjr3SXtyZbafcn lUskaPovJGcD3BOATOex+KysktMDf+omj0+3pwFpdQ/3rZYxJr4v6+cjeD+3NazL 10aMqQv3k7OP53Eswwv6wJf0m24Fq/7MpDwPb6hufvlRiwbgYa6tQ6R6H1vlZK+d Y5EV8wRlNrFBa0HUWzrbgBlRAv6On5oSQYeRp4YW0FUvfqt+6aIQuDYVZxzCCbcZ Q8Gtxh4JRkyq8mc6Jl+0k8uZllqcS321Lx0k8hoVNPxx7iB0z12Rh70Cr0Bsuerv SThhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=i7m4H3xz7cUcEC09O4w9iOsviObRN/Oa4xlAc5IYr 8A=; b=QIDddVguzSpYbhmGdlrl+OkosoabhMOZN54w+ufqfQWO9mmTbGofihzwa 0gExUWWKXjjDZrc/t7FCGXEvD3350vMkaiSjEN2VSDoK399zvXo1s1vqfgeA8PKG rMToz+R3h1sHGlIleE22qisbvD17lGGMAXAmKjTWbj/rr+8jz6WwO44HSsR3SONG UHYZwkTntvuRLeSCc5OaxkpTMpjEntkz3lHL7ifjH3ciAyCY9CBuHOzWk+q6vaz3 xasvuWSw9JzEsqPvKPvpnhK9JEu25zsg2bHaMNccAp1Kjwg+LBc7xWGagTy7Z0ti 41798qhHALusTeq1LCh5UAc5Ln7oQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrledtgddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpeeihffghfeikedugeejvefgffevgeevgeehfffhudeiieffffev ffeugeevfefgfeenucfkphepudelkedrjeegrdehuddrieeknecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhl hihgohgrthdrtghomh X-ME-Proxy: Received: from [0.0.0.0] (li551-68.members.linode.com [198.74.51.68]) by mail.messagingengine.com (Postfix) with ESMTPA id 9996D1080057; Fri, 26 Feb 2021 01:53:02 -0500 (EST) Subject: Re: [PATCH RFC] MIPS: Remove detect_memory_region() To: Jinyang He , Thomas Bogendoerfer , John Crispin Cc: "linux-mips@vger.kernel.org" , linux-kernel@vger.kernel.org References: <1614171720-13221-1-git-send-email-hejinyang@loongson.cn> <987b0dc5-9306-4271-afc0-7c44dba644b7@www.fastmail.com> From: Jiaxun Yang Message-ID: Date: Fri, 26 Feb 2021 14:52:57 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/2/26 上午9:37, Jinyang He 写道: > On 02/24/2021 11:40 PM, Jiaxun Yang wrote: > >> >> On Wed, Feb 24, 2021, at 9:02 PM, Jinyang He wrote: >>> detect_memory_region() was committed by Commit 4d9f77d25268 ("MIPS: add >>> detect_memory_region()"). Then it was equipped by Commit dd63b00804a5 >>> ("MIPS: ralink: make use of the new memory detection code") and >>> Commit 9b75733b7b5e ("MIPS: ath79: make use of the new memory detection >>> code"). Its code is based on early ath79 platform code. >>> >>> What puzzles me is that how memcmp() detect the memory region. If >>> `break` >>> was touched, the function could make sense. That means memcmp() should >>> return zero. Otherwise, the loop will be end by size > sz_max. >>> >>> I have tested detect_memory_region() on Loongson64 3A3000. On our >>> design, >>> kseg0 low 256MB maps real memory and kseg0 high 256MB maps IO/PCI. The >>> function runs and last stopped on kseg1 where is uncached. In this >>> process >>> memcmp also returned non-zero when detected kseg0 high 256MB. Then I >>> did >>> another thing. memcpy first and test memcmp then (after &_end). It >>> works >>> well on 3A3000 but badly on 3A4000. Maybe because kseg0 high 256MB maps >>> IO/PCI and it is dangerous to write like write memory. >>> >>> At last, read memory from where is not memory region may always >>> return 0. >>> (Or trigger exception.) This function have been used several years and >>> seems no error occur. Maybe it's a fallback way. >> That is not true for other platforms like ath79 or mtk. >> They'll wrap around or return 0xffffffff for out of boundary accessing. >> >> Loongson does not apply to this case as it have special "Address Window" >> design to accurately describe address regions. >> Any access beyond described windows will be handled by MC and return >> 0 or random stuff. >> >> Again, please don't make changes because you can. >> >> Thanks. >> >> - Jiaxun > > Hi, Jiaxun, > > Thank you for answering this puzzle for me in detail. > > Assume that the machine has 8MB real memory and dm address is (base + > 3M). > When size = 8MB, there will be a phenomenon of `wrap around`, the actual > content of (dm + 8M + 3M) is content of (dm + 3M), so it will trigger > `break`, right? At this time, the kernel will add 8M to the memory. Hi Jingyang, How can you boot kernel with 8M memory in present days ;-) (Ohh with respect to Nintendo64 developer who had proven it's possible) For what I can say, detect_memory_region exists because many devices doesn't have a way to pass memory size information from bootloader to kernel. Or their bootloader even don't care about memory size. Kernel needs it to get memory size correctly. Although it seems fragile. That's life, we must accept imperfect past and don't repeat it in future. Thanks. - Jiaxun > > Thanks, > Jinyang >