On Fri, Dec 12, 2025 at 04:35:08PM +0100, Matias Ezequiel Vara Larsen wrote:
> > > +
> > > + priv->can_ctr_msg.cpkt_out.msg_type = cpu_to_le16(msg_type);
> > > + sg_init_one(&sg_out, &priv->can_ctr_msg.cpkt_out,
> > > + sizeof(priv->can_ctr_msg.cpkt_out));
> > > + sg_init_one(&sg_in, &priv->can_ctr_msg.cpkt_in,
> > > sizeof(priv->can_ctr_msg.cpkt_in));
> > > +
> > > + err = virtqueue_add_sgs(vq, sgs, 1u, 1u, priv, GFP_ATOMIC);
> > > + if (err != 0) {
> > > + /* Not expected to happen */
> > > + dev_err(dev, "%s(): virtqueue_add_sgs() failed\n", __func__);
> > > + mutex_unlock(&priv->ctrl_lock);
> > > + return VIRTIO_CAN_RESULT_NOT_OK;
> > > + }
> > > +
> > > + if (!virtqueue_kick(vq)) {
> > > + /* Not expected to happen */
> > > + dev_err(dev, "%s(): Kick failed\n", __func__);
> > > + mutex_unlock(&priv->ctrl_lock);
> > > + return VIRTIO_CAN_RESULT_NOT_OK;
> > > + }
> > > +
> > > + while (!virtqueue_get_buf(vq, &len) && !virtqueue_is_broken(vq))
> > > + wait_for_completion(&priv->ctrl_done);
> > > +
> >
> > Since the call is synchronous, does can_ctr_msg really need to be part
> > of priv? Cannot be it allocated from the stack?
> >
>
> I tried to allocate in the stack but the guest blocks when during `ip
> link set up can0`, any idea?
you can not DMA to/from the stack, really.
--
MST