Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1291911lqh; Mon, 6 May 2024 03:18:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxpLzBxOMvBpOKzkxLtFM+HB9DNeVa/OvuEiDYfqnnIc9wMKoJ71jqhU/SLNUmONJ6Mafp7+FrvwRYsRyKPWna5Tnm8YbzFtRL7eAy/g== X-Google-Smtp-Source: AGHT+IFytVDuwkjcNpsttQH6/WTfSvHnS7PVfJUxrQZqqhpUbcac6hbswOHK82dWPWv8WEiDe/Ma X-Received: by 2002:a05:620a:46a2:b0:792:950c:dac5 with SMTP id bq34-20020a05620a46a200b00792950cdac5mr4300399qkb.68.1714990687349; Mon, 06 May 2024 03:18:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714990687; cv=pass; d=google.com; s=arc-20160816; b=x56j1hSuTcg9xb+ZvhAAyl9cqpQm9Cf4r/Hv1VTeohaO+G/pwkXYKz7qZRFqitetjc PLKuwkoCIHGdRxXoSG98KWOPTj0T6y7SIygvvYfV7mwIvLaABuRa5IcsmgbuIxleqjur MMZmzOsg26XNqMtNH3YMsrN8LC5T6hc+bBuo8nkT/tch7xM1gqeF5J4MecFQbMiqIDNs d7VGjmXSRNFlQBOPwT5n+EJOsix4UXtt77H20AmFIDTe3i3U9T4Ukm8XGe26JNwuuaN0 5SEyiaS6bM4hYKiLpcl/DEKglzVDBj5yGWM2PkwMe9AaVkV+QGUlH6Lsvi8t78/lOTdc IdyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=6LkVh45ZpshDqy5Wk43Tj54JvKSPwG+xZtec67y4zcQ=; fh=d7fS8hkRF+5BpTd2awDj3rOQYMR6EB+bcWDhYXq4Pr8=; b=QKMAeYSydsowK5hz1IuaGyJM4A0iV1eFxgkjHpPzKru3JccFKw4fvc3HB+udaDXKzg OiLZsLSiRb7OatwOCDcdy4MovoNvZjxFBNh3bLdOZZAC5PheSDjhJx+3MjBi9yzEDe27 bXUjSVkoUywuD8PBMBuYtihdAbb2errsck2cuYhCKyS+pddOIIOoPEnCJ4zVTemkK3+3 JQmw/PizhWhYcGkyo5z1PDszZ6FX6mRVrwdCKPM+whBfHKCa39ShCdzOoej0lYZXhz7V 4D//n2c3zHQ8Mz22a+eYD7oJtdX6EFE4+X3yQuz52b2n5JBe7rRfA1jhbUd9WcaO+432 7lgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=QHuHhiSi; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-169647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id qr20-20020a05620a391400b007928d3a6aa0si4437542qkn.555.2024.05.06.03.18.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 03:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=QHuHhiSi; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-169647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 176321C20F57 for ; Mon, 6 May 2024 10:18:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B019142642; Mon, 6 May 2024 10:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="QHuHhiSi" Received: from xry111.site (xry111.site [89.208.246.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E7AB140366 for ; Mon, 6 May 2024 10:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.208.246.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990680; cv=none; b=u/3vQF04d2D4Wzw8J0uAcm4fSmbzIZzPl9hIAU1wxooXToh+c+gf6XhLms4rzwO7qdVAiREhfkj0ZTXHQszS2Ze8zunIhhPojjDIummG3P14bn5LjTwIaSx0dfs4zCGUbEYIZo1c7+HitxYRWCo8TbW8Tp0HfLmvQVZVoluA7lI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990680; c=relaxed/simple; bh=FhKeXFv6MqdhsuG/vS9cuqQtrCTk4pnU1OTUUmRCoVo=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=dD3l4TLMzYQwKZ8NYLIx9tXYyuQnIbWRI0poC5hicc//VKRRjaKfWtNWCllpJm38oTt1/ffcTFWDGPa104pCxdjgboHOElFNZjyYGf7+GpXlTjR6YPH3ZOOQJgD5Klb1AMukmo+pHOxhQYEHhIn9Q+xHdkZXXDslPo7QXnj8RBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site; spf=pass smtp.mailfrom=xry111.site; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b=QHuHhiSi; arc=none smtp.client-ip=89.208.246.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1714990676; bh=FhKeXFv6MqdhsuG/vS9cuqQtrCTk4pnU1OTUUmRCoVo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QHuHhiSiQAOaJ/caWbAGQn0r5gQoY0P1zgnEL34yvwjAZlpnZZMsIJVpOMsXJx2Py fLx3I839+I6nFKK9VVh5W6tT1/FO/6phxcBu0PHNMYxToYW74sty8gExEL23D26QUJ yPQje3F54/5Axyc0LLt4MhxE3TN5HHh1493tPhLw= Received: from [127.0.0.1] (unknown [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id B712366BEE; Mon, 6 May 2024 06:17:54 -0400 (EDT) Message-ID: Subject: Re: [PATCH] LoongArch: Update the flush cache policy From: Xi Ruoyao To: lijun , chenhuacai@kernel.org, kernel@xen0n.name, lvjianmin@loongson.cn, dongbiao@loongson.cn, zhangbaoqi@loongson.cn Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Date: Mon, 06 May 2024 18:17:51 +0800 In-Reply-To: References: <20240506092419.4109941-1-lijun01@kylinos.cn> <8a8135eb0f1dc724cfbb4402dc6daf08db5b0bc7.camel@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2024-05-06 at 18:08 +0800, lijun wrote: > volatile prevents compiler optimization by allowing the compiler >=20 > =C2=A0=C2=A0to reread the address value of addr every time But why is this ever needed? What's wrong if the compiler optimizes it? If the problem is the compiler may optimize it to cdesc->ways * 3 * cdesc->sets * cdesc->linesz, unknowing cdesc->ways etc may magically change, you should use READ_ONCE(cdesc->ways) etc. I.e. use READ_ONCE on the expression which may magically change, instead of hacking addr. addr won't magically change. > =E5=9C=A8 2024/5/6 17:28, Xi Ruoyao =E5=86=99=E9=81=93: > > On Mon, 2024-05-06 at 17:24 +0800, Li Jun wrote: > > > fix when LoongArch s3 resume, Can't find image information > > >=20 > > > Signed-off-by: Li Jun > > > Signed-off-by: Baoqi Zhang > > > Signed-off-by: Jianmin Lv > > > Signed-off-by: Biao Dong > > > --- > > > =C2=A0=C2=A0arch/loongarch/mm/cache.c | 24 +++++++++++++++++++++++- > > > =C2=A0=C2=A01 file changed, 23 insertions(+), 1 deletion(-) > > >=20 > > > diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c > > > index 6be04d36ca07..52872fa0e5d8 100644 > > > --- a/arch/loongarch/mm/cache.c > > > +++ b/arch/loongarch/mm/cache.c > > > @@ -63,6 +63,28 @@ static void flush_cache_leaf(unsigned int leaf) > > > =C2=A0=C2=A0 } while (--nr_nodes > 0); > > > =C2=A0=C2=A0} > > > =C2=A0=20 > > > +static void flush_cache_last_level(unsigned int leaf) > > > +{ > > > + u64 addr; > > > + int i, j, nr_nodes, way_size; > > > + struct cache_desc *cdesc =3D current_cpu_data.cache_leaves > > > + > > > leaf; > > > + > > > + nr_nodes =3D loongson_sysconf.nr_nodes; > > > + > > > + addr =3D CSR_DMW1_BASE; > > > + iocsr_write32(0x1, 0x280); > > > + way_size =3D cdesc->sets * cdesc->linesz; > > > + do { > > > + for (i =3D 0; i < (cdesc->ways * 3); i++) { > > > + for (j =3D 0; j < (cdesc->sets); j++) { > > > + *(volatile u32 *)addr; > > ??? what does this line do? > >=20 >=20 --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University