From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8209C4741F for ; Thu, 5 Nov 2020 14:25:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 778BD2073A for ; Thu, 5 Nov 2020 14:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604586304; bh=/vqr9Uqi5N/fBXYtTc8XN3GMzd3Mpep/CZW0u9+tyo8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=W1Y650EKmEuGrl1VZ7bgDfYp1CG3qcA+KkhQ5/gZ0vaCUn1vsL79WZoH17ZzmScsj UnryrsiauT7AxE5OAeUPY3PFWsmpNSzMF6Swl2qxsRiy1j3chWHNxbQEEW78xlPLol 5F4DHGbb00MCc9ePGOHCYiz+BoNE8d8KhmJKYlxc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730973AbgKEOZD (ORCPT ); Thu, 5 Nov 2020 09:25:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:42932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbgKEOZC (ORCPT ); Thu, 5 Nov 2020 09:25:02 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E53322071A; Thu, 5 Nov 2020 14:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604586301; bh=/vqr9Uqi5N/fBXYtTc8XN3GMzd3Mpep/CZW0u9+tyo8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=z2/qqdZml6Ny//S+VqrA1KkrimmZM7ajoAL1n7Y056USCijCLqHFgS6QYLdZs66Ub fcm8bpYd9oCge4yONrLq+756Q9NVT/+/Y4c0j8oggvKWCXQYNpv7NNOm/vvsP53ttn Yk0YEq/iE31P7pPmlLCbsm43n0HUlvorpE16BKxc= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kagCA-007r3l-TS; Thu, 05 Nov 2020 14:24:58 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 05 Nov 2020 14:24:58 +0000 From: Marc Zyngier To: "xuqiang (M)" Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, rui.xiang@huawei.com Subject: Re: [PATCH -next] irq-chip/gic-v3-its: Fixed an issue where the ITS executes the residual commands in the queue again when the ITS wakes up from sleep mode. In-Reply-To: <5310d2fb-3f01-1283-ea4d-c5992f0c16a5@huawei.com> References: <20201103081123.119969-1-xuqiang36@huawei.com> <87imamtiav.wl-maz@kernel.org> <8395dfbb-a90e-6903-abe9-cd6f7c48f441@huawei.com> <11f4143b4ef55739ff1441e848c1f66f@kernel.org> <5310d2fb-3f01-1283-ea4d-c5992f0c16a5@huawei.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <42a66989326ff73fd01318dc8fbceffc@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: xuqiang36@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, rui.xiang@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-05 14:06, xuqiang (M) wrote: > 在 2020/11/5 21:12, Marc Zyngier 写道: >> Please don't top-post. >> >> On 2020-11-05 11:54, xuqiang (M) wrote: >>> The kernel sends three commands in the following sequence: >>> >>> 1.mapd(deviceA, ITT_addr1, valid:1) >>> >>> 2.mapti(deviceA):ITS write ITT_addr1 memory; >>> >>> 3.mapd(deviceA, ITT_addr1, valid:0) and kfree(ITT_addr1); >>> >>> 4.mapd(deviceA, ITT_addr2, valid:1); >>> >>> 5.mapti(deviceA):ITS write ITT_addr2 memory; >>> >>> In this case, the processor enters the sleep mode. After the kernel >>> performs the suspend operation, the firmware performs the store >>> operation and saves GITS_CBASER and GITS_CWRITER registers. >>> >>> Then, the processor is woken up, and the firmware restores >>> GITS_CBASER >>> and GITS_CWRITER registers. Because GITS_CWRITER register is not 0, >>> ITS will read the above command sequence execution from the command >>> queue, causing ITT_addr1 memory to be trampled. >> >> This cannot work. By doing a memset on the command queue, you are >> only feeding crap to the ITS (command 0 simply does not exist). >> Consider yourself lucky that it doesn't just lock-up. >> >> What needs to happen is the restore sequence that is already in the >> driver, so that the command queue is in a sane state before >> re-enabling >> the ITS. >> >>         M. > > > On my platform, ITS_FLAGS_SAVE_SUSPEND_STATE is not set, thus > the first if condition in its_save_disable under list_for_each_entry > goes > to the continue, however, I want to set the GITS_CWRITER to 0 at the > end of list_for_each_entry. > > Do you have any suggestions about how to do this? That's pretty much dropping the checks for ITS_FLAGS_SAVE_SUSPEND_STATE, isn't it? But I assume your ITS is already enabled by the time you reenter the kernel? If so, I bet your firmware is doing more than just writing to CBASER and CWRITER... M. -- Jazz is not dead. It just smells funny...