diff --git a/Makefile b/Makefile index 0af567df2..dfe8717eb 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ SUBDIR= linuxkpi \ lindebugfs \ drm \ - i915 \ amd \ radeon \ ${_staging} diff --git a/amd/Makefile b/amd/Makefile index 80533715c..c024ab079 100644 --- a/amd/Makefile +++ b/amd/Makefile @@ -1,11 +1,11 @@ # $FreeBSD$ -.if ${MACHINE_CPUARCH} == "amd64" +.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "powerpc" _amdgpu= amdgpu _amdkfd= amdkfd .endif -SUBDIR= ${_amdgpu} \ - ${_amdkfd} + +SUBDIR= ${_amdgpu} .include diff --git a/amd/amdgpu/Makefile b/amd/amdgpu/Makefile index 0e44d3376..953ba529b 100644 --- a/amd/amdgpu/Makefile +++ b/amd/amdgpu/Makefile @@ -4,9 +4,10 @@ SRCDIR= ${.CURDIR:H:H}/drivers/gpu/drm/amd KMOD= amdgpu +WERROR= + .PATH: ${SRCDIR}/acp \ ${SRCDIR}/amdgpu \ - ${SRCDIR}/amdkfd \ ${SRCDIR}/display \ ${SRCDIR}/display/amdgpu_dm \ ${SRCDIR}/display/dc \ @@ -23,13 +24,11 @@ KMOD= amdgpu ${SRCDIR}/display/dc/dce112 \ ${SRCDIR}/display/dc/dce120 \ ${SRCDIR}/display/dc/dce80 \ - ${SRCDIR}/display/dc/dcn10 \ ${SRCDIR}/display/dc/dml \ ${SRCDIR}/display/dc/gpio \ ${SRCDIR}/display/dc/gpio/dce110 \ ${SRCDIR}/display/dc/gpio/dce120 \ ${SRCDIR}/display/dc/gpio/dce80 \ - ${SRCDIR}/display/dc/gpio/dcn10 \ ${SRCDIR}/display/dc/gpio/diagnostics \ ${SRCDIR}/display/dc/i2caux \ ${SRCDIR}/display/dc/i2caux/dce100 \ @@ -37,7 +36,6 @@ KMOD= amdgpu ${SRCDIR}/display/dc/i2caux/dce112 \ ${SRCDIR}/display/dc/i2caux/dce120 \ ${SRCDIR}/display/dc/i2caux/dce80 \ - ${SRCDIR}/display/dc/i2caux/dcn10 \ ${SRCDIR}/display/dc/i2caux/diagnostics \ ${SRCDIR}/display/dc/inc \ ${SRCDIR}/display/dc/inc/hw \ @@ -45,7 +43,6 @@ KMOD= amdgpu ${SRCDIR}/display/dc/irq/dce110 \ ${SRCDIR}/display/dc/irq/dce120 \ ${SRCDIR}/display/dc/irq/dce80 \ - ${SRCDIR}/display/dc/irq/dcn10 \ ${SRCDIR}/display/dc/virtual \ ${SRCDIR}/display/modules \ ${SRCDIR}/display/modules/freesync \ @@ -63,14 +60,12 @@ SRCS= acp_hw.c # amdgpu # amdgpu_acp.c \ # not yet - need i2s # amdgpu_mn.c \ # disabled -SRCS+= amdgpu_acpi.c \ - amdgpu_afmt.c \ +SRCS+= amdgpu_afmt.c \ amdgpu_amdkfd.c \ amdgpu_amdkfd_gfx_v7.c \ amdgpu_amdkfd_gfx_v8.c \ amdgpu_atombios.c \ amdgpu_atomfirmware.c \ - amdgpu_atpx_handler.c \ amdgpu_benchmark.c \ amdgpu_bios.c \ amdgpu_bo_list.c \ @@ -249,21 +244,7 @@ SRCS+= amdgpu_dm.c \ dce_scl_filters.c \ dce_stream_encoder.c \ dce_transform.c \ - dcn10_cm_common.c \ - dcn10_dpp.c \ - dcn10_dpp_cm.c \ - dcn10_dpp_dscl.c \ - dcn10_hubbub.c \ - dcn10_hubp.c \ - dcn10_hw_sequencer.c \ - dcn10_ipp.c \ - dcn10_mpc.c \ - dcn10_opp.c \ - dcn10_optc.c \ - dcn10_resource.c \ - dcn_calc_auto.c \ dcn_calc_math.c \ - dcn_calcs.c \ display_mode_lib.c \ display_mode_vba.c \ display_rq_dlg_calc.c \ @@ -281,7 +262,6 @@ SRCS+= amdgpu_dm.c \ hw_factory_dce110.c \ hw_factory_dce120.c \ hw_factory_dce80.c \ - hw_factory_dcn10.c \ hw_factory_diag.c \ hw_gpio.c \ hw_hpd.c \ @@ -289,7 +269,6 @@ SRCS+= amdgpu_dm.c \ hw_translate_dce110.c \ hw_translate_dce120.c \ hw_translate_dce80.c \ - hw_translate_dcn10.c \ hw_translate_diag.c \ i2c_engine.c \ i2c_generic_hw_engine.c \ @@ -305,13 +284,11 @@ SRCS+= amdgpu_dm.c \ i2caux_dce112.c \ i2caux_dce120.c \ i2caux_dce80.c \ - i2caux_dcn10.c \ i2caux_diag.c \ irq_service.c \ irq_service_dce110.c \ irq_service_dce120.c \ irq_service_dce80.c \ - irq_service_dcn10.c \ log_helpers.c \ logger.c \ soc_bounding_box.c \ @@ -393,6 +370,20 @@ SRCS+= device_if.h vnode_if.h bus_if.h pci_if.h device_if.h iicbus_if.h opt_drm. .include +.if ${MACHINE_CPUARCH} == "powerpc" +CFLAGS.dcn_calcs.c= -maltivec -mhard-float -mfull-toc +CFLAGS.dcn_calc_auto.c= -maltivec -mhard-float -mfull-toc +CFLAGS.dcn_calc_math.c= -maltivec -mhard-float -mfull-toc + +CFLAGS.display_mode_vba.c= -maltivec -mhard-float -mfull-toc +CFLAGS.display_mode_lib.c= -maltivec -mhard-float -mfull-toc +CFLAGS.display_pipe_clocks.c= -maltivec -mhard-float -mfull-toc +CFLAGS.display_rq_dlg_calc.c= -maltivec -mhard-float -mfull-toc +CFLAGS.dml1_display_rq_dlg_calc.c= -maltivec -mhard-float -mfull-toc +CFLAGS.display_rq_dlg_helpers.c= -maltivec -mhard-float -mfull-toc +CFLAGS.soc_bounding_box.c= -maltivec -mhard-float -mfull-toc +CFLAGS.dml_common_defs.c= -maltivec -mhard-float -mfull-toc +.else CFLAGS.dcn_calcs.c= -msse -mstack-alignment=4 CFLAGS.dcn_calc_auto.c= -msse -mstack-alignment=4 CFLAGS.dcn_calc_math.c= -msse -mstack-alignment=4 -Wno-tautological-compare @@ -405,11 +396,12 @@ CFLAGS.dml1_display_rq_dlg_calc.c= -msse -mstack-alignment=4 CFLAGS.display_rq_dlg_helpers.c= -msse -mstack-alignment=4 CFLAGS.soc_bounding_box.c= -msse -mstack-alignment=4 CFLAGS.dml_common_defs.c= -msse -mstack-alignment=4 +.endif CWARNFLAGS+= -Wno-pointer-arith -Wno-format CWARNFLAGS+= -Wno-pointer-sign ${CWARNFLAGS.${.IMPSRC:T}} -CWARNFLAGS+= -Wno-expansion-to-defined +.if ${MACHINE_CPUARCH} != "powerpc" CWARNFLAGS.amdgpu_acpi.c= -Wno-int-conversion -Wno-missing-prototypes -Wno-unused-variable CWARNFLAGS.amdgpu_amdkfd.c= -Wno-missing-prototypes CWARNFLAGS.amdgpu_amdkfd_gfx_v7.c= -Wno-cast-qual @@ -543,3 +535,4 @@ CWARNFLAGS.vega10_smumgr.c= -Wno-missing-prototypes CWARNFLAGS.vega10_thermal.c= -Wno-missing-prototypes CWARNFLAGS.vi.c= -Wno-unused-const-variable CWARNFLAGS.uvd_v7_0.c= -Wno-missing-prototypes +.endif diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c index a82e0bce6..ae7d34ebd 100644 --- a/drivers/gpu/drm/drm_cache.c +++ b/drivers/gpu/drm/drm_cache.c @@ -92,7 +92,7 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages) if (wbinvd_on_all_cpus()) pr_err("Timed out waiting for cache flush\n"); -#elif defined(__powerpc__) +#elif defined(CONFIG_PPC32) unsigned long i; for (i = 0; i < num_pages; i++) { struct page *page = pages[i]; diff --git a/drivers/gpu/drm/drm_os_config.h b/drivers/gpu/drm/drm_os_config.h index 906bca187..8f3883e9d 100644 --- a/drivers/gpu/drm/drm_os_config.h +++ b/drivers/gpu/drm/drm_os_config.h @@ -21,6 +21,11 @@ #define CONFIG_IA64 1 #define CONFIG_64BIT 1 #endif +#ifdef __powerpc64__ +#define CONFIG_PPC64 1 +#define CONFIG_64BIT 1 +#define AIM 1 +#endif #if defined(__i386__) || defined(__amd64__) #define CONFIG_PCI 1 @@ -31,12 +36,22 @@ // For platforms with SSE4.1 (needed for GuC) #define CONFIG_AS_MOVNTDQA #endif +#if defined(__powerpc64__) +#define CONFIG_PCI 1 +#undef CONFIG_ACPI +#undef CONFIG_ACPI_SLEEP +#undef CONFIG_DRM_I915_KMS +#undef CONFIG_INTEL_IOMMU +#undef CONFIG_AS_MOVNTDQA +#endif #ifdef _KERNEL #define __KERNEL__ #endif - +#if !defined(AIM) #define CONFIG_AGP 1 +#endif + #define CONFIG_MTRR 1 #define CONFIG_FB 1 @@ -106,6 +121,9 @@ // Enable new amd display controller #define CONFIG_DRM_AMD_DC 1 -#define CONFIG_DRM_AMD_DC_DCN1_0 1 +// DCN 1.0 is purely an APU and therefore amd64 only. +#ifdef __amd64__ +#define CONFIG_DRM_AMD_DC_DCN1_0 1 +#endif #endif diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index bf85fb5cc..567c6575d 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -80,9 +80,9 @@ static bool drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, ktime_t *tvblank, bool in_vblank_irq); -static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ +unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ -static int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ +int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600); module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600); diff --git a/drivers/gpu/drm/linux_fb.c b/drivers/gpu/drm/linux_fb.c index ad70c0ea9..9884b6819 100644 --- a/drivers/gpu/drm/linux_fb.c +++ b/drivers/gpu/drm/linux_fb.c @@ -166,7 +166,7 @@ fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, case FBIO_BLANK: /* blank display */ if (info->fbops->fb_blank != NULL) - error = info->fbops->fb_blank((int)data, info); + error = info->fbops->fb_blank((size_t)data, info); break; default: diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 29d631727..d754bad8e 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -226,8 +226,8 @@ static struct kobj_type ttm_pool_kobj_type = { static struct ttm_pool_manager *_manager; -#ifndef CONFIG_X86 -static int set_pages_wb(struct page *page, int numpages) +#if !defined(CONFIG_X86)// && !defined(CONFIG_PPC64) +static int zzttm_set_pages_wb(struct page *page, int numpages) { #if IS_ENABLED(CONFIG_AGP) int i; @@ -238,7 +238,7 @@ static int set_pages_wb(struct page *page, int numpages) return 0; } -static int set_pages_array_wb(struct page **pages, int addrinarray) +static int zzttm_set_pages_array_wb(struct page **pages, int addrinarray) { #if IS_ENABLED(CONFIG_AGP) int i; @@ -249,7 +249,7 @@ static int set_pages_array_wb(struct page **pages, int addrinarray) return 0; } -static int set_pages_array_wc(struct page **pages, int addrinarray) +static int zzttm_set_pages_array_wc(struct page **pages, int addrinarray) { #if IS_ENABLED(CONFIG_AGP) int i; @@ -260,7 +260,7 @@ static int set_pages_array_wc(struct page **pages, int addrinarray) return 0; } -static int set_pages_array_uc(struct page **pages, int addrinarray) +static int zzttm_set_pages_array_uc(struct page **pages, int addrinarray) { #if IS_ENABLED(CONFIG_AGP) int i; @@ -306,13 +306,13 @@ static void ttm_pages_put(struct page *pages[], unsigned npages, unsigned int i, pages_nr = (1 << order); if (order == 0) { - if (set_pages_array_wb(pages, npages)) + if (zzttm_set_pages_array_wb(pages, npages)) pr_err("Failed to set %d pages to wb!\n", npages); } for (i = 0; i < npages; ++i) { if (order > 0) { - if (set_pages_wb(pages[i], pages_nr)) + if (zzttm_set_pages_wb(pages[i], pages_nr)) pr_err("Failed to set %d pages to wb!\n", pages_nr); } #ifndef __linux__ @@ -526,12 +526,12 @@ static int ttm_set_pages_caching(struct page **pages, /* Set page caching */ switch (cstate) { case tt_uncached: - r = set_pages_array_uc(pages, cpages); + r = zzttm_set_pages_array_uc(pages, cpages); if (r) pr_err("Failed to set %d pages to uc!\n", cpages); break; case tt_wc: - r = set_pages_array_wc(pages, cpages); + r = zzttm_set_pages_array_wc(pages, cpages); if (r) pr_err("Failed to set %d pages to wc!\n", cpages); break; @@ -1162,6 +1162,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) ttm_page_pool_init_locked(&_manager->uc_pool_dma32, GFP_USER | GFP_DMA32, "uc dma", 0); +#ifdef CONFIG_TRANSPARENT_HUGEPAGES ttm_page_pool_init_locked(&_manager->wc_pool_huge, (GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM) & @@ -1173,6 +1174,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) __GFP_KSWAPD_RECLAIM) & ~(__GFP_MOVABLE | __GFP_COMP) , "uc huge", order); +#endif _manager->options.max_size = max_pages; _manager->options.small = SMALL_ALLOCATION; diff --git a/drm/Makefile b/drm/Makefile index 48b824060..33dbf0a82 100644 --- a/drm/Makefile +++ b/drm/Makefile @@ -125,12 +125,11 @@ SRCS+= device_if.h \ CWARNFLAGS+=-Wno-cast-qual .endif CWARNFLAGS+= -Wno-pointer-arith -Wno-pointer-sign -Wno-format -CWARNFLAGS+= -Wno-expansion-to-defined -CWARNFLAGS.drm_mipi_dsi.c+= -Wno-incompatible-pointer-types-discards-qualifiers -Wno-int-conversion -CWARNFLAGS.drm_cache.c+= -Wno-int-conversion -CWARNFLAGS.drm_info.c+= -Wno-tautological-compare -CWARNFLAGS.drm_ioc32.c+= -Wno-address-of-packed-member -CWARNFLAGS.drm_debugfs.c+= -Wno-format-security -CWARNFLAGS.drm_scatter.c+= -Wno-int-conversion +#CWARNFLAGS.drm_mipi_dsi.c+= -Wno-incompatible-pointer-types-discards-qualifiers -Wno-int-conversion +#CWARNFLAGS.drm_cache.c+= -Wno-int-conversion +#CWARNFLAGS.drm_info.c+= -Wno-tautological-compare +#CWARNFLAGS.drm_ioc32.c+= -Wno-address-of-packed-member +#CWARNFLAGS.drm_debugfs.c+= -Wno-format-security +#CWARNFLAGS.drm_scatter.c+= -Wno-int-conversion .include diff --git a/linuxkpi/Makefile b/linuxkpi/Makefile index d546276aa..05f02c80f 100644 --- a/linuxkpi/Makefile +++ b/linuxkpi/Makefile @@ -8,7 +8,7 @@ SRCS= linux_kmod_gplv2.c \ linux_anon_inodes.c \ linux_async.c \ linux_backlight.c \ - linux_compat.c \ + linux_compat_ppc64.c \ linux_component.c \ linux_device.c \ linux_dmabuf.c \ @@ -20,6 +20,7 @@ SRCS= linux_kmod_gplv2.c \ linux_i2c.c \ linux_interval_tree.c \ linux_irq.c \ + linux_kfifo.c \ linux_llist.c \ linux_mtrr.c \ linux_notifier.c \ @@ -29,8 +30,8 @@ SRCS= linux_kmod_gplv2.c \ linux_reservation.c \ linux_seq_file.c \ linux_sort.c \ - linux_sync_file.c \ - linux_video.c + linux_sync_file.c + SRCS+= opt_acpi.h diff --git a/linuxkpi/gplv2/include/acpi/acpi_drivers.h b/linuxkpi/gplv2/include/acpi/acpi_drivers.h index 0199b3a44..dd25227ee 100644 --- a/linuxkpi/gplv2/include/acpi/acpi_drivers.h +++ b/linuxkpi/gplv2/include/acpi/acpi_drivers.h @@ -99,6 +99,7 @@ static inline void pci_acpi_crs_quirks(void) { } /*-------------------------------------------------------------------------- Dock Station -------------------------------------------------------------------------- */ +#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI_DOCK extern int is_dock_device(struct acpi_device *adev); #else @@ -107,5 +108,6 @@ static inline int is_dock_device(struct acpi_device *adev) return 0; } #endif /* CONFIG_ACPI_DOCK */ +#endif /* CONFIG_ACPI */ #endif /*__ACPI_DRIVERS_H__*/ diff --git a/linuxkpi/gplv2/include/linux/acpi.h b/linuxkpi/gplv2/include/linux/acpi.h index 12a5553c6..0059f1305 100644 --- a/linuxkpi/gplv2/include/linux/acpi.h +++ b/linuxkpi/gplv2/include/linux/acpi.h @@ -34,6 +34,7 @@ #include #include +#ifdef CONFIG_ACPI static inline acpi_handle acpi_device_handle(struct acpi_device *adev) { return adev ? adev->handle : NULL; @@ -42,6 +43,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) #define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode) #define ACPI_HANDLE_GET(dev) acpi_device_handle(ACPI_COMPANION(dev)) #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) +#endif #define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001 #define ACPI_VIDEO_DEVICE_POSTING 0x0002 @@ -56,6 +58,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 +#ifdef CONFIG_ACPI extern long acpi_is_video_device(acpi_handle handle); static inline const char *acpi_dev_name(struct acpi_device *adev) @@ -69,5 +72,6 @@ void acpi_scan_drop_device(acpi_handle handle, void *context); struct pci_dev *acpi_get_pci_dev(acpi_handle handle); int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); +#endif #endif /* _LINUX_GPLV2_ACPI_H_ */ diff --git a/linuxkpi/gplv2/include/linux/irq.h b/linuxkpi/gplv2/include/linux/irq.h index d1781dd24..d5f3c6d5a 100644 --- a/linuxkpi/gplv2/include/linux/irq.h +++ b/linuxkpi/gplv2/include/linux/irq.h @@ -15,7 +15,7 @@ #include -#if defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) || defined(__powerpc64__) #define NR_IRQS 512 /* XXX need correct value */ #else #error "NR_IRQS not defined" diff --git a/linuxkpi/gplv2/include/linux/irqdesc.h b/linuxkpi/gplv2/include/linux/irqdesc.h index 8a44dd312..1a4b2aaf7 100644 --- a/linuxkpi/gplv2/include/linux/irqdesc.h +++ b/linuxkpi/gplv2/include/linux/irqdesc.h @@ -47,8 +47,6 @@ irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags) spin_unlock_irqrestore(&desc->lock, flags); } -extern struct idr irq_idr; - static inline void generic_handle_irq_desc(struct irq_desc *desc) { diff --git a/linuxkpi/gplv2/include/linux/kfifo.h b/linuxkpi/gplv2/include/linux/kfifo.h index 1d7838259..89fc8dc7b 100644 --- a/linuxkpi/gplv2/include/linux/kfifo.h +++ b/linuxkpi/gplv2/include/linux/kfifo.h @@ -21,13 +21,40 @@ #ifndef _LINUX_KFIFO_H #define _LINUX_KFIFO_H + +/* + * How to porting drivers to the new generic FIFO API: + * + * - Modify the declaration of the "struct kfifo *" object into a + * in-place "struct kfifo" object + * - Init the in-place object with kfifo_alloc() or kfifo_init() + * Note: The address of the in-place "struct kfifo" object must be + * passed as the first argument to this functions + * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get + * into kfifo_out + * - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get + * into kfifo_out_spinlocked + * Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc + * must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked + * as the last parameter + * - The formerly __kfifo_* functions are renamed into kfifo_* + */ + +/* + * Note about locking: There is no locking required until only one reader + * and one writer is using the fifo and no kfifo_reset() will be called. + * kfifo_reset_out() can be safely used, until it will be only called + * in the reader thread. + * For multiple writer and one reader there is only a need to lock the writer. + * And vice versa for only one writer and multiple reader there is only a need + * to lock the reader. + */ + #include #include #include #include -#include - struct __kfifo { unsigned int in; unsigned int out; @@ -75,13 +102,39 @@ struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void); #define STRUCT_KFIFO_REC_2(size) \ struct __STRUCT_KFIFO(unsigned char, size, 2, void) +/* + * define kfifo_rec types + */ struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void); struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void); -#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo)) +/* + * helper macro to distinguish between real in place fifo where the fifo + * array is a part of the structure and the fifo type where the array is + * outside of the fifo structure. + */ +#define __is_kfifo_ptr(fifo) \ + (sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type)))) + +/** + * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object + * @fifo: name of the declared fifo + * @type: type of the fifo elements + */ #define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo + +/** + * DECLARE_KFIFO - macro to declare a fifo object + * @fifo: name of the declared fifo + * @type: type of the fifo elements + * @size: the number of elements in the fifo, this must be a power of 2 + */ #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo +/** + * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO + * @fifo: name of the declared fifo datatype + */ #define INIT_KFIFO(fifo) \ (void)({ \ typeof(&(fifo)) __tmp = &(fifo); \ @@ -92,6 +145,15 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void); __kfifo->esize = sizeof(*__tmp->buf); \ __kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \ }) + +/** + * DEFINE_KFIFO - macro to define and initialize a fifo + * @fifo: name of the declared fifo datatype + * @type: type of the fifo elements + * @size: the number of elements in the fifo, this must be a power of 2 + * + * Note: the macro can be used for global and local fifo data type variables. + */ #define DEFINE_KFIFO(fifo, type, size) \ DECLARE_KFIFO(fifo, type, size) = \ (typeof(fifo)) { \ @@ -123,41 +185,95 @@ __kfifo_int_must_check_helper(int val) return val; } +/** + * kfifo_initialized - Check if the fifo is initialized + * @fifo: address of the fifo to check + * + * Return %true if fifo is initialized, otherwise %false. + * Assumes the fifo was 0 before. + */ #define kfifo_initialized(fifo) ((fifo)->kfifo.mask) + +/** + * kfifo_esize - returns the size of the element managed by the fifo + * @fifo: address of the fifo to be used + */ #define kfifo_esize(fifo) ((fifo)->kfifo.esize) + +/** + * kfifo_recsize - returns the size of the record length field + * @fifo: address of the fifo to be used + */ #define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype)) + +/** + * kfifo_size - returns the size of the fifo in elements + * @fifo: address of the fifo to be used + */ #define kfifo_size(fifo) ((fifo)->kfifo.mask + 1) +/** + * kfifo_reset - removes the entire fifo content + * @fifo: address of the fifo to be used + * + * Note: usage of kfifo_reset() is dangerous. It should be only called when the + * fifo is exclusived locked or when it is secured that no other thread is + * accessing the fifo. + */ #define kfifo_reset(fifo) \ (void)({ \ typeof((fifo) + 1) __tmp = (fifo); \ __tmp->kfifo.in = __tmp->kfifo.out = 0; \ }) +/** + * kfifo_reset_out - skip fifo content + * @fifo: address of the fifo to be used + * + * Note: The usage of kfifo_reset_out() is safe until it will be only called + * from the reader thread and there is only one concurrent reader. Otherwise + * it is dangerous and must be handled in the same way as kfifo_reset(). + */ #define kfifo_reset_out(fifo) \ (void)({ \ typeof((fifo) + 1) __tmp = (fifo); \ __tmp->kfifo.out = __tmp->kfifo.in; \ }) +/** + * kfifo_len - returns the number of used elements in the fifo + * @fifo: address of the fifo to be used + */ #define kfifo_len(fifo) \ ({ \ typeof((fifo) + 1) __tmpl = (fifo); \ __tmpl->kfifo.in - __tmpl->kfifo.out; \ }) +/** + * kfifo_is_empty - returns true if the fifo is empty + * @fifo: address of the fifo to be used + */ #define kfifo_is_empty(fifo) \ ({ \ typeof((fifo) + 1) __tmpq = (fifo); \ __tmpq->kfifo.in == __tmpq->kfifo.out; \ }) +/** + * kfifo_is_full - returns true if the fifo is full + * @fifo: address of the fifo to be used + */ #define kfifo_is_full(fifo) \ ({ \ typeof((fifo) + 1) __tmpq = (fifo); \ kfifo_len(__tmpq) > __tmpq->kfifo.mask; \ }) +/** + * kfifo_avail - returns the number of unused elements in the fifo + * @fifo: address of the fifo to be used + */ #define kfifo_avail(fifo) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -170,26 +286,84 @@ __kfifo_uint_must_check_helper( \ }) \ ) +/** + * kfifo_skip - skip output data + * @fifo: address of the fifo to be used + */ +#define kfifo_skip(fifo) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_skip_r(__kfifo, __recsize); \ + else \ + __kfifo->out++; \ +}) +/** + * kfifo_peek_len - gets the size of the next fifo record + * @fifo: address of the fifo to be used + * + * This function returns the size of the next fifo record in number of bytes. + */ +#define kfifo_peek_len(fifo) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \ + __kfifo_len_r(__kfifo, __recsize); \ +}) \ +) + +/** + * kfifo_alloc - dynamically allocates a new fifo buffer + * @fifo: pointer to the fifo + * @size: the number of elements in the fifo, this must be a power of 2 + * @gfp_mask: get_free_pages mask, passed to kmalloc() + * + * This macro dynamically allocates a new fifo buffer. + * + * The number of elements will be rounded-up to a power of 2. + * The fifo will be release with kfifo_free(). + * Return 0 if no error, otherwise an error code. + */ #define kfifo_alloc(fifo, size, gfp_mask) \ __kfifo_int_must_check_helper( \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ struct __kfifo *__kfifo = &__tmp->kfifo; \ __is_kfifo_ptr(__tmp) ? \ - linux_kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \ + __kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \ -EINVAL; \ }) \ ) +/** + * kfifo_free - frees the fifo + * @fifo: the fifo to be freed + */ #define kfifo_free(fifo) \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ struct __kfifo *__kfifo = &__tmp->kfifo; \ if (__is_kfifo_ptr(__tmp)) \ - linux_kfifo_free(__kfifo); \ + __kfifo_free(__kfifo); \ }) +/** + * kfifo_init - initialize a fifo using a preallocated buffer + * @fifo: the fifo to assign the buffer + * @buffer: the preallocated buffer to be used + * @size: the size of the internal buffer, this have to be a power of 2 + * + * This macro initializes a fifo using a preallocated buffer. + * + * The number of elements will be rounded-up to a power of 2. + * Return 0 if no error, otherwise an error code. + */ #define kfifo_init(fifo, buffer, size) \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ @@ -199,7 +373,19 @@ __kfifo_int_must_check_helper( \ -EINVAL; \ }) -#define kfifo_put(fifo, val) \ +/** + * kfifo_put - put data into the fifo + * @fifo: address of the fifo to be used + * @val: the data to be added + * + * This macro copies the given value into the fifo. + * It returns 0 if the fifo was full. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_put(fifo, val) \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ typeof(*__tmp->const_type) __val = (val); \ @@ -224,7 +410,18 @@ __kfifo_int_must_check_helper( \ __ret; \ }) - +/** + * kfifo_get - get data from the fifo + * @fifo: address of the fifo to be used + * @val: address where to store the data + * + * This macro reads the data from the fifo. + * It returns 0 if the fifo was empty. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ #define kfifo_get(fifo, val) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -252,6 +449,18 @@ __kfifo_uint_must_check_helper( \ }) \ ) +/** + * kfifo_peek - get data from the fifo without removing + * @fifo: address of the fifo to be used + * @val: address where to store the data + * + * This reads the data from the fifo without removing it from the fifo. + * It returns 0 if the fifo was empty. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ #define kfifo_peek(fifo, val) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -278,7 +487,19 @@ __kfifo_uint_must_check_helper( \ }) \ ) -#define kfifo_in(fifo, buf, n) \ +/** + * kfifo_in - put data into the fifo + * @fifo: address of the fifo to be used + * @buf: the data to be added + * @n: number of elements to be added + * + * This macro copies the given buffer into the fifo and returns the + * number of copied elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_in(fifo, buf, n) \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ typeof(__tmp->ptr_const) __buf = (buf); \ @@ -287,9 +508,19 @@ __kfifo_uint_must_check_helper( \ struct __kfifo *__kfifo = &__tmp->kfifo; \ (__recsize) ?\ __kfifo_in_r(__kfifo, __buf, __n, __recsize) : \ - linux_kfifo_in(__kfifo, __buf, __n); \ + __kfifo_in(__kfifo, __buf, __n); \ }) +/** + * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking + * @fifo: address of the fifo to be used + * @buf: the data to be added + * @n: number of elements to be added + * @lock: pointer to the spinlock to use for locking + * + * This macro copies the given values buffer into the fifo and returns the + * number of copied elements. + */ #define kfifo_in_spinlocked(fifo, buf, n, lock) \ ({ \ unsigned long __flags; \ @@ -300,9 +531,22 @@ __kfifo_uint_must_check_helper( \ __ret; \ }) +/* alias for kfifo_in_spinlocked, will be removed in a future release */ #define kfifo_in_locked(fifo, buf, n, lock) \ kfifo_in_spinlocked(fifo, buf, n, lock) +/** + * kfifo_out - get data from the fifo + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * + * This macro get some data from the fifo and return the numbers of elements + * copied. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ #define kfifo_out(fifo, buf, n) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -313,10 +557,20 @@ __kfifo_uint_must_check_helper( \ struct __kfifo *__kfifo = &__tmp->kfifo; \ (__recsize) ?\ __kfifo_out_r(__kfifo, __buf, __n, __recsize) : \ - linux_kfifo_out(__kfifo, __buf, __n); \ + __kfifo_out(__kfifo, __buf, __n); \ }) \ ) +/** + * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * @lock: pointer to the spinlock to use for locking + * + * This macro get the data from the fifo and return the numbers of elements + * copied. + */ #define kfifo_out_spinlocked(fifo, buf, n, lock) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -329,9 +583,23 @@ __kfifo_uint_must_check_helper( \ }) \ ) +/* alias for kfifo_out_spinlocked, will be removed in a future release */ #define kfifo_out_locked(fifo, buf, n, lock) \ kfifo_out_spinlocked(fifo, buf, n, lock) +/** + * kfifo_from_user - puts some data from user space into the fifo + * @fifo: address of the fifo to be used + * @from: pointer to the data to be added + * @len: the length of the data to be added + * @copied: pointer to output variable to store the number of copied bytes + * + * This macro copies at most @len bytes from the @from into the + * fifo, depending of the available space and returns -EFAULT/0. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ #define kfifo_from_user(fifo, from, len, copied) \ __kfifo_uint_must_check_helper( \ ({ \ @@ -347,160 +615,174 @@ __kfifo_uint_must_check_helper( \ }) \ ) -#define kfifo_out_peek(fifo, buf, n) \ +/** + * kfifo_to_user - copies data from the fifo into user space + * @fifo: address of the fifo to be used + * @to: where the data must be copied + * @len: the size of the destination buffer + * @copied: pointer to output variable to store the number of copied bytes + * + * This macro copies at most @len bytes from the fifo into the + * @to buffer and returns -EFAULT/0. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_to_user(fifo, to, len, copied) \ __kfifo_uint_must_check_helper( \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ - typeof(__tmp->ptr) __buf = (buf); \ - unsigned long __n = (n); \ + void __user *__to = (to); \ + unsigned int __len = (len); \ + unsigned int *__copied = (copied); \ const size_t __recsize = sizeof(*__tmp->rectype); \ struct __kfifo *__kfifo = &__tmp->kfifo; \ (__recsize) ? \ - __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \ - linux_kfifo_out_peek(__kfifo, __buf, __n); \ + __kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \ + __kfifo_to_user(__kfifo, __to, __len, __copied); \ }) \ ) +/** + * kfifo_dma_in_prepare - setup a scatterlist for DMA input + * @fifo: address of the fifo to be used + * @sgl: pointer to the scatterlist array + * @nents: number of entries in the scatterlist array + * @len: number of elements to transfer + * + * This macro fills a scatterlist for DMA input. + * It returns the number entries in the scatterlist array. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct scatterlist *__sgl = (sgl); \ + int __nents = (nents); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ + __kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len); \ +}) -static inline unsigned int -kfifo_unused(struct __kfifo *fifo) -{ - return (fifo->mask + 1) - (fifo->in - fifo->out); -} - -static inline int -linux_kfifo_alloc(struct __kfifo *fifo, unsigned int size, - size_t esize, gfp_t gfp_mask) -{ - /* - * round down to the next power of 2, since our 'let the indices - * wrap' technique works only in this case. - */ - size = roundup_pow_of_two(size); - - fifo->in = 0; - fifo->out = 0; - fifo->esize = esize; - - if (size < 2) { - fifo->data = NULL; - fifo->mask = 0; - return -EINVAL; - } - - fifo->data = kmalloc(size * esize, gfp_mask); - - if (!fifo->data) { - fifo->mask = 0; - return -ENOMEM; - } - fifo->mask = size - 1; - - return 0; -} - -static inline void -linux_kfifo_free(struct __kfifo *fifo) -{ - kfree(fifo->data); - fifo->in = 0; - fifo->out = 0; - fifo->esize = 0; - fifo->data = NULL; - fifo->mask = 0; -} - -static inline void -kfifo_copy_in(struct __kfifo *fifo, const void *src, - unsigned int len, unsigned int off) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - memcpy(fifo->data + off, src, l); - memcpy(fifo->data, src + l, len - l); - /* - * make sure that the data in the fifo is up to date before - * incrementing the fifo->in index counter - */ - smp_wmb(); -} - -static inline unsigned int -linux_kfifo_in(struct __kfifo *fifo, - const void *buf, unsigned int len) -{ - unsigned int l; - - l = kfifo_unused(fifo); - if (len > l) - len = l; - - kfifo_copy_in(fifo, buf, len, fifo->in); - fifo->in += len; - return len; -} +/** + * kfifo_dma_in_finish - finish a DMA IN operation + * @fifo: address of the fifo to be used + * @len: number of bytes to received + * + * This macro finish a DMA IN operation. The in counter will be updated by + * the len parameter. No error checking will be done. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_in_finish(fifo, len) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \ + else \ + __kfifo->in += __len / sizeof(*__tmp->type); \ +}) -static inline void -kfifo_copy_out(struct __kfifo *fifo, void *dst, - unsigned int len, unsigned int off) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - memcpy(dst, fifo->data + off, l); - memcpy(dst + l, fifo->data, len - l); - /* - * make sure that the data is copied before - * incrementing the fifo->out index counter - */ - smp_wmb(); -} +/** + * kfifo_dma_out_prepare - setup a scatterlist for DMA output + * @fifo: address of the fifo to be used + * @sgl: pointer to the scatterlist array + * @nents: number of entries in the scatterlist array + * @len: number of elements to transfer + * + * This macro fills a scatterlist for DMA output which at most @len bytes + * to transfer. + * It returns the number entries in the scatterlist array. + * A zero means there is no space available and the scatterlist is not filled. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct scatterlist *__sgl = (sgl); \ + int __nents = (nents); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ + __kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len); \ +}) -static inline unsigned int -linux_kfifo_out_peek(struct __kfifo *fifo, - void *buf, unsigned int len) -{ - unsigned int l; +/** + * kfifo_dma_out_finish - finish a DMA OUT operation + * @fifo: address of the fifo to be used + * @len: number of bytes transferred + * + * This macro finish a DMA OUT operation. The out counter will be updated by + * the len parameter. No error checking will be done. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_out_finish(fifo, len) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_dma_out_finish_r(__kfifo, __recsize); \ + else \ + __kfifo->out += __len / sizeof(*__tmp->type); \ +}) - l = fifo->in - fifo->out; - if (len > l) - len = l; +/** + * kfifo_out_peek - gets some data from the fifo + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * + * This macro get the data from the fifo and return the numbers of elements + * copied. The data is not removed from the fifo. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_out_peek(fifo, buf, n) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof(__tmp->ptr) __buf = (buf); \ + unsigned long __n = (n); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \ + __kfifo_out_peek(__kfifo, __buf, __n); \ +}) \ +) - kfifo_copy_out(fifo, buf, len, fifo->out); - return len; -} +extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, + size_t esize, gfp_t gfp_mask); -static inline unsigned int -linux_kfifo_out(struct __kfifo *fifo, - void *buf, unsigned int len) -{ - len = linux_kfifo_out_peek(fifo, buf, len); - fifo->out += len; - return len; -} +extern void __kfifo_free(struct __kfifo *fifo); extern int __kfifo_init(struct __kfifo *fifo, void *buffer, unsigned int size, size_t esize); +extern unsigned int __kfifo_in(struct __kfifo *fifo, + const void *buf, unsigned int len); + +extern unsigned int __kfifo_out(struct __kfifo *fifo, + void *buf, unsigned int len); + extern int __kfifo_from_user(struct __kfifo *fifo, const void __user *from, unsigned long len, unsigned int *copied); @@ -513,6 +795,8 @@ extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, struct scatterlist *sgl, int nents, unsigned int len); +extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, + void *buf, unsigned int len); extern unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, unsigned int len, size_t recsize); diff --git a/linuxkpi/gplv2/src/linux_acpi.c b/linuxkpi/gplv2/src/linux_acpi.c index 438bd4f23..4ba3e1c01 100644 --- a/linuxkpi/gplv2/src/linux_acpi.c +++ b/linuxkpi/gplv2/src/linux_acpi.c @@ -1,3 +1,5 @@ +#ifdef CONFIG_ACPI + #include #include #include @@ -399,3 +401,5 @@ u32 acpi_target_system_state(void) return linuxkpi_acpi_target_sleep_state; } #endif + +#endif diff --git a/linuxkpi/gplv2/src/linux_i2c.c b/linuxkpi/gplv2/src/linux_i2c.c index 5a606707a..3fc1f1992 100644 --- a/linuxkpi/gplv2/src/linux_i2c.c +++ b/linuxkpi/gplv2/src/linux_i2c.c @@ -89,7 +89,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef CONFIG_ACPI #include +#endif #include #include #include @@ -106,6 +108,9 @@ static DEFINE_MUTEX(i2c_core); static struct class *i2c_class; +// BDRAGON +#include + /* * XXX needs to be updated to use "virtual" lock_bus functions * @@ -616,12 +621,14 @@ i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) static void i2c_dev_set_name(struct i2c_adapter *adap, struct i2c_client *client) { +#ifdef CONFIG_ACPI struct acpi_device *adev = ACPI_COMPANION(&client->dev); if (adev) { dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); return; } +#endif dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), i2c_encode_flags_to_addr(client)); diff --git a/linuxkpi/gplv2/src/linux_notifier.c b/linuxkpi/gplv2/src/linux_notifier.c index a4098d133..063be0e43 100644 --- a/linuxkpi/gplv2/src/linux_notifier.c +++ b/linuxkpi/gplv2/src/linux_notifier.c @@ -5,7 +5,10 @@ #include #include +#include +#ifdef CONFIG_ACPI #include +#endif #include #include #include @@ -174,6 +177,7 @@ acpi_lid_notifier_unregister(struct notifier_block *nb) return (0); } +#ifdef CONFIG_ACPI int register_acpi_notifier(struct notifier_block *nb) { @@ -187,6 +191,7 @@ unregister_acpi_notifier(struct notifier_block *nb) WARN_NOT(); return (0); } +#endif int register_oom_notifier(struct notifier_block *nb) diff --git a/linuxkpi/gplv2/src/linux_page.c b/linuxkpi/gplv2/src/linux_page.c index 103470fbc..87f3559ff 100644 --- a/linuxkpi/gplv2/src/linux_page.c +++ b/linuxkpi/gplv2/src/linux_page.c @@ -48,7 +48,7 @@ #include -#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv__) +#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv__) || defined(__powerpc64__) #define LINUXKPI_HAVE_DMAP #else #undef LINUXKPI_HAVE_DMAP @@ -57,15 +57,20 @@ extern u_int cpu_feature; extern u_int cpu_stdext_feature; +int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size); +void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size); + void __linux_clflushopt(u_long addr) { +#if !defined(__powerpc64__) if (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) clflushopt(addr); else if (cpu_feature & CPUID_CLFSH) clflush(addr); else pmap_invalidate_cache(); +#endif } void * @@ -169,7 +174,7 @@ set_pages_uc(vm_page_t page, int numpages) int set_memory_wc(unsigned long addr, int numpages) { - return (pmap_change_attr(addr, numpages, PAT_WRITE_COMBINING)); + return (pmap_change_attr(addr, numpages, VM_MEMATTR_WRITE_COMBINING)); } int @@ -184,7 +189,7 @@ set_pages_wc(vm_page_t page, int numpages) int set_memory_wb(unsigned long addr, int numpages) { - return (pmap_change_attr(addr, numpages, PAT_WRITE_BACK)); + return (pmap_change_attr(addr, numpages, VM_MEMATTR_WRITE_BACK)); } int