天天看點

UFS深入淺出 第二章 UFS結構 第三節 UFS分區

作者:Flash4U

Section 3 UFS partition

第三節 UFS分區

UFS深入淺出 第二章 UFS結構 第三節 UFS分區

UFS partition concept is similar to that in eMMC. However, it is not exactly the same. In eMMC, the whole user area could be used immediately after initialization. If there are some dedicated purposes to store specific data, some area called General Purpose Partition (aka GPP) could be separated from user space with its own address memory space assigned. GPP number is up to 4 per eMMC specification. Besides that, there are two boots partition and one RPMB partition in eMMC when shipped out from factory. Either GPP, or Boot/RPMB need dedicated Switch Command CMD6 for accessing to their own independent memory space areas.

UFS分區的概念和eMMC相似。但是,又不完全一樣。eMMC裡面的整個使用者區域可以在初始化之後立即使用。如果有特定的目的去存儲一些專門的資料,那麼可以從使用者區域裡面的分出一些配置設定了自己獨立尋址空間的區域,稱為通用目的區(也叫GPP)。根據eMMC的規範,GPP的數目最多是4個。除此之外出廠的時候在eMMC裡還有兩個boot分區以及一個RPMB分區。eMMC裡不論是GPP,或者是Boot、RPMB,都需要特定的切換指令CMD6來通路它們自己的獨立的尋址空間。

UFS partitions do not work that way. In UFS, partitions have a unique name Logical Unit (aka LU). Except one RPMB logical unit, no other Logical Units are assigned by default in UFS from factory,including boot partition. UFS memory space could not be accessed unless it has been separated into pieces with independent memory space and index assigned. Each piece is so called one Logical Unit, short as LU. The process of memory space allocation for each LU is called provisioning.

UFS的分區工作方式不太一樣。在UFS裡,分區有一個獨特的名字邏輯單元(也叫LU)。除了一個RPMB之外,在UFS裡包括boot分區在内,沒有其他邏輯分區在出廠的時候就預設配置設定好的。UFS的存儲空間在分成帶有獨立尋址空間和序列号的小塊之前,是不能被通路的。每一個小塊也就是一個邏輯單元,簡寫成LU。配置設定存儲空間給每個LU的過程叫做配置(provisioning)。

The job that provisioning does is actually to create a scattered mapping table of memory space LBA for all LU. There are two types of provisioning defined by UFS specification, Full Provisioning and Thin Provisioning. Full Provisioning gives a 1:1 mapping for all physical memory with its corresponding LBA to LU. While Thin provisioning only assigned all LBAs to LUs. Compared to Full Provisioning, Thin provisioning is more flexible to use physical Flash memory so to reducing NAND overhead blocks and save cost. This is also the reason UFS command UNMAP, which is to delete Logical to Physical Address entry to free the dirty data blocks, is only supported in Thin Provisioning as Full Provisioning need to keep those dirty data blocks unless extra physical Flash blocks that are out of UFS exported capacity are provided to replace them. Nowadays, all UFS vendors has no doubt to choose Thin provisioning.

Provisioning的工作實際上是為所有的LU建立一個分散的存儲空間LBA的映射表。UFS規範定義了兩種Provisioning模式,完全的Full Provisioning以及廋Thin Provisioning。Full Provisioning給出了所有實體存儲以及對應的LBA相對于LU的1:1對應關系。而Thin Provisioning隻需要配置設定所有的LBA個LU。和Full Provisioning相比較,Thin Provisioning可以更加靈活的使用實體閃存,進而減少額外的NAND存儲塊以及減少成本。這也是為什麼UFS的UNMAP指令隻支援Thin Provisioning方式,UNMAP指令是通過删除邏輯實體位址映射入口來釋放髒資料塊。因為Full Provision除非有輸出容量之外的額外的實體閃存塊來替換那些髒資料塊,否則就得一直留着它們。今日,所有的UFS廠商都毫無意外的選擇Thin Provisioning。

The index assigned is the number of the LU. Hence Logical Unit Number (aka LUN) is used in UFS protocol to address the specific LU. Generally, there are up to 32 LU in UFS, however the real number could be much less than that based on the real storage usage design.

配置設定給LU的索引是數字号碼,是以邏輯單元号(也叫LUN)就被用在UFS協定裡面作為定位特定的LU。一般來說,UFS最多有32個LU,然而實際的數目根據實際存儲使用的設計可能遠小于這個數字。

UFS also inherit the concept of Well-Known Logical Unit (aka W-LU) from SCSI. There are total 4 W-LU in UFS, Device and Report LUN are two W-LU which have the same definition as that in SCSI, while Boot and RPMB are two W-LU which are newly added to implement and comply with eMMC feature. Each W-LU get its fixed number called Well-known Logical Unit Number (aka W-LUN). The fixed number is the reason that these 4 W-LU are well known. Here we only need to remember that 0xB0 is for Boot and 0xC4 is for RPMB.

UFS還內建了源自于SCSI的概念,衆所周知的邏輯單元(也叫 W-LU)。UFS裡一共有4個W-LU,Device和Report LUN是和SCSI定義一樣的概念的W-LU。而Boot和RPMB是新加入的為了實作以及于eMMC特性保持一緻的W-LU。每一個W-LU有固定的衆所周知的邏輯單元碼, 也就是衆所周知的邏輯單元碼(也叫W-LUN)。這些固定的數字碼也是為什麼這四個W-LU衆所周知的原因。這裡我們隻需要記住Boot是0xB0以及RPMB是0xC4。

Boot W-LU density is part of the exported capacity of UFS, and size could be assigned up to 64MB each. This is not like eMMC. In eMMC, two boot partitions density is not counted in the exported capacity and usually is fixed for each, like 4MB. This feature gives UFS more flexibility to fit increasing demand of OS boot size requirement. Another notice for Boot W-LUs is, although it has fixed W-LUN 0xB4, it cannot be accessed until it is linked to a certain LU during the provisioning process by setting the UFS register Descriptor. RPMB W-LU is originated and does not have this limitation, W-LUN is 0xC4, which could be accessed directly. The detail will be covered in the UFS register chapter.

Boot W-LU的容量是包含在UFS的輸出容量裡的,大小可最大配置設定到64MB。這個和eMMC不一樣,在eMMC裡,兩個Boot分區的容量是不算在輸出容量裡的,而且大小通常是固定的,比如說4MB。這個特性也給了UFS更多的靈活性來适應作業系統對于Boot分區尺寸逐漸增加的需求。另外一個Boot W-LU需要注意的點是,雖然它有固定的W-LUN 0xB0,但是在通過UFS寄存器設定做Provisioning把它連結到某個LU之前,它是不能通路的。 RPMB W-LU是原生的,沒有這個限制,W-LUN是0xC4,直接就可以通路。具體的細節我們會在UFS寄存器的章節裡講。

繼續閱讀