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=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 617EFC282E3 for ; Sun, 26 May 2019 16:29:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A8D320657 for ; Sun, 26 May 2019 16:29:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iJnOYm7C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbfEZQ3n (ORCPT ); Sun, 26 May 2019 12:29:43 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42001 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbfEZQ3n (ORCPT ); Sun, 26 May 2019 12:29:43 -0400 Received: by mail-pf1-f196.google.com with SMTP id r22so5254763pfh.9 for ; Sun, 26 May 2019 09:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d9UooUjAx6NBScigOGnH7Gz4QNuQjVumDoAAYHZwJ0I=; b=iJnOYm7COmsXgX5f8j5IS+0oQvSzQ6Yvq70wyjHOGa0RULDcfSKhqE2UWULKt2ZtgV STtCPlFp9E0CLBT8ESwbD4zGEKkUkHuJ3jdiVi+btWnIAXJo48wqrNxhYS9KDUbMiih4 lP2AZzwpPDTDZsjns2zad7pxI4IEhtD5/3jrSIVK70CePseHq3V5Po8NIJpFXJzfOBQr SNO8IbtaNQ78kAceRNRrTvAytX3T1x8aATAq1Ceh6Qwdtl1dXPePywGHE57NFTjDgAWf YqsT3Ociq8yr2sylmrYDzmO2ZhZMXL1m9ynLr6r3HlEtP01InL9NBPYkWKbEfQ/LbQ+C Srsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d9UooUjAx6NBScigOGnH7Gz4QNuQjVumDoAAYHZwJ0I=; b=dZdj2SMSU/9WdwweE67PcfCnJNnhvUWYEQ2Y6X7h09tG9rI0kHsFHc/ZGKEGumfZok VlHCKv7jSuoaWEGUPJV4om8amCeHQJR96q4AzDkd2xOJgSvRw1bNQiDdUc+asGCTtNHx t0mvwFVEil3h/0f+p9D6/jj3mlyGSfShqGWmCH5AFkypsx6HUis01zLkRcvehETLkEJh 7IxUzEd+YUrMtkQkSfym4p0L+n3ojl3Kj1Xx6nVN09GrDaSzxhgaXK0nmMwTbTe/PIEW PzxjzjOX+k7sC21m1uKHSOk9j2425z/lg9Vb4rHKa4r2+UtbMltlJmRTofDfJiKx5efo Vc5A== X-Gm-Message-State: APjAAAUiLpbhPgl+8XcyNvxCP7iXw4uI5sTtQYweEULtOiKnMqZUDQgx JbAfML/SbjpqoW2L3uDE/w8= X-Google-Smtp-Source: APXvYqws+ecJtvqyZ24/vvgqtYW/1tC7KALjt0s11+al3CEJpigcuD4z8IOh5k+7gY1dQmXNq5KMpw== X-Received: by 2002:a17:90a:25ca:: with SMTP id k68mr25990305pje.14.1558888182933; Sun, 26 May 2019 09:29:42 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:3427:8c7f:94e8:c445]) by smtp.gmail.com with ESMTPSA id a11sm8671107pff.128.2019.05.26.09.29.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 May 2019 09:29:42 -0700 (PDT) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org Cc: Akinobu Mita , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Minwoo Im , Kenneth Heitke , Chaitanya Kulkarni Subject: [PATCH v3 3/3] nvme: notify thermal framework when temperature threshold events occur Date: Mon, 27 May 2019 01:29:03 +0900 Message-Id: <1558888143-5121-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558888143-5121-1-git-send-email-akinobu.mita@gmail.com> References: <1558888143-5121-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The NVMe controller supports the temperature threshold feature (Feature Identifier 04h) that enables to configure the asynchronous event request command to complete when the temperature is crossed its corresponding temperature threshold. This enables the reporting of asynchronous events from the controller when the temperature reached or exceeded a temperature threshold. In the case of the temperature threshold conditions, this notifies the thermal framework. Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Minwoo Im Cc: Kenneth Heitke Cc: Chaitanya Kulkarni Signed-off-by: Akinobu Mita --- * v3 - No changes since v2 drivers/nvme/host/core.c | 28 ++++++++++++++++++++++++++++ include/linux/nvme.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 4c8271a..26c8b59 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1186,6 +1186,9 @@ static void nvme_enable_aen(struct nvme_ctrl *ctrl) u32 result, supported_aens = ctrl->oaes & NVME_AEN_SUPPORTED; int status; + if (IS_ENABLED(CONFIG_THERMAL)) + supported_aens |= NVME_SMART_CRIT_TEMPERATURE; + if (!supported_aens) return; @@ -2470,6 +2473,16 @@ static void nvme_thermal_zones_unregister(struct nvme_ctrl *ctrl) } } +static void nvme_thermal_notify_framework(struct nvme_ctrl *ctrl) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ctrl->tzdev); i++) { + if (ctrl->tzdev[i]) + thermal_notify_framework(ctrl->tzdev[i], 0); + } +} + #else static inline int nvme_thermal_zones_register(struct nvme_ctrl *ctrl) @@ -2481,6 +2494,10 @@ static inline void nvme_thermal_zones_unregister(struct nvme_ctrl *ctrl) { } +static void nvme_thermal_notify_framework(struct nvme_ctrl *ctrl) +{ +} + #endif /* CONFIG_THERMAL */ struct nvme_core_quirk_entry { @@ -3901,6 +3918,16 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) } EXPORT_SYMBOL_GPL(nvme_remove_namespaces); +static void nvme_handle_aen_smart(struct nvme_ctrl *ctrl, u32 result) +{ + u32 aer_type = result & NVME_AER_TYPE_MASK; + u32 aer_info = (result >> NVME_AER_INFO_SHIFT) & NVME_AER_INFO_MASK; + + if (aer_type == NVME_AER_SMART && + aer_info == NVME_AER_SMART_TEMP_THRESH) + nvme_thermal_notify_framework(ctrl); +} + static void nvme_aen_uevent(struct nvme_ctrl *ctrl) { char *envp[2] = { NULL, NULL }; @@ -3922,6 +3949,7 @@ static void nvme_async_event_work(struct work_struct *work) struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, async_event_work); + nvme_handle_aen_smart(ctrl, ctrl->aen_result); nvme_aen_uevent(ctrl); ctrl->ops->submit_async_event(ctrl); } diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 54f0a13..8e7d599 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -507,6 +507,7 @@ enum { }; enum { + NVME_AER_TYPE_MASK = 0x7, NVME_AER_ERROR = 0, NVME_AER_SMART = 1, NVME_AER_NOTICE = 2, @@ -515,6 +516,12 @@ enum { }; enum { + NVME_AER_INFO_SHIFT = 8, + NVME_AER_INFO_MASK = 0xff, + NVME_AER_SMART_TEMP_THRESH = 0x01, +}; + +enum { NVME_AER_NOTICE_NS_CHANGED = 0x00, NVME_AER_NOTICE_FW_ACT_STARTING = 0x01, NVME_AER_NOTICE_ANA = 0x03, -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: akinobu.mita@gmail.com (Akinobu Mita) Date: Mon, 27 May 2019 01:29:03 +0900 Subject: [PATCH v3 3/3] nvme: notify thermal framework when temperature threshold events occur In-Reply-To: <1558888143-5121-1-git-send-email-akinobu.mita@gmail.com> References: <1558888143-5121-1-git-send-email-akinobu.mita@gmail.com> Message-ID: <1558888143-5121-4-git-send-email-akinobu.mita@gmail.com> The NVMe controller supports the temperature threshold feature (Feature Identifier 04h) that enables to configure the asynchronous event request command to complete when the temperature is crossed its corresponding temperature threshold. This enables the reporting of asynchronous events from the controller when the temperature reached or exceeded a temperature threshold. In the case of the temperature threshold conditions, this notifies the thermal framework. Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Minwoo Im Cc: Kenneth Heitke Cc: Chaitanya Kulkarni Signed-off-by: Akinobu Mita --- * v3 - No changes since v2 drivers/nvme/host/core.c | 28 ++++++++++++++++++++++++++++ include/linux/nvme.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 4c8271a..26c8b59 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1186,6 +1186,9 @@ static void nvme_enable_aen(struct nvme_ctrl *ctrl) u32 result, supported_aens = ctrl->oaes & NVME_AEN_SUPPORTED; int status; + if (IS_ENABLED(CONFIG_THERMAL)) + supported_aens |= NVME_SMART_CRIT_TEMPERATURE; + if (!supported_aens) return; @@ -2470,6 +2473,16 @@ static void nvme_thermal_zones_unregister(struct nvme_ctrl *ctrl) } } +static void nvme_thermal_notify_framework(struct nvme_ctrl *ctrl) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ctrl->tzdev); i++) { + if (ctrl->tzdev[i]) + thermal_notify_framework(ctrl->tzdev[i], 0); + } +} + #else static inline int nvme_thermal_zones_register(struct nvme_ctrl *ctrl) @@ -2481,6 +2494,10 @@ static inline void nvme_thermal_zones_unregister(struct nvme_ctrl *ctrl) { } +static void nvme_thermal_notify_framework(struct nvme_ctrl *ctrl) +{ +} + #endif /* CONFIG_THERMAL */ struct nvme_core_quirk_entry { @@ -3901,6 +3918,16 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) } EXPORT_SYMBOL_GPL(nvme_remove_namespaces); +static void nvme_handle_aen_smart(struct nvme_ctrl *ctrl, u32 result) +{ + u32 aer_type = result & NVME_AER_TYPE_MASK; + u32 aer_info = (result >> NVME_AER_INFO_SHIFT) & NVME_AER_INFO_MASK; + + if (aer_type == NVME_AER_SMART && + aer_info == NVME_AER_SMART_TEMP_THRESH) + nvme_thermal_notify_framework(ctrl); +} + static void nvme_aen_uevent(struct nvme_ctrl *ctrl) { char *envp[2] = { NULL, NULL }; @@ -3922,6 +3949,7 @@ static void nvme_async_event_work(struct work_struct *work) struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, async_event_work); + nvme_handle_aen_smart(ctrl, ctrl->aen_result); nvme_aen_uevent(ctrl); ctrl->ops->submit_async_event(ctrl); } diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 54f0a13..8e7d599 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -507,6 +507,7 @@ enum { }; enum { + NVME_AER_TYPE_MASK = 0x7, NVME_AER_ERROR = 0, NVME_AER_SMART = 1, NVME_AER_NOTICE = 2, @@ -515,6 +516,12 @@ enum { }; enum { + NVME_AER_INFO_SHIFT = 8, + NVME_AER_INFO_MASK = 0xff, + NVME_AER_SMART_TEMP_THRESH = 0x01, +}; + +enum { NVME_AER_NOTICE_NS_CHANGED = 0x00, NVME_AER_NOTICE_FW_ACT_STARTING = 0x01, NVME_AER_NOTICE_ANA = 0x03, -- 2.7.4