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=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 9E911C433E1 for ; Fri, 5 Jun 2020 19:49:33 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (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 4241A2077D for ; Fri, 5 Jun 2020 19:49:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="k/NC3Syq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4241A2077D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 15C221009EA33; Fri, 5 Jun 2020 12:44:20 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::644; helo=mail-ej1-x644.google.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9985D1009F03F for ; Fri, 5 Jun 2020 12:44:16 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id z5so11404523ejb.3 for ; Fri, 05 Jun 2020 12:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=k/NC3SyqbrnTugxOywTK0FoQRYbykja1Y9Z/Y+Oh0Xayiz4ABW5+oz0RQY8qd5omkK MI/zKIbCDsftNm5RInDUsWRSWwbzOvpk89S3IqVCZq2aIcbteePU9QhAlYiox4BD40Uz VIGF5ixopOwU4zSKVgOI+DQwI3T3Qin7bxZP7fA64XNH+/QhSfMQGS/0IbGeKvfBHljV bvU87+Ogx+1N7HpejbxT9TBt3Opl0zmBmfDr2mzq2irNdnenJ9YOZxKM68IlSopCchb5 9wbk59DZLIubfgH2ZuHMb5xfhOhcaZmZVUWwrvG6xKXPZo3CLQDgUIOKR4D0enM/jwqF IumQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=d8v9JIdP80SYqdrkZvPSMZauFrK7M+a0yINSGX293E8W6sYpn02NHiONr4Pge3lqqN eTELUJUOsN30pWSwyyKkW0P7A2phS5uP8jdQZMynYSZBNQhvHIYNtB88W/JkNIvbVMkj PujdiSUCfGw1ig2RS/7X1YDv2QNoBimlm0B0AwiS1FComDKsF4klnVEhSy8ocNw4Ttoy ne712BuFBo16wQEk3venqTkj0rWl5R49Vib9tnrTMJ2VLD+8j4AsrHwp751NN33kBNCp SsFvOqYV8aevZp+QQwfWWxyUyeKZPXMNC5SlUSORxs6V0PCwKjfpQcECacaL135GtPyF qJIA== X-Gm-Message-State: AOAM530N8Ai6zviq8P7HIfkO9GwHUexCCwfw9wZyciP62mg9DAc9V0v2 7QiezEC9R6uesZ8USKHbB7imBUDTLI2nJYvSDGAO+Q== X-Google-Smtp-Source: ABdhPJxuZwIa9IoVTuMhbnwTzDt4nAJOGfVaSR8B92lGhn2YN8cJwIHX7v31rQdpN8V9SGgR1+Mc3WTf01eoOyhXsTA= X-Received: by 2002:a17:906:22d0:: with SMTP id q16mr10033033eja.455.1591386567943; Fri, 05 Jun 2020 12:49:27 -0700 (PDT) MIME-Version: 1.0 References: <20200604234136.253703-1-vaibhav@linux.ibm.com> <20200604234136.253703-5-vaibhav@linux.ibm.com> <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> In-Reply-To: <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> From: Dan Williams Date: Fri, 5 Jun 2020 12:49:16 -0700 Message-ID: Subject: Re: [PATCH v10 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() To: Ira Weiny Message-ID-Hash: 3DM7OTZRT7FQP7HN3VIZ6ZHUCCKRCGQK X-Message-ID-Hash: 3DM7OTZRT7FQP7HN3VIZ6ZHUCCKRCGQK X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Vaibhav Jain , linuxppc-dev , linux-nvdimm , Linux Kernel Mailing List , "Aneesh Kumar K . V" , Michael Ellerman , Steven Rostedt X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Fri, Jun 5, 2020 at 10:13 AM Ira Weiny wrote: > > On Fri, Jun 05, 2020 at 05:11:34AM +0530, Vaibhav Jain wrote: > > Since papr_scm_ndctl() can be called from outside papr_scm, its > > exposed to the possibility of receiving NULL as value of 'cmd_rc' > > argument. This patch updates papr_scm_ndctl() to protect against such > > possibility by assigning it pointer to a local variable in case cmd_rc > > == NULL. > > > > Finally the patch also updates the 'default' clause of the switch-case > > block removing a 'return' statement thereby ensuring that value of > > 'cmd_rc' is always logged when papr_scm_ndctl() returns. > > > > Cc: "Aneesh Kumar K . V" > > Cc: Dan Williams > > Cc: Michael Ellerman > > Cc: Ira Weiny > > Signed-off-by: Vaibhav Jain > > --- > > Changelog: > > > > v9..v10 > > * New patch in the series > > Thanks for making this a separate patch it is easier to see what is going on > here. > > > --- > > arch/powerpc/platforms/pseries/papr_scm.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c > > index 0c091622b15e..6512fe6a2874 100644 > > --- a/arch/powerpc/platforms/pseries/papr_scm.c > > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > > @@ -355,11 +355,16 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > { > > struct nd_cmd_get_config_size *get_size_hdr; > > struct papr_scm_priv *p; > > + int rc; > > > > /* Only dimm-specific calls are supported atm */ > > if (!nvdimm) > > return -EINVAL; > > > > + /* Use a local variable in case cmd_rc pointer is NULL */ > > + if (!cmd_rc) > > + cmd_rc = &rc; > > + > > This protects you from the NULL. However... > > > p = nvdimm_provider_data(nvdimm); > > > > switch (cmd) { > > @@ -381,12 +386,13 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > break; > > > > default: > > - return -EINVAL; > > + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); > > + *cmd_rc = -EINVAL; > > ... I think you are conflating rc and cmd_rc... > > > } > > > > dev_dbg(&p->pdev->dev, "returned with cmd_rc = %d\n", *cmd_rc); > > > > - return 0; > > + return *cmd_rc; > > ... this changes the behavior of the current commands. Now if the underlying > papr_scm_meta_[get|set]() fails you return that failure as rc rather than 0. > > Is that ok? The expectation is that rc is "did the command get sent to the device, or did it fail for 'transport' reasons". The role of cmd_rc is to translate the specific status response of the command into a common error code. The expectations are: rc < 0: Error code, Linux terminated the ioctl before talking to hardware rc == 0: Linux successfully submitted the command to hardware, cmd_rc is valid for command specific response rc > 0: Linux successfully submitted the command, but detected that only a subset of the data was accepted for "write"-style commands, or that only subset of data was returned for "read"-style commands. I.e. short-write / short-read semantics. cmd_rc is valid in this case and its up to userspace to determine if a short transfer is an error or not. > Also 'logging cmd_rc' in the invalid cmd case does not seem quite right unless > you really want rc to be cmd_rc. > > The architecture is designed to separate errors which occur in the kernel vs > errors in the firmware/dimm. Are they always the same? The current code > differentiates them. Yeah, they're distinct, transport vs end-point / command-specific status returns. _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org 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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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 0B67FC433E0 for ; Fri, 5 Jun 2020 19:49:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D04872077D for ; Fri, 5 Jun 2020 19:49:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="k/NC3Syq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbgFETta (ORCPT ); Fri, 5 Jun 2020 15:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727877AbgFETt3 (ORCPT ); Fri, 5 Jun 2020 15:49:29 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61CEAC08C5C2 for ; Fri, 5 Jun 2020 12:49:29 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id o15so11352057ejm.12 for ; Fri, 05 Jun 2020 12:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=k/NC3SyqbrnTugxOywTK0FoQRYbykja1Y9Z/Y+Oh0Xayiz4ABW5+oz0RQY8qd5omkK MI/zKIbCDsftNm5RInDUsWRSWwbzOvpk89S3IqVCZq2aIcbteePU9QhAlYiox4BD40Uz VIGF5ixopOwU4zSKVgOI+DQwI3T3Qin7bxZP7fA64XNH+/QhSfMQGS/0IbGeKvfBHljV bvU87+Ogx+1N7HpejbxT9TBt3Opl0zmBmfDr2mzq2irNdnenJ9YOZxKM68IlSopCchb5 9wbk59DZLIubfgH2ZuHMb5xfhOhcaZmZVUWwrvG6xKXPZo3CLQDgUIOKR4D0enM/jwqF IumQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=KQvug2CfLQ1SQwKorW+sMMMfCq8Fy848eSTVtisZarDQY5o6s7iB8QbmgJDnRePred r0r8xIgh2/UgLC+6xrbPJuCbAXeh9x05gW70ZVNaSSQnSIU/532sUhwmmHsJeeD5pOop aLgCQj5W7Np9D4AgyS9GgErTbfSGuQFOYVIm29JKoRWkTVpitcbsr3dsa4H6DPkb31Fo cDJjP6yof/D1KCKlA2V2lhQEfIWbx7IuHX5MRcBuCr9Q+GG6QPDFNjZh10CnPnumgWkJ iHaQwk3uz7oiiIxh7Qi1sq2e3rLNq1jQwAiLz8OITgkxsl7Kyp4TyVDJYYK9qXYi37uG l4NQ== X-Gm-Message-State: AOAM5330mwDde3WMChS3OiLmFoz3IUfiC8DijR6EiaYXWYEFw4dXlNHM Vv0ay9hNpVDUPnMEu2CPf0jk3WAqsRWIOElyK7W0Yw== X-Google-Smtp-Source: ABdhPJxuZwIa9IoVTuMhbnwTzDt4nAJOGfVaSR8B92lGhn2YN8cJwIHX7v31rQdpN8V9SGgR1+Mc3WTf01eoOyhXsTA= X-Received: by 2002:a17:906:22d0:: with SMTP id q16mr10033033eja.455.1591386567943; Fri, 05 Jun 2020 12:49:27 -0700 (PDT) MIME-Version: 1.0 References: <20200604234136.253703-1-vaibhav@linux.ibm.com> <20200604234136.253703-5-vaibhav@linux.ibm.com> <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> In-Reply-To: <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> From: Dan Williams Date: Fri, 5 Jun 2020 12:49:16 -0700 Message-ID: Subject: Re: [PATCH v10 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() To: Ira Weiny Cc: Vaibhav Jain , linuxppc-dev , linux-nvdimm , Linux Kernel Mailing List , "Aneesh Kumar K . V" , Michael Ellerman , "Oliver O'Halloran" , Santosh Sivaraj , Steven Rostedt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 5, 2020 at 10:13 AM Ira Weiny wrote: > > On Fri, Jun 05, 2020 at 05:11:34AM +0530, Vaibhav Jain wrote: > > Since papr_scm_ndctl() can be called from outside papr_scm, its > > exposed to the possibility of receiving NULL as value of 'cmd_rc' > > argument. This patch updates papr_scm_ndctl() to protect against such > > possibility by assigning it pointer to a local variable in case cmd_rc > > == NULL. > > > > Finally the patch also updates the 'default' clause of the switch-case > > block removing a 'return' statement thereby ensuring that value of > > 'cmd_rc' is always logged when papr_scm_ndctl() returns. > > > > Cc: "Aneesh Kumar K . V" > > Cc: Dan Williams > > Cc: Michael Ellerman > > Cc: Ira Weiny > > Signed-off-by: Vaibhav Jain > > --- > > Changelog: > > > > v9..v10 > > * New patch in the series > > Thanks for making this a separate patch it is easier to see what is going on > here. > > > --- > > arch/powerpc/platforms/pseries/papr_scm.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c > > index 0c091622b15e..6512fe6a2874 100644 > > --- a/arch/powerpc/platforms/pseries/papr_scm.c > > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > > @@ -355,11 +355,16 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > { > > struct nd_cmd_get_config_size *get_size_hdr; > > struct papr_scm_priv *p; > > + int rc; > > > > /* Only dimm-specific calls are supported atm */ > > if (!nvdimm) > > return -EINVAL; > > > > + /* Use a local variable in case cmd_rc pointer is NULL */ > > + if (!cmd_rc) > > + cmd_rc = &rc; > > + > > This protects you from the NULL. However... > > > p = nvdimm_provider_data(nvdimm); > > > > switch (cmd) { > > @@ -381,12 +386,13 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > break; > > > > default: > > - return -EINVAL; > > + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); > > + *cmd_rc = -EINVAL; > > ... I think you are conflating rc and cmd_rc... > > > } > > > > dev_dbg(&p->pdev->dev, "returned with cmd_rc = %d\n", *cmd_rc); > > > > - return 0; > > + return *cmd_rc; > > ... this changes the behavior of the current commands. Now if the underlying > papr_scm_meta_[get|set]() fails you return that failure as rc rather than 0. > > Is that ok? The expectation is that rc is "did the command get sent to the device, or did it fail for 'transport' reasons". The role of cmd_rc is to translate the specific status response of the command into a common error code. The expectations are: rc < 0: Error code, Linux terminated the ioctl before talking to hardware rc == 0: Linux successfully submitted the command to hardware, cmd_rc is valid for command specific response rc > 0: Linux successfully submitted the command, but detected that only a subset of the data was accepted for "write"-style commands, or that only subset of data was returned for "read"-style commands. I.e. short-write / short-read semantics. cmd_rc is valid in this case and its up to userspace to determine if a short transfer is an error or not. > Also 'logging cmd_rc' in the invalid cmd case does not seem quite right unless > you really want rc to be cmd_rc. > > The architecture is designed to separate errors which occur in the kernel vs > errors in the firmware/dimm. Are they always the same? The current code > differentiates them. Yeah, they're distinct, transport vs end-point / command-specific status returns. 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=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 02968C433DF for ; Fri, 5 Jun 2020 19:51:39 +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 DF2C52074B for ; Fri, 5 Jun 2020 19:51:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="k/NC3Syq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF2C52074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49dtZH5NY3zDr3L for ; Sat, 6 Jun 2020 05:51:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=2a00:1450:4864:20::644; helo=mail-ej1-x644.google.com; envelope-from=dan.j.williams@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=k/NC3Syq; dkim-atps=neutral Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) (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 49dtX24sFFzDr0t for ; Sat, 6 Jun 2020 05:49:31 +1000 (AEST) Received: by mail-ej1-x644.google.com with SMTP id l12so7611274ejn.10 for ; Fri, 05 Jun 2020 12:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=k/NC3SyqbrnTugxOywTK0FoQRYbykja1Y9Z/Y+Oh0Xayiz4ABW5+oz0RQY8qd5omkK MI/zKIbCDsftNm5RInDUsWRSWwbzOvpk89S3IqVCZq2aIcbteePU9QhAlYiox4BD40Uz VIGF5ixopOwU4zSKVgOI+DQwI3T3Qin7bxZP7fA64XNH+/QhSfMQGS/0IbGeKvfBHljV bvU87+Ogx+1N7HpejbxT9TBt3Opl0zmBmfDr2mzq2irNdnenJ9YOZxKM68IlSopCchb5 9wbk59DZLIubfgH2ZuHMb5xfhOhcaZmZVUWwrvG6xKXPZo3CLQDgUIOKR4D0enM/jwqF IumQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KXc03rxQsyL+YifD2Y2tm+lwPD0QRqJ3ku4DKVZ1zc8=; b=K51aDlafrEo/Y3Zb+JSKsOyWG02LL+wYs1dfnVgSLrVuOYt6w/Gj4tv4S29Fcxpzus tjlG7BqRe0Y8Zplnw/m2J0Y78KSPNQdhiqsbQDGB73SJo8BgjwuMHNYVzXk4sQg8PeR8 ietwZJsaJvvhCvfJQUL2J7hInSrZSsMLDGta1iOnKbCGtrBupNekufK+2ZaRYNKDbaGy qOkC9cPSBpY21qQ/68qB7P/aDBDD4iXiDgWpt3z0/RbqHFfZ3++cR03hnk6JoKshaanF YBxbiCDwMp0bNgDHvc9cOFlpeBQ0/SrctmO8jtz6MVnJkn5y3siwMh8PpAKpxtnXlaTh Taxw== X-Gm-Message-State: AOAM533bgk+zYxeRoz1m2CQ6j5VvqP1RPwhZNErOuuNWPRi01vBKpIq3 GOVrJ/WEh5sW2ymWpR50yyhAblu8hQW0DG34TZYMXg== X-Google-Smtp-Source: ABdhPJxuZwIa9IoVTuMhbnwTzDt4nAJOGfVaSR8B92lGhn2YN8cJwIHX7v31rQdpN8V9SGgR1+Mc3WTf01eoOyhXsTA= X-Received: by 2002:a17:906:22d0:: with SMTP id q16mr10033033eja.455.1591386567943; Fri, 05 Jun 2020 12:49:27 -0700 (PDT) MIME-Version: 1.0 References: <20200604234136.253703-1-vaibhav@linux.ibm.com> <20200604234136.253703-5-vaibhav@linux.ibm.com> <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> In-Reply-To: <20200605171313.GO1505637@iweiny-DESK2.sc.intel.com> From: Dan Williams Date: Fri, 5 Jun 2020 12:49:16 -0700 Message-ID: Subject: Re: [PATCH v10 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() To: Ira Weiny Content-Type: text/plain; charset="UTF-8" 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: Santosh Sivaraj , linux-nvdimm , Linux Kernel Mailing List , Steven Rostedt , Oliver O'Halloran , "Aneesh Kumar K . V" , Vaibhav Jain , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Jun 5, 2020 at 10:13 AM Ira Weiny wrote: > > On Fri, Jun 05, 2020 at 05:11:34AM +0530, Vaibhav Jain wrote: > > Since papr_scm_ndctl() can be called from outside papr_scm, its > > exposed to the possibility of receiving NULL as value of 'cmd_rc' > > argument. This patch updates papr_scm_ndctl() to protect against such > > possibility by assigning it pointer to a local variable in case cmd_rc > > == NULL. > > > > Finally the patch also updates the 'default' clause of the switch-case > > block removing a 'return' statement thereby ensuring that value of > > 'cmd_rc' is always logged when papr_scm_ndctl() returns. > > > > Cc: "Aneesh Kumar K . V" > > Cc: Dan Williams > > Cc: Michael Ellerman > > Cc: Ira Weiny > > Signed-off-by: Vaibhav Jain > > --- > > Changelog: > > > > v9..v10 > > * New patch in the series > > Thanks for making this a separate patch it is easier to see what is going on > here. > > > --- > > arch/powerpc/platforms/pseries/papr_scm.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c > > index 0c091622b15e..6512fe6a2874 100644 > > --- a/arch/powerpc/platforms/pseries/papr_scm.c > > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > > @@ -355,11 +355,16 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > { > > struct nd_cmd_get_config_size *get_size_hdr; > > struct papr_scm_priv *p; > > + int rc; > > > > /* Only dimm-specific calls are supported atm */ > > if (!nvdimm) > > return -EINVAL; > > > > + /* Use a local variable in case cmd_rc pointer is NULL */ > > + if (!cmd_rc) > > + cmd_rc = &rc; > > + > > This protects you from the NULL. However... > > > p = nvdimm_provider_data(nvdimm); > > > > switch (cmd) { > > @@ -381,12 +386,13 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > > break; > > > > default: > > - return -EINVAL; > > + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); > > + *cmd_rc = -EINVAL; > > ... I think you are conflating rc and cmd_rc... > > > } > > > > dev_dbg(&p->pdev->dev, "returned with cmd_rc = %d\n", *cmd_rc); > > > > - return 0; > > + return *cmd_rc; > > ... this changes the behavior of the current commands. Now if the underlying > papr_scm_meta_[get|set]() fails you return that failure as rc rather than 0. > > Is that ok? The expectation is that rc is "did the command get sent to the device, or did it fail for 'transport' reasons". The role of cmd_rc is to translate the specific status response of the command into a common error code. The expectations are: rc < 0: Error code, Linux terminated the ioctl before talking to hardware rc == 0: Linux successfully submitted the command to hardware, cmd_rc is valid for command specific response rc > 0: Linux successfully submitted the command, but detected that only a subset of the data was accepted for "write"-style commands, or that only subset of data was returned for "read"-style commands. I.e. short-write / short-read semantics. cmd_rc is valid in this case and its up to userspace to determine if a short transfer is an error or not. > Also 'logging cmd_rc' in the invalid cmd case does not seem quite right unless > you really want rc to be cmd_rc. > > The architecture is designed to separate errors which occur in the kernel vs > errors in the firmware/dimm. Are they always the same? The current code > differentiates them. Yeah, they're distinct, transport vs end-point / command-specific status returns.