From patchwork Tue Jan 8 09:58:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Jain X-Patchwork-Id: 1021822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Ynn802WVz9sMQ for ; Tue, 8 Jan 2019 21:00:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43Ynn75hq3zDqSS for ; Tue, 8 Jan 2019 21:00:11 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=vaibhav@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43YnmH6rTvzDqSf for ; Tue, 8 Jan 2019 20:59:27 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x089x7jZ180948 for ; Tue, 8 Jan 2019 04:59:25 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2pvr7jd5sn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 08 Jan 2019 04:59:25 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jan 2019 09:59:23 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 8 Jan 2019 09:59:22 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x089xKAI12648688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Jan 2019 09:59:20 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CC28AE04D; Tue, 8 Jan 2019 09:59:20 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F0DCAE051; Tue, 8 Jan 2019 09:59:18 +0000 (GMT) Received: from vajain21.in.ibm.com (unknown [9.109.223.28]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 8 Jan 2019 09:59:18 +0000 (GMT) From: Vaibhav Jain To: Frederic Barrat , Andrew Donnellan , Christophe Lombard , Stewart Smith , Vasant Hegde Date: Tue, 8 Jan 2019 15:28:55 +0530 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190108095902.24718-1-vaibhav@linux.ibm.com> References: <20190108095902.24718-1-vaibhav@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19010809-0016-0000-0000-00000241DE1A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19010809-0017-0000-0000-0000329BF0C9 Message-Id: <20190108095902.24718-2-vaibhav@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-08_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901080082 Subject: [Skiboot] [PATCH v3 1/8] opal: Update opal_del_host_sync_notifier() to accept 'void *data' X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: skiboot@lists.ozlabs.org Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Current implementation of opal_del_host_sync_notifier() will only delete the first entry of the 'notify' callback found from opal_syncers list irrespective of the 'data' of list-node. This is problematic when multiple notifiers with same callback function but different 'data' are registered. In this case when the cleanup code will call opal_del_host_sync_notifier() it cannot be sure if correct opal_syncer is removed. Hence this patch updates the function to accept a new argument named 'void *data' which is then used to iterates over the opal_syncers list and only remove the first node node having the matching value for 'notify' callback as 'data'. Reviewed-by: Andrew Donnellan Reviewed-by: Christophe Lombard Reviewed-by: Vasant Hegde Signed-off-by: Vaibhav Jain Reviewed-by: Frederic Barrat --- Change-log v3: None/Respining the patchset v2: Instead of introducing a new function, update the existing function opal_del_host_sync_notifier() to accept 'void *data' [Vasant] --- core/opal.c | 7 +++++-- include/opal-internal.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/opal.c b/core/opal.c index 3a8ea30b..87aca61c 100644 --- a/core/opal.c +++ b/core/opal.c @@ -683,12 +683,15 @@ void opal_add_host_sync_notifier(bool (*notify)(void *data), void *data) list_add_tail(&opal_syncers, &ent->link); } -void opal_del_host_sync_notifier(bool (*notify)(void *data)) +/* + * Remove a host sync notifier for given callback and data + */ +void opal_del_host_sync_notifier(bool (*notify)(void *data), void *data) { struct opal_sync_entry *ent; list_for_each(&opal_syncers, ent, link) { - if (ent->notify == notify) { + if (ent->notify == notify && ent->data == data) { list_del(&ent->link); free(ent); return; diff --git a/include/opal-internal.h b/include/opal-internal.h index 40bad457..2ce25adb 100644 --- a/include/opal-internal.h +++ b/include/opal-internal.h @@ -76,7 +76,7 @@ extern void opal_run_pollers(void); * Warning: no locking, only call that from the init processor */ extern void opal_add_host_sync_notifier(bool (*notify)(void *data), void *data); -extern void opal_del_host_sync_notifier(bool (*notify)(void *data)); +extern void opal_del_host_sync_notifier(bool (*notify)(void *data), void *data); /* * Opal internal function prototype