mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	Christoph Hellwig <hch@lst.de>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] dma-mapping: don't return errors from dma_set_seg_boundary
Date: Thu, 1 Aug 2024 13:36:01 +0100	[thread overview]
Message-ID: <d54f486d-36ae-4668-b314-27137bc4d832@arm.com> (raw)
In-Reply-To: <5895603b-945f-4b05-991c-76b590094354@samsung.com>

On 01/08/2024 1:00 pm, Marek Szyprowski wrote:
> On 23.07.2024 02:05, Christoph Hellwig wrote:
>> If dev->dma_parms is not allocate that indicates a grave bug in the
>> implementation of a DMA-capable bus.  There isn't much the driver can
>> do in terms of error handling, so just warn and continue as DMA
>> operations will fail anyway.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> What about devices on platform or usb bus and subsystems calling this
> unconditionally, like scsi_init_limits()? With today's linux-next I got
> a bunch of warnings from this call for various USB storage devices.
> Before this patch, the errors from dma_set_seg_boundary() were silently
> ignored.

Maybe we could suppress the warning if the value being set is equal to 
the default, but the real point is that DMA-capable buses should be 
providing dma_parms, while non-DMA-capable devices have no business 
being here at all - if the caller isn't going to get the 
restriction/relaxation they requested, and that's not a problem, then 
why are they requesting it in the first place?

I guess I assumed that the old block layer bodges in this area had been 
cleaned up already - perhaps it *is* high time for whatever's left to 
grow a proper understanding of whether a block device actually does its 
own DMA or not.

Thanks,
Robin.

>> ---
>>    include/linux/dma-mapping.h | 10 ++++------
>>    1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
>> index cfd6bafec3f944..6bd1333dbacb9b 100644
>> --- a/include/linux/dma-mapping.h
>> +++ b/include/linux/dma-mapping.h
>> @@ -559,13 +559,11 @@ static inline unsigned long dma_get_seg_boundary_nr_pages(struct device *dev,
>>    	return (dma_get_seg_boundary(dev) >> page_shift) + 1;
>>    }
>>    
>> -static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
>> +static inline void dma_set_seg_boundary(struct device *dev, unsigned long mask)
>>    {
>> -	if (dev->dma_parms) {
>> -		dev->dma_parms->segment_boundary_mask = mask;
>> -		return 0;
>> -	}
>> -	return -EIO;
>> +	if (WARN_ON_ONCE(!dev->dma_parms))
>> +		return;
>> +	dev->dma_parms->segment_boundary_mask = mask;
>>    }
>>    
>>    static inline unsigned int dma_get_min_align_mask(struct device *dev)
> 
> Best regards

  reply	other threads:[~2024-08-01 12:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23  0:05 remove the dma_set_{max_seg_size,seg_boundary,min_align_mask} return value Christoph Hellwig
2024-07-23  0:05 ` [PATCH 1/3] dma-mapping: don't return errors from dma_set_min_align_mask Christoph Hellwig
2024-07-23  0:05 ` [PATCH 2/3] dma-mapping: don't return errors from dma_set_seg_boundary Christoph Hellwig
2024-08-01 12:00   ` Marek Szyprowski
2024-08-01 12:36     ` Robin Murphy [this message]
2024-08-01 13:33       ` Christoph Hellwig
2024-08-02 11:53         ` Robin Murphy
2024-07-23  0:05 ` [PATCH 3/3] dma-mapping: don't return errors from dma_set_max_seg_size Christoph Hellwig
2024-07-30 13:13 ` remove the dma_set_{max_seg_size,seg_boundary,min_align_mask} return value Robin Murphy
2024-07-30 15:20   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d54f486d-36ae-4668-b314-27137bc4d832@arm.com \
    --to=robin.murphy@arm.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®