From patchwork Thu Jan 9 12:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 182797 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp3214342ile; Sun, 12 Jan 2020 09:59:48 -0800 (PST) X-Received: by 2002:a2e:b007:: with SMTP id y7mr8480124ljk.215.1578851988208; Sun, 12 Jan 2020 09:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578851988; cv=none; d=google.com; s=arc-20160816; b=z4lhw3T8VIPWUDcAeNArkXMJNMOwjpKduZIp5dClwuFq2t318q9/YY6Kc4Bli8+Vjs 96EZr+/dwU7phKZ9iC7vO9BBT8wxWx90iAS/aYY4c03cZzQ86YuC+EGtbqSATAZBfDht tBXysC4WT83/wanFm/Wk35KhUKPNzVW7hCY6TV5Jqw8SgxhH17JV16TqVruv6qdciNAk VzdHVtKp0JuRkM6qSHye83rCTYGGdzs1FHMeDI5ptOqJT5ot6ifmq1iKPcoPYTfdUnNC 2BuGsVhM5L75KRpmQF8D1ffujzgRT9qyaSTFdm9MI9GH/AXx89gj+Ooq3nO/n+skQYxc DJ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0SiPYkpY1LZoKU7ldF/7ST/2p0dy5rt5wH0O4CV27+M=; b=gnVYr7cM7bnfQsKjyyz5yDJ5CXXRWO64WJG1RnIus34CW4MW1k6NSwPEydi5Fc499z APvb7/ALwPKMkaVBik7Dwp/uk6zYQbSRT+JMzQJygPMSb7/Ta1KpbcEo+29bEnhNiBwq OupdtWKbqSaToPLx22eJBKwIZ1EqaAl+b/3GRYcKL0ahAmxZrZ5ybH8Cb7GQRRJSmLX6 bPfmN+IvI/VkDFxyGI6f/TnlamKKujS5NPlRqhoKhvF7sXM6FnoLj4e43E/40h8X9hjE xdFOToP8kkkuJoBTkriu7UWEK+TUvu83BsKbOjsO/28L2K6xYctRxdEVXBeXYZ6E58gf CiAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ut+WtLUt; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r12sor4663361ljh.5.2020.01.12.09.59.47 for (Google Transport Security); Sun, 12 Jan 2020 09:59:48 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ut+WtLUt; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 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:in-reply-to:references; bh=0SiPYkpY1LZoKU7ldF/7ST/2p0dy5rt5wH0O4CV27+M=; b=ut+WtLUt+pWdeMMS9uQnf0695MJcJzhFVZPGp6n2yJdGkJ63SPUSLX4YBjOWUmrlIj BYLV6R2eblFlnMpmHaVqXJGo/a2vvA9RQ0B92Deq5J3ohCgvYoKqX1n365g6UuwlFLxl CXA+SZwkGhaZbA+vWNQ/h7yqHF5QMMDSLPgo6Rl9sLb/5dR88cl2MZ2wgJeMvI2EEktR /xopYHyiZQiQRB4v/RM7KhNRhZzp3c+krDQH0p9W6oJYE2IzsXD/1xCHjPCczkcQHDKj JuEDnTMRf6uOVGxyWGtvFc1SZKZLJUiITLGcAq5N0N5PNNGnXlShsF+DhKJgeHrKgbNO PcXA== 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:in-reply-to :references; bh=0SiPYkpY1LZoKU7ldF/7ST/2p0dy5rt5wH0O4CV27+M=; b=Da1qtkzOIij5ssBUAAv/sbhEVB4K6bbcS11WDm2xe8Y0qBt+pJ09t4EqXls4ebZIMp P2sG+SxzEtoZVeupdVuo8u3eCbu38OD0JELb8ZeeJOKm0Q+RZ7HWuUn67SQBaZzmdBOD USSEufqZqIP9mljs9cO9iUNSWfkhIg+5vMRCUzFWmcSuduMcufSThXVcG/9G3skWM2Gy EioolbzIb7rlFLsBCiiap9IUYUxIHnzMwzJ/XBHn1v6eLSsFbAY+CJtj/yg9KBQ5ux99 8t32/wEVBN4nnUMGYX8Ino4KD31lL/M0VlqPNWuKbX7W+hrYYbttlieAGiWRYeXtIE7t qCFA== X-Gm-Message-State: APjAAAWwMHMLWiHHkXqCSzQEBFAndFUfb7V1c+OHx1XeVw71KpUik7dY zDEEosCUz56JNvdOkCa41yQDf56NaZIPYOkv X-Google-Smtp-Source: APXvYqwSidHTC+rWtz8NqvtvCCR/vrebJWl9LIeuT91aGsl+rvCSvHfRSiC9O+qKFLNlyR0MMzuH0A== X-Received: by 2002:a05:651c:20a:: with SMTP id y10mr6452038ljn.216.1578573442603; Thu, 09 Jan 2020 04:37:22 -0800 (PST) Return-Path: Received: from jax.urgonet (h-249-223.A175.priv.bahnhof.se. [98.128.249.223]) by smtp.gmail.com with ESMTPSA id u16sm2887724ljo.22.2020.01.09.04.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 04:37:22 -0800 (PST) From: Jens Wiklander To: tee-dev@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Jerome Forissier , Sumit Garg , Etienne Carriere , Rijo Thomas , Devaraj Rangasamy , Jens Wiklander Subject: [PATCH 2/5] tee: remove unused tee_shm_priv_alloc() Date: Thu, 9 Jan 2020 13:36:48 +0100 Message-Id: <20200109123651.18520-3-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200109123651.18520-1-jens.wiklander@linaro.org> References: <20200109123651.18520-1-jens.wiklander@linaro.org> tee_shm_priv_alloc() isn't useful in the current state and it's also not not used so remove it. Signed-off-by: Jens Wiklander --- drivers/tee/tee_shm.c | 33 ++------------------------------- include/linux/tee_drv.h | 12 ------------ 2 files changed, 2 insertions(+), 43 deletions(-) -- 2.17.1 diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index 6cabb834db7d..8afe08b23242 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -95,20 +95,14 @@ static const struct dma_buf_ops tee_shm_dma_buf_ops = { .mmap = tee_shm_op_mmap, }; -static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, - struct tee_device *teedev, - size_t size, u32 flags) +struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) { + struct tee_device *teedev = ctx->teedev; struct tee_shm_pool_mgr *poolm = NULL; struct tee_shm *shm; void *ret; int rc; - if (ctx && ctx->teedev != teedev) { - dev_err(teedev->dev.parent, "ctx and teedev mismatch\n"); - return ERR_PTR(-EINVAL); - } - if (!(flags & TEE_SHM_MAPPED)) { dev_err(teedev->dev.parent, "only mapped allocations supported\n"); @@ -188,31 +182,8 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, tee_device_put(teedev); return ret; } - -/** - * tee_shm_alloc() - Allocate shared memory - * @ctx: Context that allocates the shared memory - * @size: Requested size of shared memory - * @flags: Flags setting properties for the requested shared memory. - * - * Memory allocated as global shared memory is automatically freed when the - * TEE file pointer is closed. The @flags field uses the bits defined by - * TEE_SHM_* in . TEE_SHM_MAPPED must currently always be - * set. If TEE_SHM_DMA_BUF global shared memory will be allocated and - * associated with a dma-buf handle, else driver private memory. - */ -struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) -{ - return __tee_shm_alloc(ctx, ctx->teedev, size, flags); -} EXPORT_SYMBOL_GPL(tee_shm_alloc); -struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size) -{ - return __tee_shm_alloc(NULL, teedev, size, TEE_SHM_MAPPED); -} -EXPORT_SYMBOL_GPL(tee_shm_priv_alloc); - struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, size_t length, u32 flags) { diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index cbddb883a7f8..42687f6c546d 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -315,18 +315,6 @@ void *tee_get_drvdata(struct tee_device *teedev); */ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); -/** - * tee_shm_priv_alloc() - Allocate shared memory privately - * @dev: Device that allocates the shared memory - * @size: Requested size of shared memory - * - * Allocates shared memory buffer that is not associated with any client - * context. Such buffers are owned by TEE driver and used for internal calls. - * - * @returns a pointer to 'struct tee_shm' - */ -struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size); - /** * tee_shm_register() - Register shared memory buffer * @ctx: Context that registers the shared memory From patchwork Thu Jan 9 12:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 182802 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp3240369ile; Sun, 12 Jan 2020 10:31:56 -0800 (PST) X-Received: by 2002:ac2:5147:: with SMTP id q7mr7731306lfd.87.1578853916647; Sun, 12 Jan 2020 10:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578853916; cv=none; d=google.com; s=arc-20160816; b=gjXRHKADY0cpQiFAnlG4L6CY00Ign0dVU+Jhb0RVTouqqcUVKUHzo1xbX5A98XTe0D WYcf7w5DeadcuR6seq7di8vcL8ngb9d/960GQxlHR1vK2oHLB7RbOcP00jJkX+/fVFeS Jt3YBXyJ/fk9Ys1UtmQ/O5GpkVYl6Hzn03GPTtc0nmUqHYbEykfV/8E/bZtMcO7Ims5w DSP5Pc+KBJdCGpoaWH0Z8rUCrU1gsPMolxWJSwI3MjtcrydlC8UeWQb8TIin8UiAWD0V LtE6eQFf3F5w4j7vD2LX4AHPs4QrTLhw0BGy2tbdZlFjOsuyWcExhJrhjQc7Plig+M2v Xrqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5KD/2e75f6x17C/yWNN9lJ6c3FFXNUAEGSK6KA9QyHc=; b=eiS7NUFGIGoHnsdpYykYZ6NtLxv0el0X4JuAhtypbGuR4HuET8iOkm+98spcF+PDBV Y7L7WTGy/JMyn+Fw+LuoA74OhdOEBWo9CUWOErdIf2JHA1u928tp8p2G8+sDs7x/svJC 7ZeaiJDh67S7RuOCwAACO8n00Tg8R63AWEan7ZAcGYOCeYPJFnRuPRxHP+DeDtrkLIla 7Nmvxp4KWTdT57fOX94wvaNR+UY99gs7kD/4rJBhLBCrC2XTovHm7zF5zH2q0NWvevik bp+F6sQgvQOoeqGCdN2FrXFIL4doDo+MzLiivYcgGMlU/poL0qXaEbTJ6y5fafv5wxIX 3N7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwBDdSr7; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f8sor4634980ljk.25.2020.01.12.10.31.56 for (Google Transport Security); Sun, 12 Jan 2020 10:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwBDdSr7; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 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:in-reply-to:references; bh=5KD/2e75f6x17C/yWNN9lJ6c3FFXNUAEGSK6KA9QyHc=; b=hwBDdSr7WL1hbEYdEVYShfN5tXgJMyByGcTrycNP2NCiZWYa90T0uSS1duVBeG3wcx VEf173mbnI0xtaCYhSi1yzw1x9GuXvVtzOuZ0MVQV1ni5e+CkgjRTOU2mcQrmEDKHdYr /c4NLAM1byBcwZW3JcI2GYsSy7/H81ElDtzCqLnu5tkWOMs7/JbtUopyJhb8CZ7Jszmh jfvSBHtxTZrLUZA0TxfCTlwzq6/8isYtjh5o+OwM4QGGxxI6TssUZmdmFtjAludyJfpy X2vYkFI+d4CRjOKouiSwvHGC0SBMITmOooONoFAzwZdLuKuJ5cL0MHbkwRe2QUN0AoEj Tlkg== 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:in-reply-to :references; bh=5KD/2e75f6x17C/yWNN9lJ6c3FFXNUAEGSK6KA9QyHc=; b=aksC7j/FOMhRB9yysV60+/mRNfWAxxJeEkZPuYWC81WUAwimZnCHURqdbhRtsBAjsM wvnbKAksru1VFm1njC3IADjjalC0GChERq18ipJZLXxIff6DHNy6Rpbf6iqajNOgYQvc ptFllXWvTwjTS7papcc9q3e0W7DJuvLUCSZ8qK5hCoKCcK+APNZecXoXBSlfDOPl6A5T 008eSUp09DzPsmi/5wpCL8x6w9scIFFb8r+g103S91oHyRpcR2cMVO39zzWRbW1WF/cb zjJG+d71mpuMVjYLwmzJVjBJlspTUfEB7mL27hTELp9kJ7vvsqkrP9m9BOZsICxw/kGh slBA== X-Gm-Message-State: APjAAAUBDzECn/hPFa9jh13LFHc7I04jIP0IJmk+IxyeVKse7CYNM2o8 VnJnhvt3cLG4kICxR5Wa9rUla8mlc7hromhq X-Google-Smtp-Source: APXvYqwlnulDrn/OVZFEfC7A4zhXwL1W37Gitw/kGfEymgF8YDh/GDiCLwd1otNIZu/BEzr4CAOWuQ== X-Received: by 2002:a2e:9a04:: with SMTP id o4mr6722903lji.214.1578573445054; Thu, 09 Jan 2020 04:37:25 -0800 (PST) Return-Path: Received: from jax.urgonet (h-249-223.A175.priv.bahnhof.se. [98.128.249.223]) by smtp.gmail.com with ESMTPSA id u16sm2887724ljo.22.2020.01.09.04.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 04:37:24 -0800 (PST) From: Jens Wiklander To: tee-dev@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Jerome Forissier , Sumit Garg , Etienne Carriere , Rijo Thomas , Devaraj Rangasamy , Jens Wiklander Subject: [PATCH 4/5] tee: remove redundant teedev in struct tee_shm Date: Thu, 9 Jan 2020 13:36:50 +0100 Message-Id: <20200109123651.18520-5-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200109123651.18520-1-jens.wiklander@linaro.org> References: <20200109123651.18520-1-jens.wiklander@linaro.org> The ctx element in struct tee_shm is always valid. So remove the now redundant teedev element. Signed-off-by: Jens Wiklander --- drivers/tee/tee_shm.c | 7 ++----- include/linux/tee_drv.h | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index e636cf82acdb..c64ec5c5e464 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -13,7 +13,7 @@ static void tee_shm_release(struct tee_shm *shm) { - struct tee_device *teedev = shm->teedev; + struct tee_device *teedev = shm->ctx->teedev; if (shm->flags & TEE_SHM_DMA_BUF) { mutex_lock(&teedev->mutex); @@ -44,8 +44,7 @@ static void tee_shm_release(struct tee_shm *shm) kfree(shm->pages); } - if (shm->ctx) - teedev_ctx_put(shm->ctx); + teedev_ctx_put(shm->ctx); kfree(shm); @@ -132,7 +131,6 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) } shm->flags = flags | TEE_SHM_POOL; - shm->teedev = teedev; shm->ctx = ctx; if (flags & TEE_SHM_DMA_BUF) poolm = teedev->pool->dma_buf_mgr; @@ -221,7 +219,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, } shm->flags = flags | TEE_SHM_REGISTER; - shm->teedev = teedev; shm->ctx = ctx; shm->id = -1; addr = untagged_addr(addr); diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index 42687f6c546d..1412e9cc79ce 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -167,8 +167,7 @@ void tee_device_unregister(struct tee_device *teedev); /** * struct tee_shm - shared memory object - * @teedev: device used to allocate the object - * @ctx: context using the object, if NULL the context is gone + * @ctx: context using the object * @paddr: physical address of the shared memory * @kaddr: virtual address of the shared memory * @size: size of shared memory @@ -183,7 +182,6 @@ void tee_device_unregister(struct tee_device *teedev); * subsystem and from drivers that implements their own shm pool manager. */ struct tee_shm { - struct tee_device *teedev; struct tee_context *ctx; phys_addr_t paddr; void *kaddr;