stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Christian König" <christian.koenig@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>
Subject: [ 56/60] drm/radeon: only save UVD bo when we have open handles
Date: Mon, 12 Aug 2013 23:34:23 -0700	[thread overview]
Message-ID: <20130813063338.873041493@linuxfoundation.org> (raw)
In-Reply-To: <20130813063331.950321483@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Christian König <christian.koenig@amd.com>

commit 4ad9c1c774c2af152283f510062094e768876f55 upstream.

Otherwise just reinitialize from scratch on resume,
and so make it more likely to succeed.

v2: rebased for 3.10-stable tree

Signed-off-by: Christian König <christian.koenig@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/radeon/radeon.h       |    2 -
 drivers/gpu/drm/radeon/radeon_fence.c |    2 -
 drivers/gpu/drm/radeon/radeon_uvd.c   |   46 ++++++++++++++++++++++++----------
 drivers/gpu/drm/radeon/rv770.c        |    2 -
 4 files changed, 36 insertions(+), 16 deletions(-)

--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1146,7 +1146,6 @@ struct radeon_uvd {
 	void			*cpu_addr;
 	uint64_t		gpu_addr;
 	void			*saved_bo;
-	unsigned		fw_size;
 	atomic_t		handles[RADEON_MAX_UVD_HANDLES];
 	struct drm_file		*filp[RADEON_MAX_UVD_HANDLES];
 	struct delayed_work	idle_work;
@@ -1686,6 +1685,7 @@ struct radeon_device {
 	const struct firmware *rlc_fw;	/* r6/700 RLC firmware */
 	const struct firmware *mc_fw;	/* NI MC firmware */
 	const struct firmware *ce_fw;	/* SI CE firmware */
+	const struct firmware *uvd_fw;	/* UVD firmware */
 	struct r600_blit r600_blit;
 	struct r600_vram_scratch vram_scratch;
 	int msi_enabled; /* msi enabled */
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -782,7 +782,7 @@ int radeon_fence_driver_start_ring(struc
 
 		} else {
 			/* put fence directly behind firmware */
-			index = ALIGN(rdev->uvd.fw_size, 8);
+			index = ALIGN(rdev->uvd_fw->size, 8);
 			rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index;
 			rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index;
 		}
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -55,7 +55,6 @@ static void radeon_uvd_idle_work_handler
 int radeon_uvd_init(struct radeon_device *rdev)
 {
 	struct platform_device *pdev;
-	const struct firmware *fw;
 	unsigned long bo_size;
 	const char *fw_name;
 	int i, r;
@@ -105,7 +104,7 @@ int radeon_uvd_init(struct radeon_device
 		return -EINVAL;
 	}
 
-	r = request_firmware(&fw, fw_name, &pdev->dev);
+	r = request_firmware(&rdev->uvd_fw, fw_name, &pdev->dev);
 	if (r) {
 		dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
 			fw_name);
@@ -115,7 +114,7 @@ int radeon_uvd_init(struct radeon_device
 
 	platform_device_unregister(pdev);
 
-	bo_size = RADEON_GPU_PAGE_ALIGN(fw->size + 8) +
+	bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
 		  RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE;
 	r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
 			     RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo);
@@ -148,12 +147,6 @@ int radeon_uvd_init(struct radeon_device
 
 	radeon_bo_unreserve(rdev->uvd.vcpu_bo);
 
-	rdev->uvd.fw_size = fw->size;
-	memset(rdev->uvd.cpu_addr, 0, bo_size);
-	memcpy(rdev->uvd.cpu_addr, fw->data, fw->size);
-
-	release_firmware(fw);
-
 	for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
 		atomic_set(&rdev->uvd.handles[i], 0);
 		rdev->uvd.filp[i] = NULL;
@@ -177,33 +170,60 @@ void radeon_uvd_fini(struct radeon_devic
 	}
 
 	radeon_bo_unref(&rdev->uvd.vcpu_bo);
+
+	release_firmware(rdev->uvd_fw);
 }
 
 int radeon_uvd_suspend(struct radeon_device *rdev)
 {
 	unsigned size;
+	void *ptr;
+	int i;
 
 	if (rdev->uvd.vcpu_bo == NULL)
 		return 0;
 
+	for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
+		if (atomic_read(&rdev->uvd.handles[i]))
+			break;
+
+	if (i == RADEON_MAX_UVD_HANDLES)
+		return 0;
+
 	size = radeon_bo_size(rdev->uvd.vcpu_bo);
+	size -= rdev->uvd_fw->size;
+
+	ptr = rdev->uvd.cpu_addr;
+	ptr += rdev->uvd_fw->size;
+
 	rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
-	memcpy(rdev->uvd.saved_bo, rdev->uvd.cpu_addr, size);
+	memcpy(rdev->uvd.saved_bo, ptr, size);
 
 	return 0;
 }
 
 int radeon_uvd_resume(struct radeon_device *rdev)
 {
+	unsigned size;
+	void *ptr;
+
 	if (rdev->uvd.vcpu_bo == NULL)
 		return -EINVAL;
 
+	memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size);
+
+	size = radeon_bo_size(rdev->uvd.vcpu_bo);
+	size -= rdev->uvd_fw->size;
+
+	ptr = rdev->uvd.cpu_addr;
+	ptr += rdev->uvd_fw->size;
+
 	if (rdev->uvd.saved_bo != NULL) {
-		unsigned size = radeon_bo_size(rdev->uvd.vcpu_bo);
-		memcpy(rdev->uvd.cpu_addr, rdev->uvd.saved_bo, size);
+		memcpy(ptr, rdev->uvd.saved_bo, size);
 		kfree(rdev->uvd.saved_bo);
 		rdev->uvd.saved_bo = NULL;
-	}
+	} else
+		memset(ptr, 0, size);
 
 	return 0;
 }
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -813,7 +813,7 @@ int rv770_uvd_resume(struct radeon_devic
 
 	/* programm the VCPU memory controller bits 0-27 */
 	addr = rdev->uvd.gpu_addr >> 3;
-	size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3;
+	size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
 	WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
 	WREG32(UVD_VCPU_CACHE_SIZE0, size);
 



  parent reply	other threads:[~2013-08-13  6:34 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  6:33 [ 00/60] 3.10.7-stable review Greg Kroah-Hartman
2013-08-13  6:33 ` [ 01/60] SCSI: Dont attempt to send extended INQUIRY command if skip_vpd_pages is set Greg Kroah-Hartman
2013-08-13  6:33 ` [ 02/60] SCSI: megaraid_sas: megaraid_sas driver init fails in kdump kernel Greg Kroah-Hartman
2013-08-13  6:33 ` [ 03/60] virtio-scsi: Fix virtqueue affinity setup Greg Kroah-Hartman
2013-08-13  6:33 ` [ 04/60] powerpc: On POWERNV enable PPC_DENORMALISATION by default Greg Kroah-Hartman
2013-08-13  6:33 ` [ 05/60] powerpc: Fix hypervisor facility unavaliable vector number Greg Kroah-Hartman
2013-08-13  6:33 ` [ 06/60] powerpc: Rework setting up H/FSCR bit definitions Greg Kroah-Hartman
2013-08-13  6:33 ` [ 07/60] powerpc: Fix context switch DSCR on POWER8 Greg Kroah-Hartman
2013-08-13  6:33 ` [ 08/60] powerpc: Save the TAR register earlier Greg Kroah-Hartman
2013-08-13  6:33 ` [ 09/60] powerpc/tm: Fix context switching TAR, PPR and DSCR SPRs Greg Kroah-Hartman
2013-08-13  6:33 ` [ 10/60] ext4: destroy ext4_es_cachep on module unload Greg Kroah-Hartman
2013-08-13  6:33 ` [ 11/60] ext4: make sure group number is bumped after a inode allocation race Greg Kroah-Hartman
2013-08-13  6:33 ` [ 12/60] ext4: fix retry handling in ext4_ext_truncate() Greg Kroah-Hartman
2013-08-13  6:33 ` [ 13/60] regmap: cache: Make sure to sync the last register in a block Greg Kroah-Hartman
2013-08-13  6:33 ` [ 14/60] regmap: Add missing header for !CONFIG_REGMAP stubs Greg Kroah-Hartman
2013-08-13  6:33 ` [ 15/60] hwmon: (adt7470) Fix incorrect return code check Greg Kroah-Hartman
2013-08-13  6:33 ` [ 16/60] staging: zcache: fix "zcache=" kernel parameter Greg Kroah-Hartman
2013-08-13  6:33 ` [ 17/60] media: em28xx: fix assignment of the eeprom data Greg Kroah-Hartman
2013-08-13  6:33 ` [ 18/60] i2c: i2c-mxs: Use DMA mode even for small transfers Greg Kroah-Hartman
2013-08-13  6:33 ` [ 19/60] cpufreq: loongson2: fix regression related to clock management Greg Kroah-Hartman
2013-08-13  6:33 ` [ 20/60] cpufreq: rename ignore_nice as ignore_nice_load Greg Kroah-Hartman
2013-08-13  6:33 ` [ 21/60] ACPI / PM: Walk physical_node_list under physical_node_lock Greg Kroah-Hartman
2013-08-13  6:33 ` [ 22/60] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Greg Kroah-Hartman
2013-08-13  6:33 ` [ 23/60] tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer Greg Kroah-Hartman
2013-08-13  6:33 ` [ 24/60] tracing: Use flag buffer_disabled for irqsoff tracer Greg Kroah-Hartman
2013-08-13  6:33 ` [ 25/60] tracing: Fix reset of time stamps during trace_clock changes Greg Kroah-Hartman
2013-08-13  6:33 ` [ 26/60] ALSA: usb-audio: do not trust too-big wMaxPacketSize values Greg Kroah-Hartman
2013-08-13  6:33 ` [ 27/60] ALSA: 6fire: fix DMA issues with URB transfer_buffer usage Greg Kroah-Hartman
2013-08-13  6:33 ` [ 28/60] Btrfs: release both paths before logging dir/changed extents Greg Kroah-Hartman
2013-08-13  6:33 ` [ 29/60] LOCKD: Dont call utsname()->nodename from nlmclnt_setlockargs Greg Kroah-Hartman
2013-08-13  6:33 ` [ 30/60] SUNRPC: Dont auto-disconnect from the local rpcbind socket Greg Kroah-Hartman
2013-08-13  6:33 ` [ 31/60] SUNRPC: If the rpcbind channel is disconnected, fail the call to unregister Greg Kroah-Hartman
2013-08-13  6:33 ` [ 32/60] virtio/console: Quit from splice_write if pipe->nrbufs is 0 Greg Kroah-Hartman
2013-08-13  6:34 ` [ 33/60] virtio/console: Add pipe_lock/unlock for splice_write Greg Kroah-Hartman
2013-08-13  6:34 ` [ 34/60] virtio: console: fix race with port unplug and open/close Greg Kroah-Hartman
2013-08-13  6:34 ` [ 35/60] virtio: console: fix race in port_fops_open() and port unplug Greg Kroah-Hartman
2013-08-13  6:34 ` [ 36/60] virtio: console: clean up port data immediately at time of unplug Greg Kroah-Hartman
2013-08-13  6:34 ` [ 37/60] virtio: console: fix raising SIGIO after port unplug Greg Kroah-Hartman
2013-08-13  6:34 ` [ 38/60] virtio: console: return -ENODEV on all read operations after unplug Greg Kroah-Hartman
2013-08-13  6:34 ` [ 39/60] drm/cirrus: Invalidate page tables when pinning a BO Greg Kroah-Hartman
2013-08-13  6:34 ` [ 40/60] drm/mgag200: " Greg Kroah-Hartman
2013-08-13  6:34 ` [ 41/60] drm/ast: invalidate " Greg Kroah-Hartman
2013-08-13  6:34 ` [ 42/60] drm: Dont pass negative delta to ktime_sub_ns() Greg Kroah-Hartman
2013-08-13  6:34 ` [ 43/60] drm/radeon: select audio dto based on encoder id for DCE3 Greg Kroah-Hartman
2013-08-13  6:34 ` [ 44/60] drm/radeon: stop sending invalid UVD destroy msg Greg Kroah-Hartman
2013-08-13  6:34 ` [ 45/60] ext4: allow the mount options nodelalloc and data=journal Greg Kroah-Hartman
2013-08-13  6:34 ` [ 46/60] ext4: fix mount/remount error messages for incompatible mount options Greg Kroah-Hartman
2013-08-13  6:34 ` [ 47/60] ext4: flush the extent status cache during EXT4_IOC_SWAP_BOOT Greg Kroah-Hartman
2013-08-13  6:34 ` [ 48/60] cifs: extend the buffer length enought for sprintf() using Greg Kroah-Hartman
2013-08-13  6:34 ` [ 49/60] cifs: dont instantiate new dentries in readdir for inodes that need to be revalidated immediately Greg Kroah-Hartman
2013-08-13  6:34 ` [ 50/60] zram: allow request end to coincide with disksize Greg Kroah-Hartman
2013-08-13  6:34 ` [ 51/60] usb: core: dont try to reset_device() a port that got just disconnected Greg Kroah-Hartman
2013-08-13  6:34 ` [ 52/60] debugfs: debugfs_remove_recursive() must not rely on list_empty(d_subdirs) Greg Kroah-Hartman
2013-08-13  6:34 ` [ 53/60] reiserfs: fix deadlock in umount Greg Kroah-Hartman
2013-08-13  6:34 ` [ 54/60] drm/i915: initialize gt_lock early with other spin locks Greg Kroah-Hartman
2013-08-13  6:34 ` [ 55/60] drm/radeon: fix halting UVD Greg Kroah-Hartman
2013-08-13  6:34 ` Greg Kroah-Hartman [this message]
2013-08-13  6:34 ` [ 57/60] drm/radeon: always program the MC on startup Greg Kroah-Hartman
2013-08-13  6:34 ` [ 58/60] SCSI: nsp32: use mdelay instead of large udelay constants Greg Kroah-Hartman
2013-08-13  6:34 ` [ 59/60] mtd: omap2: allow bulding as a module Greg Kroah-Hartman
2013-08-13  6:34 ` [ 60/60] MIPS: Expose missing pci_io{map,unmap} declarations Greg Kroah-Hartman
2013-08-13 11:57 ` [ 00/60] 3.10.7-stable review Guenter Roeck
2013-08-13 17:57   ` Greg Kroah-Hartman
2013-08-13 17:18 ` Shuah Khan
2013-08-13 17:57   ` Greg Kroah-Hartman

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=20130813063338.873041493@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.deucher@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).