Re: [PATCH v4] scsi: sas: skip opt_sectors when DMA reports no real optimization hint

From: Damien Le Moal

Date: Thu Mar 19 2026 - 07:07:16 EST


On 3/19/26 17:39, Ionut Nechita (Wind River) wrote:
> +static unsigned int sas_dma_opt_sectors(struct device *dma_dev,
> + unsigned int max_sectors)
> +{
> + size_t opt = dma_opt_mapping_size(dma_dev);
> + size_t max = dma_max_mapping_size(dma_dev);
> +
> + if (WARN_ONCE(opt > max,
> + "dma_opt_mapping_size (%zu) > dma_max_mapping_size (%zu)\n",
> + opt, max))
> + return 0;
> +
> + if (opt == max)
> + return 0;

Why return 0 ? This is a valid case, so this should get through the alignment below.

> +
> + opt = rounddown_pow_of_two(opt);
> +
> + return min_t(unsigned int, opt >> SECTOR_SHIFT, max_sectors);
> +}
> +


--
Damien Le Moal
Western Digital Research