Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5464676ybg; Tue, 22 Oct 2019 03:45:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbEj1qYWW1Gbbxp1YzZ8/tKpL0PfLV+dAl6w2cele7pl0cA8GF82lX3gD4x/19cHHaUnAN X-Received: by 2002:aa7:de1a:: with SMTP id h26mr30181307edv.289.1571741132887; Tue, 22 Oct 2019 03:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571741132; cv=none; d=google.com; s=arc-20160816; b=IJecgCJmV2bEw4spMGfJ8wTxlhR0IYilMc8rHAxU6Rhsu6CwSihR2SgFnR/oPJUjnJ cq5hwbrYvzQL463E1hE0e/JvodzIGJShmFPhRix5FC2+9NHEg3yG7v2y9F47l9dgilGU NpouJymn+gi8mSF+KMNZCw+uhj4otGHPLpHrMh48SU9SzwbUojM40DaZJCCQx2rLSHxn /Zh2AY1AyZYcRGwtGHTab7N4fFszjWTm6vXhRpLSkM2hmYs5DHc3wdYsH1gVUZ9ns556 7QR25p86Aae0aZSLQkccWMNzxLz+ofeXSmgG9XPzymKKfPX0wuappvNSYQD832qZAUTT /NjQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SFVfgieRvFhqIKf0lB981BtkUgMNwA41gyrg3nT6lNU=; b=iRdAX8OgtnXp9GpBdRE9LoX2o17EMgNPmKrSlJwTi9cFFSnpDKlKIAyPI50RLaY7Yp 8goIz/fRby5J/qmgkEECyJKbKEpIjJRV+AWRj8IGlw6bR0/vxrPjYdUvzM3IBsR7I+Pc JLI9WQk3KWyMtkuEf/mDng0mPbBet1KJFNfViwbmbgW//0WehiaFoVZo5SsCbfMliUMB 9qijDQtBDyCKdomTO+23v19ckefS68DGjsOPSnIeZ893wBfLop0rGmg+qpRTyw1YTOAw bBhi7yGyi6HRakO7V84n53fSM/If4VE+ZgzAQ4GoPnwM05fL3px0GmEPfrdhB1/UgBRR 5tCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OdV5Vo1P; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q26si4770483ejz.43.2019.10.22.03.45.08; Tue, 22 Oct 2019 03:45:32 -0700 (PDT) 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=@kernel.org header.s=default header.b=OdV5Vo1P; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388483AbfJVKmv (ORCPT + 99 others); Tue, 22 Oct 2019 06:42:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbfJVKmu (ORCPT ); Tue, 22 Oct 2019 06:42:50 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F8AF20B7C; Tue, 22 Oct 2019 10:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571740969; bh=ZB9rkiPisn/IuTUY/IajVYEn36xXAxtTFPGll20+in0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OdV5Vo1PSD3rGRuhst7NVuiD22RPXWZYfAgluI/6TQ0nSv5YtjsfwEHFyILMgH03H 5e3zfmIUDIBMDD/F18zEZh7DnTsv7tUba/HMK2DwWKXI4kh4ujHtrdtvg706auEyar 7CB1lrPekMzC5pIC7hV7/63Cxjb9hlcKcNvCKI0g= Date: Tue, 22 Oct 2019 11:42:43 +0100 From: Jonathan Cameron To: Gwendal Grignou Cc: Brian Norris , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lee Jones , Benson Leung , Enric Balletbo i Serra , Doug Anderson , Guenter Roeck , Fabien Lahoudere , linux-kernel , linux-iio Subject: Re: [PATCH v2 10/18] platform: chrome: sensorhub: Add FIFO support Message-ID: <20191022114243.1eaf19c1@archlinux> In-Reply-To: References: <20191021055403.67849-1-gwendal@chromium.org> <20191021055403.67849-11-gwendal@chromium.org> <20191021172727.0fa9918e@archlinux> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... > > > + * @sensor_hub : Sensor Hub object > > > + */ > > > +int cros_ec_sensorhub_ring_add(struct cros_ec_sensorhub *sensorhub) > > > +{ > > > + struct cros_ec_dev *ec = sensorhub->ec; > > > + int ret; > > > + > > > + /* Retrieve FIFO information */ > > > + sensorhub->msg->version = 2; > > > + sensorhub->params->cmd = MOTIONSENSE_CMD_FIFO_INFO; > > > + sensorhub->msg->outsize = 1; > > > + sensorhub->msg->insize = > > > + sizeof(struct ec_response_motion_sense_fifo_info) + > > > + sizeof(u16) * CROS_EC_SENSOR_MAX; > > > + > > > + ret = cros_ec_cmd_xfer_status(ec->ec_dev, sensorhub->msg); > > > + if (ret < 0) > > > + return ret; > > > + > > > + /* > > > + * Allocate the full fifo. > > > + * We need to copy the whole FIFO to set timestamps properly * > > > + */ > > > + sensorhub->fifo_size = sensorhub->resp->fifo_info.size; > > > + sensorhub->ring = devm_kcalloc(sensorhub->dev, sensorhub->fifo_size, > > > + sizeof(*sensorhub->ring), GFP_KERNEL); > > > + if (!sensorhub->ring) > > > + return -ENOMEM; > > > + > > > + sensorhub->fifo_timestamp[CROS_EC_SENSOR_LAST_TS] = > > > + cros_ec_get_time_ns(); > > > > Hmm. Is the IIO standard timestamp selection attribute being exposed? > > If so this is going to be confusing as we aren't obeying the selection > > of clock from that.. > > You're right, I did not find an elegant solution. > cros_ec_get_time_ns() is an inline version of ktime_get_boottime_ns > aka iio_get_time_ns( with indio_dev->clock_id set to CLOCK_BOOTTIME). > But I can not call iio_get_time_ns() here, as I don't have a > indio_dev. Besides, sensors could have a different > current_timestamp_clock attribute. I will convert in the callback > routine (cros_ec_sensors_push_data() by adding an offset > (iio_get_time_ns(indio_dev) - cros_ec_get_time_ns()) > > If you can special case that (perhaps adding some functionality to IIO) to not do anything if both are CLOCK_BOOTTIME that would be great. Thanks, Jonathan