Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2094127ybg; Thu, 24 Oct 2019 04:45:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1Izg8XOc147rIOnQIVDU1TAC+qAfBIiAQnoXWVwRm8F9OYfTcs90ypEXuyTNUV9739AsB X-Received: by 2002:a50:8dc9:: with SMTP id s9mr27351429edh.168.1571917526957; Thu, 24 Oct 2019 04:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571917526; cv=none; d=google.com; s=arc-20160816; b=DIrS0Y6vLibHDOP20gL37LgZ+wcdxop3YgHOAv2cbjYFJ1dTjjtVx98bQrl3Q0YyKx bPHu7+otZ1EdF6bRrVQ/JOJFMg+ecrcxacmEPK6/Qo4whvGw3qaX3UpTUOoWnejShVLf WoP1cEBpf2lGIpkAB+RpG9CK75ZvU7MizSqZXPvAUiW/n9ThYP3EAyJRb/RzTfPjQxqr Jt8SBzJERvlRFvV5/YxXhkw+Ug1yhgU7+lSWpmn6u2hclxVsdlBdudzbAk0IStY1kBhO SmXUphcV3PAtV8vUJbjByZorA8gZRNZc9cf5Qw9V6RipdNalMEaP8lM6lhDrSa2h6XqI YEFQ== 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=8iXr1bCPucfV/BlXP7h0HwuQ+aEH9N73PCJr0os4hb4=; b=tN2Ptn9VdsE4MPBBhGzCtEJBijEZAPVVCWBVtyn1dJyD8UXT7rkTEewnHlrWDaflri X5i7UITynZMOfjh0dGzpkz2bb9slRgfGbS9JDbT4E+AJEHMK4sDiGPsO2KSP40MzQ2m9 /ROhzY7je9/CxIanx9tb/i0CDQbaTbKyC6ikSwVAMprTId07JGt0urgXB23FHOilk7ho iWddCe3Iwh9nG7QFK/zcWruzNEAYsSquYVXkx9tAFXNnohjDZh4hJHdGzvVdWOXlHKCZ o1hSfuGgm1s9Xx2xG3eGzQ6atshp2jYI6cAL72u0QzZuwS2hwo+HDCzbKRrJ+PSU9oC/ U1tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=a+beFt5h; 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 a52si8012373eda.450.2019.10.24.04.45.02; Thu, 24 Oct 2019 04:45:26 -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=a+beFt5h; 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 S1728010AbfJWRLY (ORCPT + 99 others); Wed, 23 Oct 2019 13:11:24 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36122 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727154AbfJWRLX (ORCPT ); Wed, 23 Oct 2019 13:11:23 -0400 Received: by mail-wm1-f65.google.com with SMTP id c22so11297032wmd.1 for ; Wed, 23 Oct 2019 10:11:21 -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=8iXr1bCPucfV/BlXP7h0HwuQ+aEH9N73PCJr0os4hb4=; b=a+beFt5hlK6LWDd39o4iUH2O4kIKkoGy0GQejP4br9DTQGzzZaqNpbXf7JfWhMz4QJ 9PgtlErWslt/jNEYZodCeT7c7mw+agWZZiD/GIOCOcEYcpNiXsqnV/DLbLkL84Kn+z+q 9l/GjwurRB2XpmkM3AxWiecfKk8ZQ7+Wc8pOo5wqxGnMKf5bO3m1Bi7F/mKRbsfCe8qg J1ezNYNAlrUBlf6o/3YAWOAiGxeEvXT7SB6XmVU2fdchrO0UngUrn8HufSttMAm0/JZc 4qM3WFu00rI35leLynnYDAeJ0zY54CGeuEnbRqWOd8CPigj08oQVUJg8KvZNj7cIFfR+ Tn8w== 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=8iXr1bCPucfV/BlXP7h0HwuQ+aEH9N73PCJr0os4hb4=; b=EsUHmgYiX9Jd/8q55SrNyuqk2Q6r9bAe4khBLiQNX8bMHWLQMEieRnQWAOJJuGVfLr MnNISCjbxgQiNHobzepjF1s+XE1RpkHjzig5tQ8mQXNfMEwHIjJLOcNZYwRsEKt8tmwu AMoS3Riq/Ln3jKT73ppT9/a76QMR3sJXokBqUGdJmxpurdKVa5oqIGTVAFrqnt2EOIAZ yzRwYiX1Li54gejq/FgDCfscmuRG5wnqAUexpqXFedzleGm2xTcoXY4G9YgZC2vIcTM4 4WZo1OatIBiRqeyG7ozvZ8k1/JNByDLnbR+w9ylYW8VEefL6dpTczCJ8bTEDxvre0tFw uQKQ== X-Gm-Message-State: APjAAAXbpv1uNiB3pOMjFlZkswcbfD8Jb/OmZMktvXPDRLy9v5zMF07t uMdH3IhBBW05F9x+Hcv5kLT4Lg== X-Received: by 2002:a7b:c395:: with SMTP id s21mr946644wmj.114.1571850680225; Wed, 23 Oct 2019 10:11:20 -0700 (PDT) Received: from netronome.com (fred-musen.rivierenbuurt.horms.nl. [2001:470:7eb3:404:a2a4:c5ff:fe4c:9ce9]) by smtp.gmail.com with ESMTPSA id a2sm9365644wrv.39.2019.10.23.10.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 10:11:19 -0700 (PDT) Date: Wed, 23 Oct 2019 19:11:16 +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: <20191023171115.GA28355@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> <20191023101329.GE8732@netronome.com> <83356b5f-e2f4-ab79-79d7-20d4850c26a9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <83356b5f-e2f4-ab79-79d7-20d4850c26a9@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 Wed, Oct 23, 2019 at 06:36:13PM +0800, Jason Wang wrote: > > On 2019/10/23 下午6:13, Simon Horman wrote: > > 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? > > > > I'm not sure, and similar logic has been used by virtio-pci drivers for > years. Consider this logic is pretty simple and it should not be the only > place that virito hardware can lock kernel, we can keep it as is. Ok, I accept that there isn't much use fixing this if its idomatic and there are other places virtio hardware can lock up the kernel. > Actually, there's no need for hardware to implement generation logic, it > could be emulated by software or even ignored. In new version of > virtio-mdev, get_generation() is optional, when it was not implemented, 0 is > simply returned by virtio-mdev transport. > > Thanks >