From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 36CF2142E86 for ; Wed, 6 Nov 2024 09:29:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730885344; cv=none; b=I4vaXAiM/xIM8smdYk4mts2nrlP6nR1HkF7C1rt/Pl7bWKbaeVE4GKA604KaLlsds2MRpXtm/W3rEeSTWpcaMznU12PmBZ1OuEkrHCmPGVOJb2Efc8irnUGChoF5CMkSwsIvT3nFqDQA35J+zEnHDv9pEhUhzC1D5BUP5PvQIUc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730885344; c=relaxed/simple; bh=gD3ymZXOf1Xp+zXbXqMleltiFT4RiaNkSbFjDmEzFhY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=dSVLwjuH/WzVxT1fsSiotJ++nD7bx4vSHZab6WdcTBzGPdKgZItng1bXAZFAPvq/t5udFqibS5+TojQMKImfmzaVdpComSGmrcaCIW/pWiINu0x5siLdIBcffgAN+v99WxqnYipb3t4ctz4I86kIWhyNFp/H3bLRPnn/JPGLLBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iB+tcl+1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iB+tcl+1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730885342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ejx68tuVg9mOD/4Icv7MBobbv6b7kreS3ffjJVREaDU=; b=iB+tcl+1AEaOuyaVACays+4G27L/FXGrXL2dIbuCiqxKb1V5xuW0i/yjHNXzMTcdHe1E+b PWni14ixHNeddukW9H0Tzo6ukUoP646w2iZ1n9jCmyQMDM6ZDI8Swg/CEnelnZ77vfDwRN 1hmqSy9qpt2Y32oC5YzzpsWlc64I1u0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-158-ZpThGegVPcum2FzmbteOEw-1; Wed, 06 Nov 2024 04:29:00 -0500 X-MC-Unique: ZpThGegVPcum2FzmbteOEw-1 X-Mimecast-MFC-AGG-ID: ZpThGegVPcum2FzmbteOEw Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43159c07193so55155175e9.0 for ; Wed, 06 Nov 2024 01:29:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730885339; x=1731490139; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ejx68tuVg9mOD/4Icv7MBobbv6b7kreS3ffjJVREaDU=; b=vELXD4gHVHOsPj6aEil7B1+0s1nA5J2TCgFkQjhv7y0C7rPHCb0sxXdP99uDOgRUqd 67VuxQkAxl1OjF5YsRLT0XrygufvGTo4opmd1GDck+k9DwVCB0BxFvsu9Ge1cbMCZ85Z 1F9K6bPQR7+iBbgS/fpd72mnE6ub8z7Qw5hQlAZot3orUmIG2mRXyDe38LnN1YWfStS+ eUke9Rt3yAvUd8Fgh+ofbdq0HutnPwTCpD+tP/iDnaOgkrkcW4JMllCJZfkpnQxaW76J sudZws8zxxdPE9O2eMn6amANDrRSZLfDiv0QmVK2uUYeEqWf4fuWR8RJE7LJq7hujQe/ PKEg== X-Forwarded-Encrypted: i=1; AJvYcCVO7uE8QFUU45FNMc73o0f7FG0wg9YxH+JcKdVaRuThJkq6pTStwQph3WgfrhmWa3Vey1aNugmBzS0OpPkNhQ==@lists.linux.dev X-Gm-Message-State: AOJu0YzVL+r7BaMktG5gdXkagBrUQXoSpNxnit0rM4G5SSqvLwxAEqQe e0kLLW2wdz0qLAx8LBebfhj8eQSZHRtD0K9hwAGpqZ66G7S/Dp7x0R3fVmo9Su2FXf35Pc/evBp D6bpG1YYWwN3BDN7+r9FUQjM4UUQxmQ/NPPFYFQyXb5qmaYVMRlcC8yYu5tkFsf1Q X-Received: by 2002:a05:600c:4689:b0:431:52a3:d9d5 with SMTP id 5b1f17b1804b1-432831cb9demr222901255e9.0.1730885339663; Wed, 06 Nov 2024 01:28:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWjjkdr5r4V7Q+Qj0G1hCbvfLQeB4lT/9xr2DmAO0MVtWQKCdBKQf0iOb506nFA0FTNUYXlA== X-Received: by 2002:a05:600c:4689:b0:431:52a3:d9d5 with SMTP id 5b1f17b1804b1-432831cb9demr222900675e9.0.1730885339211; Wed, 06 Nov 2024 01:28:59 -0800 (PST) Received: from redhat.com ([2a02:14f:178:e74:5fcf:8a69:659d:f2b2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432aa5b60cfsm15505215e9.7.2024.11.06.01.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 01:28:58 -0800 (PST) Date: Wed, 6 Nov 2024 04:28:53 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: qiang4.zhang@linux.intel.com, Paolo Bonzini , Stefan Hajnoczi , Eugenio =?iso-8859-1?Q?P=E9rez?= , Xuan Zhuo , Jens Axboe , Olivia Mackall , Herbert Xu , Amit Shah , Arnd Bergmann , Greg Kroah-Hartman , Gonglei , "David S. Miller" , Viresh Kumar , "Chen, Jian Jun" , Andi Shyti , Andrew Lunn , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "James E.J. Bottomley" , "Martin K. Petersen" , David Hildenbrand , Gerd Hoffmann , Anton Yakovlev , Jaroslav Kysela , Takashi Iwai , Qiang Zhang , virtualization@lists.linux.dev, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-i2c@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-sound@vger.kernel.org Subject: Re: [PATCH v2] virtio: only reset device and restore status if needed in device resume Message-ID: <20241106042828-mutt-send-email-mst@kernel.org> References: <20241031030847.3253873-1-qiang4.zhang@linux.intel.com> <20241101015101.98111-1-qiang4.zhang@linux.intel.com> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: atPR9F5oDYZRi6zJxUdAVvmcspy72lJ_Ayh5w46yywQ_1730885340 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Nov 01, 2024 at 10:11:11AM +0800, Jason Wang wrote: > On Fri, Nov 1, 2024 at 9:54 AM wrote: > > > > From: Qiang Zhang > > > > Virtio core unconditionally reset and restore status for all virtio > > devices before calling restore method. This breaks some virtio drivers > > which don't need to do anything in suspend and resume because they > > just want to keep device state retained. > > The challenge is how can driver know device doesn't need rest. I actually don't remember why do we do reset on restore. Do you? > For example, PCI has no_soft_reset which has been done in the commit > "virtio: Add support for no-reset virtio PCI PM". > > And there's a ongoing long discussion of adding suspend support in the > virtio spec, then driver know it's safe to suspend/resume without > reset. > > > > > Virtio GPIO is a typical example. GPIO states should be kept unchanged > > after suspend and resume (e.g. output pins keep driving the output) and > > Virtio GPIO driver does nothing in freeze and restore methods. But the > > reset operation in virtio_device_restore breaks this. > > Is this mandated by GPIO or virtio spec? If yes, let's quote the revelant part. > > > > > Since some devices need reset in suspend and resume while some needn't, > > create a new helper function for the original reset and status restore > > logic so that virtio drivers can invoke it in their restore method > > if necessary. > > How are those drivers classified? > > > > > Signed-off-by: Qiang Zhang > > Thanks