From nobody Fri Nov 29 15:41:27 2024 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCC4FF9E4 for ; Wed, 18 Sep 2024 10:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653996; cv=none; b=bq8l99RBrI79SOoAXJ/rsnPTfNveGvqXCZSKHVeqdk/2yhuKXHW04ft2hfzMagld0ljyg/ktf0wqjYoKyqirF56mTyP1Ui68gLPZNzlHPI6ZzdK9oBRnL+kfBBz3UmsC2LeWvtLD5dhW3lxZWBbCOdOoh+rAlUAxD7S7AbT56BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653996; c=relaxed/simple; bh=0RM0X8+Uj/yAzEVGnz19COcilxf0hCC5AuSLiaf0NTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q5u3W2YBhONZ3xBMTOn82VOG4WSfV7OintJEW/5cyne5BoSZR0bWXMYlMDVDN3DjGutqln7+osG+61iEa4BumpXHwlacPHEfBaluu9xpyUandEZSg85RvPr4v0cz1HlDwV+Rp+HWAmJhGN7FD9zq3CLInUW5rGuAR6lK9kKxinE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=cy8YUnLg; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="cy8YUnLg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1726653993; bh=0RM0X8+Uj/yAzEVGnz19COcilxf0hCC5AuSLiaf0NTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cy8YUnLgjynfq2iwDDexAgxK1h+DtpsNktVHZ8fjZ52MtX7gaQfXTaLBCKfzTds3x eKJU7jcCvvGdJEcdHDgAjvUb2Qy1aePq3OFaZ6e9qdIw8sgKJcLIV8pmSysDXvOFZf qy9uEcFwt3padA3a9+303USK5Sl6K2zPoXh8nydGNFmbfdbAYyhWguJxB7CShuPpba yuybq5hKc8uwEjpLpJ1wZww8nHfdXtPCUMuQ1dlfqUWQ5dDKnnom3y6uGRdgq8XASO QH1cD9QGYDFmXtb+4hSao1zozNrEc6iTGNTfkPa3tcSSI5RRK1kyQkqbam5PsrvSlW 0yECGqZF2JvHg== Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id BF25B17E10AE; Wed, 18 Sep 2024 12:06:32 +0200 (CEST) From: AngeloGioacchino Del Regno To: linux-mediatek@lists.infradead.org Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v1 1/3] soc: mediatek: mtk-cmdq: Move mask build and append to function Date: Wed, 18 Sep 2024 12:06:18 +0200 Message-ID: <20240918100620.103536-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> References: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the CMDQ_CODE_MASK packet build and append logic to a new cmdq_pkt_mask() function; this reduces code duplication by 4x. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Matthias Brugger --- drivers/soc/mediatek/mtk-cmdq-helper.c | 31 ++++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/= mtk-cmdq-helper.c index a8fccedba83f..620c371fd1fc 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -180,6 +180,15 @@ static int cmdq_pkt_append_command(struct cmdq_pkt *pk= t, return 0; } =20 +static int cmdq_pkt_mask(struct cmdq_pkt *pkt, u32 mask) +{ + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_MASK, + .mask =3D ~mask + }; + return cmdq_pkt_append_command(pkt, inst); +} + int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) { struct cmdq_instruction inst; @@ -196,14 +205,11 @@ EXPORT_SYMBOL(cmdq_pkt_write); int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value, u32 mask) { - struct cmdq_instruction inst =3D { {0} }; u16 offset_mask =3D offset; int err; =20 if (mask !=3D 0xffffffff) { - inst.op =3D CMDQ_CODE_MASK; - inst.mask =3D ~mask; - err =3D cmdq_pkt_append_command(pkt, inst); + err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 @@ -251,9 +257,7 @@ int cmdq_pkt_write_s_mask(struct cmdq_pkt *pkt, u16 hig= h_addr_reg_idx, struct cmdq_instruction inst =3D {}; int err; =20 - inst.op =3D CMDQ_CODE_MASK; - inst.mask =3D ~mask; - err =3D cmdq_pkt_append_command(pkt, inst); + err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 @@ -288,9 +292,7 @@ int cmdq_pkt_write_s_mask_value(struct cmdq_pkt *pkt, u= 8 high_addr_reg_idx, struct cmdq_instruction inst =3D {}; int err; =20 - inst.op =3D CMDQ_CODE_MASK; - inst.mask =3D ~mask; - err =3D cmdq_pkt_append_command(pkt, inst); + err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 @@ -409,12 +411,9 @@ EXPORT_SYMBOL(cmdq_pkt_poll); int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value, u32 mask) { - struct cmdq_instruction inst =3D { {0} }; int err; =20 - inst.op =3D CMDQ_CODE_MASK; - inst.mask =3D ~mask; - err =3D cmdq_pkt_append_command(pkt, inst); + err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 @@ -436,9 +435,7 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t= addr, u32 value, u32 mas * which enables use_mask bit. */ if (mask !=3D GENMASK(31, 0)) { - inst.op =3D CMDQ_CODE_MASK; - inst.mask =3D ~mask; - ret =3D cmdq_pkt_append_command(pkt, inst); + ret =3D cmdq_pkt_mask(pkt, mask); if (ret < 0) return ret; use_mask =3D CMDQ_POLL_ENABLE_MASK; --=20 2.46.0 From nobody Fri Nov 29 15:41:27 2024 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57F3617B425 for ; Wed, 18 Sep 2024 10:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653997; cv=none; b=fFBZ17P86bKqS1VYZDmbrgpZYgYIFlAaM7ijxEKB20nV8Ps1UzR55D9NLFT911C8Bog3DOoEI/xsjcxY4ULITAbS3qva/dQaw4c+smz4gynJLFsOZm84h6mMU6yeZXZP6u2S3artd34svXwNq2QoiD79YtY6y3/Q7VdPpQIRs2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653997; c=relaxed/simple; bh=t5UwOBnTnD4LxneriXQ1Hkl0RZpJr4Pl9fU7M3V5eV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cNFJM26sanoC6GaV51YSJXZquHKGG2Mz0aLSRx8Nc4rRVnPGzl4pk3G8Da6/9w68RXT9VNAFstwd+ZiDT0nVihut6yHE9SK09Rsfc0uLXbDPM4IxP9RvF/J8IpFlJQxi7uVP80EgpHC4TBZ+bOC3aOpy/7sj7I5JrDkAvyWG028= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Pyw1njRU; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Pyw1njRU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1726653993; bh=t5UwOBnTnD4LxneriXQ1Hkl0RZpJr4Pl9fU7M3V5eV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pyw1njRU3yIxpRTA0+Jfu1O7bNPLtAZUkMkoCQBEl4Yxk4dCLdBqcpd8UuKIadVMZ OcDYO+tWL4TYx3sbF7e8lHFngrQeyOeOo8/JpOW02/a/x0AtKhS1rS/TeR7JhK+VsF x2JB+VGc6FZHbi4Ca/FshfWLvaLU79RglUk79eIvwUb9DCgxz3HaOh/twydbky2dtm GiRrqSM2CCgArwAEQgGzSjmzrlEUzqvysyid1AfK7BYl25cdqmDQXTKmPdeWn84ZOw B9ng63M2osERNK+xF7J+crsglWhl9VeNMdDl/ICfJXEY/uOVZKPpu+dtda8lv924Jw 75ECfkYYy+lxQ== Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id 324A517E10B5; Wed, 18 Sep 2024 12:06:33 +0200 (CEST) From: AngeloGioacchino Del Regno To: linux-mediatek@lists.infradead.org Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v1 2/3] soc: mediatek: mtk-cmdq: Mark very unlikely branches as such Date: Wed, 18 Sep 2024 12:06:19 +0200 Message-ID: <20240918100620.103536-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> References: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Calling cmdq packet builders with an unsupported event number, or without left/right operands (in the case of logic commands) means that the caller (another driver) wants to perform an unsupported operation, so this means that the caller must be fixed instead. Anyway, such checks are here for safety and, unless any driver bug or any kind of misconfiguration is present, will always be false so add a very unlikely hint for those. Knowing that CPUs' branch predictors (and compilers, anyway) are indeed smart about these cases, this is done mainly for human readability purposes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-cmdq-helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/= mtk-cmdq-helper.c index 620c371fd1fc..4ffd1a35df87 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -336,7 +336,7 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event, bool = clear) struct cmdq_instruction inst =3D { {0} }; u32 clear_option =3D clear ? CMDQ_WFE_UPDATE : 0; =20 - if (event >=3D CMDQ_MAX_EVENT) + if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 inst.op =3D CMDQ_CODE_WFE; @@ -351,7 +351,7 @@ int cmdq_pkt_acquire_event(struct cmdq_pkt *pkt, u16 ev= ent) { struct cmdq_instruction inst =3D {}; =20 - if (event >=3D CMDQ_MAX_EVENT) + if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 inst.op =3D CMDQ_CODE_WFE; @@ -366,7 +366,7 @@ int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 even= t) { struct cmdq_instruction inst =3D { {0} }; =20 - if (event >=3D CMDQ_MAX_EVENT) + if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 inst.op =3D CMDQ_CODE_WFE; @@ -381,7 +381,7 @@ int cmdq_pkt_set_event(struct cmdq_pkt *pkt, u16 event) { struct cmdq_instruction inst =3D {}; =20 - if (event >=3D CMDQ_MAX_EVENT) + if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 inst.op =3D CMDQ_CODE_WFE; @@ -476,7 +476,7 @@ int cmdq_pkt_logic_command(struct cmdq_pkt *pkt, u16 re= sult_reg_idx, { struct cmdq_instruction inst =3D { {0} }; =20 - if (!left_operand || !right_operand || s_op >=3D CMDQ_LOGIC_MAX) + if (unlikely(!left_operand || !right_operand || s_op >=3D CMDQ_LOGIC_MAX)) return -EINVAL; =20 inst.op =3D CMDQ_CODE_LOGIC; --=20 2.46.0 From nobody Fri Nov 29 15:41:27 2024 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FB6517A586 for ; Wed, 18 Sep 2024 10:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653999; cv=none; b=GGsz3QrvZI0X6MfyLrT04X1qGaCh7U8GwEQNS7KLmTQsS+HZCeuOwrJnzCLEaEhKuzZ+RT+qq6Fv01A1vyTy6VAn6uEW0uvgLl5YGBVlQ8t2L4xuEbFbuilEFKXQYT/+87vTXDkQt/lLD3M8iosOJI6VjDv6nNpWe/+xKHbf4Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726653999; c=relaxed/simple; bh=oQOnfwsjdUWCC5mJL+lquIf7uyFH9YrXYXAl2LUYApw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P6Upd/68rfkUmMiMkG898z+ODXmh1p7BHdh8EeVr27ILAiC8JZB2k7INJJ28Xd69KLlWbLTvN+7GKxK83cKnZSE+kwXuKA4xqYmfkGu+bC+cTT7NuDlOeOF7ANQstKk+Wx7iSosE0NghTZUhSyV0jLZ3qCO4Fja9xazFAjEwOs8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=lQoaoIs/; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="lQoaoIs/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1726653993; bh=oQOnfwsjdUWCC5mJL+lquIf7uyFH9YrXYXAl2LUYApw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQoaoIs/x96njIYg71YCnVd3TrIcdPXQkblg8hVHArgJAANpjdqDxC7ApRnY2w/tp fFtZGCZftubxmlWxWf5VDpRWQUfp7g8pgMVIvENfPPT0iLeXh/3t2UWSnWQRnDonwK ugWKXt6Kdi937ePf///4/Mhw8rymTet/xgA0egPqjMGRi6xeyXB2XUR/gi/MAU3l+U ftk0cL3A+hQ86r2zzxUGOYQCl4Q2B4dh+0feEuKnvSeMJZvvYyFFuLtTWyKayRcULi 3vm1iRI/m6cRkbIq/hwN5j50sMjIr8LRK0pHRiwOAURP5OFZVMy3qWDVi4waCQYSx5 uSGPZPrYl7gsA== Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id 99D4817E10D2; Wed, 18 Sep 2024 12:06:33 +0200 (CEST) From: AngeloGioacchino Del Regno To: linux-mediatek@lists.infradead.org Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v1 3/3] soc: mediatek: mtk-cmdq: Move cmdq_instruction init to declaration Date: Wed, 18 Sep 2024 12:06:20 +0200 Message-ID: <20240918100620.103536-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> References: <20240918100620.103536-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move, where possible, the initialization of struct cmdq_instruction variables to their declaration to compress the code. While at it, also change an instance of open-coded mask to use the GENMASK() macro instead, and instances of `ret =3D func(); return ret;` to the equivalent (but shorter) `return func()`. Signed-off-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-cmdq-helper.c | 200 ++++++++++++------------- 1 file changed, 93 insertions(+), 107 deletions(-) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/= mtk-cmdq-helper.c index 4ffd1a35df87..0b274b0fb44f 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -191,13 +191,12 @@ static int cmdq_pkt_mask(struct cmdq_pkt *pkt, u32 ma= sk) =20 int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) { - struct cmdq_instruction inst; - - inst.op =3D CMDQ_CODE_WRITE; - inst.value =3D value; - inst.offset =3D offset; - inst.subsys =3D subsys; - + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WRITE, + .value =3D value, + .offset =3D offset, + .subsys =3D subsys + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_write); @@ -208,30 +207,27 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subs= ys, u16 offset_mask =3D offset; int err; =20 - if (mask !=3D 0xffffffff) { + if (mask !=3D GENMASK(31, 0)) { err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 offset_mask |=3D CMDQ_WRITE_ENABLE_MASK; } - err =3D cmdq_pkt_write(pkt, subsys, offset_mask, value); - - return err; + return cmdq_pkt_write(pkt, subsys, offset_mask, value); } EXPORT_SYMBOL(cmdq_pkt_write_mask); =20 int cmdq_pkt_read_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_= low, u16 reg_idx) { - struct cmdq_instruction inst =3D {}; - - inst.op =3D CMDQ_CODE_READ_S; - inst.dst_t =3D CMDQ_REG_TYPE; - inst.sop =3D high_addr_reg_idx; - inst.reg_dst =3D reg_idx; - inst.src_reg =3D addr_low; - + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_READ_S, + .dst_t =3D CMDQ_REG_TYPE, + .sop =3D high_addr_reg_idx, + .reg_dst =3D reg_idx, + .src_reg =3D addr_low + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_read_s); @@ -239,14 +235,14 @@ EXPORT_SYMBOL(cmdq_pkt_read_s); int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_low, u16 src_reg_idx) { - struct cmdq_instruction inst =3D {}; - - inst.op =3D CMDQ_CODE_WRITE_S; - inst.src_t =3D CMDQ_REG_TYPE; - inst.sop =3D high_addr_reg_idx; - inst.offset =3D addr_low; - inst.src_reg =3D src_reg_idx; - + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WRITE_S, + .mask =3D 0, + .src_t =3D CMDQ_REG_TYPE, + .sop =3D high_addr_reg_idx, + .offset =3D addr_low, + .src_reg =3D src_reg_idx + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_write_s); @@ -254,20 +250,19 @@ EXPORT_SYMBOL(cmdq_pkt_write_s); int cmdq_pkt_write_s_mask(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_low, u16 src_reg_idx, u32 mask) { - struct cmdq_instruction inst =3D {}; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WRITE_S_MASK, + .src_t =3D CMDQ_REG_TYPE, + .sop =3D high_addr_reg_idx, + .offset =3D addr_low, + .src_reg =3D src_reg_idx, + }; int err; =20 err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 - inst.mask =3D 0; - inst.op =3D CMDQ_CODE_WRITE_S_MASK; - inst.src_t =3D CMDQ_REG_TYPE; - inst.sop =3D high_addr_reg_idx; - inst.offset =3D addr_low; - inst.src_reg =3D src_reg_idx; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_write_s_mask); @@ -275,13 +270,12 @@ EXPORT_SYMBOL(cmdq_pkt_write_s_mask); int cmdq_pkt_write_s_value(struct cmdq_pkt *pkt, u8 high_addr_reg_idx, u16 addr_low, u32 value) { - struct cmdq_instruction inst =3D {}; - - inst.op =3D CMDQ_CODE_WRITE_S; - inst.sop =3D high_addr_reg_idx; - inst.offset =3D addr_low; - inst.value =3D value; - + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WRITE_S, + .sop =3D high_addr_reg_idx, + .offset =3D addr_low, + .value =3D value + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_write_s_value); @@ -289,18 +283,18 @@ EXPORT_SYMBOL(cmdq_pkt_write_s_value); int cmdq_pkt_write_s_mask_value(struct cmdq_pkt *pkt, u8 high_addr_reg_idx, u16 addr_low, u32 value, u32 mask) { - struct cmdq_instruction inst =3D {}; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WRITE_S_MASK, + .sop =3D high_addr_reg_idx, + .offset =3D addr_low, + .value =3D value + }; int err; =20 err =3D cmdq_pkt_mask(pkt, mask); if (err < 0) return err; =20 - inst.op =3D CMDQ_CODE_WRITE_S_MASK; - inst.sop =3D high_addr_reg_idx; - inst.offset =3D addr_low; - inst.value =3D value; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_write_s_mask_value); @@ -333,61 +327,61 @@ EXPORT_SYMBOL(cmdq_pkt_mem_move); =20 int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event, bool clear) { - struct cmdq_instruction inst =3D { {0} }; u32 clear_option =3D clear ? CMDQ_WFE_UPDATE : 0; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WFE, + .value =3D CMDQ_WFE_OPTION | clear_option, + .event =3D event + }; =20 if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 - inst.op =3D CMDQ_CODE_WFE; - inst.value =3D CMDQ_WFE_OPTION | clear_option; - inst.event =3D event; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_wfe); =20 int cmdq_pkt_acquire_event(struct cmdq_pkt *pkt, u16 event) { - struct cmdq_instruction inst =3D {}; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WFE, + .value =3D CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE | CMDQ_WFE_WAIT, + .event =3D event + }; =20 if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 - inst.op =3D CMDQ_CODE_WFE; - inst.value =3D CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE | CMDQ_WFE_WAIT; - inst.event =3D event; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_acquire_event); =20 int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event) { - struct cmdq_instruction inst =3D { {0} }; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WFE, + .value =3D CMDQ_WFE_UPDATE, + .event =3D event + }; =20 if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 - inst.op =3D CMDQ_CODE_WFE; - inst.value =3D CMDQ_WFE_UPDATE; - inst.event =3D event; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_clear_event); =20 int cmdq_pkt_set_event(struct cmdq_pkt *pkt, u16 event) { - struct cmdq_instruction inst =3D {}; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_WFE, + .value =3D CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE, + .event =3D event + }; =20 if (unlikely(event >=3D CMDQ_MAX_EVENT)) return -EINVAL; =20 - inst.op =3D CMDQ_CODE_WFE; - inst.value =3D CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE; - inst.event =3D event; - return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_set_event); @@ -395,16 +389,13 @@ EXPORT_SYMBOL(cmdq_pkt_set_event); int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) { - struct cmdq_instruction inst =3D { {0} }; - int err; - - inst.op =3D CMDQ_CODE_POLL; - inst.value =3D value; - inst.offset =3D offset; - inst.subsys =3D subsys; - err =3D cmdq_pkt_append_command(pkt, inst); - - return err; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_POLL, + .value =3D value, + .offset =3D offset, + .subsys =3D subsys + }; + return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_poll); =20 @@ -418,9 +409,7 @@ int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys, return err; =20 offset =3D offset | CMDQ_POLL_ENABLE_MASK; - err =3D cmdq_pkt_poll(pkt, subsys, offset, value); - - return err; + return cmdq_pkt_poll(pkt, subsys, offset, value); } EXPORT_SYMBOL(cmdq_pkt_poll_mask); =20 @@ -474,11 +463,12 @@ int cmdq_pkt_logic_command(struct cmdq_pkt *pkt, u16 = result_reg_idx, enum cmdq_logic_op s_op, struct cmdq_operand *right_operand) { - struct cmdq_instruction inst =3D { {0} }; + struct cmdq_instruction inst; =20 if (unlikely(!left_operand || !right_operand || s_op >=3D CMDQ_LOGIC_MAX)) return -EINVAL; =20 + inst.value =3D 0; inst.op =3D CMDQ_CODE_LOGIC; inst.dst_t =3D CMDQ_REG_TYPE; inst.src_t =3D cmdq_operand_get_type(left_operand); @@ -494,43 +484,43 @@ EXPORT_SYMBOL(cmdq_pkt_logic_command); =20 int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value) { - struct cmdq_instruction inst =3D {}; - - inst.op =3D CMDQ_CODE_LOGIC; - inst.dst_t =3D CMDQ_REG_TYPE; - inst.reg_dst =3D reg_idx; - inst.value =3D value; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_LOGIC, + .dst_t =3D CMDQ_REG_TYPE, + .reg_dst =3D reg_idx, + .value =3D value + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_assign); =20 int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa) { - struct cmdq_instruction inst =3D {}; - - inst.op =3D CMDQ_CODE_JUMP; - inst.offset =3D CMDQ_JUMP_ABSOLUTE; - inst.value =3D addr >> shift_pa; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_JUMP, + .offset =3D CMDQ_JUMP_ABSOLUTE, + .value =3D addr >> shift_pa + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_jump_abs); =20 int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa) { - struct cmdq_instruction inst =3D { {0} }; - - inst.op =3D CMDQ_CODE_JUMP; - inst.value =3D (u32)offset >> shift_pa; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_JUMP, + .value =3D (u32)offset >> shift_pa + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_jump_rel); =20 int cmdq_pkt_eoc(struct cmdq_pkt *pkt) { - struct cmdq_instruction inst =3D { {0} }; - - inst.op =3D CMDQ_CODE_EOC; - inst.value =3D CMDQ_EOC_IRQ_EN; + struct cmdq_instruction inst =3D { + .op =3D CMDQ_CODE_EOC, + .value =3D CMDQ_EOC_IRQ_EN + }; return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_eoc); @@ -541,9 +531,7 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt) int err; =20 /* insert EOC and generate IRQ for each command iteration */ - inst.op =3D CMDQ_CODE_EOC; - inst.value =3D CMDQ_EOC_IRQ_EN; - err =3D cmdq_pkt_append_command(pkt, inst); + err =3D cmdq_pkt_eoc(pkt); if (err < 0) return err; =20 @@ -551,9 +539,7 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt) inst.op =3D CMDQ_CODE_JUMP; inst.value =3D CMDQ_JUMP_PASS >> cmdq_get_shift_pa(((struct cmdq_client *)pkt->cl)->chan); - err =3D cmdq_pkt_append_command(pkt, inst); - - return err; + return cmdq_pkt_append_command(pkt, inst); } EXPORT_SYMBOL(cmdq_pkt_finalize); =20 --=20 2.46.0