From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::610]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1191E10E49F for ; Tue, 7 Nov 2023 01:56:55 +0000 (UTC) Message-ID: Date: Mon, 6 Nov 2023 20:56:51 -0500 Content-Language: en-US To: Jesse Zhang , igt-dev@lists.freedesktop.org References: <20231106054317.2740044-1-jesse.zhang@amd.com> From: vitaly prosyak In-Reply-To: <20231106054317.2740044-1-jesse.zhang@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib/amdgpu: fix code sytle issue List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Huang , Luben Tuikov , Alex Deucher , Christian Koenig Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Hi Jesse, Thanks! Reviewed by Vitaly Prosyak On 2023-11-06 00:43, Jesse Zhang wrote: > Fix some waring and error when check with checkpatch.pl, > like these: > > RROR: spaces required around that '=' (ctx:VxW) > + int fd= -1; > ^ > Cc: Vitaly Prosyak > Cc: Luben Tuikov > Cc: Alex Deucher > Cc: Christian Koenig > Cc: Kamil Konieczny > Cc: Tim Huang > > Signed-off-by: Jesse Zhang > --- > lib/amdgpu/amd_pci_unplug.c | 50 ++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 23 deletions(-) > > diff --git a/lib/amdgpu/amd_pci_unplug.c b/lib/amdgpu/amd_pci_unplug.c > index 078398b5e..9811e0cc2 100644 > --- a/lib/amdgpu/amd_pci_unplug.c > +++ b/lib/amdgpu/amd_pci_unplug.c > @@ -1,4 +1,5 @@ > -/* SPDX-License-Identifier: MIT > +//SPDX-License-Identifier: MIT > +/* > * Copyright 2022 Advanced Micro Devices, Inc. > * > * Permission is hereby granted, free of charge, to any person obtaining a > @@ -19,7 +20,8 @@ > * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > * OTHER DEALINGS IN THE SOFTWARE. > * > -*/ > + */ > + > #include > #include > #include > @@ -68,10 +70,10 @@ static int > amdgpu_hotunplug_trigger(const char *pathname) > { > int len; > - int fd= -1; > + int fd = -1; > > fd = open(pathname, O_WRONLY); > - if (fd <= 0 ) > + if (fd <= 0) > goto release; > > len = write(fd, "1", 1); > @@ -93,7 +95,7 @@ amdgpu_hotunplug_setup_test(bool render_mode, const struct amd_pci_unplug_setup > > unplug->num_devices = amdgpu_open_devices(render_mode, MAX_CARDS_SUPPORTED, > unplug->drm_amdgpu_fds); > - if (unplug->num_devices == 0 ) > + if (unplug->num_devices == 0) > goto release; > > if (setup->open_device && setup->open_device2 && unplug->num_devices < 2) { > @@ -105,7 +107,7 @@ amdgpu_hotunplug_setup_test(bool render_mode, const struct amd_pci_unplug_setup > tmp_str = amdgpu_get_device_from_fd(unplug->drm_amdgpu_fds[0]); > abort_oom_if_null(tmp_str); > unplug->sysfs_remove = realloc(tmp_str, strlen(tmp_str) * 2); > - abort_oom_if_null(unplug->sysfs_remove ); > + abort_oom_if_null(unplug->sysfs_remove); > strcat(unplug->sysfs_remove, "/remove"); > > r = amdgpu_device_initialize(unplug->drm_amdgpu_fds[0], &major_version, > @@ -140,6 +142,7 @@ static void > amdgpu_hotunplug_teardown_test(struct amd_pci_unplug *unplug) > { > int i; > + > if (unplug->device_handle) { > amdgpu_device_deinitialize(unplug->device_handle); > unplug->device_handle = NULL; > @@ -149,7 +152,7 @@ amdgpu_hotunplug_teardown_test(struct amd_pci_unplug *unplug) > unplug->device_handle2 = NULL; > } > for (i = 0; i < unplug->num_devices; i++) { > - if (unplug->drm_amdgpu_fds[i] >= 0 ) { > + if (unplug->drm_amdgpu_fds[i] >= 0) { > close(unplug->drm_amdgpu_fds[i]); > unplug->drm_amdgpu_fds[i] = -1; > } > @@ -206,10 +209,11 @@ amdgpu_nop_cs(void *handle) > struct amdgpu_cs_request ibs_request; > struct amdgpu_cs_ib_info ib_info; > int bo_cmd_size = 4096; > - struct amd_pci_unplug * unplug = handle; > + struct amd_pci_unplug *unplug = handle; > amdgpu_device_handle device_handle = unplug->device_handle; > > - struct amdgpu_cmd_base * base_cmd = get_cmd_base(); > + struct amdgpu_cmd_base *base_cmd = get_cmd_base(); > + > r = amdgpu_cs_ctx_create(device_handle, &context); > igt_assert_eq(r, 0); > > @@ -221,7 +225,7 @@ amdgpu_nop_cs(void *handle) > > memset(ib_result_cpu, 0, bo_cmd_size); > base_cmd->attach_buf(base_cmd, ib_result_cpu, bo_cmd_size); > - base_cmd->emit_repeat(base_cmd, GFX_COMPUTE_NOP , 16); > + base_cmd->emit_repeat(base_cmd, GFX_COMPUTE_NOP, 16); > > r = amdgpu_bo_list_create(device_handle, 1, &ib_result_handle, NULL, &bo_list); > igt_assert_eq(r, 0); > @@ -252,10 +256,11 @@ amdgpu_nop_cs(void *handle) > } > > static pthread_t* > -amdgpu_create_cs_thread(struct amd_pci_unplug * unplug) > +amdgpu_create_cs_thread(struct amd_pci_unplug *unplug) > { > int r; > pthread_t *thread = malloc(sizeof(*thread)); > + > if (!thread) > return NULL; > > @@ -270,7 +275,7 @@ amdgpu_create_cs_thread(struct amd_pci_unplug * unplug) > } > > static void > -amdgpu_wait_cs_thread(struct amd_pci_unplug * unplug, pthread_t *thread) > +amdgpu_wait_cs_thread(struct amd_pci_unplug *unplug, pthread_t *thread) > { > unplug->do_cs = false; > > @@ -280,13 +285,13 @@ amdgpu_wait_cs_thread(struct amd_pci_unplug * unplug, pthread_t *thread) > > static void > amdgpu_hotunplug_test(bool render_mode, const struct amd_pci_unplug_setup *setup, > - struct amd_pci_unplug * unplug, bool with_cs) > + struct amd_pci_unplug *unplug, bool with_cs) > { > int r; > pthread_t *thread = NULL; > > r = amdgpu_hotunplug_setup_test(render_mode, setup, unplug); > - igt_assert_eq(r , 1); > + igt_assert_eq(r, 1); > > if (with_cs) > thread = amdgpu_create_cs_thread(unplug); > @@ -311,9 +316,9 @@ amdgpu_hotunplug_simple(struct amd_pci_unplug_setup *setup, > amdgpu_hotunplug_test(true, setup, unplug, false); > } > > - void > - amdgpu_hotunplug_with_cs(struct amd_pci_unplug_setup *setup, > - struct amd_pci_unplug *unplug) > +void > +amdgpu_hotunplug_with_cs(struct amd_pci_unplug_setup *setup, > + struct amd_pci_unplug *unplug) > { > memset(unplug, 0, sizeof(*unplug)); > setup->open_device = true; > @@ -339,7 +344,7 @@ amdgpu_hotunplug_with_exported_bo(struct amd_pci_unplug_setup *setup, > setup->open_device = true; > > r = amdgpu_hotunplug_setup_test(true, setup, unplug); > - igt_assert_eq(r , 1); > + igt_assert_eq(r, 1); > > r = amdgpu_bo_alloc(unplug->device_handle, &request, &bo_handle); > igt_assert_eq(r, 0); > @@ -359,7 +364,7 @@ amdgpu_hotunplug_with_exported_bo(struct amd_pci_unplug_setup *setup, > *ptr = 0xdeafbeef; > > munmap(ptr, 4096); > - close (dma_buf_fd); > + close(dma_buf_fd); > > r = amdgpu_hotunplug_rescan(); > igt_assert_eq(r > 0, 1); > @@ -382,7 +387,7 @@ amdgpu_hotunplug_with_exported_fence(struct amd_pci_unplug_setup *setup, > struct amdgpu_cs_fence fence_status = {0}; > int shared_fd; > int bo_cmd_size = 4096; > - struct amdgpu_cmd_base * base_cmd = get_cmd_base(); > + struct amdgpu_cmd_base *base_cmd = get_cmd_base(); > > memset(unplug, 0, sizeof(*unplug)); > setup->open_device = true; > @@ -390,9 +395,8 @@ amdgpu_hotunplug_with_exported_fence(struct amd_pci_unplug_setup *setup, > > > r = amdgpu_hotunplug_setup_test(true, setup, unplug); > - if( r != 1) { > + if (r != 1) > goto release; > - } > > r = amdgpu_cs_ctx_create(unplug->device_handle, &context); > igt_assert_eq(r, 0); > @@ -404,7 +408,7 @@ amdgpu_hotunplug_with_exported_fence(struct amd_pci_unplug_setup *setup, > igt_assert_eq(r, 0); > memset(ib_result_cpu, 0, bo_cmd_size); > base_cmd->attach_buf(base_cmd, ib_result_cpu, bo_cmd_size); > - base_cmd->emit_repeat(base_cmd, GFX_COMPUTE_NOP , 16); > + base_cmd->emit_repeat(base_cmd, GFX_COMPUTE_NOP, 16); > > r = amdgpu_bo_list_create(unplug->device_handle, 1, &ib_result_handle, NULL, > &bo_list);