All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Kleiner <mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
Cc: "nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] Take shift in crtc positions for ZaphodHeads configs into account.
Date: Sun, 15 Nov 2015 08:41:58 +0100	[thread overview]
Message-ID: <56483746.5000106@gmail.com> (raw)
In-Reply-To: <CAKb7UvgWqo7HH+-fuO+FTSqrusotFcMoCG6Juc2J5ObM9QRpYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Ping? Could we merge this patch? Nobody seems to have objections, it 
works since months on my test machines and an identical patch got 
reviewed and merged into xf86-video-modesetting, where it works without 
trouble, so it should be safe to apply.

thanks,
-mario

On 08/06/2015 07:34 PM, Ilia Mirkin wrote:
> I don't understand this patch (what are all these masks? how are they
> used?), and don't want to invest the time required to do so.
>
> However Mario is probably the sole serious user of ZaphodHeads, and if
> it fixes issues for him, probably fixes issues for others who try and
> give up with ZaphodHeads. Any objections if I just push this out?
>
> On Sat, Jun 27, 2015 at 8:33 PM, Mario Kleiner
> <mario.kleiner.de@gmail.com> wrote:
>> In multi-x-screen ZaphodHeads configurations, there isn't a
>> one-to-one mapping of kernel provided drmmode crtc index
>> to the index of the corresponding xf86Crtc inside the
>> xf86CrtcConfig crtc array anymore, ie. for kernel provided
>> drmmode->mode_res->crtcs[i], the i'th crtc won't correspond
>> to the xf86Crtc in the i'th slot of the x-screens xf86CrtcConfig
>> anymore, once ZaphodHeads has only selected a subset of all crtcs
>> of a graphics card for a given x-screen, instead of all crtcs.
>>
>> This breaks the mapping of bit positions in the bit masks returned
>> in kencoder->possible_crtcs and kencoder->possible_clones. A 1 bit
>> in position i of those masks allows use of the kernels i'th crtc for
>> the given kencoder. The X-Servers dix code checks those bit masks
>> for valid xf86Output -> xf86Crtc assignments, assuming that the i'th
>> slot xf86CrtcConfigPtr config->crtc[i] corresponds to bit i in the
>> xf86Output->possibe_crtcs bitmask, and bails if the bitmask doesn't
>> allow the specified assignment of crtc to output. If ZaphodHeads
>> breaks the assumption of bit i <-> crtc slot i this ends in failure.
>>
>> Take this shift of crtc index positions wrt. encoder bitmask bit
>> positions into account by bit-shifting positions accordingly when
>> assigning encoder->possible_crtcs to output->possible_crtcs, so
>> the proper indices match up again for validation by the dix.
>>
>> This problem wasn't apparent last year when testing the ZaphodHeads
>> support on some Kepler cards, as apparently the encoder->possible_crtcs
>> bitmasks returned for those cards by the kernel just had all 4
>> lsb bits set for all tested encoders/output, so each of the cards 4
>> crtcs could go with each output and things worked by chance.
>>
>> The current code breaks, e.g., on 2010 MacBookPro with nv50, where
>> one crtc is hardwired to the internal lvds panel, and one crtc
>> is hardwired to the external DP connector, resulting in a failure
>> where dual-display on single-x-screen works fine, but assigning
>> each output to a separate x-screen via ZaphodHeads fails due to
>> the mismatched encoder->possible_crtcs bitmasks.
>>
>> This patch fixes the problem.
>>
>> Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
>> ---
>>   src/drmmode_display.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
>> index c30cb3a..3679482 100644
>> --- a/src/drmmode_display.c
>> +++ b/src/drmmode_display.c
>> @@ -1214,7 +1214,7 @@ drmmode_zaphod_match(ScrnInfoPtr pScrn, const char *s, char *output_name)
>>   }
>>
>>   static unsigned int
>> -drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
>> +drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int crtcshift)
>>   {
>>          NVPtr pNv = NVPTR(pScrn);
>>          xf86OutputPtr output;
>> @@ -1296,8 +1296,8 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
>>          output->subpixel_order = subpixel_conv_table[koutput->subpixel];
>>          output->driver_private = drmmode_output;
>>
>> -       output->possible_crtcs = kencoder->possible_crtcs;
>> -       output->possible_clones = kencoder->possible_clones;
>> +       output->possible_crtcs = kencoder->possible_crtcs >> crtcshift;
>> +       output->possible_clones = kencoder->possible_clones >> crtcshift;
>>
>>          output->interlaceAllowed = true;
>>          output->doubleScanAllowed = true;
>> @@ -1421,6 +1421,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
>>          NVEntPtr pNVEnt = NVEntPriv(pScrn);
>>          int i;
>>          unsigned int crtcs_needed = 0;
>> +       int crtcshift;
>>
>>          drmmode = xnfalloc(sizeof *drmmode);
>>          drmmode->fd = fd;
>> @@ -1444,8 +1445,9 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
>>          }
>>
>>          xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing outputs ...\n");
>> +       crtcshift = ffs(pNVEnt->assigned_crtcs ^ 0xffffffff) - 1;
>
> Mario, any objections if I touch this up as
>
> ~pNVEnc->assigned_crtcs? XOR with ~0 is not a pattern I've seen a lot.
>
>>          for (i = 0; i < drmmode->mode_res->count_connectors; i++)
>> -               crtcs_needed += drmmode_output_init(pScrn, drmmode, i);
>> +               crtcs_needed += drmmode_output_init(pScrn, drmmode, i, crtcshift);
>>
>>          xf86DrvMsg(pScrn->scrnIndex, X_INFO,
>>                     "%d crtcs needed for screen.\n", crtcs_needed);
>> --
>> 1.9.1
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

      parent reply	other threads:[~2015-11-15  7:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28  0:33 [PATCH] Take shift in crtc positions for ZaphodHeads configs into account Mario Kleiner
     [not found] ` <1435451629-17959-1-git-send-email-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-06 17:34   ` Ilia Mirkin
     [not found]     ` <CAKb7UvgWqo7HH+-fuO+FTSqrusotFcMoCG6Juc2J5ObM9QRpYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-06 18:44       ` Mario Kleiner
2015-11-15  7:41       ` Mario Kleiner [this message]

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=56483746.5000106@gmail.com \
    --to=mario.kleiner.de-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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.