linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Pierre Morel <pmorel@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Michael Mueller <mimu@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, bfu@redhat.com,
	Halil Pasic <pasic@linux.ibm.com>
Subject: Re: [RFC PATCH 1/1] s390/cio: make ccw_device_dma_* more robust
Date: Wed, 13 Oct 2021 00:37:14 +0200	[thread overview]
Message-ID: <20211013003714.1c411f0b.pasic@linux.ibm.com> (raw)
In-Reply-To: <87pmsawdvr.fsf@redhat.com>

On Tue, 12 Oct 2021 15:50:48 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> >> If I read cio_gp_dma_zalloc() correctly, we either get NULL or a valid
> >> address, so yes.
> >>   
> >
> > I don't think the extra care will hurt us too badly. I prefer to keep
> > the IS_ERR_OR_NULL() check because it needs less domain specific
> > knowledge to be understood, and because it is more robust.  
> 
> It feels weird, though -- I'd rather have a comment that tells me

This way the change feels simpler and safer to me. I believe I explained
the why above. But if you insist I can change it. I double checked the
cio_gp_dma_zalloc() code, and more or less the code called by it. So
now I don't feel uncomfortable with the simpler check.

On the other hand, I'm not very happy doing changes solely based on
somebody's feelings. It would feel much more comfortable with a reason
based discussion.

One reason to change this to a simple NULL check, is that the
IS_ERR_OR_NULL() check could upset the reader of the client code,
which only checks for NULL.

On the other hand I do believe we have some risk of lumping together
different errors here. E.g. dma_pool is NULL or dma ops are not set up
properly. Currently we would communicate that kind of a problem as
-ENOMEM, which wouldn't be a great match. But since dma_alloc_coherent()
returns either NULL or a valid pointer, and furthermore this looks like
a common thing in all the mm-api, I decided to be inline with that.

TLDR; If you insist, I will change this to a simple null pointer check.

> exactly what cio_gp_dma_zalloc() is supposed to return; I would have
> expected that a _zalloc function always gives me a valid pointer or
> NULL.

I don't think we have such a comment for dma_alloc_coherent() or even
kmalloc(). I agree, it would be nice to have this behavior documented
in the apidoc all over the place. But IMHO that is a different issue.

Regards,
Halil


  reply	other threads:[~2021-10-12 22:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 11:59 [RFC PATCH 1/1] s390/cio: make ccw_device_dma_* more robust Halil Pasic
2021-10-11 13:45 ` Pierre Morel
2021-10-11 14:33   ` Cornelia Huck
2021-10-11 18:48     ` Halil Pasic
2021-10-12 13:50       ` Cornelia Huck
2021-10-12 22:37         ` Halil Pasic [this message]
2021-10-13  6:51           ` Cornelia Huck
2021-10-12 14:10     ` Pierre Morel
2021-10-11 18:42   ` Halil Pasic
2021-10-12 13:36 ` Vineeth Vijayan
2021-10-12 21:32   ` Halil Pasic
2021-10-13  7:29     ` Vineeth Vijayan

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=20211013003714.1c411f0b.pasic@linux.ibm.com \
    --to=pasic@linux.ibm.com \
    --cc=bfu@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mimu@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pmorel@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=vneethv@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).