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 E661630DED8; Wed, 28 Jan 2026 15:43:09 +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=1769614990; cv=none; b=WSG1kn46ZCA8uQa5zpKfogfdtGw29UualKPCOHV8AfT5fd3ETiqipWzkcINDnozrs0cUKpv047So9rCQjqG7fTpHQWqQ9X/HtXUBUy5WVlA6krg+KPuLSnUkHFK3e4dFqiuRe+QISO05qPym7C2bvJt49pYfnsp1wrCHSEAEDrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614990; c=relaxed/simple; bh=qNTohIxFW2j/EwXaNfp+jG9g6TogB5/023dltnRguaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qwM6e8rrB2SQbATO6EgNfc/HxPzTj0WEClzQjFvUAG47RtSsbL5zgXDQuAURO6YAx/q4o5alucly4G1CixH/dAGtBYhu2NNfmbzXBXHdw0RAaNZLWjNag5LIITNrqANCMFLlMwVE2hONDdS4uLz7F56w+toNgIYqF2WqbdrdKUU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FvgQCkXy; 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="FvgQCkXy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03DEBC4CEF1; Wed, 28 Jan 2026 15:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769614989; bh=qNTohIxFW2j/EwXaNfp+jG9g6TogB5/023dltnRguaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvgQCkXy4HX+reZoSDmBmy/9z61pLiKGDluNu9Xh7S2qaEkIPf6gaYgrcZk/g6nV/ 4ssjXx9hdgTFPDhnrKKSugemqMDfduJOHy7+zKbho69Z8+WK1nMPmhM44T8njcxSKH V6ByFwF+UjIbsryRZzWxAIdAC8Z2rE+U58/uuT0k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Niklas Cassel , Wolf , Damien Le Moal , Sasha Levin Subject: [PATCH 6.12 013/169] ata: ahci: Do not read the per port area for unimplemented ports Date: Wed, 28 Jan 2026 16:21:36 +0100 Message-ID: <20260128145334.493088050@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128145334.006287341@linuxfoundation.org> References: <20260128145334.006287341@linuxfoundation.org> User-Agent: quilt/0.69 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit ea4d4ea6d10a561043922d285f1765c7e4bfd32a ] An AHCI HBA specifies the number of ports it supports using CAP.NP. The HBA is free to only make a subset of the number of ports available using the PI (Ports Implemented) register. libata currently creates dummy ports for HBA ports that are provided by the HBA, but which are marked as "unavailable" using the PI register. Each port will have a per port area of registers in the HBA, regardless if the port is marked as "unavailable" or not. ahci_mark_external_port() currently reads this per port area of registers using readl() to see if the port is marked as external/hotplug-capable. However, AHCI 1.3.1, section "3.1.4 Offset 0Ch: PI – Ports Implemented" states: "Software must not read or write to registers within unavailable ports." Thus, make sure that we only call ahci_mark_external_port() and ahci_update_initial_lpm_policy() for ports that are implemented. >>From a libata perspective, this should not change anything related to LPM, as dummy ports do not provide any ap->ops (they do not have a .set_lpm() callback), so even if EH were to call .set_lpm() on a dummy port, it was already a no-op. Fixes: f7131935238d ("ata: ahci: move marking of external port earlier") Signed-off-by: Niklas Cassel Tested-by: Wolf Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- drivers/ata/ahci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 944e44caa2606..e78b97fe81708 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -2071,13 +2071,13 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (ap->flags & ATA_FLAG_EM) ap->em_message_type = hpriv->em_msg_type; - ahci_mark_external_port(ap); - - ahci_update_initial_lpm_policy(ap); - /* disabled/not-implemented port */ - if (!(hpriv->port_map & (1 << i))) + if (!(hpriv->port_map & (1 << i))) { ap->ops = &ata_dummy_port_ops; + } else { + ahci_mark_external_port(ap); + ahci_update_initial_lpm_policy(ap); + } } /* apply workaround for ASUS P5W DH Deluxe mainboard */ -- 2.51.0