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 43B7EC54EBC for ; Sun, 8 Jan 2023 03:05:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48DC2855B7; Sun, 8 Jan 2023 04:04:31 +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="XZkmg+ur"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48FB785651; Sun, 8 Jan 2023 04:04:15 +0100 (CET) Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 BA7E48566E for ; Sun, 8 Jan 2023 03:51:27 +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-il1-x12c.google.com with SMTP id h26so3279461ila.11 for ; Sat, 07 Jan 2023 18:51:27 -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=et2dJiBhWZ4X4Nw5YBDi1OxTBHsDFw4UxWw6wGNIQYI=; b=XZkmg+urzz06pzEm9GBUMwGxGOQcyrYbG7DELmehcpMDA/1yMZLKCIYo+xiNBbU1lq WhpQViwLV0/YUnVUTBCh38BtBpud9phxivRLbWAqOIci7p8kDlOKXAcx6dj5vfa1Ysrw cpWAjbHoWgArJL13RgB2vKah3bjw0ZvHOtsUo= 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=et2dJiBhWZ4X4Nw5YBDi1OxTBHsDFw4UxWw6wGNIQYI=; b=Q6o78qjuOA0S58UAKdAi8tLK+gzVYIO086eOgVwYkHAnSDeYMcP/3JKeR35fXF2IjJ nJ7/Z9yDWiV5VMQHdcwnlj2f+XHGXfOGUCs2hXYS0n619LmJjE5K56dbCj87lqsJgnxv XYgKKTMZe4+6Obo6mCq2lq1CBkV4AKGXmtVChAV9iuexJXACbNCBg7XISEodfaVQ6u4k yVyF9kOdK3yfWLNfZkhiqqXVv9TuxxNnTiLfT7z51sVQkWEayQqyQNTzgNIP2/RVjWWv nAPtPG0VPmOiUO6O249SKPlRpgIXmFnvoqpEXbO3dzNxwKfeDF2zC7un/whxB9VBI9dS DEwQ== X-Gm-Message-State: AFqh2kpaWvpw4ztQ5b1hfX2haxf/aHDJpTM1p5pUTycyP4zRrQ2ZTics yXVOykolN9x52E0tL3dgAcqGPwZ4/jUVuS5v X-Google-Smtp-Source: AMrXdXs20ikyq1lI20LHF/dy4eQ+8M2g/bHrhyBPTWgWYaRWpDZH3kepMmIcmZQmi9sdZp1+oK4eaw== X-Received: by 2002:a05:6e02:58a:b0:305:ef92:6480 with SMTP id c10-20020a056e02058a00b00305ef926480mr43141383ils.27.1673146287247; Sat, 07 Jan 2023 18:51:27 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 44/71] ata: Don't try to use non-existent ports Date: Sat, 7 Jan 2023 19:50:20 -0700 Message-Id: <20230108025047.522240-45-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-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 --- (no changes since v1) 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.314.g84b9a713c41-goog