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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 6F697C04AB4 for ; Fri, 17 May 2019 17:09:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38FA820848 for ; Fri, 17 May 2019 17:09:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38FA820848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:51359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRgM6-0006Is-0f for qemu-devel@archiver.kernel.org; Fri, 17 May 2019 13:09:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRgLC-0005zi-NZ for qemu-devel@nongnu.org; Fri, 17 May 2019 13:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRgLB-0005bY-Lu for qemu-devel@nongnu.org; Fri, 17 May 2019 13:08:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:28260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRgL9-0005UB-Cm; Fri, 17 May 2019 13:08:15 -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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2019 10:08:11 -0700 Received: from unknown (HELO [10.232.112.136]) ([10.232.112.136]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 17 May 2019 10:08:10 -0700 To: qemu-block@nongnu.org, keith.busch@intel.com, kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com References: <20190405214117.1850-1-kenneth.heitke@intel.com> <20190514060225.GA1350@apples.localdomain> <1f607df5-b523-e517-c439-392725fd441b@intel.com> <20190517053504.GA17341@apples.localdomain> <20190517062442.GB17341@apples.localdomain> From: "Heitke, Kenneth" Message-ID: Date: Fri, 17 May 2019 11:08:09 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190517062442.GB17341@apples.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] nvme: add Get/Set Feature Timestamp support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 5/17/2019 12:24 AM, Klaus Birkelund wrote: > On Fri, May 17, 2019 at 07:35:04AM +0200, Klaus Birkelund wrote: >> Hi Kenneth, >> >> On Thu, May 16, 2019 at 05:24:47PM -0600, Heitke, Kenneth wrote: >>> Hi Klaus, thank you for you review. I have one comment inline >>> >>> On 5/14/2019 12:02 AM, Klaus Birkelund wrote: >>>> On Fri, Apr 05, 2019 at 03:41:17PM -0600, Kenneth Heitke wrote: >>>>> Signed-off-by: Kenneth Heitke >>>>> --- >>>>> hw/block/nvme.c | 120 +++++++++++++++++++++++++++++++++++++++++- >>>>> hw/block/nvme.h | 3 ++ >>>>> hw/block/trace-events | 2 + >>>>> include/block/nvme.h | 2 + >>>>> 4 files changed, 125 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c >>>>> index 7caf92532a..e775e89299 100644 >>>>> --- a/hw/block/nvme.c >>>>> +++ b/hw/block/nvme.c >>>>> @@ -219,6 +219,30 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1, >>>>> return NVME_INVALID_FIELD | NVME_DNR; >>>>> } >>>>> +static uint16_t nvme_dma_write_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, >>>>> + uint64_t prp1, uint64_t prp2) >>>>> +{ >>>>> + QEMUSGList qsg; >>>>> + QEMUIOVector iov; >>>>> + uint16_t status = NVME_SUCCESS; >>>>> + >>>>> + if (nvme_map_prp(&qsg, &iov, prp1, prp2, len, n)) { >>>>> + return NVME_INVALID_FIELD | NVME_DNR; >>>>> + } >>>>> + if (qsg.nsg > 0) { >>>>> + if (dma_buf_write(ptr, len, &qsg)) { >>>>> + status = NVME_INVALID_FIELD | NVME_DNR; >>>>> + } >>>>> + qemu_sglist_destroy(&qsg); >>>>> + } else { >>>>> + if (qemu_iovec_from_buf(&iov, 0, ptr, len) != len) { >>>> >>>> This should be `qemu_iovec_to_buf`. >>>> >>> >>> This function is transferring data from the "host" to the device so I >>> believe I am using the correct function. >>> >> >> Exactly, but this means that you need to populate `ptr` with data >> described by the prps, hence dma_buf_*write* and qemu_iovec_*to*_buf. In >> this case `ptr` is set to the address of the uint64_t timestamp, and >> that is what we need to write to. >> > > I was going to argue with the fact that nvme_dma_read_prp uses > qemu_iovec_from_buf. But it uses _to_buf which as far as I can tell is > also wrong. > I think the iovec_to/from_buf is only used in the case of the controller memory buffer. I'm trying to exercise that path to verify if the correct functions are being used but I'm running into issues (io is being directed to bar0 instead of bar2).