summaryrefslogtreecommitdiff
path: root/lwis_device_slc.c
AgeCommit message (Collapse)Author
2023-11-01LWIS: devm_kzalloc() does not need kfree()Holmes Chou
devm_kzalloc() does not need kfree() Bug: 307807231 Test: local build Change-Id: I7c78d6d5b77686369b61f4c6fb2efe4713b61498 Signed-off-by: Holmes Chou <holmeschou@google.com>
2023-07-17LWIS: Remove lwis_event_subscribe_operationslinyuny
Bug: 283156240 Test: CTS, GCA Change-Id: I50d5d65ef16047a8f61dc3f7021775449911f178 Signed-off-by: linyuny <linyuny@google.com>
2023-06-13Remove unnecessary error logs from kmallocEdmond Chung
Bug: 286438999 Test: Build Change-Id: I02f0b13dd9f3b934eec345d98c61ef6e0e65fe5f Signed-off-by: Edmond Chung <edmondchung@google.com>
2023-06-09LWIS: Move device init functions back to each device type's header fileHolmes Chou
Move device init functions back to each device type's header file Bug: 286339588 Test: Build Change-Id: Ib57fec2f4c7ea3d5713f68bae7aa9d88f908fa77 Signed-off-by: Holmes Chou <holmeschou@google.com>
2023-05-31lwis: add warning for slc over-allocationRiddho Ridwanul Haque
Bug: 282901283 Test: GCA Smoke, Logs with over-allocation Change-Id: I41a234649a8dcf48306cfdf3d6c3b7c7ea8ce622
2023-04-24LWIS: Use devm_kzalloc to help manage device handler's memoryHolmes Chou
Use devm_kzalloc to help manage device handler's memory Bug: 276013291 Test: GCA, CTS Change-Id: I51670407ee89d142a5cf42277c9c8b775bf7c19e Signed-off-by: Holmes Chou <holmeschou@google.com>
2023-04-14LWIS: Add a struct device field in struce lwis_deviceHolmes Chou
The plat_dev in lwis_device might be invalid when the device type is not platform driver. But there are many common codes for all device types that access plat_dev. It will cause NPE when the device type is not a platform driver. Most of the codes to access plat_dev are to access the struct device in it. So, we can add a new struct device field in struct lwis_device and assign the struct device value from struct platform_device when probe. Then use the new added field in the common code. It should fix the NPE when the device type is not a platform driver. Bug: 278156602 Test: GCA, CTS Change-Id: Ic46b5ea66d85e1299516c8da582e06ae69eedb41 Signed-off-by: Holmes Chou <holmeschou@google.com>
2023-04-10LWIS: Use IS_ERR_OR_NULL instead of IS_ERRHolmes Chou
In most cases, we don't expect to get a NULL return. So, when we check if the return pointer is an error or not, we should check if it is NULL or not, too. Bug: 277152200 Test: GCA, CTS Change-Id: I138503873e35a46ed48aded41354d132fe9111b1 Signed-off-by: Holmes Chou <holmeschou@google.com>
2023-03-06SLC: fix type confusion vulnerabilityNick Chung
Check SLC file ops is equal to pt_file_ops. Bug: 245300559 Test: adb shell /data/local/tmp/test_poc Signed-off-by: Nick Chung <nickchung@google.com> Change-Id: I4a4ba91bc384a2a4b75c64cbf2bd0240bec17bc8 (cherry picked from commit d5c273ae9e34ff673476f726d1910067902bfc47)
2021-09-17LWIS: fix memory leakageNick Chung
Bug: 199806521 Test: kmemleak_analyze.py, CTS, GCA Signed-off-by: Nick Chung <nickchung@google.com> Change-Id: Idcff14d255d5457084d0b72c13d3666e85e89f9a (cherry picked from commit a5f3fca1485fb9c82b1b9a2d70680a452ef9db23)
2021-07-16LWIS: Free SLC partition only if the fd matches.Ge Bian
Bug: 186183144 Test: build, boot, manual test, CTS pass. Change-Id: Ib9847b1746889e1b31674f36c376b41966fd5ee0 Signed-off-by: Ge Bian <bian@google.com>
2021-07-14LWIS: Get pt_size from lwis_slc device tree.Ge Bian
Bug: 191094076 Test: build, boot and CTS test. Change-Id: Ifc486cd71726c89549180304776ad861fb6cf4bb Signed-off-by: Ge Bian <bian@google.com>
2021-07-12LWIS: update camera slc configTianyu Jiang
Bug: 193084862 Bug: 191094076 Test: slider kernel and cloudrippper kernel both builds. Test: R4 camera works with this change. CTS in process. Change-Id: I99fc5e5565309a82750c989de9a4d0a8ff0add98
2021-06-30LWIS: Update SLC partition.Ge Bian
Bug: 186183144 Test: manual and CTS Change-Id: Ibca95968f43dbd3a5d40500e4d19216e4e575fe6 Signed-off-by: Ge Bian <bian@google.com>
2021-06-11LWIS: Update camera SLC config.Ge Bian
Bug: 186183144 Test: build, boot and CTS test. Change-Id: I6f60a6731fd819be2f20b6aacfc2f2b8c13cfd15 Signed-off-by: Ge Bian <bian@google.com>
2021-03-16LWIS: Update SLC partition sizes.Tianyu Jiang
Bug: 182841244 Test: R4 boots up with updated boot.img vendor_boot.img and dtbo.img Signed-off-by: Tianyu Jiang <tianyuj@google.com> Change-Id: Id65cd3608b794e82309fb3e2e2ccc75041a4f2f6
2021-02-09Device: Add subclass specific close handles.Edmond Chung
Bug: 179789580 Test: Build, GCA Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: Ie0fea7aeaa08f967db2ca04c7efbef23c5fc7e64
2020-12-08LWIS: Update SLC partition sizes.Ge Bian
Bug: 174495296 Test: manully tested boot, and pass unit test. Signed-off-by: Ge Bian <bian@google.com> Change-Id: I2ae46e6d3ac98c134078a0908ea149a2ae669d26
2020-12-02LWIS: Change a 3-way partition to 4-way.Ge Bian
Bug: 174581287 Change-Id: Ic0b955fb15361cf8b08620d9b5fb7ea05a77a208 Signed-off-by: Ge Bian <bian@google.com>
2020-12-01IOREG: Use [read|write]X_relaxed variant for I/O accessEdmond Chung
The non-relaxed variant executes memory barrier every time read/write is called, which is an overkill and causes performance degradation. Bug: 165879653 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I7b8debd3a8a9b097054e9a14464a59c15b7374b5
2020-11-17Formatting fix based on updated clang-formatEdmond Chung
Notable difference: Line limit is now increased to 100. Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I265a14e4b102bdea6f8393fd9a523941e64f616a
2020-11-06LWIS: Add a new 4-way partition to SLC.Ge Bian
Change-Id: I9bd3d875bcb304d2f781bf0fd81c7798b29b5bec Bug: 172179693 Signed-off-by: Ge Bian <bian@google.com>
2020-09-22SLC: Add error-checking to avoid invalid handles.Edmond Chung
If pt_client_register failed, it would need to kernel panic on buffer allocation or disable. Bug: 168773078 Bug: 169169020 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I6a1936c08c21d82f9fb785c8d5e1ba38d2785c0b (cherry picked from commit 96e874d6112862857f0a83b9116d9f3cd91e537f) Signed-off-by: J. Avila <elavila@google.com>
2020-09-22SLC: Re-enable pt-related functions.Edmond Chung
Bug: 156057842 Bug: 169169020 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I014348c5770d70860bf0047493aaa8dc50d9cd0b (cherry picked from commit 36c7fa074bcd1fd7db4312993a31dbc40240b149) Signed-off-by: J. Avila <elavila@google.com>
2020-09-22Device: Remove __init attribute from probe functions.Edmond Chung
This fixes compilation in debug_memory configuration. Bug: 167308784 Bug: 169169020 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I01ed8f2e0e4ee79357c297f1c84654c107e5e823 (cherry picked from commit d18f9e30dc9b9f38695e4413bdffcd623b52cfeb) Signed-off-by: J. Avila <elavila@google.com>
2020-09-22Init: Register platform driver instead of probing during init.Edmond Chung
Initialization should not fail even if a certain device does not exist in the system. Therefore, we should just register the devices during init, instead of probing - where probing requires the existence of the device. Bug: 166187165 Bug: 169169020 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I8dd12644f4ee7a76231d0873be8202d40c1f8233 (cherry picked from commit da52787fda00abb1c6a24922051d2b62ca2c9d11) Signed-off-by: J. Avila <elavila@google.com>
2020-08-11SLC: Stub out SLC-related functions for now.Edmond Chung
This enables compilation in LWIS while we want for SLC to be migrated to 5.4. Bug: 162961559 Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I524770c6ebbde3139fe68c4ea5c0c8468c4a2c9a
2020-07-24lwis: Fix compiler warnings (W=1)Patrick Tjin
lwis_device_ioreg.c:165:12: error: no previous prototype for function 'lwis_ioreg_device_init' [-Werror,-Wmissing-prototypes] int __init lwis_ioreg_device_init(void) ^ lwis_device_ioreg.c:165:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __init lwis_ioreg_device_init(void) ^ static lwis_device_i2c.c:243:12: error: no previous prototype for function 'lwis_i2c_device_init' [-Werror,-Wmissing-prototypes] int __init lwis_i2c_device_init(void) ^ lwis_device_i2c.c:243:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __init lwis_i2c_device_init(void) ^ static lwis_device_slc.c:148:3: error: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] slc_dev->pt[NUM_PT - 1].size_kb); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_device_slc.c:236:12: error: no previous prototype for function 'lwis_slc_device_init' [-Werror,-Wmissing-prototypes] int __init lwis_slc_device_init(void) ^ lwis_device_slc.c:236:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __init lwis_slc_device_init(void) ^ static lwis_device.c:330:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(gpios)); ^~~~~~~~~~~~~~ lwis_device.c:365:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(gpios)); ^~~~~~~~~~~~~~ lwis_device.c:455:6: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(gpios)); ^~~~~~~~~~~~~~ lwis_dpm.c:71:5: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat] clk_get_rate(lwis_dev->clocks->clk[clk_index].clk)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_transaction.c:216:27: error: format specifies type 'int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] lwis_dev->name, transaction->info.id, i, ^~~~~~~~~~~~~~~~~~~~ lwis_transaction.c:215:101: error: more '%' conversions than data arguments [-Werror,-Wformat] pr_err("Device %s clean-up fails with error code %d, transaction %d, io_entries[%d], entry_type %d", ~^ lwis_device_top.c:274:35: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] "Offset (%d) must be < %d\n", entry->rw.offset, ~~ ^~~~~~~~~~~~~~~~ %llu lwis_device_top.c:285:5: error: format specifies type 'int' but the argument has type 'unsigned long long' [-Werror,-Wformat] rw_batch->offset + rw_batch->size_in_bytes, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_device_top.c:296:35: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] "Offset (%d) must be < %d\n", entry->rw.offset, ~~ ^~~~~~~~~~~~~~~~ %llu lwis_device_top.c:307:24: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] rw_batch->offset + rw_batch->size_in_bytes, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_device_top.c:318:35: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] "Offset (%d) must be < %d\n", entry->mod.offset, ~~ ^~~~~~~~~~~~~~~~~ %llu lwis_i2c.c:99:24: error: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] client->name, offset); ^~~~~~ lwis_device_top.c:429:12: error: no previous prototype for function 'lwis_top_device_init' [-Werror,-Wmissing-prototypes] int __init lwis_top_device_init(void) ^ lwis_device_top.c:429:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __init lwis_top_device_init(void) ^ static lwis_debug.c:112:24: error: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] idx++, buffer->fd, buffer->size); ^~~~~~~~~~~~ lwis_debug.c:136:5: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] buffer->info.dma_vaddr); ^~~~~~~~~~~~~~~~~~~~~~ lwis_debug.c:327:4: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dbg_dir)); ^~~~~~~~~~~~~~~~ lwis_debug.c:336:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dbg_dev_info_file)); ^~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_debug.c:345:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dbg_event_file)); ^~~~~~~~~~~~~~~~~~~~~~~ lwis_debug.c:355:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dbg_transaction_file)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_debug.c:364:5: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dbg_buffer_file)); ^~~~~~~~~~~~~~~~~~~~~~~~ lwis_event.c:687:33 error: format specifies type 'int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] event_id, event_counter); ^~~~~~~~~~~~~ lwis_ioreg.c:57:18: error: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] offset, size_in_bytes); ^~~~~~~~~~~~~ lwis_ioreg.c:206:10: error: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] size_in_bytes, value_bits / 8, value_bits); ^~~~~~~~~~~~~ lwis_event.c:871:15: error: format specifies type 'int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] event_id, event_counter); ^~~~~~~~~~~~~ lwis_ioreg.c:250:10: error: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] size_in_bytes, value_bits / 8, value_bits); ^~~~~~~~~~~~~ lwis_ioreg.c:375:11: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] entry->rw_batch.offset, block->base); ^~~~~~~~~~~~~~~~~~~~~~ lwis_ioreg.c:402:11: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] entry->rw_batch.offset, block->base); ^~~~~~~~~~~~~~~~~~~~~~ lwis_periodic_io.c:105:52: error: format specifies type 'int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] pr_info("Created hrtimer with timeout time %dns", period_ns); ~~ ^~~~~~~~~ %lld lwis_periodic_io.c:300:29: error: format specifies type 'int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] resp->error_code, info->id, i, entry->type); ^~~~~~~~ lwis_gpio.c:24:41: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] pr_info("name: %s error: %d\n", name, PTR_ERR(gpios)); ~~ ^~~~~~~~~~~~~~ %ld lwis_ioctl.c:153:22: error: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat] type_name, errno, exp_size, IOCTL_ARG_SIZE(ioctl_type)); ^~~~~~~~ lwis_ioctl.c:1166:4: error: format specifies type 'unsigned int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] k_subscribe.trigger_event_id); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ lwis_ioctl.c:1196:4: error: format specifies type 'unsigned int' but the argument has type 'int64_t' (aka 'long long') [-Werror,-Wformat] event_id); ^~~~~~~~ lwis_buffer.c:50:11: error: format specifies type 'int' but the argument has type 'long' [-Werror,-Wformat] PTR_ERR(dma_buf)); ^~~~~~~~~~~~~~~~ platform/exynos/lwis_platform_exynos.c:44:9: error: format specifies type 'unsigned long long' but the argument has type 'unsigned long' [-Werror,-Wformat] fault_addr, fault_flag, lwis_dev); ^~~~~~~~~~ platform/exynos/lwis_platform_exynos_dma.c:26:17: error: no previous prototype for function 'lwis_platform_dma_buffer_alloc' [-Werror,-Wmissing-prototypes] struct dma_buf *lwis_platform_dma_buffer_alloc(size_t len, unsigned int flags) ^ platform/exynos/lwis_platform_exynos_dma.c:26:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct dma_buf *lwis_platform_dma_buffer_alloc(size_t len, unsigned int flags) ^ static platform/exynos/lwis_platform_exynos_dma.c:44:12: error: no previous prototype for function 'lwis_platform_dma_buffer_map' [-Werror,-Wmissing-prototypes] dma_addr_t lwis_platform_dma_buffer_map(struct lwis_device *lwis_dev, ^ platform/exynos/lwis_platform_exynos_dma.c:44:1: note: declare 'static' if the function is not intended to be used outside of this translation unit dma_addr_t lwis_platform_dma_buffer_map(struct lwis_device *lwis_dev, ^ static platform/exynos/lwis_platform_exynos_dma.c:53:5: error: no previous prototype for function 'lwis_platform_dma_buffer_unmap' [-Werror,-Wmissing-prototypes] int lwis_platform_dma_buffer_unmap(struct lwis_device *lwis_dev, ^ platform/exynos/lwis_platform_exynos_dma.c:53:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int lwis_platform_dma_buffer_unmap(struct lwis_device *lwis_dev, ^ static Change-Id: I9a3803029d7ec7845dac844551958ea1d4f19012
2020-07-23Revert "LWIS: Add a dummy callback to pt resize."Daniel Mentz
Instead of passing a dummy callback to pt_client_register(), let's change the SLC driver to accept a NULL pointer. This reverts commit b58d2a4482c3622fce80f2ce6a1e3d3df040bc9e. Bug: 161812974 Change-Id: I8640f2694f17f997b2c43c22f9f1155775083857 Signed-off-by: Daniel Mentz <danielmentz@google.com>
2020-07-14LWIS/SLC: Add real fd to slc buffers.Ge Bian
The current SLC buffer's fd are reused for partition ids. This CL impliment SLC file operation, so that we can give out actual fds. Bug: 156303886 Change-Id: Ifd17aa7a46bc264fb0b86a0c9e404f38b4903bf5 Signed-off-by: Ge Bian <bian@google.com>
2020-07-14LWIS: Add a dummy callback to pt resize.Ge Bian
The partition resize callback cannot be a NULL pointer, since it will be called by the pt driver. Add a dummy callback to print some debugging info. Bug: 161177525 Signed-off-by: Ge Bian <bian@google.com> Change-Id: I888b733385a38e861e2e2f6a883a1b60ba84437b
2020-06-26(Minor) Formatting fix on all source files.Edmond Chung
Ran clang-format on all source files. See go/lwis:coding-style. Signed-off-by: Edmond Chung <edmondchung@google.com> Change-Id: I2fc276bf542b70a1d58c973c0efc916aae80f640
2020-05-13LWIS/SLC: Add a new camera slc partition.Ge Bian
Signed-off-by: Ge Bian <bian@google.com> Change-Id: Ieed2a0e1c6aa869e02432ca913959b446ab874b2
2020-04-24LWIS: Update SLC pt partition sizes.Ge Bian
Bug: 154882805 Change-Id: Idade4900bf9d2a625174c1daaa222b08c8b0dd2d Signed-off-by: Ge Bian <bian@google.com>
2020-04-17LWIS/SLC: Add initial code for new LWIS SLC device.Ge Bian
Bug: 153101411 Change-Id: I28eef47b04e9a337354593e3c33e013db35d71ca Signed-off-by: Ge Bian <bian@google.com>