Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp941137ybg; Wed, 10 Jun 2020 18:40:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqCUqHQIGrd0Q8vK8NqFnJAKowNgBGiAbblhFy3XflSypPkj/rcqG/sx559GwUxkYw4XvC X-Received: by 2002:a05:6402:1d0d:: with SMTP id dg13mr4747026edb.146.1591839600354; Wed, 10 Jun 2020 18:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591839600; cv=none; d=google.com; s=arc-20160816; b=QnYolQJ47XIMJYmEJNUNXmUCm8NlDU1TZLmUTTUkKEp0G0ArUrHwWjTD0NC0V2kzqQ Grr/a2uiC9tkdGwf44dEtNjiVDZzLOxh7Y4TTmK25myJwXu37uAMeAY8xg0+1ArYfCMt WK2YtXdffkd5V4ZPTL6g4QEu/PfhKTqmHiY8DmCHmEAvWJtbDImMb8jEg81w1hofDXQr pEuaMg6t7YbpRiBBdAlfyrSyO9BzEME/5aOYr2EKyZTjQdouj5i/NDdXswbHX9/46Shf 9X30rtvrAT3N2csKG+CzUu+8OhiPsJSRjRiQQehCsAreItZZ3S7Yjy/q4ooPs5bIFfb0 H0tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=JvLFQ/Pp9kYuh584xFsBL9APcPBK2H+2UekyjU/1FqE=; b=yP5KJL+7Lw18qBuLhiO2L8QCcyQ66ZbUVGOoFjcm+gfd7pGu6Qw7bZltxZb3rENkam tIa6OAF/wUB4IdTvADkB9Sm73Y9B3xoXTM5OsY+Cyhxhh78q8hUqq+cFK2a0qBJudwPT wR6vrpkC5x1Sc4aI+F/NMilxO27VG15e4k1SniFZewjT7gzOIadKWUphW3mPRPQsuNIE 9GSugVaHi+nGrEq0TkXEMMB2ZIFwDy8ZKw+ofYbLK6haSb99kKvIJpTR12jFbqB5gFkw b/n3AJKKpPkVnwixW+dOtI57sr80DTUSYikyX+NumQ3vEuwzbFi/fSrKp5IkiXltB2ZE 63tw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lj6si1050086ejb.108.2020.06.10.18.39.37; Wed, 10 Jun 2020 18:40:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726377AbgFKBhY (ORCPT + 99 others); Wed, 10 Jun 2020 21:37:24 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36624 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgFKBhX (ORCPT ); Wed, 10 Jun 2020 21:37:23 -0400 Received: by mail-pg1-f195.google.com with SMTP id t7so1811080pgt.3; Wed, 10 Jun 2020 18:37:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=JvLFQ/Pp9kYuh584xFsBL9APcPBK2H+2UekyjU/1FqE=; b=WcJD95bSa1R7aRxUWz+AwIO5g52jUnW5HDjS3Uy7odYA+boSggBQnkSxLeKnhKrt7Z R3VFM0JgRBhCd9cpcl+90yhcC2bsJ3pqsrQNQwPjBqyAVdYqo710XBOMMxv3FLMl28JE MoUCODTomejVnk26ajQ1BhDV9fLMxmmT4mW4Z/IRBfa/3djlU1ZbszCWEvnpSVZc9da7 Vqkci/ZtVZyl/5RUYbMAhwU6zdPrX54v0+waN0mvp17MfxHtGi42Ax00G0VgDdHvC42Z SnHWRq0G7BV2ahzcxl6eB3+SV13Um+chtgPck8xScq5mYgV9NrjSowFeU5zktHGshreL PhcA== X-Gm-Message-State: AOAM530Rvku4516IJc1ah7mFnEUq19uaJR1y1D2m8RdPbMyqSXwyAPyC ocVPXXFnF86IDEx9JpKzCgA= X-Received: by 2002:a62:5ac5:: with SMTP id o188mr5242642pfb.37.1591839441335; Wed, 10 Jun 2020 18:37:21 -0700 (PDT) Received: from [192.168.50.147] (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id cm13sm891721pjb.5.2020.06.10.18.37.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Jun 2020 18:37:20 -0700 (PDT) Subject: Re: [RFC PATCH 5/5] scsi: ufs: Prepare HPB read for cached sub-region To: daejun7.park@samsung.com, ALIM AKHTAR , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "asutoshd@codeaurora.org" , "beanhuo@micron.com" , "stanley.chu@mediatek.com" , "cang@codeaurora.org" , "tomas.winkler@intel.com" Cc: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Sang-yoon Oh , Sung-Jun Park , yongmyung lee , Jinyoung CHOI , Adel Choi , BoRam Shin References: <963815509.21591323002276.JavaMail.epsvc@epcpadp1> <231786897.01591322101492.JavaMail.epsvc@epcpadp1> <336371513.41591320902369.JavaMail.epsvc@epcpadp1> <963815509.21591320301642.JavaMail.epsvc@epcpadp1> <231786897.01591320001492.JavaMail.epsvc@epcpadp1> <336371513.41591323603173.JavaMail.epsvc@epcpadp1> From: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oB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7AFvvPjUPknS6d+BETMhTkbGzoyS+sywEsQAgA+BMCxBH4LvUmHYhpS+W6CiZ3ZMxjO8Hgc ++w1mLeRUvda3i4/U8wDT3SWuHcB3DWlcppECLkAEQEAAYkBHwQYAQIACQUCVI67igIbDAAK CRBxXD01xc4QCZ4dB/0QrnEasxjM0PGeXK5hcZMT9Eo998alUfn5XU0RQDYdwp6/kMEXMdmT oH0F0xB3SQ8WVSXA9rrc4EBvZruWQ+5/zjVrhhfUAx12CzL4oQ9Ro2k45daYaonKTANYG22y //x8dLe2Fv1By4SKGhmzwH87uXxbTJAUxiWIi1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: Date: Wed, 10 Jun 2020 18:37:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <336371513.41591323603173.JavaMail.epsvc@epcpadp1> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-04 19:12, Daejun Park wrote: > +static inline bool ufshpb_is_read_cmd(struct scsi_cmnd *cmd) > +{ > + if (cmd->cmnd[0] == READ_10 || cmd->cmnd[0] == READ_16) > + return true; > + > + return false; > +} Has it been considered to check req_op(cmd->request) instead of checking the SCSI CDB? > +static inline bool ufshpb_is_write_discard_cmd(struct scsi_cmnd *cmd) > +{ > + if (cmd->cmnd[0] == WRITE_10 || cmd->cmnd[0] == WRITE_16 || > + cmd->cmnd[0] == UNMAP) > + return true; > + > + return false; > +} Does the above code depend on how the sd driver translates write and discard requests? Do UFS devices support the WRITE SAME SCSI command? Has it been considered to check req_op(cmd->request) instead of checking the SCSI CDB? > +static inline bool ufshpb_is_support_chunk(int transfer_len) > +{ > + return transfer_len <= HPB_MULTI_CHUNK_HIGH; > +} The names used in the above function are mysterious. What is a support chunk? What does "multi chunk high" mean? Please add a comment. > +static inline u32 ufshpb_get_lpn(struct scsi_cmnd *cmnd) > +{ > + return blk_rq_pos(cmnd->request) >> > + (ilog2(cmnd->device->sector_size) - 9); > +} > > +static inline unsigned int ufshpb_get_len(struct scsi_cmnd *cmnd) > +{ > + return blk_rq_sectors(cmnd->request) >> > + (ilog2(cmnd->device->sector_size) - 9); > +} Do the above two functions perhaps each include a duplicate of sectors_to_logical()? > +/* routine : READ10 -> HPB_READ */ > +static void ufshpb_prep_fn(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) > +{ > + struct ufshpb_lu *hpb; > + struct ufshpb_region *rgn; > + struct ufshpb_subregion *srgn; > + struct scsi_cmnd *cmd = lrbp->cmd; > + u32 lpn; > + u64 ppn; > + unsigned long flags; > + int transfer_len, rgn_idx, srgn_idx, srgn_offset; > + int err = 0; > + > + hpb = ufshpb_get_hpb_data(cmd); > + err = ufshpb_lu_get(hpb); > + if (unlikely(err)) > + return; > + > + WARN_ON(hpb->lun != cmd->device->lun); ^^^^^^^ WARN_ON_ONCE()? > + if (!ufshpb_is_write_discard_cmd(cmd) && > + !ufshpb_is_read_cmd(cmd)) > + goto put_hpb; > + > + transfer_len = ufshpb_get_len(cmd); > + if (unlikely(!transfer_len)) > + goto put_hpb; > + > + lpn = ufshpb_get_lpn(cmd); > + ufshpb_get_pos_from_lpn(hpb, lpn, &rgn_idx, &srgn_idx, &srgn_offset); > + rgn = hpb->rgn_tbl + rgn_idx; > + srgn = rgn->srgn_tbl + srgn_idx; > + > + /* If commnad type is WRITE and DISCARD, set bitmap as drity */ ^^^^^^^ ^^^ ^^^^^ command? or? dirty? > + if (ufshpb_is_write_discard_cmd(cmd)) { > + spin_lock_irqsave(&hpb->hpb_state_lock, flags); > + ufshpb_set_ppn_dirty(hpb, rgn_idx, srgn_idx, srgn_offset, > + transfer_len); > + spin_unlock_irqrestore(&hpb->hpb_state_lock, flags); > + goto put_hpb; > + } > + > + WARN_ON(!ufshpb_is_read_cmd(cmd)); ^^^^^^^ WARN_ON_ONCE()? > + if (!ufshpb_is_support_chunk(transfer_len)) > + goto put_hpb; > + > + spin_lock_irqsave(&hpb->hpb_state_lock, flags); > + if (ufshpb_test_ppn_dirty(hpb, rgn_idx, srgn_idx, srgn_offset, > + transfer_len)) { > + atomic_inc(&hpb->stats.miss_cnt); > + spin_unlock_irqrestore(&hpb->hpb_state_lock, flags); > + goto put_hpb; > + } > + > + ppn = ufshpb_get_ppn(hpb, srgn->mctx, srgn_offset, &err); > + spin_unlock_irqrestore(&hpb->hpb_state_lock, flags); > + if (unlikely(err)) { > + /* > + * In this case, the region state is active, > + * but the ppn table is not allocated. > + * Make sure that ppn tabie must be allocated on ^^^^^ table? > + * active state > + */ > + WARN_ON(true); > + dev_err(&hpb->hpb_lu_dev, > + "ufshpb_get_ppn failed. err %d\n", err); > + goto put_hpb; > + } > + > + ufshpb_set_hpb_read_to_upiu(hpb, lrbp, lpn, ppn, transfer_len); > + > + atomic_inc(&hpb->stats.hit_cnt); > +put_hpb: > + ufshpb_lu_put(hpb); > +} Thanks, Bart.