[PATCH 4/4] nvme-pci: implement host memory buffer support

Max Gurtovoy maxg at mellanox.com
Thu Jun 1 02:19:13 PDT 2017



On 6/1/2017 10:18 AM, Christoph Hellwig wrote:
>>> +static void nvme_setup_host_mem(struct nvme_dev *dev)
>>> +{
>>> +	u64 max = (u64)max_host_mem_size_mb * 1024 * 1024;
>>> +	u64 preferred = (u64)dev->ctrl.hmpre * 4096;
>>> +	u64 min = (u64)dev->ctrl.hmmin * 4096;
>>> +	u32 enable_bits = NVME_HOST_MEM_ENABLE;
>>> +
>>> +	preferred = min(preferred, max);
>>> +	if (min > max) {
>>
>> Should it be:
>> if (min > preferred) ?
>
> No.  max is the maxium value the kernel allows a device to take.
> If the minimum required value is bigger than that we have to
> fail, it has nothing to do with the preferred value.
>

Ok, I probably got confused here because the "preferred = min(preferred, 
max);" statement was just before the "if" clause.


>>> +		dev_warn(dev->ctrl.device,
>>> +			"min host memory (%lld MiB) above limit (%d MiB).\n",
>>> +			preferred / 1024 / 1024, max_host_mem_size_mb);
>>
>> here we can:
>> preferred ==> min
>> max_host_mem_size_mb ==> preferred / 1024 / 1024 ?
>>
>> other option is change the warning print from "preferred" to "min" since
>> we assume that dev->ctrl.hmpre >= dev->ctrl.hmmin.
>
> The first one should indeed be min, but I think that's the only change
> we need.
>

Sure.




More information about the Linux-nvme mailing list