Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6448DC433DF for ; Tue, 28 Jul 2020 02:54:49 +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 26F9D2078E for ; Tue, 28 Jul 2020 02:54:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Cd4bL0fZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eNfbKLxK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26F9D2078E 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+linux-arm-kernel=archiver.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-Type: Content-Transfer-Encoding:Cc:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MmCUr/45RNMrEfNyUzRTyHMJv9o6azDKAOo1CR/PnT0=; b=Cd4bL0fZF9G/Ow dP5a1sR/41rGRhX1ylzQny128PbIRF4kJHD/afJdu5OQXiEywQ7SklGDw7030BlL+B+Utp/EDJDJw /CjB+ORzFxrO4Qv4BINEXFHwgHIQIfAVTcanphYarHDSvUZXjKyE3uhSJsFn0L6Fgxuv+z892snOc yj74Z8E5iIl79J0jIsPL/xrszyofXeblr/1GnD6VpiiUWxNqxOd14oDj6ij+FobJvTh9sQTsv5V8Q 9ljqyI4TF1ytAST8HKpVzHI5GNF7HI5tSeyuwTwVlQVaUCbaxd3GblGvP9k5Q7s/G3bnjl6+rWdCc CJIaVdCM1onvB9projTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0Fjp-0003XG-8W; Tue, 28 Jul 2020 02:53: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 1k0Fjm-0003Wt-I9 for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2020 02:53:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595904783; h=from:from:reply-to: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=yvuYtD0h6BGj+2+aSxFuacXbohVt+5jgmgXAGznRQKM=; b=eNfbKLxKrC0ymbX/JtmG/FctkSg8i8rZCRKkDICNvEmij7SzNPrKzVsg0kI4qldYu2ASp0 ZA8OVYFaHAbIpPAyIUvX+o8/mV3PKh8CirjMlkgeTgDg4xwmYuh0HCcO/FVvqOxaPaddXZ lWej2sGTyYXZG4C3WSXEXB4RMabCUqk= 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-82-xjTWYeBbMaSPKvYGwocNKg-1; Mon, 27 Jul 2020 22:53:01 -0400 X-MC-Unique: xjTWYeBbMaSPKvYGwocNKg-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 0399D8014D7; Tue, 28 Jul 2020 02:53:00 +0000 (UTC) Received: from [10.64.54.117] (vpn2-54-117.bne.redhat.com [10.64.54.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E3775F1EA; Tue, 28 Jul 2020 02:52:57 +0000 (UTC) Subject: Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file To: Jonathan Cameron References: <20200722095740.28560-1-gshan@redhat.com> <20200722095740.28560-15-gshan@redhat.com> <20200723161949.00000061@Huawei.com> <4b37f5ba-541e-3269-681f-1ae94b975606@redhat.com> <20200727100232.00000819@Huawei.com> <64923e7c-7fb6-2b21-e578-58aad4e7f3c1@redhat.com> <20200727145004.00003321@huawei.com> From: Gavin Shan Message-ID: Date: Tue, 28 Jul 2020 12:52:52 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200727145004.00003321@huawei.com> Content-Language: en-US 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-20200727_225306_636508_77BEF4B7 X-CRM114-Status: GOOD ( 26.90 ) 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: , Reply-To: Gavin Shan Cc: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, shan.gavin@gmail.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jonathan, On 7/27/20 11:50 PM, Jonathan Cameron wrote: > On Mon, 27 Jul 2020 19:59:24 +1000 > Gavin Shan wrote: >> On 7/27/20 7:02 PM, Jonathan Cameron wrote: >>> On Mon, 27 Jul 2020 10:46:52 +1000 >>> Gavin Shan wrote: >>>> On 7/24/20 1:19 AM, Jonathan Cameron wrote: >>>>> On Wed, 22 Jul 2020 19:57:37 +1000 >>>>> Gavin Shan wrote: [...] >>>>>> >>>>>> diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h >>>>>> index 0a241c5c911d..fdc2f868d84b 100644 >>>>>> --- a/include/linux/arm_sdei.h >>>>>> +++ b/include/linux/arm_sdei.h >>>>>> @@ -22,6 +22,46 @@ >>>>>> */ >>>>>> typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg); >>>>>> >>>>>> +/* >>>>>> + * This struct represents an event that has been registered. The driver >>>>>> + * maintains a list of all events, and which ones are registered. (Private >>>>>> + * events have one entry in the list, but are registered on each CPU). >>>>>> + * A pointer to this struct is passed to firmware, and back to the event >>>>>> + * handler. The event handler can then use this to invoke the registered >>>>>> + * callback, without having to walk the list. >>>>>> + * >>>>>> + * For CPU private events, this structure is per-cpu. >>>>>> + */ >>>>>> +struct sdei_registered_event { >>>>>> + /* For use by arch code: */ >>>>>> + struct pt_regs interrupted_regs; >>>>>> + >>>>>> + sdei_event_callback *callback; >>>>>> + void *callback_arg; >>>>>> + u32 event_num; >>>>>> + u8 priority; >>>>>> +}; >>>>>> + >>>>>> +struct sdei_event { >>>>>> + /* These three are protected by the sdei_list_lock */ >>>>> >>>>> As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid? >>>>> >>>> >>>> Yes, the comment is still valid. @sdei_list_lock is used to protect >>>> the linked list (@sdei_list) and all elements (@event) in the list. >>>> For example, the lock is taken before updating @event->reenabled in >>>> function sdei_event_enable(). >>> OK. I assume your new KVM code will simply not touch the list. >>> That's a bit messy from a 'scope' point of view, but I guess it's not >>> worth doing something like: >>> >>> struct sdei_event_opaque { >>> struct list_head list; >>> // Whatever else the kvm code doesn't need >>> struct sdei_event { >>> // The bits that you want to expose more widely (i.e. use in the >>> // kvm code. + you ensure that code only ever sees this internal structure. >>> >>> }; >>> >>> } >> >> Yes, your assumption is correct. The list is still managed by >> drivers/firmware/arm_sdei.c and it's invisible to the new KVM >> code for SDEI virtualization. >> >> It's worthy to hide those fields in "struct sdei_event" from >> external by introducing another struct, from the point of "scope". >> But it's not free to maintain another struct in this case. I would >> say lets avoid introducing another struct if you agree. > > I'm fine either way. > Thanks again for your feedback. I think about it again and it's really nice idea to narrow the scopes of the fields in the struct. I will split original struct sdei_event into struct sdei_event and struct sdei_internal_event in v3, which will be posted shortly. As the naems indicate, struct sdei_event can be dereferenced by external modules like arm64/kvm in the future, while struct sdei_internal_event is used by the SDEI client driver only :) > >> >>>> >>>>>> + 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; >>>>>> + }; >>>>>> +}; >>>>>> + [...] Thanks, Gavin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel