Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 599EAC352A1 for ; Wed, 7 Dec 2022 09:04:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30802856E8; Wed, 7 Dec 2022 09:56:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Kna0wbeY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9670C85573; Wed, 7 Dec 2022 09:56:34 +0100 (CET) Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 48423856E5 for ; Wed, 7 Dec 2022 09:56:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pj1-x1035.google.com with SMTP id u5so7580427pjy.5 for ; Wed, 07 Dec 2022 00:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3gbHyP0FNP3aWyvSYjZ05kYh4qVBcey/KQfQPDn86Os=; b=Kna0wbeYhQQJTTwDNN59YYOZgBbnIbb18RsISUXaULk1nb96UjxWsN4QXgysVk1s35 R910esjt/L22pvH2paVpUfqweGg2FEIDxdW8+1xE6ukj2wAE63M51ZE3gqUyma3+S3Jg XXeGdGg5npYP3VjPvULRirf/NFY25Mst/8xW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3gbHyP0FNP3aWyvSYjZ05kYh4qVBcey/KQfQPDn86Os=; b=yxHV0qAcTyOMRLQSBt/2lXhoJ0wl0gsks0mXDqS7LbJQ3HI4PJOxyFNrkLXrboeeez /enGssAeHsjT4+HTx9ydAx4tR25FvZKRsmkShh8m49PQ+JY0POsp5gCcf/0S4zcI/Iu+ VkfXeyW06bfKdg/VCRLpwyaGedgI5fxXr5aXgR/Ng657rx1IW7CcNsxMyr5PC8fHhDS3 tdFleZLSnhMDI6SOvt7rZCH5pgFkI3d17TuSVD+Pz3ul/1OHNlgLeP6IXzdBJJDit2lm eJb1ZBzg3CXXzdaIj0hNBIMV1dlgNLE+giqbUyg90jhOeI8gKYcTfDU9skH49/BwadF/ lr3g== X-Gm-Message-State: ANoB5pne/USqYqJKDhFLyH995e1bJOjMT4g5uM0XSsDiYzXF56TqcaWC fxfxPOsps7WPvfyd5yHJXPJrYYsL/7pXFctf X-Google-Smtp-Source: AA0mqf5mdFXfB6DRGY4/aRyoyuVKUq1veu9Wilfs2uQdJ+cBEtXhAkP2g0FUwEDTVomRn2MbxMbM/g== X-Received: by 2002:a17:902:f792:b0:186:b32c:4cdc with SMTP id q18-20020a170902f79200b00186b32c4cdcmr74198411pln.166.1670403388475; Wed, 07 Dec 2022 00:56:28 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Andrew Scull , Bin Meng Subject: [PATCH 44/71] ata: Don't try to use non-existent ports Date: Wed, 7 Dec 2022 21:51:10 +1300 Message-Id: <20221207085137.445249-45-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The controller indicates the number of ports but also has a port map which specifies which ports are actually valid. Make use of this to avoid trying to send commands to an invalid port. This avoids a crash on some controllers. Signed-off-by: Simon Glass --- drivers/ata/ahci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index de6131f1d9b..272c48b8e57 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -675,6 +675,12 @@ static int ata_scsiop_inquiry(struct ahci_uc_priv *uc_priv, /* Read id from sata */ port = pccb->target; + /* If this port number is not valid, give up */ + if (!(uc_priv->port_map & (1 << port))) { + debug("Port %x not valid in map %x\n", port, uc_priv->port_map); + return -ENODEV; + } + if (ahci_device_data_io(uc_priv, port, (u8 *)&fis, sizeof(fis), (u8 *)tmpid, ATA_ID_WORDS * 2, 0)) { debug("scsi_ahci: SCSI inquiry command failure.\n"); -- 2.39.0.rc0.267.gcb52ba06e7-goog