MAXPHYS bump for FreeBSD 13

Scott Long scottl at samsco.org
Sun Nov 15 17:33:31 UTC 2020



> On Nov 15, 2020, at 10:27 AM, Alexander Motin <mav at FreeBSD.org> wrote:
> 
> On 15.11.2020 12:11, Scott Long wrote:
>> The MAXPHYS use for AHCI is related to the maximum size of a PRD needed
>> for a command.  AHCI specifies that you can have up to 65536 PRD entries,
>> which translates into 2^16 + 2^12 = 256MB maximum I/O size.  However, the
>> AHCI driver seems inconsistent already in that it defines AHCI_PRD_MAX 
>> (via an indirection through AHCI_PRD_MASK) to be 2^22, or 4MB.  This is
>> a pretty reasonable max default for AHCI, and I don’t think we need to jump
>> through hoops to make it dynamic or make it larger for the future.  My
>> recommendation is to abandon the partial changes you have for AHCI and
>> use AHCI_PRD_MAX in place of MAXPHYS for the structure sizing and for
>> the cpi->maxio attribute.
> 
> Scott, AHCI_PRD_MAX is a maximum size of single DMA segment.  It does
> not limit number of segments, which allows up to 256MB maximum I/O as
> you have said.  I am already looking on making number of of PRDs
> dynamic.  It does not look difficult.  Though generally yes, the memory
> difference is not big, simply because SATA has maximal queue depth of
> only 32 commands.  For SAS/FC/NVMe/... it is more interesting.
> 

Sorry, you’re right, I got it backwards when I read the arguments to bus_dma.
Still, 4MB is a pretty reasonable maximum for AHCI, and keeping it static would
avoid extra complexity in the code.

Scott



More information about the freebsd-arch mailing list