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=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0B317C282DE for ; Wed, 5 Jun 2019 10:53:14 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 555E4206BA for ; Wed, 5 Jun 2019 10:53:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 555E4206BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45Jlxz0ZcmzDqXC for ; Wed, 5 Jun 2019 20:53:11 +1000 (AEST) Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45JlwN2FyzzDqRq for ; Wed, 5 Jun 2019 20:51:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45JlwL62JYz9sBb; Wed, 5 Jun 2019 20:51:46 +1000 (AEST) From: Michael Ellerman To: "Aneesh Kumar K.V" , Oliver Subject: Re: [PATCH] powerpc/nvdimm: Add support for multibyte read/write for metadata In-Reply-To: <87ef49hg85.fsf@linux.ibm.com> References: <20190602044350.31660-1-aneesh.kumar@linux.ibm.com> <87ef49hg85.fsf@linux.ibm.com> Date: Wed, 05 Jun 2019 20:51:45 +1000 Message-ID: <8736konw3i.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras , linuxppc-dev , Nicholas Piggin Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" "Aneesh Kumar K.V" writes: > Oliver writes: >> On Sun, Jun 2, 2019 at 2:44 PM Aneesh Kumar K.V >> wrote: ... >>> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c >>> index 0176ce66673f..e33cebb8ee6c 100644 >>> --- a/arch/powerpc/platforms/pseries/papr_scm.c >>> +++ b/arch/powerpc/platforms/pseries/papr_scm.c >>> @@ -97,42 +97,102 @@ static int drc_pmem_unbind(struct papr_scm_priv *p) >>> } >>> >>> static int papr_scm_meta_get(struct papr_scm_priv *p, >>> - struct nd_cmd_get_config_data_hdr *hdr) >>> + struct nd_cmd_get_config_data_hdr *hdr) >>> { >>> unsigned long data[PLPAR_HCALL_BUFSIZE]; >>> + unsigned long offset, data_offset; >>> + int len, read; >>> int64_t ret; >>> >>> - if (hdr->in_offset >= p->metadata_size || hdr->in_length != 1) >>> + if ((hdr->in_offset + hdr->in_length) >= p->metadata_size) >>> return -EINVAL; >>> >>> - ret = plpar_hcall(H_SCM_READ_METADATA, data, p->drc_index, >>> - hdr->in_offset, 1); >>> - >>> - if (ret == H_PARAMETER) /* bad DRC index */ >>> - return -ENODEV; >>> - if (ret) >>> - return -EINVAL; /* other invalid parameter */ >>> - >>> - hdr->out_buf[0] = data[0] & 0xff; >>> - >>> + for (len = hdr->in_length; len; len -= read) { >>> + >>> + data_offset = hdr->in_length - len; >>> + offset = hdr->in_offset + data_offset; >>> + >>> + if (len >= 8) >>> + read = 8; >>> + else if (len >= 4) >>> + read = 4; >>> + else if ( len >= 2) >>> + read = 2; >>> + else >>> + read = 1; >>> + >>> + ret = plpar_hcall(H_SCM_READ_METADATA, data, p->drc_index, >>> + offset, read); >>> + >>> + if (ret == H_PARAMETER) /* bad DRC index */ >>> + return -ENODEV; >>> + if (ret) >>> + return -EINVAL; /* other invalid parameter */ >>> + >>> + switch (read) { >>> + case 8: >>> + *(uint64_t *)(hdr->out_buf + data_offset) = be64_to_cpu(data[0]); >>> + break; >>> + case 4: >>> + *(uint32_t *)(hdr->out_buf + data_offset) = be32_to_cpu(data[0] & 0xffffffff); >>> + break; ... >> >> I assume you got the qemu bits sorted out with Shiva? Looks good otherwise. > > That is correct. I also tested with different xfer values (1, 2, 4, 8) > on both Qemu and PowerVM. With a big endian kernel? cheers