Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp881935pxk; Thu, 17 Sep 2020 20:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwGEY40KUS0v0iwRPekXJXvcRBiGPd0WHmGAQ/9vvLKIFbKjWm3dgG1zBeMXudc/u6rrWD X-Received: by 2002:a17:906:3506:: with SMTP id r6mr33776795eja.55.1600398830949; Thu, 17 Sep 2020 20:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398830; cv=none; d=google.com; s=arc-20160816; b=ensaezMKgtS+wAXIE4Pv4DNAGKsexPA5h+P2VpsFRVtRNVbqoBPmGRjGwJ6jCKJrMM v/L/gYkTi9k7L1GC45FunchC3dxWyTjM+tL1G3l3hhdC7RYBPmtl6KANnneF3eIA4c13 biJ7HlR9FMctDMSGM4Z6gJmHv2SioTs94FxRw8Avyj1ymUGliwWX7xkfjbm8FXMNMknf d2oQV7AdlqybJ9Kwu1ObCtAhaGWwCddfyDIY4hBs4wEuE3lWiAtZCT0yzeXclEOpWYse IQjOFwBFPrQ+KyoR/MrCTuFt/8VfPYHcwf81tcndG4ctErsO1Kea4dArG7rpgEmnDp78 TPYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WMk1nCz58J59xLAbzaK5SBTHCkOrofwv2aAeHFRi4Pc=; b=rrNV4D6p8sI9QROXTjSlsBQNhvjTn5kRXOylFtGqGJuF7j6JKikj2LwRYv3fUHN266 NdHVjZqbTUb6RiWIAeYQAZeZ5QxDjdzZA4B1V1P74aHLaTKqtTalyPHsbBL4Q+1Z/ii9 4KrqteVCTVzU7SuPwAEQNrbvVbMCamdwufhvSYu0xKECUB69G+MMG8qprc+NqslyIBsM Ta/5Z3Xtig7XeaYRr4cbexyKtnGYGX8ysn1FfG9oJPJivinxxbv7uHWrVdRL4cirRqAY 9Pq8twJM/PX+Z1Tox6pnruak6HliETtzS7MAoI447nBtaGPVh3U7uHoBO6KqG3is2nKz /JdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dt7zA69E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv15si1249066ejb.364.2020.09.17.20.13.27; Thu, 17 Sep 2020 20:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dt7zA69E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726979AbgIRDJ1 (ORCPT + 99 others); Thu, 17 Sep 2020 23:09:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:48910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbgIRCDE (ORCPT ); Thu, 17 Sep 2020 22:03:04 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76400235F7; Fri, 18 Sep 2020 02:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394583; bh=4ArYKZ/cOZ/rDNpNLfku/rCgHABEw+VMVH8kjYJ4YY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dt7zA69E0lKA8+YMOJFQMqYPlc8idAawpmR2/nzODhDp3LloAHFEAHNNSjYR4xsQu 5+jZCvso7i+4BEi5ga/HlRBdkCUbFZ7Wxh0RJknf1qmoo3Ry1zy6OP5EMICmyD/Y/c eYlNogGRSP5dyoUxK29HJGWXcCTOg4zr8TfowcUY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bart Van Assche , Bean Huo , Can Guo , Avri Altman , Stanley Chu , Tomas Winkler , Alim Akhtar , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 093/330] scsi: ufs: Fix a race condition in the tracing code Date: Thu, 17 Sep 2020 21:57:13 -0400 Message-Id: <20200918020110.2063155-93-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit eacf36f5bebde5089dddb3d5bfcbeab530b01f8a ] Starting execution of a command before tracing a command may cause the completion handler to free data while it is being traced. Fix this race by tracing a command before it is submitted. Cc: Bean Huo Cc: Can Guo Cc: Avri Altman Cc: Stanley Chu Cc: Tomas Winkler Link: https://lore.kernel.org/r/20191224220248.30138-5-bvanassche@acm.org Reviewed-by: Alim Akhtar Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 020a93a40a982..d538b3d4f74a5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1888,12 +1888,12 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) { hba->lrb[task_tag].issue_time_stamp = ktime_get(); hba->lrb[task_tag].compl_time_stamp = ktime_set(0, 0); + ufshcd_add_command_trace(hba, task_tag, "send"); ufshcd_clk_scaling_start_busy(hba); __set_bit(task_tag, &hba->outstanding_reqs); ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); /* Make sure that doorbell is committed immediately */ wmb(); - ufshcd_add_command_trace(hba, task_tag, "send"); } /** -- 2.25.1