Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2261401rwi; Tue, 1 Nov 2022 05:54:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57VoGFoHNw5EEYwz9M1NfFNgS/wzqGrSCfz086lVMkIvYpwyJIKd+1AwFQkNw0dBa8XpVl X-Received: by 2002:a17:906:99c5:b0:73d:70c5:1a4f with SMTP id s5-20020a17090699c500b0073d70c51a4fmr17931650ejn.302.1667307290572; Tue, 01 Nov 2022 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667307290; cv=none; d=google.com; s=arc-20160816; b=aPbx//Nj4fWOaTN3ZQV9u7JkA2q/JReZy8/njrVLYOeUJv5QOSEsgJsfikAVE9WQZ6 053QbU5ZMeK4UuSYBXD3F8eD3w1Eslyw3859Mx961ZEbG+Fbs2lG+d5FTg8ssxkhLoPZ FrCt9UGZK1+ByHfxOWiLVy2oCgcdzBSJBZNbcOit5mLbskg6kp4HCgCNk/agbFJLA9/s CCZcidfBanYsfMbGECk/bAt+y4yEmYDjVq6CfK3/noAo+RiFSHW0+eVFwc6ir8wjg7up ofFScdFNGVlBzaHFjyqNgy3wKhYFQhdc339GFLHoraocviugvlWF6ZFxTGQbvVn3DhIy fzqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sw+YQSBeh0VDYN0NPdshfUFn45O+04zEQkeaxHq4GCE=; b=bRb/nZQDjmAPjxF0wTPKzTrkhJ4uO4BN8TPlpFuxSjrQdbT/3PGK3xi9uU3QLCk4Lz p8k6jjlmXDdvHZQm26W7S0TK1L1p8PoXxaRHWW73RJOUef4jdeIG2hEEKIyzpxvhnhg+ PnGcweuJew3SNIV/0EoALfn7CfkNA/1UICtq9oHJZVlq8fRNZLKFeMPJBRLcs2jo/T/N OTCxgGXigzMjE7BI41oafaWNkfV/tNIyEhs6rQ7Ww0x7UY9OxipJSQVmu4G5t6Cnlg00 fXgpX4hvkrEivJzsQ7SptzXammJpbAkwMPG1wBTQPRDd2CNAj8jko21Az2O2ek08412N FZvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s3TW1NFv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs38-20020a1709072d2600b00773dd14c80asi12143120ejc.860.2022.11.01.05.54.25; Tue, 01 Nov 2022 05:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s3TW1NFv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbiKALbV (ORCPT + 97 others); Tue, 1 Nov 2022 07:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiKALak (ORCPT ); Tue, 1 Nov 2022 07:30:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BEC645E; Tue, 1 Nov 2022 04:29:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4EA56B81CCC; Tue, 1 Nov 2022 11:29:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D12DCC433D7; Tue, 1 Nov 2022 11:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667302155; bh=B3LbPgQNVizzP/SCpy9m+4Q4ekqHIeBU5u7nK2+lmq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3TW1NFv/svfFF/FwyCX6XJCHKupFWGbDbNfNdye8Ki/8i6aWW0i6kWHvIgZsb8yu LDOcAxmpT4WTV7/Zdnk/EaPyzn90OGqQOlA83xDtxdxlIGWoAjJtIkka6IaQlJHSbG 3d+cSg8BpoQEg70BpbXdV0HtCL3WI8qiPzIqGsLHiAnGeGWuMJXDixiJclBEoVFhwF PBAzS632B8JTN6GY7apm+e1THsjZYyQFsaTwHxc6DYVeZ8zN+QjWfk2naS8ptRHhFl 0wDDljqK+gN5jGHi0XJyYZWcu4SgUTyQE6he+TFr7+bjYysPmfyImNBDQ9Ex/kMMKf PkcHulK3vMI8w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Guenter Roeck , Serge Semin , Sasha Levin , kbusch@kernel.org, axboe@fb.com, sagi@grimberg.me, linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 6.0 32/34] nvme-hwmon: consistently ignore errors from nvme_hwmon_init Date: Tue, 1 Nov 2022 07:27:24 -0400 Message-Id: <20221101112726.799368-32-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101112726.799368-1-sashal@kernel.org> References: <20221101112726.799368-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit 6b8cf94005187952f794c0c4ed3920a1e8accfa3 ] An NVMe controller works perfectly fine even when the hwmon initialization fails. Stop returning errors that do not come from a controller reset from nvme_hwmon_init to handle this case consistently. Signed-off-by: Christoph Hellwig Reviewed-by: Guenter Roeck Reviewed-by: Serge Semin Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 6 +++++- drivers/nvme/host/hwmon.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 59e4b188fc71..ed47c256dbd2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3256,8 +3256,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl) return ret; if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) { + /* + * Do not return errors unless we are in a controller reset, + * the controller works perfectly fine without hwmon. + */ ret = nvme_hwmon_init(ctrl); - if (ret < 0) + if (ret == -EINTR) return ret; } diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c index 0a586d712920..23918bb7bdca 100644 --- a/drivers/nvme/host/hwmon.c +++ b/drivers/nvme/host/hwmon.c @@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) - return 0; + return -ENOMEM; data->ctrl = ctrl; mutex_init(&data->read_lock); @@ -238,8 +238,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) err = nvme_hwmon_get_smart_log(data); if (err) { dev_warn(dev, "Failed to read smart log (error %d)\n", err); - kfree(data); - return err; + goto err_free_data; } hwmon = hwmon_device_register_with_info(dev, "nvme", @@ -247,11 +246,15 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) NULL); if (IS_ERR(hwmon)) { dev_warn(dev, "Failed to instantiate hwmon device\n"); - kfree(data); - return PTR_ERR(hwmon); + err = PTR_ERR(hwmon); + goto err_free_data; } ctrl->hwmon_device = hwmon; return 0; + +err_free_data: + kfree(data); + return err; } void nvme_hwmon_exit(struct nvme_ctrl *ctrl) -- 2.35.1