From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BEC7524C067; Tue, 29 Apr 2025 17:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946657; cv=none; b=OZjFdInBxMZn1VxvfYXMMLpB3laIstt80Vk2hopo+j+EglZE7qEXztSRgrQ6qMoOjzubfsRf8cdOxJ0JNz5XBGVMh0wAJTtgK43XfaXQEQw7bPa1g0Gu16yMVM3Oeo1IuaKqYGqqZqxTZGQBXR28KkxsbHKeGyaJlHLCQzkzMSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946657; c=relaxed/simple; bh=hRxaomzV0oELqgzt/WJ3GPhPSjIHi//Qobxe96B+NG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eBFX8epKSIhjI7By3BL/Q6yD6dtasymztU4yjl4XN9+XmmtN2ln9ydLBD0nwaqzR0OoygMA2FmXDSDGqMzcs74nWmudg3Yr2IuDkZjDSED6Wb4gc8/+UdYIbIGNx9U/S6VR45nBcT8nEQAjDU7ZbZipYgVIm1YhBHMOFpY6kXEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jf2AGKQK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jf2AGKQK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A31FC4CEE9; Tue, 29 Apr 2025 17:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745946657; bh=hRxaomzV0oELqgzt/WJ3GPhPSjIHi//Qobxe96B+NG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jf2AGKQKVnOsRWjXjkrRapZlzSJybXxgBcTkC4ufOBj1OJj0sXeN6Ooq1VTjkpd0Q 3YS5a/FOiO+7/zZpuaAUupvGQ3T7AoiBH5/u8urzpMzNFDpgastauhkSaf0fNIJ6RW ski98FTs8ixlxGJi2L6KaejgzDKrcOtL7KqJk+Qw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Philip Pemberton , Damien Le Moal , Niklas Cassel , Sasha Levin Subject: [PATCH 5.10 026/286] ata: libata-eh: Do not use ATAPI DMA for a device limited to PIO mode Date: Tue, 29 Apr 2025 18:38:50 +0200 Message-ID: <20250429161108.937190514@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161107.848008295@linuxfoundation.org> References: <20250429161107.848008295@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit 91ec84f8eaddbc93d7c62e363d68aeb7b89879c7 ] atapi_eh_request_sense() currently uses ATAPI DMA if the SATA controller has ATA_FLAG_PIO_DMA (PIO cmds via DMA) set. However, ATA_FLAG_PIO_DMA is a flag that can be set by a low-level driver on a port at initialization time, before any devices are scanned. If a controller detects a connected device that only supports PIO, we set the flag ATA_DFLAG_PIO. Modify atapi_eh_request_sense() to not use ATAPI DMA if the connected device only supports PIO. Reported-by: Philip Pemberton Closes: https://lore.kernel.org/linux-ide/c6722ee8-5e21-4169-af59-cbbae9edc02f@philpem.me.uk/ Tested-by: Philip Pemberton Reviewed-by: Damien Le Moal Link: https://lore.kernel.org/r/20250221015422.20687-2-cassel@kernel.org Signed-off-by: Niklas Cassel Signed-off-by: Sasha Levin --- drivers/ata/libata-eh.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 48130b2543966..e700024a8b482 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -1479,8 +1479,15 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev, tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.command = ATA_CMD_PACKET; - /* is it pointless to prefer PIO for "safety reasons"? */ - if (ap->flags & ATA_FLAG_PIO_DMA) { + /* + * Do not use DMA if the connected device only supports PIO, even if the + * port prefers PIO commands via DMA. + * + * Ideally, we should call atapi_check_dma() to check if it is safe for + * the LLD to use DMA for REQUEST_SENSE, but we don't have a qc. + * Since we can't check the command, perhaps we should only use pio? + */ + if ((ap->flags & ATA_FLAG_PIO_DMA) && !(dev->flags & ATA_DFLAG_PIO)) { tf.protocol = ATAPI_PROT_DMA; tf.feature |= ATAPI_PKT_DMA; } else { -- 2.39.5