mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-03-29 10:10:39 +02:00
Merge branch 'fix' into 'main'
modesetting: Add retry logic to drmSetMaster to fix race condition See merge request xorg/xserver!2142
This commit is contained in:
commit
ac7723e2e2
1 changed files with 21 additions and 6 deletions
|
|
@ -1959,7 +1959,7 @@ static Bool
|
|||
SetMaster(ScrnInfoPtr pScrn)
|
||||
{
|
||||
modesettingPtr ms = modesettingPTR(pScrn);
|
||||
int ret;
|
||||
int ret, retries = 5;
|
||||
|
||||
#ifdef XF86_PDEV_SERVER_FD
|
||||
if (ms->pEnt->location.type == BUS_PLATFORM &&
|
||||
|
|
@ -1970,12 +1970,27 @@ SetMaster(ScrnInfoPtr pScrn)
|
|||
if (ms->fd_passed)
|
||||
return TRUE;
|
||||
|
||||
ret = drmSetMaster(ms->fd);
|
||||
if (ret)
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "drmSetMaster failed: %s\n",
|
||||
strerror(errno));
|
||||
/* Retry drmSetMaster a few times to handle race conditions
|
||||
* where the DRM device is not yet fully initialized.
|
||||
* This can happen when Xorg starts immediately after the
|
||||
* kernel driver loads. */
|
||||
do {
|
||||
ret = drmSetMaster(ms->fd);
|
||||
if (ret == 0)
|
||||
return TRUE;
|
||||
|
||||
return ret == 0;
|
||||
if (retries > 0 && (errno == EACCES || errno == EBUSY)) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"drmSetMaster failed: %s, retrying...\n",
|
||||
strerror(errno));
|
||||
usleep(10000); /* 10ms */
|
||||
}
|
||||
} while (ret && retries-- > 0);
|
||||
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "drmSetMaster failed: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* When the root window is created, initialize the screen contents from
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue