diff options
author | Robin Peng <robinpeng@google.com> | 2022-11-22 03:53:45 +0000 |
---|---|---|
committer | Robin Peng <robinpeng@google.com> | 2022-11-23 05:29:08 +0000 |
commit | 6f89aeb22f0295d180cc23839224ec193b5ecafd (patch) | |
tree | 2972db77c8dcfa89a3c0ff2309bdce30b89256b9 | |
parent | 2d8d797e852b2479c84dd25a23f511021a0f7acd (diff) | |
parent | 97d729c6ea520f6e5be984c1ca7b0e6551d51011 (diff) | |
download | rio-6f89aeb22f0295d180cc23839224ec193b5ecafd.tar.gz |
Merge android13-gs-pixel-5.15 into android14-gs-pixel-5.15
Bug: 260173634
Change-Id: I624670f3c11ef6a6a1d48a8bf644a4015ab27b23
Signed-off-by: Robin Peng <robinpeng@google.com>
-rw-r--r-- | drivers/edgetpu/Makefile | 3 | ||||
-rw-r--r-- | drivers/edgetpu/gcip-kernel-driver/drivers/gcip/gcip-kci.c | 1 | ||||
-rw-r--r-- | drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-common-image-header.h | 67 | ||||
-rw-r--r-- | drivers/edgetpu/mobile-pm.c | 17 | ||||
-rw-r--r-- | drivers/edgetpu/rio-pm.c | 6 |
5 files changed, 89 insertions, 5 deletions
diff --git a/drivers/edgetpu/Makefile b/drivers/edgetpu/Makefile index 27ca3a1..40416ca 100644 --- a/drivers/edgetpu/Makefile +++ b/drivers/edgetpu/Makefile @@ -34,6 +34,9 @@ include $(KERNEL_SRC)/../private/google-modules/soc/gs/Makefile.include GCIP_DIR=gcip-kernel-driver/drivers/gcip +KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build +M ?= $(shell pwd) + modules modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(M)/$(GCIP_DIR) W=1 gcip.o $(MAKE) -C $(KERNEL_SRC) M=$(M) W=1 $(KBUILD_OPTIONS) \ diff --git a/drivers/edgetpu/gcip-kernel-driver/drivers/gcip/gcip-kci.c b/drivers/edgetpu/gcip-kernel-driver/drivers/gcip/gcip-kci.c index e11d2a1..15b2c53 100644 --- a/drivers/edgetpu/gcip-kernel-driver/drivers/gcip/gcip-kci.c +++ b/drivers/edgetpu/gcip-kernel-driver/drivers/gcip/gcip-kci.c @@ -477,6 +477,7 @@ int gcip_kci_init(struct gcip_kci *kci, const struct gcip_kci_args *args) mailbox_args.timeout = args->timeout; mailbox_args.ops = &gcip_mailbox_ops; mailbox_args.data = kci; + mailbox_args.ignore_seq_order = false; ret = gcip_mailbox_init(&kci->mailbox, &mailbox_args); if (ret) diff --git a/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-common-image-header.h b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-common-image-header.h new file mode 100644 index 0000000..d986fbc --- /dev/null +++ b/drivers/edgetpu/gcip-kernel-driver/include/gcip/gcip-common-image-header.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common authenticated image format for Google SoCs + * + * Copyright (C) 2022 Google LLC + */ + +#ifndef __GCIP_COMMON_IMAGE_HEADER_H__ +#define __GCIP_COMMON_IMAGE_HEADER_H__ + +#include <linux/types.h> + +#include "gcip-image-config.h" + +#define GCIP_FW_HEADER_SIZE (0x1000) + +struct gcip_common_image_sub_header_common { + uint32_t magic; + uint32_t generation; + uint32_t rollback_info; + uint32_t length; + uint8_t flags[16]; +}; + +struct gcip_common_image_sub_header_gen1 { + uint8_t body_hash[32]; + uint8_t chip_id[32]; + uint8_t auth_config[256]; + struct gcip_image_config image_config; +}; + +struct gcip_common_image_sub_header_gen2 { + uint8_t body_hash[64]; + uint8_t chip_id[32]; + uint8_t auth_config[256]; + struct gcip_image_config image_config; +}; + +struct gcip_common_image_header { + uint8_t sig[512]; + uint8_t pub[512]; + struct { + struct gcip_common_image_sub_header_common common; + union { + struct gcip_common_image_sub_header_gen1 gen1; + struct gcip_common_image_sub_header_gen2 gen2; + }; + }; +}; + +/* + * Returns the image config field from a common image header + * or NULL if the header has an invalid generation identifier + */ +static inline struct gcip_image_config * +get_image_config_from_hdr(struct gcip_common_image_header *hdr) +{ + switch (hdr->common.generation) { + case 1: + return &hdr->gen1.image_config; + case 2: + return &hdr->gen2.image_config; + } + return NULL; +} + +#endif /* __GCIP_COMMON_IMAGE_HEADER_H__ */ diff --git a/drivers/edgetpu/mobile-pm.c b/drivers/edgetpu/mobile-pm.c index 8ad78e8..9a6a21e 100644 --- a/drivers/edgetpu/mobile-pm.c +++ b/drivers/edgetpu/mobile-pm.c @@ -24,6 +24,10 @@ #include "edgetpu-pm.c" #include "edgetpu-soc.h" +#define BLOCK_DOWN_RETRY_TIMES 50 +#define BLOCK_DOWN_MIN_DELAY_US 1000 +#define BLOCK_DOWN_MAX_DELAY_US 1500 + enum edgetpu_pwr_state edgetpu_active_states[EDGETPU_NUM_STATES] = { TPU_ACTIVE_UUD, TPU_ACTIVE_SUD, @@ -188,8 +192,17 @@ static int mobile_power_up(struct edgetpu_pm *etpm) struct edgetpu_mobile_platform_pwr *platform_pwr = &etmdev->platform_pwr; int ret; - if (platform_pwr->is_block_down && !platform_pwr->is_block_down(etdev)) - return -EAGAIN; + if (platform_pwr->is_block_down) { + int times = 0; + + do { + if (platform_pwr->is_block_down(etdev)) + break; + usleep_range(BLOCK_DOWN_MIN_DELAY_US, BLOCK_DOWN_MAX_DELAY_US); + } while (++times < BLOCK_DOWN_RETRY_TIMES); + if (times >= BLOCK_DOWN_RETRY_TIMES && !platform_pwr->is_block_down(etdev)) + return -EAGAIN; + } etdev_info(etpm->etdev, "Powering up\n"); diff --git a/drivers/edgetpu/rio-pm.c b/drivers/edgetpu/rio-pm.c index 0b6aa45..58271d7 100644 --- a/drivers/edgetpu/rio-pm.c +++ b/drivers/edgetpu/rio-pm.c @@ -18,8 +18,8 @@ #include "mobile-pm.c" -#define SHUTDOWN_DELAY_US_MIN 20 -#define SHUTDOWN_DELAY_US_MAX 20 +#define SHUTDOWN_DELAY_US_MIN 200 +#define SHUTDOWN_DELAY_US_MAX 200 #define BOOTUP_DELAY_US_MIN 100 #define BOOTUP_DELAY_US_MAX 150 #define SHUTDOWN_MAX_DELAY_COUNT 20 @@ -45,7 +45,7 @@ static void rio_lpm_down(struct edgetpu_dev *etdev) u32 val; do { - /* Manually delay 20us per retry till LPM shutdown finished */ + /* Manually delay 200us per retry till LPM shutdown finished */ usleep_range(SHUTDOWN_DELAY_US_MIN, SHUTDOWN_DELAY_US_MAX); val = edgetpu_dev_read_32_sync(etdev, EDGETPU_REG_LPM_CONTROL); if ((val & 0x100) || (val == 0)) |