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