Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp615092ybg; Wed, 23 Oct 2019 03:14:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOVpUXsE/4UphbPey67Yh3WvvPuriDlmi73VGzlV+yVljD9FhNMhP3Ob+lv3qAi3ll7zuS X-Received: by 2002:a17:906:9504:: with SMTP id u4mr10915446ejx.317.1571825693003; Wed, 23 Oct 2019 03:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571825692; cv=none; d=google.com; s=arc-20160816; b=RaJyuPwKhcf6Um5rCO+m6BxWlCRn6JcMkgl26Ez2DD0igF542X3ZUj1bHAJn/2ICRL OD5x4e17G/klj0DUZfBCcY6o32e3mAy4j1EGXSZ35Uruz5GUSNOcz1BLIzzyZVhDNZFC iYo8WAttuyuJV31zDDFic/D7Dn6TpgMsL5ii4eB6/66v+4tD0cK2loJK7i/yrJgcyktp pfjdInw9UM6PCgj3HBV+ldmkeYGo6pgR1RYlvCqArQYro8yePtpoL9knuzPCdwiddA1R /gHLLwAnjZGVqTM0Ro+lw5ZmqtRiC8Ze+IdisJe9nEk/lyi0IDXgMD6L/UaBeQgIVAT+ yxMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ORDM/VOBs1fIrp01I0A5xms2tGNpKSAd1TbHc1PkN5w=; b=a/gGWmFaf/wig6Ge89GgQTwccTmAaHEoEnqIV6R33o9RdaHgPK6pQM0wX/ZWfYf9f3 WNgcsGYSfBHM9LfKdEX0AHpjsLsXh85v+bgTSi+PxoO9BC0vF7D8vHmdTLKvutyztuh7 fPtVK1+E3tFgt75M9Ja6J4VfKZu7+UXMWzOyW4Cj90VPxcKAgIUqZM/1CLUPRnE0tlR2 o01RcD/0S3biC4z150w4loP4ZgqcCWrlP/u5+c1pPVtlNdekWhpVmpnBeJ9ZDOfbOXV1 trM7AGoExUn0dZ+vtErzMHZgvdeeZ1ZRu9omKEeP7TkhI37apF79i/pXe4VtnvBrxsPK hk9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=rXcf07Ef; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si14506992edc.279.2019.10.23.03.14.28; Wed, 23 Oct 2019 03:14:52 -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; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=rXcf07Ef; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404291AbfJWKNm (ORCPT + 99 others); Wed, 23 Oct 2019 06:13:42 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:37742 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404266AbfJWKNj (ORCPT ); Wed, 23 Oct 2019 06:13:39 -0400 Received: by mail-ed1-f68.google.com with SMTP id r4so15321755edy.4 for ; Wed, 23 Oct 2019 03:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ORDM/VOBs1fIrp01I0A5xms2tGNpKSAd1TbHc1PkN5w=; b=rXcf07Ef2MkSeZMGF3P4Q07eX4Y+LghQnjQZ4TE6fRY/lyPxphd/TGZkXWCyliyv9k JRVd5T1itlTVH6a/44ePIv+jYO7zyF7Vw8U0lWYqSfR2cMJlFLWaQZ9ubGE4RZKnWovT SeIcGZonw3JCCbt7SNCLdoY+2k5BwOiM9haBN0drd1VwFBQ9wwKEV44m5UEoOHRropd9 iajVfoflOTx5L6VT46RC8Gblu4rebThCGjwYyQH8qPMXxlgGp0iPMXkOXOfswvy4CO88 Ka9ggW3bx+36ONuvSwcGA+xqTCXQKNBGKl1zm09t/uFhLxEePbKOR457z8zA3/fkCpOy Ds9g== 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:content-transfer-encoding :in-reply-to:user-agent; bh=ORDM/VOBs1fIrp01I0A5xms2tGNpKSAd1TbHc1PkN5w=; b=KKR5za/oMC9Zr0F15q7i/oPpAT+HC0tPQnRYw7xA6WCes5En/bbrpIuNcRJV4InpTf GdKCRkaO7/eJE2lXMnss9u0g4FpWs1xTRx7GV6Xg9YrBzae9frhVQm+eIVIGSM3l+f8d 0urbmNIQeEC+yRRkR5NUeNn/LFGui3OfyBK/9zExj3KFIj16nTan7/piurqP71UBU/Nb Q1NhF0nMeEgb7Bxp73omqBjhWsBqHxrl/C2qh/gMghz/UE57curJEGPAt7d+BmP2CK1i QW0BV7o0l42btBdc55rnryfLU0EKz6C/3r0rhbWCskYvAIKy5V5gPfu2SlC5zsPcL+iQ ZIcw== X-Gm-Message-State: APjAAAVzxvGpPjLyXJ4NzM4CZjpkDIPvbQMj/eRABaw8NeMoAI1UNfFl unIBoXfNwnkNHmxaqu4jflWE+Q== X-Received: by 2002:aa7:cc95:: with SMTP id p21mr9049005edt.189.1571825617836; Wed, 23 Oct 2019 03:13:37 -0700 (PDT) Received: from netronome.com ([62.119.166.9]) by smtp.gmail.com with ESMTPSA id ck10sm39035ejb.59.2019.10.23.03.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 03:13:37 -0700 (PDT) Date: Wed, 23 Oct 2019 12:13:31 +0200 From: Simon Horman To: Jason Wang Cc: "Zhu, Lingshan" , 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 Subject: Re: [RFC 1/2] vhost: IFC VF hardware operation layer Message-ID: <20191023101329.GE8732@netronome.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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <15d94e61-9b3d-7854-b65e-6fea6db75450@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 22, 2019 at 09:32:36AM +0800, 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. Ok, so this circles back to my original question. Should we put a bound on the number of times the loop runs or should we accept that the kernel locks up if the HW is buggy? > > Thanks > > [1] https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html > Section 2.4.1 > > > > > > > > > +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. > > > > ... >