From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796287702; b=C+g3QyebYATt59qWn9uK986neh1NzvFY6fV1uKFHoYmwlLlAvpRkWqCOHANBcqihn+fU /Bj5c7/20UCC/BTBoOrViPmhVjRv+vd6hJenOiqr4jxmvSJvOrkknkhwPM2hdBwOz/ptd 5305aNejzs66Jvs0Ojoyr4I6r/B9nFEfK126ubmoaUC2TGaV1CFG8OjANhQ+glyqU3Ijb bfl5LLilxZH/T7uf2ksExipXak1Ovm3lDJU+PBXHCHYLVrbsXyeltbKJNV8oc6tLZABBU hFZ6AVqJjPk1edu2O7UVFN4JSVuSe4OYSn9bTol6RyqI/RvCz6ebKKD9ROdRq69mjsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796287702; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=z/3I5BzNlMe6DfT3rFBIADki47Re3waPREVo+9CV0ek=; b=Xt4wm68FZ2ph5NQ8bfq6zDp8ewhRF9SfZkFOpmjdHJgCfqmoGzdtDbEu70w5cWlMu0bd t/PS65USEjaDEM5lFi1XHwAyL/V38cMd6plPzLhvIEPaafMMgt7Y9XervmSWQ4jtPQ3cF O8OpzxKWUGqqccgxt5yjNdePcVfyJ6bSAyuzAE/Dlr1cNIfbvspa2oZV/Gd1OnI9sTN1G 6DR2EY0/URre+zxMoFLEq4S48K3hr4f6jKvq0XxCb/hsdKDFLMfuVUASNdLDc0YSWzI0v y6Wo9dbB2mmJRJ1u80EEVop25IJ+K1alqNVBPiXM3QVLYd5iIdzeBZVdUpxlz+UTHCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X9JcluhN; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=BVev8Wex; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 295FE606A322 for ; Thu, 3 Dec 2026 08:48:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 295FE606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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.a=rsa-sha256 header.s=mimecast20190719 header.b=X9JcluhN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=BVev8Wex DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796287701; 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: in-reply-to:in-reply-to:references:references; bh=z/3I5BzNlMe6DfT3rFBIADki47Re3waPREVo+9CV0ek=; b=X9JcluhNgvZ31NtBG+BXZUM3Rh/2BwVCDGxk+M27azWOq9XU8Y2ZR0mdlvCbuF+8mGf7T3 HDGdM5+osVVUE1AmOQ//5vfQFz4nL7OcGEjKzz8ayGmSEyDJXkY3/3T4uf3sftK+ISWxnQ 8uphShCY0aEVIp/uW09rvr3ZjpKWCZg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-1m2OoBwYMMCY3vgcYZmP6Q-1; Thu, 3 Dec 2026 08:48:13 +0000 X-MC-Unique: 1m2OoBwYMMCY3vgcYZmP6Q-1 X-Mimecast-MFC-AGG-ID: 1m2OoBwYMMCY3vgcYZmP6Q_1796287692 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4bb64c99bb8so120572355e9.1 for ; Thu, 03 Dec 2026 00:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796287692; x=1796892492; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=z/3I5BzNlMe6DfT3rFBIADki47Re3waPREVo+9CV0ek=; b=BVev8Wex/w4xQ2bz5Fg7S2hdR0qNuYHdjOJtmvKhWoEB1xekFm+eIBj/AarPlQ24Du Anedtad9rKXNntLOQt9UBg1WbL5HlMW0HkqI587OCE3wuUR+L7fMjYtLKsiQqS+xtH9p CMLjnLxfwoH6d6wUuD0ERU1IJ1lAYIMnwdVawTdcauv3N7yUGxwb79Y883kWwk0N+cvc 15FkIHZ1HCnM0r7Z9PfsnpxM+82WAqKF1RAL468FJivix+PhIjx88lgiVm4bXFG+UzHq 8kZiDBPSvIioBp6Lc+udNUePJJKDBKH/Tu4E9LoEAsLx359dO+CW9UNYMA+Pv7DCQFb/ /mHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796287692; x=1796892492; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=z/3I5BzNlMe6DfT3rFBIADki47Re3waPREVo+9CV0ek=; b=qRKW5D6agt2S+okxRCVg175haKUQePsQpePYVZaK9GcRmKhvNo73jD9X89P8BpD/Ai ci/91wNvoVzyBuqzFM46S+pxLdbrmicpYKAq3xllLfPf6kLLQNZG/Lq/5e1KE4pxUA9C j3IH/ZdvUcBz09Q8ACM4eXagMzgKcVC6sR+/TmurrwOFCG2bpUF7qVVMxNCr5+0Jr0j2 l/MAQrdHDw6A8vaBUgrUkdIzStQDMhPWH+7yqSe377MafVSvWqTWXEp1PVipCawe2wul OiSfekSTsX/jUmQv8NO6dr8EPGvPteJEXdmGzJEGnSCSSTXQYPkva5UrdmVFDVY8W/6T IxHg== X-Forwarded-Encrypted: i=1; AL+hErFOAP0Zr+t4ZOkGklKU1VNyNz+6N0aJTIgV1a5avJ8ktgLD04hjejT9oH5jw3GH4P88pFz0FM42+m8=@vger.kernel.org X-Gm-Message-State: APuU4Z97iFPVUs6nqpFzpXNFQfYYEhiNfnpwRklHhDugr/AKZt39Zgt9 aRxLlMM1PjnPbGybFzK0GquPE5K0Cjwkj6/4ev0dwpJ4OsLF6p8uBorZDKLYujeQhv0M4xQfPmz OsJixfbAi0wAHxUQEIn4Q3h4/sDFg5rBIJZzXc0jZtm5moT4SE50eLVZik8CGdw== X-Gm-Gg: AZFdTZejV4yVRlv9sRRHKL0uwiW5eIiMZRe2LUWAoZ+ao+0ABXBrD8fbCo+Zfkv6drn Y2PV1llIQIPE1XP3Cr6CUy/3wjOutv0NjnJtGdXLaNmxE2rT9ohwPYV6cecEkPB7zZ9rkGvREoU YJIG3BVhjhNBuC/u/L43pcqFzhQ55muyXwotSjav9CQzEkEBjIIyRs2R5XA8AEn840DJW4OVfBR 7ay6YAU2Ed66TrPOVRYJcEXJecsUhjJq9esx2nrLi4YcaU0lDE14JETY58X19RKbAoDopJPDZAL ZXH+0MAt+va59mYc4jed9n2/32u3opMIn22aWCpVsZ4FzMW0dJroOnHz71tuzHcfZZ9kXLGk14U 1TVcE9N7zB+RZRZOSVoDjnrBMtJRC4pIr2eZ53dV3Cg== X-Received: by 2002:a05:600c:8b83:b0:4a3:59c9:a747 with SMTP id 5b1f17b1804b1-4bb8880642cmr804708765e9.17.1796287692135; Thu, 03 Dec 2026 00:48:12 -0800 (PST) X-Received: by 2002:a05:600c:8b83:b0:4a3:59c9:a747 with SMTP id 5b1f17b1804b1-4bb8880642cmr804708225e9.17.1796287691613; Thu, 03 Dec 2026 00:48:11 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb906635c7sm805296885e9.2.2026.12.03.00.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 00:48:10 -0800 (PST) Date: Thu, 3 Dec 2026 03:48:07 -0500 From: "Michael S. Tsirkin" To: forfortuna@naver.com Cc: Harald Mommer , Matias Ezequiel Vara Larsen , Marc Kleine-Budde , Vincent Mailhol , Mikhail Golubev-Ciuchea , Francesco Valla , virtualization@lists.linux.dev, linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang , stable@vger.kernel.org Subject: Re: [PATCH v2 2/2] can: virtio: fix virtqueue use before DRIVER_OK Message-ID: <20261203033538-mutt-send-email-mst@kernel.org> References: <20261120-virtio-can-ready-v2-0-0defda2af8cb@naver.com> <20261120-virtio-can-ready-v2-2-0defda2af8cb@naver.com> X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261120-virtio-can-ready-v2-2-0defda2af8cb@naver.com> On Fri, Nov 20, 2026 at 03:56:04PM +0900, Seonghyeon Lim via B4 Relay wrote: > From: Seonghyeon Lim > > virtio_can_probe() and virtio_can_restore() fill the RX virtqueue and > kick it before the device is set DRIVER_OK. The virtio specification > does not allow the driver to notify the device before DRIVER_OK. > > In restore, if the interface was up, virtio_can_open() then sends a > START control message and waits for the reply. DRIVER_OK is only set > by the virtio core after restore returns, so the device may never > handle the request and the wait never completes, which hangs system > resume: > > task:kworker/u4:5 state:D > Workqueue: async async_run_entry_fn > Call Trace: > __wait_for_common > virtio_can_send_ctrl_msg > virtio_can_open > virtio_can_restore > virtio_device_restore_priv > dpm_run_callback > device_resume > > In probe, an ndo_open() right after register_candev() can likewise > send the START message before DRIVER_OK. > > Call virtio_device_ready() before the first virtqueue use in both > probe and restore, as virtio-net does. Config change callbacks are > still deferred by the virtio core until probe or restore returns, and > virtqueue callbacks that arrive before NAPI is enabled are handled in > virtio_can_napi_enable(). > > Fixes: 083082a4e6d8 ("can: virtio: Add virtio CAN driver") > Cc: stable@vger.kernel.org > Signed-off-by: Seonghyeon Lim > --- > drivers/net/can/virtio_can.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/can/virtio_can.c b/drivers/net/can/virtio_can.c > index 9055d7e43235..549e8d789d74 100644 > --- a/drivers/net/can/virtio_can.c > +++ b/drivers/net/can/virtio_can.c > @@ -925,6 +925,9 @@ static int virtio_can_probe(struct virtio_device *vdev) > err = -ENOMEM; > goto on_failure; > } > + > + virtio_device_ready(vdev); > + > virtio_can_populate_rx_vq(vdev); > > err = register_virtio_can_dev(dev); But this means device is now enabled on register failure. You have to reset it on failure then. > @@ -979,6 +982,9 @@ static int __maybe_unused virtio_can_restore(struct virtio_device *vdev) > virtio_can_del_vq(vdev); > return -ENOMEM; > } > + > + virtio_device_ready(vdev); > + > virtio_can_populate_rx_vq(vdev); > > if (netif_running(ndev)) { > > -- > 2.43.0 >