Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp634370ybv; Thu, 13 Feb 2020 06:57:49 -0800 (PST) X-Google-Smtp-Source: APXvYqz6JoIqumgZ2vxxlDGIHgUp7UQFg2j5DagBxXW902Z3/xjAOZHcm7ehRO6SXLxaGiSSpclJ X-Received: by 2002:aca:3805:: with SMTP id f5mr3175180oia.6.1581605869438; Thu, 13 Feb 2020 06:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581605869; cv=none; d=google.com; s=arc-20160816; b=skl/6etGYhAsp1SrhYnzeiV2z/xsiVC8NWSZRuuTiPq91QyiN6QLAm9zQCvxmRsjqN d+7rorMJaQhwMc1l40OO1TUkkOHxMldS1a5Nicjja8icjKVcVct1fHJLS4X/xvCFi3FG GS8rEkoVUxQZnJ23NVLD9Gfi/nWvLVRjkEwn2IxgboEU/COOrjNK0geiWFuQRdtIMjZE Um+gTrz03QBFxDwl938DMKzQ8lNzVg9+QNEiwUQByGhptl4WntETkcQnH8LxExhW9wVY ncKyPOsFbpzN5PJ78LUo5Ny+37KZ29pdaxE60t+wzCJzNeDAi7RXa2jZ7XmBMhBP/rkB hQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OG+hnrSnkCgWf7UG021Y7MWPAq7aPjND81Zb6RKMks0=; b=mYRtfXTzYEj0UvgaGOFLWxIXto2+ygRFC0JBBvT30dbZkpXoTelieXVo4JUdzugzBN Q6Z+0YaYLAaM2verh/1Jnl+2WC1xmJSyIwJXl9LghSo2eo7qkWxVji54xgnD52OIUqZo aWlYBn/TKsuPtRNHqokoR4xDI+HROS95l0CKHxhgvScoqlipn5bo0GdL+Aiy7FR42ONK AnxHscQknOz2d7iMxHPyKjAvqLneo0QWEbsZUWvboxIzp9itLgLmLEeqxCXGrSPLH7LE XxQQJ4vopOtLL3JnQIN0CXrWDVoWOz65XBNQVB9q/L6gelYt7hasOdfJy0K3ii52EQWc ug8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ASHeKd4G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si1139576oij.118.2020.02.13.06.57.36; Thu, 13 Feb 2020 06:57:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ASHeKd4G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbgBMO5R (ORCPT + 99 others); Thu, 13 Feb 2020 09:57:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45587 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726390AbgBMO5R (ORCPT ); Thu, 13 Feb 2020 09:57:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581605835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OG+hnrSnkCgWf7UG021Y7MWPAq7aPjND81Zb6RKMks0=; b=ASHeKd4G1NISrcqezwbZKd03mykmxNrIwZmAS8pcNlP3CTA3lrKKvoHugX3O7xQ45kItx+ 9mpbLSFFWGpq1U5h629HwG1vCRGQKToZ164D534hiQ2uJfZ3QtUC055XUBKznyo7DBCYBC jVU6THMIBz0+GosFWpaFGcgtkJWlqYg= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-BhwKaHaJNd6Fz_mzmR2yrw-1; Thu, 13 Feb 2020 09:57:08 -0500 X-MC-Unique: BhwKaHaJNd6Fz_mzmR2yrw-1 Received: by mail-qk1-f200.google.com with SMTP id c206so3874432qkg.6 for ; Thu, 13 Feb 2020 06:57:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OG+hnrSnkCgWf7UG021Y7MWPAq7aPjND81Zb6RKMks0=; b=HYPpPVPTh7vdK9LJe/5dtvQn4PNY64ZroE3+WurPbr1mINYqT5pTNxNzY5a3C6ZGJc zrmwwjgW+4yXhjiti/QlVwW29odwSNu3qTHuA7Mi1t7NL5sNbjSXhVqys8agETIUZwGK Hzdulke3HtK63qBWVegS9nmfhzjdelhq7hzqlG7T66f4iznhSseopCAPp1lQkCh0L5z1 XB7eo+l8e7g3rc/qOr2F6kPBNZu8ouWL9wYXv9eoErmJIiJd7xc/5H+Obdualj+ti209 QVah6vjYLD1jR9bp9C5UCEu3yj0Rli0eVZEG6OC3ktB0WhjJHP4UZsB3XHRQYZTiA6VB caow== X-Gm-Message-State: APjAAAV6N2CcrYHV7yA+wLx7xt2284UT6Ds4Uy7i2Pe9I80lxVfQhkTe crJ7uqh29osVrE8R8hS/eI5i2H9oqWlAenVZbKCwFUb4vbBHbnCMHYsDbe+LJgQUc519v5BlFi1 +w/8Yw/Fk6xgRh90Wex9jv1cXbfwmvgcIKaOMjjOQ X-Received: by 2002:a0c:b61c:: with SMTP id f28mr12127443qve.101.1581605828169; Thu, 13 Feb 2020 06:57:08 -0800 (PST) X-Received: by 2002:a0c:b61c:: with SMTP id f28mr12127419qve.101.1581605827808; Thu, 13 Feb 2020 06:57:07 -0800 (PST) MIME-Version: 1.0 References: <1581476197-25854-1-git-send-email-Sandeep.Singh@amd.com> <1ce6f591-1e8b-8291-7f18-48876fd70e10@redhat.com> In-Reply-To: <1ce6f591-1e8b-8291-7f18-48876fd70e10@redhat.com> From: Benjamin Tissoires Date: Thu, 13 Feb 2020 15:56:56 +0100 Message-ID: Subject: Re: [PATCH v3 0/5] SFH: Add Support for AMD Sensor Fusion Hub To: Hans de Goede Cc: Sandeep Singh , Jiri Kosina , lkml , "open list:HID CORE LAYER" , Srinivas Pandruvada , Jonathan Cameron , linux-iio@vger.kernel.org, Nehal-bakulchandra.Shah@amd.com, Shyam-sundar.S-k@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Feb 12, 2020 at 3:45 PM Hans de Goede wrote: > > Hi, > > On 2/12/20 3:56 AM, Sandeep Singh wrote: > > From: Sandeep Singh > > > > AMD SFH(Sensor Fusion Hub) is HID based driver.SFH FW > > is part of MP2 processor (MP2 which is an ARM=C2=AE Cortex-M4 > > core based co-processor to x86) and it runs on MP2 where > > in driver resides on X86.The driver functionalities are > > divided into three parts:- > > > > 1: amd-mp2-pcie:- This module will communicate with MP2 FW and > > provide that data into DRAM. > > 2: Client driver :- This part for driver will use dram data and > > convert that data into HID format based on > > HID reports. > > 3: Transport driver :- This part of driver will communicate with > > HID core. Communication between devices and > > HID core is mostly done via HID reports > > > > In terms of architecture it is much more reassembles like > > ISH(Intel Integrated Sensor Hub). However the major difference > > is all the hid reports are generated as part of kernel driver. > > AMD SFH driver taken reference from ISH in terms of > > design and functionalities at fewer location. > > > > AMD sensor fusion Hub is part of a SOC 17h family based platforms. > > The solution is working well on several OEM products. > > AMD SFH uses HID over PCIe bus. > > I started looking at this patch because of the phoronix' news item on it. > > First of all I want to say that it is great that AMD is working on > getting the Sensor Fusion Hub supported on Linux and that you are > working on a driver for this. Yep, couldn't agree more :) > > But, I've taken a quick look, mainly at the > "[PATCH v3 5/5] SFH: Create HID report to Enable support of AMD sensor fu= sion Hub (SFH)" > patch. > > AFAIK with the Intel ISH the sensor-hub itself is actually providing > HID descriptors and HID input reports. > > Looking at the AMD code, that does not seem to be the case, it seems > the values come directly from the AMD sensor-hub without being in any > HID specific form, e.g.: > > +u8 get_input_report(int sensor_idx, int report_id, > + u8 *input_report, u32 *sensor_virt_addr) > +{ > + u8 report_size =3D 0; > + struct accel3_input_report acc_input; > + struct gyro_input_report gyro_input; > + struct magno_input_report magno_input; > + struct als_input_report als_input; > + > + if (!sensor_virt_addr || !input_report) > + return report_size; > + > + switch (sensor_idx) { > + case ACCEL_IDX: /* accel */ > + acc_input.common_property.report_id =3D report_id; > + acc_input.common_property.sensor_state =3D > + HID_USAGE_SENSOR_STATE_READY_ENUM= ; > + acc_input.common_property.event_type =3D > + HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM; > + acc_input.in_accel_x_value =3D (int)sensor_virt_addr[0] / > + AMD_SFH_FIRMWARE_MULTIPLI= ER; > + acc_input.in_accel_y_value =3D (int)sensor_virt_addr[1] / > + AMD_SFH_FIRMWARE_MULTIPLI= ER; > + acc_input.in_accel_z_value =3D (int)sensor_virt_addr[2] = / > + AMD_SFH_FIRMWARE_MULTIPLI= ER; > + memcpy(input_report, &acc_input, sizeof(acc_input)); > + report_size =3D sizeof(acc_input); > + break; > > And the descriptors are hardcoded in the driver so as to fake a HID > device. > > So going through the HID subsystem seems like an unnecessary detour, > which just makes things needlessly complex and harder to debug > (and extend). > > The HID devices which the current patch-set is creating ultimately > will result in a number of devices being created under > > /sys/bus/iio/devices > > And this are the devices which userspace uses to get the sensor data. > > IMHO instead of going through the HID subsys the AMD Sensor Fusion Hub > driver should simply register 4 (*) iio-devices itself and directly > pass the data through at the iio subsys level rather then going the > long way around by creating a fake HID device which then gets > attached to by the hid-sensor driver to ultimately create the same > iio-devices. > > There are examples of e.g. various iio accel drivers under: > drivers/iio/accel/ you could start with a simple driver supporting > just the accelerometer bits and then extend things from there. > > Benjamin, Jiri, Jonathan, what is your take on this? Hard to say without knowing AMD roadmap for that. If they intend to have an ISH-like approach in the end with reports and descriptors provided by the firmwares, then it makes sense to keep this architecture for the first revision of devices. If not, then yes, this is probably overkill compared to what needs to be do= ne. Sandeep, can you explain to us why you think using HID is the best way? On a side note, I don't necessarily like patch 4/5 with the debugfs interface. It's adding a kernel API for no gain, and we should already have the debug API available in the various subsystems involved. Cheers, Benjamin > > Regards, > > Hans > > > *) One for accel, gyra, magneto and light each > > > > Sandeep Singh (5): > > SFH: Add maintainers and documentation for AMD SFH based on HID > > framework > > SFH: PCI driver to add support of AMD sensor fusion Hub using HID > > framework > > SFH: Transport Driver to add support of AMD Sensor Fusion Hub (SFH) > > SFH: Add debugfs support to AMD Sensor Fusion Hub > > SFH: Create HID report to Enable support of AMD sensor fusion Hub > > (SFH) > > > > Changes since v1: > > -Fix auto build test warnings > > -Fix warnings captured using smatch > > -Changes suggested by Dan Carpenter > > > > Links of the review comments for v1: > > [1] https://patchwork.kernel.org/patch/11325163/ > > [2] https://patchwork.kernel.org/patch/11325167/ > > [3] https://patchwork.kernel.org/patch/11325171/ > > [4] https://patchwork.kernel.org/patch/11325187/ > > > > > > Changes since v2: > > -Debugfs divided into another patch > > -Fix some cosmetic changes > > -Fix for review comments > > Reported and Suggested by:- Srinivas Pandruvada > > > > Links of the review comments for v2: > > [1] https://patchwork.kernel.org/patch/11355491/ > > [2] https://patchwork.kernel.org/patch/11355495/ > > [3] https://patchwork.kernel.org/patch/11355499/ > > [4] https://patchwork.kernel.org/patch/11355503/ > > > > > > Documentation/hid/amd-sfh-hid.rst | 160 +++++ > > MAINTAINERS | 8 + > > drivers/hid/Kconfig | 2 + > > drivers/hid/Makefile | 1 + > > drivers/hid/amd-sfh-hid/Kconfig | 20 + > > drivers/hid/amd-sfh-hid/Makefile | 17 + > > drivers/hid/amd-sfh-hid/amd_mp2_pcie.c | 243 ++++++++ > > drivers/hid/amd-sfh-hid/amd_mp2_pcie.h | 177 ++++++ > > drivers/hid/amd-sfh-hid/amdsfh-debugfs.c | 250 ++++++++ > > drivers/hid/amd-sfh-hid/amdsfh-debugfs.h | 14 + > > drivers/hid/amd-sfh-hid/amdsfh-hid-client.c | 260 +++++++++ > > drivers/hid/amd-sfh-hid/amdsfh-hid.c | 179 ++++++ > > drivers/hid/amd-sfh-hid/amdsfh-hid.h | 85 +++ > > .../hid_descriptor/amd_sfh_hid_descriptor.c | 275 +++++++++ > > .../hid_descriptor/amd_sfh_hid_descriptor.h | 125 ++++ > > .../hid_descriptor/amd_sfh_hid_report_descriptor.h | 642 ++++++++++++= +++++++++ > > 16 files changed, 2458 insertions(+) > > create mode 100644 Documentation/hid/amd-sfh-hid.rst > > create mode 100644 drivers/hid/amd-sfh-hid/Kconfig > > create mode 100644 drivers/hid/amd-sfh-hid/Makefile > > create mode 100644 drivers/hid/amd-sfh-hid/amd_mp2_pcie.c > > create mode 100644 drivers/hid/amd-sfh-hid/amd_mp2_pcie.h > > create mode 100644 drivers/hid/amd-sfh-hid/amdsfh-debugfs.c > > create mode 100644 drivers/hid/amd-sfh-hid/amdsfh-debugfs.h > > create mode 100644 drivers/hid/amd-sfh-hid/amdsfh-hid-client.c > > create mode 100644 drivers/hid/amd-sfh-hid/amdsfh-hid.c > > create mode 100644 drivers/hid/amd-sfh-hid/amdsfh-hid.h > > create mode 100644 drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid= _descriptor.c > > create mode 100644 drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid= _descriptor.h > > create mode 100644 drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid= _report_descriptor.h > > >