From patchwork Fri Jun 14 19:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 1948116 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=O2mQf/Y+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-ide+bounces-1530-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W18GH32Zwz20X9 for ; Sat, 15 Jun 2024 05:19:03 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 14845B25732 for ; Fri, 14 Jun 2024 19:19:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD4DB1A38EF; Fri, 14 Jun 2024 19:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O2mQf/Y+" X-Original-To: linux-ide@vger.kernel.org Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30B0B1487C7 for ; Fri, 14 Jun 2024 19:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392730; cv=none; b=FsU7gY+g9EHkTyadYKaOkIMSkb8o5Z0t2m2rtDEEASc4XuCYQ7m58dB11NkqOphdFY3hibS20kC4tZll+9RwtsDKwcYIKYFCariCuMN5AvtFkf7QGh4hffPg5nEPcNfy85B+pXBMCPYpx9S0ZnTD7mZhuBmE7cgpzL+OKxlh9U4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392730; c=relaxed/simple; bh=3kS79tYzgOf3yX79jAg0FWDEvMWZi/lcq/PdWyuqi8I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AUg4hmrsO3R2CLqbq1jNxlCdJlrRwbh6g2eBdx/2yBwqOrdfLgfIaPAlfYi3PpId0qDcjiVA5ne8kJ1stTybv5jAs8xr2k/vYkSqu0CDmZkWiwYQRSU5Wcce0lOoqRiMNyYUvE4AwSJtD53lMX0rhDqM2LicpKbzCF/ynCGdY3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=O2mQf/Y+; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-70426999383so2064923b3a.0 for ; Fri, 14 Jun 2024 12:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718392728; x=1718997528; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uSZdAXqO25TNI8nIM2+VeqTcUj08zaT02GPeczOjqik=; b=O2mQf/Y+D2lUQrc4fDYQ1m9Jw+6YyybiHQumEJnQPA45YiF/loJ/TjkogH26TBQE+N XN1OmuuZEr3mHwkMfcDWzIt8tJMxmfaDvsbzv5+3snOjPvYkHkEtwTrGFEtjISX5TNwm jxqCEULJrKwV9AX7Hi/uHlbmsd+9kTAYUHYXrHcBhwy6Lku5F3jrxNX75a2bLhmxQGTQ XsxNu0wZFxpBc9wcR8aWYO0gYkM15OBg+C4elO5e2tvv/ZMqv3Xzoq02LsoezwoJV+bl QVVU88ZLKqE76mEWJB3uQFs4KWbOVp16dkIT50Cj4nxLOrWkSScJTkZnQqXfgvoYDpJi NaAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718392728; x=1718997528; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uSZdAXqO25TNI8nIM2+VeqTcUj08zaT02GPeczOjqik=; b=moAk+ikDP1qtwhZNv70822O1U9+1aJzM2R5vaanRGHjrUyjv2TjsnfBdEMJxe3SA4N fYrAB1c+WenuVpcisra/VkpnprWZZ6pnL47zUyTzRwTTi94MSvT6RSSaQl9l2J2V7eiL o1/hJ+klcdytjVHAHGjgKAWJyTmOu24Yki5xpU410YkcHDsd+IjvsnHkTl+78PxmTrJ0 JzTi3+YKsve9tDILV/xSu0eoeRyUl8HGf3NuPDCSgbwI60FYotckBKdgcGJ/jQOMHt78 09AHEy4RQN1A1uLSJLZ/OllbL7pY/Gbg6NQXuEZQrnPqHsnO9g5n8mRQGQnfKG88XwZJ mFHQ== X-Forwarded-Encrypted: i=1; AJvYcCUYwN/7qmiSdlCc6lsC06LHheoyh9kl1xJJyRPudUfw3OMwabxeCoxPoYBlVjy7kAthMM1zR20aPuUvTCM8L24bYJ3W0R9zdoMq X-Gm-Message-State: AOJu0YzeIkGDmyiZ8YzBfd8ILwMXwxHd56aGjHUe81cGvQrhLhKWiIM7 s7HDCUwjP3dkRmLdn6Q3r0ICoUqIB9vVxJzbzbmZfr39HHX1R1gWxnvbGqU7vqVLzyzKiljz7sR +Y5CjyRfKag== X-Google-Smtp-Source: AGHT+IFdj24c8fzBtMzoKfG+48fuiFtXBqhb0JfTQ+EiejlPio658jL+zK7WceIb3isG3JKB/NWVMCK8RBbQDg== X-Received: from ip.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:57f3]) (user=ipylypiv job=sendgmr) by 2002:a05:6a00:1d85:b0:705:27de:74e7 with SMTP id d2e1a72fcca58-705d70f12b2mr58576b3a.1.1718392728230; Fri, 14 Jun 2024 12:18:48 -0700 (PDT) Date: Fri, 14 Jun 2024 19:18:32 +0000 In-Reply-To: <20240614191835.3056153-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240614191835.3056153-1-ipylypiv@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240614191835.3056153-2-ipylypiv@google.com> Subject: [PATCH v1 1/4] ata: libata: Remove redundant sense_buffer memsets From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel Cc: Tejun Heo , Hannes Reinecke , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv scsi_queue_rq() memsets sense_buffer before a command is dispatched. Libata is not memsetting sense_buffer before setting sense data that was obtained from a disk so there should be no reason to do a memset for ATA PASS-THROUGH / ATAPI. Memsetting the sense_buffer in ata_gen_passthru_sense() is erasing valid sense data that was previously obtained from a disk. A follow-up patch will modify ata_gen_passthru_sense() to stop generating sense data based on ATA status register bits if a valid sense data is already present. Signed-off-by: Igor Pylypiv --- drivers/ata/libata-eh.c | 2 -- drivers/ata/libata-scsi.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 214b935c2ced..b5e05efe73f6 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -1479,8 +1479,6 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev, struct ata_port *ap = dev->link->ap; struct ata_taskfile tf; - memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE); - /* initialize sense_buf with the error register, * for the case where they are -not- overwritten */ diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index cdf29b178ddc..032cf11d0bcc 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -858,8 +858,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) unsigned char *desc = sb + 8; u8 sense_key, asc, ascq; - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - /* * Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. @@ -953,8 +951,6 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) u64 block; u8 sense_key, asc, ascq; - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - if (ata_dev_disabled(dev)) { /* Device disabled after error recovery */ /* LOGICAL UNIT NOT READY, HARD RESET REQUIRED */ From patchwork Fri Jun 14 19:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 1948117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=3iA6cSmg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ide+bounces-1531-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W18GY3Drmz20X9 for ; Sat, 15 Jun 2024 05:19:17 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 296271C20F09 for ; Fri, 14 Jun 2024 19:19:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D984C1AB51F; Fri, 14 Jun 2024 19:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3iA6cSmg" X-Original-To: linux-ide@vger.kernel.org Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B7731A3BA7 for ; Fri, 14 Jun 2024 19:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392732; cv=none; b=ieIolhVFfYrqTN/waB6EYjfRfi4ze5fBEXtUkHitlMcUm51l+xP2CENeYKamfmFXJs2155UQvGX+VgbbY1tc/J3Oq9qeIJJgsG+auRLSnZJNE1IvBfR/MkLDSM1+bdT+i3NZf3s3yNYFYOOTvuVDbCpnx1Qs7EW+IfG5asB3JtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392732; c=relaxed/simple; bh=OXTK3gM4Pr8t3G/JNhWI9HNDMuZTEBhK+WvzY4WWxdI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=J7/g/bDEfNxwrhMw1V4RnUVBvDKn1+NIejdhRCKNYHUvtTzev05OIBzLWrqxRGbVb4h1VMFmERzRlTssEqICTx0YTh1R63A7rT2hNUNhp9/myQg13DTNRNyaatuAfNEdNBUnGfHCGIP713BCysrvcE/aa4kxTtSNs0zKJlhGgkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3iA6cSmg; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62a3dec382eso27184367b3.1 for ; Fri, 14 Jun 2024 12:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718392730; x=1718997530; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=U+A9L+Row2dnJmZ3QpC1oG5yWdVfX7wPmeHXsPZEOds=; b=3iA6cSmgYmEBTuAgmjE3+BsFfK1KRTliplTZ7NlVWdBBZBovwI0cTZ5q8F43rizXy/ Artx1iqvVwlwgpPxw+rJ8r5w9x8qAU+VYmod7v3tQuBNBPkp0NHqQp6xyo2zQ4d1MFLn k8TBdh71DQwG24lcmDAwS6z470rPqSWjsPcaCi+aG94irDaAIYZ9e5Mp1h6PPO6JVWTJ TTXFsL13IbOmK33I1LiWsNN0+WtPVLIycowaoTj8HFnms4W6KrDd7CZh9VjoTFnXqi5n a1OuAih5hDOrWfZEHfPb1WZE8bw6RhGkUJvZWfCNDMOfYhKiUNG7MSqqUWjPmeZf7q7j m/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718392730; x=1718997530; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=U+A9L+Row2dnJmZ3QpC1oG5yWdVfX7wPmeHXsPZEOds=; b=Ov1ttTIdteXfImU1knDfy6X3QnLBxnKkQ1u+n0kdNr5yI70AmA6l4repROsxbviask VnFp328OYmoqP0rUKN3qBLLvCy8cowXeAAV9AQKbs5m5FsuUI6nK5cA3OJneE1UHeTYF 5N9YpZkwsncbyqRe7LM+R7FaPlwm5Zfen7jfG/XE3P95/DgjSDEzRwKyllH6JN31byoa nijHWRh6kyhzUKh2jXGSOEX8WXmyBvKm4j4J2CPR9/545TK/m0LejcP0APuJ7cFkw6WL y/sFEnkw5/zehqTjqLYFT1/dzkNBgkDmpRT4ICfbeRuow3UqPTBbYgnunc5fAden2Phg 5mqA== X-Forwarded-Encrypted: i=1; AJvYcCWAW/Qw6CRS3bJ8SIfJmexfPEDl1Kgn3/DblPWb1ERT7uGQaNuYRZS7viwz1OztmrorWl9HbheNvqrusjXWi059hc1ybIoU+3lb X-Gm-Message-State: AOJu0YynMYc1MCclwfP/3ldegpmVz5seAhdv5AnpclcM0k8L6WeBhKK3 g/eMDZqLsbBnRjJQ45NVHB8s+U2UlUssEfUkc9h9ix8lKrzUcHTYQNGpluWy1Gep/ubf2tPGsrV AtDGz7EDSDw== X-Google-Smtp-Source: AGHT+IEgr36e43Ztcq9blL3xwno/d+31kbeTYxCB2shQPDd8Hlpao0W3TzB2dN5UT4kq97FW/dtEczVMQBa9BA== X-Received: from ip.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:57f3]) (user=ipylypiv job=sendgmr) by 2002:a05:690c:6e0a:b0:618:5009:cb71 with SMTP id 00721157ae682-632072d3bb5mr9083077b3.5.1718392730342; Fri, 14 Jun 2024 12:18:50 -0700 (PDT) Date: Fri, 14 Jun 2024 19:18:33 +0000 In-Reply-To: <20240614191835.3056153-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240614191835.3056153-1-ipylypiv@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240614191835.3056153-3-ipylypiv@google.com> Subject: [PATCH v1 2/4] ata: libata-scsi: Generate ATA PT sense data when ATA ERR/DF are set From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel Cc: Tejun Heo , Hannes Reinecke , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv SCSI/ATA Translation-5 (SAT-5) Table 209 — "ATA command results" specifies that SATL shall generate sense data for ATA PASS-THROUGH commands when either CK_COND is set or when ATA_ERR or ATA_DF status bits are set. ata_eh_analyze_tf() sets AC_ERR_DEV bit in qc->err_mask when ATA_ERR or ATA_DF bits are set. It looks like qc->err_mask can be used as an error indicator but ata_eh_link_autopsy() clears AC_ERR_DEV bit when ATA_QCFLAG_SENSE_VALID is set. This effectively clears the error indication if no other bits were set in qc->err_mask. ata_scsi_qc_complete() should not use qc->err_mask for ATA PASS-THROUGH commands because qc->err_mask can be zero (i.e. "no error") even when the corresponding command has failed with ATA_ERR/ATA_DF bits set. Additionally, the presence of valid sense data (ATA_QCFLAG_SENSE_VALID) should not prevent SATL from generating sense data for ATA PASS-THROUGH. Signed-off-by: Igor Pylypiv --- drivers/ata/libata-scsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 032cf11d0bcc..79e8103ef3a9 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1632,8 +1632,8 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) !(qc->flags & ATA_QCFLAG_SENSE_VALID); /* For ATA pass thru (SAT) commands, generate a sense block if - * user mandated it or if there's an error. Note that if we - * generate because the user forced us to [CK_COND =1], a check + * user mandated it or if ATA_ERR or ATA_DF bits are set. Note that + * if we generate because the user forced us to [CK_COND=1], a check * condition is generated and the ATA register values are returned * whether the command completed successfully or not. If there * was no error, we use the following sense data: @@ -1641,7 +1641,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) * asc,ascq = ATA PASS-THROUGH INFORMATION AVAILABLE */ if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && - ((cdb[2] & 0x20) || need_sense)) + ((cdb[2] & 0x20) || (qc->result_tf.status & (ATA_ERR | ATA_DF)))) ata_gen_passthru_sense(qc); else if (need_sense) ata_gen_ata_sense(qc); From patchwork Fri Jun 14 19:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 1948118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=DBOPVBvU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ide+bounces-1532-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W18Gl6FcDz20X9 for ; Sat, 15 Jun 2024 05:19:27 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0501F2857D2 for ; Fri, 14 Jun 2024 19:19:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C3C91AB8F4; Fri, 14 Jun 2024 19:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DBOPVBvU" X-Original-To: linux-ide@vger.kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A5351AB525 for ; Fri, 14 Jun 2024 19:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392734; cv=none; b=XUeicco9J40cpeMzRYTgORbrBPD95ilWcsGaVclq1SGqi4rNWHsPKS0L1AQjc0QulcxVPn15a+r+mON4xUMiib2gxRBowZLYjdr0L20HkTVhCfceOM1l3iAevKuNKudJvXWoV+xAutkxkE7/tJkuVaQBs62dI8U6hMgRI3sfg6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392734; c=relaxed/simple; bh=OsE7aRRVqh2vPXKdIi6uRApNlBEwCqMLvrna3Rqbvuw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=feT3OYRu62lxcMa4Cp8pjSJKHGDSVqCjV72t2JBTFrkfwhphvM6uxbsAnWbC78hLllb6gOZtt44YMVu2WGLe2MYSNVuyWKv51zyZ8/odxAyMnXBd7DZqNaKTAJMk2bJFevhvU8tNBLzn6N3Nt/B8Pfp0BBO9CV23NKScxzWuN98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DBOPVBvU; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-627f43bec13so42599257b3.0 for ; Fri, 14 Jun 2024 12:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718392732; x=1718997532; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=N5Y8Q6R7VHhS5DlEz/CEIrnOSJXapU1igMdb8ysJrOY=; b=DBOPVBvU3EXdWiCghMmclltYGpzQ260xnSnXIqsRnLQk8eY2XQbWaRUzX5pv/w3COX iDhHNFDnx8gg6vedSdPF2l1LpJCBcb1ef1geKqNRsRFSA9mHU/ZFE00JhwfN7F5X+tOo rIYOPR3YeRwYSOvJbO93F3ybna1DbI4yjpf+bMPHT4eC+jvucMAJ8Ohi/rGZ6GvkhNge ZvqMAuhpUG7okfesfQLSVtmyfThCFIlSXs9T/aRWZZmMTLe5cKEi0jMjip0ArrVeLvd4 TAZ+FYzGmmAbNpbwpzqlj6xhs//8qCa4a4Gud6cPxbchM56ooebaRN7WdPZk99OjcoxQ Bklg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718392732; x=1718997532; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N5Y8Q6R7VHhS5DlEz/CEIrnOSJXapU1igMdb8ysJrOY=; b=C4kJzhOR5WEwTDauDZBPyPkneSvKmut7Q2xaC8isPNEnebWfuapzAbJadwee8Jw2oK tez+lK7sMuniBebyo7y22koD4guPa+ZyMa1x7MFX569ZYK8IDcemBw9t6KW+CmYXASfK j2AxwGZqq3DfEedqG4sIQrYLtE9ETW/AyRRzBtuyOx1sBEGU2nbvXRDNd6AQGVMfXgMB k1NwQogUE2HEi3qEqz/Fzw2bhG72MrmlQbl3Udz7T2Wli7YjZGGqJZAwczdUd4wKZoc0 BI4GRO3/TGdmKXaFnEQH41zQ5z0Rsu6LwwvsYN5znyq4DLkYMIJzaZfShaMf8sdsLW7j /0wA== X-Forwarded-Encrypted: i=1; AJvYcCUVoEOgaiTrQ4VCmrcUO1DBkzXQWFlGrqzWZmmC3rvKpMcS0wCKzoJFZv/Lu04M5suw06296yWbXPpK4d5Xx21roZBcY1qu6cq2 X-Gm-Message-State: AOJu0Yz0oiAQ0xdKX3gki3pVK62hWMMSe9cVZcfBv0xmWb9SVcvE8802 VPiKyOWJNT0EHVnekOeeMzHOJKzYINIH1mTfqjJW4dbRXf6KO3eHDWNnkDilDP7M13t5Ywf6gUB X5ffN56xt/Q== X-Google-Smtp-Source: AGHT+IFAQcSwFKGcNCpGx6cDExUUokRstHtgNipOk4oYaWFz9OzYHZCeAbLOqEXX5BK7k/s00LnS2IvikgPe7Q== X-Received: from ip.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:57f3]) (user=ipylypiv job=sendgmr) by 2002:a05:690c:398:b0:62d:a29:537e with SMTP id 00721157ae682-63222565d7emr10233367b3.4.1718392732108; Fri, 14 Jun 2024 12:18:52 -0700 (PDT) Date: Fri, 14 Jun 2024 19:18:34 +0000 In-Reply-To: <20240614191835.3056153-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240614191835.3056153-1-ipylypiv@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240614191835.3056153-4-ipylypiv@google.com> Subject: [PATCH v1 3/4] ata: libata-scsi: Report valid sense data for ATA PT if present From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel Cc: Tejun Heo , Hannes Reinecke , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv Do not generate sense data from ATA status/error registers if valid sense data is already present. Signed-off-by: Igor Pylypiv --- drivers/ata/libata-scsi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 79e8103ef3a9..4bfe47e7d266 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -858,12 +858,17 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) unsigned char *desc = sb + 8; u8 sense_key, asc, ascq; - /* - * Use ata_to_sense_error() to map status register bits - * onto sense key, asc & ascq. - */ - if (qc->err_mask || - tf->status & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { + if (qc->flags & ATA_QCFLAG_SENSE_VALID) { + /* + * Do not generate sense data from ATA status/error + * registers if valid sense data is already present. + */ + } else if (qc->err_mask || + tf->status & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { + /* + * Use ata_to_sense_error() to map status register bits + * onto sense key, asc & ascq. + */ ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, &sense_key, &asc, &ascq); ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); From patchwork Fri Jun 14 19:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 1948119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=B6Yo+ktA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ide+bounces-1533-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W18Gx4jG2z20X9 for ; Sat, 15 Jun 2024 05:19:37 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9D0181C20FD9 for ; Fri, 14 Jun 2024 19:19:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEF211ABCCC; Fri, 14 Jun 2024 19:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B6Yo+ktA" X-Original-To: linux-ide@vger.kernel.org Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B6661AB8EF for ; Fri, 14 Jun 2024 19:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392735; cv=none; b=AoR2K1VE8Wa/zWIeg/FVh9Kugut18R3V4WrNvCUBxQWM8NDJupjBumb+xL+mO5R1SqCKDX9UNb3rOCOE8EIc+oVC5v/DoQEuZ59oAVnOfUmAJ4AZcDaAHTp7x+MFQxWqH2PoC9ikJ1iOOueI0bFmb/n1sLhe41WhLIiMIjryIgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718392735; c=relaxed/simple; bh=qgmtNL4k97jHCwRfQqDmBVh7jd6+0c78XagNpSAyDsc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=f1fEvT7OPTmA3McVBdl/nmhogiGd6lCZAdXrw7nbW4CkhTP/XshDTI6FXm88FT8COQG8UsfbggRe+Ix3ral9tM9Gq9JiM0w2+WO/hoZquifq2rpiuxCX49rOCb+b8nEl0s+YHQdDcdJdcCFEfrk6Z10/olok9eESaoBwshuPn20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=B6Yo+ktA; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-6cebd09196bso1602425a12.2 for ; Fri, 14 Jun 2024 12:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718392734; x=1718997534; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=/4AyfSTdpu6N2Lo5b6nZ4La1DDoSqqNXNC9AYdKo6X0=; b=B6Yo+ktA4Y6r0pnzTunJVbAAVCggpn02WJlQah7rNLepgOF10Ue7B9hbbDHeNi7Sff um9ZhtjPxHctqi4rM1PiBTV76aZksTMo7WhKDr+/9VFuY/3XSpIzmj6JCix2hslAV258 ePiqhnQd3WtakFp0EqYdtrqnPkCJLnXh+xZ8n9licsks2I5uaws8Gd1lP9p5hK8vMVt0 YLKsnZFUXagyci6m77TSRQC68AGLEJmaZMDgfqKYkvRmTb4C7N/HvXXLOme0jOI0dpKo a7Ye4bfKLypEV9dxmSQUUY5bwYpmTyLVPS2tw085zPtGWseih0JJ6UKT64ChrRd+andL ehRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718392734; x=1718997534; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=/4AyfSTdpu6N2Lo5b6nZ4La1DDoSqqNXNC9AYdKo6X0=; b=SxhscAd9fg9lZxzt8wYNMqt2kbFzYS1VTPr+HEMnvGlOscy8smeFcGJ5CklcxyiLRI vwZTOHompufAijgmIDTrmIsd2eId89KZC0e8230OBXQm7LbVFWLV/Cz8cy4gIV1keKPw jHdCe4hcvG7b3YlFhEoaP2HFaGZO6xA9mxeg11heQGHT4VgwVXvrO1zN5uDhW2Nhkhej gGGPHpfQq6Eh+tucxcM9QYqSkdKUxZJX60qTttrDoBOzgMwlPMJQgJnQv53hyI6jH+yG HjEQYKGBUiQVPYDMDT/k0DiWv/BVwLd69VSGXIXuJhZbPwltc+oX8EcoK6blPsAFSXvC EDoA== X-Forwarded-Encrypted: i=1; AJvYcCWF5lWRYQ6eLQSMxlCdgtPDOdewQEOm7dab93lZueBxP/tdXp3NKKvBHKiB6Vd3gOEWddnze+a08360avaErCC+k83pQJUHuHUn X-Gm-Message-State: AOJu0YxN6J8IeZyglxgFQl4iWQC76vR/LNQ50Eb01EROP6dsa/rSnVix izG57Sb9B7Nsx+uc+iBOdc2yq5e/elVCbUZcT1ZI43Sl1LVh8iWm9q2mA6i4vAwcmFVFh4v7Nzu CUBACgr7Fgw== X-Google-Smtp-Source: AGHT+IFhH0CY+7Imr4D7VPghy++YvEZgaw5IeIxH2RrSR71z103r+UyBHoV1Cf87mIAHSR19WF+ZEMhiq4U01Q== X-Received: from ip.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:57f3]) (user=ipylypiv job=sendgmr) by 2002:a63:4c04:0:b0:6ea:87eb:9493 with SMTP id 41be03b00d2f7-7019504fd99mr9226a12.2.1718392733536; Fri, 14 Jun 2024 12:18:53 -0700 (PDT) Date: Fri, 14 Jun 2024 19:18:35 +0000 In-Reply-To: <20240614191835.3056153-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240614191835.3056153-1-ipylypiv@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240614191835.3056153-5-ipylypiv@google.com> Subject: [PATCH v1 4/4] ata: libata-scsi: Fix offsets for the fixed format sense data From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel Cc: Tejun Heo , Hannes Reinecke , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv , Akshat Jain Correct the ATA PASS-THROUGH fixed format sense data offsets to conform to SPC-6 and SAT-5 specifications. Additionally, set the VALID bit to indicate that the INFORMATION field contains valid information. INFORMATION =========== SAT-5 Table 212 — "Fixed format sense data INFORMATION field for the ATA PASS-THROUGH commands" defines the following format: +------+------------+ | Byte | Field | +------+------------+ | 0 | ERROR | | 1 | STATUS | | 2 | DEVICE | | 3 | COUNT(7:0) | +------+------------+ SPC-6 Table 48 - "Fixed format sense data" specifies that the INFORMATION field starts at byte 3 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands: +------------+-------------------------+ | Field | Offset in sense buffer | +------------+-------------------------+ | ERROR | 3 | | STATUS | 4 | | DEVICE | 5 | | COUNT(7:0) | 6 | +------------+-------------------------+ COMMAND-SPECIFIC INFORMATION ============================ SAT-5 Table 213 - "Fixed format sense data COMMAND-SPECIFIC INFORMATION field for ATA PASS-THROUGH" defines the following format: +------+-------------------+ | Byte | Field | +------+-------------------+ | 0 | FLAGS | LOG INDEX | | 1 | LBA (7:0) | | 2 | LBA (15:8) | | 3 | LBA (23:16) | +------+-------------------+ SPC-6 Table 48 - "Fixed format sense data" specifies that the COMMAND-SPECIFIC-INFORMATION field starts at byte 8 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands: Offsets of these fields in the fixed sense format are as follows: +-------------------+-------------------------+ | Field | Offset in sense buffer | +-------------------+-------------------------+ | FLAGS | LOG INDEX | 8 | | LBA (7:0) | 9 | | LBA (15:8) | 10 | | LBA (23:16) | 11 | +-------------------+-------------------------+ Reported-by: Akshat Jain Fixes: 11093cb1ef56 ("libata-scsi: generate correct ATA pass-through sense") Signed-off-by: Igor Pylypiv --- drivers/ata/libata-scsi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 4bfe47e7d266..8588512f5975 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -855,7 +855,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) struct scsi_cmnd *cmd = qc->scsicmd; struct ata_taskfile *tf = &qc->result_tf; unsigned char *sb = cmd->sense_buffer; - unsigned char *desc = sb + 8; u8 sense_key, asc, ascq; if (qc->flags & ATA_QCFLAG_SENSE_VALID) { @@ -880,8 +879,9 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D); } - if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) { + if ((sb[0] & 0x7f) >= 0x72) { u8 len; + unsigned char *desc; /* descriptor format */ len = sb[7]; @@ -919,21 +919,21 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) } } else { /* Fixed sense format */ - desc[0] = tf->error; - desc[1] = tf->status; - desc[2] = tf->device; - desc[3] = tf->nsect; - desc[7] = 0; + sb[0] |= 0x80; + sb[3] = tf->error; + sb[4] = tf->status; + sb[5] = tf->device; + sb[6] = tf->nsect; if (tf->flags & ATA_TFLAG_LBA48) { - desc[8] |= 0x80; + sb[8] |= 0x80; if (tf->hob_nsect) - desc[8] |= 0x40; + sb[8] |= 0x40; if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) - desc[8] |= 0x20; + sb[8] |= 0x20; } - desc[9] = tf->lbal; - desc[10] = tf->lbam; - desc[11] = tf->lbah; + sb[9] = tf->lbal; + sb[10] = tf->lbam; + sb[11] = tf->lbah; } }