From patchwork Mon Feb 21 05:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=GRTC1xDA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BL462gxz9sFn for ; Mon, 21 Feb 2022 16:53:16 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dB-0000EB-R5; Mon, 21 Feb 2022 05:53:05 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1d8-0000DP-PJ for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:02 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 946443F1B6 for ; Mon, 21 Feb 2022 05:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422782; bh=GHZEiq90wdnkI8nK4T5wKiTVVLl2+ijIci3BNUido6Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GRTC1xDAivKi9bRYJP5eigMddB0lPQvP7kU/xeAZzLS1v/c5fVi3eGNDmrRh0xvYf fpNbRz6x7G8sZyJvqXIQF08L+lUEuxoSMMvDdPUGzGw5O1zd3tIxUrlENa31RfGcN2 k9z1Fhx54q99FlFk6GCSYjgAS04M9uZmhAfdtQR3PLrcCqTsujOFujiWRKDoW6uEco fzLAyOUepRlJRPEhRqG4zAXHZzw7lA73inCGylnuK+RehsASIcUov9mekl7DjBo32y QBiPBK5zAnThB/qb2Py4fwupKGyAOeKam1ig+vKut2v+wdFLOFHYwaGYyhaRI3WdZV /x1C2MIdCWYKQ== Received: by mail-pj1-f69.google.com with SMTP id y15-20020a17090a390f00b001b9fde42fd4so13646287pjb.0 for ; Sun, 20 Feb 2022 21:53:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GHZEiq90wdnkI8nK4T5wKiTVVLl2+ijIci3BNUido6Q=; b=XAToKFXu08xgTxVWbDP3LGt92qjH1f4k8jIY+y5/t9FRe1TfDlWnOpKbnioCyfbtRj Ag4X/3uoT3YjQLAc99KYTivgIggeRskOlqSUwZXdXSc+D9bb/0djGcKuBs03x0rzjBuT QkTeggKE4lzxoIM313/fjvMoBVKbOD8W8ftiuXelal+i9Wem2hhk9VnrRUi1ivEajBON /mjhVWc5FvjF7rGMFCtH/xKY1U38XaeA25Z8SBcZucSWED8ZXvwatp6e6z6TJtMxcF2/ RZnhJaWLX4rX5YZlKGcVLJ5p5FOBmx6vxLj5soa2SVFze3e3+aBdPFq0I/LYHMtvORZ+ fykQ== X-Gm-Message-State: AOAM533VYVomxFQtRxJ5S/ifKyqSripMYrgYf3XkJm3UlMVOjU5QNfZD r90vtZs2A4pFdYMgbNA9MJRCAcQK+Xv8PtjzPmyk54km7ITVlaQt++PKlz7PCTFqky6ONgMUdNV MvxiGoMuiEdGREaf7ktAZo36n1BdvYLcEjZrUDR2vVQ== X-Received: by 2002:a17:902:8d8b:b0:14f:795a:977a with SMTP id v11-20020a1709028d8b00b0014f795a977amr12898558plo.104.1645422780739; Sun, 20 Feb 2022 21:53:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJya3rfTUTOTLRG51OJp9QhVPSzfBopTOibXLIrnHfLuK55j9ws4q8PQFddBxA8R6MkQtBq7Fw== X-Received: by 2002:a17:902:8d8b:b0:14f:795a:977a with SMTP id v11-20020a1709028d8b00b0014f795a977amr12898532plo.104.1645422780361; Sun, 20 Feb 2022 21:53:00 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id p10sm11717059pfo.209.2022.02.20.21.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:52:59 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/7][SRU][OEM-5.14] HID: amd_sfh: Add command response to check command status Date: Sun, 20 Feb 2022 22:52:51 -0700 Message-Id: <20220221055257.1168996-2-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Sometimes sensor enable/disable may take time, without checking the actual status bits from MP2 FW can lead the amd-sfh to misbehave. Hence add a status check of enable/disable command by waiting on the command response before sending the next command to FW. Reviewed-by: Shyam Sundar S K Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit 173709f50e98df4c49c2776834605a2f7ed3e681) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 40 ++++++++++++++++++++++++-------- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 16 +++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 18 ++++++++++++++ 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 4710b9a..b7b66a1 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -123,14 +123,24 @@ static void amd_sfh_work_buffer(struct work_struct *work) int i; for (i = 0; i < cli_data->num_hid_devices; i++) { - report_size = get_input_report(i, cli_data->sensor_idx[i], cli_data->report_id[i], - in_data); - hid_input_report(cli_data->hid_sensor_hubs[i], HID_INPUT_REPORT, - in_data->input_report[i], report_size, 0); + if (cli_data->sensor_sts[i] == SENSOR_ENABLED) { + report_size = get_input_report + (i, cli_data->sensor_idx[i], cli_data->report_id[i], in_data); + hid_input_report(cli_data->hid_sensor_hubs[i], HID_INPUT_REPORT, + in_data->input_report[i], report_size, 0); + } } schedule_delayed_work(&cli_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); } +u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts) +{ + if (mp2->mp2_ops->response) + sensor_sts = mp2->mp2_ops->response(mp2, sid, sensor_sts); + + return sensor_sts; +} + int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) { struct amd_input_data *in_data = &privdata->in_data; @@ -139,8 +149,8 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) struct device *dev; u32 feature_report_size; u32 input_report_size; + int rc, i, status; u8 cl_idx; - int rc, i; dev = &privdata->pdev->dev; @@ -155,7 +165,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) in_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8, &cl_data->sensor_dma_addr[i], GFP_KERNEL); - cl_data->sensor_sts[i] = 0; + cl_data->sensor_sts[i] = SENSOR_DISABLED; cl_data->sensor_requested_cnt[i] = 0; cl_data->cur_hid_dev = i; cl_idx = cl_data->sensor_idx[i]; @@ -201,7 +211,10 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) if (rc) return rc; privdata->mp2_ops->start(privdata, info); - cl_data->sensor_sts[i] = 1; + status = amd_sfh_wait_for_response + (privdata, cl_data->sensor_idx[i], SENSOR_ENABLED); + if (status == SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_ENABLED; } schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); return 0; @@ -224,10 +237,17 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) { struct amdtp_cl_data *cl_data = privdata->cl_data; struct amd_input_data *in_data = cl_data->in_data; - int i; + int i, status; - for (i = 0; i < cl_data->num_hid_devices; i++) - privdata->mp2_ops->stop(privdata, i); + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { + privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (privdata, cl_data->sensor_idx[i], SENSOR_DISABLED); + if (status != SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + } + } cancel_delayed_work_sync(&cl_data->work); cancel_delayed_work_sync(&cl_data->work_buffer); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 1b4a192..ef2df3b 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,20 @@ static int sensor_mask_override = -1; module_param_named(sensor_mask, sensor_mask_override, int, 0444); MODULE_PARM_DESC(sensor_mask, "override the detected sensors mask"); +static int amd_sfh_wait_response_v2(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts) +{ + union cmd_response cmd_resp; + + /* Get response with status within a max of 800 ms timeout */ + if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp, + (cmd_resp.response_v2.response == sensor_sts && + cmd_resp.response_v2.status == 0 && (sid == 0xff || + cmd_resp.response_v2.sensor_id == sid)), 500, 800000)) + return cmd_resp.response_v2.response; + + return SENSOR_DISABLED; +} + static void amd_start_sensor_v2(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) { union sfh_cmd_base cmd_base; @@ -183,6 +198,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 = { .start = amd_start_sensor_v2, .stop = amd_stop_sensor_v2, .stop_all = amd_stop_all_sensor_v2, + .response = amd_sfh_wait_response_v2, }; static const struct amd_mp2_ops amd_sfh_ops = { diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 2d5c57e..21ef55d 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -24,12 +24,16 @@ #define AMD_C2P_MSG2 0x10508 #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4)) +#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4)) /* MP2 P2C Message Registers */ #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */ #define V2_STATUS 0x2 +#define SENSOR_ENABLED 4 +#define SENSOR_DISABLED 5 + #define HPD_IDX 16 /* SFH Command register */ @@ -51,6 +55,19 @@ union sfh_cmd_base { } cmd_v2; }; +union cmd_response { + u32 resp; + struct { + u32 status : 2; + u32 out_in_c2p : 1; + u32 rsvd1 : 1; + u32 response : 4; + u32 sub_cmd : 8; + u32 sensor_id : 6; + u32 rsvd2 : 10; + } response_v2; +}; + union sfh_cmd_param { u32 ul; struct { @@ -117,5 +134,6 @@ struct amd_mp2_ops { void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info); void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx); void (*stop_all)(struct amd_mp2_dev *privdata); + int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); }; #endif From patchwork Mon Feb 21 05:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Egx34CT7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BL71PZSz9sFh for ; Mon, 21 Feb 2022 16:53:18 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dF-0000GI-0d; Mon, 21 Feb 2022 05:53:09 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dA-0000Dd-4q for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:04 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id A54153F1B6 for ; Mon, 21 Feb 2022 05:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422783; bh=8TlXtmbL6jMgqlTPwdXEUHyan43IzvCz2JHzrSM2iYs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Egx34CT7zwftD0mhksHiCb8hlQLfBu2fS4r7980lfa5szOWQ85+K9sJMVs65vq4oC i8qMDNj1lzRVuag3nUFjmo0gcrxXE5h0XM6GlQ8Oc2Q/w/Dr6TyttDlMSBJgz7RmOA skRWxoUVESCNvKAZh2jSkUoC5uVPUxqkd0YrkcYASK1yIwKqqOIlxaKWU35AhBOEQs JGZcNcLFD6Iz+HQou591hN/J4LlfGjt5gOP4jrjgPk94cORdO+m81YMy3ik/Kc7G67 58nXVTkhWS6MsGzsrhdiT6kfFSP7pFMHVSAI4TbNzDgi6NYr5STEeVbT4b9cilXA8v VhEsJLch/m9zQ== Received: by mail-pg1-f199.google.com with SMTP id m15-20020a63580f000000b00370dc6cafe9so8895265pgb.5 for ; Sun, 20 Feb 2022 21:53:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8TlXtmbL6jMgqlTPwdXEUHyan43IzvCz2JHzrSM2iYs=; b=F/zoQwpeh/SGxgUh6wk6/Yg2/0beqCO7/GFAYTPPK6b64rlLOUY6OUtqYashI1O/U6 zdaIDjjEBxH5X+nD29XZ1geq21HCnQCCxlOP80twGD+6gny5DarmVu2gzrNTPcX/tz3i ng6GK6Bb713QZSefSGscFNJ/oYlgca/xVfxe80m5EbxWOZmJI6ogQRTCEY4KkwMBIGag YDC9DdcKhrdBsZBOFL8IXBDHm0jW2GtcQLrzveH7gRa5xbfo7L7YcS3mOErzkuKD7635 Rjo5hRouXd9QrNhTaYTozjTJNPNwF7AI4234m++D6kw/Y1Z1llaTM6mJAIQcXuOtNH0Q jPYg== X-Gm-Message-State: AOAM533l6zkEpz07WuVYoKoRfGliZAjh/XuwgAv/LfYdhvoSjLQknqcO NUK2Q1PQthR2qKozclLpQOzwziPFBHYdg4fvBlNa4BidEotRn8bULU/PefYp3EMRPtxXW08YEyo 9+bVkQqf/tzmGOisy+q9a5ikNIqbu1b5eMQ2YEUFk1A== X-Received: by 2002:a63:4c55:0:b0:36c:54eb:fc44 with SMTP id m21-20020a634c55000000b0036c54ebfc44mr14737925pgl.323.1645422782015; Sun, 20 Feb 2022 21:53:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoaDM3ChCcpsGC8B8/PhpfcLyVM7OhI6k1+DyFb6CuLb6q4gCRwM0EE4HA9yaO2mn4rOFhJQ== X-Received: by 2002:a63:4c55:0:b0:36c:54eb:fc44 with SMTP id m21-20020a634c55000000b0036c54ebfc44mr14737909pgl.323.1645422781657; Sun, 20 Feb 2022 21:53:01 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id b8sm11381400pfv.74.2022.02.20.21.53.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:01 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/7][SRU][OEM-5.14] HID: amd_sfh: Add support for PM suspend and resume Date: Sun, 20 Feb 2022 22:52:52 -0700 Message-Id: <20220221055257.1168996-3-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Add support for power management routines. Reviewed-by: Shyam Sundar S K Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit 0873d1afacd2167e717ea751fe7274011cb4c26a) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 1 - drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 49 ++++++++++++++++++++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 5 ++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index b7b66a1..e8aabde 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -17,7 +17,6 @@ #include "amd_sfh_pcie.h" #include "amd_sfh_hid.h" -#define AMD_SFH_IDLE_LOOP 200 struct request_list { struct hid_device *hid; diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index ef2df3b..2a40f32a 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -264,6 +264,54 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); } +static int __maybe_unused amd_mp2_pci_resume(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev); + struct amdtp_cl_data *cl_data = mp2->cl_data; + struct amd_mp2_sensor_info info; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_sts[i] == SENSOR_DISABLED) { + info.period = AMD_SFH_IDLE_LOOP; + info.sensor_idx = cl_data->sensor_idx[i]; + info.dma_address = cl_data->sensor_dma_addr[i]; + mp2->mp2_ops->start(mp2, info); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], SENSOR_ENABLED); + if (status == SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_ENABLED; + } + } + + return 0; +} + +static int __maybe_unused amd_mp2_pci_suspend(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev); + struct amdtp_cl_data *cl_data = mp2->cl_data; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_idx[i] != HPD_IDX && + cl_data->sensor_sts[i] == SENSOR_ENABLED) { + mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], SENSOR_DISABLED); + if (status != SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + } + } + + return 0; +} + +static SIMPLE_DEV_PM_OPS(amd_mp2_pm_ops, amd_mp2_pci_suspend, + amd_mp2_pci_resume); + static const struct pci_device_id amd_mp2_pci_tbl[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2) }, { } @@ -274,6 +322,7 @@ static struct pci_driver amd_mp2_pci_driver = { .name = DRIVER_NAME, .id_table = amd_mp2_pci_tbl, .probe = amd_mp2_pci_probe, + .driver.pm = &amd_mp2_pm_ops, }; module_pci_driver(amd_mp2_pci_driver); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 21ef55d..1ff6f83 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -36,6 +36,8 @@ #define HPD_IDX 16 +#define AMD_SFH_IDLE_LOOP 200 + /* SFH Command register */ union sfh_cmd_base { u32 ul; @@ -129,6 +131,9 @@ void amd_stop_all_sensors(struct amd_mp2_dev *privdata); int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id); int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata); int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata); +u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); +void amd_mp2_suspend(struct amd_mp2_dev *mp2); +void amd_mp2_resume(struct amd_mp2_dev *mp2); struct amd_mp2_ops { void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info); From patchwork Mon Feb 21 05:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=nyE4I+ct; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BL82ktbz9sFh for ; Mon, 21 Feb 2022 16:53:20 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dF-0000Gc-9l; Mon, 21 Feb 2022 05:53:09 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dB-0000E4-NY for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:05 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id B298E3F1A4 for ; Mon, 21 Feb 2022 05:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422784; bh=/RlEous0KBUoU6M2CpTmZ2KZ69KIea4zqjGSFcWR8Kk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nyE4I+ct7hSAsS0Uw7HJ9QuUuBgpow1qtF9YjY2XRlDdnm19wPibtLnns2KugLB7c ed+Ze9iWHEn+0nfsuCtBcBeLLRaS0gzKzfvgCllDT2WR1Od2KGEHe4k2WEk6WA6SiD 352zgZCx1YCJpGIs+GY/7jCyHJTK5vkGQ+G67vz9YVcFHUS+B/rkp9+Riqn4tD7i+K CcIFkvNJ++YZvFRVdrpa2G3NXmw+ksPUKCFjxZyJpqjYWghI5/LqCehgBWo2mrWJMA 7nunUOYgtpJR716wIdPMU04xyl0bLIK29DmLbhjiAPNX+5Z0Anu2Cc3q6ULIrMLe5X cCjl6SUIUXxpA== Received: by mail-pl1-f199.google.com with SMTP id b5-20020a170902e94500b0014f6d0a417bso1722546pll.6 for ; Sun, 20 Feb 2022 21:53:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/RlEous0KBUoU6M2CpTmZ2KZ69KIea4zqjGSFcWR8Kk=; b=X8AFZF+9uDKiEnOtmqfC5bujPUpLnNfvgTURhzbKUPOlu14H+76XSciGp8cIe5oJ0x 4tqQ6B3eUOiuSQ1gJJGWfxOcSOkJVd1qzOR8ApPF5TCacXi7mBjCVfCXiiqODhuG82p0 l82uqayFSK9Kdb6ogCyjLBj8aS42p1leCxiRx/wEqGkTKCbp6MQUs0xHeLW0UwO8pNO5 Ts3mZeLKDYLrS6hWEKROKGZVcqoiwQrK9HENTxPLJR1IF/X138ymID/QOVjdCn6keRdo Xec7AfJ+fcZ3EUJw0Eo4LtB75HuisSXmRwQNA804X0Ns3501N/MeZC7Swd1qyinJy7Tz gYSw== X-Gm-Message-State: AOAM530p8eucgOudq3eKcIt/4ng+OXoZoXYfXZyAPwKMZaYTPVTcCpig TlknI70MTpVB07Jx2AcdIHODxMh49CIK4UF4NiujCCFTcuryRCBGHCg5qYSZi0uP/E1jfowd0sk FImto6nUS4Qe/yO+986gGiMNwGkxK7Is9fhMrOQ5DUg== X-Received: by 2002:a17:902:854a:b0:14e:e053:c8b3 with SMTP id d10-20020a170902854a00b0014ee053c8b3mr17674986plo.8.1645422783218; Sun, 20 Feb 2022 21:53:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4uChiiHlVZKxy5oDI0C+zCNByGFg8H/qSO+GGiX8wamb9OOw3jhzE9wJAAtDUr+P2yAOrHA== X-Received: by 2002:a17:902:854a:b0:14e:e053:c8b3 with SMTP id d10-20020a170902854a00b0014ee053c8b3mr17674973plo.8.1645422782882; Sun, 20 Feb 2022 21:53:02 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id h26sm17291136pgm.72.2022.02.20.21.53.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:02 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/7][SRU][OEM-5.14] HID: amd_sfh: Handle amd_sfh work buffer in PM ops Date: Sun, 20 Feb 2022 22:52:53 -0700 Message-Id: <20220221055257.1168996-4-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Since in the current amd_sfh design the sensor data is periodically obtained in the form of poll data, during the suspend/resume cycle, scheduling a delayed work adds no value. So, cancel the work and restart back during the suspend/resume cycle respectively. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit 0cf74235f4403b760a37f77271d2ca3424001ff9) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 2a40f32a..6ecf1f0 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -285,6 +285,8 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev) } } + schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); + return 0; } @@ -306,6 +308,8 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev) } } + cancel_delayed_work_sync(&cl_data->work_buffer); + return 0; } From patchwork Mon Feb 21 05:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=jNPWD0W9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BL973Jxz9sFn for ; Mon, 21 Feb 2022 16:53:21 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dH-0000Jt-Jm; Mon, 21 Feb 2022 05:53:11 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dC-0000EX-1W for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:06 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id DC1EA3F1B6 for ; Mon, 21 Feb 2022 05:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422785; bh=rFksf45M30eK9FVziHg4dgFkAetxH22npxlvO4IlITc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jNPWD0W9WVazxM4NvB8fyLi8pFwKg2L7A+Syb/v2RZuxDjbxZvh3MRflEtUvKDpnB X7r36DMP4oPiPOotirTs+Ii/jKoK24UaX/iNVo08twocc0MlcPVTSy1XbZe5chFYbJ dpl2v74CN0kU5YN/pJEw98ETw2tssgozow3ALAqVvFl0NLc4G6vbzS2d2oqHbUTgVT Qcp0qxrZLTLozX5e5t7GLrpmZuAC4kyjg2+RgMXBPr7qO6HjcsPxEaAyulnrbrIKhB QzuMUd7zrN8SO/NoaUj39SWwtpITuNINkdxnjz3WmSJypABhZb6aZLQY9du+WbZxfh dgUmUvKfjXG4g== Received: by mail-pl1-f197.google.com with SMTP id p16-20020a170902a41000b0014992c5d56bso4097888plq.19 for ; Sun, 20 Feb 2022 21:53:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rFksf45M30eK9FVziHg4dgFkAetxH22npxlvO4IlITc=; b=2P/SCagO1wGwZB1fPz6BTGVtEeZV1+eBHPbP1lfvZIhEiszrKF1PjJ9JmmP13BSpLw 6thTraEGAHXlWnroYAEQryMt9faFfi7kh7w9j2kTpiaCQ6rcRyxFziyDtPYONNV7IF/O TPKP7TKXsI2YCHPxWt8i342lBwAXQg9Bo/JS6jCEgNnkaOZfYc6hgqgs87X6VtVYjb9Y 1wWmzdBpgI2e9vEeuNjER4b/hiZeA7ct8orWHjNzvxYjskE4zIR56IOK1UnmTnUBI+JP CEzrZhZkZJ9Z/Y69QyqKrWb0QnLU1h3OsezqFv9iqp/RCPzaWHghSKKu4j8wlg/euBFi BQpA== X-Gm-Message-State: AOAM5331U9GZrzIrJC4sk4X+Mn3wSPB0sU7SD2P5EeK4dMvdMlSO7srA 7z8u+NgOwSzbYRkKLZaHllCOyNBStDZsv2YUtHlpBfZXlDyoaSSgkZEcUk8qcUg7hj2blqv70H3 l8qRDfEov08ktsAFPSQ0FbP8e041qEahcWhxDtlx7hw== X-Received: by 2002:a63:f252:0:b0:373:416d:c8db with SMTP id d18-20020a63f252000000b00373416dc8dbmr15036230pgk.568.1645422784309; Sun, 20 Feb 2022 21:53:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe9C+BbnfxZMySO5SlFdyrW0pzsKf5ObNto+YvTK6gEpNscvz0CWQZBrq69PjQonioaBRzkg== X-Received: by 2002:a63:f252:0:b0:373:416d:c8db with SMTP id d18-20020a63f252000000b00373416dc8dbmr15036217pgk.568.1645422784004; Sun, 20 Feb 2022 21:53:04 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id a17sm11671910pfv.23.2022.02.20.21.53.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:03 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/7][SRU][OEM-5.14] HID: amd_sfh: Correct the structure field name Date: Sun, 20 Feb 2022 22:52:54 -0700 Message-Id: <20220221055257.1168996-5-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Misinterpreted intr_enable field name. Hence correct the structure field name accordingly to reflect the functionality. Fixes: f264481ad614 ("HID: amd_sfh: Extend driver capabilities for multi-generation support") Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit aa0b724a2bf041036e56cbb3b4b3afde7c5e7c9e) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 1ff6f83..9c91192 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -48,7 +48,7 @@ union sfh_cmd_base { } s; struct { u32 cmd_id : 4; - u32 intr_enable : 1; + u32 intr_disable : 1; u32 rsvd1 : 3; u32 length : 7; u32 mem_type : 1; From patchwork Mon Feb 21 05:52:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=C+is5Kn8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BL92Q6hz9sFh for ; Mon, 21 Feb 2022 16:53:21 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dF-0000HY-T0; Mon, 21 Feb 2022 05:53:09 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dD-0000FG-Cz for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:07 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 361F93F1B6 for ; Mon, 21 Feb 2022 05:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422787; bh=UeHbWvNZKXEjeXNDVqVUnbaYLgRWj5FQXnMCur5IND0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C+is5Kn8EXo+vptUyW55ZVXD166lieT+id4/DkbXkWuGeyZ1w5LRTGmrhSL81J7ho xsopwhWlHplvYBUaIRYa+H4yT4lQflaSVMhvSJJU0B+ZXkmMX+jPOvwggomXwkJ4jg rAWKYRG/M/8rPoACYcIGP60LT0cX5yxgmbMmPH/Rs7D30sPFQwQrKOfxqhnLP4N4da nkiMR3Zq4Gdw06vnEUiaSjjDmeWec/I0WkfgZhs5XHNW9yEkkSnKQN+sphd8eKhy58 /bbx5qe+woQmXbKIBjWH46YTmL3LZUTvWvPMbjy6dNiqgysWYmGJxQBzr9vA08KPSp F9TJItxUHDkUQ== Received: by mail-pg1-f199.google.com with SMTP id r8-20020a638f48000000b0036c6a881088so8893689pgn.2 for ; Sun, 20 Feb 2022 21:53:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UeHbWvNZKXEjeXNDVqVUnbaYLgRWj5FQXnMCur5IND0=; b=WbMJy6ShlFFYi28dEw+DWAHw80RScwmIXdC6VIF9SmnN8MzNl3ekSJJD5OUfzymxFL nqf1WxKbxCFFkg2VsbzfFSJFuB/CGNT/CLsuCwNQ9I7mCVprnQxsUvqa6cbBkdeNBw26 MUv6S9r2Z4dk/qxZyIHxKP4mjW55+aKovE3o7uJOknXxQuLvtu/QExd7UJyaVVBeVwRx 9AKbkE+TZiqjxvI+teRVxhEwyuw5xIV7h0uzt0+XrRi2cqAwZjt189PAFNwsjsiaoJEf Uapzo3qrxl1VPaFu8imol4T0aPjVVXiY2pGyu2BE8S8t69C1Ur4TOwhg+nVNxb0qnoue ArxQ== X-Gm-Message-State: AOAM530O24O/zcN8jgqecKL4U0hYkkSptdpoSZq+lGqStGWlyLqvnR+a UA0xNDHkI4UwUDLWvQHbdJNDC1qFBWPttY0HISi5Rz6jqQN1d4p4ZUrgdP9GFmDAfnKVAst3t7r u0bRzyQZysS845clSHKA3Q1UmSAEHfxZE1FZGepZJzQ== X-Received: by 2002:a17:903:31c9:b0:14f:3f88:1aeb with SMTP id v9-20020a17090331c900b0014f3f881aebmr17795426ple.130.1645422785679; Sun, 20 Feb 2022 21:53:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmW5Ta764d6YG5UT5TGZrH3k/LXwroo2dD5Hhrw5ks9SmUyc8RgrRDC75jnRT7Nv87l++4/Q== X-Received: by 2002:a17:903:31c9:b0:14f:3f88:1aeb with SMTP id v9-20020a17090331c900b0014f3f881aebmr17795412ple.130.1645422785337; Sun, 20 Feb 2022 21:53:05 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id k9sm11604433pfc.157.2022.02.20.21.53.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:04 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/7][SRU][OEM-5.14] HID: amd_sfh: Disable the interrupt for all command Date: Sun, 20 Feb 2022 22:52:55 -0700 Message-Id: <20220221055257.1168996-6-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Sensor data is processed in polling mode. Hence disable the interrupt for all sensor command. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 6ecf1f0..14c1612 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -52,6 +52,7 @@ static void amd_start_sensor_v2(struct amd_mp2_dev *privdata, struct amd_mp2_sen cmd_base.ul = 0; cmd_base.cmd_v2.cmd_id = ENABLE_SENSOR; + cmd_base.cmd_v2.intr_disable = 1; cmd_base.cmd_v2.period = info.period; cmd_base.cmd_v2.sensor_id = info.sensor_idx; cmd_base.cmd_v2.length = 16; @@ -69,6 +70,7 @@ static void amd_stop_sensor_v2(struct amd_mp2_dev *privdata, u16 sensor_idx) cmd_base.ul = 0; cmd_base.cmd_v2.cmd_id = DISABLE_SENSOR; + cmd_base.cmd_v2.intr_disable = 1; cmd_base.cmd_v2.period = 0; cmd_base.cmd_v2.sensor_id = sensor_idx; cmd_base.cmd_v2.length = 16; @@ -82,6 +84,7 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata) union sfh_cmd_base cmd_base; cmd_base.cmd_v2.cmd_id = STOP_ALL_SENSORS; + cmd_base.cmd_v2.intr_disable = 1; cmd_base.cmd_v2.period = 0; cmd_base.cmd_v2.sensor_id = 0; From patchwork Mon Feb 21 05:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=amThrz7Q; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BLC3jPXz9sFh for ; Mon, 21 Feb 2022 16:53:23 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dI-0000L3-1E; Mon, 21 Feb 2022 05:53:12 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dE-0000G3-Mt for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:08 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 78E233F1B6 for ; Mon, 21 Feb 2022 05:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422788; bh=8yfw+IxmSmW2YRlBoob61NYtHnqI7faUmw93gyz4PEQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=amThrz7QJuA1xqvf5QqvZEhLCZSR97O+mMaGaeHgic/nPnPgw119wBqG+GBk9sCuK 2/jRpjc25Sx8K2xjoVNWncoaB3iO+evxGD4LSbAUX7+Lp5q6Int9T81hejJBiOCqh+ 5DcFlZHwNFvIseUBpSVygGFGub1nywEqe2hpvVpIjgsn1pp64nS4+8dwmSRCcjHmKC j8KUAPsiO6CGpIF0oREbY+vqEDMj5e65GVB/5R93xncnCqsT7QgPSKw8BnM8+KNwR9 C3SH9F6na9I+pdIaC80okyQ1x8M+ZyeCqrz3EpgLIBylDXsJwDgSMSEdJvREoYtT3U /88s8DhgHLlaw== Received: by mail-pg1-f197.google.com with SMTP id bh9-20020a056a02020900b0036c0d29eb3eso8891034pgb.9 for ; Sun, 20 Feb 2022 21:53:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8yfw+IxmSmW2YRlBoob61NYtHnqI7faUmw93gyz4PEQ=; b=6pUvsqBsxgbSfR388LvRiBK96xMsjVWExrtPw67L+gyfFhx/OllxSPrxSzsmcD6d25 jZqmTVnF7bL/q4g1Olnyledufewj3rQPLmRe4B6sp82qEhk6nmTY5vCewlZHBYlkZmPK 7QstwQzimbieeDsDFm2AoMX604FLrKo35EEMvV6KAYuVEkyfwi/9li+EdHMesho0PtL9 77hABI7p/5tfTjNEOA2Uffg9R7jKyLreMM6cojCAt51TREFbCIKpbJpaLs2B3iZA2w4b WknjvCBTYttboLoz2/esqwMB4gmhIR0w8hQAeVDnOBss+ELbdstX6E8mlckjqfruhER+ vjOg== X-Gm-Message-State: AOAM5312WT42QKXVSY8qC7aNeCu63phNpcHQkX3P2Ru11axa3aOsQptp oeEKj47rGB4+RO3CALktGKVvsi0YJOxKJmbqWX4iPVQIXvvJ6UqrUt0Vt2TDbLdLDmrNl7pcMDQ /mzxncJneqILgZBlGxMyH59LaYEcibee3PFhmE/SGBg== X-Received: by 2002:a17:90a:6c66:b0:1bc:52a2:18e8 with SMTP id x93-20020a17090a6c6600b001bc52a218e8mr611549pjj.180.1645422786864; Sun, 20 Feb 2022 21:53:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN26qzstLsKFYGwxkBa1NIRc0GhvyCzG7ITCDY/Z3QYrTSGCBZOPInrV8n1KUiDHH9SKMSfA== X-Received: by 2002:a17:90a:6c66:b0:1bc:52a2:18e8 with SMTP id x93-20020a17090a6c6600b001bc52a218e8mr611531pjj.180.1645422786581; Sun, 20 Feb 2022 21:53:06 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id g5sm11124791pfv.22.2022.02.20.21.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:06 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 6/7][SRU][OEM-5.14] HID: amd_sfh: Add functionality to clear interrupts Date: Sun, 20 Feb 2022 22:52:56 -0700 Message-Id: <20220221055257.1168996-7-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 Newer AMD platforms with SFH may generate interrupts on some events which are unwarranted. Until this is cleared the actual MP2 data processing maybe stalled in some cases. Add a mechanism to clear the pending interrupts (if any) during the driver initialization and sensor command operations. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit fb75a3791a8032848c987db29b622878d8fe2b1c) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 25 ++++++++++++++++++++++++- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 14c1612..7a2c1524 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -91,6 +91,20 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata) writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0); } +static void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata) +{ + if (readl(privdata->mmio + AMD_P2C_MSG(4))) { + writel(0, privdata->mmio + AMD_P2C_MSG(4)); + writel(0xf, privdata->mmio + AMD_P2C_MSG(5)); + } +} + +static void amd_sfh_clear_intr(struct amd_mp2_dev *privdata) +{ + if (privdata->mp2_ops->clear_intr) + privdata->mp2_ops->clear_intr(privdata); +} + void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) { union sfh_cmd_param cmd_param; @@ -195,6 +209,7 @@ static void amd_mp2_pci_remove(void *privdata) struct amd_mp2_dev *mp2 = privdata; amd_sfh_hid_client_deinit(privdata); mp2->mp2_ops->stop_all(mp2); + amd_sfh_clear_intr(mp2); } static const struct amd_mp2_ops amd_sfh_ops_v2 = { @@ -202,6 +217,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 = { .stop = amd_stop_sensor_v2, .stop_all = amd_stop_all_sensor_v2, .response = amd_sfh_wait_response_v2, + .clear_intr = amd_sfh_clear_intr_v2, }; static const struct amd_mp2_ops amd_sfh_ops = { @@ -261,8 +277,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i mp2_select_ops(privdata); rc = amd_sfh_hid_client_init(privdata); - if (rc) + if (rc) { + amd_sfh_clear_intr(privdata); + dev_err(&pdev->dev, "amd_sfh_hid_client_init failed\n"); return rc; + } + + amd_sfh_clear_intr(privdata); return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); } @@ -289,6 +310,7 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev) } schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); + amd_sfh_clear_intr(mp2); return 0; } @@ -312,6 +334,7 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev) } cancel_delayed_work_sync(&cl_data->work_buffer); + amd_sfh_clear_intr(mp2); return 0; } diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 9c91192..ee9818d 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -140,5 +140,6 @@ struct amd_mp2_ops { void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx); void (*stop_all)(struct amd_mp2_dev *privdata); int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); + void (*clear_intr)(struct amd_mp2_dev *privdata); }; #endif From patchwork Mon Feb 21 05:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1595343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=NSBmpq2O; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2BLJ20cnz9sFh for ; Mon, 21 Feb 2022 16:53:28 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nM1dP-0000VP-Vm; Mon, 21 Feb 2022 05:53:20 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nM1dG-0000HS-DD for kernel-team@lists.ubuntu.com; Mon, 21 Feb 2022 05:53:10 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8A7803F1A4 for ; Mon, 21 Feb 2022 05:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645422789; bh=S0h2LFytNkA1As0zhFy6JQjzfIyYXKNKJl/2jMSbb2I=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NSBmpq2OICEzzDeElG4nj4qxzd5uYfEXauE+OrJynUZZF9a5lJ2WyJRqlBobmwtbp g87J9ra83kwLPvomfl20dnNbZh50i9sctrVzHjTHHx03bzWVpt7eWXFKEheH7t//vL l61os6ycZqTqRCCMSZu77F0bxtYh0t7Aynv+pBZRqvm2+dq8IQqRQI5P0rKXWnyCFf Lr7vRKbioiPdnVpo7SXYgTebpyuUvugNm9rb0RHA38cKQIiAGM2UBR4dBlsmN/APkQ tCOlmvxcp3X5TLddjZoTTfK1bIBhfSpzP4VqvrO4okf2B+KfnvRLJyb6pgbROFkRYD U4TiqkKa7OpKw== Received: by mail-pj1-f71.google.com with SMTP id q68-20020a17090a17ca00b001bc1004382fso3581908pja.1 for ; Sun, 20 Feb 2022 21:53:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S0h2LFytNkA1As0zhFy6JQjzfIyYXKNKJl/2jMSbb2I=; b=ifCQpyFmUcbVk0hCDrCnTZAFSKL9m6mk0wppQOrIYlxWulbXzvsHM+f+hS2HEPCh/d x6x79xM4NEhEfAMzLbhhtPHZ2VeyutB7m/aNlJ5xQyOj21tHG+t3J3u1RWwMgwLiPPc4 Ar+Tp5vLA4DgEyt/96wgsQBSYaTHmdsLr+CLTVxx4//XyyNDeY0USvyO8BkrY5bSRx+o wMBztFQdsGvm8WIK/v+4Xexo6sCcCgYG8v3ismVWkRklszrE5wvZX8B2oTX+53vb5DdQ DrtmOF3W+KXKo04luKB3gW38/knj9PSc3GeL3aQMMM7Mx/bAMjdG8bq7I6Cu20ojeTP/ voCQ== X-Gm-Message-State: AOAM531jMQHG4yNYK6IbplXuXSAu4yKz3McyMR5xE74jO1unsmfbVqS8 08WOZs9xpMuhGALvdfITi5fYoAQBGdIWNn+bvForALE3PTE34QXBIH7AJB3jkSEY3qzUypYfDc/ H6Sgc35B18UUTdzmGgGv3zs7sZbwfsuXfVXDqHCeoRg== X-Received: by 2002:a17:90a:b798:b0:1bb:fa37:b019 with SMTP id m24-20020a17090ab79800b001bbfa37b019mr9561515pjr.108.1645422788002; Sun, 20 Feb 2022 21:53:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM/v2tWX+F5FQKya8MKkBS0oCdYuOOO5AKE8vNG8z3WNmnGpbQf+ERMPTevtsKbc5f6pwhSw== X-Received: by 2002:a17:90a:b798:b0:1bb:fa37:b019 with SMTP id m24-20020a17090ab79800b001bbfa37b019mr9561495pjr.108.1645422787712; Sun, 20 Feb 2022 21:53:07 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmfmg.ipv6.telus.net. [2001:56a:78ed:fb00::998]) by smtp.gmail.com with ESMTPSA id b14sm11116484pfm.17.2022.02.20.21.53.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 21:53:07 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 7/7][SRU][OEM-5.14] HID: amd_sfh: Add interrupt handler to process interrupts Date: Sun, 20 Feb 2022 22:52:57 -0700 Message-Id: <20220221055257.1168996-8-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221055257.1168996-1-alex.hung@canonical.com> References: <20220221055257.1168996-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Basavaraj Natikar BugLink: https://bugs.launchpad.net/bugs/1961121 On newer AMD platforms with SFH, it is observed that random interrupts get generated on the SFH hardware and until this is cleared the firmware sensor processing is stalled, resulting in no data been received to driver side. Add routines to handle these interrupts, so that firmware operations are not stalled. Signed-off-by: Basavaraj Natikar Signed-off-by: Jiri Kosina (cherry picked from commit 7f016b35ca7623c71b31facdde080e8ce171a697) Signed-off-by: Alex Hung --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 40 ++++++++++++++++++++++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + 2 files changed, 41 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 7a2c1524..71c0ed3 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -105,6 +105,30 @@ static void amd_sfh_clear_intr(struct amd_mp2_dev *privdata) privdata->mp2_ops->clear_intr(privdata); } +static irqreturn_t amd_sfh_irq_handler(int irq, void *data) +{ + amd_sfh_clear_intr(data); + + return IRQ_HANDLED; +} + +static int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata) +{ + int rc; + + pci_intx(privdata->pdev, true); + + rc = devm_request_irq(&privdata->pdev->dev, privdata->pdev->irq, + amd_sfh_irq_handler, 0, DRIVER_NAME, privdata); + if (rc) { + dev_err(&privdata->pdev->dev, "failed to request irq %d err=%d\n", + privdata->pdev->irq, rc); + return rc; + } + + return 0; +} + void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) { union sfh_cmd_param cmd_param; @@ -209,6 +233,7 @@ static void amd_mp2_pci_remove(void *privdata) struct amd_mp2_dev *mp2 = privdata; amd_sfh_hid_client_deinit(privdata); mp2->mp2_ops->stop_all(mp2); + pci_intx(mp2->pdev, false); amd_sfh_clear_intr(mp2); } @@ -218,6 +243,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 = { .stop_all = amd_stop_all_sensor_v2, .response = amd_sfh_wait_response_v2, .clear_intr = amd_sfh_clear_intr_v2, + .init_intr = amd_sfh_irq_init_v2, }; static const struct amd_mp2_ops amd_sfh_ops = { @@ -243,6 +269,14 @@ static void mp2_select_ops(struct amd_mp2_dev *privdata) } } +static int amd_sfh_irq_init(struct amd_mp2_dev *privdata) +{ + if (privdata->mp2_ops->init_intr) + return privdata->mp2_ops->init_intr(privdata); + + return 0; +} + static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct amd_mp2_dev *privdata; @@ -276,6 +310,12 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i mp2_select_ops(privdata); + rc = amd_sfh_irq_init(privdata); + if (rc) { + dev_err(&pdev->dev, "amd_sfh_irq_init failed\n"); + return rc; + } + rc = amd_sfh_hid_client_init(privdata); if (rc) { amd_sfh_clear_intr(privdata); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index ee9818d..00fc083 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -141,5 +141,6 @@ struct amd_mp2_ops { void (*stop_all)(struct amd_mp2_dev *privdata); int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); void (*clear_intr)(struct amd_mp2_dev *privdata); + int (*init_intr)(struct amd_mp2_dev *privdata); }; #endif