Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp668219pxj; Thu, 3 Jun 2021 16:47:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqc4fTEV92+bI8bTnKCKCs9WFbNNJtYENU7fczoKLKjsKgt1rewLSG9dYIVstcazx3W6nr X-Received: by 2002:a05:6402:524d:: with SMTP id t13mr1800351edd.209.1622764038534; Thu, 03 Jun 2021 16:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622764038; cv=none; d=google.com; s=arc-20160816; b=doYEYOwtCwjIDC8162nKP/cLKku8SBZmQes19wV8QGJETIxe7xngDRrDcAtC5GURoE F6OlD5elqVGy2e5zNA15Lne68xVeojnqGdsrkrGyKP/9QPPNA2J+OuEGz5Pc1GJxgOBW v0BTnkr9MPhr3IJhQn5QBsHD5LTuwNF7kU8/pMLSxkpEKKYcHNeZyn0ib2zrvLB6k2if oUr2c0I/HLWLowLLxOd7FxY63IcCDwDwRrQnC2ng/8DSMOvRLzk+CNW+fJ+7YEoPSUVe enaqjqU7eGkhWAVPdnkf2YKLAxqSADvDgwJf7KcIg1uJz7AYiPRIshp1ty8J1P/3rhoJ wvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3CgvK6mP0QW9sFdMKMBwLGrltbNn3STDZujxPwSb3s0=; b=gBamASJZUA5ydcBBeQNpB6UxajQ7gBkkDQsd3bgce5m7f7J6DbAaPbifNBZ+yeZ2jc NsJwR0Qb3AQe8WSUCTA40dqMHDv4DY39lHGd/MW4Kzt9QTT9jKbs7x/koO3XoAYBuGQt qkq9BukXtZHgcgt2pYLqPCOUOu95LTv/BgKzBYaqAwUyFC888Bm/eLdVdNcCYFYdoDF2 OsCTag0v5bLtYdQE3sJrSIibKmAPXsBu1xJclOJv6supHjSgNSVy4mpC3mvc2jsq1sEa 09Oludgy5NlcYuNL3Lltj0wrhf9T6zNuJF7wdgyVMIX5ZL8ghyMrd1s2YHD5Ibecnoq/ sVjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=toQvauYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si3683107ejb.592.2021.06.03.16.46.52; Thu, 03 Jun 2021 16:47:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=toQvauYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhFCXrp (ORCPT + 99 others); Thu, 3 Jun 2021 19:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFCXro (ORCPT ); Thu, 3 Jun 2021 19:47:44 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C54BC06174A; Thu, 3 Jun 2021 16:45:44 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id f20so123910wmg.0; Thu, 03 Jun 2021 16:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3CgvK6mP0QW9sFdMKMBwLGrltbNn3STDZujxPwSb3s0=; b=toQvauYIYaxK+64eW0m/teo1WO7qG+E6rvyBjOo2/RsBhhRaKvtVwcsl60yfYr+1+C Wv1hk3d8ezwhdH1VDu0egjpyUk/Is0EQwXmnN2xaceWcC5k8AJCKQkAa7JV3zD5dKoxd baeU6vjw+BL0zTr3vaobJ+G8IzibFoVc0iBsE1RslaE1r8K00LyFnHp846rEjwWJVDeZ jJ81ZKPYGmNQhF+B4GPsnDyq9ulxlaE9ibrNtVAY7fiAa3MNe7D3KV6Zh2KdqWeUU84T ultGwZGoclirp6nrL3Qh1p+zCuTOXU3JWvT7iG8zu8zXBMEvhTtgpr6jFOOBIPCRTSU9 VXHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3CgvK6mP0QW9sFdMKMBwLGrltbNn3STDZujxPwSb3s0=; b=YW9SxOR4W1mVJkGjc9OO/RI12yIrrM1bTmfw97ofKzf3yLV1WDlBrLxjWM8bjiFtI6 o93kqK9KBh5OmRugPdZrswpFBMHY/ra2ZeOZyBnwyTfLpj9mFPwpiYeXaiM1oBv3rWjO ZV6S+ohN1jRB0bfXBpBjwzFi6UHrze+F7GKZxBUWgkAI/XHxNUWl+cISKa2vbf9mt2rY U+oFcb2KdLi5+65BMihBWNjjR2Q+roWgbp2SsAGjka6MikNM4LYujrvl57D2YayEUPzy ccLaijDfo7ayilJ5idnD4AnB+EowZjLRxWDfaCt/sDxjsEbxtgmQ+pFRkGfMz0oRngTO wHKg== X-Gm-Message-State: AOAM533VHzlepbazBnboMrFb5FRG1/eZAVnNP1H7TU02lWr43zeK0R3U LFSBLwzJTZ8+jcTsQOvYodk= X-Received: by 2002:a1c:e915:: with SMTP id q21mr772896wmc.110.1622763942808; Thu, 03 Jun 2021 16:45:42 -0700 (PDT) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id a11sm4743386wrr.48.2021.06.03.16.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 16:45:42 -0700 (PDT) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , Jonathan Corbet , platform-driver-x86@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/7] platform/surface: aggregator: Extend user-space interface for events Date: Fri, 4 Jun 2021 01:45:19 +0200 Message-Id: <20210603234526.2503590-1-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend the user-space debug interface so that it can be used to receive SSAM events in user-space. Currently, inspecting SSAM events requires writing a custom client device and corresponding driver. This is not particularly user-friendly for quick testing and comes with higher iteration times. Since we already have a user-space interface, we can extend this to forward events from SSAM via the controller device file to user-space. With this we can then essentially write user-space SSAM clients for testing and reverse-engineering, providing us with all the essential functionality that previously only a kernel driver would have access to. Note that this is still only intended to be an interface for debugging and reverse-engineering purposes. To achieve this, we need to extend the core to decouple events from notifiers. Right now, enabling an event group requires registering a notifier for that group. This notifier provides a callback that is called when the event occurs. For user-space forwarding, we need to run all events through the same file. In the current implementation, this presents a problem as, when we don't know the exact events or can't filter for them, multiple notifiers for the same target category will lead to duplicate events to be sent through the file, one per notifier. Decoupling notifier registration from event enable-/disablement (and the corresponding reference counting) allows us to avoid this issue. We can then register one notifier for a whole target category and enable or disable events independently of this notifier. Since events are strictly separated by their target category, this will not lead to duplicate events. With this, we can then provide user-space with two new IOCTLs for registering notifiers for a specific target category of events they are interested in. This allows us to forward all events received by those notifiers to the internal buffer of the device file, from which they can be read by user-space. In other words, user-space can, via those two IOCTLs, select which event target categories they are interested in. Furthermore, we add another two IOCTLs for enabling and disabling events via the controller. While events can already be enabled and disabled via generic requests, this does not respect the controller-internal reference counting mechanism. Due to that, this can lead to an event group being disabled even though a kernel-driver has requested it to be enabled. Or in other words: Without this, a user-space client cannot safely reset the state as it has only two options, keeping the event group enabled and not attempt cleanup at all, or disable the event group for all clients and potentially stop them from working properly. Also update the copyright lines since we're already doing some work on the core. Maximilian Luz (7): platform/surface: aggregator: Allow registering notifiers without enabling events platform/surface: aggregator: Allow enabling of events without notifiers platform/surface: aggregator: Update copyright platform/surface: aggregator_cdev: Add support for forwarding events to user-space platform/surface: aggregator_cdev: Allow enabling of events from user-space platform/surface: aggregator_cdev: Add lockdep support docs: driver-api: Update Surface Aggregator user-space interface documentation .../surface_aggregator/clients/cdev.rst | 127 ++++- .../userspace-api/ioctl/ioctl-number.rst | 2 +- drivers/platform/surface/aggregator/Kconfig | 2 +- drivers/platform/surface/aggregator/Makefile | 2 +- drivers/platform/surface/aggregator/bus.c | 2 +- drivers/platform/surface/aggregator/bus.h | 2 +- .../platform/surface/aggregator/controller.c | 206 ++++++- .../platform/surface/aggregator/controller.h | 2 +- drivers/platform/surface/aggregator/core.c | 2 +- .../platform/surface/aggregator/ssh_msgb.h | 2 +- .../surface/aggregator/ssh_packet_layer.c | 2 +- .../surface/aggregator/ssh_packet_layer.h | 2 +- .../platform/surface/aggregator/ssh_parser.c | 2 +- .../platform/surface/aggregator/ssh_parser.h | 2 +- .../surface/aggregator/ssh_request_layer.c | 2 +- .../surface/aggregator/ssh_request_layer.h | 2 +- drivers/platform/surface/aggregator/trace.h | 2 +- .../surface/surface_aggregator_cdev.c | 531 +++++++++++++++++- include/linux/surface_aggregator/controller.h | 27 +- include/linux/surface_aggregator/device.h | 2 +- include/linux/surface_aggregator/serial_hub.h | 2 +- include/uapi/linux/surface_aggregator/cdev.h | 73 ++- 22 files changed, 921 insertions(+), 77 deletions(-) -- 2.31.1