From patchwork Wed Jun 12 20:37:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 804500 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 4E97384FB7; Wed, 12 Jun 2024 20:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718224670; cv=none; b=NZ/KntlwofEsyGeddDruvA7zikRWeRa2g70ZrI1hG2if0UoOIlgV581qqbC7PVFTwpqv9kxyEYQgnLxJd1yEV/q0GGIf5YuKpd0SBgaARPLBde0uVgVOZ3VT5zVNj9HQ2VEo1MWq2qu91SuDmBbV6TbgI/GJvheSdpi24UMznjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718224670; c=relaxed/simple; bh=qVdsce9kI7phLWSg6H8f1oBYl958AVtUymwUn2irbvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kS5IlNSfANIHQnv0jxPhcEIURQJtDT22u6wGUG56RFH24QCYpikzc/lqXsnx5ZWcwieDv2pwAQY5u3IpantJRFEuC1PgLLgakg3hJ/AIlD5bmwz2dQog9pPeH0FL84hPIIuG9dMl4D066TTcrIKCkac00dfXtqpCWGVbdLXRXMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=V/PnVLy9; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="V/PnVLy9" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Vzy644rBnz6Cnk9X; Wed, 12 Jun 2024 20:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1718224663; x=1720816664; bh=yEYek 9bgEzYOmdogb2Tp0iSUExccUecXfH9k7dVFWHc=; b=V/PnVLy9Na1LnEh6+A6Ki UBZ24k5kEbInQzIka2dqkgiVQ+irDnoWZz0u4M94WmNSdCNfJwEaOQlXoAvEaBOf b4fQbTJuYgIekc09dSmH2f5wnNyMIUHT/r+LVpT6bT511Uz105mmK/c/bonCFdGo yXWE9phwDS3n6j8ZcU/vIsGxTAyERVP3J3BOxI74b9mbB3izFpic+52BUIALx5nN h61CODWTw/7jjRcEzCX9Jr6HElU6JmsZG4sMOX0GybkLjOEqo52HCIv6p28251oV +2eDWkq+xswQKkMkqBfc4TgTEkhQya5PMQTwCXhb6G04uxu6mGRI11v6hRflUTae A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id fISjZYGyZOef; Wed, 12 Jun 2024 20:37:43 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Vzy5y6gb9z6Cp2tZ; Wed, 12 Jun 2024 20:37:42 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: Alan Stern , linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, Bart Van Assche , Joao Machado , Andy Shevchenko , Christian Heusel , stable@vger.kernel.org, "James E.J. Bottomley" Subject: [PATCH v2 1/2] scsi: core: Introduce the BLIST_SKIP_IO_HINTS flag Date: Wed, 12 Jun 2024 13:37:33 -0700 Message-ID: <20240612203735.4108690-3-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612203735.4108690-1-bvanassche@acm.org> References: <20240612203735.4108690-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prepare for skipping reading the IO hints VPD page for USB storage devices. Cc: Alan Stern Cc: Joao Machado Cc: Andy Shevchenko Cc: Christian Heusel Cc: stable@vger.kernel.org Fixes: 4f53138fffc2 ("scsi: sd: Translate data lifetime information") Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 4 ++++ include/scsi/scsi_devinfo.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3a43e2209751..fcf3d7730466 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -3117,6 +3118,9 @@ static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer) struct scsi_mode_data data; int res; + if (sdp->sdev_bflags & BLIST_SKIP_IO_HINTS) + return; + res = scsi_mode_sense(sdp, /*dbd=*/0x8, /*modepage=*/0x0a, /*subpage=*/0x05, buffer, SD_BUF_SIZE, SD_TIMEOUT, sdkp->max_retries, &data, &sshdr); diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index 6b548dc2c496..fa8721e49dec 100644 --- a/include/scsi/scsi_devinfo.h +++ b/include/scsi/scsi_devinfo.h @@ -69,8 +69,10 @@ #define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32)) /* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* Do not read the I/O hints mode page */ +#define BLIST_SKIP_IO_HINTS ((__force blist_flags_t)(1ULL << 34)) -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 +#define __BLIST_LAST_USED BLIST_SKIP_IO_HINTS #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ (__force blist_flags_t) \ From patchwork Wed Jun 12 20:37:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 803825 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 C922E84FB7; Wed, 12 Jun 2024 20:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718224673; cv=none; b=mw3B7fsur3xBklFjCebqXro+dZbF1W56YbnoLkHJAmDVdkRCxyP6gYpXDaabJ1qNAiabqmVBvIDjVM40Vj9Hm8qOcru0294jzCqC2xSXkLcaaNCZQxsdzKX0Eg/xXpoOmzW/v1GUq4aGX5TGl7kW6onfDhc2evtHMMF1Q3hQxHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718224673; c=relaxed/simple; bh=P6YdIf+4h9Mbh9g27KC45uffOCN8bhGX+6xrXGja70g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qesKk0HRkJFqULcFT21kW/BPcbab6/cMTdkcOsZ1rC9DMVUtfaQsCLrUxa7i8kpyiVmLlAfA2siVOcl3OERfA+vrDd1xQoEFex0NRlGQQinq5owdSv4FLWf1+iyZDdxIyCm1/CGAWRyjImk7BTTa8yW4RKUpM2mESMeXKpYOkpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=c3RB1txl; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="c3RB1txl" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Vzy673jwwz6Cnv3g; Wed, 12 Jun 2024 20:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1718224664; x=1720816665; bh=vkQHJ TTJIwL9c+V0Yep/xL4oLUQVR0FrLfLA/m0LXvA=; b=c3RB1txlv0ZhRUvtUzF5C oyLtvY4KZ6BFV/kxYGR/rCofpz6ld4hik7ATC7+b01pZIcOTF6rq6f7EnT0/gs61 XbVuW6ODBrzDv13OYwk4vFOnKRJ5Gmv4xPB37z8lNCMqG+6AsguJYJsRtvrQCZab EOy1HaYVA3L287J4OgzPt5tF9iD7HrG1dGOr9jrdeDhcVqUPMfgY3wCbIatJNTmR dZo9BjMG4mcmTSTrdPtKWLoFVGlpg90uqYu/5Hzsf4/VuCl0me6KmYVLfWvTrKb9 TVGdA88GvNfobr0ckF0XdXPSguBcd7VT1REqtrgDBN+yrqYug7dMiMsYKNa3h3DD Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id wX-nDI5cUhJu; Wed, 12 Jun 2024 20:37:44 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Vzy600hxFz6Cnk9Y; Wed, 12 Jun 2024 20:37:44 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: Alan Stern , linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, Bart Van Assche , Joao Machado , Andy Shevchenko , Christian Heusel , stable@vger.kernel.org, Greg Kroah-Hartman , Oliver Neukum Subject: [PATCH v2 2/2] scsi: core: Do not query IO hints for USB devices Date: Wed, 12 Jun 2024 13:37:34 -0700 Message-ID: <20240612203735.4108690-4-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612203735.4108690-1-bvanassche@acm.org> References: <20240612203735.4108690-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Recently it was reported that the following USB storage devices are unusable with Linux kernel 6.9: * Kingston DataTraveler G2 * Garmin FR35 This is because attempting to read the IO hint VPD page causes these devices to reset. Hence do not read the IO hint VPD page from USB storage devices. Cc: Alan Stern Cc: linux-usb@vger.kernel.org Cc: Joao Machado Cc: Andy Shevchenko Cc: Christian Heusel Cc: stable@vger.kernel.org Fixes: 4f53138fffc2 ("scsi: sd: Translate data lifetime information") Reported-by: Joao Machado Closes: https://lore.kernel.org/linux-scsi/20240130214911.1863909-1-bvanassche@acm.org/T/#mf4e3410d8f210454d7e4c3d1fb5c0f41e651b85f Tested-by: Andy Shevchenko Bisected-by: Christian Heusel Reported-by: Andy Shevchenko Closes: https://lore.kernel.org/linux-scsi/CACLx9VdpUanftfPo2jVAqXdcWe8Y43MsDeZmMPooTzVaVJAh2w@mail.gmail.com/ Signed-off-by: Bart Van Assche Acked-by: Alan Stern --- drivers/usb/storage/scsiglue.c | 6 ++++++ drivers/usb/storage/uas.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index b31464740f6c..b4cf0349fd0d 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -79,6 +79,12 @@ static int slave_alloc (struct scsi_device *sdev) if (us->protocol == USB_PR_BULK && us->max_lun > 0) sdev->sdev_bflags |= BLIST_FORCELUN; + /* + * Some USB storage devices reset if the IO hints VPD page is queried. + * Hence skip that VPD page. + */ + sdev->sdev_bflags |= BLIST_SKIP_IO_HINTS; + return 0; } diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index a48870a87a29..77fdfb6a90c8 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -820,6 +821,12 @@ static int uas_slave_alloc(struct scsi_device *sdev) struct uas_dev_info *devinfo = (struct uas_dev_info *)sdev->host->hostdata; + /* + * Some USB storage devices reset if the IO hints VPD page is queried. + * Hence skip that VPD page. + */ + sdev->sdev_bflags |= BLIST_SKIP_IO_HINTS; + sdev->hostdata = devinfo; return 0; }