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=IX+tISJMVkdvcmM/1ELKQXUIdst/W0JDZpWCe0Z8Ia020VQoSsSaiAxj9JEKt1PaLiTb SFodi+exDiE34cyY8l0M4aptJDQ1rGZZ28RoQEMwpfeOQV58BnS3/wfhyxM3ATDQpN/SG g/UFV3rhPeB1lVHS4aFohaKebEV1Eak1nWoT+CsiXS8cex/YDUnLPF4aCaPcKdUwAefyG xZc+0yOvm/9XbG50WWYpwo7Ey5UctQzIkDVtHIdtzGlfk8Q8c9dpv1P46PsS47CRvuuXt s3JGy4HJeBP85tjnPvlxXSTwvsUgXh5AljEU2IF2NTe2N7oMi23DNUjgJoDCRs0gYKA== 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=ec8zsKba5ji132Q7JTE0jVHg5LAniwIkFE274UBfeJan8ihygyWL6RSvAv0fBTyEmE/T mKgy8SqwphtwExWE/y0YYAOrC0MKIjsrJjJs6kTjJHEmUiqQPYK5acGCImCwtuTIsz1LJ QGtt2WRzfNvhZBxBEO3I4h2eaSdZMyTsYCE3YMUlCJL5AfMHlMT/f4OuoruebRq80LWq+ FNF9WrtU6MSu1mmshUQyd/LaRrxL5adXYyDRKJNrpe1tnwncv5ZEZikCvMkiL8ikb97EV KonEfbFHqylktMXT2U//1GFyYqerCw0HkDMNFVVenBly7YenAsEye6+kHSOJZX6g7Kw== 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 61DBF606A32C for ; Thu, 3 Dec 2026 08:48:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61DBF606A32C 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-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446-brH2YsXwODiEO0syEOnzgQ-1; Thu, 3 Dec 2026 08:48:13 +0000 X-MC-Unique: brH2YsXwODiEO0syEOnzgQ-1 X-Mimecast-MFC-AGG-ID: brH2YsXwODiEO0syEOnzgQ_1796287692 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-49d70f45b22so8961997f8f.2 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=luQc1BmmEQaVTI8iKyrzTYCOgE8UzndLAcLjHWhibeR4MyBkrc7SvJo0PDpccDfpaU a6z+cBlIrsjZQgaslUJ2uC++3Jyy8IRZ1i0ilna6TQVWN7MqVN2LIbvxJKKL9Sa9zfT/ 6WIONazNCEDkFe2xJL2kRB2IWiN/Uo48HT0PDI1Qp9a9Yo5ogzIk0hChFBOL81mgpqhc wLufptLRoRoLdbxzm6THm6tYw2hCi3e27S2JJItiOJO++60fpFRm23WfzsOWLy3TFSRn SbDeHQPCqW9kQlYsreFEu3k00XlMXsgsPrDAd2xAJmX31yP6e9KGw1+/QF6f67/2K1aK 1cpA== X-Forwarded-Encrypted: i=1; AL+hErHn/L7bqhR1whuXbG+TtJGHsli75Js/EBM9yij2njz8Ee7NatUNwRSqsvrWyltnI07Aosry6eCEAjbefzg=@vger.kernel.org X-Gm-Message-State: APuU4Z9jFhZWfBD3muiqRsSpCVlcsxTHLtPgca35To9bM6byIS2C6gFY K2j/xXO/Mo+7j3zMsjq/0NJc4hhO3XyPwF4eSBuuZgeidljMH99DZMMjhIZ3y5Y57mJC7Zx7jnn AaIWOwJA2koyp/6ko9UUVJeagBGodFcj/VEh8uNqeAksvRu/RAgPlUpcTjz1nCYCXWQ== X-Gm-Gg: AZFdTZf3hK4v8RCjLIOMESnXpn0LjvZGDxbVBgKo4p6SNfn4YBUFE9SnmPilxlvNETN bSaq3Q+LKKLxqWMPH7pvzG4Dfj3hL/B1/acwWtr/UyBPoGBPjtX2bMQOsCmO4/4VLyfvb+K5wFZ u2WLhBcHk2GVEDwkBz5YdF2R4LwSUhnJP+ButMdtONiQdypk6jYDls4P8KrPGc4Fs4pYOBYEtSH c2wP313te6+e2plO7Ij2COs9CwZWoqTWUcbFo29N4Bk3o4165QiHgth/DiURC2lGTxSozFqGJP/ 4H2DBSbr8iEnKuw6TCiqtTYqGKBa9o588W2ZfglF/SAPVpxO4UPMT4a+hSpq+Mf0AfrsBHUm7m9 zJT/tfimPaRwbd2WmdvFTNExkDk90Ug2FBN0D8/Sd2Q== X-Received: by 2002:a05:600c:8b83:b0:4a3:59c9:a747 with SMTP id 5b1f17b1804b1-4bb8880642cmr804708875e9.17.1796287692164; 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-kernel@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 >