Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp195390imm; Wed, 18 Jul 2018 00:05:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfrQj/fdcMgZ6rWE7g+VAXRaZ/3kT5utF439HTyQcheemuKnpX1etGOh77hW7lnWTLxRY1B X-Received: by 2002:a63:c742:: with SMTP id v2-v6mr4626171pgg.331.1531897559837; Wed, 18 Jul 2018 00:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531897559; cv=none; d=google.com; s=arc-20160816; b=xq8asNwFT90Sipj/wvkAkclBqXKOuke2Go+kNSFJ7bJQoc8qKuB3RxIKGuIej1yKlN fUdu9sYossPvclXVGaITndIicXcOnI9Oj3E4I1COljAd59obHmVBSfG752pVWhsmBLbH zmFGjrsDdp31s+L5dV9X/Ou80i+39SnlosEbuqAnD8+UTeTzTC1MK/Te37bowOVkIRff +wjagGZpT7wdC6WMul3Ny9KheTPs2FmscgFIHOxNS5Lvks5AHOklRwrB/Tstl3R0A7cp twSK+dWG/d5Zv+9tSTwA1xZyZ+bGYgCNSlNtnWg2xyXXqdts4s7K8NG1vT8lWKnHXfQi JhSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:arc-authentication-results; bh=WcW86TMOsFLKKjJiweUQQ8EG5gN2zSiqI+uJFGxnK/U=; b=BvfMQ0o0Xju+zAvVlylri0Ulo/9pAFWOeDhnriq4NetVwubwcpAYxSAshIj7jzrz5M 0IjuBBXIiGxbHo7JJqEnYbYCMsPj0PTIcuwxfjGgrVkUyya9YS6/v6hIHvV/9DUKrbbg Ix+ALquu6EcQ+HW9ypY+fAY7kIz3SyNguUpeb71LsmlOH0yd0M57HNvcr7ak3ypP7Jlv 2FPe92NyUxPiOyO2IClUrfbXd3p9bTnXaBYal/oTFnUqHE9dIAe983NDq9KSzZ/p0ftg Kh/y5NZ8zkDgm8BSTODeqSAXxfj+VXxe9rcY4JH/8Vw0DTTyiyGafRDEAdoN9prU5QPg YgDw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si2528941pld.429.2018.07.18.00.05.44; Wed, 18 Jul 2018 00:05:59 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbeGRHld (ORCPT + 99 others); Wed, 18 Jul 2018 03:41:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42298 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeGRHld (ORCPT ); Wed, 18 Jul 2018 03:41:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D982F81DE8; Wed, 18 Jul 2018 07:05:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F3915C1A1; Wed, 18 Jul 2018 07:05:10 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E0FF44BB78; Wed, 18 Jul 2018 07:05:09 +0000 (UTC) Date: Wed, 18 Jul 2018 03:05:09 -0400 (EDT) From: Pankaj Gupta To: Stefan Hajnoczi Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, linux-nvdimm@ml01.01.org, jack@suse.cz, dan j williams , riel@surriel.com, haozhong zhang , nilal@redhat.com, kwolf@redhat.com, pbonzini@redhat.com, ross zwisler , david@redhat.com, xiaoguangrong eric , hch@infradead.org, mst@redhat.com, niteshnarayanlal@hotmail.com, lcapitulino@redhat.com, imammedo@redhat.com, eblake@redhat.com Message-ID: <2137768776.51859350.1531897509492.JavaMail.zimbra@redhat.com> In-Reply-To: <20180717131156.GA13498@stefanha-x1.localdomain> References: <20180713075232.9575-1-pagupta@redhat.com> <20180713075232.9575-3-pagupta@redhat.com> <20180717131156.GA13498@stefanha-x1.localdomain> Subject: Re: [RFC v3 2/2] virtio-pmem: Add virtio pmem driver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.65.193.70, 10.4.195.11] Thread-Topic: virtio-pmem: Add virtio pmem driver Thread-Index: IHu9fR6hsmnbOScmgE4tqtLPkAEXeg== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 18 Jul 2018 07:05:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, > > + /* The request submission function */ > > +static int virtio_pmem_flush(struct device *dev) > > +{ > > + int err; > > + unsigned long flags; > > + struct scatterlist *sgs[2], sg, ret; > > + struct virtio_device *vdev = dev_to_virtio(dev->parent->parent); > > + struct virtio_pmem *vpmem = vdev->priv; > > + struct virtio_pmem_request *req = kmalloc(sizeof(*req), GFP_KERNEL); > > + > > + req->done = false; > > + init_waitqueue_head(&req->acked); > > + spin_lock_irqsave(&vpmem->pmem_lock, flags); > > + > > + sg_init_one(&sg, req, sizeof(req)); > > What are you trying to do here? > > sizeof(req) == sizeof(struct virtio_pmem_request *) == sizeof(void *) > > Did you mean sizeof(*req)? yes, I meant: sizeof(struct virtio_pmem_request) Thanks for catching this. > > But why map struct virtio_pmem_request to the device? struct > virtio_pmem_request is the driver-internal request state and is not part > of the hardware interface. o.k. I will separate out request from 'virtio_pmem_request' struct and use that. > > > + sgs[0] = &sg; > > + sg_init_one(&ret, &req->ret, sizeof(req->ret)); > > + sgs[1] = &ret; > > + err = virtqueue_add_sgs(vpmem->req_vq, sgs, 1, 1, req, GFP_ATOMIC); > > + if (err) { > > + dev_err(&vdev->dev, "failed to send command to virtio pmem device\n"); > > This can happen if the virtqueue is full. Printing a message and > failing the flush isn't appropriate. This thread needs to wait until > virtqueue space becomes available. o.k. I will implement this. > > > + spin_unlock_irqrestore(&vpmem->pmem_lock, flags); > > + return -ENOSPC; > > req is leaked. will free req. > > > + virtio_device_ready(vdev); > > This call isn't needed. Driver use it when they wish to submit buffers > on virtqueues before ->probe() returns. o.k. I will remove it. > > > diff --git a/include/linux/virtio_pmem.h b/include/linux/virtio_pmem.h > > new file mode 100644 > > index 0000000..0f83d9c > > --- /dev/null > > +++ b/include/linux/virtio_pmem.h > > include/ is for declarations (e.g. kernel APIs) needed by other > compilation units. The contents of this header are internal to the > virtio_pmem driver implementation and can therefore be in virtio_pmem.c. > include/linux/virtio_pmem.h isn't necessary since nothing besides > virtio_pmem.c will need to include it. Agree. Will move declarations from virtio_pmem.h to virtio_pmem.c Thanks, Pankaj