From patchwork Thu Jun 10 06:21:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Even Xu X-Patchwork-Id: 458764 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 424E9C48BDF for ; Thu, 10 Jun 2021 06:22:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A59F613F1 for ; Thu, 10 Jun 2021 06:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbhFJGYD (ORCPT ); Thu, 10 Jun 2021 02:24:03 -0400 Received: from mga17.intel.com ([192.55.52.151]:10599 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbhFJGYC (ORCPT ); Thu, 10 Jun 2021 02:24:02 -0400 IronPort-SDR: hr0E6rpYiVSTZb+h08JTMmAB2smKAK3rywVbubAfJyelSBVn9+DULpQxTRhfpQTQgSSEG14ULN 0NySbgpy0KNQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="185610252" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="185610252" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 23:22:02 -0700 IronPort-SDR: 361QJnCqPWnszfc2PolyEbGrj03wNWe1tcLr+jXA6pWDAqLl0mP3nMyEc7rDeAsX+osTQRRFCb dXj0llr0m58A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="482702846" Received: from shsensorbuild2.sh.intel.com ([10.239.132.180]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2021 23:22:00 -0700 From: Even Xu To: srinivas.pandruvada@linux.intel.com, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, Even Xu Subject: [PATCH 1/3] hid: intel-ish-hid: Set ISH driver depends on x86 Date: Thu, 10 Jun 2021 14:21:52 +0800 Message-Id: <1623306114-19208-2-git-send-email-even.xu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623306114-19208-1-git-send-email-even.xu@intel.com> References: <1623306114-19208-1-git-send-email-even.xu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org During ISH DMA enabling, some platforms (such as EHL) don't support cache snooping, driver needs involve clflush_cache_range API which isn't supported by all archs (such as ARM). Considering ISH only exists on Intel platforms, add the dependence in Kconfig to avoid build warnings or errors on other archs. Acked-by: Pandruvada, Srinivas Signed-off-by: Even Xu --- drivers/hid/intel-ish-hid/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/intel-ish-hid/Kconfig b/drivers/hid/intel-ish-hid/Kconfig index c6c9cfe2..689da84 100644 --- a/drivers/hid/intel-ish-hid/Kconfig +++ b/drivers/hid/intel-ish-hid/Kconfig @@ -5,6 +5,7 @@ menu "Intel ISH HID support" config INTEL_ISH_HID tristate "Intel Integrated Sensor Hub" default n + depends on X86 select HID help The Integrated Sensor Hub (ISH) enables the ability to offload From patchwork Thu Jun 10 06:21:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Even Xu X-Patchwork-Id: 458110 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 2FEEEC48BCD for ; Thu, 10 Jun 2021 06:22:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EC0E613E4 for ; Thu, 10 Jun 2021 06:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbhFJGYD (ORCPT ); Thu, 10 Jun 2021 02:24:03 -0400 Received: from mga17.intel.com ([192.55.52.151]:10603 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbhFJGYC (ORCPT ); Thu, 10 Jun 2021 02:24:02 -0400 IronPort-SDR: wTKdSUwOucPBMQIZV6Gtm3bXPn3MfI6LA7QO2GgdlVYpON322uVWf3f86bqqFGBq5ZnbRzO5a9 g9GYjPEA2iig== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="185610256" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="185610256" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 23:22:05 -0700 IronPort-SDR: XU6TCadIPGuNbVpJ6ae5zFbcYlDx2+qpS68heo9Ryle7BTaap6ODtyWF/oh3/74+GvCxA3BFBZ gXmJeeir8BJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="482702891" Received: from shsensorbuild2.sh.intel.com ([10.239.132.180]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2021 23:22:03 -0700 From: Even Xu To: srinivas.pandruvada@linux.intel.com, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, Even Xu Subject: [PATCH 2/3] hid: intel-ish-hid: ishtp: Add dma_no_cache_snooping() callback Date: Thu, 10 Jun 2021 14:21:53 +0800 Message-Id: <1623306114-19208-3-git-send-email-even.xu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623306114-19208-1-git-send-email-even.xu@intel.com> References: <1623306114-19208-1-git-send-email-even.xu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Different platforms have different DMA capability, on most of platforms, DMA support cache snooping. But few platforms, such as ElkhartLake (EHL), don't support cache snooping which requires cache flush from driver. So add a hardware level callback to let ishtp driver know if cache flush is needed. As most of platform support cache snooping, so driver will not do cache flush by default, until platform implements this callback and return true explicitly. Acked-by: Pandruvada, Srinivas Signed-off-by: Even Xu --- drivers/hid/intel-ish-hid/ishtp/client.c | 18 ++++++++++++++++++ drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/hid/intel-ish-hid/ishtp/client.c b/drivers/hid/intel-ish-hid/ishtp/client.c index 1cc1571..be443d6 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.c +++ b/drivers/hid/intel-ish-hid/ishtp/client.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "hbm.h" #include "client.h" @@ -773,6 +774,14 @@ static void ishtp_cl_send_msg_dma(struct ishtp_device *dev, /* write msg to dma buf */ memcpy(msg_addr, cl_msg->send_buf.data, cl_msg->send_buf.size); + /* + * if current fw don't support cache snooping, driver have to + * flush the cache manually. + */ + if (dev->ops->dma_no_cache_snooping && + dev->ops->dma_no_cache_snooping(dev)) + clflush_cache_range(msg_addr, cl_msg->send_buf.size); + /* send dma_xfer hbm msg */ off = msg_addr - (unsigned char *)dev->ishtp_host_dma_tx_buf; ishtp_hbm_hdr(&hdr, sizeof(struct dma_xfer_hbm)); @@ -997,6 +1006,15 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg, } buffer = rb->buffer.data; + + /* + * if current fw don't support cache snooping, driver have to + * flush the cache manually. + */ + if (dev->ops->dma_no_cache_snooping && + dev->ops->dma_no_cache_snooping(dev)) + clflush_cache_range(msg, hbm->msg_length); + memcpy(buffer, msg, hbm->msg_length); rb->buf_idx = hbm->msg_length; diff --git a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h index 1cc6364..e443dc9 100644 --- a/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +++ b/drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h @@ -118,6 +118,7 @@ struct ishtp_hw_ops { unsigned long buffer_length); uint32_t (*get_fw_status)(struct ishtp_device *dev); void (*sync_fw_clock)(struct ishtp_device *dev); + bool (*dma_no_cache_snooping)(struct ishtp_device *dev); }; /** From patchwork Thu Jun 10 06:21:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Even Xu X-Patchwork-Id: 458109 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 33828C47094 for ; Thu, 10 Jun 2021 06:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11D94613EC for ; Thu, 10 Jun 2021 06:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbhFJGYG (ORCPT ); Thu, 10 Jun 2021 02:24:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:10611 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbhFJGYF (ORCPT ); Thu, 10 Jun 2021 02:24:05 -0400 IronPort-SDR: mq1UJxuc1IV2w1XkST+/nzGEmjtex+Vpyf1Gfcj3Xj/SFzvLTgAYK7PVsKripuY2kKJ9Rg+GMJ jVfng+ZOu4ZQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="185610269" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="185610269" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 23:22:10 -0700 IronPort-SDR: uqd8o3yUzwQcQv82l5+O7O6CqraZQJ+nf8hXev/W3s5quidbY85zYrebySqcejH+0PAHCWzfx2 965lfUz23SRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="482702912" Received: from shsensorbuild2.sh.intel.com ([10.239.132.180]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2021 23:22:08 -0700 From: Even Xu To: srinivas.pandruvada@linux.intel.com, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, Even Xu Subject: [PATCH 3/3] hid: intel-ish-hid: ipc: Specify that EHL no cache snooping Date: Thu, 10 Jun 2021 14:21:54 +0800 Message-Id: <1623306114-19208-4-git-send-email-even.xu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623306114-19208-1-git-send-email-even.xu@intel.com> References: <1623306114-19208-1-git-send-email-even.xu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Specify that EHL doesn't support DMA cache snooping. Acked-by: Pandruvada, Srinivas Signed-off-by: Even Xu --- drivers/hid/intel-ish-hid/ipc/ipc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c index 47bbeb8..89ea2ff 100644 --- a/drivers/hid/intel-ish-hid/ipc/ipc.c +++ b/drivers/hid/intel-ish-hid/ipc/ipc.c @@ -889,6 +889,29 @@ static uint32_t ish_ipc_get_header(struct ishtp_device *dev, int length, return drbl_val; } +/** + * _dma_no_cache_snooping() + * + * Check on current platform, DMA supports cache snooping or not. + * This callback is used to notify uplayer driver if manully cache + * flush is needed when do DMA operation. + * + * Please pay attention to this callback implementation, if declare + * having cache snooping on a cache snooping not supported platform + * will cause uplayer driver receiving mismatched data; and if + * declare no cache snooping on a cache snooping supported platform + * will cause cache be flushed twice and performance hit. + * + * @dev: ishtp device pointer + * + * Return: false - has cache snooping capability + * true - no cache snooping, need manually cache flush + */ +static bool _dma_no_cache_snooping(struct ishtp_device *dev) +{ + return dev->pdev->device == EHL_Ax_DEVICE_ID; +} + static const struct ishtp_hw_ops ish_hw_ops = { .hw_reset = _ish_hw_reset, .ipc_reset = _ish_ipc_reset, @@ -897,7 +920,8 @@ static const struct ishtp_hw_ops ish_hw_ops = { .write = write_ipc_to_queue, .get_fw_status = _ish_read_fw_sts_reg, .sync_fw_clock = _ish_sync_fw_clock, - .ishtp_read_hdr = _ishtp_read_hdr + .ishtp_read_hdr = _ishtp_read_hdr, + .dma_no_cache_snooping = _dma_no_cache_snooping }; /**