From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 1244742E8E2 for ; Mon, 6 Jul 2026 21:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783371673; cv=none; b=LBPs/int6/XmqacbKQ/aH8oIgsFDpRDWqiEQDCTRLW09NHpJjos41QJX0V6I2OEnd2hFLGv7VZpc3mCn8sLUVSWwqbsAxbR12mBujmzo1jNOTfeLw3wN1tV5EoymqxSbfk1njCMYByhusqHKEX6y0NDuNPdMyA32nlWL5+Gyeec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783371673; c=relaxed/simple; bh=AUsdJIwhx/8wVrjpLpGu9bj0SdXuTRaeDaoVf0zlRbY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tzIXOliTMC+DWkrvbogkpb6fBuzoAEuFWduaciD5luRzFnUOCSbxivEWN33ZgKSfDr3qiTtCUQjIOtjE9deTUtD5gJfDeXfVGG+4cMbLxUMOEDoS/cX6daG0ba5t3QwRNMAM3hFh60Nqpak0aocEaaz9y+T0FF2tJo5DtA0Ifvk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tadamsjr.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oqWpKHE+; arc=none smtp.client-ip=209.85.214.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--tadamsjr.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oqWpKHE+" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2cae134ab3aso59525905ad.2 for ; Mon, 06 Jul 2026 14:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783371669; x=1783976469; 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=u7XCOgk7ctBSByIGDwcU0SJLQp5oIbrKOxK4NCnIYMs=; b=oqWpKHE+IUx12ZeaHoF2z46O4BI6trqnQp4AkygU0kHr/mq702UVn8JtTr4dQ+wpce VJxPNngplB1dYLYfA6SOD+2k6hp42ZufTfzsRzKHvTGTCTTEMR25yQoelHh0WKVx9Pd0 u2dcMU1J2XnoQ2dlaO9F0MJ8vf3vae52vg3Z/KZg88nRlkKBayu+cLQyd8bZ0piDJyzM EpdflKzMW0FKXar4Pw0LCtvuxgs3J9Ozoi4mUHHg3QxcUixX74J2+3BMe3DGU1OIVrZE KmI+NkOR5AUyj/yS5eclL0xWG1yB9QtcshLIX1pFqH7bWB4OiGXR+snqNtQvexoChfqI Hr/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783371669; x=1783976469; 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=u7XCOgk7ctBSByIGDwcU0SJLQp5oIbrKOxK4NCnIYMs=; b=NnxQ9lqPLYnhlTqhdrZ1fMXgt1M3OwEtdAjjU039RimuJsKvuM2UGFo9RhDSVvthMv +WjvcRl4z+j/hioikTmAL877DCOe35NwvtHdVYPdzcEcPrJtb/M/bgbW2uTTbakyl1l7 /+BYcXhT3HMl5y0LYg+VmkD+v5+NNIkUfrLvRvlaemBr7ixNuvi+Zd+uRQV1P6J7QyKw obfM4yCqoKAjGQuKrfy09yvTtzBuKHFCE1YVvgxndxdMw4v5i7+B2m8rCwiqXYx+g/ET fOCDGPNh2+Ktgz3sbAVzyzcZJ2ddZPJkvnd/YA2HwaDUpEb/rhoRfIhRDf5XQek2taxW zTRA== X-Forwarded-Encrypted: i=1; AHgh+RoeZUwmhnJC8O6wkSH/oy4q1YrSm3Bz1jY/3KAhOT6ah1vyA/3xVcVyTyX+RrF22fahZ25dbriQhaS/oqE=@vger.kernel.org X-Gm-Message-State: AOJu0YzTQDDIQHOcedSe1oh8Z8bV39x94Xq0TatDy4963F+E2un5sSuf gaxt/7baBqgNOsAKiaimZSSFTlAQVYwA6aPbBnL9Fy73drlnyd1zGmsMhNaQveRvfCfyj/SfApV T1G35fSYlfSokUQ== X-Received: from plw20.prod.google.com ([2002:a17:903:45d4:b0:2cb:97d4:2e28]) (user=tadamsjr job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:15c7:b0:2cc:777e:a878 with SMTP id d9443c01a7336-2ccbee1e07bmr24202235ad.26.1783371669268; Mon, 06 Jul 2026 14:01:09 -0700 (PDT) Date: Mon, 6 Jul 2026 14:00:54 -0700 In-Reply-To: <20260706210054.1336654-1-tadamsjr@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260706210054.1336654-1-tadamsjr@google.com> X-Mailer: git-send-email 2.55.0.rc2.803.g1fd1e6609c-goog Message-ID: <20260706210054.1336654-3-tadamsjr@google.com> Subject: [PATCH v2 2/2] ata: libata-core: Allow capacity transition to zero for locked drives From: TJ Adams To: Damien Le Moal , Niklas Cassel , Hannes Reinecke , "Martin K. Petersen" Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv , Salomon Dushimirimana , TJ Adams Content-Type: text/plain; charset="UTF-8" Commit 91842ed844a0 ("ata: libata-core: Set capacity to zero for a security locked drive") introduced setting the device capacity (n_sectors) to zero in ata_dev_configure() if the drive is security locked. However, during runtime revalidation, ata_dev_revalidate() compares the new capacity (now 0) with the old capacity (>0) and detects a mismatch. Since it does not consider the locked status, it returns -ENODEV. This revalidation failure can occur when doing a reset of the PHY (e.g. hard reset) for a controller that has I/Os in flight. The timed out I/Os trigger the SCSI Error Handling (EH) path, which in turn invokes libata device revalidation. If the drive is locked at runtime (e.g. it lost power during reset and relocked), revalidation sees the capacity transition to zero and fails, eventually disabling the device. Fix this by allowing the capacity transition to zero in ata_dev_revalidate() if the drive is reported as security locked by ata_id_is_locked(). Fixes: 91842ed844a0 ("ata: libata-core: Set capacity to zero for a security locked drive") Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Terrence Adams --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3c06a15952f8..c43bd28b20b1 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3992,7 +3992,7 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, /* verify n_sectors hasn't changed */ if (dev->class != ATA_DEV_ATA || !n_sectors || - dev->n_sectors == n_sectors) + dev->n_sectors == n_sectors || ata_id_is_locked(dev->id)) return 0; /* n_sectors has changed */ -- 2.55.0.rc2.803.g1fd1e6609c-goog