Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1554799ybz; Thu, 30 Apr 2020 01:12:49 -0700 (PDT) X-Google-Smtp-Source: APiQypL4q4d0G9JgshIxEpIIea8gKEchAEZ5ngZsMVtFixdQ6ZbNEnHFCHP+kvpHWBjrnVdA55L9 X-Received: by 2002:a05:6402:14ce:: with SMTP id f14mr1527755edx.244.1588234369677; Thu, 30 Apr 2020 01:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588234369; cv=none; d=google.com; s=arc-20160816; b=rg+CuaNNf353Z+3zRBsPPxqsPBo1mmiyB6/PH9miRlwaZPQTzeHC/eTmLICQsRHpRr I/9MoaS8RLbmJyBhDgmPneBQBEP1eq4hVmnz+Hytzg8bf9pex1lnSPBVzgn5Zj8mFNxp ilCPGVCCBmGZ87n9XwIn4oIXsbX7178p9IW6dCBAp3q4CsIYkUx7sct6UuddP4vDDSqP VoJEONUvhxtxuRJQw/iyTxPR1d4DYsk6X/t007mzxe1UM0rRgZpQ9x5cTmyh1L0Wpku/ 9CqL/Wk5X5cB1ZGaZZFnd7ct51HGCDuYNa27zfqF4kAoW6QgCExjxzGDrRpMgB5j6J7D x6Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=bZI3iAMkvNUCYYeARzf9CZekcyseghOrMO8UQUtAMIs=; b=lRqFA4DPAHhUANNE8ZCfH5YtWM9LUR2SxIT+dRM1Q/wviqdb9Ve2lftRhD23E1/3EY UFDnb35qc8v3Bl8/XQvtVEI4xw89ajFb3/uvuKJP0Vl/H09bIzoK7CXmUjT+RtBLVxo4 H1glZqub/2d/PyAU+CFtr+5XfumYqm715LvOiBeyNKjgqkTKIWIB1uIgeKD7YivuEgWO rvhitjUKvN+vBV1do/I+rORnbFVt7tJlaBvaCwwDRVlXU3D34R8S65/9Wc3wV9MYmo2S RarloaC7GwYLsLaotVAyQB0zBlm3gLNz51H1np01pp5NyaC1YEvv2rGLNlS1NlQO2TNd X7rg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si4780343edi.111.2020.04.30.01.12.26; Thu, 30 Apr 2020 01:12:49 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgD3IHl (ORCPT + 99 others); Thu, 30 Apr 2020 04:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbgD3IHj (ORCPT ); Thu, 30 Apr 2020 04:07:39 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A6EC035494 for ; Thu, 30 Apr 2020 01:07:38 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id AD6532A0221; Thu, 30 Apr 2020 09:07:35 +0100 (BST) Date: Thu, 30 Apr 2020 10:07:33 +0200 From: Boris Brezillon To: Parshuram Thombare Cc: , , , , , , Subject: Re: [PATCH v6 3/8] i3c: master: i3c mastership request and handover Message-ID: <20200430100733.4e0dc578@collabora.com> In-Reply-To: <1587140462-30209-1-git-send-email-pthombar@cadence.com> References: <1587140398-29473-1-git-send-email-pthombar@cadence.com> <1587140462-30209-1-git-send-email-pthombar@cadence.com> Organization: Collabora X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 17 Apr 2020 18:21:02 +0200 Parshuram Thombare wrote: > + > +/* This function is expected to be called with normaluse_lock */ > +int i3c_master_acquire_bus(struct i3c_master_controller *master) > +{ > + int ret = 0; > + > + if (!master->this || master->this != master->bus.cur_master) { Let's limit the number of indentations by doing if (master->this == master->bus.cur_master) return 0; > + if (master->mr_state == I3C_MR_IDLE) { > + master->mr_state = I3C_MR_WAIT_DA; > + init_completion(&master->mr_comp); > + queue_work(master->wq, &master->sec_mst_work); > + /* > + * Bus acquire procedure may need write lock > + * so release read lock before yielding > + * to bus acquire state machine > + */ > + i3c_bus_normaluse_unlock(&master->bus); > + wait_for_completion(&master->mr_comp); > + i3c_bus_normaluse_lock(&master->bus); Is that really enough? I remember we had something a bit more complex to handle the case where bus is acquired to send a message to a device, and another master on the bus re-acquires it before we have a chance to send this message message. i3c_master_acquire_bus_ownership() was dealing with that in Przemek series. It seems you've rewritten a lot of these things. Would you mind explaining why, and how that works? > + if (master->mr_state != I3C_MR_DONE) > + ret = -EAGAIN; > + master->mr_state = I3C_MR_IDLE; > + } else { > + /* > + * MR request is already in process for > + * this master > + */ > + ret = -EAGAIN; > + } > + } > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(i3c_master_acquire_bus);