On 10/06/2025 07.06, Christoph Hellwig wrote: > Move the average segment size into a separate helper, and return a > tristate to distinguish the case where can use SGL vs where we have to > use SGLs. This will allow the simplify the code and make more efficient > decisions in follow on changes. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > --- > drivers/nvme/host/pci.c | 41 +++++++++++++++++++++++++++-------------- > 1 file changed, 27 insertions(+), 14 deletions(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 449a9950b46c..0b85c11d3c96 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c ... > @@ -886,7 +897,9 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, > goto out_free_sg; > } > > - if (nvme_pci_use_sgls(dev, req, iod->sgt.nents)) > + if (use_sgl == SGL_FORCED || > + (use_sgl == SGL_SUPPORTED && FORCED implies SUPPORTED, what about simplifying to: if (use_sgl >= SGL_SUPPORTED) or just do: if (use_sgl)