diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-06-29 21:00:17 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-06-29 21:00:17 +0300 |
commit | 1b722407a13b7f8658d2e26917791f32805980a2 (patch) | |
tree | 30aab582725a46e42843d75e2eb9ce4151f0f3ed /drivers/video/fbdev | |
parent | f8824e151fbfa0ac0a258015d606ea6f4a10251b (diff) | |
parent | 5ff2977b19769fd24b0cfbe7cbe4d5114b6106af (diff) | |
download | linux-1b722407a13b7f8658d2e26917791f32805980a2.tar.xz |
Merge tag 'drm-next-2023-06-29' of git://anongit.freedesktop.org/drm/drm
Pull drm updates from Dave Airlie:
"There is one set of patches to misc for a i915 gsc/mei proxy driver.
Otherwise it's mostly amdgpu/i915/msm, lots of hw enablement and lots
of refactoring.
core:
- replace strlcpy with strscpy
- EDID changes to support further conversion to struct drm_edid
- Move i915 DSC parameter code to common DRM helpers
- Add Colorspace functionality
aperture:
- ignore framebuffers with non-primary devices
fbdev:
- use fbdev i/o helpers
- add Kconfig options for fb_ops helpers
- use new fb io helpers directly in drivers
sysfs:
- export DRM connector ID
scheduler:
- Avoid an infinite loop
ttm:
- store function table in .rodata
- Add query for TTM mem limit
- Add NUMA awareness to pools
- Export ttm_pool_fini()
bridge:
- fsl-ldb: support i.MX6SX
- lt9211, lt9611: remove blanking packets
- tc358768: implement input bus formats, devm cleanups
- ti-snd65dsi86: implement wait_hpd_asserted
- analogix: fix endless probe loop
- samsung-dsim: support swapped clock, fix enabling, support var
clock
- display-connector: Add support for external power supply
- imx: Fix module linking
- tc358762: Support reset GPIO
panel:
- nt36523: Support Lenovo J606F
- st7703: Support Anbernic RG353V-V2
- InnoLux G070ACE-L01 support
- boe-tv101wum-nl6: Improve initialization
- sharp-ls043t1le001: Mode fixes
- simple: BOE EV121WXM-N10-1850, S6D7AA0
- Ampire AM-800480L1TMQW-T00H
- Rocktech RK043FN48H
- Starry himax83102-j02
- Starry ili9882t
amdgpu:
- add new ctx query flag to handle reset better
- add new query/set shadow buffer for rdna3
- DCN 3.2/3.1.x/3.0.x updates
- Enable DC_FP on loongarch
- PCIe fix for RDNA2
- improve DC FAMS/SubVP support for better power management
- partition support for lots of engines
- Take NUMA into account when allocating memory
- Add new DRM_AMDGPU_WERROR config parameter to help with CI
- Initial SMU13 overdrive support
- Add support for new colorspace KMS API
- W=1 fixes
amdkfd:
- Query TTM mem limit rather than hardcoding it
- GC 9.4.3 partition support
- Handle NUMA for partitions
- Add debugger interface for enabling gdb
- Add KFD event age tracking
radeon:
- Fix possible UAF
i915:
- new getparam for PXP support
- GSC/MEI proxy driver
- Meteorlake display enablement
- avoid clearing preallocated framebuffers with TTM
- implement framebuffer mmap support
- Disable sampler indirect state in bindless heap
- Enable fdinfo for GuC backends
- GuC loading and firmware table handling fixes
- Various refactors for multi-tile enablement
- Define MOCS and PAT tables for MTL
- GSC/MEI support for Meteorlake
- PMU multi-tile support
- Large driver kernel doc cleanup
- Allow VRR toggling and arbitrary refresh rates
- Support async flips on linear buffers on display ver 12+
- Expose CRTC CTM property on ILK/SNB/VLV
- New debugfs for display clock frequencies
- Hotplug refactoring
- Display refactoring
- I915_GEM_CREATE_EXT_SET_PAT for Mesa on Meteorlake
- Use large rings for compute contexts
- HuC loading for MTL
- Allow user to set cache at BO creation
- MTL powermanagement enhancements
- Switch to dedicated workqueues to stop using flush_scheduled_work()
- Move display runtime init under display/
- Remove 10bit gamma on desktop gen3 parts, they don't support it
habanalabs:
- uapi: return 0 for user queries if there was a h/w or f/w error
- Add pci health check when we lose connection with the firmware.
This can be used to distinguish between pci link down and firmware
getting stuck.
- Add more info to the error print when TPC interrupt occur.
- Firmware fixes
msm:
- Adreno A660 bindings
- SM8350 MDSS bindings fix
- Added support for DPU on sm6350 and sm6375 platforms
- Implemented tearcheck support to support vsync on SM150 and newer
platforms
- Enabled missing features (DSPP, DSC, split display) on sc8180x,
sc8280xp, sm8450
- Added support for DSI and 28nm DSI PHY on MSM8226 platform
- Added support for DSI on sm6350 and sm6375 platforms
- Added support for display controller on MSM8226 platform
- A690 GPU support
- Move cmdstream dumping out of fence signaling path
- a610 support
- Support for a6xx devices without GMU
nouveau:
- NULL ptr before deref fixes
armada:
- implement fbdev emulation as client
sun4i:
- fix mipi-dsi dotclock
- release clocks
vc4:
- rgb range toggle property
- BT601 / BT2020 HDMI support
vkms:
- convert to drmm helpers
- add reflection and rotation support
- fix rgb565 conversion
gma500:
- fix iomem access
shmobile:
- support renesas soc platform
- enable fbdev
mxsfb:
- Add support for i.MX93 LCDIF
stm:
- dsi: Use devm_ helper
- ltdc: Fix potential invalid pointer deref
renesas:
- Group drivers in renesas subdirectory to prepare for new platform
- Drop deprecated R-Car H3 ES1.x support
meson:
- Add support for MIPI DSI displays
virtio:
- add sync object support
mediatek:
- Add display binding document for MT6795"
* tag 'drm-next-2023-06-29' of git://anongit.freedesktop.org/drm/drm: (1791 commits)
drm/i915: Fix a NULL vs IS_ERR() bug
drm/i915: make i915_drm_client_fdinfo() reference conditional again
drm/i915/huc: Fix missing error code in intel_huc_init()
drm/i915/gsc: take a wakeref for the proxy-init-completion check
drm/msm/a6xx: Add A610 speedbin support
drm/msm/a6xx: Add A619_holi speedbin support
drm/msm/a6xx: Use adreno_is_aXYZ macros in speedbin matching
drm/msm/a6xx: Use "else if" in GPU speedbin rev matching
drm/msm/a6xx: Fix some A619 tunables
drm/msm/a6xx: Add A610 support
drm/msm/a6xx: Add support for A619_holi
drm/msm/adreno: Disable has_cached_coherent in GMU wrapper configurations
drm/msm/a6xx: Introduce GMU wrapper support
drm/msm/a6xx: Move CX GMU power counter enablement to hw_init
drm/msm/a6xx: Extend and explain UBWC config
drm/msm/a6xx: Remove both GBIF and RBBM GBIF halt on hw init
drm/msm/a6xx: Add a helper for software-resetting the GPU
drm/msm/a6xx: Improve a6xx_bus_clear_pending_transactions()
drm/msm/a6xx: Move a6xx_bus_clear_pending_transactions to a6xx_gpu
drm/msm/a6xx: Move force keepalive vote removal to a6xx_gmu_force_off()
...
Diffstat (limited to 'drivers/video/fbdev')
33 files changed, 330 insertions, 653 deletions
diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 0fdf5f46802c..6df9bd09454a 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -158,6 +158,27 @@ config FB_DEFERRED_IO bool depends on FB +config FB_IO_HELPERS + bool + depends on FB + select FB_CFB_COPYAREA + select FB_CFB_FILLRECT + select FB_CFB_IMAGEBLIT + +config FB_SYS_HELPERS + bool + depends on FB + select FB_SYS_COPYAREA + select FB_SYS_FILLRECT + select FB_SYS_FOPS + select FB_SYS_IMAGEBLIT + +config FB_SYS_HELPERS_DEFERRED + bool + depends on FB + select FB_DEFERRED_IO + select FB_SYS_HELPERS + config FB_HECUBA tristate depends on FB @@ -551,10 +572,9 @@ config FB_STI select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select STI_CORE default y help - STI refers to the HP "Standard Text Interface" which is a set of - BIOS routines contained in a ROM chip in HP PA-RISC based machines. Enabling this option will implement the linux framebuffer device using calls to the STI BIOS routines for initialisation. diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c index 08d15e408413..9aaea3be8281 100644 --- a/drivers/video/fbdev/arcfb.c +++ b/drivers/video/fbdev/arcfb.c @@ -41,6 +41,7 @@ #include <linux/vmalloc.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include <linux/io.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/arcfb.h> @@ -260,7 +261,7 @@ static void arcfb_lcd_update_page(struct arcfb_par *par, unsigned int upper, ks108_set_yaddr(par, chipindex, upper/8); linesize = par->info->var.xres/8; - src = (unsigned char __force *) par->info->screen_base + (left/8) + + src = (unsigned char *)par->info->screen_buffer + (left/8) + (upper * linesize); ks108_set_xaddr(par, chipindex, left); @@ -451,6 +452,9 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf, struct arcfb_par *par; unsigned int xres; + if (!info->screen_buffer) + return -ENODEV; + p = *ppos; par = info->par; xres = info->var.xres; @@ -468,7 +472,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf, if (count) { char *base_addr; - base_addr = (char __force *)info->screen_base; + base_addr = info->screen_buffer; count -= copy_from_user(base_addr + p, buf, count); *ppos += count; err = -EFAULT; @@ -525,7 +529,7 @@ static int arcfb_probe(struct platform_device *dev) if (!info) goto err_fb_alloc; - info->screen_base = (char __iomem *)videomemory; + info->screen_buffer = videomemory; info->fbops = &arcfb_ops; info->var = arcfb_var; @@ -598,7 +602,7 @@ static void arcfb_remove(struct platform_device *dev) unregister_framebuffer(info); if (irq) free_irq(((struct arcfb_par *)(info->par))->irq, info); - vfree((void __force *)info->screen_base); + vfree(info->screen_buffer); framebuffer_release(info); } } diff --git a/drivers/video/fbdev/aty/atyfb.h b/drivers/video/fbdev/aty/atyfb.h index 465f55beb97f..30da3e82ed3c 100644 --- a/drivers/video/fbdev/aty/atyfb.h +++ b/drivers/video/fbdev/aty/atyfb.h @@ -3,8 +3,10 @@ * ATI Frame Buffer Device Driver Core Definitions */ +#include <linux/io.h> #include <linux/spinlock.h> #include <linux/wait.h> + /* * Elements of the hardware specific atyfb_par structure */ diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c index 4ad0331a8c57..971355c2cd7e 100644 --- a/drivers/video/fbdev/aty/mach64_cursor.c +++ b/drivers/video/fbdev/aty/mach64_cursor.c @@ -153,7 +153,7 @@ static int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor) u8 m, b; // Clear cursor image with 1010101010... - fb_memset(dst, 0xaa, 1024); + fb_memset_io(dst, 0xaa, 1024); offset = align - width*2; diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c index aed88ce45bf0..5c232eb13724 100644 --- a/drivers/video/fbdev/au1200fb.c +++ b/drivers/video/fbdev/au1200fb.c @@ -1568,7 +1568,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev) fbi->fix.mmio_len = 0; fbi->fix.accel = FB_ACCEL_NONE; - fbi->screen_base = (char __iomem *) fbdev->fb_mem; + fbi->screen_buffer = fbdev->fb_mem; au1200fb_update_fbinfo(fbi); diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c index 678d182d187d..06403a4fe0e3 100644 --- a/drivers/video/fbdev/broadsheetfb.c +++ b/drivers/video/fbdev/broadsheetfb.c @@ -824,7 +824,7 @@ static void broadsheet_init_display(struct broadsheetfb_par *par) broadsheet_burst_write(par, (panel_table[par->panel_index].w * panel_table[par->panel_index].h)/2, - (u16 *) par->info->screen_base); + (u16 *)par->info->screen_buffer); broadsheet_send_command(par, BS_CMD_LD_IMG_END); @@ -865,7 +865,7 @@ static void broadsheetfb_dpy_update_pages(struct broadsheetfb_par *par, u16 y1, u16 y2) { u16 args[5]; - unsigned char *buf = (unsigned char *)par->info->screen_base; + unsigned char *buf = par->info->screen_buffer; mutex_lock(&(par->io_lock)); /* y1 must be a multiple of 4 so drop the lower bits */ @@ -913,7 +913,7 @@ static void broadsheetfb_dpy_update(struct broadsheetfb_par *par) broadsheet_send_cmdargs(par, BS_CMD_WR_REG, 1, args); broadsheet_burst_write(par, (panel_table[par->panel_index].w * panel_table[par->panel_index].h)/2, - (u16 *) par->info->screen_base); + (u16 *)par->info->screen_buffer); broadsheet_send_command(par, BS_CMD_LD_IMG_END); @@ -1013,8 +1013,8 @@ static ssize_t broadsheetfb_write(struct fb_info *info, const char __user *buf, int err = 0; unsigned long total_size; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; + if (!info->screen_buffer) + return -ENODEV; total_size = info->fix.smem_len; @@ -1033,7 +1033,7 @@ static ssize_t broadsheetfb_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - dst = (void *)(info->screen_base + p); + dst = info->screen_buffer + p; if (copy_from_user(dst, buf, count)) err = -EFAULT; @@ -1109,7 +1109,7 @@ static int broadsheetfb_probe(struct platform_device *dev) if (!videomemory) goto err_fb_rel; - info->screen_base = (char *)videomemory; + info->screen_buffer = videomemory; info->fbops = &broadsheetfb_ops; broadsheetfb_var.xres = dpyw; @@ -1205,7 +1205,7 @@ static void broadsheetfb_remove(struct platform_device *dev) fb_deferred_io_cleanup(info); par->board->cleanup(par); fb_dealloc_cmap(&info->cmap); - vfree((void *)info->screen_base); + vfree(info->screen_buffer); module_put(par->board->owner); framebuffer_release(info); } diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c index 7799d52a651f..2a27ba94f652 100644 --- a/drivers/video/fbdev/chipsfb.c +++ b/drivers/video/fbdev/chipsfb.c @@ -332,7 +332,7 @@ static const struct fb_var_screeninfo chipsfb_var = { static void init_chips(struct fb_info *p, unsigned long addr) { - fb_memset(p->screen_base, 0, 0x100000); + fb_memset_io(p->screen_base, 0, 0x100000); p->fix = chipsfb_fix; p->fix.smem_start = addr; diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c index feeace079425..3d59a01ec677 100644 --- a/drivers/video/fbdev/cobalt_lcdfb.c +++ b/drivers/video/fbdev/cobalt_lcdfb.c @@ -129,6 +129,9 @@ static ssize_t cobalt_lcdfb_read(struct fb_info *info, char __user *buf, unsigned long pos; int len, retval = 0; + if (!info->screen_base) + return -ENODEV; + pos = *ppos; if (pos >= LCD_CHARS_MAX || count == 0) return 0; @@ -175,6 +178,9 @@ static ssize_t cobalt_lcdfb_write(struct fb_info *info, const char __user *buf, unsigned long pos; int len, retval = 0; + if (!info->screen_base) + return -ENODEV; + pos = *ppos; if (pos >= LCD_CHARS_MAX || count == 0) return 0; diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile index 08fabce76b74..8f0060160ffb 100644 --- a/drivers/video/fbdev/core/Makefile +++ b/drivers/video/fbdev/core/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_FB_NOTIFY) += fb_notify.o obj-$(CONFIG_FB) += fb.o fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ - modedb.o fbcvt.o fb_cmdline.o + modedb.o fbcvt.o fb_cmdline.o fb_io_fops.o fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE),y) diff --git a/drivers/video/fbdev/core/fb_io_fops.c b/drivers/video/fbdev/core/fb_io_fops.c new file mode 100644 index 000000000000..5985e5e1b040 --- /dev/null +++ b/drivers/video/fbdev/core/fb_io_fops.c @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/fb.h> +#include <linux/module.h> +#include <linux/uaccess.h> + +ssize_t fb_io_read(struct fb_info *info, char __user *buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + u8 *buffer, *dst; + u8 __iomem *src; + int c, cnt = 0, err = 0; + unsigned long total_size, trailing; + + if (!info->screen_base) + return -ENODEV; + + total_size = info->screen_size; + + if (total_size == 0) + total_size = info->fix.smem_len; + + if (p >= total_size) + return 0; + + if (count >= total_size) + count = total_size; + + if (count + p > total_size) + count = total_size - p; + + buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, + GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + src = (u8 __iomem *) (info->screen_base + p); + + if (info->fbops->fb_sync) + info->fbops->fb_sync(info); + + while (count) { + c = (count > PAGE_SIZE) ? PAGE_SIZE : count; + dst = buffer; + fb_memcpy_fromio(dst, src, c); + dst += c; + src += c; + + trailing = copy_to_user(buf, buffer, c); + if (trailing == c) { + err = -EFAULT; + break; + } + c -= trailing; + + *ppos += c; + buf += c; + cnt += c; + count -= c; + } + + kfree(buffer); + + return cnt ? cnt : err; +} +EXPORT_SYMBOL(fb_io_read); + +ssize_t fb_io_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + u8 *buffer, *src; + u8 __iomem *dst; + int c, cnt = 0, err = 0; + unsigned long total_size, trailing; + + if (!info->screen_base) + return -ENODEV; + + total_size = info->screen_size; + + if (total_size == 0) + total_size = info->fix.smem_len; + + if (p > total_size) + return -EFBIG; + + if (count > total_size) { + err = -EFBIG; + count = total_size; + } + + if (count + p > total_size) { + if (!err) + err = -ENOSPC; + + count = total_size - p; + } + + buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, + GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + dst = (u8 __iomem *) (info->screen_base + p); + + if (info->fbops->fb_sync) + info->fbops->fb_sync(info); + + while (count) { + c = (count > PAGE_SIZE) ? PAGE_SIZE : count; + src = buffer; + + trailing = copy_from_user(src, buf, c); + if (trailing == c) { + err = -EFAULT; + break; + } + c -= trailing; + + fb_memcpy_toio(dst, src, c); + dst += c; + src += c; + *ppos += c; + buf += c; + cnt += c; + count -= c; + } + + kfree(buffer); + + return (cnt) ? cnt : err; +} +EXPORT_SYMBOL(fb_io_write); diff --git a/drivers/video/fbdev/core/fb_sys_fops.c b/drivers/video/fbdev/core/fb_sys_fops.c index ff275d7f3eaf..0cb0989abda6 100644 --- a/drivers/video/fbdev/core/fb_sys_fops.c +++ b/drivers/video/fbdev/core/fb_sys_fops.c @@ -19,10 +19,11 @@ ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count, unsigned long p = *ppos; void *src; int err = 0; - unsigned long total_size; + unsigned long total_size, c; + ssize_t ret; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; + if (!info->screen_buffer) + return -ENODEV; total_size = info->screen_size; @@ -38,18 +39,19 @@ ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count, if (count + p > total_size) count = total_size - p; - src = (void __force *)(info->screen_base + p); + src = info->screen_buffer + p; if (info->fbops->fb_sync) info->fbops->fb_sync(info); - if (copy_to_user(buf, src, count)) + c = copy_to_user(buf, src, count); + if (c) err = -EFAULT; + ret = count - c; - if (!err) - *ppos += count; + *ppos += ret; - return (err) ? err : count; + return ret ? ret : err; } EXPORT_SYMBOL_GPL(fb_sys_read); @@ -59,10 +61,11 @@ ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, unsigned long p = *ppos; void *dst; int err = 0; - unsigned long total_size; + unsigned long total_size, c; + size_t ret; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; + if (!info->screen_buffer) + return -ENODEV; total_size = info->screen_size; @@ -84,18 +87,19 @@ ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - dst = (void __force *) (info->screen_base + p); + dst = info->screen_buffer + p; if (info->fbops->fb_sync) info->fbops->fb_sync(info); - if (copy_from_user(dst, buf, count)) + c = copy_from_user(dst, buf, count); + if (c) err = -EFAULT; + ret = count - c; - if (!err) - *ppos += count; + *ppos += ret; - return (err) ? err : count; + return ret ? ret : err; } EXPORT_SYMBOL_GPL(fb_sys_write); diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index eb565a10e5cd..c6c9d040bdec 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -75,7 +75,6 @@ #include <linux/interrupt.h> #include <linux/crc32.h> /* For counting font checksums */ #include <linux/uaccess.h> -#include <asm/fb.h> #include <asm/irq.h> #include "fbcon.h" diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 28739f1cb5e7..329d16e49a90 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -37,8 +37,6 @@ #include <linux/mem_encrypt.h> #include <linux/pci.h> -#include <asm/fb.h> - #include <video/nomodeset.h> #include <video/vga.h> @@ -761,14 +759,9 @@ static struct fb_info *file_fb_info(struct file *file) static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - unsigned long p = *ppos; struct fb_info *info = file_fb_info(file); - u8 *buffer, *dst; - u8 __iomem *src; - int c, cnt = 0, err = 0; - unsigned long total_size; - if (!info || ! info->screen_base) + if (!info) return -ENODEV; if (info->state != FBINFO_STATE_RUNNING) @@ -777,63 +770,15 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) if (info->fbops->fb_read) return info->fbops->fb_read(info, buf, count, ppos); - total_size = info->screen_size; - - if (total_size == 0) - total_size = info->fix.smem_len; - - if (p >= total_size) - return 0; - - if (count >= total_size) - count = total_size; - - if (count + p > total_size) - count = total_size - p; - - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, - GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - src = (u8 __iomem *) (info->screen_base + p); - - if (info->fbops->fb_sync) - info->fbops->fb_sync(info); - - while (count) { - c = (count > PAGE_SIZE) ? PAGE_SIZE : count; - dst = buffer; - fb_memcpy_fromfb(dst, src, c); - dst += c; - src += c; - - if (copy_to_user(buf, buffer, c)) { - err = -EFAULT; - break; - } - *ppos += c; - buf += c; - cnt += c; - count -= c; - } - - kfree(buffer); - - return (err) ? err : cnt; + return fb_io_read(info, buf, count, ppos); } static ssize_t fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - unsigned long p = *ppos; struct fb_info *info = file_fb_info(file); - u8 *buffer, *src; - u8 __iomem *dst; - int c, cnt = 0, err = 0; - unsigned long total_size; - if (!info || !info->screen_base) + if (!info) return -ENODEV; if (info->state != FBINFO_STATE_RUNNING) @@ -842,57 +787,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) if (info->fbops->fb_write) return info->fbops->fb_write(info, buf, count, ppos); - total_size = info->screen_size; - - if (total_size == 0) - total_size = info->fix.smem_len; - - if (p > total_size) - return -EFBIG; - - if (count > total_size) { - err = -EFBIG; - count = total_size; - } - - if (count + p > total_size) { - if (!err) - err = -ENOSPC; - - count = total_size - p; - } - - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, - GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - dst = (u8 __iomem *) (info->screen_base + p); - - if (info->fbops->fb_sync) - info->fbops->fb_sync(info); - - while (count) { - c = (count > PAGE_SIZE) ? PAGE_SIZE : count; - src = buffer; - - if (copy_from_user(src, buf, c)) { - err = -EFAULT; - break; - } - - fb_memcpy_tofb(dst, src, c); - dst += c; - src += c; - *ppos += c; - buf += c; - cnt += c; - count -= c; - } - - kfree(buffer); - - return (cnt) ? cnt : err; + return fb_io_write(info, buf, count, ppos); } int diff --git a/drivers/video/fbdev/hecubafb.c b/drivers/video/fbdev/hecubafb.c index 5a149458d3b4..7ce0a16ce8b9 100644 --- a/drivers/video/fbdev/hecubafb.c +++ b/drivers/video/fbdev/hecubafb.c @@ -102,7 +102,7 @@ static void apollo_send_command(struct hecubafb_par *par, unsigned char data) static void hecubafb_dpy_update(struct hecubafb_par *par) { int i; - unsigned char *buf = (unsigned char __force *)par->info->screen_base; + unsigned char *buf = par->info->screen_buffer; apollo_send_command(par, APOLLO_START_NEW_IMG); @@ -163,8 +163,8 @@ static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf, int err = 0; unsigned long total_size; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; + if (!info->screen_buffer) + return -ENODEV; total_size = info->fix.smem_len; @@ -183,7 +183,7 @@ static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - dst = (void __force *) (info->screen_base + p); + dst = info->screen_buffer + p; if (copy_from_user(dst, buf, count)) err = -EFAULT; @@ -239,7 +239,7 @@ static int hecubafb_probe(struct platform_device *dev) if (!info) goto err_fballoc; - info->screen_base = (char __force __iomem *)videomemory; + info->screen_buffer = videomemory; info->fbops = &hecubafb_ops; info->var = hecubafb_var; @@ -287,7 +287,7 @@ static void hecubafb_remove(struct platform_device *dev) struct hecubafb_par *par = info->par; fb_deferred_io_cleanup(info); unregister_framebuffer(info); - vfree((void __force *)info->screen_base); + vfree(info->screen_buffer); if (par->board->remove) par->board->remove(par); module_put(par->board->owner); diff --git a/drivers/video/fbdev/hitfb.c b/drivers/video/fbdev/hitfb.c index 5f544a177033..9fd196637d14 100644 --- a/drivers/video/fbdev/hitfb.c +++ b/drivers/video/fbdev/hitfb.c @@ -42,17 +42,33 @@ static struct fb_fix_screeninfo hitfb_fix = { .accel = FB_ACCEL_NONE, }; +static volatile void __iomem *hitfb_offset_to_addr(unsigned int offset) +{ + return (__force volatile void __iomem *)(uintptr_t)offset; +} + +static u16 hitfb_readw(unsigned int offset) +{ + return fb_readw(hitfb_offset_to_addr(offset)); +} + +static void hitfb_writew(u16 value, unsigned int offset) +{ + fb_writew(value, hitfb_offset_to_addr(offset)); +} + static inline void hitfb_accel_wait(void) { - while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) ; + while (hitfb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) + ; } static inline void hitfb_accel_start(int truecolor) { if (truecolor) { - fb_writew(6, HD64461_GRCFGR); + hitfb_writew(6, HD64461_GRCFGR); } else { - fb_writew(7, HD64461_GRCFGR); + hitfb_writew(7, HD64461_GRCFGR); } } @@ -63,11 +79,11 @@ static inline void hitfb_accel_set_dest(int truecolor, u16 dx, u16 dy, if (truecolor) saddr <<= 1; - fb_writew(width-1, HD64461_BBTDWR); - fb_writew(height-1, HD64461_BBTDHR); + hitfb_writew(width-1, HD64461_BBTDWR); + hitfb_writew(height-1, HD64461_BBTDHR); - fb_writew(saddr & 0xffff, HD64461_BBTDSARL); - fb_writew(saddr >> 16, HD64461_BBTDSARH); + hitfb_writew(saddr & 0xffff, HD64461_BBTDSARL); + hitfb_writew(saddr >> 16, HD64461_BBTDSARH); } @@ -80,7 +96,7 @@ static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx, height--; width--; - fb_writew(rop, HD64461_BBTROPR); + hitfb_writew(rop, HD64461_BBTROPR); if ((sy < dy) || ((sy == dy) && (sx <= dx))) { saddr = WIDTH * (sy + height) + sx + width; daddr = WIDTH * (dy + height) + dx + width; @@ -91,32 +107,32 @@ static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx, maddr = (((width >> 4) + 1) * (height + 1) - 1) * 2; - fb_writew((1 << 5) | 1, HD64461_BBTMDR); + hitfb_writew((1 << 5) | 1, HD64461_BBTMDR); } else - fb_writew(1, HD64461_BBTMDR); + hitfb_writew(1, HD64461_BBTMDR); } else { saddr = WIDTH * sy + sx; daddr = WIDTH * dy + dx; if (mask_addr) { - fb_writew((1 << 5), HD64461_BBTMDR); + hitfb_writew((1 << 5), HD64461_BBTMDR); } else { - fb_writew(0, HD64461_BBTMDR); + hitfb_writew(0, HD64461_BBTMDR); } } if (truecolor) { saddr <<= 1; daddr <<= 1; } - fb_writew(width, HD64461_BBTDWR); - fb_writew(height, HD64461_BBTDHR); - fb_writew(saddr & 0xffff, HD64461_BBTSSARL); - fb_writew(saddr >> 16, HD64461_BBTSSARH); - fb_writew(daddr & 0xffff, HD64461_BBTDSARL); - fb_writew(daddr >> 16, HD64461_BBTDSARH); + hitfb_writew(width, HD64461_BBTDWR); + hitfb_writew(height, HD64461_BBTDHR); + hitfb_writew(saddr & 0xffff, HD64461_BBTSSARL); + hitfb_writew(saddr >> 16, HD64461_BBTSSARH); + hitfb_writew(daddr & 0xffff, HD64461_BBTDSARL); + hitfb_writew(daddr >> 16, HD64461_BBTDSARH); if (mask_addr) { maddr += mask_addr; - fb_writew(maddr & 0xffff, HD64461_BBTMARL); - fb_writew(maddr >> 16, HD64461_BBTMARH); + hitfb_writew(maddr & 0xffff, HD64461_BBTMARL); + hitfb_writew(maddr >> 16, HD64461_BBTMARH); } hitfb_accel_start(truecolor); } @@ -127,17 +143,17 @@ static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) cfb_fillrect(p, rect); else { hitfb_accel_wait(); - fb_writew(0x00f0, HD64461_BBTROPR); - fb_writew(16, HD64461_BBTMDR); + hitfb_writew(0x00f0, HD64461_BBTROPR); + hitfb_writew(16, HD64461_BBTMDR); if (p->var.bits_per_pixel == 16) { - fb_writew(((u32 *) (p->pseudo_palette))[rect->color], + hitfb_writew(((u32 *) (p->pseudo_palette))[rect->color], HD64461_GRSCR); hitfb_accel_set_dest(1, rect->dx, rect->dy, rect->width, rect->height); hitfb_accel_start(1); } else { - fb_writew(rect->color, HD64461_GRSCR); + hitfb_writew(rect->color, HD64461_GRSCR); hitfb_accel_set_dest(0, rect->dx, rect->dy, rect->width, rect->height); hitfb_accel_start(0); @@ -162,7 +178,7 @@ static int hitfb_pan_display(struct fb_var_screeninfo *var, if (xoffset != 0) return -EINVAL; - fb_writew((yoffset*info->fix.line_length)>>10, HD64461_LCDCBAR); + hitfb_writew((yoffset*info->fix.line_length)>>10, HD64461_LCDCBAR); return 0; } @@ -172,33 +188,33 @@ static int hitfb_blank(int blank_mode, struct fb_info *info) unsigned short v; if (blank_mode) { - v = fb_readw(HD64461_LDR1); + v = hitfb_readw(HD64461_LDR1); v &= ~HD64461_LDR1_DON; - fb_writew(v, HD64461_LDR1); + hitfb_writew(v, HD64461_LDR1); - v = fb_readw(HD64461_LCDCCR); + v = hitfb_readw(HD64461_LCDCCR); v |= HD64461_LCDCCR_MOFF; - fb_writew(v, HD64461_LCDCCR); + hitfb_writew(v, HD64461_LCDCCR); - v = fb_readw(HD64461_STBCR); + v = hitfb_readw(HD64461_STBCR); v |= HD64461_STBCR_SLCDST; - fb_writew(v, HD64461_STBCR); + hitfb_writew(v, HD64461_STBCR); } else { - v = fb_readw(HD64461_STBCR); + v = hitfb_readw(HD64461_STBCR); v &= ~HD64461_STBCR_SLCDST; - fb_writew(v, HD64461_STBCR); + hitfb_writew(v, HD64461_STBCR); - v = fb_readw(HD64461_LCDCCR); + v = hitfb_readw(HD64461_LCDCCR); v &= ~(HD64461_LCDCCR_MOFF | HD64461_LCDCCR_STREQ); - fb_writew(v, HD64461_LCDCCR); + hitfb_writew(v, HD64461_LCDCCR); do { - v = fb_readw(HD64461_LCDCCR); + v = hitfb_readw(HD64461_LCDCCR); } while(v&HD64461_LCDCCR_STBACK); - v = fb_readw(HD64461_LDR1); + v = hitfb_readw(HD64461_LDR1); v |= HD64461_LDR1_DON; - fb_writew(v, HD64461_LDR1); + hitfb_writew(v, HD64461_LDR1); } return 0; } @@ -211,10 +227,10 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green, switch (info->var.bits_per_pixel) { case 8: - fb_writew(regno << 8, HD64461_CPTWAR); - fb_writew(red >> 10, HD64461_CPTWDR); - fb_writew(green >> 10, HD64461_CPTWDR); - fb_writew(blue >> 10, HD64461_CPTWDR); + hitfb_writew(regno << 8, HD64461_CPTWAR); + hitfb_writew(red >> 10, HD64461_CPTWDR); + hitfb_writew(green >> 10, HD64461_CPTWDR); + hitfb_writew(blue >> 10, HD64461_CPTWDR); break; case 16: if (regno >= 16) @@ -302,11 +318,11 @@ static int hitfb_set_par(struct fb_info *info) break; } - fb_writew(info->fix.line_length, HD64461_LCDCLOR); - ldr3 = fb_readw(HD64461_LDR3); + hitfb_writew(info->fix.line_length, HD64461_LCDCLOR); + ldr3 = hitfb_readw(HD64461_LDR3); ldr3 &= ~15; ldr3 |= (info->var.bits_per_pixel == 8) ? 4 : 8; - fb_writew(ldr3, HD64461_LDR3); + hitfb_writew(ldr3, HD64461_LDR3); return 0; } @@ -337,9 +353,9 @@ static int hitfb_probe(struct platform_device *dev) hitfb_fix.smem_start = HD64461_IO_OFFSET(0x02000000); hitfb_fix.smem_len = 512 * 1024; - lcdclor = fb_readw(HD64461_LCDCLOR); - ldvndr = fb_readw(HD64461_LDVNDR); - ldr3 = fb_readw(HD64461_LDR3); + lcdclor = hitfb_readw(HD64461_LCDCLOR); + ldvndr = hitfb_readw(HD64461_LDVNDR); + ldr3 = hitfb_readw(HD64461_LDR3); switch (ldr3 & 15) { default: @@ -429,9 +445,9 @@ static int hitfb_suspend(struct device *dev) u16 v; hitfb_blank(1, NULL); - v = fb_readw(HD64461_STBCR); + v = hitfb_readw(HD64461_STBCR); v |= HD64461_STBCR_SLCKE_IST; - fb_writew(v, HD64461_STBCR); + hitfb_writew(v, HD64461_STBCR); return 0; } @@ -440,12 +456,12 @@ static int hitfb_resume(struct device *dev) { u16 v; - v = fb_readw(HD64461_STBCR); + v = hitfb_readw(HD64461_STBCR); v &= ~HD64461_STBCR_SLCKE_OST; msleep(100); - v = fb_readw(HD64461_STBCR); + v = hitfb_readw(HD64461_STBCR); v &= ~HD64461_STBCR_SLCKE_IST; - fb_writew(v, HD64461_STBCR); + hitfb_writew(v, HD64461_STBCR); hitfb_blank(0, NULL); return 0; diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 34781dec3856..1ae35ab62b29 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1073,7 +1073,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) info->screen_size = dio_fb_size; getmem_done: - aperture_remove_conflicting_devices(base, size, false, KBUILD_MODNAME); + aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME); if (gen2vm) { /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */ diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index 0596573ef140..3f277bdb3a32 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -737,7 +737,7 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) info->var.bits_per_pixel); size *= info->var.yres_virtual; - fb_memset(info->screen_base, 0, size); + fb_memset_io(info->screen_base, 0, size); if (register_framebuffer(info) < 0) goto out_unmap; diff --git a/drivers/video/fbdev/matrox/matroxfb_accel.c b/drivers/video/fbdev/matrox/matroxfb_accel.c index 9cb0685feddd..ce51227798a1 100644 --- a/drivers/video/fbdev/matrox/matroxfb_accel.c +++ b/drivers/video/fbdev/matrox/matroxfb_accel.c @@ -88,7 +88,7 @@ static inline void matrox_cfb4_pal(u_int32_t* pal) { unsigned int i; - + for (i = 0; i < 16; i++) { pal[i] = i * 0x11111111U; } @@ -96,7 +96,7 @@ static inline void matrox_cfb4_pal(u_int32_t* pal) { static inline void matrox_cfb8_pal(u_int32_t* pal) { unsigned int i; - + for (i = 0; i < 16; i++) { pal[i] = i * 0x01010101U; } @@ -482,7 +482,7 @@ static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx, /* Tell... well, why bother... */ while (height--) { size_t i; - + for (i = 0; i < step; i += 4) { /* Hope that there are at least three readable bytes beyond the end of bitmap */ fb_writel(get_unaligned((u_int32_t*)(chardata + i)),mmio.vaddr); diff --git a/drivers/video/fbdev/matrox/matroxfb_base.h b/drivers/video/fbdev/matrox/matroxfb_base.h index 958be6805f87..c93c69bbcd57 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.h +++ b/drivers/video/fbdev/matrox/matroxfb_base.h @@ -301,9 +301,9 @@ struct matrox_altout { int (*verifymode)(void* altout_dev, u_int32_t mode); int (*getqueryctrl)(void* altout_dev, struct v4l2_queryctrl* ctrl); - int (*getctrl)(void* altout_dev, + int (*getctrl)(void *altout_dev, struct v4l2_control* ctrl); - int (*setctrl)(void* altout_dev, + int (*setctrl)(void *altout_dev, struct v4l2_control* ctrl); }; diff --git a/drivers/video/fbdev/metronomefb.c b/drivers/video/fbdev/metronomefb.c index 4e50882d080c..ebdb4949c4ac 100644 --- a/drivers/video/fbdev/metronomefb.c +++ b/drivers/video/fbdev/metronomefb.c @@ -438,7 +438,7 @@ static void metronomefb_dpy_update(struct metronomefb_par *par) { int fbsize; u16 cksum; - unsigned char *buf = (unsigned char __force *)par->info->screen_base; + unsigned char *buf = par->info->screen_buffer; fbsize = par->info->fix.smem_len; /* copy from vm to metromem */ @@ -453,7 +453,7 @@ static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index) { int i; u16 csum = 0; - u16 *buf = (u16 __force *)(par->info->screen_base + index); + u16 *buf = (u16 *)(par->info->screen_buffer + index); u16 *img = (u16 *)(par->metromem_img + index); /* swizzle from vm to metromem and recalc cksum at the same time*/ @@ -523,8 +523,8 @@ static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf, int err = 0; unsigned long total_size; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; + if (!info->screen_buffer) + return -ENODEV; total_size = info->fix.smem_len; @@ -543,7 +543,7 @@ static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - dst = (void __force *)(info->screen_base + p); + dst = info->screen_buffer + p; if (copy_from_user(dst, buf, count)) err = -EFAULT; @@ -599,7 +599,7 @@ static int metronomefb_probe(struct platform_device *dev) goto err; /* we have two blocks of memory. - info->screen_base which is vm, and is the fb used by apps. + info->screen_buffer which is vm, and is the fb used by apps. par->metromem which is physically contiguous memory and contains the display controller commands, waveform, processed image data and padding. this is the data pulled @@ -634,7 +634,7 @@ static int metronomefb_probe(struct platform_device *dev) if (!videomemory) goto err_fb_rel; - info->screen_base = (char __force __iomem *)videomemory; + info->screen_buffer = videomemory; info->fbops = &metronomefb_ops; metronomefb_fix.line_length = fw; @@ -756,7 +756,7 @@ static void metronomefb_remove(struct platform_device *dev) fb_dealloc_cmap(&info->cmap); par->board->cleanup(par); vfree(par->csum_table); - vfree((void __force *)info->screen_base); + vfree(info->screen_buffer); module_put(par->board->owner); dev_dbg(&dev->dev, "calling release\n"); framebuffer_release(info); diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c index 98aaa330a193..d4abcf8aff75 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -650,7 +650,7 @@ static int ps3fb_set_par(struct fb_info *info) } /* Clear XDR frame buffer memory */ - memset((void __force *)info->screen_base, 0, info->fix.smem_len); + memset(info->screen_buffer, 0, info->fix.smem_len); /* Clear DDR frame buffer memory */ lines = vmode->yres * par->num_frames; @@ -1140,7 +1140,7 @@ static int ps3fb_probe(struct ps3_system_bus_device *dev) * memory */ fb_start = ps3fb_videomemory.address + GPU_FB_START; - info->screen_base = (char __force __iomem *)fb_start; + info->screen_buffer = fb_start; info->fix.smem_start = __pa(fb_start); info->fix.smem_len = ps3fb_videomemory.size - GPU_FB_START; diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index 6888127a5eb8..c692cd597ce3 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -647,6 +647,9 @@ static ssize_t pvr2fb_write(struct fb_info *info, const char *buf, struct page **pages; int ret, i; + if (!info->screen_base) + return -ENODEV; + nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT; pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); @@ -798,7 +801,7 @@ static int __maybe_unused pvr2fb_common_init(void) goto out_err; } - fb_memset(fb_info->screen_base, 0, pvr2_fix.smem_len); + fb_memset_io(fb_info->screen_base, 0, pvr2_fix.smem_len); pvr2_fix.ypanstep = nopan ? 0 : 1; pvr2_fix.ywrapstep = nowrap ? 0 : 1; diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index b528776c7612..b7ad3c644e13 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1028,12 +1028,9 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf, int c, i, cnt = 0, err = 0; unsigned long total_size; - if (!info || !info->screen_base) + if (!info->screen_base) return -ENODEV; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; - total_size = info->screen_size; if (total_size == 0) @@ -1094,12 +1091,9 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf, int c, i, cnt = 0, err = 0; unsigned long total_size; - if (!info || !info->screen_base) + if (!info->screen_base) return -ENODEV; - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; - total_size = info->screen_size; if (total_size == 0) diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c index 2ad6e98ce10d..17cec62cc65d 100644 --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -1150,7 +1150,7 @@ static void ufx_free_framebuffer(struct ufx_data *dev) fb_dealloc_cmap(&info->cmap); if (info->monspecs.modedb) fb_destroy_modedb(info->monspecs.modedb); - vfree(info->screen_base); + vfree(info->screen_buffer); fb_destroy_modelist(&info->modelist); @@ -1257,7 +1257,7 @@ static int ufx_ops_set_par(struct fb_info *info) if ((result == 0) && (dev->fb_count == 0)) { /* paint greenscreen */ - pix_framebuffer = (u16 *) info->screen_base; + pix_framebuffer = (u16 *)info->screen_buffer; for (i = 0; i < info->fix.smem_len / 2; i++) pix_framebuffer[i] = 0x37e6; @@ -1303,7 +1303,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info) { int old_len = info->fix.smem_len; int new_len; - unsigned char *old_fb = info->screen_base; + unsigned char *old_fb = info->screen_buffer; unsigned char *new_fb; pr_debug("Reallocating framebuffer. Addresses will change!"); @@ -1318,12 +1318,12 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info) if (!new_fb) return -ENOMEM; - if (info->screen_base) { + if (info->screen_buffer) { memcpy(new_fb, old_fb, old_len); - vfree(info->screen_base); + vfree(info->screen_buffer); } - info->screen_base = new_fb; + info->screen_buffer = new_fb; info->fix.smem_len = PAGE_ALIGN(new_len); info->fix.smem_start = (unsigned long) new_fb; info->flags = smscufx_info_flags; @@ -1746,7 +1746,7 @@ reset_active: atomic_set(&dev->usb_active, 0); setup_modes: fb_destroy_modedb(info->monspecs.modedb); - vfree(info->screen_base); + vfree(info->screen_buffer); fb_destroy_modelist(&info->modelist); error: fb_dealloc_cmap(&info->cmap); diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 132d1a205011..11c373798279 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -301,6 +301,9 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf, void *dst; int ret; + if (!info->screen_buffer) + return -ENODEV; + total_size = info->fix.smem_len; if (p > total_size) diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index da296b2ab54a..582324f5d869 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -335,7 +335,7 @@ static int sst_calc_pll(const int freq, int *freq_out, struct pll_timing *t) static void sstfb_clear_screen(struct fb_info *info) { /* clear screen */ - fb_memset(info->screen_base, 0, info->fix.smem_len); + fb_memset_io(info->screen_base, 0, info->fix.smem_len); } diff --git a/drivers/video/fbdev/sticore.h b/drivers/video/fbdev/sticore.h deleted file mode 100644 index 0ebdd28a0b81..000000000000 --- a/drivers/video/fbdev/sticore.h +++ /dev/null @@ -1,404 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef STICORE_H -#define STICORE_H - -/* generic STI structures & functions */ - -#define MAX_STI_ROMS 4 /* max no. of ROMs which this driver handles */ - -#define STI_REGION_MAX 8 /* hardcoded STI constants */ -#define STI_DEV_NAME_LENGTH 32 -#define STI_MONITOR_MAX 256 - -#define STI_FONT_HPROMAN8 1 -#define STI_FONT_KANA8 2 - -#define ALT_CODE_TYPE_UNKNOWN 0x00 /* alt code type values */ -#define ALT_CODE_TYPE_PA_RISC_64 0x01 - -/* The latency of the STI functions cannot really be reduced by setting - * this to 0; STI doesn't seem to be designed to allow calling a different - * function (or the same function with different arguments) after a - * function exited with 1 as return value. - * - * As all of the functions below could be called from interrupt context, - * we have to spin_lock_irqsave around the do { ret = bla(); } while(ret==1) - * block. Really bad latency there. - * - * Probably the best solution to all this is have the generic code manage - * the screen buffer and a kernel thread to call STI occasionally. - * - * Luckily, the frame buffer guys have the same problem so we can just wait - * for them to fix it and steal their solution. prumpf - */ - -#include <asm/io.h> - -#define STI_WAIT 1 - -#define STI_PTR(p) ( virt_to_phys(p) ) -#define PTR_STI(p) ( phys_to_virt((unsigned long)p) ) - -#define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x) -#define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y) - -/* sti_font_xy() use the native font ROM ! */ -#define sti_font_x(sti) (PTR_STI(sti->font)->width) -#define sti_font_y(sti) (PTR_STI(sti->font)->height) - -#ifdef CONFIG_64BIT -#define STI_LOWMEM (GFP_KERNEL | GFP_DMA) -#else -#define STI_LOWMEM (GFP_KERNEL) -#endif - - -/* STI function configuration structs */ - -typedef union region { - struct { - u32 offset : 14; /* offset in 4kbyte page */ - u32 sys_only : 1; /* don't map to user space */ - u32 cache : 1; /* map to data cache */ - u32 btlb : 1; /* map to block tlb */ - u32 last : 1; /* last region in list */ - u32 length : 14; /* length in 4kbyte page */ - } region_desc; - - u32 region; /* complete region value */ -} region_t; - -#define REGION_OFFSET_TO_PHYS( rt, hpa ) \ - (((rt).region_desc.offset << 12) + (hpa)) - -struct sti_glob_cfg_ext { - u8 curr_mon; /* current monitor configured */ - u8 friendly_boot; /* in friendly boot mode */ - s16 power; /* power calculation (in Watts) */ - s32 freq_ref; /* frequency reference */ - u32 sti_mem_addr; /* pointer to global sti memory (size=sti_mem_request) */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_glob_cfg { - s32 text_planes; /* number of planes used for text */ - s16 onscreen_x; /* screen width in pixels */ - s16 onscreen_y; /* screen height in pixels */ - s16 offscreen_x; /* offset width in pixels */ - s16 offscreen_y; /* offset height in pixels */ - s16 total_x; /* frame buffer width in pixels */ - s16 total_y; /* frame buffer height in pixels */ - u32 region_ptrs[STI_REGION_MAX]; /* region pointers */ - s32 reent_lvl; /* storage for reentry level value */ - u32 save_addr; /* where to save or restore reentrant state */ - u32 ext_ptr; /* pointer to extended glob_cfg data structure */ -}; - - -/* STI init function structs */ - -struct sti_init_flags { - u32 wait : 1; /* should routine idle wait or not */ - u32 reset : 1; /* hard reset the device? */ - u32 text : 1; /* turn on text display planes? */ - u32 nontext : 1; /* turn on non-text display planes? */ - u32 clear : 1; /* clear text display planes? */ - u32 cmap_blk : 1; /* non-text planes cmap black? */ - u32 enable_be_timer : 1; /* enable bus error timer */ - u32 enable_be_int : 1; /* enable bus error timer interrupt */ - u32 no_chg_tx : 1; /* don't change text settings */ - u32 no_chg_ntx : 1; /* don't change non-text settings */ - u32 no_chg_bet : 1; /* don't change berr timer settings */ - u32 no_chg_bei : 1; /* don't change berr int settings */ - u32 init_cmap_tx : 1; /* initialize cmap for text planes */ - u32 cmt_chg : 1; /* change current monitor type */ - u32 retain_ie : 1; /* don't allow reset to clear int enables */ - u32 caller_bootrom : 1; /* set only by bootrom for each call */ - u32 caller_kernel : 1; /* set only by kernel for each call */ - u32 caller_other : 1; /* set only by non-[BR/K] caller */ - u32 pad : 14; /* pad to word boundary */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_init_inptr_ext { - u8 config_mon_type; /* configure to monitor type */ - u8 pad[1]; /* pad to word boundary */ - u16 inflight_data; /* inflight data possible on PCI */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_init_inptr { - s32 text_planes; /* number of planes to use for text */ - u32 ext_ptr; /* pointer to extended init_graph inptr data structure*/ -}; - - -struct sti_init_outptr { - s32 errno; /* error number on failure */ - s32 text_planes; /* number of planes used for text */ - u32 future_ptr; /* pointer to future data */ -}; - - - -/* STI configuration function structs */ - -struct sti_conf_flags { - u32 wait : 1; /* should routine idle wait or not */ - u32 pad : 31; /* pad to word boundary */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_conf_inptr { - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_conf_outptr_ext { - u32 crt_config[3]; /* hardware specific X11/OGL information */ - u32 crt_hdw[3]; - u32 future_ptr; -}; - -struct sti_conf_outptr { - s32 errno; /* error number on failure */ - s16 onscreen_x; /* screen width in pixels */ - s16 onscreen_y; /* screen height in pixels */ - s16 offscreen_x; /* offscreen width in pixels */ - s16 offscreen_y; /* offscreen height in pixels */ - s16 total_x; /* frame buffer width in pixels */ - s16 total_y; /* frame buffer height in pixels */ - s32 bits_per_pixel; /* bits/pixel device has configured */ - s32 bits_used; /* bits which can be accessed */ - s32 planes; /* number of fb planes in system */ - u8 dev_name[STI_DEV_NAME_LENGTH]; /* null terminated product name */ - u32 attributes; /* flags denoting attributes */ - u32 ext_ptr; /* pointer to future data */ -}; - -struct sti_rom { - u8 type[4]; - u8 res004; - u8 num_mons; - u8 revno[2]; - u32 graphics_id[2]; - - u32 font_start; - u32 statesize; - u32 last_addr; - u32 region_list; - - u16 reentsize; - u16 maxtime; - u32 mon_tbl_addr; - u32 user_data_addr; - u32 sti_mem_req; - - u32 user_data_size; - u16 power; - u8 bus_support; - u8 ext_bus_support; - u8 alt_code_type; - u8 ext_dd_struct[3]; - u32 cfb_addr; - - u32 init_graph; - u32 state_mgmt; - u32 font_unpmv; - u32 block_move; - u32 self_test; - u32 excep_hdlr; - u32 inq_conf; - u32 set_cm_entry; - u32 dma_ctrl; - u8 res040[7 * 4]; - - u32 init_graph_addr; - u32 state_mgmt_addr; - u32 font_unp_addr; - u32 block_move_addr; - u32 self_test_addr; - u32 excep_hdlr_addr; - u32 inq_conf_addr; - u32 set_cm_entry_addr; - u32 image_unpack_addr; - u32 pa_risx_addrs[7]; -}; - -struct sti_rom_font { - u16 first_char; - u16 last_char; - u8 width; - u8 height; - u8 font_type; /* language type */ - u8 bytes_per_char; - u32 next_font; - u8 underline_height; - u8 underline_pos; - u8 res008[2]; -}; - -/* sticore internal font handling */ - -struct sti_cooked_font { - struct sti_rom_font *raw; /* native ptr for STI functions */ - void *raw_ptr; /* kmalloc'ed font data */ - struct sti_cooked_font *next_font; - int height, width; - int refcount; - u32 crc; -}; - -struct sti_cooked_rom { - struct sti_rom *raw; - struct sti_cooked_font *font_start; -}; - -/* STI font printing function structs */ - -struct sti_font_inptr { - u32 font_start_addr; /* address of font start */ - s16 index; /* index into font table of character */ - u8 fg_color; /* foreground color of character */ - u8 bg_color; /* background color of character */ - s16 dest_x; /* X location of character upper left */ - s16 dest_y; /* Y location of character upper left */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_font_flags { - u32 wait : 1; /* should routine idle wait or not */ - u32 non_text : 1; /* font unpack/move in non_text planes =1, text =0 */ - u32 pad : 30; /* pad to word boundary */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_font_outptr { - s32 errno; /* error number on failure */ - u32 future_ptr; /* pointer to future data */ -}; - -/* STI blockmove structs */ - -struct sti_blkmv_flags { - u32 wait : 1; /* should routine idle wait or not */ - u32 color : 1; /* change color during move? */ - u32 clear : 1; /* clear during move? */ - u32 non_text : 1; /* block move in non_text planes =1, text =0 */ - u32 pad : 28; /* pad to word boundary */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_blkmv_inptr { - u8 fg_color; /* foreground color after move */ - u8 bg_color; /* background color after move */ - s16 src_x; /* source upper left pixel x location */ - s16 src_y; /* source upper left pixel y location */ - s16 dest_x; /* dest upper left pixel x location */ - s16 dest_y; /* dest upper left pixel y location */ - s16 width; /* block width in pixels */ - s16 height; /* block height in pixels */ - u32 future_ptr; /* pointer to future data */ -}; - -struct sti_blkmv_outptr { - s32 errno; /* error number on failure */ - u32 future_ptr; /* pointer to future data */ -}; - - -/* sti_all_data is an internal struct which needs to be allocated in - * low memory (< 4GB) if STI is used with 32bit STI on a 64bit kernel */ - -struct sti_all_data { - struct sti_glob_cfg glob_cfg; - struct sti_glob_cfg_ext glob_cfg_ext; - - struct sti_conf_inptr inq_inptr; - struct sti_conf_outptr inq_outptr; /* configuration */ - struct sti_conf_outptr_ext inq_outptr_ext; - - struct sti_init_inptr_ext init_inptr_ext; - struct sti_init_inptr init_inptr; - struct sti_init_outptr init_outptr; - - struct sti_blkmv_inptr blkmv_inptr; - struct sti_blkmv_outptr blkmv_outptr; - - struct sti_font_inptr font_inptr; - struct sti_font_outptr font_outptr; - - /* leave as last entries */ - unsigned long save_addr[1024 / sizeof(unsigned long)]; - /* min 256 bytes which is STI default, max sti->sti_mem_request */ - unsigned long sti_mem_addr[256 / sizeof(unsigned long)]; - /* do not add something below here ! */ -}; - -/* internal generic STI struct */ - -struct sti_struct { - spinlock_t lock; - - /* char **mon_strings; */ - int sti_mem_request; - u32 graphics_id[2]; - - struct sti_cooked_rom *rom; - - unsigned long font_unpmv; - unsigned long block_move; - unsigned long init_graph; - unsigned long inq_conf; - - /* all following fields are initialized by the generic routines */ - int text_planes; - region_t regions[STI_REGION_MAX]; - unsigned long regions_phys[STI_REGION_MAX]; - - struct sti_glob_cfg *glob_cfg; /* points into sti_all_data */ - - int wordmode; - struct sti_cooked_font *font; /* ptr to selected font (cooked) */ - - struct pci_dev *pd; - - /* PCI data structures (pg. 17ff from sti.pdf) */ - u8 rm_entry[16]; /* pci region mapper array == pci config space offset */ - - /* pointer to the fb_info where this STI device is used */ - struct fb_info *info; - - /* pointer to all internal data */ - struct sti_all_data *sti_data; - - /* pa_path of this device */ - char pa_path[24]; -}; - - -/* sticore interface functions */ - -struct sti_struct *sti_get_rom(unsigned int index); /* 0: default sti */ -void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f); - - -/* sticore main function to call STI firmware */ - -int sti_call(const struct sti_struct *sti, unsigned long func, - const void *flags, void *inptr, void *outptr, - struct sti_glob_cfg *glob_cfg); - - -/* functions to call the STI ROM directly */ - -void sti_putc(struct sti_struct *sti, int c, int y, int x, - struct sti_cooked_font *font); -void sti_set(struct sti_struct *sti, int src_y, int src_x, - int height, int width, u8 color); -void sti_clear(struct sti_struct *sti, int src_y, int src_x, - int height, int width, int c, struct sti_cooked_font *font); -void sti_bmove(struct sti_struct *sti, int src_y, int src_x, - int dst_y, int dst_x, int height, int width, - struct sti_cooked_font *font); - -#endif /* STICORE_H */ diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c index 686a234f3899..66d82f6d17c7 100644 --- a/drivers/video/fbdev/stifb.c +++ b/drivers/video/fbdev/stifb.c @@ -69,7 +69,7 @@ #include <asm/grfioctl.h> /* for HP-UX compatibility */ #include <linux/uaccess.h> -#include "sticore.h" +#include <video/sticore.h> /* REGION_BASE(fb_info, index) returns the virtual address for region <index> */ #define REGION_BASE(fb_info, index) \ @@ -527,8 +527,8 @@ rattlerSetupPlanes(struct stifb_info *fb) fb->id = saved_id; for (y = 0; y < fb->info.var.yres; ++y) - fb_memset(fb->info.screen_base + y * fb->info.fix.line_length, - 0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8); + fb_memset_io(fb->info.screen_base + y * fb->info.fix.line_length, + 0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8); CRX24_SET_OVLY_MASK(fb); SETUP_FB(fb); diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index d17e5e1472aa..cdf8e9fe9948 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -1116,7 +1116,7 @@ static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor) u8 *mask = (u8 *)cursor->mask; int i; - fb_memset(cursorbase, 0, 1024); + fb_memset_io(cursorbase, 0, 1024); for (i = 0; i < cursor->image.height; i++) { int h = 0; diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index dabc30a09f96..a4a21b4ac28c 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1008,7 +1008,7 @@ static void dlfb_ops_destroy(struct fb_info *info) fb_dealloc_cmap(&info->cmap); if (info->monspecs.modedb) fb_destroy_modedb(info->monspecs.modedb); - vfree(info->screen_base); + vfree(info->screen_buffer); fb_destroy_modelist(&info->modelist); @@ -1122,7 +1122,7 @@ static int dlfb_ops_set_par(struct fb_info *info) /* paint greenscreen */ - pix_framebuffer = (u16 *) info->screen_base; + pix_framebuffer = (u16 *)info->screen_buffer; for (i = 0; i < info->fix.smem_len / 2; i++) pix_framebuffer[i] = 0x37e6; } @@ -1221,7 +1221,7 @@ static void dlfb_deferred_vfree(struct dlfb_data *dlfb, void *mem) static int dlfb_realloc_framebuffer(struct dlfb_data *dlfb, struct fb_info *info, u32 new_len) { u32 old_len = info->fix.smem_len; - const void *old_fb = (const void __force *)info->screen_base; + const void *old_fb = info->screen_buffer; unsigned char *new_fb; unsigned char *new_back = NULL; @@ -1238,12 +1238,12 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dlfb, struct fb_info *info } memset(new_fb, 0xff, new_len); - if (info->screen_base) { + if (info->screen_buffer) { memcpy(new_fb, old_fb, old_len); - dlfb_deferred_vfree(dlfb, (void __force *)info->screen_base); + dlfb_deferred_vfree(dlfb, info->screen_buffer); } - info->screen_base = (char __iomem *)new_fb; + info->screen_buffer = new_fb; info->fix.smem_len = new_len; info->fix.smem_start = (unsigned long) new_fb; info->flags = udlfb_info_flags; diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 6f1990969361..cf3c72754ce7 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -440,7 +440,7 @@ static int vfb_probe(struct platform_device *dev) if (!info) goto err; - info->screen_base = (char __iomem *)videomemory; + info->screen_buffer = videomemory; info->fbops = &vfb_ops; if (!fb_find_mode(&info->var, info, mode_option, diff --git a/drivers/video/fbdev/wmt_ge_rops.c b/drivers/video/fbdev/wmt_ge_rops.c index 3ed143457d22..b70961901683 100644 --- a/drivers/video/fbdev/wmt_ge_rops.c +++ b/drivers/video/fbdev/wmt_ge_rops.c @@ -9,7 +9,9 @@ #include <linux/module.h> #include <linux/fb.h> +#include <linux/io.h> #include <linux/platform_device.h> + #include "core/fb_draw.h" #include "wmt_ge_rops.h" diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index d7f3e6281ce4..9b2a786621a6 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c @@ -429,7 +429,7 @@ static int xenfb_probe(struct xenbus_device *dev, fb_info->pseudo_palette = fb_info->par; fb_info->par = info; - fb_info->screen_base = info->fb; + fb_info->screen_buffer = info->fb; fb_info->fbops = &xenfb_fb_ops; fb_info->var.xres_virtual = fb_info->var.xres = video[KPARAM_WIDTH]; |