Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3017506pxj; Sun, 6 Jun 2021 23:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwknBo47mCsBAeDsucfl5n+xoy4s1HN+J4mt9PWhoCsAlhxy905eUAmb+9WvwSA1vMPGPQa X-Received: by 2002:aa7:d74b:: with SMTP id a11mr18267170eds.95.1623046693944; Sun, 06 Jun 2021 23:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623046693; cv=none; d=google.com; s=arc-20160816; b=PVCW2iQiqh+0rBR/DZbQ+YezH5mtSz7j4EJIqJ0i9Ks48FnHTNvQHyLDGgFoMSVfMz QstSKnl+u+1t9VL5pXEA0+oKG1bS/QCmTW7I0TPHkmcqQoQzJhER1R79EuN6H5GoWiop i19grJeDcCMvXHON/FITdydyxSGzHpb7JLvCAanCT3lDcIeYT+KPWuU0oYIdQ6+vW+qA kRYn7La0/dOqh2OVhj6rYoDlPjZXK2HEwXfu4VWUfFPqMJi7Rj6xqDCNdORdB9KiE8d9 ECjakywTDy21Q4qGCR1M2VcgYk+oeS+sNaCJXFK9ttQxHHqPwQkmhOVYwHsbOmjvuHg3 elug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=3A/G+mZT62hkoQPacjtgeXJa6v4KoDqG1UOz8vpHjRY=; b=TDtYyMINwTzMcXPE1kD6mgx87/loFeJJ0nFwZQfUiy080VERt1OCFzOlDQpgZm9CL7 LoBz5hqkMCCBV0NI5yMioiiVjyraU5g6wzuqQngArMzkt6AAk0CyBv0CVOBntrF68ghT Ob1sezxGJaduley9N6GH/P25vf3wpAFVnP0Cd8niVabHmpaFrU1UWbOb2RWHF61MuvWv h2gnVYL7bovfJT1onS90Jvwf0CE7ZDqaw52d+OTghD1FZqMWkwfuzu8gSvIl9snEiXwJ cK7hURqkMFD7CzdzTtlK5ik6fto5Ox/ASLysipM0GEbcZ2mq6i/FtBLsdw8/P1VCTHKh VADg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=b4bP9RA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si13564689edd.348.2021.06.06.23.17.51; Sun, 06 Jun 2021 23:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=b4bP9RA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbhFGGR1 (ORCPT + 99 others); Mon, 7 Jun 2021 02:17:27 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:2821 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhFGGR0 (ORCPT ); Mon, 7 Jun 2021 02:17:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1623046534; x=1654582534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AXJBFjm/7TYzVmtA72gTqs/XcMuZbx07I+y7xGfmgC4=; b=b4bP9RA5yy1DacYD32KbDFIJx3TRn45VEwuCBmLMZb/NLgWqGhxxVvFG xBSgAOn88p7szKpmLMA/Gvb8SMIsEXHoBdxQkzZXzeSK0ra+zbiycECm6 ykXmRRFuzYc/Ezk2u04EHRUBTXphOp6L4x6UkbTFib4U3KU+AfYf/fGbs a2Q1Rhh0CeTPqlztZvrq+wEcMYT9d4GsxOUhZaFgha6T3StTXV1yzEhwK OKaY9rhStb0kUm1h911r4onUcA1Ua7wJGG/3VTi67Bojl/DWzcybfPewi kAY+gkANS2YmYTdACUDiVyMcQ+y9VBqKKaAoMXxmCpJEsAYS4HY5Bpvvm w==; IronPort-SDR: urVnFkjvf/R1oE970TvZaPHftm/chj9b/EhXGbLE5aanhfrk8E6eBj3SUicETeY8GepU86H1eP H5Wka6DZ03V7eztF6P7PITh9sonGF6YWHtGk2/d4wZvBMKM6Ow6hy1I16M3++edWOcr1Bajkck yRSChsZTqzJmX/wkeh3KFGf9l9llTD9wyqpbJE7sKIYMN3NalSjw2xCcvj2Ss1U16+BPSVYQJq GVwzahhUkfB9Q4jPRcqfnQsZyItv9s/ANeTyYbahkVnSxf0va749IsXC1iSboPHP9ZduB9m7f5 oO4= X-IronPort-AV: E=Sophos;i="5.83,254,1616428800"; d="scan'208";a="175741178" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Jun 2021 14:15:34 +0800 IronPort-SDR: okqM6UCQRpMccJuneo+TJ5roxGQ2zyPDxUqKVRkrMGXXitNUi5khfdG90aMhfSmPQuZQdyBnfN LGhgYoOxLSciS+T3gRIfAiswkHLXv4S74XCtRBl31VKTCzCYiwqrZ1kkMSqVTTYoSc8RANGhe+ rdpELsF56tnHNvMGKWcXeo+Hl75RqinOh0iKYj8XHyu3zLrgGYe8+K/lY/N1aCd7M7yVA0GiIL fe9DO/x5lBwz1ym8QWICSwd+viuyc2BotxM0bX70F2w5pSVYESUVM34fJOIJTKqolApI3Jd/HA M2R31nCs/GV0md6myiEtKLTf Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2021 22:53:17 -0700 IronPort-SDR: t3NsnUIGc+k2cKIG+n/RK88LiXHHrq8v9nnHxut+geflD6AlbEOIIRFzNH3Dni5h0JEfhXFkYS oWnLG196bvt5hHVB1DaIFwUjnUzuyl8hi8b4rtxrqumhG6oF869XmMCT+7vPRozMDu6ChMh7/a JVTubvtwYyZ/Ex2shQWPf2kHMI6kZ7uYKUhAxTZxM6IcTGYfLHXEpzP70MQUP5wA4hM59Jp9La Ho5UtZAH6kil8u574K3zsoYN39iuUiyQBed+IE+xETG7juHHQ3voECPqPMsuT+t5dm0bb/GvFw tc8= WDCIronportException: Internal Received: from bxygm33.sdcorp.global.sandisk.com ([10.0.231.247]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Jun 2021 23:15:31 -0700 From: Avri Altman To: "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, Bart Van Assche , yongmyung lee , Daejun Park , alim.akhtar@samsung.com, asutoshd@codeaurora.org, Zang Leigang , Avi Shchislowski , Bean Huo , cang@codeaurora.org, stanley.chu@mediatek.com, Avri Altman Subject: [PATCH v10 07/12] scsi: ufshpb: Add hpb dev reset response Date: Mon, 7 Jun 2021 09:13:56 +0300 Message-Id: <20210607061401.58884-8-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210607061401.58884-1-avri.altman@wdc.com> References: <20210607061401.58884-1-avri.altman@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The spec does not define what is the host's recommended response when the device send hpb dev reset response (oper 0x2). We will update all active hpb regions: mark them and do that on the next read. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 32 +++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshpb.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 0ef46aa71045..1a29fe491c62 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -195,7 +195,8 @@ static void ufshpb_iterate_rgn(struct ufshpb_lu *hpb, int rgn_idx, int srgn_idx, } spin_unlock(&rgn->rgn_lock); - if (activate) { + if (activate || + test_and_clear_bit(RGN_FLAG_UPDATE, &rgn->rgn_flags)) { spin_lock_irqsave(&hpb->rsp_list_lock, flags); ufshpb_update_active_info(hpb, rgn_idx, srgn_idx); spin_unlock_irqrestore(&hpb->rsp_list_lock, flags); @@ -1417,6 +1418,20 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, queue_work(ufshpb_wq, &hpb->map_work); } +static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) +{ + struct victim_select_info *lru_info = &hpb->lru_info; + struct ufshpb_region *rgn; + unsigned long flags; + + spin_lock_irqsave(&hpb->rgn_state_lock, flags); + + list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) + set_bit(RGN_FLAG_UPDATE, &rgn->rgn_flags); + + spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); +} + /* * This function will parse recommended active subregion information in sense * data field of response UPIU with SAM_STAT_GOOD state. @@ -1491,6 +1506,18 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) case HPB_RSP_DEV_RESET: dev_warn(&hpb->sdev_ufs_lu->sdev_dev, "UFS device lost HPB information during PM.\n"); + + if (hpb->is_hcm) { + struct scsi_device *sdev; + + __shost_for_each_device(sdev, hba->host) { + struct ufshpb_lu *h = sdev->hostdata; + + if (h) + ufshpb_dev_reset_handler(h); + } + } + break; default: dev_notice(&hpb->sdev_ufs_lu->sdev_dev, @@ -1816,6 +1843,8 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb) } else { rgn->rgn_state = HPB_RGN_INACTIVE; } + + rgn->rgn_flags = 0; } return 0; @@ -2141,6 +2170,7 @@ static void ufshpb_cancel_jobs(struct ufshpb_lu *hpb) { if (hpb->is_hcm) cancel_work_sync(&hpb->ufshpb_normalization_work); + cancel_work_sync(&hpb->map_work); } diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index 1ea58c17a4de..b863540e28d6 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -127,6 +127,7 @@ struct ufshpb_region { struct list_head list_lru_rgn; unsigned long rgn_flags; #define RGN_FLAG_DIRTY 0 +#define RGN_FLAG_UPDATE 1 /* region reads - for host mode */ spinlock_t rgn_lock; -- 2.25.1