From patchwork Mon Jul 6 05:47: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: 11644871 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 DC1F960D for ; Mon, 6 Jul 2020 05:50: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 B51EA206E6 for ; Mon, 6 Jul 2020 05:50: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="Ue+QXcgt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QuH6Jr3z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B51EA206E6 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=fs26gZVE+HwTdyR5qTInKRPkGpz5jAGxIk6z/mEvjBw=; b=Ue+QXcgtAu5+PHaKDwyPAlLOQ SgsyM8p+cjI+WPnuS7o+sfSg0DG/2mitZlD8yX31maEcOsxXf7UiieWXY5L+VFijPymz4W4In88/X eAYTR2XgU6it9xkehmR2emuSEpc73YVgK6p2TynQfWSNIVPKnW+O8ZveWJD/wEEo+oHv3OxdAxpju ATpj9pC/xE9wkoo3rGwevcL3XzNGJkcF1H8CfwmAq+F3X15dgeUfEG1TXSxJ9/sf6hYj+lD6jdW/w dCIptJCsFc87HObL2ZhTaRSC3RkTG40DzSPGULBrgvOzvp0ioq1hKcrixYnAdWpIqXxOD3Zmz0yh1 bjuT9jcRw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJyv-0003We-NI; Mon, 06 Jul 2020 05:47:57 +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 1jsJys-0003W4-UX for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:47:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014473; 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=lwX0yvwf4a177Zn91qdAoIi5sCLUFTkruY7ga8C5Y74=; b=QuH6Jr3zhx4rqJoVw1kQPi27thaV4yyc/kJxurnV0tg29GWX2AbJZaFugF+5iHa+pF5UXT qJZZbYpOCFxTJvqP2iG0mdRE6iUQTBIJDYURdZ7etVNs+ntqtU6QlfO/YrN3kwjoF+SsaQ E+WF3W379gEULpW1D6OGA884XykI3+8= 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-438-PQgHBafmNsmwIy9yFes-9w-1; Mon, 06 Jul 2020 01:47:52 -0400 X-MC-Unique: PQgHBafmNsmwIy9yFes-9w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5670800403; Mon, 6 Jul 2020 05:47:50 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F376C0DBA; Mon, 6 Jul 2020 05:47:48 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 01/14] drivers/firmware/sdei: Remove sdei_is_err() Date: Mon, 6 Jul 2020 15:47:19 +1000 Message-Id: <20200706054732.99387-2-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014755_026777_8C87BC72 X-CRM114-Status: GOOD ( 14.13 ) 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_H3 RBL: Good reputation (+3) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com 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(). This shouldn't cause functional changes. Signed-off-by: Gavin Shan Reviewed-by: James Morse --- drivers/firmware/arm_sdei.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index e7e36aab2386..415c243a8e65 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, @@ -147,8 +128,7 @@ static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0, 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 Mon Jul 6 05:47: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: 11644861 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 533C460D for ; Mon, 6 Jul 2020 05:49: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 2649E20739 for ; Mon, 6 Jul 2020 05:49: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="Yr4txx9x"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EMP6jNNx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2649E20739 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=ybMRjVGvs0lvViaN9ZCjEGM17BVUOVncny4JfepzSZU=; b=Yr4txx9xQlWPyaA1bdGG3BP5k 02QBqJOXPkeBBZgubTAZz9IA2AlyOXMhhIoE+3HzoPsPSVGjQ+vtoRoducfivxzQRk7VMGpdAEtN4 PyAkWwN6js+hXgHnA72wdmnBg6l+Z9HmDBZpG+x1bh2uPEd6Z4bZbEzmrZBlWcLKvaN9+Mbwx0L3/ lJiM5dA5CzI/YnVG5KtA4ZDkjX+65nZx7Z33qV8Wl5Lm4GO86mUQQAJ7WNZ5I2/DlRaQCKWWqIr3A P65S1Bzidlcdw2ED9cKxbem7atNI9bxEfV7tlGH+EXeSBxGl/m2bf2iMaglIsRm8snlxEWZ/K4sE1 ZulEXRw6Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJz0-0003Xd-8Z; Mon, 06 Jul 2020 05:48:02 +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 1jsJyw-0003Wl-Qi for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:47:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014478; 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=PGFQ88tr5M2m58z/b6yYODSxjgEAIdHDWPIlG9VPi+w=; b=EMP6jNNxwPhKgGrf89cBVhnnN4b7sIQZgXMaR5NdlPNVkf45XCUMtM4HhTVvo4WhJQ4ohc w2mg0gIW3XL9VDgDRrGPDb16bBEY9dlUqxtxzEGAzJrGEBdp7qscarnODIHK9CcnSl9w9Z 99P+g9eqNgF4Pi3Amx1rImO8shKedWQ= 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-448-59Bsk2KxPSeeDQ4Mg0hNJg-1; Mon, 06 Jul 2020 01:47:55 -0400 X-MC-Unique: 59Bsk2KxPSeeDQ4Mg0hNJg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 982BC1005510; Mon, 6 Jul 2020 05:47:54 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E8CCCF94C; Mon, 6 Jul 2020 05:47:51 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/14] drivers/firmware/sdei: Common block for failing path in sdei_event_create() Date: Mon, 6 Jul 2020 15:47:20 +1000 Message-Id: <20200706054732.99387-3-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014759_023283_6038BBED X-CRM114-Status: GOOD ( 12.06 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The failing path in sdei_event_create() is to free SDEI event and return the corresponding error. This introduces common block of code for that to avoid duplicated logics. By the way, the function scoped variables are also reordered according to their importance. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 415c243a8e65..a75212a743d3 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -182,41 +182,39 @@ static struct sdei_event *sdei_event_create(u32 event_num, sdei_event_callback *cb, void *cb_arg) { - int err; - u64 result; struct sdei_event *event; struct sdei_registered_event *reg; + u64 result; + int err; 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,9 @@ 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 Mon Jul 6 05:47: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: 11644881 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 E8A0E13B6 for ; Mon, 6 Jul 2020 05:50:38 +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 BE6232074F for ; Mon, 6 Jul 2020 05:50:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qIqMX9+r"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hIL9X16k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE6232074F 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=WUtsusn+R8U1Wb96jijrngvDJsExR9s5QfCZDl4DpKo=; b=qIqMX9+r3tMCZ9OambW5pWY4Z xezaF8a0x3SFCWIlsj4QtZZ8F2/Aos6A5bCx69w12GxKmIKXXpZm15Z09uYfOoUoud1Pn+Vuqz4A/ iWJeomUwp0IVz/Qed2fbKiSSt00aJCTybJn6t/bHnCf/SAkMFv4xyZF8lzogjz4wq83XclTUd7PVP Vo5d7XIEswlJygxxEjcxFgkr50TC9dmR2qXk37tzQ5y/+JvZZt80q3OHlkYDqML2PUIbfTj/Al7nO 8/EgN3Z7oC+WnxDD+v6Hn2OHyVyFX3FQHt+bDVVGJMTOAeSKTS9YbaLTZj+Vs/mTDjLKvcdFXQgL0 tyP+Ge/QQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJz3-0003YZ-Sn; Mon, 06 Jul 2020 05:48:05 +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 1jsJz0-0003Xc-4O for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014481; 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=7/yDAu2YxhpEZSUHewbX6rNmpw9uJ8GVPgb63NeuF4U=; b=hIL9X16kALdwGDBaggkPOb0o39KFTB4NTHBno/0LX2fpOykuF2/mPtyR77SmY6szsw1zN8 bgK1pE2GLVpLFeUMwMvngGZGOoEWb6hjUsL7in3hYfAA/NrQ2rcgKljTsqRooUIgtfeNe5 +faiSAVHFvpnnNjCOZwVlG84tUYNWiE= 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-485-IEz5aKoXPBKSqr3N-j28kQ-1; Mon, 06 Jul 2020 01:47:58 -0400 X-MC-Unique: IEz5aKoXPBKSqr3N-j28kQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA260A0BD7; Mon, 6 Jul 2020 05:47:56 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 350FCC0DBA; Mon, 6 Jul 2020 05:47:53 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/14] drivers/firmware/sdei: Dereference SDEI event parameter directly Date: Mon, 6 Jul 2020 15:47:21 +1000 Message-Id: <20200706054732.99387-4-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014802_265006_ABC01433 X-CRM114-Status: GOOD ( 12.44 ) 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.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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The SDEI parameter is dereferenced by @sdei_event->registered or @sdei_event->private_registered, depending on the event type. They can be dereferenced directly so that the intermediate variable (@regs) can be removed. It makes the code looks a bit simplified. Also, @event->event_num instead of @event_num is used for retrieving the event number for the shared event, which makes the code similar to the case of private event. Besides, the local scoped variables are reordered according to their importance by the way. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index a75212a743d3..35a319e7e1e6 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -211,38 +211,35 @@ static struct sdei_event *sdei_event_create(u32 event_num, event->type = result; if (event->type == SDEI_EVENT_TYPE_SHARED) { - reg = kzalloc(sizeof(*reg), GFP_KERNEL); - if (!reg) { + event->registered = kzalloc(sizeof(*reg), GFP_KERNEL); + if (!event->registered) { err = -ENOMEM; goto fail; } - reg->event_num = event_num; - reg->priority = event->priority; - - reg->callback = cb; - reg->callback_arg = cb_arg; - event->registered = reg; + event->registered->event_num = event->event_num; + event->registered->priority = event->priority; + event->registered->callback = cb; + event->registered->callback_arg = cb_arg; } else { int cpu; - struct sdei_registered_event __percpu *regs; + struct sdei_registered_event *reg; - regs = alloc_percpu(struct sdei_registered_event); - if (!regs) { + event->private_registered = + alloc_percpu(struct sdei_registered_event); + if (!event->private_registered) { err = -ENOMEM; goto fail; } for_each_possible_cpu(cpu) { - reg = per_cpu_ptr(regs, cpu); + reg = per_cpu_ptr(event->private_registered, cpu); reg->event_num = event->event_num; reg->priority = event->priority; reg->callback = cb; reg->callback_arg = cb_arg; } - - event->private_registered = regs; } spin_lock(&sdei_list_lock); From patchwork Mon Jul 6 05:47: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: 11644865 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 DE78D60D for ; Mon, 6 Jul 2020 05:50:03 +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 B75AF20739 for ; Mon, 6 Jul 2020 05:50:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jDjBqpSh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PXTgKnnj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B75AF20739 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=QQzCI/EiVBVb6i8YL262EWr8i32/f3B+gyZPfWhig9g=; b=jDjBqpShzsAeOZMKE4TV85nSN Ni3Fy8wSiAmz03BnBDbuoaTCAp4g0x5sTGgfDglwqJWnHOlbmT6lqQ7OEnrD0yQVGvYwn44i5x+rC LoU9uNh5koTJ4yORTp+KZ51fFDgji0urhdaCHudJIWaWy0eFVGEoqKcS/jz+waTF7UX6RzflKDLyq rw3Vjcg7mFF2uLvtLpdKj0/KHaX9A6cc6RSbkHg+kwKV+s06voezF7kTFOcrAUq74OufW2msdfDp4 Hyb3vTdtaFidgX8noga8VPnnOxcDgNPOkABNenJoln8fAlkfhuCq/IdsUR6KLX2JieW5ZwTlTRPOe s4ZfaMQKA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJz7-0003Z8-KW; Mon, 06 Jul 2020 05:48:09 +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 1jsJz0-0003Xj-Lu for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014482; 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=64gWJEFelnKgYAula/uoutdlAyE5+Tm44u2RP58Y9z4=; b=PXTgKnnjs5RR6akod2p7Ex53zLC+PumaZFuZcmNunGstXqjDMp0jon76c1cs4JzIg/4p7r 1e5ZpRqejaJmZ1fSmwO02nrpRtaDadvv7nGxGrAHq+xzJM/OzvzqnrQ8JjyA9jq5AK4WBw 1y6jeMN04U4HA4qPU1IYtUh1IXk0viY= 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-150-HTKAIRsuMOa0owh7m5W4nQ-1; Mon, 06 Jul 2020 01:48:00 -0400 X-MC-Unique: HTKAIRsuMOa0owh7m5W4nQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E0D8107B765; Mon, 6 Jul 2020 05:47:59 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DA47C0DBA; Mon, 6 Jul 2020 05:47:56 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/14] drivers/firmware/sdei: Rework sdei_init() Date: Mon, 6 Jul 2020 15:47:22 +1000 Message-Id: <20200706054732.99387-5-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014802_837182_EBCE7878 X-CRM114-Status: GOOD ( 13.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_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [205.139.110.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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This reworks sdei_init() * The function follows the steps in sequence: check ACPI existence, register platform device, register platform driver. * The corresponding error numbers are returned in failing paths. * The platform device is deleted if the driver can't be registered. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 35a319e7e1e6..7e7b26b1f91b 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -1058,7 +1058,7 @@ static bool __init sdei_present_acpi(void) acpi_status status; struct acpi_table_header *sdei_table_header; - if (acpi_disabled) + if (!IS_ENABLED(CONFIG_ACPI) || acpi_disabled) return false; status = acpi_get_table(ACPI_SIG_SDEI, 0, &sdei_table_header); @@ -1077,19 +1077,27 @@ static bool __init sdei_present_acpi(void) static int __init sdei_init(void) { - int ret = platform_driver_register(&sdei_driver); + struct platform_device *pdev; + int ret; - if (!ret && sdei_present_acpi()) { - struct platform_device *pdev; + if (!sdei_present_acpi()) + return -EPERM; - 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)); + 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 -ENOMEM; } - return ret; + ret = platform_driver_register(&sdei_driver); + if (ret) { + platform_device_del(pdev); + return ret; + } + + return 0; } /* From patchwork Mon Jul 6 05:47: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: 11644863 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 8C4BF13B4 for ; Mon, 6 Jul 2020 05:49: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 6605620739 for ; Mon, 6 Jul 2020 05:49: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="KKOJCXwz"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CB6K6nhN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6605620739 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=ygyR8iw5J2y1JXSAqZqf2GtEnzb4oCVQj2BFMVFOW5o=; b=KKOJCXwznMlmLaXXG64N1zzRH y+M9IPEnPQaqIWmUUwKbuXF5J8o6L8K0p5WZaDx/vRaIMjGoktkxhFhxnNBon987ztLH2aoF5OwRa mSsYc9Vnv5WwL0qe1QG02Ak4Zf6mpOodZU2vNdEH0Pa+yx0dZPFC8PT9pJADtWStH87dQE1sevDoc Arp/QwQ4JcDqMtmlTG6AleL7JGS1J+6ywqIjaIcsDliiHG7jOZjSlP/sjJcgZS+3yK2VKfZ+u/6jj IzOJxfFXYC/tM5Gr+/8Ji5CbhErBok6niMAchuoHr1rHkk1Gkyi0wQjcSXLBQ6acL4cnK/bxaHOKn 5fNp0tzeA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzB-0003aB-A4; Mon, 06 Jul 2020 05:48:13 +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 1jsJz3-0003Ya-VT for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014485; 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=4vmNEyqmrubgoSVYBU+M5O6KwKr6W8TujiPFTF3c5Mg=; b=CB6K6nhNB6qIPg41/Z0I0LdAIOqMYC6GbY7CI6zmnQwlh1+e0D2Et4TDxsJprUoyvyp0wt DgbdQ0qCHFrrJJotgpMO4mG66qAeuCVVgMqHLOrFf+5Q5bGoT7ttq+pHQzcrqy9rNX3282 iXomFaE9gs0v7v0gjJaFSjqh0NGSpnc= 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-64-NfxUnEkHPwya9ZRZsoPcfw-1; Mon, 06 Jul 2020 01:48:03 -0400 X-MC-Unique: NfxUnEkHPwya9ZRZsoPcfw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F1A5A0BD7; Mon, 6 Jul 2020 05:48:02 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF937C0DBA; Mon, 6 Jul 2020 05:47:59 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/14] drivers/firmware/sdei: Remove sdei_get_conduit() Date: Mon, 6 Jul 2020 15:47:23 +1000 Message-Id: <20200706054732.99387-6-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014806_117887_780B7A5C X-CRM114-Status: GOOD ( 13.07 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org There are some logics in sdei_get_conduit() can be safely dropped: * There are no associated device node with the platform device, so it's pointless to check on it. * ACPI functionality has been verified when the platform device is added in sdei_init(). So it's unnecessary to recheck. With above logics dropped, sdei_get_conduit() is quite simple and it's not worthy to maintain a separate function. The logic is merged to sdei_probe() as it's the only caller. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 40 +++---------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 7e7b26b1f91b..ca0e3f5eb907 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -933,49 +933,15 @@ int sdei_unregister_ghes(struct ghes *ghes) return err; } -static int sdei_get_conduit(struct platform_device *pdev) -{ - const char *method; - struct device_node *np = pdev->dev.of_node; - - sdei_firmware_call = NULL; - if (np) { - if (of_property_read_string(np, "method", &method)) { - pr_warn("missing \"method\" property\n"); - return SMCCC_CONDUIT_NONE; - } - - if (!strcmp("hvc", method)) { - sdei_firmware_call = &sdei_smccc_hvc; - return SMCCC_CONDUIT_HVC; - } else if (!strcmp("smc", method)) { - sdei_firmware_call = &sdei_smccc_smc; - return SMCCC_CONDUIT_SMC; - } - - pr_warn("invalid \"method\" property: %s\n", method); - } else if (IS_ENABLED(CONFIG_ACPI) && !acpi_disabled) { - if (acpi_psci_use_hvc()) { - sdei_firmware_call = &sdei_smccc_hvc; - return SMCCC_CONDUIT_HVC; - } else { - sdei_firmware_call = &sdei_smccc_smc; - return SMCCC_CONDUIT_SMC; - } - } - - return SMCCC_CONDUIT_NONE; -} - static int sdei_probe(struct platform_device *pdev) { int err; u64 ver = 0; int conduit; - conduit = sdei_get_conduit(pdev); - if (!sdei_firmware_call) - return 0; + conduit = acpi_psci_use_hvc() ? SMCCC_CONDUIT_HVC : SMCCC_CONDUIT_SMC; + sdei_firmware_call = acpi_psci_use_hvc() ? + &sdei_smccc_hvc : &sdei_smccc_smc; err = sdei_api_get_version(&ver); if (err == -EOPNOTSUPP) From patchwork Mon Jul 6 05:47: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: 11644875 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 59496739 for ; Mon, 6 Jul 2020 05:50:36 +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 F0084206E6 for ; Mon, 6 Jul 2020 05:50:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0eZxjIOl"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MDCyk5Yq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0084206E6 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=Y+NUcZwRG8lEZDAbcb37xN2YT2r/IQtSFQZOZsh33Ns=; b=0eZxjIOleEo1NqcDVUnjzPoWN IgGVxk22hDQkOsQMj7RRr0GiUJMy83N2/m4ETvolBop3G1O3asHhFjzwvtr4oSMUTZNDN1iDolvWg WizTcwdwt5R275TsB6FBeCGKX5rYKlgCU27xtHCtQM8CizU3lLJGtJY3j9LklLtU/jM7hldfj2d7s Dt66RwNT35X7NIs9h1bX5MAtXYzRH4fWTU0eRm6nqJHUG0nYaufDiQL7+PaVi4nwIwz2h7GoX45qX A9GU6X4MB3bFfaPZitjjYgqo/FX4RNQoNu/Um+pmOPukW0KbjvyQEa24t3fgPcNmHD+trJSkDMRwm 0bTTJs/Ew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzG-0003c4-21; Mon, 06 Jul 2020 05:48:19 +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 1jsJz8-0003ZI-El for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014490; 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=QpIMne7SJiTcVxKbD28trTYpKVnK2HH1XZoyUkaBEXQ=; b=MDCyk5Yq55JVL1WcM+RZ7gdlUAOdS+t6h48hGarOoMY76Ca8O2AjNWXLysbP7JLl4T46n9 rFRf4PGvbc15OLgDZczlyV0ow53O/I2dBDg9YeABDcJdTEXUyiXEOAHzKa+NcJXi1LIViM 67L1aj8h3H6NuBpFUHdqv795PgPedsE= 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-26-jmZQctS-Pi-VNNsh66Udzw-1; Mon, 06 Jul 2020 01:48:06 -0400 X-MC-Unique: jmZQctS-Pi-VNNsh66Udzw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1C24800D5C; Mon, 6 Jul 2020 05:48:04 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF022C0DBA; Mon, 6 Jul 2020 05:48:02 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/14] drivers/firmware/sdei: Drop redundant error message in sdei_probe() Date: Mon, 6 Jul 2020 15:47:24 +1000 Message-Id: <20200706054732.99387-7-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014810_585450_5404E1AD X-CRM114-Status: GOOD ( 10.12 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This drops the redundant error message in sdei_probe() because the situation can be indicated by the error number from next error message. The function scoped variables are reorder according to their importance by the way. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index ca0e3f5eb907..28bc712ba71d 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -935,17 +935,15 @@ int sdei_unregister_ghes(struct ghes *ghes) static int sdei_probe(struct platform_device *pdev) { - int err; - u64 ver = 0; int conduit; + u64 ver = 0; + int err; conduit = acpi_psci_use_hvc() ? SMCCC_CONDUIT_HVC : SMCCC_CONDUIT_SMC; sdei_firmware_call = acpi_psci_use_hvc() ? &sdei_smccc_hvc : &sdei_smccc_smc; 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 Mon Jul 6 05:47: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: 11644867 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 2D5AC60D for ; Mon, 6 Jul 2020 05:50:10 +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 0558F2074F for ; Mon, 6 Jul 2020 05:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nHEHxMAA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CqQIPpf7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0558F2074F 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=Y4DfD57cjYd1mIkTpaWnaPJ3hjDAEmbVqCYFuZ6zcPI=; b=nHEHxMAAz14Gwz1v4+KhNlYnd PAaDnLA7GXWz1F3TxnqOl8w6KsL8/F3vI/38elsxB6OwZhIqGEuB1c0OjAhZRrttP9ktIJ3FMcEOS uNYHE/Bb+Kg2Pmdw55bLN9lKORDPQX5ZffnaWimbGqPxFwgTg1eC6jl8LOWL58M/DOAU/CxvbHVZM tEwNxIOIzKRHuwzguNPhsWzPvCK8SQ65PJ63QdccERDVgvYKW5eYPlZGF8Iz4PZPpBgzW5HsjTaqi V1VmwfkRkcYKgRMuX58QSGRIZdiLUVoy4e8tkEGLfvDpOKk4ifa0yAx+9/Adnr/sHR4L+GRxp3MhC Jfywdc+sQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzP-0003ek-5s; Mon, 06 Jul 2020 05:48:27 +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 1jsJz9-0003Zm-8j for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014490; 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=DpdgncV4K5FhuDk3z4/OkurhKvj2O5wppTTQEw8+qM8=; b=CqQIPpf7SnW1+aMR7opSFX5Ni8D0toVzlol1tTalLLlF23c++AFSv6XHlIRjron9BPKWjF x/vVioVPUMLRifoY6rqBe57MqQ1BGX+hnyRyKKSX7fUg/dwvu09qiycpetlthZQDivUM4l QZ85rHL3uXcW6pJLjZWPeehSeMpwYmY= 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-278-iunEPf7tMumbh9dM2JHIDQ-1; Mon, 06 Jul 2020 01:48:08 -0400 X-MC-Unique: iunEPf7tMumbh9dM2JHIDQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EE78800D5C; Mon, 6 Jul 2020 05:48:07 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D124CF953; Mon, 6 Jul 2020 05:48:05 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/14] drivers/firmware/sdei: Drop unnecessary while loop Date: Mon, 6 Jul 2020 15:47:25 +1000 Message-Id: <20200706054732.99387-8-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014812_126023_067654E8 X-CRM114-Status: GOOD ( 11.92 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org There are two unnecessary "do { ... } while (0);" in the function sdei_event_{register, unregister} separately. This just removes them to avoid them to make the code a bit cleaner. This shouldn't cause any logical changes. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 86 ++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 28bc712ba71d..e3efea40df88 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -487,26 +487,25 @@ 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 out; + } - 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 out; - sdei_event_destroy(event); - } while (0); - mutex_unlock(&sdei_events_lock); + sdei_event_destroy(event); +out: + mutex_unlock(&sdei_events_lock); return err; } @@ -586,36 +585,37 @@ 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 out; + } - 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 out; + } - 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(); +out: + mutex_unlock(&sdei_events_lock); return err; } From patchwork Mon Jul 6 05:47: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: 11644877 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 CE4AC60D for ; Mon, 6 Jul 2020 05:50:37 +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 A686B206E6 for ; Mon, 6 Jul 2020 05:50:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cJaH0Oqd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ToikbCAf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A686B206E6 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=HBM5NMwXZSqO7ZciA20Dfhkbps5Lf9wXP1hre0Np91g=; b=cJaH0OqdFtfi+sxqL7Oppge9r BRAHVhGKfMII8Nt0/4dg4VWpM/0uFPHVIhY+NJrw2mQuA74Bg6eY5F53o6FeqmGWSRfFxnJOIvWN2 FdyUfRBt97b3wHKH8BX4dXNp7LUEVFOxonAkt8z3Jp0JCdGNkEHAfZulGGV476p4ytKS/Z4l7A4e/ 6IUBgCC0OjXocCuQjFqvxUmlHJ8TV0/5HBxYX9kZJdP+l0DJ1yWV6q45oahOy004IXTM3wot0OJUr kQb/siMGXXcJQ9q10uTsCloWTnI/uNeifALNdPQ4FJjJDDcPqcgjetsM3okG2VgUNt8veBBgC9cp6 A4KaxUnrQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzb-0003jp-4B; Mon, 06 Jul 2020 05:48:39 +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 1jsJzE-0003bS-7U for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014495; 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=8ibpLY/Xa6vfyDyYqc8TXqwLLLzPrbQBsdtjZP1M5oY=; b=ToikbCAfBp/pRHr1P3l8L/BtfogM2cGJWfx2P3TmLEQqHuHgn0qdYyHhkwJ8PsWkfrHsOL +Wk6zLu/K9t/DUZUlFkbmcy4+YleYeYGoDHD6+jGcsAsUMtG53vOc1q2JL2GkH00Eb7GRl 3XYRG2OJwZGY1ODXIMjzGh4ybrCWChc= 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-190-sxSbdTGuM9KPjMBSWqNhMg-1; Mon, 06 Jul 2020 01:48:11 -0400 X-MC-Unique: sxSbdTGuM9KPjMBSWqNhMg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7EFFE80183C; Mon, 6 Jul 2020 05:48:10 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AD25C0DBA; Mon, 6 Jul 2020 05:48:08 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/14] drivers/firmware/sdei: Cleanup on cross call functions Date: Mon, 6 Jul 2020 15:47:26 +1000 Message-Id: <20200706054732.99387-9-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014816_360822_5EC8C80F X-CRM114-Status: GOOD ( 12.20 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This applies cleanup on the corss call functions, no functional changes is introduced: * Cleanup struct sdei_crosscall_arg to use tab between fields and their types. * Move sdei_cross_call_return() ahead of sdei_do_cross_call(). * Refactor CROSSCALL_INIT to use "do { ... } while (0)". Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index e3efea40df88..3393f1650b20 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -73,14 +73,24 @@ static LIST_HEAD(sdei_list); /* Private events are registered/enabled via IPI passing one of these */ struct sdei_crosscall_args { - struct sdei_event *event; - atomic_t errors; - int first_error; + struct sdei_event *event; + atomic_t errors; + int first_error; }; -#define CROSSCALL_INIT(arg, event) (arg.event = event, \ - arg.first_error = 0, \ - atomic_set(&arg.errors, 0)) +#define CROSSCALL_INIT(arg, event) \ + do { \ + arg.event = event; \ + arg.first_error = 0; \ + atomic_set(&arg.errors, 0); \ + } while (0) + +static inline void +sdei_cross_call_return(struct sdei_crosscall_args *arg, int err) +{ + if (err && (atomic_inc_return(&arg->errors) == 1)) + arg->first_error = err; +} static inline int sdei_do_cross_call(void *fn, struct sdei_event * event) { @@ -92,13 +102,6 @@ static inline int sdei_do_cross_call(void *fn, struct sdei_event * event) return arg.first_error; } -static inline void -sdei_cross_call_return(struct sdei_crosscall_args *arg, int err) -{ - if (err && (atomic_inc_return(&arg->errors) == 1)) - arg->first_error = err; -} - static int sdei_to_linux_errno(unsigned long sdei_err) { switch (sdei_err) { From patchwork Mon Jul 6 05:47: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: 11644879 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 E179B739 for ; Mon, 6 Jul 2020 05:50:38 +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 B9CE6206E6 for ; Mon, 6 Jul 2020 05:50:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Oiq3MWMC"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KrdmFZd4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9CE6206E6 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=kOgOpMUbLez8ZePY2uCEUanoaAcn3mGv+j80KKQUNy8=; b=Oiq3MWMCazjPEV4jz4YKX3ytn CPT+4PNM4yWPL7wwE/uWsmXM4Bkw5AbdQFGq8IKmOJriJJ2wWUZygo90LWqsuvytvcrsig0LvjCp+ EXoO+NAUTzNsWnID4sb31yeYYgdLTSSNptY7SEzYsFYyCsDbDoKJ/g/HR/ivfqePMgi7z5TkffAVx wAf16n5Med15GaNGT3HLVCrbF4WCRohmtcBv1MnVFX1lyFLrM/lkXvOu6t48uS40/Qe2E+6GKZLg9 oHDmLjbfs7zqP4wx5aE51szh7pe+46O4IvsaelakDLQs9PYbYVUEYY6nnYTbX/whsFci9TBd+ZyuS 9fcJVM4MQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJze-0003mh-Sg; Mon, 06 Jul 2020 05:48:42 +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 1jsJzH-0003cS-Bq for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014498; 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=RSldUwhsXSG1zWLE1Lkjlm1JGuT3pjJw5tI/XQjx1lk=; b=KrdmFZd4g+aAa7HmpLiUpX0Tq9HtCzt7x7DA/Dz5ACwzVFVL3DgaMzhDWrdS09CW+PrWWk thpHVtP+EI3atkYVn+a+lD5JBS6+M/HUIunGjWv9LJTEP7HCNXUCPaprtJMTb09gAArWoy JaLmV3hGo5TiSxusmkGH4XhTQX3ulYI= 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-415-oma8l1EzOZmHvQPTjvobFA-1; Mon, 06 Jul 2020 01:48:15 -0400 X-MC-Unique: oma8l1EzOZmHvQPTjvobFA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7625107B76A; Mon, 6 Jul 2020 05:48:13 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BDAFC0DBA; Mon, 6 Jul 2020 05:48:10 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/14] drivers/firmware/sdei: Introduce sdei_do_local_call() Date: Mon, 6 Jul 2020 15:47:27 +1000 Message-Id: <20200706054732.99387-10-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014819_479363_C705933A X-CRM114-Status: GOOD ( 12.86 ) 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.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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For the private events, there are codes to repeat the same steps: initializing cross call argument, make function call on local CPU, check the returned error. This introduces sdei_do_local_call() helper to cover the first two steps. Another benefit is to make CROSSCALL_INIT and sdei_crosscall_args only visible to sddi_do_{cross, local}_call(). Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 3393f1650b20..6a583eb34222 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -102,6 +102,18 @@ static inline int sdei_do_cross_call(void *fn, struct sdei_event * event) return arg.first_error; } +static inline int sdei_do_local_call(void *fn, + struct sdei_event *event) +{ + struct sdei_crosscall_args arg; + void (*func)(void *) = fn; + + CROSSCALL_INIT(arg, event); + func(&arg); + + return arg.first_error; +} + static int sdei_to_linux_errno(unsigned long sdei_err) { switch (sdei_err) { @@ -675,7 +687,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); @@ -683,12 +695,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); @@ -698,7 +709,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); @@ -707,20 +718,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 Mon Jul 6 05:47: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: 11644885 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 4E75313B6 for ; Mon, 6 Jul 2020 05:50:40 +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 27551206E6 for ; Mon, 6 Jul 2020 05:50:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nrff8oW5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DfCeHS8A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27551206E6 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=Bm8rD5joJSPM313beefubOxCKnUZXl3bmVnZhnaMAdM=; b=Nrff8oW5B8lb+UySpOgFW8X4v /suHLHG0n8KYaH6nn+wFgVALtPHLkUufAWF9k6YDqQsRkU8AhfF63TAeu5oKp0FQl7XL+0Tx3wnss rgFO8hlYtmkLGjTVyOY9JLkM65MH9evkXvIPH5g86HMJ0mX7CHU+MDM0PVhe8dmHSLEu4l44D8A+q 5uu2B1asDDReyBOQhOa84lQm7eV028o0Wf5FGMd7UL+FGWMIbFs9FvOQRlM/vb+Wpb1EM/oB/SE1P tHLzXEgy9lckezVmYgoIOPORGL7jnYcA2wleJkCjD3DmrPou2Zumb59wyluklfezAqpYZnUkMH2PO q7sa7LNAQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzj-0003p5-NN; Mon, 06 Jul 2020 05:48:47 +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 1jsJzI-0003dA-8c for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014499; 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=YJz7EyeIgSO0wHxqdDIcPqq+/n9OgKTMNVZHVoUC59E=; b=DfCeHS8AB6NItr7JCxynpQlsF3nWhBcr2UMj4s21rpVTWvWZ+pHK5tr3Hku2MTgC+LzSTf nl1v6kuds5KXBn5Wdut+RE/h/ayg4TPrigQV8wN3nJzpGUQeu/M+qRFZS0tb59yfhq+Nda DnAEEpCtCRADpZYNLrNxhQx2DTWlMyU= 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-455-UbGo9BKSO4q4T28Zh4PB-Q-1; Mon, 06 Jul 2020 01:48:17 -0400 X-MC-Unique: UbGo9BKSO4q4T28Zh4PB-Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CD62107ACF2; Mon, 6 Jul 2020 05:48:16 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C17C0DBA; Mon, 6 Jul 2020 05:48:14 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 10/14] drivers/firmware/sdei: Remove _sdei_event_register() Date: Mon, 6 Jul 2020 15:47:28 +1000 Message-Id: <20200706054732.99387-11-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014820_386931_D153AFBD X-CRM114-Status: GOOD ( 14.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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com 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. The different set of reregistration and reenablement cpu mask will be updted once it's going to be supported. Also, the shared events are only taken cared by sdei_device_thaw(), but _sdei_event_register() covers both privte and shared events. So the logic about the private events in _sdei_event_register() is useless to sdei_device_thaw(). sdei_event_register sdei_device_thaw _sdei_event_register sdei_reregister_shared sdei_reregister_event_llocked _sdei_event_register This removes _sdei_event_register(). After it's removed, another function (sdei_reregister_event_llocked()) is also removed as its only caller is sdei_reregister_shared(). This shouldn't cause any logicial changes. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 81 ++++++++++++++----------------------- 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 6a583eb34222..2530b8565267 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -573,25 +573,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; @@ -615,7 +596,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, @@ -634,50 +625,40 @@ 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; struct sdei_event *event; + int err = 0; mutex_lock(&sdei_events_lock); spin_lock(&sdei_list_lock); + list_for_each_entry(event, &sdei_list, list) { if (event->type != SDEI_EVENT_TYPE_SHARED) 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); mutex_unlock(&sdei_events_lock); From patchwork Mon Jul 6 05:47: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: 11644883 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 87FA960D for ; Mon, 6 Jul 2020 05:50:39 +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 5F617206E6 for ; Mon, 6 Jul 2020 05:50:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VnkvXO/v"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QRNiIU4J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F617206E6 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=q5LmMiSrutPdglsLDB6xjWd1im+BNCkget/7I76QgVY=; b=VnkvXO/vjbm77L36kkO7yfTLZ dOBUVW7/WhTc6PYf8gRJKmiaLfdW2pXU6W4TazVpnggylTuPwqVt9qgJI3ScKlmeg/UthdIH3u6G/ HBG2tUOimiT765+3ZynUUZUMUmxCwdG9ByWAiAY2OV+DWbmiKcgDIQYbwhIn2YsLYnjgp8SIrImtq XRDUj8A/GFgyw2X56vikPwEZVWwxDbdnGIry0km3av+3c7zKrxHCcj9njfZTMMZEi/UPL9MpvUpKJ tvD5fTtZlOI7kAOadDoAOjo500G/v5dwthqB6Nacuhik84RYlSkTek3d4qd6VKQECfsK2Wqj0aOdl lVARfBaaQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzo-0003rO-Rj; Mon, 06 Jul 2020 05:48:52 +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 1jsJzN-0003ew-KJ for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014504; 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=cUmh8+/B9Gprg9lKfwzx7MaVPEghiYJENBqFDBxp3YU=; b=QRNiIU4JtJWJ1Fs81htMrXW4FTDudxcm4pN2c3RzD2Z+cTs1RphqscUQTEgu5Z4HF+PK43 d2pW1AbZfmnzS8fRaaZgobBDpEOKh1I4duIDu7zSwwM0q+L9KmTXa6Q/M3m5Xuq7BblhdY bnDW3LedbfwgDx+Nd0JesXitxdQ3tE0= 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-356-WCbj5_EVMJKFFKxmU2tAmg-1; Mon, 06 Jul 2020 01:48:20 -0400 X-MC-Unique: WCbj5_EVMJKFFKxmU2tAmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0423B19067E6; Mon, 6 Jul 2020 05:48:19 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CDC9C0DBA; Mon, 6 Jul 2020 05:48:16 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 11/14] drivers/firmware/sdei: Remove _sdei_event_unregister() Date: Mon, 6 Jul 2020 15:47:29 +1000 Message-Id: <20200706054732.99387-12-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014826_391598_BD7685A7 X-CRM114-Status: GOOD ( 11.04 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The function is called like the following function call chain shows. The shared events are unregistered only by sdei_device_freeze(). So the logic to unregister the private events in _sdei_event_unregister() is useless to sdei_device_freeze(). sdei_event_unregister sdei_device_freeze _sdei_event_unregister sdei_unregister_shared _sdei_event_unregister This removes _sdei_event_unregister(), which is similar to what we did for _sdei_event_register(). It shouldn't cause logicial changes. Signed-off-by: Gavin Shan --- 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 2530b8565267..8f53bef88379 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -483,16 +483,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; @@ -513,7 +503,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 out; @@ -539,7 +533,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 Mon Jul 6 05:47: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: 11644889 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 D3D4860D for ; Mon, 6 Jul 2020 05: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 9F8AD2074F for ; Mon, 6 Jul 2020 05: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="AXtGHwU/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aGmeDeOQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F8AD2074F 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=SmLH9tYU6KgBOud7kfAzkzfVd7MLsMeEjFRDoO2NlK0=; b=AXtGHwU/x60mhPJD7OFNEbrKL AhU/9etsqDSHVot/krse2K6X1XR2V32fDkYefd76SBcyNMnkIDcY60Vq6j0Z45JMKu6tyN6UC5QVs IAhydtJwm/YI6avSWxVqKAY7pcp2RIAXMoEgozR1Np9vcK/qUL6mkwGNIyPddLCsMm8rox0uvb3G6 11qznUbGAq2w1vTE5HuDJHqwy3P0tpvqR4aGzHkslKXcQr2CYsUJBquFj6UlI5Ndva24VOfIKEpOH AO4KwY+0NE7GszBQLEk/x0iqelhmhDODxm09vxQ6RUex+FGTp74CNuIBS7yOWy1HcXOUCGsQIgb4i uOZYmzPQg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsK02-0003z7-TH; Mon, 06 Jul 2020 05:49:06 +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 1jsJzO-0003fI-Cf for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014505; 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=bQduMedDUMkgcn7HYQv7Wm36k5Mvj7BS+DErp3vKYbI=; b=aGmeDeOQvZ75iGnm+whNq3B5IyK9P9XuueUHTDPG2cZAo10Ck45oD56FnMDgKvK91WQdgc 25N0hpX90wyOtUuUcPVThnx3AxRbZg/8D3/OOccxD2Vp5QcKD+6AcySiuJ5gRFGW2oB7la z3ZmeDPsX8utSPtbNj+A4+63Wiphje0= 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-349-55R1ug2cOhGySx-qe-DrZg-1; Mon, 06 Jul 2020 01:48:23 -0400 X-MC-Unique: 55R1ug2cOhGySx-qe-DrZg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1716119067E0; Mon, 6 Jul 2020 05:48:22 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CD4FC0DBA; Mon, 6 Jul 2020 05:48:19 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/14] drivers/firmware/sdei: Identify event by struct sdei_event Date: Mon, 6 Jul 2020 15:47:30 +1000 Message-Id: <20200706054732.99387-13-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014826_613408_6DFAEA6A X-CRM114-Status: GOOD ( 23.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_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [207.211.31.81 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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com 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 according 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 --- drivers/firmware/arm_sdei.c | 145 +++++++++++++++++------------------- include/linux/arm_sdei.h | 71 ++++++++++-------- 2 files changed, 108 insertions(+), 108 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 8f53bef88379..8e5f6683c155 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -44,26 +44,6 @@ 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 { - /* 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 */ - struct sdei_registered_event *registered; - - /* CPU private events */ - struct sdei_registered_event __percpu *private_registered; - }; -}; - /* Take the mutex for any API call or modification. Take the mutex first. */ static DEFINE_MUTEX(sdei_events_lock); @@ -393,30 +373,26 @@ 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_event *event; mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { - mutex_unlock(&sdei_events_lock); - return -ENOENT; - } - - cpus_read_lock(); + 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) { - spin_lock(&sdei_list_lock); - event->reenable = true; - spin_unlock(&sdei_list_lock); - } + if (err) + goto cpu_unlock; + + spin_lock(&sdei_list_lock); + event->reenable = true; + spin_unlock(&sdei_list_lock); + +cpu_unlock: cpus_read_unlock(); mutex_unlock(&sdei_events_lock); @@ -439,28 +415,26 @@ 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_event *event; mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { - mutex_unlock(&sdei_events_lock); - return -ENOENT; - } - - spin_lock(&sdei_list_lock); - event->reenable = false; - spin_unlock(&sdei_list_lock); 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); - mutex_unlock(&sdei_events_lock); + if (err) + goto out; + + spin_lock(&sdei_list_lock); + event->reenable = false; + spin_unlock(&sdei_list_lock); + +out: + mutex_unlock(&sdei_events_lock); return err; } @@ -483,25 +457,13 @@ 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_event *event; WARN_ON(in_nmi()); mutex_lock(&sdei_events_lock); - event = sdei_event_find(event_num); - if (!event) { - pr_warn("Event %u not registered\n", event_num); - err = -ENOENT; - goto out; - } - - spin_lock(&sdei_list_lock); - event->reregister = false; - event->reenable = false; - spin_unlock(&sdei_list_lock); if (event->type == SDEI_EVENT_TYPE_SHARED) err = sdei_api_event_unregister(event->event_num); @@ -511,6 +473,11 @@ int sdei_event_unregister(u32 event_num) if (err) goto out; + spin_lock(&sdei_list_lock); + event->reregister = false; + event->reenable = false; + spin_unlock(&sdei_list_lock); + sdei_event_destroy(event); out: @@ -567,17 +534,18 @@ 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) { + struct sdei_event *event = NULL; int err; - struct sdei_event *event; WARN_ON(in_nmi()); 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 out; } @@ -603,6 +571,7 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) if (err) { sdei_event_destroy(event); + event = ERR_PTR(err); pr_warn("Failed to register event %u: %d\n", event_num, err); goto cpu_unlock; @@ -616,7 +585,7 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg) cpus_read_unlock(); out: mutex_unlock(&sdei_events_lock); - return err; + return event; } static int sdei_reregister_shared(void) @@ -857,13 +826,16 @@ NOKPROBE_SYMBOL(sdei_smccc_hvc); int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, sdei_event_callback *critical_cb) { - int err; + struct sdei_event *event; u64 result; u32 event_num; sdei_event_callback *cb; + int err; - if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) - return -EOPNOTSUPP; + if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) { + err = -EOPNOTSUPP; + goto out; + } event_num = ghes->generic->notify.vector; if (event_num == 0) { @@ -871,53 +843,70 @@ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, * Event 0 is reserved by the specification for * SDEI_EVENT_SIGNAL. */ - return -EINVAL; + err = -EINVAL; + goto out; } err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY, &result); if (err) - return err; + goto out; if (result == SDEI_EVENT_PRIORITY_CRITICAL) cb = critical_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); + goto out; + } + err = sdei_event_enable(event); + +out: return err; } int sdei_unregister_ghes(struct ghes *ghes) { - int i; - int err; + struct sdei_event *event; u32 event_num = ghes->generic->notify.vector; + int err, i; might_sleep(); - if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) - return -EOPNOTSUPP; + if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) { + err = -EOPNOTSUPP; + goto out; + } + + mutex_lock(&sdei_events_lock); + event = sdei_event_find(event_num); + mutex_unlock(&sdei_events_lock); + if (!event) { + err = -ENOENT; + goto out; + } /* * 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); + err = sdei_event_disable(event); if (err) - return err; + goto out; for (i = 0; i < 3; i++) { - err = sdei_event_unregister(event_num); + err = sdei_event_unregister(event); if (err != -EINPROGRESS) break; schedule(); } +out: return err; } diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index 0a241c5c911d..fb6aa455e51d 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -22,36 +22,6 @@ */ typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg); -/* - * 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); - -/* - * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling - * it until it succeeds. - */ -int sdei_event_unregister(u32 event_num); - -int sdei_event_enable(u32 event_num); -int sdei_event_disable(u32 event_num); - -/* GHES register/unregister helpers */ -int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, - sdei_event_callback *critical_cb); -int sdei_unregister_ghes(struct ghes *ghes); - -#ifdef CONFIG_ARM_SDE_INTERFACE -/* For use by arch code when CPU hotplug notifiers are not appropriate. */ -int sdei_mask_local_cpu(void); -int sdei_unmask_local_cpu(void); -#else -static inline int sdei_mask_local_cpu(void) { return 0; } -static inline int sdei_unmask_local_cpu(void) { return 0; } -#endif /* CONFIG_ARM_SDE_INTERFACE */ - - /* * This struct represents an event that has been registered. The driver * maintains a list of all events, and which ones are registered. (Private @@ -72,6 +42,47 @@ struct sdei_registered_event { u8 priority; }; +struct sdei_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 */ + struct sdei_registered_event *registered; + + /* CPU private events */ + struct sdei_registered_event __percpu *private_registered; + }; +}; + +/* APIs */ +struct sdei_event *sdei_event_register(u32 event_num, + sdei_event_callback *cb, void *arg); +int sdei_event_unregister(struct sdei_event *event); +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, + sdei_event_callback *critical_cb); +int sdei_unregister_ghes(struct ghes *ghes); + +#ifdef CONFIG_ARM_SDE_INTERFACE +/* For use by arch code when CPU hotplug notifiers are not appropriate. */ +int sdei_mask_local_cpu(void); +int sdei_unmask_local_cpu(void); +#else +static inline int sdei_mask_local_cpu(void) { return 0; } +static inline int sdei_unmask_local_cpu(void) { return 0; } +#endif /* CONFIG_ARM_SDE_INTERFACE */ + /* The arch code entry point should then call this when an event arrives. */ int notrace sdei_event_handler(struct pt_regs *regs, struct sdei_registered_event *arg); From patchwork Mon Jul 6 05:47:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11644873 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 C707A60D for ; Mon, 6 Jul 2020 05:50: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 A0497206E6 for ; Mon, 6 Jul 2020 05:50: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="iHVkumsn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P+ku6UE9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0497206E6 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=w5EN2VdPrhXKRaomtL8IXSC6bP6CwcEsZ58LRiOCULc=; b=iHVkumsnvidtTnjZYnb48Ikcz XVCssaunQ1RlRCLR8r7SSyypEPmdxVfgGJMi1FNStrjK9jNtFJSj8r885XgzMTg+CSbzQuHRD0Bke pg+/AYZJBaIqTPpgtKEcr9aBQXKDHYz7uuNka7bRgo/E5kWwBvuAmrwWBpC8yyNO7PP0I9l/jH8G1 2mMQsTsI+8710lirMtPIeRUfrz5ba5oWPR6vuYqAEpUV7+xL7Gpq/ohkM0C9SOerxU242L4ZSxpu7 tt8vHq5a4snXzQoN6AImT1t6++nm99viJ7g2yNplsSYZPnj6b7YweIKxbpYvZmijsyHGNuBc42lFw BfP1xyMhA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsJzt-0003u1-65; Mon, 06 Jul 2020 05:48:57 +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 1jsJzQ-0003gO-UH for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014507; 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=wAkazxVlNCWpJC/H4idkKUdo5LNw9pTD6GOmjUm75yg=; b=P+ku6UE9OQ0/2rNhrHQ5SghoGqghvg0Jcn5AcYvzRH33gRj8xMGOMjlI1qUpiHs9Mmj8qM 4X9bJUKnK3D87LMPOwQ7zxeQxYLq1WltOkK1YJZ2P3ov5u3mOXe/h+cKRfnqxQa8JDZoiZ 4eifu+ymcv8k8EajLRqpyEgQP6FVm0k= 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-234-bJzCN_EbNw6fOdJMvYTZ0w-1; Mon, 06 Jul 2020 01:48:25 -0400 X-MC-Unique: bJzCN_EbNw6fOdJMvYTZ0w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E7671005510; Mon, 6 Jul 2020 05:48:24 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9033BC0DBA; Mon, 6 Jul 2020 05:48:22 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/14] drivers/firmware/sdei: Retrieve event signaled property on creation Date: Mon, 6 Jul 2020 15:47:31 +1000 Message-Id: <20200706054732.99387-14-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014829_113402_470BF45F X-CRM114-Status: GOOD ( 12.12 ) 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) [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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 6 ++++++ include/linux/arm_sdei.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 8e5f6683c155..c6bd43914ea0 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -205,6 +205,12 @@ static struct sdei_event *sdei_event_create(u32 event_num, goto fail; event->type = result; + err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED, + &result); + if (err) + goto fail; + event->signaled = result; + if (event->type == SDEI_EVENT_TYPE_SHARED) { event->registered = kzalloc(sizeof(*reg), GFP_KERNEL); if (!event->registered) { diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index fb6aa455e51d..36003751e26e 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -51,6 +51,7 @@ struct sdei_event { u32 event_num; u8 type; u8 priority; + u8 signaled; /* This pointer is handed to firmware as the event argument. */ union { From patchwork Mon Jul 6 05:47:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11644887 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 8EAD360D for ; Mon, 6 Jul 2020 05:50:52 +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 65CAF2074F for ; Mon, 6 Jul 2020 05:50:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Gjir6Wzl"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bytDcbAs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65CAF2074F 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=4UHuoSHkqkxc0amc1/R/2kBgiVwLROiyIhVk5ZZ7pis=; b=Gjir6WzlhEy+wQDROBCTLFzby UVRByczg6hjttp3fRYQ7P3c4pViqUmYiyGke72l0KrD5tCfVRO8FT6wqjQfg+kNvVx7wATxqIuxPl V3R6Hll8Fcd69jAD/K0maZkAk8yx/epUNeLYchEKtE5nBfbNOM5rdcM8tnKT/MPDY+6WYG1UEw7VF A2qsL6OljDlGIYucRtpfxFPB8AYrzN4Hi+jJhUarKwaJbBYPkFiC0x5mDpK55agl0ERjc+lMy4ofn twrDZvdnhrWdHsFxPR7ntKIkOw1wT3XTErzhVVRum50g7PRM191DpIZTEnPjCeabtmRVaYK9HaW0e uE3bCrMqg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsK08-00042q-5l; Mon, 06 Jul 2020 05:49:12 +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 1jsJzT-0003hh-2N for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 05:48:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594014510; 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=MUziWvs6NECJJB0obdG/4d3S41533/3EmOK4mzptH3k=; b=bytDcbAsknyBOGCJFIyonvpEGvpNE0iRBqKv+TF5/9U3sNgGRy2HHK0H6yrC33a27YDhxk NgauGUl5b6lXWy1ITBFNehFpOP5Y3mfzsWOlU0pypbRRFAONX5hfTWwyFqZthg9dolZixi OgA3vxcKME309gul2D4mEz3MbPpxWWU= 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-461-VIgmbk6aOXiHP7_8xTCWUQ-1; Mon, 06 Jul 2020 01:48:28 -0400 X-MC-Unique: VIgmbk6aOXiHP7_8xTCWUQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66963A0BE4; Mon, 6 Jul 2020 05:48:27 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BFFAC0DBA; Mon, 6 Jul 2020 05:48:24 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 14/14] drivers/firmware/sdei: Add sdei_event_get_info() Date: Mon, 6 Jul 2020 15:47:32 +1000 Message-Id: <20200706054732.99387-15-gshan@redhat.com> In-Reply-To: <20200706054732.99387-1-gshan@redhat.com> References: <20200706054732.99387-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-20200706_014831_205895_17F4A923 X-CRM114-Status: GOOD ( 11.17 ) 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.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 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, will@kernel.org, james.morse@arm.com, shan.gavin@gmail.com, catalin.marinas@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This adds API sdei_event_get_info(), to be used when virtualized SDEI is supported to retrieve the information about the specified event. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 13 +++++++++++++ include/linux/arm_sdei.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index c6bd43914ea0..d5aadf99d0c1 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -173,6 +173,19 @@ static int sdei_api_event_get_info(u32 event, u32 info, u64 *result) 0, 0, result); } +int sdei_event_get_info(u32 event, u32 info, u64 *result) +{ + int err; + + mutex_lock(&sdei_events_lock); + + err = sdei_api_event_get_info(event, info, result); + + mutex_unlock(&sdei_events_lock); + + return err; +} + static struct sdei_event *sdei_event_create(u32 event_num, sdei_event_callback *cb, void *cb_arg) diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index 36003751e26e..11dd66273209 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -64,6 +64,7 @@ struct sdei_event { }; /* APIs */ +int sdei_event_get_info(u32 event, u32 info, u64 *result); struct sdei_event *sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg); int sdei_event_unregister(struct sdei_event *event);