From patchwork Sun Jan 13 05:37:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Jain X-Patchwork-Id: 1024027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43clk862YQz9sCX for ; Sun, 13 Jan 2019 16:37:52 +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 43clk80mrwzDqnV for ; Sun, 13 Jan 2019 16:37:52 +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 43cljv3BzczDqs6 for ; Sun, 13 Jan 2019 16:37:39 +1100 (AEDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0D5XXoW041505 for ; Sun, 13 Jan 2019 00:37:36 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pyxegsdtj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 13 Jan 2019 00:37:36 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 13 Jan 2019 05:37:35 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 13 Jan 2019 05:37:33 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0D5bV6U1442074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 13 Jan 2019 05:37:31 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66DFAA4051; Sun, 13 Jan 2019 05:37:31 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDCFEA4040; Sun, 13 Jan 2019 05:37:29 +0000 (GMT) Received: from vajain21.in.ibm.com.com (unknown [9.85.69.225]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 13 Jan 2019 05:37:29 +0000 (GMT) From: Vaibhav Jain To: Frederic Barrat , Andrew Donnellan , Christophe Lombard , Stewart Smith Date: Sun, 13 Jan 2019 11:07:08 +0530 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190113053715.23941-1-vaibhav@linux.ibm.com> References: <20190113053715.23941-1-vaibhav@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19011305-4275-0000-0000-000002FE70A2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011305-4276-0000-0000-0000380C87AE Message-Id: <20190113053715.23941-2-vaibhav@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-13_02:, , 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-1901130051 Subject: [Skiboot] [PATCH v4 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: Frederic Barrat Reviewed-by: Andrew Donnellan Reviewed-by: Christophe Lombard Reviewed-by: Vasant Hegde Signed-off-by: Vaibhav Jain --- Change-log v4: * None. Re-spinning the patchset. v3: * None. Re-spinning 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 46035e83..78869b52 100644 --- a/core/opal.c +++ b/core/opal.c @@ -685,12 +685,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