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=-18.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,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 808A0C4320A for ; Wed, 4 Aug 2021 08:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D85C60C3E for ; Wed, 4 Aug 2021 08:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236512AbhHDIbN (ORCPT ); Wed, 4 Aug 2021 04:31:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31443 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236424AbhHDIbM (ORCPT ); Wed, 4 Aug 2021 04:31:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628065860; 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=R+iBXiMp+0i0kwjToWGA8/FOLua2xKY/IasSPwlB2ug=; b=SIOcMys6eqGi4oT1OUGcy7Rk7zFUzXliGyJqrEntREDryOfgYnJqb39Hx9IE3drzoGhEGR hWstrU5OB1MvSvn8P3P7w+kz90G90LOTFjvOjo4zUIrffHN0up8qznCh2nPbKuvXQf5O5y o+o1WzYgo/fiq52H2NCR04A3hKjgZwc= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-554-Za7RWkr3OI-0wlsigVPPzw-1; Wed, 04 Aug 2021 04:30:58 -0400 X-MC-Unique: Za7RWkr3OI-0wlsigVPPzw-1 Received: by mail-pj1-f70.google.com with SMTP id z17-20020a17090ad791b029017763b6fe71so1449338pju.3 for ; Wed, 04 Aug 2021 01:30:58 -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=R+iBXiMp+0i0kwjToWGA8/FOLua2xKY/IasSPwlB2ug=; b=nISZz8rU1w9H/M93RiBGMWrT8nvkqXZOEpOoKVqhxOyCpixRV6orMiF8D4Isd4zUTW k44CPdFHkVQkaVdgWOtfOHiFV/b4YSfKcMy5qKUFnkhO4xOgzyL5wJXM5JCdX4nFXTl+ 9K00xGrCN1h6E4+kF2MCWVxqCk5fLAJJ/CPzk3uqDTxmSnwBcAU59txnE6R06bw1Cr2y kSsunkFL97EtW8naFr9P5SYz3FMgLCEqpJGS15Eowef7MVbfsJT/9T/lcTgT9dXVt3vO BLC0KrlaOllH7DiaPcGgjMZi2GE7A3AuIu20BEdpDF1NsXrUfkHmPiWg7bcna7JVn7oZ mUdQ== X-Gm-Message-State: AOAM530g2W6JOlGmXjV+o0svm9pm8fcvmRL1jmaGeMNjokZfOh16d5AP FMXitavwLUwLWjNHtkJEaffKLp+tboPf7a03/IS1YkrcaQ/iapP9C6iuFzi8qa4SlGegXPg9E/H ZUhWJvlxstbxU X-Received: by 2002:a17:90a:5886:: with SMTP id j6mr27687754pji.34.1628065857833; Wed, 04 Aug 2021 01:30:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnH9lVsulyqPnREH97Ou07tfmz86+gb2/y1eNG5JuTtEooMRamySZ0IC743fc1pY8YcAbbnQ== X-Received: by 2002:a17:90a:5886:: with SMTP id j6mr27687725pji.34.1628065857537; Wed, 04 Aug 2021 01:30:57 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id i14sm2040290pgh.79.2021.08.04.01.30.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Aug 2021 01:30:57 -0700 (PDT) Subject: Re: [PATCH v10 04/17] vdpa: Fail the vdpa_reset() if fail to set device status to zero 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 , He Zhe , Liu Xiaodong , Joe Perches , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel References: <20210729073503.187-1-xieyongji@bytedance.com> <20210729073503.187-5-xieyongji@bytedance.com> <39a191f6-555b-d2e6-e712-735b540526d0@redhat.com> From: Jason Wang Message-ID: <31d11097-dab8-578b-402e-a0e55949ce66@redhat.com> Date: Wed, 4 Aug 2021 16:30:47 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.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: kvm@vger.kernel.org 在 2021/8/3 下午5:31, Yongji Xie 写道: > On Tue, Aug 3, 2021 at 3:58 PM Jason Wang wrote: >> >> 在 2021/7/29 下午3:34, Xie Yongji 写道: >>> Re-read the device status to ensure it's set to zero during >>> resetting. Otherwise, fail the vdpa_reset() after timeout. >>> >>> Signed-off-by: Xie Yongji >>> --- >>> include/linux/vdpa.h | 15 ++++++++++++++- >>> 1 file changed, 14 insertions(+), 1 deletion(-) >>> >>> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h >>> index 406d53a606ac..d1a80ef05089 100644 >>> --- a/include/linux/vdpa.h >>> +++ b/include/linux/vdpa.h >>> @@ -6,6 +6,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> /** >>> * struct vdpa_calllback - vDPA callback definition. >>> @@ -340,12 +341,24 @@ 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) >>> +#define VDPA_RESET_TIMEOUT_MS 1000 >>> + >>> +static inline int vdpa_reset(struct vdpa_device *vdev) >>> { >>> const struct vdpa_config_ops *ops = vdev->config; >>> + int timeout = 0; >>> >>> vdev->features_valid = false; >>> ops->set_status(vdev, 0); >>> + while (ops->get_status(vdev)) { >>> + timeout += 20; >>> + if (timeout > VDPA_RESET_TIMEOUT_MS) >>> + return -EIO; >>> + >>> + msleep(20); >>> + } >> >> I wonder if it's better to do this in the vDPA parent? >> >> Thanks >> > Sorry, I didn't get you here. Do you mean vDPA parent driver (e.g. > VDUSE)? Yes, since the how it's expected to behave depends on the specific hardware. Even for the spec, the behavior is transport specific: PCI: requires reread until 0 MMIO: doesn't require but it might not work for the hardware so we decide to change CCW: the succeed of the ccw command means the success of the reset Thanks > Actually I didn't find any other place where I can do > set_status() and get_status(). > > Thanks, > Yongji >