Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6406153ybv; Tue, 18 Feb 2020 16:22:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwVVSw0jiv2lOZjksQzh9/SS0HpMBAf/Hcn9t4M02HzIx6FeqwD2qCU8yZyuG7QZ7M0tPOg X-Received: by 2002:aca:d610:: with SMTP id n16mr3088856oig.108.1582071723349; Tue, 18 Feb 2020 16:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582071723; cv=none; d=google.com; s=arc-20160816; b=h9NlMbLSs6hr8xdydHd6HbvfOTJDnxDPDnNnXO0HuCKFBKtCxZy6D/AsEEToCFuSIQ D0gXih13rGpIFN6IGWxEd5P1P/Q/lXEyHFsU+k53eVQYU/kZl8doqZ6DOwoz7DMBMalg AfBLn3EbWZetX1t51fIL29IvyFW8RUO3sYFFcrVmjEqHvzWaJi6Byqta5686Duw/kJI1 dkjpRqGVqRylGV5bReBKoevJJtzGXlpmhI0QhxmQGkw7D4xJ+b6p1dMeBUTBgvpIaP8Q PyRihVyM224Mj5NfKyXBzOXVXcIYXb/9K/xLX5NO2oQXL/fQBzygpY4T4Sp4XlmP5RtR pERg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=EJo9hDqpdXOIYVaAg32HWKFwO6zFS6Hsd1I2urPBJ6w=; b=pmkgOKAD9QGMWR9SnaPnjjaMVV+BFFYbCyC27kLOy6CWUMFt9QyIygE0pHejAtC9qr bXH72tvJG5fKHedu7HfO+Ol8kv45ryG5yfifx5xsCAL8xnku37CugdcfYe79dgAZ4ciq /M/8w+CoXX0K3LdkZCIvQZqFNQKXpGpQWB9Wl9Ephb7+QWct6SivF58TzSv+Jn7AJa2R kaeJdggO8A/jneEpwVUjBpofmHVStydZ7Lf9KdDmE2jzvBAZelBKEIzbdk56SuTgJz3Y FEWJpYCukG/qwqhLOU5XmpMczhWZSdYWm0sJ1M2Dqy+6xksLxYXRYU5p7SIUw0Zmx/lG BqQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=dICGGJNh; 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=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si239264otp.70.2020.02.18.16.21.51; Tue, 18 Feb 2020 16:22:03 -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=@synopsys.com header.s=mail header.b=dICGGJNh; 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=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbgBSAUv (ORCPT + 99 others); Tue, 18 Feb 2020 19:20:51 -0500 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:42562 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727006AbgBSAUv (ORCPT ); Tue, 18 Feb 2020 19:20:51 -0500 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 11BA0C0098; Wed, 19 Feb 2020 00:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1582071650; bh=ddKM9xkbcpuB2cBOgjOc0jvYyLJYZ6mC3oVxtJxau2Q=; h=From:To:Cc:Subject:Date:From; b=dICGGJNh6vH/STWxR/oej8fNp8Uuz1I5m9moEHsNCMPpZzmSOiUYAzPKGJALDy5lc E/+2+5+el+eeqNre6i3Cil92pMdXZzU2+gbsclmQjztrsbRIAyeBH6YAMvI1PWuAU5 RoTmjkTcLdyP1YmL4yzGPupCDMo17kugkYDgUPWgqXOdhea0m1eT+0oPU9Me56hKJg gMMeNCbqOXf8h9EOYm21f97u9mqka3tBAddnqU3TLKXO4X0RAHKrIEAOmtxgurl5Rj S3jRzA4krL0PaJYmwiQz6EmTbDLGc+b11s1HXgwQ0xF1dpcfLXh1UYEsx/4KzHVgWk oEKyAyBDgnbOQ== Received: from de02.synopsys.com (de02.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 34E31A007B; Wed, 19 Feb 2020 00:20:47 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id E39B73D240; Wed, 19 Feb 2020 01:20:46 +0100 (CET) From: Vitor Soares To: linux-kernel@vger.kernel.org, linux-i3c@lists.infradead.org Cc: Joao.Pinto@synopsys.com, Jose.Abreu@synopsys.com, bbrezillon@kernel.org, gregkh@linuxfoundation.org, wsa@the-dreams.de, arnd@arndb.de, broonie@kernel.org, corbet@lwn.net, Vitor Soares Subject: [PATCH v3 0/5] Introduce i3c device userspace interface Date: Wed, 19 Feb 2020 01:20:38 +0100 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For today there is no way to use i3c devices from user space and the introduction of such API will help developers during the i3c device or i3c host controllers development. The i3cdev module is highly based on i2c-dev and yet I tried to address the concerns raised in [1]. NOTES: - The i3cdev dynamically request an unused major number. - The i3c devices are dynamically exposed/removed from dev/ folder based on if they have a device driver bound to it. - For now, the module exposes i3c devices without device driver on dev/bus/i3c/- - As in the i2c subsystem, here it is exposed the i3c_priv_xfer to userspace. I tried to use a dedicated structure as in spidev but I don't see any obvious advantage. - Since the i3c API only exposes i3c_priv_xfer to devices, for now, the module just makes use of one ioctl(). This can change in the future with the introduction hdr commands or by the need of exposing some CCC commands to the device API (private contract between master-slave). Regarding the i3c device info, some information is already available through sysfs. We can add more device attributes to expose more information or add a dedicated ioctl() request for that purpose or both. - Similar to i2c, I have also created a tool that you can find in [2] for testing purposes. If you have some time available I would appreciate your feedback about it as well. [1] https://lkml.org/lkml/2018/11/15/853 [2] https://github.com/vitor-soares-snps/i3c-tools.git Changes in v3: Use the xfer_lock to prevent device detach during ioctl call Expose i3cdev under /dev/bus/i3c/ folder like usb does Change NOTIFY_BOUND to NOTIFY_BIND, this allows the device detach occur before driver->probe call Avoid use of IS_ERR_OR_NULL Use u64_to_user_ptr instead of (void __user *)(uintptr_t) cast Allocate k_xfer and data_ptrs at once and eliminate double allocation check Pass i3cdev to dev->driver_data Make all minors available Add API documentation Changes in v2: Use IDR api for minor numbering Modify ioctl struct Fix SPDX license Vitor Soares (5): i3c: master: export i3c_masterdev_type i3c: master: export i3c_bus_type symbol i3c: master: add i3c_for_each_dev helper i3c: add i3cdev module to expose i3c dev in /dev Documentation: userspac-api: add i3cdev documentation Documentation/userspace-api/i3c/i3cdev.rst | 116 ++++++++ drivers/i3c/Kconfig | 15 + drivers/i3c/Makefile | 1 + drivers/i3c/i3cdev.c | 429 +++++++++++++++++++++++++++++ drivers/i3c/internals.h | 2 + drivers/i3c/master.c | 16 +- include/uapi/linux/i3c/i3cdev.h | 38 +++ 7 files changed, 616 insertions(+), 1 deletion(-) create mode 100644 Documentation/userspace-api/i3c/i3cdev.rst create mode 100644 drivers/i3c/i3cdev.c create mode 100644 include/uapi/linux/i3c/i3cdev.h -- 2.7.4