Module Name:    src
Committed By:   martin
Date:           Fri Jul 17 15:30:26 UTC 2020

Modified Files:
        src/sys/dev/pci [netbsd-9]: radeonfb.c radeonfbvar.h

Log Message:
Pull up following revision(s) (requested by macallan in ticket #1019):

        sys/dev/pci/radeonfbvar.h: revision 1.21
        sys/dev/pci/radeonfb.c: revision 1.107

reduce stack usage in radeonfb_pickres() and radeonfb_set_cursor()

forgot to commit a header change, again...


To generate a diff of this commit:
cvs rdiff -u -r1.104.4.1 -r1.104.4.2 src/sys/dev/pci/radeonfb.c
cvs rdiff -u -r1.20 -r1.20.26.1 src/sys/dev/pci/radeonfbvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.104.4.1 src/sys/dev/pci/radeonfb.c:1.104.4.2
--- src/sys/dev/pci/radeonfb.c:1.104.4.1	Sun Aug 18 09:58:49 2019
+++ src/sys/dev/pci/radeonfb.c	Fri Jul 17 15:30:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.104.4.2 2020/07/17 15:30:26 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104.4.2 2020/07/17 15:30:26 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -80,6 +80,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v
 #include <sys/kernel.h>
 #include <sys/lwp.h>
 #include <sys/kauth.h>
+#include <sys/kmem.h>
 
 #include <dev/wscons/wsdisplayvar.h>
 #include <dev/wscons/wsconsio.h>
@@ -3691,12 +3692,12 @@ radeonfb_set_cursor(struct radeonfb_disp
 	unsigned	index, count;
 	int		i, err;
 	int		pitch, size;
-	struct radeonfb_cursor	nc;
+	struct radeonfb_cursor	*nc = &dp->rd_tempcursor;
 
 	flags = wc->which;
 
 	/* copy old values */
-	nc = dp->rd_cursor;
+	memcpy(nc, &dp->rd_cursor, sizeof(struct radeonfb_cursor));
 
 	if (flags & WSDISPLAY_CURSOR_DOCMAP) {
 		index = wc->cmap.index;
@@ -3716,7 +3717,7 @@ radeonfb_set_cursor(struct radeonfb_disp
 			return err;
 
 		for (i = index; i < index + count; i++) {
-			nc.rc_cmap[i] =
+			nc->rc_cmap[i] =
 			    (r[i] << 16) + (g[i] << 8) + (b[i] << 0);
 		}
 	}
@@ -3731,46 +3732,46 @@ radeonfb_set_cursor(struct radeonfb_disp
 		size = pitch * wc->size.y;
 
 		/* clear the old cursor and mask */
-		memset(nc.rc_image, 0, 512);
-		memset(nc.rc_mask, 0, 512);
+		memset(nc->rc_image, 0, 512);
+		memset(nc->rc_mask, 0, 512);
 
-		nc.rc_size = wc->size;
+		nc->rc_size = wc->size;
 
-		if ((err = copyin(wc->image, nc.rc_image, size)) != 0)
+		if ((err = copyin(wc->image, nc->rc_image, size)) != 0)
 			return err;
 
-		if ((err = copyin(wc->mask, nc.rc_mask, size)) != 0)
+		if ((err = copyin(wc->mask, nc->rc_mask, size)) != 0)
 			return err;
 	}
 
 	if (flags & WSDISPLAY_CURSOR_DOHOT) {
-		nc.rc_hot = wc->hot;
-		if (nc.rc_hot.x >= nc.rc_size.x)
-			nc.rc_hot.x = nc.rc_size.x - 1;
-		if (nc.rc_hot.y >= nc.rc_size.y)
-			nc.rc_hot.y = nc.rc_size.y - 1;
+		nc->rc_hot = wc->hot;
+		if (nc->rc_hot.x >= nc->rc_size.x)
+			nc->rc_hot.x = nc->rc_size.x - 1;
+		if (nc->rc_hot.y >= nc->rc_size.y)
+			nc->rc_hot.y = nc->rc_size.y - 1;
 	}
 
 	if (flags & WSDISPLAY_CURSOR_DOPOS) {
-		nc.rc_pos = wc->pos;
-		if (nc.rc_pos.x >= dp->rd_virtx)
-			nc.rc_pos.x = dp->rd_virtx - 1;
+		nc->rc_pos = wc->pos;
+		if (nc->rc_pos.x >= dp->rd_virtx)
+			nc->rc_pos.x = dp->rd_virtx - 1;
 #if 0
-		if (nc.rc_pos.x < 0)
-			nc.rc_pos.x = 0;
+		if (nc->rc_pos.x < 0)
+			nc->rc_pos.x = 0;
 #endif
-		if (nc.rc_pos.y >= dp->rd_virty)
-			nc.rc_pos.y = dp->rd_virty - 1;
+		if (nc->rc_pos.y >= dp->rd_virty)
+			nc->rc_pos.y = dp->rd_virty - 1;
 #if 0
-		if (nc.rc_pos.y < 0)
-			nc.rc_pos.y = 0;
+		if (nc->rc_pos.y < 0)
+			nc->rc_pos.y = 0;
 #endif
 	}
 	if (flags & WSDISPLAY_CURSOR_DOCUR) {
-		nc.rc_visible = wc->enable;
+		nc->rc_visible = wc->enable;
 	}
 
-	dp->rd_cursor = nc;
+	memcpy(&dp->rd_cursor, nc, sizeof(struct radeonfb_cursor));
 	radeonfb_cursor_update(dp, wc->which);
 
 	return 0;
@@ -4171,10 +4172,14 @@ radeonfb_pickres(struct radeonfb_display
 		}
 
 	} else {
-		struct videomode	modes[64];
+		struct videomode	*modes;
+		size_t			smodes;
 		int			nmodes = 0;
 		int			valid = 0;
 
+		smodes = sizeof(struct videomode) * 64;
+		modes = kmem_alloc(smodes, KM_SLEEP);
+
 		for (i = 0; i < dp->rd_ncrtcs; i++) {
 			/*
 			 * pick the largest resolution in common.
@@ -4243,6 +4248,8 @@ radeonfb_pickres(struct radeonfb_display
 				*y = modes[i].vdisplay;
 			}
 		}
+		kmem_free(modes, smodes);
+
 	}
 
 	if ((*x == 0) || (*y == 0)) {

Index: src/sys/dev/pci/radeonfbvar.h
diff -u src/sys/dev/pci/radeonfbvar.h:1.20 src/sys/dev/pci/radeonfbvar.h:1.20.26.1
--- src/sys/dev/pci/radeonfbvar.h:1.20	Wed Nov  5 19:39:17 2014
+++ src/sys/dev/pci/radeonfbvar.h	Fri Jul 17 15:30:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfbvar.h,v 1.20 2014/11/05 19:39:17 macallan Exp $ */
+/* $NetBSD: radeonfbvar.h,v 1.20.26.1 2020/07/17 15:30:26 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -184,7 +184,7 @@ struct radeonfb_display {
 	int			rd_ncrtcs;
 	struct radeonfb_crtc	rd_crtcs[2];
 
-	struct radeonfb_cursor	rd_cursor;
+	struct radeonfb_cursor	rd_cursor, rd_tempcursor;
 	/* XXX: this should probaby be an array for CRTCs */
 	//struct videomode	rd_videomode;
 

Reply via email to