RE: [PATCH v32 4/4] scsi: ufs: Add HPB 2.0 support

2021-04-20 Thread Avri Altman
> Hi, > > if (dev_info->wspecversion >= UFS_DEV_HPB_SUPPORT_VERSION && > > (b_ufs_feature_sup & UFS_DEV_HPB_SUPPORT)) { > > - dev_info->hpb_enabled = true; > > + bool hpb_en = false; > > + > > ufshpb_get_dev_info(hba, desc_buf); > > +

[PATCH v4 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written

2021-04-20 Thread Avri Altman
The cache function can be turned ON and OFF by writing to the CACHE_CTRL byte (EXT_CSD byte [33]). However, card->ext_csd.cache_ctrl is only set on init if cache size > 0. Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write. Signed-off-by: Avri Altman Acked-by: Adrian

[PATCH v4 1/2] mmc: block: Issue flush only if allowed

2021-04-20 Thread Avri Altman
so. fixes: 1e8e55b67030 (mmc: block: Add CQE support) Reported-by: Brendan Peter Tested-by: Brendan Peter Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 9 + drivers/mmc/core/mmc.c | 2 +- drivers/mmc/core/mmc_ops.h | 5 + 3 files changed, 15 insertions(+), 1

[PATCH v4 0/2] Do not flush cache when it is disabled

2021-04-20 Thread Avri Altman
an access to the main nonvolatile storage. The cache function can be turned ON and OFF. Once OFF, the host is not expected to issue a flush-cache command to the device. Avri Altman (2): mmc: block: Issue flush only if allowed mmc: block: Update ext_csd.cache_ctrl if it was written drivers

RE: [PATCH v3 1/2] mmc: block: Issue flush only if allowed

2021-04-20 Thread Avri Altman
> On 20/04/21 8:53 am, Avri Altman wrote: > > The cache may be flushed to the nonvolatile storage by writing to > > FLUSH_CACHE byte (EXT_CSD byte [32]). When in command queueing mode, > the > > cache may be flushed by issuing a CMDQ_TASK_ DEV_MGMT (CMD48) with a > >

[PATCH v3 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written

2021-04-19 Thread Avri Altman
The cache function can be turned ON and OFF by writing to the CACHE_CTRL byte (EXT_CSD byte [33]). However, card->ext_csd.cache_ctrl is only set on init if cache size > 0. Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write. Signed-off-by: Avri Altman --- drivers/mm

[PATCH v3 1/2] mmc: block: Issue flush only if allowed

2021-04-19 Thread Avri Altman
so. fixes: 1e8e55b67030 (mmc: block: Add CQE support) Reported-by: Brendan Peter Tested-by: Brendan Peter Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 7 +++ drivers/mmc/core/mmc.c | 2 +- drivers/mmc/core/mmc_ops.h | 5 + 3 files changed, 13 insertions(+), 1

[PATCH v3 0/2] Do not flush cache when it is disabled

2021-04-19 Thread Avri Altman
on can be turned ON and OFF. Once OFF, the host is not expected to issue a flush-cache command to the device. Avri Altman (2): mmc: block: Issue flush only if allowed mmc: block: Update ext_csd.cache_ctrl if it was written drivers/mmc/core/block.c | 19 +++ drivers/mmc/core

RE: [PATCH v2 1/2] mmc: block: Issue flush only if allowed

2021-04-19 Thread Avri Altman
> > On Sun, 18 Apr 2021 at 08:00, Avri Altman wrote: > > > > The cache may be flushed to the nonvolatile storage by writing to > > FLUSH_CACHE byte (EXT_CSD byte [32]). When in command queueing mode, > the > > cache may be flushed by issuing a CMDQ_TASK_ DEV_MG

RE: [PATCH v2 1/2] mmc: block: Issue flush only if allowed

2021-04-19 Thread Avri Altman
> > On Sun, 18 Apr 2021 at 08:00, Avri Altman wrote: > > > > The cache may be flushed to the nonvolatile storage by writing to > > FLUSH_CACHE byte (EXT_CSD byte [32]). When in command queueing mode, > the > > cache may be flushed by issuing a CMDQ_TASK_ DEV_MG

RE: [PATCH] mmc: core: Move eMMC cache flushing to a new bus_ops callback

2021-04-19 Thread Avri Altman
w. > > Signed-off-by: Ulf Hansson Reviewed-by: Avri Altman

RE: [PATCH v32 4/4] scsi: ufs: Add HPB 2.0 support

2021-04-19 Thread Avri Altman
Hi, > if (dev_info->wspecversion >= UFS_DEV_HPB_SUPPORT_VERSION && > (b_ufs_feature_sup & UFS_DEV_HPB_SUPPORT)) { > - dev_info->hpb_enabled = true; > + bool hpb_en = false; > + > ufshpb_get_dev_info(hba, desc_buf); > + > +

RE: [PATCH] scsi: ufs: Check for bkops in runtime suspend

2021-04-18 Thread Avri Altman
> On 18/04/21 10:21 am, Avri Altman wrote: > > The UFS driver allowed BKOPS and WB Flush operations to be completed on > > Runtime suspend. Adding the DeepSleep support, this is no longer true: > > the driver will ignore BKOPS and WB Flush states, and force a link

[PATCH] scsi: ufs: Check for bkops in runtime suspend

2021-04-18 Thread Avri Altman
suspend flow. fixes: fe1d4c2ebcae (scsi: ufs: Add DeepSleep feature) Suggested-by: Alex Lemberg Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 58d7f264c664

[PATCH v2 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written

2021-04-18 Thread Avri Altman
The cache function can be turned ON and OFF by writing to the CACHE_CTRL byte (EXT_CSD byte [33]). However, card->ext_csd.cache_ctrl is only set on init if cache size > 0. Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write. Signed-off-by: Avri Altman --- drivers/mm

[PATCH v2 1/2] mmc: block: Issue flush only if allowed

2021-04-18 Thread Avri Altman
so. fixes: 1e8e55b67030 (mmc: block: Add CQE support) Reported-by: Brendan Peter Tested-by: Brendan Peter Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 7 +++ drivers/mmc/core/mmc_ops.c | 4 +--- drivers/mmc/core/mmc_ops.h | 5 + 3 files changed, 13 insertions(+), 3

[PATCH v2 0/2] Do not flush cache when it is disabled

2021-04-18 Thread Avri Altman
ost is not expected to issue a flush-cache command to the device. Avri Altman (2): mmc: block: Issue flush only if allowed mmc: block: Update ext_csd.cache_ctrl if it was written drivers/mmc/core/block.c | 19 +++ drivers/mmc/core/mmc_ops.c | 4 +--- drivers/mmc/core/mmc_ops.h |

RE: [PATCH v32 4/4] scsi: ufs: Add HPB 2.0 support

2021-04-14 Thread Avri Altman
> From: Daejun Park > > @@ -1692,6 +2188,7 @@ static void ufshpb_hpb_lu_prepared(struct ufs_hba > *hba) > ufshpb_set_state(hpb, HPB_PRESENT); > if ((hpb->lu_pinned_end - hpb->lu_pinned_start) > 0) >

RE: [PATCH] mmc: add quirk to disable eMMC cache for Micron eMMC v5.0 cards

2021-04-13 Thread Avri Altman
Scott hi, Can you take a look at https://lore.kernel.org/lkml/20210322133645.4901-1-avri.alt...@wdc.com/ Is there a chance that it will work for you as well? Thanks, Avri > -Original Message- > From: Scott Branden > Sent: Tuesday, 13 April 2021 18:46 > To: Ulf Hansson ; Bean Huo

[PATCH v8 09/11] scsi: ufshpb: Limit the number of inflight map requests

2021-04-11 Thread Avri Altman
In host control mode the host is the originator of map requests. To not flood the device with map requests, use a simple throttling mechanism that limits the number of inflight map requests. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 11

[PATCH v8 08/11] scsi: ufshpb: Add "Cold" regions timer

2021-04-11 Thread Avri Altman
to the "to-be-inactivated" list, unless it is clean and did not exhaust its READ_TO_EXPIRIES - another parameter. All this does not apply to pinned regions. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 74 +-- driver

[PATCH v8 11/11] scsi: ufshpb: Make host mode parameters configurable

2021-04-11 Thread Avri Altman
We can make use of this commit, to elaborate some more of the host control mode logic, explaining what role play each and every variable. While at it, allow those parameters to be configurable. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- Documentation/ABI/testing/sysfs-driver-ufs

[PATCH v8 04/11] scsi: ufshpb: Add reads counter

2021-04-11 Thread Avri Altman
hose reads as a comparative score, to make various decisions. If during consecutive normalizations an active region has exhaust its reads - inactivate it. while at it, protect the {active,inactive}_count stats by adding them into the applicable handler. Signed-off-by: Avri Altman Reviewed-by: D

[PATCH v8 10/11] scsi: ufshpb: Add support for host control mode

2021-04-11 Thread Avri Altman
Support devices that report they are using host control mode. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 0f72ea3f5d71..3c4001486cf1 100644

[PATCH v8 07/11] scsi: ufshpb: Add hpb dev reset response

2021-04-11 Thread Avri Altman
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

[PATCH v8 02/11] scsi: ufshpb: Add host control mode support to rsp_upiu

2021-04-11 Thread Avri Altman
to update an active and clean subregion, it is better to follow those recommendation because otherwise the host has no other way to know that some internal relocation took place. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 34

[PATCH v8 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-11 Thread Avri Altman
In host mode, the host is expected to send HPB-WRITE-BUFFER with buffer-id = 0x1 when it inactivates a region. Use the map-requests pool as there is no point in assigning a designated cache for umap-requests. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c

[PATCH v8 03/11] scsi: ufshpb: Transform set_dirty to iterate_rgn

2021-04-11 Thread Avri Altman
Given a transfer length, set_dirty meticulously runs over all the entries, across subregions and regions if needed. Currently its only use is to mark dirty blocks, but soon HCM may profit from it as well, when managing its read counters. Signed-off-by: Avri Altman Reviewed-by: Daejun Park

[PATCH v8 05/11] scsi: ufshpb: Make eviction depends on region's reads

2021-04-11 Thread Avri Altman
In host mode, eviction is considered an extreme measure. verify that the entering region has enough reads, and the exiting region has much less reads. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 18 +- 1 file changed, 17 insertions(+), 1

[PATCH v8 00/11] Add Host control mode to HPB

2021-04-11 Thread Avri Altman
rameters, and utilize system-wide info to optimize HPB potential. This series is based on Samsung's V32 device-control HPB2.0 driver This version was tested on Galaxy S20, and Xiaomi Mi10 pro. Your meticulous review and testing is mostly welcome and appreciated. Thanks, Avri Avri Altman (11): sc

[PATCH v8 01/11] scsi: ufshpb: Cache HPB Control mode on init

2021-04-11 Thread Avri Altman
We will use it later, when we'll need to differentiate between device and host control modes. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshcd.h | 2 ++ drivers/scsi/ufs/ufshpb.c | 8 +--- drivers/scsi/ufs/ufshpb.h | 2 ++ 3 files changed, 9 insertions(+), 3

RE: [PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-09 Thread Avri Altman
> > >> On 2021-04-06 13:20, Avri Altman wrote: > > >> >> > -static void __ufshpb_evict_region(struct ufshpb_lu *hpb, > > >> >> > - struct ufshpb_region *rgn) > > >

RE: [PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-06 Thread Avri Altman
> >> > >> On 2021-04-06 13:20, Avri Altman wrote: > >> >> > -static void __ufshpb_evict_region(struct ufshpb_lu *hpb, > >> >> > - struct ufshpb_region *rgn) > >&g

RE: [PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-06 Thread Avri Altman
> > On 2021-04-06 13:20, Avri Altman wrote: > >> > -static void __ufshpb_evict_region(struct ufshpb_lu *hpb, > >> > - struct ufshpb_region *rgn) > >> > +static int __ufshpb_evict_region(struct ufshpb_lu *hpb, &g

RE: [PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-05 Thread Avri Altman
> > -static void __ufshpb_evict_region(struct ufshpb_lu *hpb, > > - struct ufshpb_region *rgn) > > +static int __ufshpb_evict_region(struct ufshpb_lu *hpb, > > + struct ufshpb_region *rgn) > > { > > struct victim_select_info

RE: [PATCH][next] scsi: ufs: Fix out-of-bounds warnings in ufshcd_exec_raw_upiu_cmd

2021-04-03 Thread Avri Altman
> > Also, this helps with the ongoing efforts to enable -Warray-bounds > and avoid confusing the compiler. > > Link: https://github.com/KSPP/linux/issues/109 > Reported-by: kernel test robot > Build-tested-by: kernel test robot > Link: > https://lore.kernel.org/lkml/

Re: [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written

2021-04-02 Thread Avri Altman
>> @@ -571,6 +571,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, >> struct mmc_blk_data *md, >> main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK; >> } >> >> +/* Make sure to update CACHE_CTRL in case it was changed */ > It might be worth noting that

Re: [PATCH 1/2] mmc: block: Issue flush only if allowed

2021-04-02 Thread Avri Altman
>> @@ -1473,6 +1473,9 @@ static int mmc_blk_cqe_issue_flush(struct mmc_queue >> *mq, struct request *req) >> struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req); >> struct mmc_request *mrq = mmc_blk_cqe_prep_dcmd(mqrq, req); >> >> +if (mmc_card_mmc(mq->card) &&

RE: [PATCH v4 1/2] scsi: ufs: Fix task management request completion timeout

2021-03-31 Thread Avri Altman
> ufshcd_tmc_handler() calls blk_mq_tagset_busy_iter(fn = > ufshcd_compl_tm()), > but since blk_mq_tagset_busy_iter() only iterates over all reserved tags > and requests which are not in IDLE state, ufshcd_compl_tm() never gets a > chance to run. Thus, TMR always ends up with completion timeout.

[PATCH v7 11/11] scsi: ufshpb: Make host mode parameters configurable

2021-03-31 Thread Avri Altman
We can make use of this commit, to elaborate some more of the host control mode logic, explaining what role play each and every variable. While at it, allow those parameters to be configurable. Signed-off-by: Avri Altman --- Documentation/ABI/testing/sysfs-driver-ufs | 84 +- drivers/scsi

[PATCH v7 10/11] scsi: ufshpb: Add support for host control mode

2021-03-31 Thread Avri Altman
Support devices that report they are using host control mode. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index c07da481ff4e..08066bb6da65 100644 --- a/drivers/scsi/ufs

[PATCH v7 09/11] scsi: ufshpb: Limit the number of inflight map requests

2021-03-31 Thread Avri Altman
In host control mode the host is the originator of map requests. To not flood the device with map requests, use a simple throttling mechanism that limits the number of inflight map requests. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 11 +++ drivers/scsi/ufs/ufshpb.h

[PATCH v7 05/11] scsi: ufshpb: Make eviction depends on region's reads

2021-03-31 Thread Avri Altman
In host mode, eviction is considered an extreme measure. verify that the entering region has enough reads, and the exiting region has much less reads. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git

[PATCH v7 08/11] scsi: ufshpb: Add "Cold" regions timer

2021-03-31 Thread Avri Altman
to the "to-be-inactivated" list, unless it is clean and did not exhaust its READ_TO_EXPIRIES - another parameter. All this does not apply to pinned regions. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 74 +-- drivers/scsi/ufs/ufshpb.h | 8

[PATCH v7 07/11] scsi: ufshpb: Add hpb dev reset response

2021-03-31 Thread Avri Altman
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 --- drivers/scsi/ufs/ufshpb.c | 32

[PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-03-31 Thread Avri Altman
In host mode, the host is expected to send HPB-WRITE-BUFFER with buffer-id = 0x1 when it inactivates a region. Use the map-requests pool as there is no point in assigning a designated cache for umap-requests. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 35

[PATCH v7 03/11] scsi: ufshpb: Transform set_dirty to iterate_rgn

2021-03-31 Thread Avri Altman
Given a transfer length, set_dirty meticulously runs over all the entries, across subregions and regions if needed. Currently its only use is to mark dirty blocks, but soon HCM may profit from it as well, when managing its read counters. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c

[PATCH v7 04/11] scsi: ufshpb: Add reads counter

2021-03-31 Thread Avri Altman
hose reads as a comparative score, to make various decisions. If during consecutive normalizations an active region has exhaust its reads - inactivate it. while at it, protect the {active,inactive}_count stats by adding them into the applicable handler. Signed-off-by: Avri Altman --- drivers/scsi/uf

[PATCH v7 02/11] scsi: ufshpb: Add host control mode support to rsp_upiu

2021-03-31 Thread Avri Altman
to update an active and clean subregion, it is better to follow those recommendation because otherwise the host has no other way to know that some internal relocation took place. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 34 +- drivers/scsi/ufs

[PATCH v7 01/11] scsi: ufshpb: Cache HPB Control mode on init

2021-03-31 Thread Avri Altman
We will use it later, when we'll need to differentiate between device and host control modes. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.h | 2 ++ drivers/scsi/ufs/ufshpb.c | 8 +--- drivers/scsi/ufs/ufshpb.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git

[PATCH v7 00/11] Add Host control mode to HPB

2021-03-31 Thread Avri Altman
ice-control HPB2.0 driver This version was tested on Galaxy S20, and Xiaomi Mi10 pro. Your meticulous review and testing is mostly welcome and appreciated. Thanks, Avri Avri Altman (11): scsi: ufshpb: Cache HPB Control mode on init scsi: ufshpb: Add host control mode support to rsp_u

RE: [PATCH 1/1] scsi: ufs: Remove duplicated header file inclusion

2021-03-28 Thread Avri Altman
> > The header file is already included above and can be > removed here. Already removed, see https://lore.kernel.org/lkml/20210306114706.217873-1-zhang.yun...@zte.com.cn/ Thanks, Avri > > Signed-off-by: Zhen Lei > --- > drivers/scsi/ufs/ufshcd.c | 1 - > 1 file changed, 1 deletion(-) > >

RE: [PATCH v6 03/10] scsi: ufshpb: Add region's reads counter

2021-03-27 Thread Avri Altman
> > > @@ -596,12 +615,43 @@ int ufshpb_prep(struct ufs_hba *hba, struct > > > ufshcd_lrb *lrbp) > > > ufshpb_set_ppn_dirty(hpb, rgn_idx, srgn_idx, srgn_offset, > > >transfer_len); > > > spin_unlock_irqrestore(>rgn_state_lock, flags); > >

RE: [PATCH v6 04/10] scsi: ufshpb: Make eviction depends on region's reads

2021-03-24 Thread Avri Altman
> > On 2021-03-22 16:10, Avri Altman wrote: > > In host mode, eviction is considered an extreme measure. > > verify that the entering region has enough reads, and the exiting > > region has much less reads. > > > > Signed-off-by: Avri Altman > &g

RE: [PATCH v6 02/10] scsi: ufshpb: Add host control mode support to rsp_upiu

2021-03-24 Thread Avri Altman
> >> @@ -1245,6 +1257,18 @@ static void > ufshpb_rsp_req_region_update(struct > >> ufshpb_lu *hpb, > >> srgn_i = > >> > >> be16_to_cpu(rsp_field->hpb_active_field[i].active_srgn); > >> > >> +rgn = hpb->rgn_tbl + rgn_i; > >> +if

RE: [PATCH v6 03/10] scsi: ufshpb: Add region's reads counter

2021-03-24 Thread Avri Altman
> > @@ -596,12 +615,43 @@ int ufshpb_prep(struct ufs_hba *hba, struct > > ufshcd_lrb *lrbp) > > ufshpb_set_ppn_dirty(hpb, rgn_idx, srgn_idx, srgn_offset, > >transfer_len); > > spin_unlock_irqrestore(>rgn_state_lock, flags); > > + > > +

RE: [PATCH v31 2/4] scsi: ufs: L2P map management for HPB read

2021-03-23 Thread Avri Altman
> > On 2021-03-23 14:37, Daejun Park wrote: > >> On 2021-03-23 14:19, Daejun Park wrote: > On 2021-03-23 13:37, Daejun Park wrote: > >> On 2021-03-23 12:22, Can Guo wrote: > >>> On 2021-03-22 17:11, Bean Huo wrote: > On Mon, 2021-03-22 at 15:54 +0900, Daejun Park wrote: >

[PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written

2021-03-22 Thread Avri Altman
The cache function can be turned ON and OFF by writing to the CACHE_CTRL byte (EXT_CSD byte [33]). However, card->ext_csd.cache_ctrl is only set on init if cache size > 0. Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write. Signed-off-by: Avri Altman --- drivers/mm

[PATCH 1/2] mmc: block: Issue flush only if allowed

2021-03-22 Thread Avri Altman
so. fixes: 1e8e55b67030 (mmc: block: Add CQE support) Reported-by: Brendan Peter Tested-by: Brendan Peter Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 3 +++ drivers/mmc/core/mmc_ops.c | 4 +--- drivers/mmc/core/mmc_ops.h | 5 + 3 files changed, 9 insertions(+), 3 deletions

[PATCH 0/2] Do not flush cache when it is disabled

2021-03-22 Thread Avri Altman
to the device. Avri Altman (2): mmc: block: Issue flush only if allowed mmc: block: Update ext_csd.cache_ctrl if it was written drivers/mmc/core/block.c | 11 +++ drivers/mmc/core/mmc_ops.c | 4 +--- drivers/mmc/core/mmc_ops.h | 5 + 3 files changed, 17 insertions(+), 3

[PATCH v6 10/10] scsi: ufshpb: Make host mode parameters configurable

2021-03-22 Thread Avri Altman
We can make use of this commit, to elaborate some more of the host control mode logic, explaining what role play each and every variable. While at it, allow those parameters to be configurable. Signed-off-by: Avri Altman --- Documentation/ABI/testing/sysfs-driver-ufs | 84 +- drivers/scsi

[PATCH v6 08/10] scsi: ufshpb: Limit the number of inflight map requests

2021-03-22 Thread Avri Altman
In host control mode the host is the originator of map requests. To not flood the device with map requests, use a simple throttling mechanism that limits the number of inflight map requests. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 11 +++ drivers/scsi/ufs/ufshpb.h

[PATCH v6 09/10] scsi: ufshpb: Add support for host control mode

2021-03-22 Thread Avri Altman
Support devices that report they are using host control mode. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index f755f5a7775c..51c527c6f8c2 100644 --- a/drivers/scsi/ufs

[PATCH v6 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-22 Thread Avri Altman
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 --- drivers/scsi/ufs/ufshpb.c | 32

[PATCH v6 07/10] scsi: ufshpb: Add "Cold" regions timer

2021-03-22 Thread Avri Altman
to the "to-be-inactivated" list, unless it is clean and did not exhaust its READ_TO_EXPIRIES - another parameter. All this does not apply to pinned regions. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 74 +-- drivers/scsi/ufs/ufshpb.h | 8

[PATCH v6 04/10] scsi: ufshpb: Make eviction depends on region's reads

2021-03-22 Thread Avri Altman
In host mode, eviction is considered an extreme measure. verify that the entering region has enough reads, and the exiting region has much less reads. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git

[PATCH v6 05/10] scsi: ufshpb: Region inactivation in host mode

2021-03-22 Thread Avri Altman
In host mode, the host is expected to send HPB-WRITE-BUFFER with buffer-id = 0x1 when it inactivates a region. Use the map-requests pool as there is no point in assigning a designated cache for umap-requests. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 35

[PATCH v6 03/10] scsi: ufshpb: Add region's reads counter

2021-03-22 Thread Avri Altman
hose reads as a comparative score, to make various decisions. If during consecutive normalizations an active region has exhaust its reads - inactivate it. while at it, protect the {active,inactive}_count stats by adding them into the applicable handler. Signed-off-by: Avri Altman --- drivers/scsi/uf

[PATCH v6 02/10] scsi: ufshpb: Add host control mode support to rsp_upiu

2021-03-22 Thread Avri Altman
to update an active and clean subregion, it is better to follow those recommendation because otherwise the host has no other way to know that some internal relocation took place. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshpb.c | 34 +- drivers/scsi/ufs

[PATCH v6 01/10] scsi: ufshpb: Cache HPB Control mode on init

2021-03-22 Thread Avri Altman
We will use it later, when we'll need to differentiate between device and host control modes. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.h | 2 ++ drivers/scsi/ufs/ufshpb.c | 8 +--- drivers/scsi/ufs/ufshpb.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git

[PATCH v6 00/10] Add Host control mode to HPB

2021-03-22 Thread Avri Altman
. This version was tested on Galaxy S20, and Xiaomi Mi10 pro. Your meticulous review and testing is mostly welcome and appreciated. Thanks, Avri Avri Altman (10): scsi: ufshpb: Cache HPB Control mode on init scsi: ufshpb: Add host control mode support to rsp_upiu scsi: ufshpb: Add region'

RE: [PATCH v29 4/4] scsi: ufs: Add HPB 2.0 support

2021-03-21 Thread Avri Altman
> +static int ufshpb_execute_umap_req(struct ufshpb_lu *hpb, > + struct ufshpb_req *umap_req, > + struct ufshpb_region *rgn) > +{ > + struct request *req; > + struct scsi_request *rq; > + > + req = umap_req->req;

RE: [PATCH v2] scsi: ufs: Tidy up WB configuration code

2021-03-18 Thread Avri Altman
> > -int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) > +static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn > idn) > { > - int ret; > u8 index; > enum query_opcode opcode; What I meant is: enum query_opcode opcode = set ?

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-18 Thread Avri Altman
> On 2021-03-17 23:46, Avri Altman wrote: > >> >> >> >> > >> >> >> >> Just curious, directly doing below things inside ufshpb_rsp_upiu() > >> >> >> >> does > >> >> >> >> not > &

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-17 Thread Avri Altman
> >> >> >> > >> >> >> Just curious, directly doing below things inside ufshpb_rsp_upiu() > >> >> >> does > >> >> >> not > >> >> >> seem a problem to me, does this really deserve a separate work? > >> >> > I don't know, I never even consider of doing this. > >> >> > The active region list may

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-17 Thread Avri Altman
> > On 2021-03-17 20:22, Avri Altman wrote: > >> > >> On 2021-03-17 19:23, Avri Altman wrote: > >> >> > >> >> On 2021-03-02 21:24, Avri Altman wrote: > >> >> > The spec does not define what is the host's recommended re

RE: [PATCH] scsi: ufs: Tidy up WB configuration code

2021-03-17 Thread Avri Altman
Signed-off-by: Yue Hu A small nit below, otherwise - looks good to me. Reviewed-by: Avri Altman > --- > drivers/scsi/ufs/ufs-sysfs.c | 2 +- > drivers/scsi/ufs/ufshcd.c| 99 > +++- > drivers/scsi/ufs/ufshcd.h| 2 +- > 3 files chan

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-17 Thread Avri Altman
> > On 2021-03-17 19:23, Avri Altman wrote: > >> > >> On 2021-03-02 21:24, Avri Altman wrote: > >> > The spec does not define what is the host's recommended response when > >> > the device send hpb dev reset response (oper 0x2). > >>

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-17 Thread Avri Altman
> > On 2021-03-02 21:24, Avri Altman wrote: > > 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 &

RE: [PATCH v5 03/10] scsi: ufshpb: Add region's reads counter

2021-03-17 Thread Avri Altman
> >> > @@ -1079,6 +1113,14 @@ static void __ufshpb_evict_region(struct > >> > ufshpb_lu *hpb, > >> > > >> > ufshpb_cleanup_lru_info(lru_info, rgn); > >> > > >> > + if (hpb->is_hcm) { > >> > + unsigned long flags; > >> > + > >> > + spin_lock_irqsave(>rgn_lock,

RE: [PATCH v5 05/10] scsi: ufshpb: Region inactivation in host mode

2021-03-17 Thread Avri Altman
> On 2021-03-17 10:28, Daejun Park wrote: > >>> >> --- > >>> >> drivers/scsi/ufs/ufshpb.c | 14 ++ > >>> >> drivers/scsi/ufs/ufshpb.h | 1 + > >>> >> 2 files changed, 15 insertions(+) > >>> >> > >>> >> diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c > >>> >> index

RE: [PATCH v5 07/10] scsi: ufshpb: Add "Cold" regions timer

2021-03-17 Thread Avri Altman
> On 2021-03-16 17:21, Avri Altman wrote: > >> > +static void ufshpb_read_to_handler(struct work_struct *work) > >> > +{ > >> > + struct delayed_work *dwork = to_delayed_work(work); > >> > + struct ufshpb_lu *hpb; > >> >

RE: [PATCH v5 07/10] scsi: ufshpb: Add "Cold" regions timer

2021-03-16 Thread Avri Altman
> > +static void ufshpb_read_to_handler(struct work_struct *work) > > +{ > > + struct delayed_work *dwork = to_delayed_work(work); > > + struct ufshpb_lu *hpb; > > + struct victim_select_info *lru_info; > > + struct ufshpb_region *rgn; > > + unsigned long flags; > > +

RE: [PATCH v5 04/10] scsi: ufshpb: Make eviction depends on region's reads

2021-03-16 Thread Avri Altman
> > int ret = 0; > > @@ -1263,6 +1271,16 @@ static int ufshpb_add_region(struct ufshpb_lu > > *hpb, struct ufshpb_region *rgn) > >* because the device could detect this region > >* by not issuing HPB_READ > >*/ > > + > >

RE: [PATCH v5 08/10] scsi: ufshpb: Limit the number of inflight map requests

2021-03-16 Thread Avri Altman
> > > On 2021-03-02 21:25, Avri Altman wrote: > > in host control mode the host is the originator of map requests. To not > > in -> In Done. > > Thanks, > Can Guo. > > > flood the device with map requests, use a simple throttling mechanism > >

RE: [PATCH v5 05/10] scsi: ufshpb: Region inactivation in host mode

2021-03-16 Thread Avri Altman
> >> --- > >> drivers/scsi/ufs/ufshpb.c | 14 ++ > >> drivers/scsi/ufs/ufshpb.h | 1 + > >> 2 files changed, 15 insertions(+) > >> > >> diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c > >> index 6f4fd22eaf2f..0744feb4d484 100644 > >> --- a/drivers/scsi/ufs/ufshpb.c

RE: [PATCH v5 03/10] scsi: ufshpb: Add region's reads counter

2021-03-15 Thread Avri Altman
> > + /* if region is active but has no reads - inactivate it */ > > + spin_lock(>rsp_list_lock); > > + ufshpb_update_inactive_info(hpb, rgn->rgn_idx); > > Miss a hpb->stats.rb_inactive_cnt++ here? Thanks. Also noticed that since rb_inactive_cnt and

RE: [PATCH v5 03/10] scsi: ufshpb: Add region's reads counter

2021-03-15 Thread Avri Altman
> > + > > + if (hpb->is_hcm) { > > + spin_lock_irqsave(>rgn_lock, flags); > > rgn_lock is never used in IRQ contexts, so no need of irqsave and > irqrestore everywhere, which can impact performance. Please correct > me if I am wrong. Thanks. Will do. > >

RE: [PATCH v5 07/10] scsi: ufshpb: Add "Cold" regions timer

2021-03-15 Thread Avri Altman
> > > > +static void ufshpb_read_to_handler(struct work_struct *work) > > +{ > > + struct delayed_work *dwork = to_delayed_work(work); > > + struct ufshpb_lu *hpb; > > struct ufshpb_lu *hpb = container_of(work, struct ufshpb_lu, > ufshpb_read_to_work.work); > > usually we use

RE: [PATCH v5 06/10] scsi: ufshpb: Add hpb dev reset response

2021-03-15 Thread Avri Altman
> > +static void ufshpb_reset_work_handler(struct work_struct *work) > > +{ > > + struct ufshpb_lu *hpb; > > struct ufshpb_lu *hpb = container_of(work, struct ufshpb_lu, > ufshpb_lun_reset_work); > > > + struct victim_select_info *lru_info; > > struct

RE: [RFC PATCH 0/5] RPMB internal and user-space API + WIP virtio-rpmb frontend

2021-03-11 Thread Avri Altman
> Avri Altman writes: > > > The mmc driver has some hooks to support rpmb access, but access is > > mainly facilitated from user space, e.g. mmc-utils. > > > > The ufs driver has no concept of rpmb access - it is facilitated via > > user space, e.g. ufs-uti

RE: [PATCH v5 05/10] scsi: ufshpb: Region inactivation in host mode

2021-03-11 Thread Avri Altman
> > On 2021-03-02 21:24, Avri Altman wrote: > > I host mode, the host is expected to send HPB-WRITE-BUFFER with > > In host mode, Done. > > static int ufshpb_issue_umap_all_req(struct ufshpb_lu *hpb) > > { > > return ufshpb_issue_umap_req(hpb, NULL

RE: [PATCH v5 04/10] scsi: ufshpb: Make eviction depends on region's reads

2021-03-11 Thread Avri Altman
> > diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c > > index a8f8d13af21a..6f4fd22eaf2f 100644 > > --- a/drivers/scsi/ufs/ufshpb.c > > +++ b/drivers/scsi/ufs/ufshpb.c > > @@ -17,6 +17,7 @@ > > #include "../sd.h" > > > > #define ACTIVATION_THRESHOLD 4 /* 4 IOs */ > > +#define

RE: [PATCH v5 03/10] scsi: ufshpb: Add region's reads counter

2021-03-11 Thread Avri Altman
> > diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c > > index 044fec9854a0..a8f8d13af21a 100644 > > --- a/drivers/scsi/ufs/ufshpb.c > > +++ b/drivers/scsi/ufs/ufshpb.c > > @@ -16,6 +16,8 @@ > > #include "ufshpb.h" > > #include "../sd.h" > > > > +#define ACTIVATION_THRESHOLD 4

RE: [PATCH v3 1/3] scsi: ufshcd: use a function to calculate versions

2021-03-10 Thread Avri Altman
> Hi Avri, > > On 10/03/2021 4:34 pm, Avri Altman wrote: > >> @@ -9298,10 +9291,7 @@ int ufshcd_init(struct ufs_hba *hba, void > __iomem > >> *mmio_base, unsigned int irq) > >> /* Get UFS version supported by the controller */ > >>

RE: [PATCH v3 1/3] scsi: ufshcd: use a function to calculate versions

2021-03-10 Thread Avri Altman
> @@ -9298,10 +9291,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem > *mmio_base, unsigned int irq) > /* Get UFS version supported by the controller */ > hba->ufs_version = ufshcd_get_ufs_version(hba); > > - if ((hba->ufs_version != UFSHCI_VERSION_10) && > -

[RFC PATCH 0/5] RPMB internal and user-space API + WIP virtio-rpmb frontend

2021-03-09 Thread Avri Altman
The mmc driver has some hooks to support rpmb access, but access is mainly facilitated from user space, e.g. mmc-utils. The ufs driver has no concept of rpmb access - it is facilitated via user space, e.g. ufs-utils and similar. Both for ufs and mmc, rpmb access is defined in their applicable

RE: [PATCH] scsi: ufs: fix error return code of ufshcd_populate_vreg()

2021-03-06 Thread Avri Altman
> > When np is NULL or of_parse_phandle() returns NULL, no error return code > of ufshcd_populate_vreg() is assigned. > To fix this bug, ret is assigned with -EINVAL or -ENOENT as error return > code. This changes the flow of ufshcd_parse_regulator_info so you need to: a) get a tested-by tag and

RE: [PATCH v2 1/3] scsi: ufs: Minor adjustments to error handling

2021-03-03 Thread Avri Altman
), since it may be > called multiple times during error recovery. > > Signed-off-by: Can Guo Reviewed-by: Avri Altman > --- > drivers/scsi/ufs/ufshcd.c | 18 -- > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/dr

RE: [PATCH v2 1/3] scsi: ufs: Minor adjustments to error handling

2021-03-03 Thread Avri Altman
> > > In error handling prepare stage, after SCSI requests are blocked, do a > down/up_write(clk_scaling_lock) to clean up the queuecommand() path. > Meanwhile, stop eeh_work in case it disturbs error recovery. Moreover, > reset ufshcd_state at the entrance of ufshcd_probe_hba(), since it may be

  1   2   3   4   5   6   >