Received: by 2002:a17:906:80c3:b0:7ae:d8f:8937 with SMTP id a3csp1074315ejx; Thu, 17 Nov 2022 00:02:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5weajrrjzspUHjLGd24tmSX+1XDSMpsAGZbEYcrtjnvGtd7qFkBBUunv2B5pyOl2K4WTAI X-Received: by 2002:a37:2f44:0:b0:6fa:fc92:13fd with SMTP id v65-20020a372f44000000b006fafc9213fdmr772922qkh.183.1668672159900; Thu, 17 Nov 2022 00:02:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668672159; cv=none; d=google.com; s=arc-20160816; b=H/+zEdbOCmYMP9DoFEcEnhkfo5Ky2hnVF90zUrjMtmLXpcu4u8NsQcRVV/ER6KAvfF mgX6cGFA1T2wC1BtshobY7pGY3nPZh13bg6ABXKQbJW2aVKMR2vEMvp1Gxzb1vl1NBrh koEnb3WVpTp8W40cr0v1I3b/Df66TcJHd3jnE0o0m7j7WraIoyepdrx1G49CZZhLHPjC pQT5Qa0wgL1KSuW0BAqTnb4bDUZ+0UXPptfezdv123DsCI7meCNLO++omj1rAmdLV0sj sx5gqbGbsQ4uFpzCZL1kjCljYaxiyw0LxY6N300/ytbR/EXCbeJZlBRrzRr0Ob7vhNeG UKfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=p74ydWvqaI2GcoLFKPJ4nDsK3QEKegTDwGcUh22tsfw=; b=JSlf0H9IjE+XB4uosShBHoI6OW9WBALTpwGKQqyXkjq5ldlPX60VuTF46XOv7Q8tNY Vjz/zE1mkH0wRnRf1ils+djy21fYwOfSQsZbeZCFlkdCiH5RlkfLXHx5qv5BUcZx31+3 3wA2/ZJoksIJ7xYBQ8C53Kbb9WT7lAl18i2rMTgusoaZo+0vdzGaHOMzkqs5gdQSEFOm TDEoK+NcK7hCRcLLEV5TpXOy1baOSJ5VD9lFife+vweU6q3/G/doiBjuD0ANjPmqQ22i 1kBzi4DWhQadCHzDzr2kTGWjqeWIisa4PjdAbPXRLL281mC1qFQRkS6KrzodL8m+9OIz HViQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h125-20020a37b783000000b006fa4e67cd78si16598qkf.460.2022.11.17.00.02.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Nov 2022 00:02:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovZqN-0002Eq-3d; Thu, 17 Nov 2022 03:01:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovZq6-0002Cg-Vu; Thu, 17 Nov 2022 03:01:51 -0500 Received: from smtpout3.mo529.mail-out.ovh.net ([46.105.54.81]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovZq2-0004Td-RS; Thu, 17 Nov 2022 03:01:38 -0500 Received: from mxplan5.mail.ovh.net (unknown [10.109.156.124]) by mo529.mail-out.ovh.net (Postfix) with ESMTPS id 3054113FCF361; Thu, 17 Nov 2022 09:01:24 +0100 (CET) Received: from kaod.org (37.59.142.100) by DAG4EX2.mxp5.local (172.16.2.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 17 Nov 2022 09:01:23 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-100R003c4f11eac-bf75-47b9-9550-d15f78110560, AE5717285A2AC47C671D2CB192D1CF6730B7D7F3) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <465b2d2e-5958-d63f-02dc-cf96dd1d459e@kaod.org> Date: Thu, 17 Nov 2022 09:01:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH maybe-7.2 1/3] hw/i2c: only schedule pending master when bus is idle Content-Language: en-US To: Klaus Jensen CC: , Andrew Jeffery , Keith Busch , Corey Minyard , Peter Delevoryas , , Peter Maydell , , Jeremy Kerr , Joel Stanley , Klaus Jensen References: <20221116084312.35808-1-its@irrelevant.dk> <20221116084312.35808-2-its@irrelevant.dk> <8dd9ed34-93c3-0638-e152-f619f9e097e6@kaod.org> <6bfe7b2e-2e4f-c286-530a-b0342f9107a0@kaod.org> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.100] X-ClientProxiedBy: DAG1EX2.mxp5.local (172.16.2.2) To DAG4EX2.mxp5.local (172.16.2.32) X-Ovh-Tracer-GUID: 9fddcbc4-5a6f-4d65-a87c-270eabb9c85b X-Ovh-Tracer-Id: 16884839431422446584 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrgeejgdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeffudefleeiudejfeffhfejffeigffhhffhvdekieejheelvdeufffhjedtheeggeenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddruddttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegtlhhgsehkrghougdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepihhtshesihhrrhgvlhgvvhgrnhhtrdgukhdpqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdprghnughrvgifsegrjhdrihgurdgruhdpkhgsuhhstghhsehkvghrnhgvlhdrohhrghdptghmihhnhigrrhgusehmvhhishhtrgdrtghomhdpphgvthgvrhesphhjugdruggvvhdpqhgvmhhuqdgrrhhmsehnohhnghhnuhdrohhrghdpphgvthgvrhdrmhgrhiguvghllheslhhinhgrrhhordhorhhgpdhqvghmuhdqsghlohgtkhesnhhonhhgnhhurdhorhhgpdhjkhestghoug gvtghonhhsthhruhgtthdrtghomhdrrghupdhjohgvlhesjhhmshdrihgurdgruhdpkhdrjhgvnhhsvghnsehsrghmshhunhhgrdgtohhmpdfovfetjfhoshhtpehmohehvdelpdhmohguvgepshhmthhpohhuth Received-SPF: pass client-ip=46.105.54.81; envelope-from=clg@kaod.org; helo=smtpout3.mo529.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: MHDOaYPw22b1 On 11/17/22 08:37, Klaus Jensen wrote: > On Nov 17 07:56, Cédric Le Goater wrote: >> On 11/17/22 07:40, Klaus Jensen wrote: >>> On Nov 16 16:58, Cédric Le Goater wrote: >>>> On 11/16/22 09:43, Klaus Jensen wrote: >>>>> From: Klaus Jensen >>>>> >>>>> It is not given that the current master will release the bus after a >>>>> transfer ends. Only schedule a pending master if the bus is idle. >>>>> >>>>> Fixes: 37fa5ca42623 ("hw/i2c: support multiple masters") >>>>> Signed-off-by: Klaus Jensen >>>>> --- >>>>> hw/i2c/aspeed_i2c.c | 2 ++ >>>>> hw/i2c/core.c | 37 ++++++++++++++++++++++--------------- >>>>> include/hw/i2c/i2c.h | 2 ++ >>>>> 3 files changed, 26 insertions(+), 15 deletions(-) >>>>> >>>>> diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c >>>>> index c166fd20fa11..1f071a3811f7 100644 >>>>> --- a/hw/i2c/aspeed_i2c.c >>>>> +++ b/hw/i2c/aspeed_i2c.c >>>>> @@ -550,6 +550,8 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) >>>>> } >>>>> SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_STOP_CMD, 0); >>>>> aspeed_i2c_set_state(bus, I2CD_IDLE); >>>>> + >>>>> + i2c_schedule_pending_master(bus->bus); >>>> >>>> Shouldn't it be i2c_bus_release() ? >>>> >>> >>> The reason for having both i2c_bus_release() and >>> i2c_schedule_pending_master() is that i2c_bus_release() sort of pairs >>> with i2c_bus_master(). They either set or clear the bus->bh member. >>> >>> In the current design, the controller (in this case the Aspeed I2C) is >>> an "implicit" master (it does not have a bottom half driving it), so >>> there is no bus->bh to clear. >>> >>> I should (and will) write some documentation on the asynchronous API. >> >> I found the routine names confusing. Thanks for the clarification. >> >> Maybe we could do this rename : >> >> i2c_bus_release() -> i2c_bus_release_and_clear() >> i2c_schedule_pending_master() -> i2c_bus_release() >> >> and keep i2c_schedule_pending_master() internal the I2C core subsystem. >> > > How about renaming i2c_bus_master to i2c_bus_acquire() such that it > pairs with i2c_bus_release(). Looks good to me. > And then add an i2c_bus_yield() to be used by the controller? I think we > should be able to assert in i2c_bus_yield() that bus->bh is NULL. But > I'll take a closer look at that. I am using your i2c-echo slave device to track regressions in the Aspeed machines. May be we could merge it for tests ? Thanks, C.