Linux kernel -stable discussions
 help / color / mirror / Atom feed
diff for duplicates of <20250907195610.004226610@linuxfoundation.org>

diff --git a/a/1.txt b/N1/1.txt
index fe6f60c..a5be26b 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -1,217 +1,82 @@
-6.1-stable review patch.  If anyone has any objections, please let me know.
+6.6-stable review patch.  If anyone has any objections, please let me know.
 
 ------------------
 
-From: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
+From: Filipe Manana <fdmanana@suse.com>
 
-[ Upstream commit f14c8c3e1fc9e10c6d54999a96acb2b5087374df ]
+[ Upstream commit 986bf6ed44dff7fbae7b43a0882757ee7f5ba21b ]
 
-Fix the following checkpatch warnings & error in amdgpu_psp.c
+At inode_logged() we do a couple lockless checks for ->logged_trans, and
+these are generally safe except the second one in case we get a load or
+store tearing due to a concurrent call updating ->logged_trans (either at
+btrfs_log_inode() or later at inode_logged()).
 
-WARNING: Comparisons should place the constant on the right side of the test
-WARNING: braces {} are not necessary for single statement blocks
-WARNING: please, no space before tabs
-WARNING: braces {} are not necessary for single statement blocks
-ERROR: that open brace { should be on the previous line
+In the first case it's safe to compare to the current transaction ID since
+once ->logged_trans is set the current transaction, we never set it to a
+lower value.
 
-Suggested-by: Christian König <christian.koenig@amd.com>
-Cc: Christian König <christian.koenig@amd.com>
-Cc: Alex Deucher <alexander.deucher@amd.com>
-Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
-Reviewed-by: Christian König <christian.koenig@amd.com>
-Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-Stable-dep-of: 467e00b30dfe ("drm/amd/amdgpu: Fix missing error return on kzalloc failure")
+In the second case, where we check if it's greater than zero, we are prone
+to load/store tearing races, since we can have a concurrent task updating
+to the current transaction ID with store tearing for example, instead of
+updating with a single 64 bits write, to update with two 32 bits writes or
+four 16 bits writes. In that case the reading side at inode_logged() could
+see a positive value that does not match the current transaction and then
+return a false negative.
+
+Fix this by doing the second check while holding the inode's spinlock, add
+some comments about it too. Also add the data_race() annotation to the
+first check to avoid any reports from KCSAN (or similar tools) and comment
+about it.
+
+Fixes: 0f8ce49821de ("btrfs: avoid inode logging during rename and link when possible")
+Reviewed-by: Boris Burkov <boris@bur.io>
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
 Signed-off-by: Sasha Levin <sashal@kernel.org>
 ---
- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 51 ++++++++++---------------
- 1 file changed, 20 insertions(+), 31 deletions(-)
+ fs/btrfs/tree-log.c | 25 +++++++++++++++++++++----
+ 1 file changed, 21 insertions(+), 4 deletions(-)
 
-diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
-index ff3678a1c0296..459a5af3a99ac 100644
---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
-+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
-@@ -392,7 +392,7 @@ static int psp_sw_init(void *handle)
- 	if ((psp_get_runtime_db_entry(adev,
- 				PSP_RUNTIME_ENTRY_TYPE_PPTABLE_ERR_STATUS,
- 				&scpm_entry)) &&
--	    (SCPM_DISABLE != scpm_entry.scpm_status)) {
-+	    (scpm_entry.scpm_status != SCPM_DISABLE)) {
- 		adev->scpm_enabled = true;
- 		adev->scpm_status = scpm_entry.scpm_status;
- 	} else {
-@@ -439,10 +439,9 @@ static int psp_sw_init(void *handle)
- 
- 	if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 0) ||
- 	    adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 7)) {
--		ret= psp_sysfs_init(adev);
--		if (ret) {
-+		ret = psp_sysfs_init(adev);
-+		if (ret)
- 			return ret;
--		}
- 	}
- 
- 	ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
-@@ -641,7 +640,7 @@ psp_cmd_submit_buf(struct psp_context *psp,
- 	skip_unsupport = (psp->cmd_buf_mem->resp.status == TEE_ERROR_NOT_SUPPORTED ||
- 		psp->cmd_buf_mem->resp.status == PSP_ERR_UNKNOWN_COMMAND) && amdgpu_sriov_vf(psp->adev);
- 
--	memcpy((void*)&cmd->resp, (void*)&psp->cmd_buf_mem->resp, sizeof(struct psp_gfx_resp));
-+	memcpy(&cmd->resp, &psp->cmd_buf_mem->resp, sizeof(struct psp_gfx_resp));
- 
- 	/* In some cases, psp response status is not 0 even there is no
- 	 * problem while the command is submitted. Some version of PSP FW
-@@ -823,7 +822,7 @@ static int psp_tmr_load(struct psp_context *psp)
- }
- 
- static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp,
--				        struct psp_gfx_cmd_resp *cmd)
-+					struct psp_gfx_cmd_resp *cmd)
- {
- 	if (amdgpu_sriov_vf(psp->adev))
- 		cmd->cmd_id = GFX_CMD_ID_DESTROY_VMR;
-@@ -1052,7 +1051,7 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
- 				     struct ta_context *context)
- {
- 	cmd->cmd_id				= context->ta_load_type;
--	cmd->cmd.cmd_load_ta.app_phy_addr_lo 	= lower_32_bits(ta_bin_mc);
-+	cmd->cmd.cmd_load_ta.app_phy_addr_lo	= lower_32_bits(ta_bin_mc);
- 	cmd->cmd.cmd_load_ta.app_phy_addr_hi	= upper_32_bits(ta_bin_mc);
- 	cmd->cmd.cmd_load_ta.app_len		= context->bin_desc.size_bytes;
- 
-@@ -1158,9 +1157,8 @@ int psp_ta_load(struct psp_context *psp, struct ta_context *context)
- 
- 	context->resp_status = cmd->resp.status;
- 
--	if (!ret) {
-+	if (!ret)
- 		context->session_id = cmd->resp.session_id;
--	}
- 
- 	release_psp_cmd_buf(psp);
- 
-@@ -1490,8 +1488,7 @@ int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id)
- 	if (amdgpu_ras_intr_triggered())
- 		return ret;
- 
--	if (ras_cmd->if_version > RAS_TA_HOST_IF_VER)
--	{
-+	if (ras_cmd->if_version > RAS_TA_HOST_IF_VER) {
- 		DRM_WARN("RAS: Unsupported Interface");
- 		return -EINVAL;
- 	}
-@@ -1501,8 +1498,7 @@ int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id)
- 			dev_warn(psp->adev->dev, "ECC switch disabled\n");
- 
- 			ras_cmd->ras_status = TA_RAS_STATUS__ERROR_RAS_NOT_AVAILABLE;
--		}
--		else if (ras_cmd->ras_out_message.flags.reg_access_failure_flag)
-+		} else if (ras_cmd->ras_out_message.flags.reg_access_failure_flag)
- 			dev_warn(psp->adev->dev,
- 				 "RAS internal register access blocked\n");
- 
-@@ -1598,11 +1594,10 @@ static int psp_ras_initialize(struct psp_context *psp)
- 				if (ret)
- 					dev_warn(adev->dev, "PSP set boot config failed\n");
- 				else
--					dev_warn(adev->dev, "GECC will be disabled in next boot cycle "
--						 "if set amdgpu_ras_enable and/or amdgpu_ras_mask to 0x0\n");
-+					dev_warn(adev->dev, "GECC will be disabled in next boot cycle if set amdgpu_ras_enable and/or amdgpu_ras_mask to 0x0\n");
- 			}
- 		} else {
--			if (1 == boot_cfg) {
-+			if (boot_cfg == 1) {
- 				dev_info(adev->dev, "GECC is enabled\n");
- 			} else {
- 				/* enable GECC in next boot cycle if it is disabled
-@@ -2389,7 +2384,7 @@ static int psp_prep_load_ip_fw_cmd_buf(struct amdgpu_firmware_info *ucode,
- }
- 
- static int psp_execute_non_psp_fw_load(struct psp_context *psp,
--			          struct amdgpu_firmware_info *ucode)
-+				  struct amdgpu_firmware_info *ucode)
- {
- 	int ret = 0;
- 	struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp);
-@@ -2428,9 +2423,8 @@ static int psp_load_smu_fw(struct psp_context *psp)
- 	     (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 4) ||
- 	      adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 2)))) {
- 		ret = amdgpu_dpm_set_mp1_state(adev, PP_MP1_STATE_UNLOAD);
--		if (ret) {
-+		if (ret)
- 			DRM_WARN("Failed to set MP1 state prepare for reload\n");
--		}
- 	}
- 
- 	ret = psp_execute_non_psp_fw_load(psp, ucode);
-@@ -2740,9 +2734,8 @@ static int psp_suspend(void *handle)
- 	}
- 
- 	ret = psp_ring_stop(psp, PSP_RING_TYPE__KM);
--	if (ret) {
-+	if (ret)
- 		DRM_ERROR("PSP ring stop failed\n");
--	}
- 
- out:
- 	return ret;
-@@ -3015,7 +3008,7 @@ static int parse_sos_bin_descriptor(struct psp_context *psp,
- 		psp->sos.fw_version        = le32_to_cpu(desc->fw_version);
- 		psp->sos.feature_version   = le32_to_cpu(desc->fw_version);
- 		psp->sos.size_bytes        = le32_to_cpu(desc->size_bytes);
--		psp->sos.start_addr 	   = ucode_start_addr;
-+		psp->sos.start_addr	   = ucode_start_addr;
- 		break;
- 	case PSP_FW_TYPE_PSP_SYS_DRV:
- 		psp->sys.fw_version        = le32_to_cpu(desc->fw_version);
-@@ -3501,7 +3494,7 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
- 	drm_dev_exit(idx);
- }
- 
--static DEVICE_ATTR(usbc_pd_fw, S_IRUGO | S_IWUSR,
-+static DEVICE_ATTR(usbc_pd_fw, 0644,
- 		   psp_usbc_pd_fw_sysfs_read,
- 		   psp_usbc_pd_fw_sysfs_write);
- 
-@@ -3686,8 +3679,7 @@ static void psp_sysfs_fini(struct amdgpu_device *adev)
- 	device_remove_file(adev->dev, &dev_attr_usbc_pd_fw);
- }
- 
--const struct amdgpu_ip_block_version psp_v3_1_ip_block =
--{
-+const struct amdgpu_ip_block_version psp_v3_1_ip_block = {
- 	.type = AMD_IP_BLOCK_TYPE_PSP,
- 	.major = 3,
- 	.minor = 1,
-@@ -3695,8 +3687,7 @@ const struct amdgpu_ip_block_version psp_v3_1_ip_block =
- 	.funcs = &psp_ip_funcs,
- };
- 
--const struct amdgpu_ip_block_version psp_v10_0_ip_block =
--{
-+const struct amdgpu_ip_block_version psp_v10_0_ip_block = {
- 	.type = AMD_IP_BLOCK_TYPE_PSP,
- 	.major = 10,
- 	.minor = 0,
-@@ -3704,8 +3695,7 @@ const struct amdgpu_ip_block_version psp_v10_0_ip_block =
- 	.funcs = &psp_ip_funcs,
- };
- 
--const struct amdgpu_ip_block_version psp_v11_0_ip_block =
--{
-+const struct amdgpu_ip_block_version psp_v11_0_ip_block = {
- 	.type = AMD_IP_BLOCK_TYPE_PSP,
- 	.major = 11,
- 	.minor = 0,
-@@ -3721,8 +3711,7 @@ const struct amdgpu_ip_block_version psp_v11_0_8_ip_block = {
- 	.funcs = &psp_ip_funcs,
- };
- 
--const struct amdgpu_ip_block_version psp_v12_0_ip_block =
--{
-+const struct amdgpu_ip_block_version psp_v12_0_ip_block = {
- 	.type = AMD_IP_BLOCK_TYPE_PSP,
- 	.major = 12,
- 	.minor = 0,
+diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
+index afd76dff1d2bb..e5d6bc1bb5e5d 100644
+--- a/fs/btrfs/tree-log.c
++++ b/fs/btrfs/tree-log.c
+@@ -3398,15 +3398,32 @@ static int inode_logged(const struct btrfs_trans_handle *trans,
+ 	struct btrfs_key key;
+ 	int ret;
+ 
+-	if (inode->logged_trans == trans->transid)
++	/*
++	 * Quick lockless call, since once ->logged_trans is set to the current
++	 * transaction, we never set it to a lower value anywhere else.
++	 */
++	if (data_race(inode->logged_trans) == trans->transid)
+ 		return 1;
+ 
+ 	/*
+-	 * If logged_trans is not 0, then we know the inode logged was not logged
+-	 * in this transaction, so we can return false right away.
++	 * If logged_trans is not 0 and not trans->transid, then we know the
++	 * inode was not logged in this transaction, so we can return false
++	 * right away. We take the lock to avoid a race caused by load/store
++	 * tearing with a concurrent btrfs_log_inode() call or a concurrent task
++	 * in this function further below - an update to trans->transid can be
++	 * teared into two 32 bits updates for example, in which case we could
++	 * see a positive value that is not trans->transid and assume the inode
++	 * was not logged when it was.
+ 	 */
+-	if (inode->logged_trans > 0)
++	spin_lock(&inode->lock);
++	if (inode->logged_trans == trans->transid) {
++		spin_unlock(&inode->lock);
++		return 1;
++	} else if (inode->logged_trans > 0) {
++		spin_unlock(&inode->lock);
+ 		return 0;
++	}
++	spin_unlock(&inode->lock);
+ 
+ 	/*
+ 	 * If no log tree was created for this root in this transaction, then
 -- 
-2.51.0
+2.50.1
diff --git a/a/content_digest b/N1/content_digest
index d4488ab..1334685 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -1,232 +1,97 @@
- "ref\020250907195607.664912704@linuxfoundation.org\0"
+ "ref\020250907195609.817339617@linuxfoundation.org\0"
  "From\0Greg Kroah-Hartman <gregkh@linuxfoundation.org>\0"
- "Subject\0[PATCH 6.1 090/104] drm/amd/amdgpu: Fix style problems in amdgpu_psp.c\0"
- "Date\0Sun,  7 Sep 2025 21:58:47 +0200\0"
+ "Subject\0[PATCH 6.6 007/121] btrfs: avoid load/store tearing races when checking if an inode was logged\0"
+ "Date\0Sun,  7 Sep 2025 21:57:23 +0200\0"
  "To\0stable@vger.kernel.org\0"
  "Cc\0Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
   patches@lists.linux.dev
- " Christian K\303\266nig <christian.koenig@amd.com>"
-  Alex Deucher <alexander.deucher@amd.com>
-  Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
+  Boris Burkov <boris@bur.io>
+  Filipe Manana <fdmanana@suse.com>
+  David Sterba <dsterba@suse.com>
  " Sasha Levin <sashal@kernel.org>\0"
  "\00:1\0"
  "b\0"
- "6.1-stable review patch.  If anyone has any objections, please let me know.\n"
+ "6.6-stable review patch.  If anyone has any objections, please let me know.\n"
  "\n"
  "------------------\n"
  "\n"
- "From: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>\n"
+ "From: Filipe Manana <fdmanana@suse.com>\n"
  "\n"
- "[ Upstream commit f14c8c3e1fc9e10c6d54999a96acb2b5087374df ]\n"
+ "[ Upstream commit 986bf6ed44dff7fbae7b43a0882757ee7f5ba21b ]\n"
  "\n"
- "Fix the following checkpatch warnings & error in amdgpu_psp.c\n"
+ "At inode_logged() we do a couple lockless checks for ->logged_trans, and\n"
+ "these are generally safe except the second one in case we get a load or\n"
+ "store tearing due to a concurrent call updating ->logged_trans (either at\n"
+ "btrfs_log_inode() or later at inode_logged()).\n"
  "\n"
- "WARNING: Comparisons should place the constant on the right side of the test\n"
- "WARNING: braces {} are not necessary for single statement blocks\n"
- "WARNING: please, no space before tabs\n"
- "WARNING: braces {} are not necessary for single statement blocks\n"
- "ERROR: that open brace { should be on the previous line\n"
+ "In the first case it's safe to compare to the current transaction ID since\n"
+ "once ->logged_trans is set the current transaction, we never set it to a\n"
+ "lower value.\n"
  "\n"
- "Suggested-by: Christian K\303\266nig <christian.koenig@amd.com>\n"
- "Cc: Christian K\303\266nig <christian.koenig@amd.com>\n"
- "Cc: Alex Deucher <alexander.deucher@amd.com>\n"
- "Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>\n"
- "Reviewed-by: Christian K\303\266nig <christian.koenig@amd.com>\n"
- "Signed-off-by: Alex Deucher <alexander.deucher@amd.com>\n"
- "Stable-dep-of: 467e00b30dfe (\"drm/amd/amdgpu: Fix missing error return on kzalloc failure\")\n"
+ "In the second case, where we check if it's greater than zero, we are prone\n"
+ "to load/store tearing races, since we can have a concurrent task updating\n"
+ "to the current transaction ID with store tearing for example, instead of\n"
+ "updating with a single 64 bits write, to update with two 32 bits writes or\n"
+ "four 16 bits writes. In that case the reading side at inode_logged() could\n"
+ "see a positive value that does not match the current transaction and then\n"
+ "return a false negative.\n"
+ "\n"
+ "Fix this by doing the second check while holding the inode's spinlock, add\n"
+ "some comments about it too. Also add the data_race() annotation to the\n"
+ "first check to avoid any reports from KCSAN (or similar tools) and comment\n"
+ "about it.\n"
+ "\n"
+ "Fixes: 0f8ce49821de (\"btrfs: avoid inode logging during rename and link when possible\")\n"
+ "Reviewed-by: Boris Burkov <boris@bur.io>\n"
+ "Signed-off-by: Filipe Manana <fdmanana@suse.com>\n"
+ "Signed-off-by: David Sterba <dsterba@suse.com>\n"
  "Signed-off-by: Sasha Levin <sashal@kernel.org>\n"
  "---\n"
- " drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 51 ++++++++++---------------\n"
- " 1 file changed, 20 insertions(+), 31 deletions(-)\n"
+ " fs/btrfs/tree-log.c | 25 +++++++++++++++++++++----\n"
+ " 1 file changed, 21 insertions(+), 4 deletions(-)\n"
  "\n"
- "diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c\n"
- "index ff3678a1c0296..459a5af3a99ac 100644\n"
- "--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c\n"
- "+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c\n"
- "@@ -392,7 +392,7 @@ static int psp_sw_init(void *handle)\n"
- " \tif ((psp_get_runtime_db_entry(adev,\n"
- " \t\t\t\tPSP_RUNTIME_ENTRY_TYPE_PPTABLE_ERR_STATUS,\n"
- " \t\t\t\t&scpm_entry)) &&\n"
- "-\t    (SCPM_DISABLE != scpm_entry.scpm_status)) {\n"
- "+\t    (scpm_entry.scpm_status != SCPM_DISABLE)) {\n"
- " \t\tadev->scpm_enabled = true;\n"
- " \t\tadev->scpm_status = scpm_entry.scpm_status;\n"
- " \t} else {\n"
- "@@ -439,10 +439,9 @@ static int psp_sw_init(void *handle)\n"
- " \n"
- " \tif (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 0) ||\n"
- " \t    adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 7)) {\n"
- "-\t\tret= psp_sysfs_init(adev);\n"
- "-\t\tif (ret) {\n"
- "+\t\tret = psp_sysfs_init(adev);\n"
- "+\t\tif (ret)\n"
- " \t\t\treturn ret;\n"
- "-\t\t}\n"
- " \t}\n"
- " \n"
- " \tret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,\n"
- "@@ -641,7 +640,7 @@ psp_cmd_submit_buf(struct psp_context *psp,\n"
- " \tskip_unsupport = (psp->cmd_buf_mem->resp.status == TEE_ERROR_NOT_SUPPORTED ||\n"
- " \t\tpsp->cmd_buf_mem->resp.status == PSP_ERR_UNKNOWN_COMMAND) && amdgpu_sriov_vf(psp->adev);\n"
- " \n"
- "-\tmemcpy((void*)&cmd->resp, (void*)&psp->cmd_buf_mem->resp, sizeof(struct psp_gfx_resp));\n"
- "+\tmemcpy(&cmd->resp, &psp->cmd_buf_mem->resp, sizeof(struct psp_gfx_resp));\n"
- " \n"
- " \t/* In some cases, psp response status is not 0 even there is no\n"
- " \t * problem while the command is submitted. Some version of PSP FW\n"
- "@@ -823,7 +822,7 @@ static int psp_tmr_load(struct psp_context *psp)\n"
- " }\n"
- " \n"
- " static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp,\n"
- "-\t\t\t\t        struct psp_gfx_cmd_resp *cmd)\n"
- "+\t\t\t\t\tstruct psp_gfx_cmd_resp *cmd)\n"
- " {\n"
- " \tif (amdgpu_sriov_vf(psp->adev))\n"
- " \t\tcmd->cmd_id = GFX_CMD_ID_DESTROY_VMR;\n"
- "@@ -1052,7 +1051,7 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,\n"
- " \t\t\t\t     struct ta_context *context)\n"
- " {\n"
- " \tcmd->cmd_id\t\t\t\t= context->ta_load_type;\n"
- "-\tcmd->cmd.cmd_load_ta.app_phy_addr_lo \t= lower_32_bits(ta_bin_mc);\n"
- "+\tcmd->cmd.cmd_load_ta.app_phy_addr_lo\t= lower_32_bits(ta_bin_mc);\n"
- " \tcmd->cmd.cmd_load_ta.app_phy_addr_hi\t= upper_32_bits(ta_bin_mc);\n"
- " \tcmd->cmd.cmd_load_ta.app_len\t\t= context->bin_desc.size_bytes;\n"
- " \n"
- "@@ -1158,9 +1157,8 @@ int psp_ta_load(struct psp_context *psp, struct ta_context *context)\n"
- " \n"
- " \tcontext->resp_status = cmd->resp.status;\n"
- " \n"
- "-\tif (!ret) {\n"
- "+\tif (!ret)\n"
- " \t\tcontext->session_id = cmd->resp.session_id;\n"
- "-\t}\n"
- " \n"
- " \trelease_psp_cmd_buf(psp);\n"
- " \n"
- "@@ -1490,8 +1488,7 @@ int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id)\n"
- " \tif (amdgpu_ras_intr_triggered())\n"
- " \t\treturn ret;\n"
- " \n"
- "-\tif (ras_cmd->if_version > RAS_TA_HOST_IF_VER)\n"
- "-\t{\n"
- "+\tif (ras_cmd->if_version > RAS_TA_HOST_IF_VER) {\n"
- " \t\tDRM_WARN(\"RAS: Unsupported Interface\");\n"
- " \t\treturn -EINVAL;\n"
- " \t}\n"
- "@@ -1501,8 +1498,7 @@ int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id)\n"
- " \t\t\tdev_warn(psp->adev->dev, \"ECC switch disabled\\n\");\n"
- " \n"
- " \t\t\tras_cmd->ras_status = TA_RAS_STATUS__ERROR_RAS_NOT_AVAILABLE;\n"
- "-\t\t}\n"
- "-\t\telse if (ras_cmd->ras_out_message.flags.reg_access_failure_flag)\n"
- "+\t\t} else if (ras_cmd->ras_out_message.flags.reg_access_failure_flag)\n"
- " \t\t\tdev_warn(psp->adev->dev,\n"
- " \t\t\t\t \"RAS internal register access blocked\\n\");\n"
- " \n"
- "@@ -1598,11 +1594,10 @@ static int psp_ras_initialize(struct psp_context *psp)\n"
- " \t\t\t\tif (ret)\n"
- " \t\t\t\t\tdev_warn(adev->dev, \"PSP set boot config failed\\n\");\n"
- " \t\t\t\telse\n"
- "-\t\t\t\t\tdev_warn(adev->dev, \"GECC will be disabled in next boot cycle \"\n"
- "-\t\t\t\t\t\t \"if set amdgpu_ras_enable and/or amdgpu_ras_mask to 0x0\\n\");\n"
- "+\t\t\t\t\tdev_warn(adev->dev, \"GECC will be disabled in next boot cycle if set amdgpu_ras_enable and/or amdgpu_ras_mask to 0x0\\n\");\n"
- " \t\t\t}\n"
- " \t\t} else {\n"
- "-\t\t\tif (1 == boot_cfg) {\n"
- "+\t\t\tif (boot_cfg == 1) {\n"
- " \t\t\t\tdev_info(adev->dev, \"GECC is enabled\\n\");\n"
- " \t\t\t} else {\n"
- " \t\t\t\t/* enable GECC in next boot cycle if it is disabled\n"
- "@@ -2389,7 +2384,7 @@ static int psp_prep_load_ip_fw_cmd_buf(struct amdgpu_firmware_info *ucode,\n"
- " }\n"
- " \n"
- " static int psp_execute_non_psp_fw_load(struct psp_context *psp,\n"
- "-\t\t\t          struct amdgpu_firmware_info *ucode)\n"
- "+\t\t\t\t  struct amdgpu_firmware_info *ucode)\n"
- " {\n"
- " \tint ret = 0;\n"
- " \tstruct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp);\n"
- "@@ -2428,9 +2423,8 @@ static int psp_load_smu_fw(struct psp_context *psp)\n"
- " \t     (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 4) ||\n"
- " \t      adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 2)))) {\n"
- " \t\tret = amdgpu_dpm_set_mp1_state(adev, PP_MP1_STATE_UNLOAD);\n"
- "-\t\tif (ret) {\n"
- "+\t\tif (ret)\n"
- " \t\t\tDRM_WARN(\"Failed to set MP1 state prepare for reload\\n\");\n"
- "-\t\t}\n"
- " \t}\n"
- " \n"
- " \tret = psp_execute_non_psp_fw_load(psp, ucode);\n"
- "@@ -2740,9 +2734,8 @@ static int psp_suspend(void *handle)\n"
- " \t}\n"
- " \n"
- " \tret = psp_ring_stop(psp, PSP_RING_TYPE__KM);\n"
- "-\tif (ret) {\n"
- "+\tif (ret)\n"
- " \t\tDRM_ERROR(\"PSP ring stop failed\\n\");\n"
- "-\t}\n"
- " \n"
- " out:\n"
- " \treturn ret;\n"
- "@@ -3015,7 +3008,7 @@ static int parse_sos_bin_descriptor(struct psp_context *psp,\n"
- " \t\tpsp->sos.fw_version        = le32_to_cpu(desc->fw_version);\n"
- " \t\tpsp->sos.feature_version   = le32_to_cpu(desc->fw_version);\n"
- " \t\tpsp->sos.size_bytes        = le32_to_cpu(desc->size_bytes);\n"
- "-\t\tpsp->sos.start_addr \t   = ucode_start_addr;\n"
- "+\t\tpsp->sos.start_addr\t   = ucode_start_addr;\n"
- " \t\tbreak;\n"
- " \tcase PSP_FW_TYPE_PSP_SYS_DRV:\n"
- " \t\tpsp->sys.fw_version        = le32_to_cpu(desc->fw_version);\n"
- "@@ -3501,7 +3494,7 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size\n"
- " \tdrm_dev_exit(idx);\n"
- " }\n"
- " \n"
- "-static DEVICE_ATTR(usbc_pd_fw, S_IRUGO | S_IWUSR,\n"
- "+static DEVICE_ATTR(usbc_pd_fw, 0644,\n"
- " \t\t   psp_usbc_pd_fw_sysfs_read,\n"
- " \t\t   psp_usbc_pd_fw_sysfs_write);\n"
- " \n"
- "@@ -3686,8 +3679,7 @@ static void psp_sysfs_fini(struct amdgpu_device *adev)\n"
- " \tdevice_remove_file(adev->dev, &dev_attr_usbc_pd_fw);\n"
- " }\n"
- " \n"
- "-const struct amdgpu_ip_block_version psp_v3_1_ip_block =\n"
- "-{\n"
- "+const struct amdgpu_ip_block_version psp_v3_1_ip_block = {\n"
- " \t.type = AMD_IP_BLOCK_TYPE_PSP,\n"
- " \t.major = 3,\n"
- " \t.minor = 1,\n"
- "@@ -3695,8 +3687,7 @@ const struct amdgpu_ip_block_version psp_v3_1_ip_block =\n"
- " \t.funcs = &psp_ip_funcs,\n"
- " };\n"
- " \n"
- "-const struct amdgpu_ip_block_version psp_v10_0_ip_block =\n"
- "-{\n"
- "+const struct amdgpu_ip_block_version psp_v10_0_ip_block = {\n"
- " \t.type = AMD_IP_BLOCK_TYPE_PSP,\n"
- " \t.major = 10,\n"
- " \t.minor = 0,\n"
- "@@ -3704,8 +3695,7 @@ const struct amdgpu_ip_block_version psp_v10_0_ip_block =\n"
- " \t.funcs = &psp_ip_funcs,\n"
- " };\n"
- " \n"
- "-const struct amdgpu_ip_block_version psp_v11_0_ip_block =\n"
- "-{\n"
- "+const struct amdgpu_ip_block_version psp_v11_0_ip_block = {\n"
- " \t.type = AMD_IP_BLOCK_TYPE_PSP,\n"
- " \t.major = 11,\n"
- " \t.minor = 0,\n"
- "@@ -3721,8 +3711,7 @@ const struct amdgpu_ip_block_version psp_v11_0_8_ip_block = {\n"
- " \t.funcs = &psp_ip_funcs,\n"
- " };\n"
- " \n"
- "-const struct amdgpu_ip_block_version psp_v12_0_ip_block =\n"
- "-{\n"
- "+const struct amdgpu_ip_block_version psp_v12_0_ip_block = {\n"
- " \t.type = AMD_IP_BLOCK_TYPE_PSP,\n"
- " \t.major = 12,\n"
- " \t.minor = 0,\n"
+ "diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c\n"
+ "index afd76dff1d2bb..e5d6bc1bb5e5d 100644\n"
+ "--- a/fs/btrfs/tree-log.c\n"
+ "+++ b/fs/btrfs/tree-log.c\n"
+ "@@ -3398,15 +3398,32 @@ static int inode_logged(const struct btrfs_trans_handle *trans,\n"
+ " \tstruct btrfs_key key;\n"
+ " \tint ret;\n"
+ " \n"
+ "-\tif (inode->logged_trans == trans->transid)\n"
+ "+\t/*\n"
+ "+\t * Quick lockless call, since once ->logged_trans is set to the current\n"
+ "+\t * transaction, we never set it to a lower value anywhere else.\n"
+ "+\t */\n"
+ "+\tif (data_race(inode->logged_trans) == trans->transid)\n"
+ " \t\treturn 1;\n"
+ " \n"
+ " \t/*\n"
+ "-\t * If logged_trans is not 0, then we know the inode logged was not logged\n"
+ "-\t * in this transaction, so we can return false right away.\n"
+ "+\t * If logged_trans is not 0 and not trans->transid, then we know the\n"
+ "+\t * inode was not logged in this transaction, so we can return false\n"
+ "+\t * right away. We take the lock to avoid a race caused by load/store\n"
+ "+\t * tearing with a concurrent btrfs_log_inode() call or a concurrent task\n"
+ "+\t * in this function further below - an update to trans->transid can be\n"
+ "+\t * teared into two 32 bits updates for example, in which case we could\n"
+ "+\t * see a positive value that is not trans->transid and assume the inode\n"
+ "+\t * was not logged when it was.\n"
+ " \t */\n"
+ "-\tif (inode->logged_trans > 0)\n"
+ "+\tspin_lock(&inode->lock);\n"
+ "+\tif (inode->logged_trans == trans->transid) {\n"
+ "+\t\tspin_unlock(&inode->lock);\n"
+ "+\t\treturn 1;\n"
+ "+\t} else if (inode->logged_trans > 0) {\n"
+ "+\t\tspin_unlock(&inode->lock);\n"
+ " \t\treturn 0;\n"
+ "+\t}\n"
+ "+\tspin_unlock(&inode->lock);\n"
+ " \n"
+ " \t/*\n"
+ " \t * If no log tree was created for this root in this transaction, then\n"
  "-- \n"
- 2.51.0
+ 2.50.1
 
-0d7439e8c8b58729e1023e4db90326354f3e5e1c83f0ffab0c13c3aee486a77f
+89a4a059198a8abd516e7bda3674ed8c70625a9588881b643858ac2e727f0061

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox