From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758036AbcFHVPh (ORCPT ); Wed, 8 Jun 2016 17:15:37 -0400 Received: from mail1.bemta12.messagelabs.com ([216.82.251.12]:7115 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756106AbcFHVOm (ORCPT ); Wed, 8 Jun 2016 17:14:42 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRWlGSWpSXmKPExsVywNY2Q/dgV0S 4wc3PHBYL25awWFzeNYfNgcnj8ya5AMYo1sy8pPyKBNaMlm0fmQreeVdcXhfWwDjLvouRi0NI YBejxPfHy1kgnEOMEm2f3zDDOa3HDrJCOJcYJbbv+s4I4axllNj/ZglUzxZGiUdNH4F6ODnYB AwkZt65yw5iiwicZ5F4eiu3i5GDg1lATeLGd0uQsLCAn8TS91dYQWwWARWJm28/gbXyCnhJvL rVzwZiSwjISZw8NhmshhMo/vDXWiYQW0jAU6Ll3WN2CFtN4vDZR1D1wRJH/85jhZgjKHFy5hM WEJtZQELi4IsXzBMYhWchSc1CklrAyLSKUaM4tagstUjXyFgvqSgzPaMkNzEzR9fQ0EgvN7W4 ODE9NScxqVgvOT93EyMwuOsZGBh3MK6e7nWIUZKDSUmUt8w9IlyILyk/pTIjsTgjvqg0J7X4E KMMB4eSBO+3DqCcYFFqempFWmYOMM5g0hIcPEoivEGdQGne4oLE3OLMdIjUKUZFKXFeO5CEAE giozQPrg0W25cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfNagEzhycwrgZv+CmgxE9Di5Uf CQRaXJCKkpBoYm/dd6vDJCmPM/XbknspbuW0PQiLMdm6Jvvd92UaZa4/MeJj1Ss/5MOr+q3pV O+XoR9PFj/fbN+/8+ZLjz5sIrYCNJrqss+oWLFCTjrsR66W7/MLhQ7vUDb+nLVNLKUjMUNE48 L3e777JlbSeDcw7Ai7E9Mvobtne/8Pxfbm8qYbDgXveYh8llViKMxINtZiLihMBr4avkOgCAA A= X-Env-Sender: David.Kershner@unisys.com X-Msg-Ref: server-16.tower-164.messagelabs.com!1465420478!19132149!6 X-Originating-IP: [192.61.61.104] X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked From: David Kershner To: , , , , , , , , , , , , , , , , , , , , , CC: Tim Sell Subject: [PATCH v4 11/29] staging: unisys: visorbus: remove periodic_work.h/.c Date: Wed, 8 Jun 2016 17:14:05 -0400 Message-ID: <1465420463-24982-12-git-send-email-david.kershner@unisys.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465420463-24982-1-git-send-email-david.kershner@unisys.com> References: <1465420463-24982-1-git-send-email-david.kershner@unisys.com> X-OriginalArrivalTime: 08 Jun 2016 21:14:28.0388 (UTC) FILETIME=[BDE48640:01D1C1CA] MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tim Sell These files were made no-longer-necessary by recent commits. Signed-off-by: Tim Sell Signed-off-by: David Kershner --- drivers/staging/unisys/include/periodic_work.h | 40 ----- drivers/staging/unisys/visorbus/Makefile | 1 - drivers/staging/unisys/visorbus/periodic_work.c | 204 ------------------------ drivers/staging/unisys/visorbus/visorchipset.c | 1 - 4 files changed, 246 deletions(-) delete mode 100644 drivers/staging/unisys/include/periodic_work.h delete mode 100644 drivers/staging/unisys/visorbus/periodic_work.c diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h deleted file mode 100644 index 0b3335a..0000000 --- a/drivers/staging/unisys/include/periodic_work.h +++ /dev/null @@ -1,40 +0,0 @@ -/* periodic_work.h - * - * Copyright (C) 2010 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -#ifndef __PERIODIC_WORK_H__ -#define __PERIODIC_WORK_H__ - -#include -#include - -/* PERIODIC_WORK an opaque structure to users. - * Fields are declared only in the implementation .c files. - */ -struct periodic_work; - -struct periodic_work * -visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam); -void visor_periodic_work_destroy(struct periodic_work *pw); -bool visor_periodic_work_nextperiod(struct periodic_work *pw); -bool visor_periodic_work_start(struct periodic_work *pw); -bool visor_periodic_work_stop(struct periodic_work *pw); - -#endif diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index fc790e7..f3730d8 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -7,6 +7,5 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o visorbus-y += visorchannel.o visorbus-y += visorchipset.o -visorbus-y += periodic_work.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorbus/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c deleted file mode 100644 index 00b1527..0000000 --- a/drivers/staging/unisys/visorbus/periodic_work.c +++ /dev/null @@ -1,204 +0,0 @@ -/* periodic_work.c - * - * Copyright (C) 2010 - 2015 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -/* - * Helper functions to schedule periodic work in Linux kernel mode. - */ -#include - -#include "periodic_work.h" - -#define MYDRVNAME "periodic_work" - -struct periodic_work { - rwlock_t lock; - struct delayed_work work; - void (*workfunc)(void *); - void *workfuncarg; - bool is_scheduled; - bool want_to_stop; - ulong jiffy_interval; - struct workqueue_struct *workqueue; - const char *devnam; -}; - -static void periodic_work_func(struct work_struct *work) -{ - struct periodic_work *pw; - - pw = container_of(work, struct periodic_work, work.work); - (*pw->workfunc)(pw->workfuncarg); -} - -struct periodic_work -*visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam) -{ - struct periodic_work *pw; - - pw = kzalloc(sizeof(*pw), GFP_KERNEL | __GFP_NORETRY); - if (!pw) - return NULL; - - rwlock_init(&pw->lock); - pw->jiffy_interval = jiffy_interval; - pw->workqueue = workqueue; - pw->workfunc = workfunc; - pw->workfuncarg = workfuncarg; - pw->devnam = devnam; - return pw; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_create); - -void visor_periodic_work_destroy(struct periodic_work *pw) -{ - kfree(pw); -} -EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); - -/** Call this from your periodic work worker function to schedule the next - * call. - * If this function returns false, there was a failure and the - * periodic work is no longer scheduled - */ -bool visor_periodic_work_nextperiod(struct periodic_work *pw) -{ - bool rc = false; - - write_lock(&pw->lock); - if (pw->want_to_stop) { - pw->is_scheduled = false; - pw->want_to_stop = false; - rc = true; /* yes, true; see visor_periodic_work_stop() */ - goto unlock; - } else if (!queue_delayed_work(pw->workqueue, &pw->work, - pw->jiffy_interval)) { - pw->is_scheduled = false; - rc = false; - goto unlock; - } - rc = true; -unlock: - write_unlock(&pw->lock); - return rc; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); - -/** This function returns true iff new periodic work was actually started. - * If this function returns false, then no work was started - * (either because it was already started, or because of a failure). - */ -bool visor_periodic_work_start(struct periodic_work *pw) -{ - bool rc = false; - - write_lock(&pw->lock); - if (pw->is_scheduled) { - rc = false; - goto unlock; - } - if (pw->want_to_stop) { - rc = false; - goto unlock; - } - INIT_DELAYED_WORK(&pw->work, &periodic_work_func); - if (!queue_delayed_work(pw->workqueue, &pw->work, - pw->jiffy_interval)) { - rc = false; - goto unlock; - } - pw->is_scheduled = true; - rc = true; -unlock: - write_unlock(&pw->lock); - return rc; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_start); - -/** This function returns true iff your call actually stopped the periodic - * work. - * - * -- PAY ATTENTION... this is important -- - * - * NO NO #1 - * - * Do NOT call this function from some function that is running on the - * same workqueue as the work you are trying to stop might be running - * on! If you violate this rule, visor_periodic_work_stop() MIGHT work, - * but it also MIGHT get hung up in an infinite loop saying - * "waiting for delayed work...". This will happen if the delayed work - * you are trying to cancel has been put in the workqueue list, but can't - * run yet because we are running that same workqueue thread right now. - * - * Bottom line: If you need to call visor_periodic_work_stop() from a - * workitem, be sure the workitem is on a DIFFERENT workqueue than the - * workitem that you are trying to cancel. - * - * If I could figure out some way to check for this "no no" condition in - * the code, I would. It would have saved me the trouble of writing this - * long comment. And also, don't think this is some "theoretical" race - * condition. It is REAL, as I have spent the day chasing it. - * - * NO NO #2 - * - * Take close note of the locks that you own when you call this function. - * You must NOT own any locks that are needed by the periodic work - * function that is currently installed. If you DO, a deadlock may result, - * because stopping the periodic work often involves waiting for the last - * iteration of the periodic work function to complete. Again, if you hit - * this deadlock, you will get hung up in an infinite loop saying - * "waiting for delayed work...". - */ -bool visor_periodic_work_stop(struct periodic_work *pw) -{ - bool stopped_something = false; - - write_lock(&pw->lock); - stopped_something = pw->is_scheduled && (!pw->want_to_stop); - while (pw->is_scheduled) { - pw->want_to_stop = true; - if (cancel_delayed_work(&pw->work)) { - /* We get here if the delayed work was pending as - * delayed work, but was NOT run. - */ - WARN_ON(!pw->is_scheduled); - pw->is_scheduled = false; - } else { - /* If we get here, either the delayed work: - * - was run, OR, - * - is running RIGHT NOW on another processor, OR, - * - wasn't even scheduled (there is a miniscule - * timing window where this could be the case) - * flush_workqueue() would make sure it is finished - * executing, but that still isn't very useful, which - * explains the loop... - */ - } - if (pw->is_scheduled) { - write_unlock(&pw->lock); - schedule_timeout_interruptible(msecs_to_jiffies(10)); - write_lock(&pw->lock); - } else { - pw->want_to_stop = false; - } - } - write_unlock(&pw->lock); - return stopped_something; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_stop); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 7f44913..b668b80 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -29,7 +29,6 @@ #include "controlvmchannel.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" -#include "periodic_work.h" #include "version.h" #include "visorbus.h" #include "visorbus_private.h" -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: David Kershner Subject: [PATCH v4 11/29] staging: unisys: visorbus: remove periodic_work.h/.c Date: Wed, 8 Jun 2016 17:14:05 -0400 Message-ID: <1465420463-24982-12-git-send-email-david.kershner@unisys.com> In-Reply-To: <1465420463-24982-1-git-send-email-david.kershner@unisys.com> References: <1465420463-24982-1-git-send-email-david.kershner@unisys.com> MIME-Version: 1.0 Content-Type: text/plain List-ID: To: corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, david.kershner@unisys.com, gregkh@linuxfoundation.org, erik.arfvidson@unisys.com, timothy.sell@unisys.com, hofrat@osadl.org, dzickus@redhat.com, jes.sorensen@redhat.com, alexander.curtin@unisys.com, janani.rvchndrn@gmail.com, sudipm.mukherjee@gmail.com, prarit@redhat.com, david.binder@unisys.com, nhorman@redhat.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, driverdev-devel@linuxdriverproject.org, sparmaintainer@unisys.com Cc: Tim Sell From: Tim Sell These files were made no-longer-necessary by recent commits. Signed-off-by: Tim Sell Signed-off-by: David Kershner --- drivers/staging/unisys/include/periodic_work.h | 40 ----- drivers/staging/unisys/visorbus/Makefile | 1 - drivers/staging/unisys/visorbus/periodic_work.c | 204 ------------------------ drivers/staging/unisys/visorbus/visorchipset.c | 1 - 4 files changed, 246 deletions(-) delete mode 100644 drivers/staging/unisys/include/periodic_work.h delete mode 100644 drivers/staging/unisys/visorbus/periodic_work.c diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h deleted file mode 100644 index 0b3335a..0000000 --- a/drivers/staging/unisys/include/periodic_work.h +++ /dev/null @@ -1,40 +0,0 @@ -/* periodic_work.h - * - * Copyright (C) 2010 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -#ifndef __PERIODIC_WORK_H__ -#define __PERIODIC_WORK_H__ - -#include -#include - -/* PERIODIC_WORK an opaque structure to users. - * Fields are declared only in the implementation .c files. - */ -struct periodic_work; - -struct periodic_work * -visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam); -void visor_periodic_work_destroy(struct periodic_work *pw); -bool visor_periodic_work_nextperiod(struct periodic_work *pw); -bool visor_periodic_work_start(struct periodic_work *pw); -bool visor_periodic_work_stop(struct periodic_work *pw); - -#endif diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile index fc790e7..f3730d8 100644 --- a/drivers/staging/unisys/visorbus/Makefile +++ b/drivers/staging/unisys/visorbus/Makefile @@ -7,6 +7,5 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o visorbus-y := visorbus_main.o visorbus-y += visorchannel.o visorbus-y += visorchipset.o -visorbus-y += periodic_work.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorbus/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c deleted file mode 100644 index 00b1527..0000000 --- a/drivers/staging/unisys/visorbus/periodic_work.c +++ /dev/null @@ -1,204 +0,0 @@ -/* periodic_work.c - * - * Copyright (C) 2010 - 2015 UNISYS CORPORATION - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -/* - * Helper functions to schedule periodic work in Linux kernel mode. - */ -#include - -#include "periodic_work.h" - -#define MYDRVNAME "periodic_work" - -struct periodic_work { - rwlock_t lock; - struct delayed_work work; - void (*workfunc)(void *); - void *workfuncarg; - bool is_scheduled; - bool want_to_stop; - ulong jiffy_interval; - struct workqueue_struct *workqueue; - const char *devnam; -}; - -static void periodic_work_func(struct work_struct *work) -{ - struct periodic_work *pw; - - pw = container_of(work, struct periodic_work, work.work); - (*pw->workfunc)(pw->workfuncarg); -} - -struct periodic_work -*visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam) -{ - struct periodic_work *pw; - - pw = kzalloc(sizeof(*pw), GFP_KERNEL | __GFP_NORETRY); - if (!pw) - return NULL; - - rwlock_init(&pw->lock); - pw->jiffy_interval = jiffy_interval; - pw->workqueue = workqueue; - pw->workfunc = workfunc; - pw->workfuncarg = workfuncarg; - pw->devnam = devnam; - return pw; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_create); - -void visor_periodic_work_destroy(struct periodic_work *pw) -{ - kfree(pw); -} -EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); - -/** Call this from your periodic work worker function to schedule the next - * call. - * If this function returns false, there was a failure and the - * periodic work is no longer scheduled - */ -bool visor_periodic_work_nextperiod(struct periodic_work *pw) -{ - bool rc = false; - - write_lock(&pw->lock); - if (pw->want_to_stop) { - pw->is_scheduled = false; - pw->want_to_stop = false; - rc = true; /* yes, true; see visor_periodic_work_stop() */ - goto unlock; - } else if (!queue_delayed_work(pw->workqueue, &pw->work, - pw->jiffy_interval)) { - pw->is_scheduled = false; - rc = false; - goto unlock; - } - rc = true; -unlock: - write_unlock(&pw->lock); - return rc; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); - -/** This function returns true iff new periodic work was actually started. - * If this function returns false, then no work was started - * (either because it was already started, or because of a failure). - */ -bool visor_periodic_work_start(struct periodic_work *pw) -{ - bool rc = false; - - write_lock(&pw->lock); - if (pw->is_scheduled) { - rc = false; - goto unlock; - } - if (pw->want_to_stop) { - rc = false; - goto unlock; - } - INIT_DELAYED_WORK(&pw->work, &periodic_work_func); - if (!queue_delayed_work(pw->workqueue, &pw->work, - pw->jiffy_interval)) { - rc = false; - goto unlock; - } - pw->is_scheduled = true; - rc = true; -unlock: - write_unlock(&pw->lock); - return rc; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_start); - -/** This function returns true iff your call actually stopped the periodic - * work. - * - * -- PAY ATTENTION... this is important -- - * - * NO NO #1 - * - * Do NOT call this function from some function that is running on the - * same workqueue as the work you are trying to stop might be running - * on! If you violate this rule, visor_periodic_work_stop() MIGHT work, - * but it also MIGHT get hung up in an infinite loop saying - * "waiting for delayed work...". This will happen if the delayed work - * you are trying to cancel has been put in the workqueue list, but can't - * run yet because we are running that same workqueue thread right now. - * - * Bottom line: If you need to call visor_periodic_work_stop() from a - * workitem, be sure the workitem is on a DIFFERENT workqueue than the - * workitem that you are trying to cancel. - * - * If I could figure out some way to check for this "no no" condition in - * the code, I would. It would have saved me the trouble of writing this - * long comment. And also, don't think this is some "theoretical" race - * condition. It is REAL, as I have spent the day chasing it. - * - * NO NO #2 - * - * Take close note of the locks that you own when you call this function. - * You must NOT own any locks that are needed by the periodic work - * function that is currently installed. If you DO, a deadlock may result, - * because stopping the periodic work often involves waiting for the last - * iteration of the periodic work function to complete. Again, if you hit - * this deadlock, you will get hung up in an infinite loop saying - * "waiting for delayed work...". - */ -bool visor_periodic_work_stop(struct periodic_work *pw) -{ - bool stopped_something = false; - - write_lock(&pw->lock); - stopped_something = pw->is_scheduled && (!pw->want_to_stop); - while (pw->is_scheduled) { - pw->want_to_stop = true; - if (cancel_delayed_work(&pw->work)) { - /* We get here if the delayed work was pending as - * delayed work, but was NOT run. - */ - WARN_ON(!pw->is_scheduled); - pw->is_scheduled = false; - } else { - /* If we get here, either the delayed work: - * - was run, OR, - * - is running RIGHT NOW on another processor, OR, - * - wasn't even scheduled (there is a miniscule - * timing window where this could be the case) - * flush_workqueue() would make sure it is finished - * executing, but that still isn't very useful, which - * explains the loop... - */ - } - if (pw->is_scheduled) { - write_unlock(&pw->lock); - schedule_timeout_interruptible(msecs_to_jiffies(10)); - write_lock(&pw->lock); - } else { - pw->want_to_stop = false; - } - } - write_unlock(&pw->lock); - return stopped_something; -} -EXPORT_SYMBOL_GPL(visor_periodic_work_stop); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 7f44913..b668b80 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -29,7 +29,6 @@ #include "controlvmchannel.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" -#include "periodic_work.h" #include "version.h" #include "visorbus.h" #include "visorbus_private.h" -- 1.9.1