All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.ibm.com>
To: Konstantin Shkolnyy <kshk@linux.ibm.com>
Cc: alifm@linux.ibm.com, farman@linux.ibm.com,
	richard.henderson@linaro.org, iii@linux.ibm.com,
	david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com,
	borntraeger@linux.ibm.com, qemu-s390x@nongnu.org,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v11 14/16] s390x/pci: Factor ioat sanity checks into a separate function
Date: Mon, 5 Oct 2026 09:30:19 -0400	[thread overview]
Message-ID: <fc472877-5b10-4dc8-bde4-f149e4e3ddc7@linux.ibm.com> (raw)
In-Reply-To: <606b2a78-52b5-40a7-87cc-3f247985aa51@linux.ibm.com>

On 10/2/26 8:43 PM, Konstantin Shkolnyy wrote:
> On 261002 13:28, Matthew Rosato wrote:
>>
>>> -static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev,
>>> ZpciFib fib,
>>> -                    uintptr_t ra)
>>> +bool s390_pci_ioat_validate(S390PCIBusDevice *pbdev, uint64_t pba,
>>> +                             uint64_t pal, uint64_t g_iota, Error
>>> **errp)
>>>   {
>>> -    uint64_t pba = ldq_be_p(&fib.pba);
>>> -    uint64_t pal = ldq_be_p(&fib.pal);
>>> -    uint64_t g_iota = ldq_be_p(&fib.iota);
>>>       uint8_t dt = (g_iota >> 2) & 0x7;
>>>       bool t = s390_pci_is_translation_enabled(g_iota);
>>>   -    pba &= ~0xfff;
>>> -    pal |= 0xfff;
>>>       if (pba > pal || pba < pbdev->zpci_fn.sdma || pal > pbdev-
>>> >zpci_fn.edma) {
>>> -        s390_program_interrupt(env, PGM_OPERAND, ra);
>>> -        return -EINVAL;
>>> +        return false;
>>
>> This will now violate include/qapi/error.h because you're returning
>> false but not setting errp:
>>
>>   * - On success, the function should not touch *errp.  On failure, it
>>   *   should set a new error, e.g. with error_setg(errp, ...), or
>>   *   propagate an existing one, e.g. with error_propagate(errp, ...).
>>
>> A simple solution would be to add a new message for this case.
> 
> But the original reg_ioat() also didn't print any message in this error
> branch. I had to assume it was intentional, and preserved the behavior.
> 

Yes, but the original path was not passing an Error *errp back to a
caller, it was calling error_report (and then qemu_log_mask) directly;
your patch is changing this to a model where we return an Error *errp to
a caller.  Which in and of itself is totally fine, but we should make
efforts to then adhere to the rules laid out in include/qapi/error.h
where all failure paths should have an error when passing back an errp.

> If you believe a new message should be introduced, I can insert a commit
> for that - what would be the explanation?

Separate commit not needed, it only becomes necessary as part of this
change as described above.

As for a message, something like the following?

"ioat pba 0x%"PRIx64" pal 0x%"PRIx64" out of device dma range
[0x%"PRIx64" 0x%"PRIx64"]", pba, pal, pbdev->zpci_fn.sdma,
pbdev->zpci_fn.edma

> 
>>
>> [...]
>>> +
>>> +static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev,
>>> ZpciFib fib,
>>> +                    uintptr_t ra)
>>> +{
>>> +    Error *err = NULL;
>>> +    uint64_t pba = ldq_be_p(&fib.pba);
>>> +    uint64_t pal = ldq_be_p(&fib.pal);
>>> +    uint64_t g_iota = ldq_be_p(&fib.iota);
>>> +    bool t = s390_pci_is_translation_enabled(g_iota);
>>> +
>>> +    pba &= ~0xfff;
>>> +    pal |= 0xfff;
>>> +
>>> +    if (!s390_pci_ioat_validate(pbdev, pba, pal, g_iota, &err)) {
>>> +        if (err) {
>>> +            qemu_log_mask(LOG_GUEST_ERROR, "%s\n",
>>> error_get_pretty(err));
>>> +            error_free(err);
>>> +        }
>>
>> With that change, you won't need the if (err) check anymore.
>>
>> Thanks,
>> Matt
> 



  parent reply	other threads:[~2026-10-05 13:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:52 [PATCH v11 00/16] s390x/pci: Implement migration for emulated devices Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 01/16] s390x/pci: implement IOMMU replay Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 02/16] s390x/pci: Create function to contain translation status check Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 03/16] s390x/pci: Move iommu_mr from S390PCIIOMMU to S390PCIBusDevice Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 04/16] s390x/pci: Move dm_mr " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 05/16] s390x/pci: Move iotlb " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 06/16] s390x/pci: Remove a ptr to S390PCIBusDevice from S390PCIIOMMU Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 07/16] s390x/pci: Move/rename enabled from S390PCIIOMMU to S390PCIBusDevice Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 08/16] s390x/pci: Move dma_limit " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 09/16] s390x/pci: Move g_iota " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 10/16] s390x/pci: Move pba " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 11/16] s390x/pci: Move pal " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 12/16] s390x/pci: Move max_dma_limit " Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 13/16] s390x/pci: Add a comment explaining S390PCIIOMMU purpose Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 14/16] s390x/pci: Factor ioat sanity checks into a separate function Konstantin Shkolnyy
2026-10-02 18:28   ` Matthew Rosato
2026-10-03  0:43     ` Konstantin Shkolnyy
2026-10-05 13:23       ` Konstantin Shkolnyy
2026-10-05 13:46         ` Matthew Rosato
2026-10-05 16:20           ` Konstantin Shkolnyy
2026-10-05 13:30       ` Matthew Rosato [this message]
2026-09-30 14:52 ` [PATCH v11 15/16] s390x/pci: Implement migration for emulated devices Konstantin Shkolnyy
2026-10-05 19:39   ` Matthew Rosato
2026-10-05 22:20   ` Farhan Ali
2026-10-05 22:31     ` Konstantin Shkolnyy
2026-09-30 14:52 ` [PATCH v11 16/16] s390x/pci: Create function to contain fmb_timer start Konstantin Shkolnyy

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=fc472877-5b10-4dc8-bde4-f149e4e3ddc7@linux.ibm.com \
    --to=mjrosato@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@kernel.org \
    --cc=farman@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=kshk@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.