From patchwork Mon Feb 10 17:58:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF6EBC0219E for ; Mon, 10 Feb 2025 17:58:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49FD610E37D; Mon, 10 Feb 2025 17:58:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="lP7pjWRL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4500710E377 for ; Mon, 10 Feb 2025 17:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210322; x=1770746322; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=UWJhwlEt7s0lbvuhdvvsN9FO7NkPoN8T32onlxnbizY=; b=lP7pjWRLE2YklIGSzZx3VxPnf5CCW5ZhNzY6jW3xt5F7NBKgd2BCM8Kj P0alO0r6OMOJ8T591Nmx/kgqpajZy6R8v9zokP75+SyGWHbWhQJoAh1nU sxFe8iHDbFe/qbRcKCKbHlrpOfGm7/oFqqX28O8YUu1sU8lh0x7R0KYxk HgobpWRcfLEc1JFe9zZGpDS/ZPFg7gUDdG4v9xuBHJlj6s1FjjIwwIp+Y vaWYN61RixxE/fybDrK15EnAOm540mAQ7IT3UDAuEzIGRguYBJYxyRb42 oDkOCoyolCL+PdS9pSwoXLiq5mW/VfhXKFGH55Hxa0jmiGCiTn2NcVTwz g==; X-CSE-ConnectionGUID: kfpq5e9JR/Wju4Qw5GENwA== X-CSE-MsgGUID: kyCgNvtrSPCtXI8fFsxeRA== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39002990" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39002990" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:42 -0800 X-CSE-ConnectionGUID: clZXK/XrTBuM1r+XEox9Gg== X-CSE-MsgGUID: nz1+ADzPSzOC0GNs7X+ptQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480685" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:40 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:39 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 1/7] Fix transposed calloc() arguments Date: Mon, 10 Feb 2025 19:58:30 +0200 Message-ID: <20250210175836.30984-2-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä gcc-14 complains: ../src/legacy/i810/i810_dri.c:281:48: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] ... Fix them all up via cocci: @@ expression E1, E2; type T; @@ ( - calloc(sizeof(T), E2) + calloc(E2, sizeof(T)) | - calloc(sizeof(E1), E2) + calloc(E2, sizeof(E1)) ) Signed-off-by: Ville Syrjälä --- src/legacy/i810/i810_dri.c | 2 +- src/legacy/i810/i810_driver.c | 2 +- src/sna/sna_display.c | 4 ++-- src/sna/sna_glyphs.c | 4 ++-- src/uxa/intel_display.c | 8 ++++---- src/uxa/intel_present.c | 2 +- src/uxa/uxa-glyphs.c | 2 +- src/uxa/uxa.c | 2 +- test/basic-copyarea.c | 3 ++- test/basic-fillrect.c | 3 ++- test/basic-putimage.c | 3 ++- test/render-composite-solid.c | 3 ++- test/render-copy-alphaless.c | 3 ++- test/render-copyarea.c | 3 ++- test/render-fill-copy.c | 3 ++- test/render-fill.c | 3 ++- test/render-trapezoid-image.c | 3 ++- test/render-trapezoid.c | 3 ++- 18 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/legacy/i810/i810_dri.c b/src/legacy/i810/i810_dri.c index cca35d663b35..6c747f483ac6 100644 --- a/src/legacy/i810/i810_dri.c +++ b/src/legacy/i810/i810_dri.c @@ -278,7 +278,7 @@ I810DRIScreenInit(ScreenPtr pScreen) } pDRIInfo->SAREASize = SAREA_MAX; - if (!(pI810DRI = (I810DRIPtr) calloc(sizeof(I810DRIRec), 1))) { + if (!(pI810DRI = (I810DRIPtr) calloc(1, sizeof(I810DRIRec)))) { DRIDestroyInfoRec(pI810->pDRIInfo); pI810->pDRIInfo = NULL; return FALSE; diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c index 778b1a415274..c0de514e6a7c 100644 --- a/src/legacy/i810/i810_driver.c +++ b/src/legacy/i810/i810_driver.c @@ -1544,7 +1544,7 @@ I810ScreenInit(SCREEN_INIT_ARGS_DECL) pI810 = I810PTR(scrn); hwp = VGAHWPTR(scrn); - pI810->LpRing = calloc(sizeof(I810RingBuffer),1); + pI810->LpRing = calloc(1, sizeof(I810RingBuffer)); if (!pI810->LpRing) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Could not allocate lpring data structure.\n"); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index d4fa7b0bc759..e4a26ac53437 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3793,7 +3793,7 @@ sna_crtc_add(ScrnInfoPtr scrn, unsigned id, int index) DBG(("%s(%d): is-zaphod? %d\n", __FUNCTION__, id, is_zaphod(scrn))); - sna_crtc = calloc(sizeof(struct sna_crtc), 1); + sna_crtc = calloc(1, sizeof(struct sna_crtc)); if (sna_crtc == NULL) return false; @@ -5321,7 +5321,7 @@ sna_output_add(struct sna *sna, unsigned id, unsigned serial) possible_crtcs >>= ffs(zaphod_crtcs) - 1; } - sna_output = calloc(sizeof(struct sna_output), 1); + sna_output = calloc(1, sizeof(struct sna_output)); if (!sna_output) return -1; diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index ebc061b5a8a8..285ded82128a 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -269,8 +269,8 @@ bool sna_glyphs_create(struct sna *sna) cache->count = cache->evict = 0; cache->picture = picture; - cache->glyphs = calloc(sizeof(struct sna_glyph *), - GLYPH_CACHE_SIZE); + cache->glyphs = calloc(GLYPH_CACHE_SIZE, + sizeof(struct sna_glyph *)); if (!cache->glyphs) goto bail; diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c index 409cbbcf7901..fc8e0811fd4a 100644 --- a/src/uxa/intel_display.c +++ b/src/uxa/intel_display.c @@ -313,7 +313,7 @@ intel_crtc_apply(xf86CrtcPtr crtc) int fb_id, x, y; int i, ret = FALSE; - output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); + output_ids = calloc(xf86_config->num_output, sizeof(uint32_t)); if (!output_ids) return FALSE; @@ -734,7 +734,7 @@ intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_re xf86CrtcPtr crtc; struct intel_crtc *intel_crtc; - intel_crtc = calloc(sizeof(struct intel_crtc), 1); + intel_crtc = calloc(1, sizeof(struct intel_crtc)); if (intel_crtc == NULL) return; @@ -1542,7 +1542,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_ return; } } - kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders); + kencoders = calloc(koutput->count_encoders, sizeof(drmModeEncoderPtr)); if (!kencoders) { goto out_free_encoders; } @@ -1558,7 +1558,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_ goto out_free_encoders; } - intel_output = calloc(sizeof(struct intel_output), 1); + intel_output = calloc(1, sizeof(struct intel_output)); if (!intel_output) { xf86OutputDestroy(output); goto out_free_encoders; diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c index b21e5c41072f..d92aebc68e12 100644 --- a/src/uxa/intel_present.c +++ b/src/uxa/intel_present.c @@ -168,7 +168,7 @@ intel_present_queue_vblank(RRCrtcPtr crtc, int ret; uint32_t seq; - event = calloc(sizeof(struct intel_present_vblank_event), 1); + event = calloc(1, sizeof(struct intel_present_vblank_event)); if (!event) return BadAlloc; event->event_id = event_id; diff --git a/src/uxa/uxa-glyphs.c b/src/uxa/uxa-glyphs.c index d24ba5187870..98f02ffc442a 100644 --- a/src/uxa/uxa-glyphs.c +++ b/src/uxa/uxa-glyphs.c @@ -190,7 +190,7 @@ static Bool uxa_realize_glyph_caches(ScreenPtr pScreen) ValidatePicture(picture); cache->picture = picture; - cache->glyphs = calloc(sizeof(GlyphPtr), GLYPH_CACHE_SIZE); + cache->glyphs = calloc(GLYPH_CACHE_SIZE, sizeof(GlyphPtr)); if (!cache->glyphs) goto bail; diff --git a/src/uxa/uxa.c b/src/uxa/uxa.c index b682dfd9f7f7..3a474ff6ef8b 100644 --- a/src/uxa/uxa.c +++ b/src/uxa/uxa.c @@ -470,7 +470,7 @@ Bool uxa_driver_init(ScreenPtr screen, uxa_driver_t * uxa_driver) if (!dixRegisterPrivateKey(&uxa_screen_index, PRIVATE_SCREEN, 0)) return FALSE; #endif - uxa_screen = calloc(sizeof(uxa_screen_t), 1); + uxa_screen = calloc(1, sizeof(uxa_screen_t)); if (!uxa_screen) { LogMessage(X_WARNING, diff --git a/test/basic-copyarea.c b/test/basic-copyarea.c index a1ef34913176..c70b6a65536e 100644 --- a/test/basic-copyarea.c +++ b/test/basic-copyarea.c @@ -154,7 +154,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/basic-fillrect.c b/test/basic-fillrect.c index 80c219c7b731..967caacb48bf 100644 --- a/test/basic-fillrect.c +++ b/test/basic-fillrect.c @@ -124,7 +124,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/basic-putimage.c b/test/basic-putimage.c index e252fe3fe2b4..2a96e7cf1e31 100644 --- a/test/basic-putimage.c +++ b/test/basic-putimage.c @@ -144,7 +144,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s %s shm): ", diff --git a/test/render-composite-solid.c b/test/render-composite-solid.c index 9d779be2e808..4751c0c60eb0 100644 --- a/test/render-composite-solid.c +++ b/test/render-composite-solid.c @@ -109,7 +109,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/render-copy-alphaless.c b/test/render-copy-alphaless.c index 01c74a7ee912..5ba31291154e 100644 --- a/test/render-copy-alphaless.c +++ b/test/render-copy-alphaless.c @@ -139,7 +139,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/render-copyarea.c b/test/render-copyarea.c index a202ddeb2711..ee7ff34e83b8 100644 --- a/test/render-copyarea.c +++ b/test/render-copyarea.c @@ -158,7 +158,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/render-fill-copy.c b/test/render-fill-copy.c index b5b475a081d6..0cbbe8c93866 100644 --- a/test/render-fill-copy.c +++ b/test/render-fill-copy.c @@ -131,7 +131,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/render-fill.c b/test/render-fill.c index 37c9d8583249..153104649d02 100644 --- a/test/render-fill.c +++ b/test/render-fill.c @@ -101,7 +101,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); diff --git a/test/render-trapezoid-image.c b/test/render-trapezoid-image.c index 452b4ec99a95..0a84ef887eee 100644 --- a/test/render-trapezoid-image.c +++ b/test/render-trapezoid-image.c @@ -265,7 +265,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s using %s source): ", diff --git a/test/render-trapezoid.c b/test/render-trapezoid.c index f15a78e3bdc0..38713a5fc8ff 100644 --- a/test/render-trapezoid.c +++ b/test/render-trapezoid.c @@ -151,7 +151,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); + uint32_t *cells = calloc(t->out.width * t->out.height, + sizeof(uint32_t)); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); From patchwork Mon Feb 10 17:58:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A077AC02198 for ; Mon, 10 Feb 2025 17:58:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3430910E5D3; Mon, 10 Feb 2025 17:58:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="DA7rGD09"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27C0510E5D3 for ; Mon, 10 Feb 2025 17:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210325; x=1770746325; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=1eGH8zv8Ts06YqTyjBURQfDUXWuKnEF/T6vEfBIDx8Y=; b=DA7rGD09KHHXaXyo08JePTw6L0z9NNZQHWxxoZWc1+9kaMN1hqKq24bW 3Fg3Sbee6y5p63iTwoqn8spjTAjcTBfRUjMHNYPcbr5ELg8K85g5hudno XiA2/oLuEYWlpUzkwHUncN3UEGisJ2+Y1CeVeadHczX/GAK0go0mbmZS6 A+xNDIcflfQy3/LxevOkjZJf0HrZc18Ddok5bUZikXMOZrpVfSZ3zYtKz HSBO9wPQLpovOGp/UzdZ8M55fqsvI7ywTuK8g91IPrOH3k2Y08Dez/VLJ dTotS4psBV36UXFnW3uXtqEq0V6pjibe1Uf3f905bG413C/3/M49qfKbA Q==; X-CSE-ConnectionGUID: ZdZ9vtjnQmSiBgVMJXlrgg== X-CSE-MsgGUID: WvM/DaySQf6Oc8Hq3P3kSA== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39002995" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39002995" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:45 -0800 X-CSE-ConnectionGUID: jBFWW5leROCCOGDEqpJOhQ== X-CSE-MsgGUID: byt6ni++TISPCV4Q27F1OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480690" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:43 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:42 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 2/7] sna: Don't memcpy() between different types Date: Mon, 10 Feb 2025 19:58:31 +0200 Message-ID: <20250210175836.30984-3-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Currently we're doing a blind memcpy() from a DDXPointRec into the beginning of a BoxRec. While this apparently works it's quite dodgy. Get rid of the memcpy() and simply assign each member by hand. Signed-off-by: Ville Syrjälä --- src/sna/fb/fbspan.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/sna/fb/fbspan.c b/src/sna/fb/fbspan.c index 18136c200458..0700d8811efe 100644 --- a/src/sna/fb/fbspan.c +++ b/src/sna/fb/fbspan.c @@ -37,14 +37,16 @@ fbFillSpans(DrawablePtr drawable, GCPtr gc, { DBG(("%s x %d\n", __FUNCTION__, n)); while (n--) { - BoxRec box; - - memcpy(&box, pt, sizeof(box)); - box.x2 = box.x1 + *width++; - box.y2 = box.y1 + 1; + BoxRec box = { + .x1 = pt->x, + .y1 = pt->y, + .x2 = pt->x + *width, + .y2 = pt->y + 1, + }; /* XXX fSorted */ fbDrawableRun(drawable, gc, &box, fbFillSpan, NULL); + width++; pt++; } } @@ -90,12 +92,14 @@ fbSetSpans(DrawablePtr drawable, GCPtr gc, data.src = src; while (n--) { - BoxRec box; + BoxRec box = { + .x1 = pt->x, + .y1 = pt->y, + .x2 = pt->x + *width, + .y2 = pt->y + 1, + }; - memcpy(&box, pt, sizeof(box)); data.pt = *pt; - box.x2 = box.x1 + *width; - box.y2 = box.y1 + 1; fbDrawableRun(drawable, gc, &box, fbSetSpan, &data); From patchwork Mon Feb 10 17:58:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 203CEC021A1 for ; Mon, 10 Feb 2025 17:58:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A671F10E5D7; Mon, 10 Feb 2025 17:58:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ekyWnsvL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE7AB10E5D6 for ; Mon, 10 Feb 2025 17:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210328; x=1770746328; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=4XS0DZZyxsTBaTv4UuKrA8GC9lG1lpFIZDhzWfiqwYU=; b=ekyWnsvLjdkN7BdiKvwxFuthih/O97FdnMbjQtNA3xF0gU0D4lp5pu/1 8pTWhOix9P7igj9as1UyekHjE1HDJsBkMGLQxsLmm2sTfdpXrP8Lv+/V6 hgxRGFD6kgJl16cIti1eZZTfc8fTfU4T0pK6t16oTQzNgYRgf/OAkAI4q yGz+QdKMqMmSpP6wHt293zgoDguoEQzHvUqpGZ+2susrPz7DUqFnellzY DORoXlTIx4UXgGunQq4K4hQgMrcP2fl4iYout+R9jCILhWF2X/Rnbrt4t 3+Vikj03vtg0c9cQHutelOYhxiVeG5DcurpXFJMPruez6tWzeFSVu3gA8 w==; X-CSE-ConnectionGUID: zyD6jLl4RcKVQen275TTJA== X-CSE-MsgGUID: DCdHeL/mS3iThGy/ivGrRg== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39003001" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39003001" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:47 -0800 X-CSE-ConnectionGUID: nmy9IcdCTiqVkPbL125M+Q== X-CSE-MsgGUID: 3SJPlXRnQ4m7bD+6kb4EgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480691" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:45 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:45 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 3/7] sna/kgem: Add kgem_bo_replace() Date: Mon, 10 Feb 2025 19:58:32 +0200 Message-ID: <20250210175836.30984-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Add a helper to do the unref old + ref new bo dance. Signed-off-by: Ville Syrjälä --- src/sna/kgem.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 6a087a574a78..205a4eaefb75 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -411,6 +411,15 @@ static inline void kgem_bo_destroy(struct kgem *kgem, struct kgem_bo *bo) _kgem_bo_destroy(kgem, bo); } +static inline void kgem_bo_replace(struct kgem *kgem, + struct kgem_bo **bo, + struct kgem_bo *new_bo) +{ + if (*bo) + kgem_bo_destroy(kgem, *bo); + *bo = new_bo ? kgem_bo_reference(new_bo) : NULL; +} + void kgem_clear_dirty(struct kgem *kgem); static inline void kgem_set_mode(struct kgem *kgem, From patchwork Mon Feb 10 17:58:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C2B6C02198 for ; Mon, 10 Feb 2025 17:58:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F3BC10E377; Mon, 10 Feb 2025 17:58:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="e9MccIlh"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA8D410E5D9 for ; Mon, 10 Feb 2025 17:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210331; x=1770746331; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=zOLduP6qYbbG6mikOiwT3nY3ZvZD5bPac75GCUvySRc=; b=e9MccIlhdWrsh2Ji67a4oDkiVveUAS5sVZFv878ybAeZQ0drTVF1yu2z hsjX1R4a4UUq/SGxaSjHSWsT+375QThhFygkiPz+l3IW1w8C6nRkgx6qC Mrv9sa1AhjPo+H7dswbim8v/hhOL0ZSGjJfmUOvQUCH7wpUk7PV42Ydjv aRdA81KzdaX0qKfmxVyHfLaJbSHP0qh2QFVdyPRDmTgK7nnKJx8Qb5uLu I+XnHWBYPXCBMIvpNxaYn8s5gqlATVxMpjy+lhd7vF564FKzmGoMfnYFu tLRoJimzpuH4kMbfB6A/hpm3oumyE8u+ZFG8z4kJiotsNZ0vu8lSO19Sq Q==; X-CSE-ConnectionGUID: EMcXLe1RTC24BZGRGktA9g== X-CSE-MsgGUID: A4vz4lTeSFibIWk91Ad3DQ== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39003007" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39003007" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:50 -0800 X-CSE-ConnectionGUID: X1hrOIZHSXaLUFyqISU5pQ== X-CSE-MsgGUID: +v8pLgzWRceJirpzeosmQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480692" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:48 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:47 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 4/7] sna/video/sprite: Use kgem_bo_replace() Date: Mon, 10 Feb 2025 19:58:33 +0200 Message-ID: <20250210175836.30984-5-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Replace the hand rolled bo unref+ref stuff with kgem_bo_replace(). Signed-off-by: Ville Syrjälä --- src/sna/sna_video_sprite.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index db3865b9ffae..ce09d890af71 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -115,9 +115,7 @@ static int sna_video_sprite_stop(ddStopVideo_ARGS) xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, "failed to disable plane\n"); - if (video->bo[index]) - kgem_bo_destroy(&video->sna->kgem, video->bo[index]); - video->bo[index] = NULL; + kgem_bo_replace(&video->sna->kgem, &video->bo[index], NULL); } sna_window_set_port((WindowPtr)draw, NULL); @@ -468,18 +466,13 @@ sna_video_sprite_show(struct sna *sna, if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) { DBG(("SET_PLANE failed: ret=%d\n", errno)); - if (video->bo[index]) { - kgem_bo_destroy(&sna->kgem, video->bo[index]); - video->bo[index] = NULL; - } + kgem_bo_replace(&sna->kgem, &video->bo[index], NULL); return false; } __kgem_bo_clear_dirty(frame->bo); - if (video->bo[index]) - kgem_bo_destroy(&sna->kgem, video->bo[index]); - video->bo[index] = kgem_bo_reference(frame->bo); + kgem_bo_replace(&sna->kgem, &video->bo[index], frame->bo); return true; } From patchwork Mon Feb 10 17:58:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 283A9C0219B for ; Mon, 10 Feb 2025 17:58:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BADE410E5D9; Mon, 10 Feb 2025 17:58:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="GmAz/4B9"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A24910E5D9 for ; Mon, 10 Feb 2025 17:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210333; x=1770746333; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BDGIt7KTYIKv972pcJ+JIsakU64sahaLXZNAWKgFyZc=; b=GmAz/4B9GrXpzhRm28I4kLodhxKhXpMu4XP4CXteS6BDIZQWjr5+qTGc gOBHB237VG0Xhdn2+h69bY9SWc6P2SvhvFpA39wDQC5S5kLOS3d2e6aGt S9wnBtaKU4yOxs+3S4hhKopNleU6Z3otXush/y9zrI0eq5dshhYsGDBX6 rB3j0yPqGfasNl/2uSJrh3M8RCW3EHz7F7w/859AUA4xYXZOrzekchO14 fVHKnY3ABMaYkbAzfhHk9kFQWCTZj81QnoUBuxY5cmVcnaHs4pTNnUDCY 1kh/fXu5kZU3yNLIdKpIU2Ly9jgngOXdYcWFndZCvIRjfsEGs7x8/aPV8 w==; X-CSE-ConnectionGUID: /Vl9qFHCTn6YgHaGvMbSRA== X-CSE-MsgGUID: gO9e3VxeT5m6H0boHTX/aw== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39003010" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39003010" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:53 -0800 X-CSE-ConnectionGUID: B8BP7bFgSBa3M2YS/GrvJA== X-CSE-MsgGUID: 5Mv8CZTfSQCNlbBcLAhHBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480693" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:51 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:50 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 5/7] sna/video/sprite: Plug bo leak Date: Mon, 10 Feb 2025 19:58:34 +0200 Message-ID: <20250210175836.30984-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Looks like we're leaking video->bo[index] if the entire sprite gets clipped. Let's plug that leak. Signed-off-by: Ville Syrjälä --- src/sna/sna_video_sprite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index ce09d890af71..e2541e351b3f 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -548,7 +548,7 @@ off: if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, "failed to disable plane\n"); - video->bo[index] = NULL; + kgem_bo_replace(&sna->kgem, &video->bo[index], NULL); } continue; } From patchwork Mon Feb 10 17:58:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7488FC0219E for ; Mon, 10 Feb 2025 17:58:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B6EE10E5D8; Mon, 10 Feb 2025 17:58:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="BX/JeO/I"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id B42A210E5D8 for ; Mon, 10 Feb 2025 17:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210337; x=1770746337; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=CQbFXzVwjFNellMB/9pATb9LoL4kr7uMSaJ1vUDoT0Q=; b=BX/JeO/I0RWSDXiK5tWLh9jlM8P1V5IpMZV3+SWMmTOyRxjdecvCQiuP YbKt3Q6f6g5M3EsqENXUNM+2qIQ5jJXJTmYWkJt2YkbJLQWHJBHxNtE8y BOJrtdCZTQYbMDj57kLPMH5BW4g98/9axZKxzeZeLicPfFDY7YJlbRD5u 6Ay8Oxy9vJ8ovfLrSqwVsvYwlm/qleJexbAYHSs9dr42vCz7VcpZ/C/KY F/dMLvvO7bTE5/C/4zWYUARopkMYWsVNWm3+B2pVPWke9iUYI6/5xNLYn SbcMj8L+ixdZ4xzZNATXdD4RfbVvd4T+Seincme7e6Jro2VDay8OR18Dk A==; X-CSE-ConnectionGUID: BQVMlb1xSXOr49rhZUAABA== X-CSE-MsgGUID: uJ3i9EZRTmyFs7Xb3JIwaA== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39003014" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39003014" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:56 -0800 X-CSE-ConnectionGUID: rfT1gfhMSTCyCeNpMviE2w== X-CSE-MsgGUID: sPJy9shHQYmYBUFbBRHZ/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480694" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:54 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:53 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 6/7] sna/video/sprite: Extract sna_video_sprite_hide() Date: Mon, 10 Feb 2025 19:58:35 +0200 Message-ID: <20250210175836.30984-7-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä --- src/sna/sna_video_sprite.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index e2541e351b3f..5f1e4616a23e 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -93,10 +93,20 @@ static const XvAttributeRec attribs[] = { { XvSettable | XvGettable, 0, 1, (char *)"XV_ALWAYS_ON_TOP" }, }; +static void sna_video_sprite_hide(xf86CrtcPtr crtc, struct sna_video *video) +{ + struct local_mode_set_plane s = { + .plane_id = sna_crtc_to_sprite(crtc, video->idx), + }; + + if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) + xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, + "failed to disable plane\n"); +} + static int sna_video_sprite_stop(ddStopVideo_ARGS) { struct sna_video *video = port->devPriv.ptr; - struct local_mode_set_plane s; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(video->sna->scrn); int i; @@ -109,12 +119,7 @@ static int sna_video_sprite_stop(ddStopVideo_ARGS) if (video->bo[index] == NULL) continue; - memset(&s, 0, sizeof(s)); - s.plane_id = sna_crtc_to_sprite(crtc, video->idx); - if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) - xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, - "failed to disable plane\n"); - + sna_video_sprite_hide(crtc, video); kgem_bo_replace(&video->sna->kgem, &video->bo[index], NULL); } @@ -322,13 +327,8 @@ sna_video_sprite_show(struct sna *sna, if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY, &set)) { - memset(&s, 0, sizeof(s)); - s.plane_id = sna_crtc_to_sprite(crtc, video->idx); - /* try to disable the plane first */ - if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) - xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, - "failed to disable plane\n"); + sna_video_sprite_hide(crtc, video); if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY, &set)) { xf86DrvMsg(sna->scrn->scrnIndex, X_ERROR, @@ -542,12 +542,7 @@ retry: off: assert(index < ARRAY_SIZE(video->bo)); if (video->bo[index]) { - struct local_mode_set_plane s; - memset(&s, 0, sizeof(s)); - s.plane_id = sna_crtc_to_sprite(crtc, video->idx); - if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) - xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, - "failed to disable plane\n"); + sna_video_sprite_hide(crtc, video); kgem_bo_replace(&sna->kgem, &video->bo[index], NULL); } continue; From patchwork Mon Feb 10 17:58:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13968328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75496C0219B for ; Mon, 10 Feb 2025 17:59:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1525D10E5DA; Mon, 10 Feb 2025 17:59:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="eWJ0Q6Mo"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEC2D10E5DA for ; Mon, 10 Feb 2025 17:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739210339; x=1770746339; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=3tRgRI7uEn7YCi3eYOhUCm+BH9gh7GfQeZHfosUz1Eo=; b=eWJ0Q6MoebmSUH3hiVbhYcscOFdIpolla4j0eW6VONSfDPt3uCx99bri 6T95BXOi5aP/2oLicvCgApRFBobfu6J5DVf5Gx29lav4Rrxp3pgZDcNWV HR03P14kaBmRI4t8IaH9gP5IY4UWwPQfW2p+oX7HHog5+iGBjs2wdofNO NPIe2RC2d2KoDic3hxtk07ORKp2jv07mUcTeQZRcPYpmFqiIbXukVAzUP /RMpDvzbzSGnJWUJ7ezs6yS78L3ybyEqcRX6ys/t0oZVrXWswrGzhzapn y1+lGjoGF8MQ26zQYra20ELGlDGyJSySdJppSxOk2RoYNn7rb9P5vez/m g==; X-CSE-ConnectionGUID: +PkY9ARhSB+yT130H0Kqtg== X-CSE-MsgGUID: QhHUnSvMRa2r1JEk0zJaJQ== X-IronPort-AV: E=McAfee;i="6700,10204,11341"; a="39003019" X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="39003019" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2025 09:58:59 -0800 X-CSE-ConnectionGUID: 2jk3PmmqR0iPoBr9pHXsdA== X-CSE-MsgGUID: t9QBchYpQ1aGwbU67rQMIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,275,1732608000"; d="scan'208";a="112480695" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 10 Feb 2025 09:58:56 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 10 Feb 2025 19:58:56 +0200 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH xf86-video-intel 7/7] sna/video/sprite: Reset colorkey whenever disabling the sprite plane Date: Mon, 10 Feb 2025 19:58:36 +0200 Message-ID: <20250210175836.30984-8-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250210175836.30984-1-ville.syrjala@linux.intel.com> References: <20250210175836.30984-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä Let's disable the colorkey whenever we hide the sprite. The colorkey is a non-standard thing so generic kms clients have no way to disable it, and the kernel may reject certain otherwise legal things if colorkeying is left active. Signed-off-by: Ville Syrjälä --- src/sna/sna_video_sprite.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 5f1e4616a23e..5cb9e638abe0 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -93,15 +93,34 @@ static const XvAttributeRec attribs[] = { { XvSettable | XvGettable, 0, 1, (char *)"XV_ALWAYS_ON_TOP" }, }; +#define DRM_I915_SET_SPRITE_COLORKEY 0x2b +#define LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct local_intel_sprite_colorkey) +#define LOCAL_IOCTL_MODE_ADDFB2 DRM_IOWR(0xb8, struct local_mode_fb_cmd2) + +struct local_intel_sprite_colorkey { + uint32_t plane_id; + uint32_t min_value; + uint32_t channel_mask; + uint32_t max_value; + uint32_t flags; +}; + static void sna_video_sprite_hide(xf86CrtcPtr crtc, struct sna_video *video) { struct local_mode_set_plane s = { .plane_id = sna_crtc_to_sprite(crtc, video->idx), }; + struct local_intel_sprite_colorkey key = { + .plane_id = sna_crtc_to_sprite(crtc, video->idx), + }; + int index = sna_crtc_index(crtc); if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR, "failed to disable plane\n"); + + drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY, &key); + video->color_key_changed |= 1 << index; } static int sna_video_sprite_stop(ddStopVideo_ARGS) @@ -300,18 +319,8 @@ sna_video_sprite_show(struct sna *sna, VG_CLEAR(s); s.plane_id = sna_crtc_to_sprite(crtc, video->idx); -#define DRM_I915_SET_SPRITE_COLORKEY 0x2b -#define LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct local_intel_sprite_colorkey) -#define LOCAL_IOCTL_MODE_ADDFB2 DRM_IOWR(0xb8, struct local_mode_fb_cmd2) - if (video->color_key_changed & (1 << index) && video->has_color_key) { - struct local_intel_sprite_colorkey { - uint32_t plane_id; - uint32_t min_value; - uint32_t channel_mask; - uint32_t max_value; - uint32_t flags; - } set; + struct local_intel_sprite_colorkey set; DBG(("%s: updating color key: %x\n", __FUNCTION__, video->color_key));