Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp228725pxj; Wed, 23 Jun 2021 20:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxveP1mXX8oN3j79sMw9s60vGOgsFI8QMWkNPuXiE0l9rQsRrsaGLHxP8JCt5hjNoxABDuf X-Received: by 2002:a05:6602:188:: with SMTP id m8mr2274783ioo.201.1624505783715; Wed, 23 Jun 2021 20:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624505783; cv=none; d=google.com; s=arc-20160816; b=jtf+0ukdBXvRxKIl1CQkvlvURz85PpmU4sZQ0k2RIzd+jSwsTm+AFikHdgPa1EGkCe JVlZwsPipuXuWP/vzTs6gAr6/oZD4ePqUFo9J8cjACpt81DQQKf9a+jpoVNxxhAjpagJ CcCyiKxcUdHsFgchVE+ZGJqND4p/pdMVtmWMwFXE3EzDVvGE9F3sSsHPDZ572MPHoX2H TFiQsBCkh5fNDQ0IWca9dqIlJYFKe0dkkINoIPa1EfDg1eK0spdoW9qQqhCP3ECii0Jj SShJN9+/f4EWbffVY1KfbUwxF1uL0owQCGnwexm6zxBOKq1YMhH/rHU8mSr9smmE4x/M S85Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=5QohIO9QZ56POeZsL8ywMd6mageIeyr6m/mT20FPwPo=; b=UMgvqCsU7rWP6ZqnXcN+p7mAjc+iY0Fz3KVTuqDOLpMqmFAXFGQrm2tg23Nc5Hdrdg 6ODHWIel/YYj+jVFbdcjF+4mnQMTCV4VTFi+gzcprqhucZIiGsUpyiXBSR29ZNAETesH 3bwa8rXlz220LffCI3Jv5ZbgRXPUUm5D6KjafBbdBd5qHqJtzjMrbtL7xm3olUgfau9B XLtWIhMnqPJaZIx5ZfpXKkHgiV3U25Eh3Xad4VDJ8NmMIsc8FcAwDr0ay3MgwScJEm7d 2XJdJPfqGnSJ5+pmMwrNlvR16gbP6IKM749OJyWO0XprJD5j2eiY4hkqY8BG0NFaTNcu J30g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IvnMUpI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si1622792ilv.85.2021.06.23.20.36.11; Wed, 23 Jun 2021 20:36:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IvnMUpI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbhFXDhX (ORCPT + 99 others); Wed, 23 Jun 2021 23:37:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23343 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhFXDhU (ORCPT ); Wed, 23 Jun 2021 23:37:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624505701; 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=5QohIO9QZ56POeZsL8ywMd6mageIeyr6m/mT20FPwPo=; b=IvnMUpI8ARjUQ2px4raVHAzkZtw8Xe8nNM9kftL3XfBjKTJcrecktPUp7p9IcpR5MXDNGR DE5AgIzEme5gS3gO8raxa67tqctDueaqX9ZfAub2jdg0bSe8pbw5yfGlIiIvz+ic3rtRao E5g34nLDd19n6b7XaBsRfiqUYH2+tX8= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-Ya7Chmu6MqSbEfOWbdWPlQ-1; Wed, 23 Jun 2021 23:35:00 -0400 X-MC-Unique: Ya7Chmu6MqSbEfOWbdWPlQ-1 Received: by mail-pf1-f200.google.com with SMTP id i13-20020aa78b4d0000b02902ea019ef670so3106144pfd.0 for ; Wed, 23 Jun 2021 20:34:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=5QohIO9QZ56POeZsL8ywMd6mageIeyr6m/mT20FPwPo=; b=IjH+HP21PsgSAdPtkgFXPjng2vRR7eZxnq1VmloJ8f9w3vq8YXB+wWy1+h8jXAM00B x2CdfroSbrjdj7cqAaQsLq8tDXYenHLQSd/VHTC/88AHHfims6y+lmQOVj21CdPvbYA5 2zrs555+2tP1677XszM3Y0CPQWHl5IjVX7ROlcBuatmZSBFKebZW3oDB6VM+E3JaA0Dc 9l5u2yt8koZU7sc56IuQiSmFv79mcTM7ojzVUOby+sWiViJmz7ZZXcPMlMBffpig9jBO 817448QTmI5/fEUwWH+3DG9Mc8p9Qx9oxMm+11SuM/BX91Lq/ZjDdRGtta6x1IcRWRkz UEiw== X-Gm-Message-State: AOAM532K6Vcx7DKSq4C9HEbgheUZTORFwsGn7xzVl7l7209RGXrNwFq/ LNKN48GVb7pE09HE2zKsuwUgKLPaDM+Wl+MivN5GbYI/Mv7uDJmwyqYsnq7qHEFJ8JW3yds2V1v 3Gi5tiPu+Rk9IkTzV+5sxuVmnY8m/p40O6jkTZ4VOdQ5uBlp/wPSIACCwPZp3y/CEOGs7kJeWD4 CT X-Received: by 2002:a17:90b:1191:: with SMTP id gk17mr2989122pjb.95.1624505698754; Wed, 23 Jun 2021 20:34:58 -0700 (PDT) X-Received: by 2002:a17:90b:1191:: with SMTP id gk17mr2989081pjb.95.1624505698416; Wed, 23 Jun 2021 20:34:58 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a15sm1101133pff.128.2021.06.23.20.34.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 20:34:57 -0700 (PDT) Subject: Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace To: Yongji Xie Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=c3=a4?= , Dan Carpenter , joro@8bytes.org, Greg KH , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel References: <20210615141331.407-1-xieyongji@bytedance.com> <20210615141331.407-10-xieyongji@bytedance.com> <1bba439f-ffc8-c20e-e8a4-ac73e890c592@redhat.com> <0aeb7cb7-58e5-1a95-d830-68edd7e8ec2e@redhat.com> From: Jason Wang Message-ID: Date: Thu, 24 Jun 2021 11:34:46 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/6/23 下午1:50, Yongji Xie 写道: > On Wed, Jun 23, 2021 at 11:31 AM Jason Wang wrote: >> >> 在 2021/6/22 下午4:14, Yongji Xie 写道: >>> On Tue, Jun 22, 2021 at 3:50 PM Jason Wang wrote: >>>> 在 2021/6/22 下午3:22, Yongji Xie 写道: >>>>>> We need fix a way to propagate the error to the userspace. >>>>>> >>>>>> E.g if we want to stop the deivce, we will delay the status reset until >>>>>> we get respose from the userspace? >>>>>> >>>>> I didn't get how to delay the status reset. And should it be a DoS >>>>> that we want to fix if the userspace doesn't give a response forever? >>>> You're right. So let's make set_status() can fail first, then propagate >>>> its failure via VHOST_VDPA_SET_STATUS. >>>> >>> OK. So we only need to propagate the failure in the vhost-vdpa case, right? >> >> I think not, we need to deal with the reset for virtio as well: >> >> E.g in register_virtio_devices(), we have: >> >> /* We always start by resetting the device, in case a previous >> * driver messed it up. This also tests that code path a >> little. */ >> dev->config->reset(dev); >> >> We probably need to make reset can fail and then fail the >> register_virtio_device() as well. >> > OK, looks like virtio_add_status() and virtio_device_ready()[1] should > be also modified if we need to propagate the failure in the > virtio-vdpa case. Or do we only need to care about the reset case? > > [1] https://lore.kernel.org/lkml/20210517093428.670-1-xieyongji@bytedance.com/ My understanding is DRIVER_OK is not something that needs to be validated: " DRIVER_OK (4) Indicates that the driver is set up and ready to drive the device. " Since the spec doesn't require to re-read the and check if DRIVER_OK is set in 3.1.1 Driver Requirements: Device Initialization. It's more about "telling the device that driver is ready." But we don have some status bit that requires the synchronization with the device. 1) FEATURES_OK, spec requires to re-read the status bit to check whether or it it was set by the device: " Re-read device status to ensure the FEATURES_OK bit is still set: otherwise, the device does not support our subset of features and the device is unusable. " This is useful for some device which can only support a subset of the features. E.g a device that can only work for packed virtqueue. This means the current design of set_features won't work, we need either: 1a) relay the set_features request to userspace or 1b) introduce a mandated_device_features during device creation and validate the driver features during the set_features(), and don't set FEATURES_OK if they don't match. 2) Some transports (PCI) requires to re-read the status to ensure the synchronization. " After writing 0 to device_status, the driver MUST wait for a read of device_status to return 0 before reinitializing the device. " So we need to deal with both FEATURES_OK and reset, but probably not DRIVER_OK. Thanks > > Thanks, > Yongji >