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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 D85BBC4332F for ; Mon, 6 Sep 2021 06:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6F3C60F92 for ; Mon, 6 Sep 2021 06:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239458AbhIFGiS (ORCPT ); Mon, 6 Sep 2021 02:38:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49055 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239400AbhIFGiQ (ORCPT ); Mon, 6 Sep 2021 02:38:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630910231; 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=NwUBcFLW2DErKP8nW3thbj1Bfk3yLnGU+eP2iS4eEBM=; b=R+H8Np+vTCVl4xtIk6PKqlDWDsqZxr7sUAVikNbQWsoRDVQ1GX8oAxJdbso0RPq4OhAevn 91O+Q64e2mjUFqHqqZZ78eF+BdPBGdWWWWZTJT6dOt0oVS1OnhrVrG8eg+43I+eFCG2J/U LRI+LURSjylrl/aw9X8HDWSPU9sOCJE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-a_S8BS1rNiyIpoeCE5dnxQ-1; Mon, 06 Sep 2021 02:37:11 -0400 X-MC-Unique: a_S8BS1rNiyIpoeCE5dnxQ-1 Received: by mail-wm1-f70.google.com with SMTP id s197-20020a1ca9ce000000b002e72ba822dcso3499952wme.6 for ; Sun, 05 Sep 2021 23:37:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NwUBcFLW2DErKP8nW3thbj1Bfk3yLnGU+eP2iS4eEBM=; b=CkhGQH+/QCEa8M/+tbckTynadAhNgoa7uDxkc3GZKyi23vsaS4+Gr1/PhBI/31Yjgq C0HbBQFK/Vs+6wLx3pcd4gbiQk75n/2jE0YE2qJhLF2vHSx81Sv5samVq53i+0uk+M1V X6vJHNJFjWtyzBiMo+LH93SV6zHtC0QLYyr7wgKWbTW4S8AM+ESNnZ7P/gmI9lM18G97 fwFlkh7PPO4F+8H0xQPTubXmW2ZkYOqxCHvD1AN+ovfApRCoWrDOyfaQ+Eg50B2si7qj TCAMfBetiMdushROjt8lembzArxtIIN9BCDcSmTlkSQq7Qwrat8D5FkM+vq0JLcLf0em lFCA== X-Gm-Message-State: AOAM533YAHuEHdCAy4C3J8Yk3nX0/eNkIqe3Zo1aZJE8cVV+I0odFZiv uQKN7HGN48jYCt5sljt4WPj5uoA2EwTaEeYc+2JUmpWrQDen5rzMYdm6mO6fO5b+Bs/rUrPeeUz lj2Tav89Esoj+ X-Received: by 2002:a1c:1f8e:: with SMTP id f136mr9990694wmf.132.1630910229766; Sun, 05 Sep 2021 23:37:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRCwrPqlTT9EQxN6i2JahNEijC2yzlB8bw+tqErn2HIqi0obsj9A8iduK7E+CvdT1s7MMNSQ== X-Received: by 2002:a1c:1f8e:: with SMTP id f136mr9990653wmf.132.1630910229544; Sun, 05 Sep 2021 23:37:09 -0700 (PDT) Received: from redhat.com ([2.55.131.183]) by smtp.gmail.com with ESMTPSA id g1sm8586151wrb.27.2021.09.05.23.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Sep 2021 23:37:08 -0700 (PDT) Date: Mon, 6 Sep 2021 02:37:03 -0400 From: "Michael S. Tsirkin" To: Yongji Xie Cc: Jason Wang , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , Mika =?iso-8859-1?Q?Penttil=E4?= , Dan Carpenter , joro@8bytes.org, Greg KH , He Zhe , Liu Xiaodong , Joe Perches , Robin Murphy , Will Deacon , John Garry , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel Subject: Re: [PATCH v13 05/13] vdpa: Add reset callback in vdpa_config_ops Message-ID: <20210906023131-mutt-send-email-mst@kernel.org> References: <20210831103634.33-1-xieyongji@bytedance.com> <20210831103634.33-6-xieyongji@bytedance.com> <20210906015524-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Sep 06, 2021 at 02:09:25PM +0800, Yongji Xie wrote: > On Mon, Sep 6, 2021 at 1:56 PM Michael S. Tsirkin wrote: > > > > On Tue, Aug 31, 2021 at 06:36:26PM +0800, Xie Yongji wrote: > > > This adds a new callback to support device specific reset > > > behavior. The vdpa bus driver will call the reset function > > > instead of setting status to zero during resetting. > > > > > > Signed-off-by: Xie Yongji > > > > > > This does gloss over a significant change though: > > > > > > > --- > > > @@ -348,12 +352,12 @@ static inline struct device *vdpa_get_dma_dev(struct vdpa_device *vdev) > > > return vdev->dma_dev; > > > } > > > > > > -static inline void vdpa_reset(struct vdpa_device *vdev) > > > +static inline int vdpa_reset(struct vdpa_device *vdev) > > > { > > > const struct vdpa_config_ops *ops = vdev->config; > > > > > > vdev->features_valid = false; > > > - ops->set_status(vdev, 0); > > > + return ops->reset(vdev); > > > } > > > > > > static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features) > > > > > > Unfortunately this breaks virtio_vdpa: > > > > > > static void virtio_vdpa_reset(struct virtio_device *vdev) > > { > > struct vdpa_device *vdpa = vd_get_vdpa(vdev); > > > > vdpa_reset(vdpa); > > } > > > > > > and there's no easy way to fix this, kernel can't recover > > from a reset failure e.g. during driver unbind. > > > > Yes, but it should be safe with the protection of software IOTLB even > if the reset() fails during driver unbind. > > Thanks, > Yongji Hmm. I don't see it. What exactly will happen? What prevents device from poking at memory after reset? Note that dma unmap in e.g. del_vqs happens too late. And what about e.g. interrupts? E.g. we have this: /* Virtqueues are stopped, nothing can use vblk->vdev anymore. */ vblk->vdev = NULL; and this is no longer true at this point. -- MST