From patchwork Wed Oct 6 07:15:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 515298 Delivered-To: patches@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp232039imy; Wed, 6 Oct 2021 00:15:57 -0700 (PDT) X-Received: by 2002:a05:6512:3b9e:: with SMTP id g30mr8389433lfv.546.1633504557065; Wed, 06 Oct 2021 00:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633504557; cv=none; d=google.com; s=arc-20160816; b=fQi8mqJmdKg5icfkreQmG4IJdV6ockPt/18HVio4gCGhxDdIP4IfPDbosR4D9FXerE Nmvt6DDjwHzNzvLfkFt3A8m9hg7R37lwyjy0f/MktvPJhc1f77buYMehXQf60R6jqIxm ZPVYNNenLG37hAto9mUywZCxFgmqOSfUQHE11cZ0faaBo4ROCNnywt1iIsfc2UlNig9x HmCmrh+GK42SECQoN2YkIfxNQVzMALVMTcA5AcM8VMPhk6ia8AuqvfVGDrXs5aBQNw2P vSJX7SQY1ldyqeKQ/cwxAigRvtQoxGXPDkButJTHMlMDp4oHVxxLP1+jWXTr7SdlfEYa BJ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=AKrh6jeg1+D2CUT4DyWcA9w76ozKBLfI8b6gpIDDpCY=; b=C6jQVXsTNIrvmpSrkNjqDJHEGOF47oO5ZbMngwuCFsN1fD5IjFLsf4LFPFeA422sAh i6oFUXFdnCi9AHlbSPQXEhReaI4cvUwrNGdt/X13HBiV0vZ6t8gJFwAYgz70FM8/Up4u 9i3zCElIaZUL3pNEYRk5TBXnknYJz+5yY+QjLYSBZ2/uq3OEOylIltDH3CIL0K6f4v6X Wg8kcOo5ojc/kL4+FNOzBMMUf8mP3C8eYfRTTmYfNmLvVy+NVDpSezCgUO90RCtG9klO s/kidjeiWQNiRvslyO5fQmJY0l+ALpu4pefWA20rFnytHAyZUdSRFgGZJFNVzGRUm5Rr f0RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jlvFw1Vy; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id w22sor9737771ljw.22.2021.10.06.00.15.56 for (Google Transport Security); Wed, 06 Oct 2021 00:15:57 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jlvFw1Vy; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AKrh6jeg1+D2CUT4DyWcA9w76ozKBLfI8b6gpIDDpCY=; b=jlvFw1VyiUIGeXyBbQ9knQIXcxkL5XR1d87HM6bU+T3TKIwdXnnumNjfeQaX1d878T svv3scwdLS4dmAva4UIVS5EK12PD74qGcJ652OscGWQNjBkuAhLvcdubUBVqPWpiC3VI jhCmorePoM8uiIS2+Cu6GdwuJcx1eCQ9hpHMNsyi4arUZbX2dCNVCm3/cbkH4f8hDrGa 7Dlf6EqmJ+v6doctL4CnV4sN6f8We+sz5hu6w/zdGmU+YUbXKpWyJoQ+ZfIIY9YzN2br iE/CQRmOgCbFlFOzyF6uRhd3BEV1iJp+OKQUIqi2lkWSk6jlXgYeraLdeSBPkuCyPp1H d5FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AKrh6jeg1+D2CUT4DyWcA9w76ozKBLfI8b6gpIDDpCY=; b=TWHSc+5TlZkkwjt8bKAWd9bRG256WbzoGo/EjPfMzn8juTN4jXZT8/2U6+QYt336ME llqqxSxTo9IWGTgtmM+Cjp/ls3jWTGE279M+Mq3bfEbeDNTtkLwHz+DU+OmVTlA6hcR3 e0tkXVANrGuhbKq5LF5psS0SZBhrNyf8Pu3URfax+p/ZGF5bvLi1AC47ghBqud7km5hL GaqS9uEqb4lulCoWON32bho1L2aKeBD+6wGaXb1LlitAUARymxsiLOHe8PiruBVMcbxo lUuf8eP065tOceA1uYbCpmTulOY4hZDG5GeIgxJwvvdOJ5fKYPy1bmkaGT9ZBb1qHlhK ZcXg== X-Gm-Message-State: AOAM5322XMFnL851KTuZPqHcWh4oAf0FUF66XjC/dRAzWzItSXPdFw1j KTLf54wMx7opqwYWu78Df05CTA0k X-Google-Smtp-Source: ABdhPJxX+Sqcew6GyVwEuZ8oDl53IzGhaBx4xrF1wNs0tSxodxjwllEsfBZ5NsFHcMMU+iWWjE3zCQ== X-Received: by 2002:a05:651c:1039:: with SMTP id w25mr26709368ljm.440.1633504556692; Wed, 06 Oct 2021 00:15:56 -0700 (PDT) Return-Path: Received: from jade.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y7sm960376lfk.143.2021.10.06.00.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 00:15:56 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, op-tee@lists.trustedfirmware.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Cc: Jerome Forissier , Etienne Carriere , Sumit Garg , Vincent Guittot , Rob Herring , Jonathan Corbet , Ard Biesheuvel , Marc Zyngier , Jens Wiklander Subject: [PATCH v6 0/6] Asynchronous notifications from secure world Date: Wed, 6 Oct 2021 09:15:40 +0200 Message-Id: <20211006071546.2540920-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Hi all, This adds support for asynchronous notifications from OP-TEE in secure world to the OP-TEE driver. This allows a design with a top half and bottom half type of driver where the top half runs in secure interrupt context and a notifications tells normal world to schedule a yielding call to do the bottom half processing. An edge-triggered interrupt is used to notify the driver that there are asynchronous notifications pending. The documentation and DT bindings patches are now well reviewed, but the patches with code would do with some more attention. v5->v6: * Rebased on v5.15-rc2 * Replaced "tee: add tee_dev_open_helper() primitive" with "tee: export teedev_open() and teedev_close_context()" since it turned out that the normal teedev functions could be used instead as noted by Sumit. * Changed "optee: add asynchronous notifications" to use the exported teedev_open() and teedev_close_context() functions instead. v4->v5: * Rebased on v5.14-rc7 * Updated documentation to clarify that one interrupt may represent multiple notifications as requested. * Applied Marc's and Rob's tags v3->v4: * Clarfied the expected type of interrypt is edge-triggered, both in the normal documentation and in the DT bindings as requested. v2->v3: * Rebased on v5.14-rc2 which made the patch "dt-bindings: arm: Convert optee binding to json-schema" from the V2 patch set obsolete. * Applied Ard's Acked-by on "optee: add asynchronous notifications" v1->v2: * Added documentation * Converted optee bindings to json-schema and added interrupt property * Configure notification interrupt from DT instead of getting it from secure world, suggested by Ard Biesheuvel . Thanks, Jens Jens Wiklander (6): docs: staging/tee.rst: add a section on OP-TEE notifications dt-bindings: arm: optee: add interrupt property tee: fix put order in teedev_close_context() tee: export teedev_open() and teedev_close_context() optee: separate notification functions optee: add asynchronous notifications .../arm/firmware/linaro,optee-tz.yaml | 7 + Documentation/staging/tee.rst | 30 +++ drivers/tee/optee/Makefile | 1 + drivers/tee/optee/call.c | 27 +++ drivers/tee/optee/core.c | 87 +++++-- drivers/tee/optee/notif.c | 226 ++++++++++++++++++ drivers/tee/optee/optee_msg.h | 9 + drivers/tee/optee/optee_private.h | 23 +- drivers/tee/optee/optee_rpc_cmd.h | 31 +-- drivers/tee/optee/optee_smc.h | 75 +++++- drivers/tee/optee/rpc.c | 73 +----- drivers/tee/tee_core.c | 10 +- include/linux/tee_drv.h | 14 ++ 13 files changed, 496 insertions(+), 117 deletions(-) create mode 100644 drivers/tee/optee/notif.c -- 2.31.1