From patchwork Thu Jul 30 01:45:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9438013B6 for ; Thu, 30 Jul 2020 01:48:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E5E72083E for ; Thu, 30 Jul 2020 01:48:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gcgyM4un"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K03z21EA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E5E72083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MukqYiiDzDQR7YGQm6QJ2wxz1Rplj0anl9hU2PcxHMc=; b=gcgyM4un0IMWwGxbJmKop0q2x 4RHf9iFUnQBxwGlu4FiOosCzCJHfbeUXesvzsjETyk+dLR9Ycem1LO+xQ4PwxY0AWPo6A3TkEVCMo uP40kLH3vlrHvQZ8cSFYC/xRdYwLukfV3KBobmyzJaYd0nKSvcOEC+UXuRlyG5x7QsQJVZfyuUy/d LOc6YPhhXos8kKy2mpBN3evPcbpGEsu0B8R3jO/aa0CKR4UcS1JVCUb8gktpsO99plfbv3NViI7pq KYJBjCgg/Q4QASFMRUkf6R8kC3ldy7O+krtnwYPp2FowdmeKYHR7xkDdICgQ0lXU/+yHDXFP8L5HP CsANtBkjg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xdz-0002z5-6y; Thu, 30 Jul 2020 01:46:03 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xdt-0002xV-7L for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:45:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZx7pgX9yzml4yiO55uFCpiaVzryNBVpkuU/Xu5k2SY=; b=K03z21EApyUpC9fCI3iqnQTeG9b6m+H+R5TIzSkYzi9VuMPQuFUitG3VY8Cnf52e21Buck pGboRiGn+2h/weC/VQimBW+XKHn7czXbEwR5f1TM3ETyZuQQtRgAxoiXpWgG1d/VAippbh el6nvRr2uraa+3uYTw7UtEir8if4Kg0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-KsJfGk_2NU-WHjSZbGxdnw-1; Wed, 29 Jul 2020 21:45:53 -0400 X-MC-Unique: KsJfGk_2NU-WHjSZbGxdnw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBFA7800465; Thu, 30 Jul 2020 01:45:51 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DF4D51C4F; Thu, 30 Jul 2020 01:45:48 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 01/15] drivers/firmware/sdei: Remove sdei_is_err() Date: Thu, 30 Jul 2020 11:45:16 +1000 Message-Id: <20200730014531.310465-2-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214557_334518_E5894BEC X-CRM114-Status: GOOD ( 18.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org sdei_is_err() is only called by sdei_to_linux_errno(). The logic of checking on the error number is common to them. They can be combined finely. This removes sdei_is_err() and its logic is combined to the function sdei_to_linux_errno(). Also, the assignment of @err to zero is also dropped in invoke_sdei_fn() because it's always overridden afterwards. This shouldn't cause functional changes. Signed-off-by: Gavin Shan Reviewed-by: James Morse Reviewed-by: Jonathan Cameron --- drivers/firmware/arm_sdei.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index e7e36aab2386..be5367f839f2 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -114,26 +114,7 @@ static int sdei_to_linux_errno(unsigned long sdei_err) return -ENOMEM; } - /* Not an error value ... */ - return sdei_err; -} - -/* - * If x0 is any of these values, then the call failed, use sdei_to_linux_errno() - * to translate. - */ -static int sdei_is_err(struct arm_smccc_res *res) -{ - switch (res->a0) { - case SDEI_NOT_SUPPORTED: - case SDEI_INVALID_PARAMETERS: - case SDEI_DENIED: - case SDEI_PENDING: - case SDEI_OUT_OF_RESOURCE: - return true; - } - - return false; + return 0; } static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0, @@ -141,14 +122,13 @@ static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0, unsigned long arg3, unsigned long arg4, u64 *result) { - int err = 0; + int err; struct arm_smccc_res res; if (sdei_firmware_call) { sdei_firmware_call(function_id, arg0, arg1, arg2, arg3, arg4, &res); - if (sdei_is_err(&res)) - err = sdei_to_linux_errno(res.a0); + err = sdei_to_linux_errno(res.a0); } else { /* * !sdei_firmware_call means we failed to probe or called From patchwork Thu Jul 30 01:45:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3CAC13B6 for ; Thu, 30 Jul 2020 01:48:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F3302082E for ; Thu, 30 Jul 2020 01:48:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="v2FazYDh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M6LP5D1C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F3302082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fEjFJje+2z/bbxHXp/mtYYwbNxe3emJ1nba6RAiviZ0=; b=v2FazYDhpEF5OjlCShxeyCwUI F0N0ghcQgvhi/XWoVbdeynMxvt124UpXUITuAWOKVBbcYJTShvhKDjZZhKNK7OX4AkQOyVMVsZf84 1Au8ZFSBe4QTGlFVr9MsFnpk1b2tAQdC7rhpbKk621VriQo/bx6sKzjAA8ZfjAuumZcegglEIoaFx sr3Zs6mT18cq9GuVkR0Mz0NVfskFaPmEeJ+6wO1uc6wRdQbI1OSHP6qqAPgQJABwoCp3OH4lAqC+A y+OWyQg8Qy5zZ6zvFoSEeAhQN04reuS+U330O8JlXA4mz70RnwL43lEurutDOAjRroAHBDRFxfvlh 9XOH3KEgA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xe1-0002ze-PK; Thu, 30 Jul 2020 01:46:05 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xdv-0002xz-8W for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/gQ8ZMHikXMYS7Uh6awxraNf9vvTzwNF/lqb6XIpyo=; b=M6LP5D1C29lf7KrcuUn9YZCE6VWK9D75eDUMd54RJ40V24/z82K9HXHS2amxmau3l+ZFZF x+tpQ8Wo3ObOid7wdFSjcyiQBH8Q9tjhJrsTpWrCiu3tgtRkekZNdEX4JebbPkt1WTs6c9 K0Oyz/8THbk/7ZXyDJFni9tgBLPwYxQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-DAgVb-wkPE-cCzyVg9AyHw-1; Wed, 29 Jul 2020 21:45:56 -0400 X-MC-Unique: DAgVb-wkPE-cCzyVg9AyHw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13B188017FB; Thu, 30 Jul 2020 01:45:55 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78A76619B5; Thu, 30 Jul 2020 01:45:52 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 02/15] drivers/firmware/sdei: Common block for failing path in sdei_event_create() Date: Thu, 30 Jul 2020 11:45:17 +1000 Message-Id: <20200730014531.310465-3-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214559_378276_F121126D X-CRM114-Status: GOOD ( 15.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org There are multiple calls of kfree(event) in the failing path of sdei_event_create() to free the SDEI event. It means we need to call it again when adding more code in the failing path. It's prone to miss doing that and introduce memory leakage. This introduces common block for failing path in sdei_event_create() to resolve the issue. This shouldn't cause functional changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Acked-by: James Morse --- drivers/firmware/arm_sdei.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index be5367f839f2..67da02b3a06e 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -190,33 +190,31 @@ static struct sdei_event *sdei_event_create(u32 event_num, lockdep_assert_held(&sdei_events_lock); event = kzalloc(sizeof(*event), GFP_KERNEL); - if (!event) - return ERR_PTR(-ENOMEM); + if (!event) { + err = -ENOMEM; + goto fail; + } INIT_LIST_HEAD(&event->list); event->event_num = event_num; err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY, &result); - if (err) { - kfree(event); - return ERR_PTR(err); - } + if (err) + goto fail; event->priority = result; err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_TYPE, &result); - if (err) { - kfree(event); - return ERR_PTR(err); - } + if (err) + goto fail; event->type = result; if (event->type == SDEI_EVENT_TYPE_SHARED) { reg = kzalloc(sizeof(*reg), GFP_KERNEL); if (!reg) { - kfree(event); - return ERR_PTR(-ENOMEM); + err = -ENOMEM; + goto fail; } reg->event_num = event_num; @@ -231,8 +229,8 @@ static struct sdei_event *sdei_event_create(u32 event_num, regs = alloc_percpu(struct sdei_registered_event); if (!regs) { - kfree(event); - return ERR_PTR(-ENOMEM); + err = -ENOMEM; + goto fail; } for_each_possible_cpu(cpu) { @@ -252,6 +250,10 @@ static struct sdei_event *sdei_event_create(u32 event_num, spin_unlock(&sdei_list_lock); return event; + +fail: + kfree(event); + return ERR_PTR(err); } static void sdei_event_destroy_llocked(struct sdei_event *event) From patchwork Thu Jul 30 01:45:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4BF16C1 for ; Thu, 30 Jul 2020 01:48:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A338B2082E for ; Thu, 30 Jul 2020 01:48:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="grvAaPMZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QzCFjPES" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A338B2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HRHhY/ubhybasXZMf05RV3a6AXyQTQ5s0FExI1yOr9E=; b=grvAaPMZYFtEmGHJo5JtUPLe/ o9xyKSCFmWDINR1eK/IAPIwzmmWFbv5dNd20aGNmKyeLjOL9RvC4pS4XwoHgYDQwkwIwmHs36tqyy GkFxiha6YYf9XpbcAX2bq2Y8aGJXecpBr66Bb2+QcefLPwSRFb0bSnPqSbk3TRF9z4wi1XvzJrYaE WR25IwB7UggLIssM/bIPjjVs9ZY2uyuXEJAkcrMbVY/osG4eE35b0AQDvmqjBTkPtOTYf6xusqD1E qAe+Grw7VmlIryFmEL8jaxE4opcKExoIFlzdBn9otsplD9CS+C1INe4cN4cz/8bX0B5j17pERE9IR sMPZu5YKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeC-00032R-64; Thu, 30 Jul 2020 01:46:16 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xdy-0002yl-50 for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mC3jIj+AukFGqVwJ/RZySdqVfbr3vkl6KloE0xG7nZg=; b=QzCFjPESUYFesuaoOrvm6kIu4PxCl04sSGf4RELFZ//gMxkFrH/ALEfC6RtEtROUeDvpWi Lnyk3dEejxxh3TicSBfyQfRJt4uDNVWmr2/6RA0ZNml+d7c1u6lyIRuEOvU8BYt+iFkI98 imuo1/e/+Y6Yby37f5XHVktm8sKNciI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-RWbXmFoBOmu4DHpbEs75ew-1; Wed, 29 Jul 2020 21:45:59 -0400 X-MC-Unique: RWbXmFoBOmu4DHpbEs75ew-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57FAA1DF0; Thu, 30 Jul 2020 01:45:58 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id A34D8619B5; Thu, 30 Jul 2020 01:45:55 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 03/15] drivers/firmware/sdei: Retrieve event number from event instance Date: Thu, 30 Jul 2020 11:45:18 +1000 Message-Id: <20200730014531.310465-4-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214602_227353_5BA75E0D X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.120 listed in wl.mailspike.net] -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In sdei_event_create(), the event number is retrieved from the variable @event_num for the shared event. The event number was stored in the event instance. So we can fetch it from the event instance, similar to what we're doing for the private event. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Acked-by: James Morse --- drivers/firmware/arm_sdei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 67da02b3a06e..86ab878d1198 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -217,7 +217,7 @@ static struct sdei_event *sdei_event_create(u32 event_num, goto fail; } - reg->event_num = event_num; + reg->event_num = event->event_num; reg->priority = event->priority; reg->callback = cb; From patchwork Thu Jul 30 01:45:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7E9A6C1 for ; Thu, 30 Jul 2020 01:48:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B11912082E for ; Thu, 30 Jul 2020 01:48:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SDNGiFXl"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AgVB1SgR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B11912082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PonQTDwv30OOawZ5edhA2NRykCI/QfTYSLvEPCLWKhI=; b=SDNGiFXlCBVFfrbbts8/9xkxg 7QmyDFsf87vFbok+XPmIYfh+sTyux5G+/2RWG5h0TlkOOJZfAosj8xFXWtwFTYiE/IVC4bAeGzeW7 Ffo5wXIaGMVEZxN6jUSe+Uoz/CvYY1aa4doQNF8OInTw2YUwDCGDdXfZ9BFNuMHIsEk7RFRHyjlZL K8xTQ16P4dExpo0Amvq8CCaANQLuUHuPeClp1Kr4+nmiJq6IvnvKe+KkDVVpRL+swUOLDPYkz3K+8 Vo4dTXaAvlbFwO1p0CRhE4J9tNEjBw5AuKvEX0OJdYg108w4Kk4iBp6v9MYiMfgztHkKLqk6kIRsT 70/EWAk2A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeV-00037B-Vu; Thu, 30 Jul 2020 01:46:36 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xe7-00030s-9P for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4gLox16sb7vxjZ6ldCsWokzKTCyvwNP0OeIy3iAgd1E=; b=AgVB1SgRhoyUuvMPwCuXuhnnQLqiwKxEb1vt96w1n/A18ZtmHvXIoU/fS/se0X0CpFB9l1 xNLX7HTVNwrblwFRqXaLR1UtqAN/uHmGMjCiqzKSi45WwnXQfB6XIDsCUvzdnQy143p8JF mosDMxrgUJtJUvm1TgfhNoFK3plal4A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-DlN-VTLDNcyJMIkQ3wxFhw-1; Wed, 29 Jul 2020 21:46:06 -0400 X-MC-Unique: DlN-VTLDNcyJMIkQ3wxFhw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 817E3102C7E9; Thu, 30 Jul 2020 01:46:01 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFB881EA; Thu, 30 Jul 2020 01:45:58 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 04/15] drivers/firmware/sdei: Avoid nested statements in sdei_init() Date: Thu, 30 Jul 2020 11:45:19 +1000 Message-Id: <20200730014531.310465-5-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214611_405102_8118E1AC X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.61 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In sdei_init(), the nested statements can be avoided by bailing on error from platform_driver_register() or absent ACPI SDEI table. With it, the code looks a bit more readable. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 86ab878d1198..c9f2bedfb6b5 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -1081,17 +1081,18 @@ static bool __init sdei_present_acpi(void) static int __init sdei_init(void) { - int ret = platform_driver_register(&sdei_driver); - - if (!ret && sdei_present_acpi()) { - struct platform_device *pdev; - - pdev = platform_device_register_simple(sdei_driver.driver.name, - 0, NULL, 0); - if (IS_ERR(pdev)) - pr_info("Failed to register ACPI:SDEI platform device %ld\n", - PTR_ERR(pdev)); - } + struct platform_device *pdev; + int ret; + + ret = platform_driver_register(&sdei_driver); + if (ret || !sdei_present_acpi()) + return ret; + + pdev = platform_device_register_simple(sdei_driver.driver.name, + 0, NULL, 0); + if (IS_ERR(pdev)) + pr_info("Failed to register ACPI:SDEI platform device %ld\n", + PTR_ERR(pdev)); return ret; } From patchwork Thu Jul 30 01:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E382414B7 for ; Thu, 30 Jul 2020 01:48:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD8C42082E for ; Thu, 30 Jul 2020 01:48:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IXjQghxs"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OXJX6nW5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD8C42082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0Lu0eoeTYAa7tV5HhuP2MoYgUbmAmzib9q/pV5GR/yo=; b=IXjQghxsvkdfnTht/fHQuHZGG l+2NZpqh7MXz462HTAFqBCko1s7V/Sfq093WxurboeOUloZI2L3Wxg+wPfyFhe5meCnOoENKsAj2P ymKKqBgUcXQI71Cm7gEWLFZodRn1EHY6TAG/RuQbeXGOR6ueT9+Z+n6hD63gQ7JisVTYPzUQ6p1Tg rd0stnEAIr4+vPBPENYb4Y1GmB2fPeM7NfZ/pMwwM9JyodwNMB5a/f9BFHn7jjxrn7iGSlbB05ao1 GmjgXAYnMPfVlS5/MlYB4yCQGebRijNlQ/uDrrzZder7nHpvXtRPQ769p/C9vBTSyg/3WymDJkxYl spgAzf3ng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeK-00034d-C5; Thu, 30 Jul 2020 01:46:24 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xe3-0002zx-T0 for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cDagN0+kHdf7NGstX/NeJGUxep/AZ24IhCwsJX1KlRE=; b=OXJX6nW5joXY2hjZFcKQoKmnAwW/gC60gVe1Xm0RwNF3/RLSuf78b9Q7+uwoBaF1NKEoA7 FH2b/vwhUyCObN8RcSaI6d1hmb0nXDDcvAv5xs6LTS2xJHXYGN7nckXSiKCktKLUBBnFp+ akCoYcSYvk3xY3Hf5Wksd68kWqH25sA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-cs_h-WWsO9CXbLRbMRUnAg-1; Wed, 29 Jul 2020 21:46:05 -0400 X-MC-Unique: cs_h-WWsO9CXbLRbMRUnAg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23B371DE9; Thu, 30 Jul 2020 01:46:04 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id EABC560C84; Thu, 30 Jul 2020 01:46:01 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 05/15] drivers/firmware/sdei: Unregister driver on error in sdei_init() Date: Thu, 30 Jul 2020 11:45:20 +1000 Message-Id: <20200730014531.310465-6-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214608_065385_687EFA43 X-CRM114-Status: GOOD ( 14.39 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [207.211.31.120 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The platform driver needs to be unregistered on error to create the platform device, so that the state is restored to original one. Besides, the errno (@ret) should be updated acccording in that case. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index c9f2bedfb6b5..909f27abf8a7 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -1090,9 +1090,12 @@ static int __init sdei_init(void) pdev = platform_device_register_simple(sdei_driver.driver.name, 0, NULL, 0); - if (IS_ERR(pdev)) - pr_info("Failed to register ACPI:SDEI platform device %ld\n", - PTR_ERR(pdev)); + if (IS_ERR(pdev)) { + ret = PTR_ERR(pdev); + platform_driver_unregister(&sdei_driver); + pr_info("Failed to register ACPI:SDEI platform device %d\n", + ret); + } return ret; } From patchwork Thu Jul 30 01:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD71F6C1 for ; Thu, 30 Jul 2020 01:49:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96CC72082E for ; Thu, 30 Jul 2020 01:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XmwQmwr5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eY7koomZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96CC72082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=l05o63Dz4qSKdtk/f0eprRj0ODfh+6MCq/DFZ3MRXH8=; b=XmwQmwr5uAXomiFX1UnqpFjDw 60XYVmWpa52cyg5/DmF586+mW9xdyLQOeONJm2DckVXVjZJjlK0hwuuGj7uuWsRq19qcftiwQdC6u FYwsQqM7hvw4X/a9oFO3L2COjXQC6lE8LhBnpZ7b019UbXqP9zfzy6hYwizUxaSedJLemM8DbRQdz 7JT2H3yWeaNFfdPNUGWW+SzBFc/mG5QaEeXaC3CwsIpXj+kyE/K7LDpBEmA0a21T98mUXoraaa89m NwNt2WVxJtUuNolqjxOp3vjLCs2qB2VSeoaZ5wehEyGUiO+LgYYsj+vb+E9HpIkFcZ/EybO6f3AZj ERzQZ1I2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeo-0003Es-1e; Thu, 30 Jul 2020 01:46:54 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xe9-00031O-04 for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dHbe9G4uMdgtwyR6p149bUuCqhJpzYnVQDf3aFzOG0M=; b=eY7koomZQGbU+/FOpnzZRNOkDi0Q94jhIi4JI1zcoULcMFaBMQga9D0TIfxgmPFzVxS7Ij wvlwwo9HoIhuwnEEA5sM0HYiVufp1vD2MLQIWD7RS/PZLHiTV/7iKZOb2qwOJG+8XCxBST ZNbALLMbFaidw088+V4V4ptX2qsW2lI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-XUVi5hoGOMWodS2L_IISHg-1; Wed, 29 Jul 2020 21:46:08 -0400 X-MC-Unique: XUVi5hoGOMWodS2L_IISHg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70F12102C7F7; Thu, 30 Jul 2020 01:46:07 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EB5E60C84; Thu, 30 Jul 2020 01:46:04 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 06/15] drivers/firmware/sdei: Remove duplicate check in sdei_get_conduit() Date: Thu, 30 Jul 2020 11:45:21 +1000 Message-Id: <20200730014531.310465-7-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214613_116192_63B0EA28 X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The following two checks are duplicate because @acpi_disabled doesn't depend on CONFIG_ACPI. So the duplicate check (IS_ENABLED(CONFIG_ACPI)) can be dropped. More details is provided to keep the commit log complete: * @acpi_disabled is defined in arch/arm64/kernel/acpi.c when CONFIG_ACPI is enabled. * @acpi_disabled in defined in include/acpi.h when CONFIG_ACPI is disabled. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Acked-by: James Morse --- drivers/firmware/arm_sdei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 909f27abf8a7..240c06ae7bfe 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -958,7 +958,7 @@ static int sdei_get_conduit(struct platform_device *pdev) } pr_warn("invalid \"method\" property: %s\n", method); - } else if (IS_ENABLED(CONFIG_ACPI) && !acpi_disabled) { + } else if (!acpi_disabled) { if (acpi_psci_use_hvc()) { sdei_firmware_call = &sdei_smccc_hvc; return SMCCC_CONDUIT_HVC; From patchwork Thu Jul 30 01:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 830A66C1 for ; Thu, 30 Jul 2020 01:48:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C09D2082E for ; Thu, 30 Jul 2020 01:48:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KySGFbRA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CBLDIORr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C09D2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CmCeQrCHftWGLMF4cA/riof/lTsZE07GBXbJI6XMHQI=; b=KySGFbRAHdFSR90R97Rpv2IWM GrXqGhniuHx1/bdfUdLNrBFIW8SpVaFc5nxwTeSfQpnWkz+G8/JgHe81dRit4cfnuJQ6A8oTt7l1U mK/eXU++0aUpYEeDVPvxjhdT3L7+xRanVMY6A/5vXtaW4/W09dFp0c1PjGg5rQ3toIfMZCXpW6meD T8CN4cZVUnvW2nTNuYvACNKGdaQp8dFFhzO5U7NMJgkID4OhlYdITpODqJeDYxbJ+byioS2NS799U Ki9FTcBdGcqp1JPujpRm8TFLyUPsjDOlBipW1rsWXSUgamrDzpvgB4zvot1wrt28klQd/EH5mmC6d +a1Lpk54w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xet-0003HM-UY; Thu, 30 Jul 2020 01:47:00 +0000 Received: from us-smtp-1.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeA-00031n-6U for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KQkLAwrds5cK+to3tZEmGhdtyq9WQH0ifEZ9d6Di0cU=; b=CBLDIORrhnacMPFGLvs/aNJgG9x2+4nAQBv0+CYnGQN6ms6UDTp/NibyIvfai7IrOhq1Ls 2DzcQrWYUdusULD9O768uNMVsHudg08bgtkK2NY7aFNv/Q3rTmdmTsT9YehlZSm5QnErH1 ub0yACjR7/n5aJySJzo4evMqkpb0wDg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-WgOtwjp8PRSVinDRGq4LLA-1; Wed, 29 Jul 2020 21:46:12 -0400 X-MC-Unique: WgOtwjp8PRSVinDRGq4LLA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE0DA107ACCA; Thu, 30 Jul 2020 01:46:10 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ED9B60C84; Thu, 30 Jul 2020 01:46:07 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 07/15] drivers/firmware/sdei: Remove Drop redundant error message in sdei_probe() Date: Thu, 30 Jul 2020 11:45:22 +1000 Message-Id: <20200730014531.310465-8-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214614_675424_749CACAE X-CRM114-Status: GOOD ( 12.74 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.61 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.61 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This removes the redundant error message in sdei_probe() because the case can be identified from the errno in next error message. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Acked-by: James Morse --- drivers/firmware/arm_sdei.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 240c06ae7bfe..03b1179da9b4 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -982,8 +982,6 @@ static int sdei_probe(struct platform_device *pdev) return 0; err = sdei_api_get_version(&ver); - if (err == -EOPNOTSUPP) - pr_err("advertised but not implemented in platform firmware\n"); if (err) { pr_err("Failed to get SDEI version: %d\n", err); sdei_mark_interface_broken(); From patchwork Thu Jul 30 01:45:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2076313B6 for ; Thu, 30 Jul 2020 01:49:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED3932082E for ; Thu, 30 Jul 2020 01:49:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1MRpoHg+"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WhVV1Wpb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED3932082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MGf0CUJpWuKX+PAg2yA1EEGCteKxCMNM1kdYf7BML2s=; b=1MRpoHg+7u7UA430RfXTb098f 11oMWIb15iatAzFehGvyLsX6p0LjXCCXUqUZfMrbN0nXVfrK9LEBsJiFvJ51rctwrB6CA5Ti3TNaW MSlk5ooZDQedknP705LRqkP/FArn5H1VjAF5UnLiVa5Xjd/drOqVIdLlUQTD2CH3/a1AVDsYltU1g /y8Ya9SZOfSDlvZynDiWiOW8Y0O9IBbU91XxM0rK2rLHhqbW0R4greCBPUxeNtNflzW8SaH3JX5u9 2vG6DOastWTSDmgu3k6tJ7sG/BQxonIxMU3aio13EJcwEIQsCVlOO6DeU+KKu/GSXCbBWWhEQ0qLq INAYyam0w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xfN-0003Ot-J7; Thu, 30 Jul 2020 01:47:29 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeE-00032j-1m for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pfevqZGhFgeJ/wFTNdPcRdA1AnOkfEScPd22mD7uXuA=; b=WhVV1WpbWJGVTX1vpc0Inyvfw3t2lEsMtLYGCsYUwnHAbQZAE3+WxkIufd2z0y9KgaijLu GWD22ufatqAhvojvVy6vmq69gTTo8er83/GxMiA56G2swPcrb465zgnSYStX/02HX9htG4 QYvsiuJq82wjL4kplEsj4Z5DfHrPT+4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-UrfAZVO8NTu4QElpziIOjw-1; Wed, 29 Jul 2020 21:46:15 -0400 X-MC-Unique: UrfAZVO8NTu4QElpziIOjw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E12519200C0; Thu, 30 Jul 2020 01:46:14 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B35B59; Thu, 30 Jul 2020 01:46:11 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 08/15] drivers/firmware/sdei: Remove while loop in sdei_event_register() Date: Thu, 30 Jul 2020 11:45:23 +1000 Message-Id: <20200730014531.310465-9-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214618_172723_9C1F1486 X-CRM114-Status: GOOD ( 13.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.120 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This removes the unnecessary while loop in sdei_event_register(). This shouldn't cause any functional changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron --- drivers/firmware/arm_sdei.c | 52 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 03b1179da9b4..d04329f98922 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -590,36 +590,34 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) WARN_ON(in_nmi()); mutex_lock(&sdei_events_lock); - do { - if (sdei_event_find(event_num)) { - pr_warn("Event %u already registered\n", event_num); - err = -EBUSY; - break; - } + if (sdei_event_find(event_num)) { + pr_warn("Event %u already registered\n", event_num); + err = -EBUSY; + goto unlock; + } - event = sdei_event_create(event_num, cb, arg); - if (IS_ERR(event)) { - err = PTR_ERR(event); - pr_warn("Failed to create event %u: %d\n", event_num, - err); - break; - } + event = sdei_event_create(event_num, cb, arg); + if (IS_ERR(event)) { + err = PTR_ERR(event); + pr_warn("Failed to create event %u: %d\n", event_num, err); + goto unlock; + } - cpus_read_lock(); - err = _sdei_event_register(event); - if (err) { - sdei_event_destroy(event); - pr_warn("Failed to register event %u: %d\n", event_num, - err); - } else { - spin_lock(&sdei_list_lock); - event->reregister = true; - spin_unlock(&sdei_list_lock); - } - cpus_read_unlock(); - } while (0); - mutex_unlock(&sdei_events_lock); + cpus_read_lock(); + err = _sdei_event_register(event); + if (err) { + sdei_event_destroy(event); + pr_warn("Failed to register event %u: %d\n", event_num, err); + goto cpu_unlock; + } + spin_lock(&sdei_list_lock); + event->reregister = true; + spin_unlock(&sdei_list_lock); +cpu_unlock: + cpus_read_unlock(); +unlock: + mutex_unlock(&sdei_events_lock); return err; } From patchwork Thu Jul 30 01:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1A366C1 for ; Thu, 30 Jul 2020 01:49:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F10D2082E for ; Thu, 30 Jul 2020 01:49:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qACVqq9N"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YtjM0hZ6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F10D2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1T0Xj0S8+cQUYwv4ytOkIJaH+zu82geq2xpyEh3XfBE=; b=qACVqq9NDXCxPH4BqQmEWHZZq vBVaslTRvw1yzAJBf96F22IZcgr0sBg/aVhNaBQZpMKIkCGA72Uxq16Rg1zuzrRmkPDTpT8VlvdJA RbE8N2AsPq3LuP/CnbClWbm8v5DCHA2D3+mbFTiO3+UrqBwlAxR0kLpbwsaxY9xojCbpW1kJYnHjO AOikYWT5KM86qq+ZBJQIqBLkivshdHiRkq0mVMiuzhuyWNitzl/IQXkfuF56Eddh6Ya48zm4zUwU2 JGSB4gxhscyUBjgcdXtCy0Cokzmcuo/w7zRjhCJB6CjIralWHYybuY9vD5FZnpYsyHYb50M8kAfCe gn/MaXcaQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xfl-0003cX-S8; Thu, 30 Jul 2020 01:47:54 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeH-00033m-9l for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+0JEbdPQLj3ek6y9I75K9b7KFect6dP51EfAZ75ZizA=; b=YtjM0hZ6aWD3G5hfqtP5KYnnZMbF2Df91TnXMepw33T3cBD2z8hF2cVi4xeTJfZzaX3POx X4uS2Q+QyzhyJzPvIyp0MxZVGNtRlvz0tKJ4jS0eKdzs7ofgd9JOFVUM+siXKHbeEcqVGp +sCYLTefhsjQDiucPOpLzYrWQQMPdZE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-O_Dt_4p_N-OiQl9-Im-8ew-1; Wed, 29 Jul 2020 21:46:18 -0400 X-MC-Unique: O_Dt_4p_N-OiQl9-Im-8ew-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F1E7800597; Thu, 30 Jul 2020 01:46:17 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEC5760C84; Thu, 30 Jul 2020 01:46:14 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 09/15] drivers/firmware/sdei: Remove while loop in sdei_event_unregister() Date: Thu, 30 Jul 2020 11:45:24 +1000 Message-Id: <20200730014531.310465-10-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214621_441048_B33F0667 X-CRM114-Status: GOOD ( 13.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [207.211.31.120 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This removes the unnecessary while loop in sdei_event_unregister(). This shouldn't cause any functional changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron --- drivers/firmware/arm_sdei.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index d04329f98922..c8e894098c56 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -491,24 +491,23 @@ int sdei_event_unregister(u32 event_num) mutex_lock(&sdei_events_lock); event = sdei_event_find(event_num); - do { - if (!event) { - pr_warn("Event %u not registered\n", event_num); - err = -ENOENT; - break; - } + if (!event) { + pr_warn("Event %u not registered\n", event_num); + err = -ENOENT; + goto unlock; + } - spin_lock(&sdei_list_lock); - event->reregister = false; - event->reenable = false; - spin_unlock(&sdei_list_lock); + spin_lock(&sdei_list_lock); + event->reregister = false; + event->reenable = false; + spin_unlock(&sdei_list_lock); - err = _sdei_event_unregister(event); - if (err) - break; + err = _sdei_event_unregister(event); + if (err) + goto unlock; - sdei_event_destroy(event); - } while (0); + sdei_event_destroy(event); +unlock: mutex_unlock(&sdei_events_lock); return err; From patchwork Thu Jul 30 01:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A85C13B6 for ; Thu, 30 Jul 2020 01:50:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2042E2074B for ; Thu, 30 Jul 2020 01:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ObIMpF+I"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="csDtZI/a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2042E2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g2odyPxamsQOoX633sLn0WDeSn+2iocyTVaywYJYTpk=; b=ObIMpF+IXMjOS3k/DAs3nvsiD d5FdS/OL+0qOy1Yc7gQHOFtPGYVSfE5XUUeGamtN7dggMFRJpuxLIR//GrxGrUE+2uBGdXoTYTRCp yi+ZulllGhDwsYdMnz9lGnJfgiL4TIz/pqw03Iy877mp30skOZ/Qgvv579p5E3R+rnHD2v9Fz9gX9 AHsezPqwnKZ83+/rZCWdD4RI0nkxa0ZwZRkLWcjX3qoNG+RnKoJOdOCuBg0zm56bvVuoZN3Q1oqw2 bc7dWNK/+Psb/qXrROX/qcog1WR7DXFSqEVscHNm1buWbPdf+tlXANSp3JWSadNRwp4iJVcvesMTz HOObckg3w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xg7-0003kF-BY; Thu, 30 Jul 2020 01:48:15 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeK-00034r-DS for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=97yqcdX19HxE4NPvwTtg18g3et/tcT0fCE5mUvZ8nIg=; b=csDtZI/afXHCdqM8wo6Vew0KfxPFVLL+LQRM3rbQVBJBAJdKFtTVKPu3z6o8VzAvppCveY RV3e8CoLy3OXluM6rZwZlnogb/Q6ukBfEh8g0Rm8S2lfcSfBlDQZvavv/S/DpIE5YmR9a1 TDWZwNVqmU73+r1uNWVGTq4TJccnxFw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-333-DyUtrsQyOVuJeCjWikHmdw-1; Wed, 29 Jul 2020 21:46:21 -0400 X-MC-Unique: DyUtrsQyOVuJeCjWikHmdw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5DF85800465; Thu, 30 Jul 2020 01:46:20 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDF0D60C84; Thu, 30 Jul 2020 01:46:17 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 10/15] drivers/firmware/sdei: Cleanup on cross call function Date: Thu, 30 Jul 2020 11:45:25 +1000 Message-Id: <20200730014531.310465-11-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214624_574225_96F83600 X-CRM114-Status: GOOD ( 14.78 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [207.211.31.120 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This applies cleanup on the cross call functions, no functional changes are introduced: * Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl * Use smp_call_func_t for @fn argument in sdei_do_cross_call() * Remove unnecessary space before @event in sdei_do_cross_call() Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index c8e894098c56..5560c8880631 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -78,11 +78,15 @@ struct sdei_crosscall_args { int first_error; }; -#define CROSSCALL_INIT(arg, event) (arg.event = event, \ - arg.first_error = 0, \ - atomic_set(&arg.errors, 0)) - -static inline int sdei_do_cross_call(void *fn, struct sdei_event * event) +#define CROSSCALL_INIT(arg, event) \ + do { \ + arg.event = event; \ + arg.first_error = 0; \ + atomic_set(&arg.errors, 0); \ + } while (0) + +static inline int sdei_do_cross_call(smp_call_func_t fn, + struct sdei_event *event) { struct sdei_crosscall_args arg; From patchwork Thu Jul 30 01:45:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 579FE13B1 for ; Thu, 30 Jul 2020 01:50:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EA242083E for ; Thu, 30 Jul 2020 01:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BHkAj/nP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DHzGUJIX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EA242083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5/CFIg3ZeahvTYc9GjozDa7Oy5FMixx705fAVtoUFTE=; b=BHkAj/nPa0y49IaQb/uikFsi1 Mh8vxLm3rpM6NqUveiyZJo0JTTqkbS1eNmjjGx9d4jj87hBWAibf83C82ggu7C2f1pOn9oQKOlzlv 0yEcbDWxRQrIr8kM+C/J+DFGwawK6r+YuW4gtrE4/qkLIp89LUA7pMtsMGOTm6UfMymGW5yYpOy4g lbJsWc75weLxu2J+LimYgK2n3JvwMYbiVqKGAuL3k9FiPbXWIsKlZiiIKmeOd4knQej6VPaR16/Vt zgd3DT+2VLDpoUljR+VrcxeknPv8a3qDIrVMJLpCtvRTMzERYEJHKk/ZdLeztGLnVpQylM3WtwRXU Pkhs3kX1g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xgP-0003wm-5D; Thu, 30 Jul 2020 01:48:33 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeN-00035e-PE for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nV2hF9VhR+wt3Z2APK5NDQofoFoLBfW+2qyvqcpKoMA=; b=DHzGUJIXXTJpHYvbYmplZajI4A7ZF0NK2xX+opYWOrpw0I4/CHRkz7+58drvdl1+NoVK20 B3Ef8bvT2TEfX5VPVrGrCd9711didPUWdqRjWOEKT7P8a/HzWlbpiqoo/Q4c4/SPRhaU7m dhms8lPdBAdTcmdTrHBcnZDLbA+RwbY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-g419n4KJPoWP668XoV2NbQ-1; Wed, 29 Jul 2020 21:46:24 -0400 X-MC-Unique: g419n4KJPoWP668XoV2NbQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B7E1107ACCA; Thu, 30 Jul 2020 01:46:23 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3D6B59; Thu, 30 Jul 2020 01:46:20 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 11/15] drivers/firmware/sdei: Introduce sdei_do_local_call() Date: Thu, 30 Jul 2020 11:45:26 +1000 Message-Id: <20200730014531.310465-12-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214627_956194_C2928C7B X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org During the CPU hotplug, the private events are registered, enabled or unregistered on the specific CPU. It repeats the same steps: initializing cross call argument, make function call on local CPU, check the returned error. This introduces sdei_do_local_call() to cover the first steps. The other benefit is to make CROSSCALL_INIT and struct sdei_crosscall_args are only visible to sddi_do_{cross, local}_call(). Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 5560c8880631..7f4309039513 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -85,6 +85,17 @@ struct sdei_crosscall_args { atomic_set(&arg.errors, 0); \ } while (0) +static inline int sdei_do_local_call(smp_call_func_t fn, + struct sdei_event *event) +{ + struct sdei_crosscall_args arg; + + CROSSCALL_INIT(arg, event); + fn(&arg); + + return arg.first_error; +} + static inline int sdei_do_cross_call(smp_call_func_t fn, struct sdei_event *event) { @@ -677,7 +688,7 @@ static int sdei_reregister_shared(void) static int sdei_cpuhp_down(unsigned int cpu) { struct sdei_event *event; - struct sdei_crosscall_args arg; + int err; /* un-register private events */ spin_lock(&sdei_list_lock); @@ -685,12 +696,11 @@ static int sdei_cpuhp_down(unsigned int cpu) if (event->type == SDEI_EVENT_TYPE_SHARED) continue; - CROSSCALL_INIT(arg, event); - /* call the cross-call function locally... */ - _local_event_unregister(&arg); - if (arg.first_error) + err = sdei_do_local_call(_local_event_unregister, event); + if (err) { pr_err("Failed to unregister event %u: %d\n", - event->event_num, arg.first_error); + event->event_num, err); + } } spin_unlock(&sdei_list_lock); @@ -700,7 +710,7 @@ static int sdei_cpuhp_down(unsigned int cpu) static int sdei_cpuhp_up(unsigned int cpu) { struct sdei_event *event; - struct sdei_crosscall_args arg; + int err; /* re-register/enable private events */ spin_lock(&sdei_list_lock); @@ -709,20 +719,19 @@ static int sdei_cpuhp_up(unsigned int cpu) continue; if (event->reregister) { - CROSSCALL_INIT(arg, event); - /* call the cross-call function locally... */ - _local_event_register(&arg); - if (arg.first_error) + err = sdei_do_local_call(_local_event_register, event); + if (err) { pr_err("Failed to re-register event %u: %d\n", - event->event_num, arg.first_error); + event->event_num, err); + } } if (event->reenable) { - CROSSCALL_INIT(arg, event); - _local_event_enable(&arg); - if (arg.first_error) + err = sdei_do_local_call(_local_event_enable, event); + if (err) { pr_err("Failed to re-enable event %u: %d\n", - event->event_num, arg.first_error); + event->event_num, err); + } } } spin_unlock(&sdei_list_lock); From patchwork Thu Jul 30 01:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A77F713B6 for ; Thu, 30 Jul 2020 01:50:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 810B12074B for ; Thu, 30 Jul 2020 01:50:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="S2ffLNq1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PreehlgQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 810B12074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Yj1XffXKorCAA4WhgdLSvRCNtdKY8eN37kXj3KikdTA=; b=S2ffLNq1ikzTOXoKmn4v7Fdg+ 5TqL9UH8R+ajGQNe9p6+Xbe0LB9uA9txkYM4L151I33SoAadYka5tHL5Tr7C/6J+EfYu2S/Sb+BJc afNKJdqPyRsj0VbhpEeYysdwSSng4oXqzuxXrkG49DtfZyTter7idEAZnEWVX1zTXFk4wYF+C1X3d 3Gh+qbdp4QLCNQ2q3G4g1KE43rkWXkJf91kSFjWcfdR/zD2Bc6aESHgEsCKiL/GHOaPApZGa+yt8r S4r7MkzXj6vFZYkWxS63od/PAdza4M14ZEJlsEuL9T/YrQ44sDuuNRXtH4N+ztJl3Ddw/7jYGL5Sm F+y/9axqA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xgW-00042M-3J; Thu, 30 Jul 2020 01:48:44 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeQ-00037G-OU for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MOcfe4n3U3QyFAO5mf7jd2fPzJDKJGmJT5du5wGK3Pw=; b=PreehlgQFRPG5D1xHPKM/+rnAd1Fz9Ogd56JOYlGDOesdI/b4p0N+0cnuG6/dm+jUkOV8A 6I5WzW+RtMMaLA456If3MlsEnzrHqL71HyX14FUCD7jWhG0d8r5YeSr/U3L9N0Gj2grh1W 1xGqkL/N+BfoRIOmkcas63x56Bscczk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-XOVYY85BOzWowPkQoo6s-A-1; Wed, 29 Jul 2020 21:46:27 -0400 X-MC-Unique: XOVYY85BOzWowPkQoo6s-A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FF641005510; Thu, 30 Jul 2020 01:46:26 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id E344060C84; Thu, 30 Jul 2020 01:46:23 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 12/15] drivers/firmware/sdei: Remove _sdei_event_register() Date: Thu, 30 Jul 2020 11:45:27 +1000 Message-Id: <20200730014531.310465-13-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214631_027341_6452A0EF X-CRM114-Status: GOOD ( 16.97 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.120 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The function _sdei_event_register() is called by sdei_event_register() and sdei_device_thaw() as the following functional call chain shows. _sdei_event_register() covers the shared and private events, but sdei_device_thaw() only covers the shared events. So the logic to cover the private events in _sdei_event_register() isn't needed by sdei_device_thaw(). Similarly, sdei_reregister_event_llocked() covers the shared and private events in the regard of reenablement. The logic to cover the private events isn't needed by sdei_device_thaw() either. sdei_event_register sdei_device_thaw _sdei_event_register sdei_reregister_shared sdei_reregister_event_llocked _sdei_event_register This removes _sdei_event_register() and sdei_reregister_event_llocked(). Their logic is moved to sdei_event_register() and sdei_reregister_shared(). This shouldn't cause any logicial changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 77 ++++++++++++++----------------------- 1 file changed, 28 insertions(+), 49 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 7f4309039513..749f1619e652 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -577,25 +577,6 @@ static void _local_event_register(void *data) sdei_cross_call_return(arg, err); } -static int _sdei_event_register(struct sdei_event *event) -{ - int err; - - lockdep_assert_held(&sdei_events_lock); - - if (event->type == SDEI_EVENT_TYPE_SHARED) - return sdei_api_event_register(event->event_num, - sdei_entry_point, - event->registered, - SDEI_EVENT_REGISTER_RM_ANY, 0); - - err = sdei_do_cross_call(_local_event_register, event); - if (err) - sdei_do_cross_call(_local_event_unregister, event); - - return err; -} - int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) { int err; @@ -618,7 +599,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) } cpus_read_lock(); - err = _sdei_event_register(event); + if (event->type == SDEI_EVENT_TYPE_SHARED) { + err = sdei_api_event_register(event->event_num, + sdei_entry_point, + event->registered, + SDEI_EVENT_REGISTER_RM_ANY, 0); + } else { + err = sdei_do_cross_call(_local_event_register, event); + if (err) + sdei_do_cross_call(_local_event_unregister, event); + } + if (err) { sdei_event_destroy(event); pr_warn("Failed to register event %u: %d\n", event_num, err); @@ -635,33 +626,6 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) return err; } -static int sdei_reregister_event_llocked(struct sdei_event *event) -{ - int err; - - lockdep_assert_held(&sdei_events_lock); - lockdep_assert_held(&sdei_list_lock); - - err = _sdei_event_register(event); - if (err) { - pr_err("Failed to re-register event %u\n", event->event_num); - sdei_event_destroy_llocked(event); - return err; - } - - if (event->reenable) { - if (event->type == SDEI_EVENT_TYPE_SHARED) - err = sdei_api_event_enable(event->event_num); - else - err = sdei_do_cross_call(_local_event_enable, event); - } - - if (err) - pr_err("Failed to re-enable event %u\n", event->event_num); - - return err; -} - static int sdei_reregister_shared(void) { int err = 0; @@ -674,9 +638,24 @@ static int sdei_reregister_shared(void) continue; if (event->reregister) { - err = sdei_reregister_event_llocked(event); - if (err) + err = sdei_api_event_register(event->event_num, + sdei_entry_point, event->registered, + SDEI_EVENT_REGISTER_RM_ANY, 0); + if (err) { + sdei_event_destroy_llocked(event); + pr_err("Failed to re-register event %u\n", + event->event_num); break; + } + } + + if (event->reenable) { + err = sdei_api_event_enable(event->event_num); + if (err) { + pr_err("Failed to re-enable event %u\n", + event->event_num); + break; + } } } spin_unlock(&sdei_list_lock); From patchwork Thu Jul 30 01:45:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBDF013B1 for ; Thu, 30 Jul 2020 01:50:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB4FA2074B for ; Thu, 30 Jul 2020 01:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CHYm/zvU"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IVrmSVez" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB4FA2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qPjePBXO+B/qEOoRKrWmszao52xMk6OfE2x3oxoyW3E=; b=CHYm/zvU3uBBLfUaiVUwCkqUY 1tXoXSALBJBRB/irWHZC2KN1zoTLTFGP8ZuBTis9hfjQxkfGc9nYETfmTiqXfJnAOFnOriwx+2VIO gzVqDy3eX7GsoLle4dR+30NcrHq4lxf0Sc/nIVtFkrzjSQx4jUs/7kbUhqGh1Hz0OpyLoqV6bxUSn pgXRTtFeeSFbG9Eo0z8hcT4+3fDH3JYSu61XOwJhhPZLl5WqDH3GVYF0knHk5U6TvDTTMCvoyl11G knOwbfHA4WzqdGhA5XgXKCCB+oc1Ms9NKnRyu3K/DwLjyhuSK1KP45f8/nbW7OWeGRJjq50SBn8h5 nyeC1qydg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xgo-00048J-O3; Thu, 30 Jul 2020 01:48:58 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xeV-00038M-1A for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dQuSJ9XdlL4ZGLFBIT2XgF9Xn3ef0l2GJoJAuEJEpJk=; b=IVrmSVezGzuS9MHkr4bhN2LwSUuwcRwHFpcU6ghP4jGKMOSXUKJTZec6mVk/zTlnQzLcOc BMLsdwjpbTADhcKo5gSpCJkV2dMhG1HBMucwIQN7hQg7IczEfrAOfkqRsQwCIJJQYourSH gs3Vd1/xDkr36UW8IXk/F6gz4kaSE/I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-ZU82z5nROC29gv0WHbPHkQ-1; Wed, 29 Jul 2020 21:46:31 -0400 X-MC-Unique: ZU82z5nROC29gv0WHbPHkQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E58A107ACCA; Thu, 30 Jul 2020 01:46:29 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19DBB60C84; Thu, 30 Jul 2020 01:46:26 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 13/15] drivers/firmware/sdei: Remove _sdei_event_unregister() Date: Thu, 30 Jul 2020 11:45:28 +1000 Message-Id: <20200730014531.310465-14-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214635_367765_70B79429 X-CRM114-Status: GOOD ( 14.40 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [205.139.110.120 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org _sdei_event_unregister() is called by sdei_event_unregister() and sdei_device_freeze(). _sdei_event_unregister() covers the shared and private events, but sdei_device_freeze() only covers the shared events. So the logic to cover the private events isn't needed by sdei_device_freeze(). sdei_event_unregister sdei_device_freeze _sdei_event_unregister sdei_unregister_shared _sdei_event_unregister This removes _sdei_event_unregister(). Its logic is moved to its callers accordingly. This shouldn't cause any logicial changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 749f1619e652..2678475940e6 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -487,16 +487,6 @@ static void _local_event_unregister(void *data) sdei_cross_call_return(arg, err); } -static int _sdei_event_unregister(struct sdei_event *event) -{ - lockdep_assert_held(&sdei_events_lock); - - if (event->type == SDEI_EVENT_TYPE_SHARED) - return sdei_api_event_unregister(event->event_num); - - return sdei_do_cross_call(_local_event_unregister, event); -} - int sdei_event_unregister(u32 event_num) { int err; @@ -517,7 +507,11 @@ int sdei_event_unregister(u32 event_num) event->reenable = false; spin_unlock(&sdei_list_lock); - err = _sdei_event_unregister(event); + if (event->type == SDEI_EVENT_TYPE_SHARED) + err = sdei_api_event_unregister(event->event_num); + else + err = sdei_do_cross_call(_local_event_unregister, event); + if (err) goto unlock; @@ -543,7 +537,7 @@ static int sdei_unregister_shared(void) if (event->type != SDEI_EVENT_TYPE_SHARED) continue; - err = _sdei_event_unregister(event); + err = sdei_api_event_unregister(event->event_num); if (err) break; } From patchwork Thu Jul 30 01:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52C0113B1 for ; Thu, 30 Jul 2020 01:50:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CC392074B for ; Thu, 30 Jul 2020 01:50:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NCLB7lRE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i4IpuXMh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CC392074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=57bNI6oO1ntgjkyUZ4YP1WQTOgXqkxfA3So4w6xljTg=; b=NCLB7lREuvn4gc8TAY5mDNThc 0hHeENhm5U1f4Rb9qb0/N0iQx44k3EEbMceojpNiZif3qsj/YSAGFKexnV3uSSZCcyoKOXArlvVe1 fQE0AGq0UtC3ucjQlHPtWfk7QgTdwyV6u8Les6HPaUKLrX63QcMdyMdSCN5Ir+oHFWXHvzjeGqpPk 3hARbKs0K7VtIIgHV0CNiJ59LQCOlD+uY7egpW9CSRPlBaYAQCxYJWHvjt6TPFliVW83Zk+G8znrH Jn98lRtzmICnhphhEPqlymhCXOJi9Mmd4bTXil2m9Ch04RxBaBU0gXF3WDTtcsWYej/8JaP1wPTU6 2tXdCQgUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xh4-0004Hs-8X; Thu, 30 Jul 2020 01:49:14 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xea-0003AZ-Bk for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b2lFRE/5gYsAlRZy+KWgGgPB1f8p6u+wl1ZkXYqyJuo=; b=i4IpuXMh021H43K+1sJwtL38jiCY1ZIa8Hw0B3xKm0EfjRenqToQKbCx3WljSBcmKF7xpL QrFQqUgXx09ljHX7XYnXk5S+fdeRGejHKFa3AUh69xHWRGBVgsAiznBAQ+cIz+eWzJJokR Y7m857Xb8WeZiJhbDYDBbnUP4QECHsU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-oSSwt3dJO-O1nlumrEKzAg-1; Wed, 29 Jul 2020 21:46:34 -0400 X-MC-Unique: oSSwt3dJO-O1nlumrEKzAg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A6AB58; Thu, 30 Jul 2020 01:46:33 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BAEE60C84; Thu, 30 Jul 2020 01:46:29 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 14/15] drivers/firmware/sdei: Expose struct sdei_event Date: Thu, 30 Jul 2020 11:45:29 +1000 Message-Id: <20200730014531.310465-15-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214640_886649_0029D4C2 X-CRM114-Status: GOOD ( 26.34 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This splits struct sdei_event into two structs: sdei_event and sdei_internal_event. The former one can be dereferenced from external module like arm64/kvm when SDEI virtualization is supported. The later one is used by the client driver only. This also renames local variables from @event to @event_el if their type is "struct sdei_internal_event" to make the variable name a bit meaningful. Note that it's not applied to sdei_do_{local,cross}_call() because CROSSCALL_INIT stops us doing this unless much more changes are needed. I'm avoiding to do that. Besides, @event is added as "struct sdei_event" to cache @event_el->event if it's accessed for multiple times in the particular function to reduce the code change size. This shouldn't cause functional changes. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron --- v4: Rename variable @event to @event_el if it's internal event Use @event to cache @event_el->event if it's used for multiple times --- drivers/firmware/arm_sdei.c | 160 ++++++++++++++++++++---------------- include/linux/arm_sdei.h | 6 ++ 2 files changed, 94 insertions(+), 72 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 2678475940e6..f9827c096275 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -44,16 +44,14 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id, /* entry point from firmware to arch asm code */ static unsigned long sdei_entry_point; -struct sdei_event { +struct sdei_internal_event { + struct sdei_event event; + /* These three are protected by the sdei_list_lock */ struct list_head list; bool reregister; bool reenable; - u32 event_num; - u8 type; - u8 priority; - /* This pointer is handed to firmware as the event argument. */ union { /* Shared events */ @@ -73,7 +71,7 @@ static LIST_HEAD(sdei_list); /* Private events are registered/enabled via IPI passing one of these */ struct sdei_crosscall_args { - struct sdei_event *event; + struct sdei_internal_event *event; atomic_t errors; int first_error; }; @@ -86,7 +84,7 @@ struct sdei_crosscall_args { } while (0) static inline int sdei_do_local_call(smp_call_func_t fn, - struct sdei_event *event) + struct sdei_internal_event *event) { struct sdei_crosscall_args arg; @@ -97,7 +95,7 @@ static inline int sdei_do_local_call(smp_call_func_t fn, } static inline int sdei_do_cross_call(smp_call_func_t fn, - struct sdei_event *event) + struct sdei_internal_event *event) { struct sdei_crosscall_args arg; @@ -162,16 +160,16 @@ static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0, } NOKPROBE_SYMBOL(invoke_sdei_fn); -static struct sdei_event *sdei_event_find(u32 event_num) +static struct sdei_internal_event *sdei_event_find(u32 event_num) { - struct sdei_event *e, *found = NULL; + struct sdei_internal_event *event_el, *found = NULL; lockdep_assert_held(&sdei_events_lock); spin_lock(&sdei_list_lock); - list_for_each_entry(e, &sdei_list, list) { - if (e->event_num == event_num) { - found = e; + list_for_each_entry(event_el, &sdei_list, list) { + if (event_el->event.event_num == event_num) { + found = event_el; break; } } @@ -193,24 +191,26 @@ static int sdei_api_event_get_info(u32 event, u32 info, u64 *result) 0, 0, result); } -static struct sdei_event *sdei_event_create(u32 event_num, - sdei_event_callback *cb, - void *cb_arg) +static struct sdei_internal_event *sdei_event_create(u32 event_num, + sdei_event_callback *cb, + void *cb_arg) { int err; u64 result; + struct sdei_internal_event *event_el; struct sdei_event *event; struct sdei_registered_event *reg; lockdep_assert_held(&sdei_events_lock); - event = kzalloc(sizeof(*event), GFP_KERNEL); - if (!event) { + event_el = kzalloc(sizeof(*event_el), GFP_KERNEL); + if (!event_el) { err = -ENOMEM; goto fail; } - INIT_LIST_HEAD(&event->list); + event = &event_el->event; + INIT_LIST_HEAD(&event_el->list); event->event_num = event_num; err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY, @@ -237,7 +237,7 @@ static struct sdei_event *sdei_event_create(u32 event_num, reg->callback = cb; reg->callback_arg = cb_arg; - event->registered = reg; + event_el->registered = reg; } else { int cpu; struct sdei_registered_event __percpu *regs; @@ -257,39 +257,39 @@ static struct sdei_event *sdei_event_create(u32 event_num, reg->callback_arg = cb_arg; } - event->private_registered = regs; + event_el->private_registered = regs; } spin_lock(&sdei_list_lock); - list_add(&event->list, &sdei_list); + list_add(&event_el->list, &sdei_list); spin_unlock(&sdei_list_lock); - return event; + return event_el; fail: - kfree(event); + kfree(event_el); return ERR_PTR(err); } -static void sdei_event_destroy_llocked(struct sdei_event *event) +static void sdei_event_destroy_llocked(struct sdei_internal_event *event_el) { lockdep_assert_held(&sdei_events_lock); lockdep_assert_held(&sdei_list_lock); - list_del(&event->list); + list_del(&event_el->list); - if (event->type == SDEI_EVENT_TYPE_SHARED) - kfree(event->registered); + if (event_el->event.type == SDEI_EVENT_TYPE_SHARED) + kfree(event_el->registered); else - free_percpu(event->private_registered); + free_percpu(event_el->private_registered); - kfree(event); + kfree(event_el); } -static void sdei_event_destroy(struct sdei_event *event) +static void sdei_event_destroy(struct sdei_internal_event *event_el) { spin_lock(&sdei_list_lock); - sdei_event_destroy_llocked(event); + sdei_event_destroy_llocked(event_el); spin_unlock(&sdei_list_lock); } @@ -392,7 +392,7 @@ static void _local_event_enable(void *data) WARN_ON_ONCE(preemptible()); - err = sdei_api_event_enable(arg->event->event_num); + err = sdei_api_event_enable(arg->event->event.event_num); sdei_cross_call_return(arg, err); } @@ -400,25 +400,27 @@ static void _local_event_enable(void *data) int sdei_event_enable(u32 event_num) { int err = -EINVAL; + struct sdei_internal_event *event_el; struct sdei_event *event; mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { + event_el = sdei_event_find(event_num); + if (!event_el) { mutex_unlock(&sdei_events_lock); return -ENOENT; } cpus_read_lock(); + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_enable(event->event_num); else - err = sdei_do_cross_call(_local_event_enable, event); + err = sdei_do_cross_call(_local_event_enable, event_el); if (!err) { spin_lock(&sdei_list_lock); - event->reenable = true; + event_el->reenable = true; spin_unlock(&sdei_list_lock); } cpus_read_unlock(); @@ -438,7 +440,7 @@ static void _ipi_event_disable(void *data) int err; struct sdei_crosscall_args *arg = data; - err = sdei_api_event_disable(arg->event->event_num); + err = sdei_api_event_disable(arg->event->event.event_num); sdei_cross_call_return(arg, err); } @@ -446,23 +448,25 @@ static void _ipi_event_disable(void *data) int sdei_event_disable(u32 event_num) { int err = -EINVAL; + struct sdei_internal_event *event_el; struct sdei_event *event; mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { + event_el = sdei_event_find(event_num); + if (!event_el) { mutex_unlock(&sdei_events_lock); return -ENOENT; } spin_lock(&sdei_list_lock); - event->reenable = false; + event_el->reenable = false; spin_unlock(&sdei_list_lock); + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_disable(event->event_num); else - err = sdei_do_cross_call(_ipi_event_disable, event); + err = sdei_do_cross_call(_ipi_event_disable, event_el); mutex_unlock(&sdei_events_lock); return err; @@ -482,7 +486,7 @@ static void _local_event_unregister(void *data) WARN_ON_ONCE(preemptible()); - err = sdei_api_event_unregister(arg->event->event_num); + err = sdei_api_event_unregister(arg->event->event.event_num); sdei_cross_call_return(arg, err); } @@ -490,32 +494,34 @@ static void _local_event_unregister(void *data) int sdei_event_unregister(u32 event_num) { int err; + struct sdei_internal_event *event_el; struct sdei_event *event; WARN_ON(in_nmi()); mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { + event_el = sdei_event_find(event_num); + if (!event_el) { pr_warn("Event %u not registered\n", event_num); err = -ENOENT; goto unlock; } spin_lock(&sdei_list_lock); - event->reregister = false; - event->reenable = false; + event_el->reregister = false; + event_el->reenable = false; spin_unlock(&sdei_list_lock); + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_unregister(event->event_num); else - err = sdei_do_cross_call(_local_event_unregister, event); + err = sdei_do_cross_call(_local_event_unregister, event_el); if (err) goto unlock; - sdei_event_destroy(event); + sdei_event_destroy(event_el); unlock: mutex_unlock(&sdei_events_lock); @@ -529,11 +535,13 @@ int sdei_event_unregister(u32 event_num) static int sdei_unregister_shared(void) { int err = 0; + struct sdei_internal_event *event_el; struct sdei_event *event; mutex_lock(&sdei_events_lock); spin_lock(&sdei_list_lock); - list_for_each_entry(event, &sdei_list, list) { + list_for_each_entry(event_el, &sdei_list, list) { + event = &event_el->event; if (event->type != SDEI_EVENT_TYPE_SHARED) continue; @@ -565,8 +573,8 @@ static void _local_event_register(void *data) WARN_ON(preemptible()); reg = per_cpu_ptr(arg->event->private_registered, smp_processor_id()); - err = sdei_api_event_register(arg->event->event_num, sdei_entry_point, - reg, 0, 0); + err = sdei_api_event_register(arg->event->event.event_num, + sdei_entry_point, reg, 0, 0); sdei_cross_call_return(arg, err); } @@ -574,6 +582,7 @@ static void _local_event_register(void *data) int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) { int err; + struct sdei_internal_event *event_el; struct sdei_event *event; WARN_ON(in_nmi()); @@ -585,33 +594,34 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) goto unlock; } - event = sdei_event_create(event_num, cb, arg); - if (IS_ERR(event)) { - err = PTR_ERR(event); + event_el = sdei_event_create(event_num, cb, arg); + if (IS_ERR(event_el)) { + err = PTR_ERR(event_el); pr_warn("Failed to create event %u: %d\n", event_num, err); goto unlock; } cpus_read_lock(); + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) { err = sdei_api_event_register(event->event_num, sdei_entry_point, - event->registered, + event_el->registered, SDEI_EVENT_REGISTER_RM_ANY, 0); } else { - err = sdei_do_cross_call(_local_event_register, event); + err = sdei_do_cross_call(_local_event_register, event_el); if (err) - sdei_do_cross_call(_local_event_unregister, event); + sdei_do_cross_call(_local_event_unregister, event_el); } if (err) { - sdei_event_destroy(event); + sdei_event_destroy(event_el); pr_warn("Failed to register event %u: %d\n", event_num, err); goto cpu_unlock; } spin_lock(&sdei_list_lock); - event->reregister = true; + event_el->reregister = true; spin_unlock(&sdei_list_lock); cpu_unlock: cpus_read_unlock(); @@ -623,27 +633,29 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) static int sdei_reregister_shared(void) { int err = 0; + struct sdei_internal_event *event_el; struct sdei_event *event; mutex_lock(&sdei_events_lock); spin_lock(&sdei_list_lock); - list_for_each_entry(event, &sdei_list, list) { + list_for_each_entry(event_el, &sdei_list, list) { + event = &event_el->event; if (event->type != SDEI_EVENT_TYPE_SHARED) continue; - if (event->reregister) { + if (event_el->reregister) { err = sdei_api_event_register(event->event_num, - sdei_entry_point, event->registered, + sdei_entry_point, event_el->registered, SDEI_EVENT_REGISTER_RM_ANY, 0); if (err) { - sdei_event_destroy_llocked(event); + sdei_event_destroy_llocked(event_el); pr_err("Failed to re-register event %u\n", event->event_num); break; } } - if (event->reenable) { + if (event_el->reenable) { err = sdei_api_event_enable(event->event_num); if (err) { pr_err("Failed to re-enable event %u\n", @@ -660,16 +672,18 @@ static int sdei_reregister_shared(void) static int sdei_cpuhp_down(unsigned int cpu) { + struct sdei_internal_event *event_el; struct sdei_event *event; int err; /* un-register private events */ spin_lock(&sdei_list_lock); - list_for_each_entry(event, &sdei_list, list) { + list_for_each_entry(event_el, &sdei_list, list) { + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) continue; - err = sdei_do_local_call(_local_event_unregister, event); + err = sdei_do_local_call(_local_event_unregister, event_el); if (err) { pr_err("Failed to unregister event %u: %d\n", event->event_num, err); @@ -682,25 +696,27 @@ static int sdei_cpuhp_down(unsigned int cpu) static int sdei_cpuhp_up(unsigned int cpu) { + struct sdei_internal_event *event_el; struct sdei_event *event; int err; /* re-register/enable private events */ spin_lock(&sdei_list_lock); - list_for_each_entry(event, &sdei_list, list) { + list_for_each_entry(event_el, &sdei_list, list) { + event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) continue; - if (event->reregister) { - err = sdei_do_local_call(_local_event_register, event); + if (event_el->reregister) { + err = sdei_do_local_call(_local_event_register, event_el); if (err) { pr_err("Failed to re-register event %u: %d\n", event->event_num, err); } } - if (event->reenable) { - err = sdei_do_local_call(_local_event_enable, event); + if (event_el->reenable) { + err = sdei_do_local_call(_local_event_enable, event_el); if (err) { pr_err("Failed to re-enable event %u: %d\n", event->event_num, err); diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index 0a241c5c911d..d2464a18b6ff 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -22,6 +22,12 @@ */ typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg); +struct sdei_event { + u32 event_num; + u8 type; + u8 priority; +}; + /* * Register your callback to claim an event. The event must be described * by firmware. From patchwork Thu Jul 30 01:45:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11692187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CEB813B6 for ; Thu, 30 Jul 2020 01:51:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCF4E2074B for ; Thu, 30 Jul 2020 01:51:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QLHlMV8d"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dDPkMhOs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCF4E2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=M7FwR4/4Uvsgqz6Ele+iJiROSk3DKA0fMMsDi0lZb/0=; b=QLHlMV8dT6X6jgds6j3OK2ybS 9p99Gws9F7m1XlDJlC00+VXgHRYoKFL3DSbscucbZnYxD+teC4tI0JviSfCYxpEhHbbR2GvQ281HI 4lLufzMiLF7JdNUvetuA1/zH8U9kGxo7z96MQivGQAqSg2Rt4a44R0qsbvDmSXLUzF9PWuZb0iskm blj5HGrcPJmqqsbSrAzXnPDfOevWTEKKWnqO5ysHKA3miH9yCnhmhD5BQLLU6O4LRu1EuuvuifP9Q fK1ELCpj5hzsWDYr9NUk+BKBEh0bW70/AgEudqupR/AiygruZdUc0z11eWtN80H431B3XYp0wbh2w ioKq5fdYA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xhJ-0004N4-6J; Thu, 30 Jul 2020 01:49:32 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0xed-0003BY-4G for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 01:46:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596073601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sz2vaPL5FS6pA5oXa7tR1/JoXFLskcg3QTq3qwK9xnk=; b=dDPkMhOsw2hGAX8E1IT/vaAAZ2pNNdTVnyll6Ys7AcA3KvNNe29tac7Pwq9rQr5x/ZuWn9 FzeSdV+vv9nkZg+jZ0yIh9zCUBzw1QWeYuLTpmxL/2wpJG3oC1iB4o+JPsMqLvPrOdn7Rv uEyN5V4ordxgERn1r+Sa984owb3COhU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-c__o4IILNP-bVTQtRBVaxw-1; Wed, 29 Jul 2020 21:46:37 -0400 X-MC-Unique: c__o4IILNP-bVTQtRBVaxw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B10858; Thu, 30 Jul 2020 01:46:36 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id B37D96FEF4; Thu, 30 Jul 2020 01:46:33 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 15/15] drivers/firmware/sdei: Identify event by struct sdei_event Date: Thu, 30 Jul 2020 11:45:30 +1000 Message-Id: <20200730014531.310465-16-gshan@redhat.com> In-Reply-To: <20200730014531.310465-1-gshan@redhat.com> References: <20200730014531.310465-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_214643_269616_73CC3012 X-CRM114-Status: GOOD ( 19.37 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.211.31.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org There are 4 APIs exported by the driver as below. They are using the event number as the identifier to the event. It's conflicting with the requirement to dereference the event by struct sdei_event instance when SDEI virtualization is supported. So this reworks on the APIs accordingly to dereference the event by struct sdei_event instance: * sdei_event_register() returns the struct sdei_event instance. * sdei_event_unregister() and sdei_event_{enable, disable}() accepts struct sdei_event instance as the parameter. * Rework sdei_{register,unregister}_ghes() to use the modified APIs. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron --- v4: Rename @se to @event for APIs --- drivers/firmware/arm_sdei.c | 76 ++++++++++++++++++------------------- include/linux/arm_sdei.h | 10 +++-- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index f9827c096275..9c7a6a7c9527 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -397,22 +397,14 @@ static void _local_event_enable(void *data) sdei_cross_call_return(arg, err); } -int sdei_event_enable(u32 event_num) +int sdei_event_enable(struct sdei_event *event) { int err = -EINVAL; - struct sdei_internal_event *event_el; - struct sdei_event *event; + struct sdei_internal_event *event_el = + container_of(event, struct sdei_internal_event, event); mutex_lock(&sdei_events_lock); - event_el = sdei_event_find(event_num); - if (!event_el) { - mutex_unlock(&sdei_events_lock); - return -ENOENT; - } - - cpus_read_lock(); - event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_enable(event->event_num); else @@ -445,24 +437,17 @@ static void _ipi_event_disable(void *data) sdei_cross_call_return(arg, err); } -int sdei_event_disable(u32 event_num) +int sdei_event_disable(struct sdei_event *event) { int err = -EINVAL; - struct sdei_internal_event *event_el; - struct sdei_event *event; + struct sdei_internal_event *event_el = + container_of(event, struct sdei_internal_event, event); mutex_lock(&sdei_events_lock); - event_el = sdei_event_find(event_num); - if (!event_el) { - mutex_unlock(&sdei_events_lock); - return -ENOENT; - } - spin_lock(&sdei_list_lock); event_el->reenable = false; spin_unlock(&sdei_list_lock); - event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_disable(event->event_num); else @@ -491,28 +476,20 @@ static void _local_event_unregister(void *data) sdei_cross_call_return(arg, err); } -int sdei_event_unregister(u32 event_num) +int sdei_event_unregister(struct sdei_event *event) { int err; - struct sdei_internal_event *event_el; - struct sdei_event *event; + struct sdei_internal_event *event_el = + container_of(event, struct sdei_internal_event, event); WARN_ON(in_nmi()); mutex_lock(&sdei_events_lock); - event_el = sdei_event_find(event_num); - if (!event_el) { - pr_warn("Event %u not registered\n", event_num); - err = -ENOENT; - goto unlock; - } - spin_lock(&sdei_list_lock); event_el->reregister = false; event_el->reenable = false; spin_unlock(&sdei_list_lock); - event = &event_el->event; if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_unregister(event->event_num); else @@ -579,7 +556,9 @@ static void _local_event_register(void *data) sdei_cross_call_return(arg, err); } -int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) +struct sdei_event *sdei_event_register(u32 event_num, + sdei_event_callback *cb, + void *arg) { int err; struct sdei_internal_event *event_el; @@ -590,13 +569,14 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) mutex_lock(&sdei_events_lock); if (sdei_event_find(event_num)) { pr_warn("Event %u already registered\n", event_num); - err = -EBUSY; + event = ERR_PTR(-EBUSY); goto unlock; } event_el = sdei_event_create(event_num, cb, arg); if (IS_ERR(event_el)) { err = PTR_ERR(event_el); + event = ERR_PTR(err); pr_warn("Failed to create event %u: %d\n", event_num, err); goto unlock; } @@ -615,11 +595,13 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) } if (err) { + event = ERR_PTR(err); sdei_event_destroy(event_el); pr_warn("Failed to register event %u: %d\n", event_num, err); goto cpu_unlock; } + event = &event_el->event; spin_lock(&sdei_list_lock); event_el->reregister = true; spin_unlock(&sdei_list_lock); @@ -627,7 +609,7 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) cpus_read_unlock(); unlock: mutex_unlock(&sdei_events_lock); - return err; + return event; } static int sdei_reregister_shared(void) @@ -876,6 +858,7 @@ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, u64 result; u32 event_num; sdei_event_callback *cb; + struct sdei_event *event; if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return -EOPNOTSUPP; @@ -899,9 +882,13 @@ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, else cb = normal_cb; - err = sdei_event_register(event_num, cb, ghes); - if (!err) - err = sdei_event_enable(event_num); + event = sdei_event_register(event_num, cb, ghes); + if (IS_ERR(event)) { + err = PTR_ERR(event); + return err; + } + + err = sdei_event_enable(event); return err; } @@ -911,22 +898,31 @@ int sdei_unregister_ghes(struct ghes *ghes) int i; int err; u32 event_num = ghes->generic->notify.vector; + struct sdei_internal_event *event_el; + struct sdei_event *event; might_sleep(); if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return -EOPNOTSUPP; + mutex_lock(&sdei_events_lock); + event_el = sdei_event_find(event_num); + mutex_unlock(&sdei_events_lock); + if (!event_el) + return -ENOENT; + /* * The event may be running on another CPU. Disable it * to stop new events, then try to unregister a few times. */ - err = sdei_event_disable(event_num); + event = &event_el->event; + err = sdei_event_disable(event); if (err) return err; for (i = 0; i < 3; i++) { - err = sdei_event_unregister(event_num); + err = sdei_event_unregister(event); if (err != -EINPROGRESS) break; diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index d2464a18b6ff..2723a99937f3 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -32,16 +32,18 @@ struct sdei_event { * Register your callback to claim an event. The event must be described * by firmware. */ -int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg); +struct sdei_event *sdei_event_register(u32 event_num, + sdei_event_callback *cb, + void *arg); /* * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling * it until it succeeds. */ -int sdei_event_unregister(u32 event_num); +int sdei_event_unregister(struct sdei_event *event); -int sdei_event_enable(u32 event_num); -int sdei_event_disable(u32 event_num); +int sdei_event_enable(struct sdei_event *event); +int sdei_event_disable(struct sdei_event *event); /* GHES register/unregister helpers */ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,