diff mbox series

[09/10] drm/bochs: Validate display modes against available video memory

Message ID 20240823124422.286989-10-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series rm/bochs: Modernize driver | expand

Commit Message

Thomas Zimmermann Aug. 23, 2024, 12:28 p.m. UTC
For each mode, test the required memory against the available video
memory. Filters out modes that do not fit into display memory.

Also remove the old test against the 4 MiB limit. It is now obsolete
and did not necessarily produce correct results.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tiny/bochs.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

Comments

kernel test robot Aug. 29, 2024, 8:37 p.m. UTC | #1
Hi Thomas,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-misc/drm-misc-next drm-tip/drm-tip linus/master v6.11-rc5 next-20240829]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-bochs-Remove-manual-format-test-from-fb_create/20240826-131701
base:   git://anongit.freedesktop.org/drm/drm drm-next
patch link:    https://lore.kernel.org/r/20240823124422.286989-10-tzimmermann%40suse.de
patch subject: [PATCH 09/10] drm/bochs: Validate display modes against available video memory
config: i386-randconfig-006-20240829 (https://download.01.org/0day-ci/archive/20240830/202408300420.qcGOiIM6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240830/202408300420.qcGOiIM6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408300420.qcGOiIM6-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: drivers/gpu/drm/tiny/bochs.o: in function `bochs_mode_config_mode_valid':
>> drivers/gpu/drm/tiny/bochs.c:574: undefined reference to `__udivdi3'


vim +574 drivers/gpu/drm/tiny/bochs.c

   560	
   561	static enum drm_mode_status bochs_mode_config_mode_valid(struct drm_device *dev,
   562								 const struct drm_display_mode *mode)
   563	{
   564		struct bochs_device *bochs = to_bochs_device(dev);
   565		const struct drm_format_info *format = drm_format_info(DRM_FORMAT_XRGB8888);
   566		uint64_t pitch;
   567	
   568		if (drm_WARN_ON(dev, !format))
   569			return MODE_ERROR;
   570	
   571		pitch = drm_format_info_min_pitch(format, 0, mode->vdisplay);
   572		if (!pitch)
   573			return MODE_BAD_WIDTH;
 > 574		if (bochs->fb_size / pitch < mode->hdisplay)
   575			return MODE_MEM;
   576	
   577		return MODE_OK;
   578	}
   579
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index bde70a6075ec..b09c6c76923b 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -558,8 +558,28 @@  static const struct drm_connector_funcs bochs_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
+static enum drm_mode_status bochs_mode_config_mode_valid(struct drm_device *dev,
+							 const struct drm_display_mode *mode)
+{
+	struct bochs_device *bochs = to_bochs_device(dev);
+	const struct drm_format_info *format = drm_format_info(DRM_FORMAT_XRGB8888);
+	uint64_t pitch;
+
+	if (drm_WARN_ON(dev, !format))
+		return MODE_ERROR;
+
+	pitch = drm_format_info_min_pitch(format, 0, mode->vdisplay);
+	if (!pitch)
+		return MODE_BAD_WIDTH;
+	if (bochs->fb_size / pitch < mode->hdisplay)
+		return MODE_MEM;
+
+	return MODE_OK;
+}
+
 static const struct drm_mode_config_funcs bochs_mode_config_funcs = {
 	.fb_create = drm_gem_fb_create_with_dirty,
+	.mode_valid = bochs_mode_config_mode_valid,
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
@@ -687,15 +707,8 @@  static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
 {
 	struct bochs_device *bochs;
 	struct drm_device *dev;
-	unsigned long fbsize;
 	int ret;
 
-	fbsize = pci_resource_len(pdev, 0);
-	if (fbsize < 4 * 1024 * 1024) {
-		DRM_ERROR("less than 4 MB video memory, ignoring device\n");
-		return -ENOMEM;
-	}
-
 	ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &bochs_driver);
 	if (ret)
 		return ret;