Skip to content

Commit c720c09

Browse files
scsi: ufs: sysfs: geometry descriptor
This patch introduces a sysfs group entry for the UFS geometry descriptor parameters. The group adds "geometry_descriptor" folder under the UFS driver sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The parameters are shown as hexadecimal numbers. The full information about the parameters could be found at UFS specifications 2.1. Signed-off-by: Stanislav Nijnikov <stanislav.nijnikov@wdc.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 8c2582b commit c720c09

File tree

3 files changed

+293
-0
lines changed

3 files changed

+293
-0
lines changed

Documentation/ABI/testing/sysfs-driver-ufs

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,176 @@ Description: This file shows the MIPI M-PHY version number in BCD format.
240240
The full information about the descriptor could be found at
241241
UFS specifications 2.1.
242242
The file is read only.
243+
244+
245+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/raw_device_capacity
246+
Date: February 2018
247+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
248+
Description: This file shows the total memory quantity available to
249+
the user to configure the device logical units. This is one
250+
of the UFS geometry descriptor parameters. The full
251+
information about the descriptor could be found at
252+
UFS specifications 2.1.
253+
The file is read only.
254+
255+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_number_of_luns
256+
Date: February 2018
257+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
258+
Description: This file shows the maximum number of logical units
259+
supported by the UFS device. This is one of the UFS
260+
geometry descriptor parameters. The full information about
261+
the descriptor could be found at UFS specifications 2.1.
262+
The file is read only.
263+
264+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/segment_size
265+
Date: February 2018
266+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
267+
Description: This file shows the segment size. This is one of the UFS
268+
geometry descriptor parameters. The full information about
269+
the descriptor could be found at UFS specifications 2.1.
270+
The file is read only.
271+
272+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/allocation_unit_size
273+
Date: February 2018
274+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
275+
Description: This file shows the allocation unit size. This is one of
276+
the UFS geometry descriptor parameters. The full information
277+
about the descriptor could be found at UFS specifications 2.1.
278+
The file is read only.
279+
280+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/min_addressable_block_size
281+
Date: February 2018
282+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
283+
Description: This file shows the minimum addressable block size. This
284+
is one of the UFS geometry descriptor parameters. The full
285+
information about the descriptor could be found at UFS
286+
specifications 2.1.
287+
The file is read only.
288+
289+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/optimal_read_block_size
290+
Date: February 2018
291+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
292+
Description: This file shows the optimal read block size. This is one
293+
of the UFS geometry descriptor parameters. The full
294+
information about the descriptor could be found at UFS
295+
specifications 2.1.
296+
The file is read only.
297+
298+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/optimal_write_block_size
299+
Date: February 2018
300+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
301+
Description: This file shows the optimal write block size. This is one
302+
of the UFS geometry descriptor parameters. The full
303+
information about the descriptor could be found at UFS
304+
specifications 2.1.
305+
The file is read only.
306+
307+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_in_buffer_size
308+
Date: February 2018
309+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
310+
Description: This file shows the maximum data-in buffer size. This
311+
is one of the UFS geometry descriptor parameters. The full
312+
information about the descriptor could be found at UFS
313+
specifications 2.1.
314+
The file is read only.
315+
316+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_out_buffer_size
317+
Date: February 2018
318+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
319+
Description: This file shows the maximum data-out buffer size. This
320+
is one of the UFS geometry descriptor parameters. The full
321+
information about the descriptor could be found at UFS
322+
specifications 2.1.
323+
The file is read only.
324+
325+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/rpmb_rw_size
326+
Date: February 2018
327+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
328+
Description: This file shows the maximum number of RPMB frames allowed
329+
in Security Protocol In/Out. This is one of the UFS geometry
330+
descriptor parameters. The full information about the
331+
descriptor could be found at UFS specifications 2.1.
332+
The file is read only.
333+
334+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/dyn_capacity_resource_policy
335+
Date: February 2018
336+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
337+
Description: This file shows the dynamic capacity resource policy. This
338+
is one of the UFS geometry descriptor parameters. The full
339+
information about the descriptor could be found at
340+
UFS specifications 2.1.
341+
The file is read only.
342+
343+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/data_ordering
344+
Date: February 2018
345+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
346+
Description: This file shows support for out-of-order data transfer.
347+
This is one of the UFS geometry descriptor parameters.
348+
The full information about the descriptor could be found at
349+
UFS specifications 2.1.
350+
The file is read only.
351+
352+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_number_of_contexts
353+
Date: February 2018
354+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
355+
Description: This file shows maximum available number of contexts which
356+
are supported by the device. This is one of the UFS geometry
357+
descriptor parameters. The full information about the
358+
descriptor could be found at UFS specifications 2.1.
359+
The file is read only.
360+
361+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/sys_data_tag_unit_size
362+
Date: February 2018
363+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
364+
Description: This file shows system data tag unit size. This is one of
365+
the UFS geometry descriptor parameters. The full information
366+
about the descriptor could be found at UFS specifications 2.1.
367+
The file is read only.
368+
369+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/sys_data_tag_resource_size
370+
Date: February 2018
371+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
372+
Description: This file shows maximum storage area size allocated by
373+
the device to handle system data by the tagging mechanism.
374+
This is one of the UFS geometry descriptor parameters.
375+
The full information about the descriptor could be found at
376+
UFS specifications 2.1.
377+
The file is read only.
378+
379+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/secure_removal_types
380+
Date: February 2018
381+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
382+
Description: This file shows supported secure removal types. This is
383+
one of the UFS geometry descriptor parameters. The full
384+
information about the descriptor could be found at
385+
UFS specifications 2.1.
386+
The file is read only.
387+
388+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/memory_types
389+
Date: February 2018
390+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
391+
Description: This file shows supported memory types. This is one of
392+
the UFS geometry descriptor parameters. The full
393+
information about the descriptor could be found at
394+
UFS specifications 2.1.
395+
The file is read only.
396+
397+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/*_memory_max_alloc_units
398+
Date: February 2018
399+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
400+
Description: This file shows the maximum number of allocation units for
401+
different memory types (system code, non persistent,
402+
enhanced type 1-4). This is one of the UFS geometry
403+
descriptor parameters. The full information about the
404+
descriptor could be found at UFS specifications 2.1.
405+
The file is read only.
406+
407+
What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/*_memory_capacity_adjustment_factor
408+
Date: February 2018
409+
Contact: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
410+
Description: This file shows the memory capacity adjustment factor for
411+
different memory types (system code, non persistent,
412+
enhanced type 1-4). This is one of the UFS geometry
413+
descriptor parameters. The full information about the
414+
descriptor could be found at UFS specifications 2.1.
415+
The file is read only.

drivers/scsi/ufs/ufs-sysfs.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,94 @@ static const struct attribute_group ufs_sysfs_interconnect_descriptor_group = {
266266
.attrs = ufs_sysfs_interconnect_descriptor,
267267
};
268268

269+
#define UFS_GEOMETRY_DESC_PARAM(_name, _uname, _size) \
270+
UFS_DESC_PARAM(_name, _uname, GEOMETRY, _size)
271+
272+
UFS_GEOMETRY_DESC_PARAM(raw_device_capacity, _DEV_CAP, 8);
273+
UFS_GEOMETRY_DESC_PARAM(max_number_of_luns, _MAX_NUM_LUN, 1);
274+
UFS_GEOMETRY_DESC_PARAM(segment_size, _SEG_SIZE, 4);
275+
UFS_GEOMETRY_DESC_PARAM(allocation_unit_size, _ALLOC_UNIT_SIZE, 1);
276+
UFS_GEOMETRY_DESC_PARAM(min_addressable_block_size, _MIN_BLK_SIZE, 1);
277+
UFS_GEOMETRY_DESC_PARAM(optimal_read_block_size, _OPT_RD_BLK_SIZE, 1);
278+
UFS_GEOMETRY_DESC_PARAM(optimal_write_block_size, _OPT_WR_BLK_SIZE, 1);
279+
UFS_GEOMETRY_DESC_PARAM(max_in_buffer_size, _MAX_IN_BUF_SIZE, 1);
280+
UFS_GEOMETRY_DESC_PARAM(max_out_buffer_size, _MAX_OUT_BUF_SIZE, 1);
281+
UFS_GEOMETRY_DESC_PARAM(rpmb_rw_size, _RPMB_RW_SIZE, 1);
282+
UFS_GEOMETRY_DESC_PARAM(dyn_capacity_resource_policy, _DYN_CAP_RSRC_PLC, 1);
283+
UFS_GEOMETRY_DESC_PARAM(data_ordering, _DATA_ORDER, 1);
284+
UFS_GEOMETRY_DESC_PARAM(max_number_of_contexts, _MAX_NUM_CTX, 1);
285+
UFS_GEOMETRY_DESC_PARAM(sys_data_tag_unit_size, _TAG_UNIT_SIZE, 1);
286+
UFS_GEOMETRY_DESC_PARAM(sys_data_tag_resource_size, _TAG_RSRC_SIZE, 1);
287+
UFS_GEOMETRY_DESC_PARAM(secure_removal_types, _SEC_RM_TYPES, 1);
288+
UFS_GEOMETRY_DESC_PARAM(memory_types, _MEM_TYPES, 2);
289+
UFS_GEOMETRY_DESC_PARAM(sys_code_memory_max_alloc_units,
290+
_SCM_MAX_NUM_UNITS, 4);
291+
UFS_GEOMETRY_DESC_PARAM(sys_code_memory_capacity_adjustment_factor,
292+
_SCM_CAP_ADJ_FCTR, 2);
293+
UFS_GEOMETRY_DESC_PARAM(non_persist_memory_max_alloc_units,
294+
_NPM_MAX_NUM_UNITS, 4);
295+
UFS_GEOMETRY_DESC_PARAM(non_persist_memory_capacity_adjustment_factor,
296+
_NPM_CAP_ADJ_FCTR, 2);
297+
UFS_GEOMETRY_DESC_PARAM(enh1_memory_max_alloc_units,
298+
_ENM1_MAX_NUM_UNITS, 4);
299+
UFS_GEOMETRY_DESC_PARAM(enh1_memory_capacity_adjustment_factor,
300+
_ENM1_CAP_ADJ_FCTR, 2);
301+
UFS_GEOMETRY_DESC_PARAM(enh2_memory_max_alloc_units,
302+
_ENM2_MAX_NUM_UNITS, 4);
303+
UFS_GEOMETRY_DESC_PARAM(enh2_memory_capacity_adjustment_factor,
304+
_ENM2_CAP_ADJ_FCTR, 2);
305+
UFS_GEOMETRY_DESC_PARAM(enh3_memory_max_alloc_units,
306+
_ENM3_MAX_NUM_UNITS, 4);
307+
UFS_GEOMETRY_DESC_PARAM(enh3_memory_capacity_adjustment_factor,
308+
_ENM3_CAP_ADJ_FCTR, 2);
309+
UFS_GEOMETRY_DESC_PARAM(enh4_memory_max_alloc_units,
310+
_ENM4_MAX_NUM_UNITS, 4);
311+
UFS_GEOMETRY_DESC_PARAM(enh4_memory_capacity_adjustment_factor,
312+
_ENM4_CAP_ADJ_FCTR, 2);
313+
314+
static struct attribute *ufs_sysfs_geometry_descriptor[] = {
315+
&dev_attr_raw_device_capacity.attr,
316+
&dev_attr_max_number_of_luns.attr,
317+
&dev_attr_segment_size.attr,
318+
&dev_attr_allocation_unit_size.attr,
319+
&dev_attr_min_addressable_block_size.attr,
320+
&dev_attr_optimal_read_block_size.attr,
321+
&dev_attr_optimal_write_block_size.attr,
322+
&dev_attr_max_in_buffer_size.attr,
323+
&dev_attr_max_out_buffer_size.attr,
324+
&dev_attr_rpmb_rw_size.attr,
325+
&dev_attr_dyn_capacity_resource_policy.attr,
326+
&dev_attr_data_ordering.attr,
327+
&dev_attr_max_number_of_contexts.attr,
328+
&dev_attr_sys_data_tag_unit_size.attr,
329+
&dev_attr_sys_data_tag_resource_size.attr,
330+
&dev_attr_secure_removal_types.attr,
331+
&dev_attr_memory_types.attr,
332+
&dev_attr_sys_code_memory_max_alloc_units.attr,
333+
&dev_attr_sys_code_memory_capacity_adjustment_factor.attr,
334+
&dev_attr_non_persist_memory_max_alloc_units.attr,
335+
&dev_attr_non_persist_memory_capacity_adjustment_factor.attr,
336+
&dev_attr_enh1_memory_max_alloc_units.attr,
337+
&dev_attr_enh1_memory_capacity_adjustment_factor.attr,
338+
&dev_attr_enh2_memory_max_alloc_units.attr,
339+
&dev_attr_enh2_memory_capacity_adjustment_factor.attr,
340+
&dev_attr_enh3_memory_max_alloc_units.attr,
341+
&dev_attr_enh3_memory_capacity_adjustment_factor.attr,
342+
&dev_attr_enh4_memory_max_alloc_units.attr,
343+
&dev_attr_enh4_memory_capacity_adjustment_factor.attr,
344+
NULL,
345+
};
346+
347+
static const struct attribute_group ufs_sysfs_geometry_descriptor_group = {
348+
.name = "geometry_descriptor",
349+
.attrs = ufs_sysfs_geometry_descriptor,
350+
};
351+
269352
static const struct attribute_group *ufs_sysfs_groups[] = {
270353
&ufs_sysfs_default_group,
271354
&ufs_sysfs_device_descriptor_group,
272355
&ufs_sysfs_interconnect_descriptor_group,
356+
&ufs_sysfs_geometry_descriptor_group,
273357
NULL,
274358
};
275359

drivers/scsi/ufs/ufs.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,42 @@ enum interconnect_desc_param {
238238
INTERCONNECT_DESC_PARAM_MPHY_VER = 0x4,
239239
};
240240

241+
/* Geometry descriptor parameters offsets in bytes*/
242+
enum geometry_desc_param {
243+
GEOMETRY_DESC_PARAM_LEN = 0x0,
244+
GEOMETRY_DESC_PARAM_TYPE = 0x1,
245+
GEOMETRY_DESC_PARAM_DEV_CAP = 0x4,
246+
GEOMETRY_DESC_PARAM_MAX_NUM_LUN = 0xC,
247+
GEOMETRY_DESC_PARAM_SEG_SIZE = 0xD,
248+
GEOMETRY_DESC_PARAM_ALLOC_UNIT_SIZE = 0x11,
249+
GEOMETRY_DESC_PARAM_MIN_BLK_SIZE = 0x12,
250+
GEOMETRY_DESC_PARAM_OPT_RD_BLK_SIZE = 0x13,
251+
GEOMETRY_DESC_PARAM_OPT_WR_BLK_SIZE = 0x14,
252+
GEOMETRY_DESC_PARAM_MAX_IN_BUF_SIZE = 0x15,
253+
GEOMETRY_DESC_PARAM_MAX_OUT_BUF_SIZE = 0x16,
254+
GEOMETRY_DESC_PARAM_RPMB_RW_SIZE = 0x17,
255+
GEOMETRY_DESC_PARAM_DYN_CAP_RSRC_PLC = 0x18,
256+
GEOMETRY_DESC_PARAM_DATA_ORDER = 0x19,
257+
GEOMETRY_DESC_PARAM_MAX_NUM_CTX = 0x1A,
258+
GEOMETRY_DESC_PARAM_TAG_UNIT_SIZE = 0x1B,
259+
GEOMETRY_DESC_PARAM_TAG_RSRC_SIZE = 0x1C,
260+
GEOMETRY_DESC_PARAM_SEC_RM_TYPES = 0x1D,
261+
GEOMETRY_DESC_PARAM_MEM_TYPES = 0x1E,
262+
GEOMETRY_DESC_PARAM_SCM_MAX_NUM_UNITS = 0x20,
263+
GEOMETRY_DESC_PARAM_SCM_CAP_ADJ_FCTR = 0x24,
264+
GEOMETRY_DESC_PARAM_NPM_MAX_NUM_UNITS = 0x26,
265+
GEOMETRY_DESC_PARAM_NPM_CAP_ADJ_FCTR = 0x2A,
266+
GEOMETRY_DESC_PARAM_ENM1_MAX_NUM_UNITS = 0x2C,
267+
GEOMETRY_DESC_PARAM_ENM1_CAP_ADJ_FCTR = 0x30,
268+
GEOMETRY_DESC_PARAM_ENM2_MAX_NUM_UNITS = 0x32,
269+
GEOMETRY_DESC_PARAM_ENM2_CAP_ADJ_FCTR = 0x36,
270+
GEOMETRY_DESC_PARAM_ENM3_MAX_NUM_UNITS = 0x38,
271+
GEOMETRY_DESC_PARAM_ENM3_CAP_ADJ_FCTR = 0x3C,
272+
GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS = 0x3E,
273+
GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR = 0x42,
274+
GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE = 0x44,
275+
};
276+
241277
/*
242278
* Logical Unit Write Protect
243279
* 00h: LU not write protected

0 commit comments

Comments
 (0)