summaryrefslogtreecommitdiffstats
path: root/drivers/hte (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hte: tegra-194: Convert to platform remove callback returning voidUwe Kleine-König2024-04-121-4/+2
| | | | | | | | | | | | | | | | | | | | The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Thierry Reding <treding@nvidia.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* Merge tag 'for-6.7-rc1' of ↵Linus Torvalds2023-11-014-26/+23
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/linux Pull hte/timestamp updates from Dipen Patel: - Improve comments in the translate function - Reflect the GPIOLIB API changes during calculation of the GPIO base - Improve error handling in Tegra test and provider drivers - Improve code to set the line name * tag 'for-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/linux: hte: Use kasprintf() instead of fixed buffer formatting hte: tegra: Fix missing error code in tegra_hte_test_probe() hte: tegra194: Switch to LATE_SIMPLE_DEV_PM_OPS() hte: tegra194: Remove redundant dev_err() hte: tegra194: improve the GPIO-related comment hte: allow building modules with COMPILE_TEST enabled hte: Annotate struct hte_device with __counted_by
| * hte: Use kasprintf() instead of fixed buffer formattingAndy Shevchenko2023-10-271-9/+4
| | | | | | | | | | | | | | | | | | Improve readability and maintainability by replacing a hardcoded string allocation and formatting by the use of the kasprintf() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: tegra: Fix missing error code in tegra_hte_test_probe()Harshit Mogalapalli2023-10-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | The value of 'ret' is zero when of_hte_req_count() fails to get number of entitties to timestamp. And returning success(zero) on this failure path is incorrect. Fixes: 9a75a7cd03c9 ("hte: Add Tegra HTE test driver") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: tegra194: Switch to LATE_SIMPLE_DEV_PM_OPS()Andy Shevchenko2023-10-121-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | SET_LATE_SYSTEM_SLEEP_PM_OPS is deprecated, replace it with LATE_SYSTEM_SLEEP_PM_OPS() and use pm_sleep_ptr() for setting the driver's pm routines. We can now remove the __maybe_unused qualifier in the suspend and resume functions. Tested-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20231010151709.4104747-5-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: tegra194: Remove redundant dev_err()Andy Shevchenko2023-10-121-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | There is no need to call the dev_err() function directly to print a custom message when handling an error from platform_get_irq() function as it is going to display an appropriate error message in case of a failure. Reviewed-by: Dipen Patel <dipenp@nvidia.com> Tested-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20231010151709.4104747-4-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: tegra194: improve the GPIO-related commentBartosz Golaszewski2023-10-061-5/+8
| | | | | | | | | | | | | | | | | | | | Using any of the GPIO interfaces using the global numberspace is deprecated. Make it clear in the comment. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: allow building modules with COMPILE_TEST enabledBartosz Golaszewski2023-10-031-2/+2
| | | | | | | | | | | | | | | | | | Allow building all HTE modules with COMPILE_TEST Kconfig option enabled. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
| * hte: Annotate struct hte_device with __counted_byKees Cook2023-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct hte_device. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Dipen Patel <dipenp@nvidia.com> Cc: timestamp@lists.linux.dev Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Justin Stitt <justinstitt@google.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* | hte: tegra194: add GPIOLIB dependencyArnd Bergmann2023-10-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The driver started calling into a few interfaces that are part of GPIOLIB and don't have stub implementations otherwise: drivers/hte/hte-tegra194.c: In function 'tegra_hte_line_xlate': drivers/hte/hte-tegra194.c:424:48: error: implicit declaration of function 'gpio_device_get_base'; did you mean 'gpio_device_get_desc'? [-Werror=implicit-function-declaration] 424 | line_id = desc->attr.line_id - gpio_device_get_base(gs->gdev); | ^~~~~~~~~~~~~~~~~~~~ | gpio_device_get_desc Add a Kconfig dependency to only allow building when this is defined. Fixes: dc850faa28ee0 ("hte: tegra194: don't access struct gpio_chip") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
* | hte: tegra194: don't access struct gpio_chipBartosz Golaszewski2023-10-181-14/+16
|/ | | | | | | | | | | | | | Using struct gpio_chip is not safe as it will disappear if the underlying driver is unbound for any reason. Switch to using reference counted struct gpio_device and its dedicated accessors. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Tested-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> [andy: used gpio_device_find_by_fwnode()] Reviewed-by: Dipen Patel <dipenp@nvidia.com> Link: https://lore.kernel.org/r/20231010151709.4104747-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* hte: Explicitly include correct DT includesRob Herring2023-08-282-2/+1
| | | | | | | | | | | | | | | The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it was merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Acked-by: Dipen Patel <dipenp@nvidia.com> Link: https://lore.kernel.org/r/20230714174600.4057041-1-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
* hte: tegra-194: Use proper includesLinus Walleij2023-04-271-5/+4
| | | | | | | | | | | | | | | | The test driver uses the gpiod consumer API so include the right <linux/gpio/consumer.h> header. This may cause a problem with struct of_device_id being implcitly pulled in by the legacy header <linux/gpio.h> so include <linux/mod_devicetable.h> explicitly as well. While at it, drop explicit moduleparam.h (it's included with module.h) and sort the headers. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: Use device_match_of_node()ye xingchen2023-04-271-1/+1
| | | | | | | | Replace the open-code with device_match_of_node(). Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: tegra-194: Fix off by one in tegra_hte_map_to_line_id()Dan Carpenter2023-04-271-1/+1
| | | | | | | | | | | The "map_sz" is the number of elements in the "m" array so the > comparison needs to be changed to >= to prevent an out of bounds read. Fixes: 09574cca6ad6 ("hte: Add Tegra194 HTE kernel provider") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: tegra: fix 'struct of_device_id' build errorArnd Bergmann2023-04-271-0/+1
| | | | | | | | | | | | | Without the extra #include, this driver produces a build failure in some configurations. drivers/hte/hte-tegra194-test.c:96:34: error: array type has incomplete element type 'struct of_device_id' 96 | static const struct of_device_id tegra_hte_test_of_match[] = { Fixes: 9a75a7cd03c9 ("hte: Add Tegra HTE test driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: Use of_property_present() for testing DT property presenceRob Herring2023-04-271-1/+1
| | | | | | | | | | | | | It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: handle nvidia,gpio-controller propertyDipen Patel2023-04-271-7/+21
| | | | | | | | | | | | | The dt binding adds nvidia,gpio-controller property from Tegra234 SoC onwards to simplify code handling gpio chip search. The gpio chip search is needed for the AON GPIO GTE instances to map the hardware timestamp GPIO request (coming from the GPIO framework) to the tegra HTE providers. The patch also adds new gpio chip match function to match from the fwnode instead of the gpio controller label. The addition of the property does not break ABI for the existing Tegra194 code. Signed-off-by: Dipen Patel <dipenp@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
* hte: Deprecate nvidia,slices propertyDipen Patel2023-04-271-10/+21
| | | | | | | | The relevant DT bindings deprecates nvidia,slices property from Tegra234 SoC onwards, moving the slices value per SoC data structure instead. Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: Add Tegra234 providerDipen Patel2023-04-272-5/+121
| | | | | | | | The Tegra234 AON GPIO instance and LIC IRQ support HTE. For the GPIO HTE support, it also requires to add mapping between GPIO and HTE framework same as it was done with Tegra194 SoC. Signed-off-by: Dipen Patel <dipenp@nvidia.com>
* hte: Uninitialized variable in hte_ts_get()Dan Carpenter2022-05-201-1/+1
| | | | | | | | | The "free_name" variable is sometimes used without being initialized. Fixes: 31ab09b42188 ("drivers: Add hardware timestamp engine (HTE) subsystem") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* hte: Fix off by one in hte_push_ts_ns()Dan Carpenter2022-05-101-1/+1
| | | | | | | | | | | | The &chip->gdev->ei[] array has chip->nlines elements so this > comparison needs to be >= to prevent an out of bounds access. The gdev->ei[] array is allocated in hte_register_chip(). Fixes: 31ab09b42188 ("drivers: Add hardware timestamp engine (HTE) subsystem") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* hte: Fix possible use-after-free in tegra_hte_test_remove()Yang Yingliang2022-05-101-1/+1
| | | | | | | | | | | | | | | del_timer() does not wait until the timer handler finishing. This means that the timer handler may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix it by calling del_timer_sync(), which makes sure the timer handler has finished. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* hte: Remove unused including <linux/version.h>Jiapeng Chong2022-05-101-1/+0
| | | | | | | | | | | | Eliminate the follow versioncheck warning: ./drivers/hte/hte-tegra194-test.c: 8 linux/version.h not needed. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Reviewed-by: Dipen Patel <dipenp@nvidia.com> Acked-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* hte: Add Tegra HTE test driverDipen Patel2022-05-043-1/+247
| | | | | | | | | The test driver uses IRQ and GPIO lines to timestamp using HTE subsystem. The patch also adds compilation support in Kconfig and Makefile. Signed-off-by: Dipen Patel <dipenp@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* hte: Add Tegra194 HTE kernel providerDipen Patel2022-05-043-0/+743
| | | | | | | | | | | | | | | | | Tegra194 device has multiple HTE instances also known as GTE (Generic Hardware Timestamping Engine) which can timestamp subset of SoC lines and signals. This provider driver focuses on IRQ and GPIO lines and exposes timestamping ability on those lines to the consumers through HTE subsystem. Also, with this patch, added: - documentation about this provider and its capabilities at Documentation/hte. - Compilation support in Makefile and Kconfig Signed-off-by: Dipen Patel <dipenp@nvidia.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* drivers: Add hardware timestamp engine (HTE) subsystemDipen Patel2022-05-043-0/+963
Some devices can timestamp system lines/signals/Buses in real-time using the hardware counter or other hardware means which can give finer granularity and help avoid jitter introduced by software timestamping. To utilize such functionality, this patchset creates HTE subsystem where devices can register themselves as providers so that the consumers devices can request specific line from the providers. The patch also adds compilation support in Makefile and menu options in Kconfig. The provider does following: - Registers chip with the framework. - Provides translation hook to convert logical line id. - Provides enable/disable, request/release callbacks. - Pushes timestamp data to HTE subsystem. The consumer does following: - Initializes line attribute. - Gets HTE timestamp descriptor. - Requests timestamp functionality. - Puts HTE timestamp descriptor. Signed-off-by: Dipen Patel <dipenp@nvidia.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Thierry Reding <treding@nvidia.com>