Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3225715pxu; Tue, 8 Dec 2020 06:47:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxqJeqEuX2gXA0CTbqw99bu+TxJcdD4bzBDmBxkV4syM2aEnIPBajh4+zSway0VgF393s8 X-Received: by 2002:a17:906:604e:: with SMTP id p14mr24365935ejj.515.1607438836964; Tue, 08 Dec 2020 06:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607438836; cv=none; d=google.com; s=arc-20160816; b=z6nIWO/d5mZgwJnpvVFp8R9vCxV7Y5SyMM/7xkYEL4Ho55bN86fxzb2WNKR5Gtkk4h fc9tUy3gWfZlhLKNp72KamJ9CjIYD8K71Llya9mORe1/nFkJWdisJbtVeB6z32yK/opj IwJdcK4wFl3rQrp+1LS2i4q7oujWYInMdz+H42vsHtOzKc0gkO1w/8OsPimZbcF342/U 9Llw4puv3Lo+UUz+u/EWjWd4KLJ9YN6DXiXYMeF4X4n4tTAXhdmxJokXgZkyc6lOyYqJ ClVdhDBObMEZJ8uLA8fAS2ofEJ8g4U/meGSniFkwXpGnkS1IDqEGYF3YDEoc3SiHDiMG Y78g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Cfa7wLpbxuEZq+R+bI/0NtkJcPb3sJm2JZkzYyHbJ5Q=; b=WbNxH+/2jplWsGfNQck5twef2tJ9t3MFeJRvuqhqg1qkBSvxGC49x4aiwIF2JPAoO/ weiyaPUr3RDtadfhnqphAf9Fpt6RFAlMKU3J+WBA6Z4eBC2oKnM5bcf4Ngpfr/u+lBu+ yE+8fimOr/U9xTlhkGW2tIdmPhKCXZGVI8O5QYoCC6gspWtMkA1sZsysrnDrh7nRBBpI iMvcsYXsDrj/drFlTFrqIFVfSlVTzLbCKGNkQ3Yiml1dDZQ6NvebfvxtLwsjDkcl2NoS 0hOL90D3QL2ZRfRDnO8i5FXcWdijhTS6bkd8r+GqIXtmysYoUN1rj8JR0ckKUsfd2hvN swrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HVah9qDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si8290153eje.628.2020.12.08.06.46.46; Tue, 08 Dec 2020 06:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HVah9qDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729471AbgLHOpE (ORCPT + 99 others); Tue, 8 Dec 2020 09:45:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28124 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbgLHOpD (ORCPT ); Tue, 8 Dec 2020 09:45:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607438616; 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=Cfa7wLpbxuEZq+R+bI/0NtkJcPb3sJm2JZkzYyHbJ5Q=; b=HVah9qDgV+SP6M9VQgyO1bv/7XqZ0qJnL+CF0iSf2QeIBmI2kkFd5FbxMAuaMKjdtl29VW TybudDAYnpRzeQ99knKrm+L0Ttfkh/e/n66vsKBCoh2+vBFl71Q2C2lXu9sZZtdC3m8+6H 49qClm+dOi8cr1mDk2wf1sCfirjdkJE= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-Q0mGymiaN0Cc8fdacmJkNA-1; Tue, 08 Dec 2020 09:43:35 -0500 X-MC-Unique: Q0mGymiaN0Cc8fdacmJkNA-1 Received: by mail-ed1-f70.google.com with SMTP id e11so6672481edn.11 for ; Tue, 08 Dec 2020 06:43:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Cfa7wLpbxuEZq+R+bI/0NtkJcPb3sJm2JZkzYyHbJ5Q=; b=cnNvG66h/YeL6IQ9fahsEF8LMn0WAhRz2GMl26jHYs9B1+HzM45m0M3d57yajL1I2d BzC3iXpcwOT6rnlLnSfRmlFTv1mAFzuO3tCOmWeay2vYO1XhkZGiU9xgRlpXHkHUzl2N hn5qySAPPZxBSUEoQuuZxSMh55ZMESDY2DcHAm9CoAuMtbDvd3sHlLJpa3jHOh48iqqs YZODDXHgh54MFoPKV2C/D7/NkcxI/YlPonD0DdhRK+zgFpfPUxm4UyhIo3o63We7j+Rg w2sygR7QzFJVz7KP5Unqq6G8oFkxZ8JKeqSe7nFXIKDFSYaX9F36HKP2cj6X9QT146BA OajA== X-Gm-Message-State: AOAM531lkWzl1YBXNMf/Cy0h7L0ZbxFFvDI/pUgDhG4ZCp7uOYUyr/Xk cpbqDk6vRyP58ZlB6vgG1BWiz0cJv0URIoP6RR6pzkFP1uxFxyVEBNnvYQVkBkCR6Nb52sc4T9n G7FIIwABlVSHIhL/yqfAuGxI0 X-Received: by 2002:aa7:c355:: with SMTP id j21mr15707869edr.338.1607438613754; Tue, 08 Dec 2020 06:43:33 -0800 (PST) X-Received: by 2002:aa7:c355:: with SMTP id j21mr15707853edr.338.1607438613544; Tue, 08 Dec 2020 06:43:33 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c0c-fe00-d2ea-f29d-118b-24dc.cable.dynamic.v6.ziggo.nl. [2001:1c00:c0c:fe00:d2ea:f29d:118b:24dc]) by smtp.gmail.com with ESMTPSA id d14sm18083317edn.31.2020.12.08.06.43.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Dec 2020 06:43:32 -0800 (PST) Subject: Re: [PATCH v2 1/9] platform/surface: Add Surface Aggregator subsystem To: Maximilian Luz , linux-kernel@vger.kernel.org Cc: Mark Gross , Andy Shevchenko , =?UTF-8?Q?Barnab=c3=a1s_P=c5=91cze?= , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Jiri Slaby , "Rafael J . Wysocki" , Len Brown , =?UTF-8?Q?Bla=c5=be_Hrastnik?= , Dorian Stoll , platform-driver-x86@vger.kernel.org, linux-serial@vger.kernel.org, linux-acpi@vger.kernel.org References: <20201203212640.663931-1-luzmaximilian@gmail.com> <20201203212640.663931-2-luzmaximilian@gmail.com> From: Hans de Goede Message-ID: <9748d778-b5e9-c80c-5968-a77b3203d769@redhat.com> Date: Tue, 8 Dec 2020 15:43:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/8/20 3:37 PM, Maximilian Luz wrote: >>> + >>> +    obj = acpi_evaluate_dsm_typed(handle, &SSAM_SSH_DSM_GUID, >>> +                      SSAM_SSH_DSM_REVISION, func, NULL, >>> +                      ACPI_TYPE_INTEGER); >>> +    if (!obj) >>> +        return -EIO; >>> + >>> +    val = obj->integer.value; >>> +    ACPI_FREE(obj); >>> + >>> +    if (val > U32_MAX) >>> +        return -ERANGE; >>> + >>> +    *ret = val; >>> +    return 0; >>> +} > > [...] > >>> +/** >>> + * ssam_controller_start() - Start the receiver and transmitter threads of the >>> + * controller. >>> + * @ctrl: The controller. >>> + * >>> + * Note: When this function is called, the controller should be properly >>> + * hooked up to the serdev core via &struct serdev_device_ops. Please refer >>> + * to ssam_controller_init() for more details on controller initialization. >>> + * >>> + * This function must be called from an exclusive context with regards to the >>> + * state, if necessary, by locking the controller via ssam_controller_lock(). >> >> Again you are being a bit hand-wavy (I assume you know what I mean by that) >> wrt the locking requirements. If possible I would prefer clearly spelled out >> locking requirements in the form of "this and that lock must be held when >> calling this function". Preferably backed-up by lockdep_assert-s asserting >> these conditions. > > The reason for this is that this function specifically is currently only > called during initialization, when the controller has not been published > yet, i.e. when we have an exclusive reference to the controller. > > I'll change this to fully enforce locking (with lockdep_assert). > >> And maybe if you are a bit stricter with always holding the lock when >> calling this, you can also drop the WRITE_ONCE and the comment about it >> (in all places where you do this). > > The WRITE_ONCE is only there to ensure that the basic test in > ssam_request_sync_submit() can be done. I always try to be explicit > about access that can happen without the respective locks being held. Yes I saw the matching READ_ONCE later on (as the comment indicated I would), which made it more obvious to me why the WRITE_ONCE is here,' so maybe I should have gone back and updated this comment. Anyways, keeping the WRITE_ONCE + READ_ONCE for this is fine. > Unfortunately it's not feasible to hold the reader lock in > ssam_request_sync_submit() due to reentrancy. Specifically, as the lock, > if at all (i.e. if this is not a client driver bound to the controller), > must be held not only during submission but until the request has been > completed. Note that if we would hold the lock during submission, this > is just a smoke-test. Ack. Regards, Hans