From patchwork Tue Apr 18 19:01:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranav Prasad X-Patchwork-Id: 85027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3071678vqo; Tue, 18 Apr 2023 12:14:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZwgMBjmERD+MISn9GcGQxyHD9FTT4ctz9ZWYa947Dem6U2m+OjFfuWeR6KNHiDQLEruGRx X-Received: by 2002:a05:6a21:6d8a:b0:ee:a546:d439 with SMTP id wl10-20020a056a216d8a00b000eea546d439mr860307pzb.38.1681845278119; Tue, 18 Apr 2023 12:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681845278; cv=none; d=google.com; s=arc-20160816; b=tpr7oX6MjogkeLKU5eLIuULZzkryo/Qoj5qwARomzNnxsKv7oaYDBj30nx7pjE7SmE f++yzu1Y5n9SS0j8EkTzBtvl4/ei3kBiljd0AeM6V3tY5r+fyLDXSMJs63Q595BW3dj2 HQQl/djx8tLRPWrWPeQuXWtkyMAOKyKMFJEVq7Bf+ccCj68gsqSYlBb316VV979PD14y MvgalBDx+1OviO8lZvPoDY+jlYSl7a6fob0/Uf2ZIIw+Ypv53sAjpd4lScnTnQBzJ0Zi CnBbvK6pWPQSnRRvnwJyj7laJQveLU3gdB0wZSkkaX0dK4xxmp+qeIhbsG7o85xqjWHx YBqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=qpvX6zUZ3jJSuVnzz4zMHHsJJxYIrejED2Kgcd4VmHE=; b=sjcw7GWJfDzEI7tRQAVjC8AQ46Spe9GoGatFbQySdc271MCjhf5XwmO3nxw/6JveBn eZtT2pky4ZEDEevycIwdL3/ApTolYnQaYzFD2ky+M0XQOYjjHip3qoagTxFGGNojbLJF sBsPNy6ZkTcZTKlFA7k4l+OLrxTrDxp4dF4R4+pfgViCkW9Sl6rMzf/ah43lcB0M5/81 6+aBUjq7lLJ+38YubOve45/UPvJgOb6cEellYp5HPmKqVzPgQ2nLMC4nMrVF7g60amis b24En2ct5Ad39j/baf6NC4hF1yS7yy8RDdwUB9t9fwcjRDbTWMQ7MiM8IA6tcz0AiLuq 0TcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lrLE+nDG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020aa79d0c000000b0063b8dc46d4dsi6039234pfp.19.2023.04.18.12.14.25; Tue, 18 Apr 2023 12:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lrLE+nDG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232719AbjDRTC2 (ORCPT + 99 others); Tue, 18 Apr 2023 15:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbjDRTCG (ORCPT ); Tue, 18 Apr 2023 15:02:06 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB41AC147 for ; Tue, 18 Apr 2023 12:01:57 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54f69fb5cafso211707887b3.12 for ; Tue, 18 Apr 2023 12:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681844516; x=1684436516; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qpvX6zUZ3jJSuVnzz4zMHHsJJxYIrejED2Kgcd4VmHE=; b=lrLE+nDGD3TZMrxvhsLtTXo+MNZ85rg5PEI9Nq6nxIGe6cjQJsYwtEVVtXsZvhPACp I+clHOcIZHU3sn0gZwgImhOcecFYUu2CF3TDngh8xKkpf839M9bc5GGFLd72Bhb0TvMc qz+OBU8XG1j8DkyljpLzjQh8qHIm8UpTufz0UUz7eEjof9zws82ra68q99kqYl8kMP/r uII2BDiN1wlpPZzd5POZ6XwzrbF1n3XYQZza6YnLSHtFX95okvT1Wpo07CrT5DzU0Fos QxTT/dNYmSHv1mQVBqX32MQ0+ebXb5Hq04VriTzYf+nyGMgXHDF15TEk2wKSiWl7Pi1J hUbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681844516; x=1684436516; 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=qpvX6zUZ3jJSuVnzz4zMHHsJJxYIrejED2Kgcd4VmHE=; b=DmwG4kDQQU5woqqIQaeGMtN00MnOzz4JfpKQsvXiovl+p4hffJjW8K7g0AbxKI/P2j QI157QNa6j/S5xWTBWH8m62lzB1OrPSmAwOlf8qVLP+3u1daBbMDDQMogsbaq7yWXhpK vfSh3EhRnvU4zIeTIN8/MJscOKBu/8sTzRIqQ1NRdn3pTm9XZ0hbCr+4hhmn8TAg/NJk NuJjm1C4gj9gqDJYlUQnYqKXeNKc4VNzHUea9Xw/OpH/30SHFJwwRsEcGloF7E8R0tvJ QIEOsoAEeL3srCTitksEh/usA9EMtAHnFOVKMQ4PzzgPduqfnDuagbpCAvfd4FCeO/Cs 4ZmA== X-Gm-Message-State: AAQBX9cLRz3mOL4wiOh1DfECOoiC5oWYahajF7tTRaoGiaOoXg52ZsN8 UbOy5tLu0vxctQRkR7NpbSGECB/0ftNqKA== X-Received: from pranav-first.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:390b]) (user=pranavpp job=sendgmr) by 2002:a25:df41:0:b0:b8b:eea7:525e with SMTP id w62-20020a25df41000000b00b8beea7525emr12896039ybg.5.1681844516750; Tue, 18 Apr 2023 12:01:56 -0700 (PDT) Date: Tue, 18 Apr 2023 19:01:01 +0000 In-Reply-To: <20230418190101.696345-1-pranavpp@google.com> Mime-Version: 1.0 References: <20230418190101.696345-1-pranavpp@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418190101.696345-7-pranavpp@google.com> Subject: [PATCH 6/6] scsi: pm80xx: Update PHY state after hard reset From: Pranav Prasad To: Jack Wang , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Changyuan Lyu , Pranav Prasad X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763542594393815567?= X-GMAIL-MSGID: =?utf-8?q?1763542594393815567?= From: Changyuan Lyu Update phy_attached, phy_state, and port_state to correct values after a hard rest. Without this patch, after a successful hard reset, phy_attached is still 0, as a result, any following hard reset will cause a PHY START to be issued first. Signed-off-by: Changyuan Lyu Signed-off-by: Pranav Prasad Acked-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 85908068b8d7..39a12ee94a72 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -3417,6 +3417,7 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); u8 phy_id = (u8)((phyid_npip_portstate & 0xFF0000) >> 16); + u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); u16 eventType = (u16)((lr_status_evt_portid & 0x00FFFF00) >> 8); u8 status = @@ -3449,7 +3450,6 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) break; case HW_EVENT_PHY_DOWN: hw_event_phy_down(pm8001_ha, piomb); - phy->phy_attached = 0; phy->phy_state = PHY_LINK_DISABLE; break; case HW_EVENT_PORT_INVALID: @@ -3567,14 +3567,15 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) break; case HW_EVENT_PORT_RESET_TIMER_TMO: pm8001_dbg(pm8001_ha, EVENT, - "HW_EVENT_PORT_RESET_TIMER_TMO phyid:%#x port_id:%#x\n", - phy_id, port_id); + "HW_EVENT_PORT_RESET_TIMER_TMO phyid:%#x port_id:%#x portstate:%#x\n", + phy_id, port_id, portstate); if (!pm8001_ha->phy[phy_id].reset_completion) { pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, port_id, phy_id, 0, 0); } sas_phy_disconnected(sas_phy); phy->phy_attached = 0; + port->port_state = portstate; sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR, GFP_ATOMIC); if (pm8001_ha->phy[phy_id].reset_completion) { @@ -3608,14 +3609,17 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) break; case HW_EVENT_PORT_RESET_COMPLETE: pm8001_dbg(pm8001_ha, EVENT, - "HW_EVENT_PORT_RESET_COMPLETE phyid:%#x port_id:%#x\n", - phy_id, port_id); + "HW_EVENT_PORT_RESET_COMPLETE phyid:%#x port_id:%#x portstate:%#x\n", + phy_id, port_id, portstate); if (pm8001_ha->phy[phy_id].reset_completion) { pm8001_ha->phy[phy_id].port_reset_status = PORT_RESET_SUCCESS; complete(pm8001_ha->phy[phy_id].reset_completion); pm8001_ha->phy[phy_id].reset_completion = NULL; } + phy->phy_attached = 1; + phy->phy_state = PHY_STATE_LINK_UP_SPCV; + port->port_state = portstate; break; case EVENT_BROADCAST_ASYNCH_EVENT: pm8001_dbg(pm8001_ha, MSG, "EVENT_BROADCAST_ASYNCH_EVENT\n");