Re: compress: funopen error handling
On Sat, 31 Jan 2015 16:40:48 +0100, Tobias Stoeckmann wrote: this diff adds error handling for funopen() failure. I have also fixed a whitespace issue for proper intendation. OK millert@ - todd
compress: funopen error handling
Hi, this diff adds error handling for funopen() failure. I have also fixed a whitespace issue for proper intendation. Tobias Index: usr.bin/compress/zopen.c === RCS file: /cvs/src/usr.bin/compress/zopen.c,v retrieving revision 1.19 diff -u -p -r1.19 zopen.c --- usr.bin/compress/zopen.c16 Jan 2015 06:40:06 - 1.19 +++ usr.bin/compress/zopen.c31 Jan 2015 15:36:23 - @@ -278,7 +278,7 @@ zwrite(void *cookie, const char *wbp, in /* Secondary hash (after G. Knott). */ disp = zs-zs_hsize_reg - i; if (i == 0) - disp = 1; + disp = 1; probe: if ((i -= disp) 0) i += zs-zs_hsize_reg; @@ -738,6 +738,7 @@ cl_hash(struct s_zstate *zs, count_int c FILE * zopen(const char *name, const char *mode, int bits) { + FILE *fp; int fd; void *cookie; if ((fd = open(name, (*mode=='r'? O_RDONLY:O_WRONLY|O_CREAT), @@ -747,8 +748,13 @@ zopen(const char *name, const char *mode close(fd); return NULL; } - return funopen(cookie, (*mode == 'r'?zread:NULL), - (*mode == 'w'?zwrite:NULL), NULL, zclose); + if ((fp = funopen(cookie, (*mode == 'r'?zread:NULL), + (*mode == 'w'?zwrite:NULL), NULL, zclose)) == NULL) { + close(fd); + free(cookie); + return NULL; + } + return fp; } void *
additional drm fixes from linux-stable 3.10.y
Some test reports with this would be great. In particular for radeon. drm/i915: Fix mutex-owner inspection race under DEBUG_MUTEXES drm/i915: Force the CS stall for invalidate flushes drm/i915: Invalidate media caches on gen7 drm/radeon: properly filter DP1.2 4k modes on non-DP1.2 hw drm/radeon: check the right ring in radeon_evict_flags() drm/i915: Unlock panel even when LVDS is disabled drm_calc_vbltimestamp_from_scanoutpos with 3.18.0-rc6 drm/radeon: add missing crtc unlock when setting up the MC drm/radeon: add connector quirk for fujitsu board drm/i915: Wait for vblank before enabling the TV encoder drm/i915: Remove bogus __init annotation from DMI callbacks drm/i915: read HEAD register back in init_ring_common() to enforce ordering drm/radeon: load the lm63 driver for an lm64 thermal chip. drm/radeon: avoid leaking edid data drm/radeon: set default bl level to something reasonable drm/radeon: stop poisoning the GART TLB diff --git sys/dev/pci/drm/i915/i915_gem.c sys/dev/pci/drm/i915/i915_gem.c index d42b923..95e351f 100644 --- sys/dev/pci/drm/i915/i915_gem.c +++ sys/dev/pci/drm/i915/i915_gem.c @@ -4596,7 +4596,7 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task) if (!mutex_is_locked(mutex)) return false; -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES) +#if defined(CONFIG_SMP) !defined(CONFIG_DEBUG_MUTEXES) return mutex-owner == task; #else /* Since UP may be pre-empted, we cannot assume that we own the lock */ diff --git sys/dev/pci/drm/i915/i915_reg.h sys/dev/pci/drm/i915/i915_reg.h index cf447cf..b4b25bc 100644 --- sys/dev/pci/drm/i915/i915_reg.h +++ sys/dev/pci/drm/i915/i915_reg.h @@ -305,6 +305,7 @@ #define PIPE_CONTROL_GLOBAL_GTT_IVB (124) /* gen7+ */ #define PIPE_CONTROL_CS_STALL(120) #define PIPE_CONTROL_TLB_INVALIDATE (118) +#define PIPE_CONTROL_MEDIA_STATE_CLEAR (116) #define PIPE_CONTROL_QW_WRITE(114) #define PIPE_CONTROL_DEPTH_STALL (113) #define PIPE_CONTROL_WRITE_FLUSH (112) diff --git sys/dev/pci/drm/i915/intel_bios.c sys/dev/pci/drm/i915/intel_bios.c index 88406ad..47a0285 100644 --- sys/dev/pci/drm/i915/intel_bios.c +++ sys/dev/pci/drm/i915/intel_bios.c @@ -660,7 +660,7 @@ init_vbt_defaults(struct drm_i915_private *dev_priv) DRM_DEBUG_KMS(Set default to SSC at %dMHz\n, dev_priv-lvds_ssc_freq); } -static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id) +static int intel_no_opregion_vbt_callback(const struct dmi_system_id *id) { DRM_DEBUG_KMS(Falling back to manually reading VBT from VBIOS ROM for %s\n, diff --git sys/dev/pci/drm/i915/intel_crt.c sys/dev/pci/drm/i915/intel_crt.c index adbbadf..9e8f01d 100644 --- sys/dev/pci/drm/i915/intel_crt.c +++ sys/dev/pci/drm/i915/intel_crt.c @@ -714,7 +714,7 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = { .destroy = intel_encoder_destroy, }; -static int __init intel_no_crt_dmi_callback(const struct dmi_system_id *id) +static int intel_no_crt_dmi_callback(const struct dmi_system_id *id) { printf(Skipping CRT initialization for %s\n, id-ident); return 1; diff --git sys/dev/pci/drm/i915/intel_lvds.c sys/dev/pci/drm/i915/intel_lvds.c index 6c18e63..5b00c6f 100644 --- sys/dev/pci/drm/i915/intel_lvds.c +++ sys/dev/pci/drm/i915/intel_lvds.c @@ -636,7 +636,7 @@ static const struct drm_encoder_funcs intel_lvds_enc_funcs = { .destroy = intel_encoder_destroy, }; -static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id) +static int intel_no_lvds_dmi_callback(const struct dmi_system_id *id) { printf(Skipping LVDS initialization for %s\n, id-ident); return 1; @@ -984,6 +984,17 @@ bool intel_lvds_init(struct drm_device *dev) int pipe; u8 pin; + /* +* Unlock registers and just leave them unlocked. Do this before +* checking quirk lists to avoid bogus WARNINGs. +*/ + if (HAS_PCH_SPLIT(dev)) { + I915_WRITE(PCH_PP_CONTROL, + I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS); + } else { + I915_WRITE(PP_CONTROL, + I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS); + } if (!intel_lvds_supported(dev)) return false; @@ -1154,17 +1165,6 @@ bool intel_lvds_init(struct drm_device *dev) goto failed; out: - /* -* Unlock registers and just -* leave them unlocked -*/ - if (HAS_PCH_SPLIT(dev)) { - I915_WRITE(PCH_PP_CONTROL, - I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS); - } else { - I915_WRITE(PP_CONTROL, - I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS); - }
Re: [dhcpd] Too many call to remove ip from pf's table
bumping this legit patch. On Thu, Jan 22, 2015 at 6:48 PM, Bertrand PROVOST provost.bertr...@gmail.com wrote: Hello, Based on a patch[1] found on the mailing list, I added a link between dhcpd and unbound to be able to resolve name of all client that have a lease on dhcpd. And I found a bug in the function 'periodic_scan' which is called every X second (X = half of the minimum lease duration). This function check all leases and for each expired leases, it call `release_lease' and remove from pf table `leases' the associated ip to this lease. 1) Calling `release_lease' in dhcpd.c, in `periodic_scan' is irrelevant. The function `release_lease' would be used to trigger this part of code. This function check if the leases is NOT yet expired and then change the end time of the lease to `cur_time' So it do nothing if this condition is false: if (lt.ends cur_time) And this condition cannot be true when it's called in `periodic_scan' because we check that the lease has already expire if (cur_time = l-ends){ 2) This function would remove an IP address from a pf's table again and again. Then, for example, if the shortest leases time is 10 minutes, every 5 minutes, this code will be call: pfmsg('R', l); So I choose to add a condition that check this was not called on previous scan. I don't know if this can be a problem because this ip should be handle only by one dhcpd server. But in case or we want add manually this ip in the table, it will be removed every time that, the function `periodic_scan` is called [1] http://marc.info/?l=openbsd-techm=118039557923827 -- Bertrand PROVOST Index: dhcpd.c === RCS file: /cvs/src/usr.sbin/dhcpd/dhcpd.c,v retrieving revision 1.46 diff -u -p -r1.46 dhcpd.c --- dhcpd.c 16 Jan 2015 06:40:16 - 1.46 +++ dhcpd.c 22 Jan 2015 19:15:55 - @@ -48,6 +48,7 @@ void usage(void); time_t cur_time; +time_t last_periodic_scan_time; struct group root_group; u_int16_t server_port; @@ -347,10 +348,10 @@ periodic_scan(void *p) for (g = n-group; g; g = g-next) for (s = g-shared_network; s; s = s-next) for (l = s-leases; l l-ends; l = l-next) - if (cur_time = l-ends){ - release_lease(l); + if (cur_time = l-ends l-ends last_periodic_scan_time){ pfmsg('R', l); } + last_periodic_scan_time = cur_time; add_timeout(cur_time + y, periodic_scan, NULL); } -- - () ascii ribbon campaign - against html e-mail /\
Re: Allow resuming with closed lid
On Fri, Jan 30, 2015 at 05:44:25PM -0500, Ted Unangst wrote: On Sat, Jan 31, 2015 at 00:24, Ville Valkonen wrote: Hello Mike and Max, my work laptop is running Windows and on there one must press power button to wake up the machine. If I connect the dots right, current behaviour was implemented to prevent a hot bag problem. Mimicking the Windows behaviour would also prevent laptop wake ups on a bumpy road. Would it make any sense to mimic this behaviour in obsd? This obviously depends on your windows config. My windows laptop resumes whenver I open the lid. Now what can maybe be improved would be to add a check for which wakeup event we received. If somebody pushed the power button, the lid closed check should probably be skipped. If the wakeup event was lid opening, then making sure the lid really is open makes sense. What Ted says makes sense. Unfortunately, it's a bit more difficult than it seems to obtain the wake source. 1. Not all machines (very few in fact) implement _SWS 2. Instrumenting a few machines to check GPEs on wake, I found that none of them were asserted in the lid-open case, the power-button case, and a few others as well. This likely means we are wiping out the status before we check it. When I checked the status during early init instead, the GPE status bits were either all on, or all off, or filled with random data. In a nutshell, I haven't yet found a good way to determine the wake source that works on all machines. A diff that properly does this would certainly be welcome and go a long way toward fixing a lot of this nonsense. -ml
Re: Allow resuming with closed lid
What Ted says makes sense. Unfortunately, it's a bit more difficult than it seems to obtain the wake source. 1. Not all machines (very few in fact) implement _SWS 2. Instrumenting a few machines to check GPEs on wake, I found that none of them were asserted in the lid-open case, the power-button case, and a few others as well. This likely means we are wiping out the status before we check it. When I checked the status during early init instead, the GPE status bits were either all on, or all off, or filled with random data. In a nutshell, I haven't yet found a good way to determine the wake source that works on all machines. A diff that properly does this would certainly be welcome and go a long way toward fixing a lot of this nonsense. Yes, that is essentially the problem. We have some on/off events that sometimes work, and we have some true/false state we can probe ... sometimes. The frameworks underneath seem unreliable. It might be bugs in our acpi stack, but quite likely there are also variations (bugs) in the machines themselves... (If these issues are not identified and improved, we could hackishly move the decision making to a timeout-based codepath which will have more information..)
usbhidctl(1) regression
Last year big HID parser modification introduced a regression reported by Benjamin Baier [0]. He confirmed that the diff below fixes it for his use case. I'm looking for more tests to know if this does not break anything else. [0] http://marc.info/?l=openbsd-bugsm=142153086729320w=2 Index: parse.c === RCS file: /cvs/src/lib/libusbhid/parse.c,v retrieving revision 1.10 diff -u -p -r1.10 parse.c --- parse.c 18 Jan 2015 17:16:06 - 1.10 +++ parse.c 31 Jan 2015 11:34:55 - @@ -67,6 +67,8 @@ struct hid_data { uint8_t ousage; /* current usages_min/max offset */ uint8_t susage; /* usage set flags */ int32_t reportid; /* requested report ID */ + struct hid_item savedcoll; /* save coll until we know the ID */ + uint8_t hassavedcoll; }; static void @@ -151,6 +153,7 @@ hid_start_parse(report_desc_t d, int kin s-end = d-data + d-size; s-kindset = kindset; s-reportid = id; + s-hassavedcoll = 0; return (s); } @@ -191,10 +194,20 @@ hid_get_byte(struct hid_data *s, const u return (retval); } +#define REPORT_SAVED_COLL \ + do { \ + if (s-hassavedcoll) { \ + *h = s-savedcoll; \ + h-report_ID = c-report_ID; \ + s-hassavedcoll = 0; \ + return (1); \ + } \ + } while(0) + static int hid_get_item_raw(hid_data_t s, hid_item_t *h) { - hid_item_t *c; + hid_item_t nc, *c; unsigned int bTag, bType, bSize; int32_t mask; int32_t dval; @@ -207,6 +220,7 @@ hid_get_item_raw(hid_data_t s, hid_item_ top: /* check if there is an array of items */ if (s-icount s-ncount) { + REPORT_SAVED_COLL; /* get current usage */ if (s-iusage s-nusage) { dval = s-usages_min[s-iusage] + s-ousage; @@ -328,13 +342,23 @@ hid_get_item_raw(hid_data_t s, hid_item_ c-collection = dval; c-collevel++; c-usage = s-usage_last; - *h = *c; - return (1); + nc = *c; + if (s-hassavedcoll) { + *h = s-savedcoll; + h-report_ID = nc.report_ID; + s-savedcoll = nc; + return (1); + } else { + s-hassavedcoll = 1; + s-savedcoll = nc; + } + goto top; case 11:/* Feature */ c-kind = hid_feature; c-flags = dval; goto ret; case 12:/* End collection */ + REPORT_SAVED_COLL; c-kind = hid_endcollection; if (c-collevel == 0) { /* Invalid end collection. */