Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5250860ybg; Tue, 22 Oct 2019 00:05:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwR0g5aUc4gklrD6i8HStzdFOG9SPqCFRrjJv+W0Qshav4Mhubb7gz0vqITgIqHoJpYJn23 X-Received: by 2002:a17:906:3009:: with SMTP id 9mr26124564ejz.124.1571727938808; Tue, 22 Oct 2019 00:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571727938; cv=none; d=google.com; s=arc-20160816; b=a08FY6IbwzM57tBxs+rG+ZcuO2oVvoWDiSWQVHByw/yhr836YId6+SdZVJv8dg/tOl 0RUpwDDRTFTUSOcozjlhUjr4zWm0LWEqjt8Y7+/+6NqoV5M4ZsoN0vFv8A/6ms+dJWgA 7DdprC4l0tta8irTqv7zjeRQCATP9heVBzPPQNrfhX7Hxf1JfKURXUFsTZVTwaY0U/Nr 8roNtZYtHMPcaxXe+uQmo9YTZJ0yqWQVcNxplsQ6LWyjUHZJGQgcgHZq2aFnbUYb/9bJ jWEX1xG1SE/KFMK/UP6tU5N3pjfHkM+mJFacm7XDovItIrpfW45GdH9pEM3qcXv78Qb2 u7lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=G/Y9DIUUGkFN+j1xezD2zyDUUgAeWd8Ja7i34Rz87tw=; b=zrWGlkTYzJi4/EBxx163jlu7Zg8s3I9v5WqXa2cLi6OOYVo1CEvjxxa58W7UG8GMGE IRjkmL4vaRRAXvActXetm3437Ye5rkXXj3SLiVjMyynYsjsIiwWj9S+0lDiMXZ3Mv2Zg hd3ThTGdY1UIicR+wON0qzg9XzuZfL3XLh/ck4/VgxiIb/zc+4erdRLjAin387MT28z0 s/sOeuf70tg/fANc9lym4N3dizPeNEpDZagrRFw46agJVZLJH2/nr0LEVgZzTbkYorT2 z1v3oMFr+GmPTb88vXQSuSpwDeP/yBrXGrGCCVCH0KYx6uIPYdAVAY4xxdUGYg6mh/US x00A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si10029523ejr.180.2019.10.22.00.05.14; Tue, 22 Oct 2019 00:05:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387754AbfJVGsu (ORCPT + 99 others); Tue, 22 Oct 2019 02:48:50 -0400 Received: from mga14.intel.com ([192.55.52.115]:21797 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbfJVGst (ORCPT ); Tue, 22 Oct 2019 02:48:49 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 23:48:49 -0700 X-IronPort-AV: E=Sophos;i="5.67,326,1566889200"; d="scan'208";a="191365233" Received: from lingshan-mobl5.ccr.corp.intel.com (HELO [10.238.129.48]) ([10.238.129.48]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Oct 2019 23:48:45 -0700 Subject: Re: [RFC 1/2] vhost: IFC VF hardware operation layer To: Jason Wang , Simon Horman , "Zhu, Lingshan" Cc: mst@redhat.com, alex.williamson@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org, dan.daly@intel.com, cunming.liang@intel.com, tiwei.bie@intel.com, jason.zeng@intel.com, zhiyuan.lv@intel.com References: <20191016011041.3441-1-lingshan.zhu@intel.com> <20191016011041.3441-2-lingshan.zhu@intel.com> <20191016095347.5sb43knc7eq44ivo@netronome.com> <075be045-3a02-e7d8-672f-4a207c410ee8@intel.com> <20191021163139.GC4486@netronome.com> <15d94e61-9b3d-7854-b65e-6fea6db75450@redhat.com> From: Zhu Lingshan Message-ID: <1f468365-4fe4-b13f-0841-cc5a60a8fe41@linux.intel.com> Date: Tue, 22 Oct 2019 14:48:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.0 MIME-Version: 1.0 In-Reply-To: <15d94e61-9b3d-7854-b65e-6fea6db75450@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/22/2019 9:32 AM, Jason Wang wrote: > > On 2019/10/22 上午12:31, Simon Horman wrote: >> On Mon, Oct 21, 2019 at 05:55:33PM +0800, Zhu, Lingshan wrote: >>> On 10/16/2019 5:53 PM, Simon Horman wrote: >>>> Hi Zhu, >>>> >>>> thanks for your patch. >>>> >>>> On Wed, Oct 16, 2019 at 09:10:40AM +0800, Zhu Lingshan wrote: >> ... >> >>>>> +static void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset, >>>>> +               void *dst, int length) >>>>> +{ >>>>> +    int i; >>>>> +    u8 *p; >>>>> +    u8 old_gen, new_gen; >>>>> + >>>>> +    do { >>>>> +        old_gen = ioread8(&hw->common_cfg->config_generation); >>>>> + >>>>> +        p = dst; >>>>> +        for (i = 0; i < length; i++) >>>>> +            *p++ = ioread8((u8 *)hw->dev_cfg + offset + i); >>>>> + >>>>> +        new_gen = ioread8(&hw->common_cfg->config_generation); >>>>> +    } while (old_gen != new_gen); >>>> Would it be wise to limit the number of iterations of the loop above? >>> Thanks but I don't quite get it. This is used to make sure the function >>> would get the latest config. >> I am worried about the possibility that it will loop forever. >> Could that happen? >> >> ... > > > My understanding is that the function here is similar to virtio config > generation [1]. So this can only happen for a buggy hardware. > > Thanks > > [1] > https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html > Section 2.4.1 Yes! > > >> >>>>> +static void io_write64_twopart(u64 val, u32 *lo, u32 *hi) >>>>> +{ >>>>> +    iowrite32(val & ((1ULL << 32) - 1), lo); >>>>> +    iowrite32(val >> 32, hi); >>>>> +} >>>> I see this macro is also in virtio_pci_modern.c >>>> >>>> Assuming lo and hi aren't guaranteed to be sequential >>>> and thus iowrite64_hi_lo() cannot be used perhaps >>>> it would be good to add a common helper somewhere. >>> Thanks, I will try after this IFC patchwork, I will cc you. >> Thanks. >> >> ... >