All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 01/10] drivers/char: Add support for USB3 DbC debugger
Date: Fri, 5 Aug 2022 11:51:27 +0200	[thread overview]
Message-ID: <YuzoIAh+scGcDY1R@mail-itl> (raw)
In-Reply-To: <04256d0a-79a1-56f4-d092-de78f629c7f6@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]

On Fri, Aug 05, 2022 at 09:23:32AM +0200, Jan Beulich wrote:
> On 26.07.2022 05:23, Marek Marczykowski-Górecki wrote:
> > +static uint64_t dbc_work_ring_size(const struct dbc_work_ring *ring)
> > +{
> > +    if ( ring->enq >= ring->deq )
> > +        return ring->enq - ring->deq;
> > +
> > +    return DBC_WORK_RING_CAP - ring->deq + ring->enq;
> > +}
> 
> Doesn't unsigned int suffice as a return type here?

Yes, it does.

> > +static int64_t dbc_push_work(struct dbc *dbc, struct dbc_work_ring *ring,
> > +                             const char *buf, unsigned int len)
> > +{
> > +    unsigned int i = 0;
> > +    unsigned int end, start = ring->enq;
> > +
> > +    while ( !dbc_work_ring_full(ring) && i < len )
> > +    {
> > +        ring->buf[ring->enq] = buf[i++];
> > +        ring->enq = (ring->enq + 1) & (DBC_WORK_RING_CAP - 1);
> > +    }
> > +
> > +    end = ring->enq;
> > +
> > +    if ( end > start )
> > +        cache_flush(&ring->buf[start], end - start);
> > +    else if ( i > 0 )
> > +    {
> > +        cache_flush(&ring->buf[start], DBC_WORK_RING_CAP - start);
> > +        cache_flush(&ring->buf[0], end);
> > +    }
> > +
> > +    return i;
> > +}
> 
> The function's return type is int64_t but the sole return statement
> hands back an unsigned int - what's the deal here?

And also, the only use for the return value is comparing to 0. So, yes,
should be unsigned int.

> > +static struct xhci_trb evt_trb[DBC_TRB_RING_CAP];
> > +static struct xhci_trb out_trb[DBC_TRB_RING_CAP];
> > +static struct xhci_trb in_trb[DBC_TRB_RING_CAP];
> > +static struct xhci_erst_segment erst __aligned(64);
> > +static struct xhci_dbc_ctx ctx __aligned(64);
> > +static uint8_t out_wrk_buf[DBC_WORK_RING_CAP] __aligned(DBC_PAGE_SIZE);
> 
> I've been trying to identify the reason for the alignment here,
> compared to the other buffers which are no longer page-aligned. I
> haven't even been able to locate the place where the address of
> this buffer is actually written to hardware; all I could find was
> the respective virt_to_maddr(). Could you please point me at that?

It's dbc_flush() -> dbc_push_trb().
And indeed, I think I can drop the alignment when it's moved into
structure dedicated for DMA-accessible buffers.

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-08-05  9:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26  3:23 [PATCH v3 00/10] Add Xue - console over USB 3 Debug Capability Marek Marczykowski-Górecki
2022-07-26  3:19 ` [PATCH v3 01/10] drivers/char: Add support for USB3 DbC debugger Marek Marczykowski-Górecki
2022-07-26  3:23   ` Marek Marczykowski-Górecki
2022-08-04 12:57   ` Jan Beulich
2022-08-04 13:43     ` Marek Marczykowski-Górecki
2022-08-04 14:21       ` Jan Beulich
2022-08-04 14:28         ` Marek Marczykowski-Górecki
2022-08-04 14:36           ` Jan Beulich
2022-08-04 14:41             ` Marek Marczykowski-Górecki
2022-08-04 14:49               ` Jan Beulich
2022-08-04 14:34         ` Jan Beulich
2022-08-05  6:14           ` Jan Beulich
2022-08-05  7:23   ` Jan Beulich
2022-08-05  9:51     ` Marek Marczykowski-Górecki [this message]
2022-08-05  9:54       ` Jan Beulich
2022-08-05 10:01         ` Marek Marczykowski-Górecki
2022-07-26  3:23 ` [PATCH v3 02/10] drivers/char: reset XHCI ports when initializing dbc Marek Marczykowski-Górecki
2022-08-04 13:14   ` Jan Beulich
2022-07-26  3:23 ` [PATCH v3 03/10] drivers/char: add support for selecting specific xhci Marek Marczykowski-Górecki
2022-07-26  3:23 ` [PATCH v3 04/10] console: support multiple serial console simultaneously Marek Marczykowski-Górecki
2022-08-04 14:13   ` Jan Beulich
2022-08-05  7:41   ` Jan Beulich
2022-08-05 13:11     ` Marek Marczykowski-Górecki
2022-07-26  3:23 ` [PATCH v3 05/10] IOMMU: add common API for device reserved memory Marek Marczykowski-Górecki
2022-08-04 14:25   ` Jan Beulich
2022-08-04 14:38     ` Marek Marczykowski-Górecki
2022-08-04 14:41       ` Jan Beulich
2022-07-26  3:23 ` [PATCH v3 06/10] IOMMU/VT-d: wire common device reserved memory API Marek Marczykowski-Górecki
2022-07-26  3:23 ` [PATCH v3 07/10] IOMMU/AMD: " Marek Marczykowski-Górecki
2022-08-04 14:53   ` Jan Beulich
2022-07-26  3:23 ` [PATCH v3 08/10] drivers/char: mark DMA buffers as reserved for the XHCI Marek Marczykowski-Górecki
2022-08-05  7:05   ` Jan Beulich
2022-08-05 10:11     ` Marek Marczykowski-Górecki
2022-07-26  3:23 ` [PATCH v3 09/10] drivers/char: allow driving the rest of XHCI by a domain while Xen uses DbC Marek Marczykowski-Górecki
2022-08-05  8:15   ` Jan Beulich
2022-08-05 15:49     ` Marek Marczykowski-Górecki
2022-08-09  6:24       ` Jan Beulich
2022-07-26  3:23 ` [PATCH v3 10/10] driver/char: add RX support to the XHCI driver Marek Marczykowski-Górecki
2022-08-05  8:38   ` Jan Beulich
2022-08-05  9:58     ` Marek Marczykowski-Górecki
2022-08-05 12:38       ` Jan Beulich
2022-08-05 12:47         ` Marek Marczykowski-Górecki
2022-08-05 12:51           ` Jan Beulich
2022-07-26  6:18 ` [PATCH v3 00/10] Add Xue - console over USB 3 Debug Capability Jan Beulich
2022-07-26  9:26   ` Marek Marczykowski-Górecki

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=YuzoIAh+scGcDY1R@mail-itl \
    --to=marmarek@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.