From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96350C433F5 for ; Wed, 2 Feb 2022 14:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241342AbiBBOmU (ORCPT ); Wed, 2 Feb 2022 09:42:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231280AbiBBOmR (ORCPT ); Wed, 2 Feb 2022 09:42:17 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE66C061714 for ; Wed, 2 Feb 2022 06:42:17 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id q63so20434684pja.1 for ; Wed, 02 Feb 2022 06:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Wjge9Jzg3BsNzlCYuO9fFbJGJw1RDim9e+0Nkebz6RI=; b=hzMv5WDFmCdqZwP3nYdUjkvQutRgOzCV3UbIw1pZsSW8oe9PJ2lPgKS2cHp8jYqhFT UL8CH0zBgwu9bcOV7YWRMgV2VVk13aqI+ELA3MUELh3ercHNejB7/7Fn3ZiQslQiHsz6 qynyQ/Zug4/WFDKgS2dbwrWksJxkqyRlg4yNHCfBAxEtnvSXg3ltZmeqTo5w/TTBOpMA MSxerok0B+QY7aIjTq5oezZcxF43asrt+lTMgYFbZv+946Ijg06H6Zp5AFkOdyBdno8m 1GZ70wIO/500kb1RwKjCwOIY5nDkBJ0dQTI6hq//kLsibO4kWokvWdLRxtTeEynqrX/Q 61BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Wjge9Jzg3BsNzlCYuO9fFbJGJw1RDim9e+0Nkebz6RI=; b=ZWKXK7rpU70gW8st8DbxoCvkzypUIbHFVrXZCpyBtm/dtzWZm5/+XQisLstQmbnF6M cDhAyeSShyj2HnneKqmWRaDVUe0Tvzf5qeCO2fnpjcb43GWMNYtTo+p1ClSeju5Qi5bM BMPF2XNbNGJOGlmt3WP9Im3+EDE82URkczOysQIL8XMX5ZLqBrg3/WlfHcqTpM9nUXvz q0b+IuCMc6znM+K0rTHLWzRRu5aa7v4XlQEjJtbdUsO5yl5/CgCj57gZvLoe1k9GGgRY v+VG+3OBx1raVjlcNokl4ldGQaGfIDyTuDc8Es0vujdsayeV3IQKtIfA5tv/zdVM9e17 iG7w== X-Gm-Message-State: AOAM533Iyy0h/X8JUSKHDS234YM2/ysPmBqRXt5PxcKJ3jBv8skEctdf qpoPgLyL4gLZ0dcRcacmOmFdQ5SGJZKCWtl6vpEQ4w== X-Google-Smtp-Source: ABdhPJxwIAcnlCMB7YCJ9mCTx7OSZs+4LI7Dd16OxzmhHEpvld8tOSUrJsgmXxB3sPdbSTxEdVD+aODVlKQshryq748= X-Received: by 2002:a17:903:24d:: with SMTP id j13mr30332365plh.145.1643812936933; Wed, 02 Feb 2022 06:42:16 -0800 (PST) MIME-Version: 1.0 References: <20220120001621.705352-2-jsd@semihalf.com> <20220128144811.783279-1-jsd@semihalf.com> <20220128144811.783279-3-jsd@semihalf.com> In-Reply-To: From: =?UTF-8?B?SmFuIETEhWJyb8Wb?= Date: Wed, 2 Feb 2022 15:42:06 +0100 Message-ID: Subject: Re: [PATCH v2 2/2] i2c: designware: Add AMD PSP I2C bus support To: Andy Shevchenko Cc: Linux Kernel Mailing List , linux-i2c , Jarkko Nikula , Mika Westerberg , Hans de Goede , Wolfram Sang , Raul E Rangel , Marcin Wojtas , Grzegorz Jaszczyk , upstream@semihalf.com, Tom Lendacky , "Deucher, Alexander" , "Easow, Nimesh" , "Limonciello, Mario" , kernel test robot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 31 sty 2022 o 14:32 Andy Shevchenko napisa=C5=82(a): > > On Mon, Jan 31, 2022 at 12:56:27PM +0100, Jan D=C4=85bro=C5=9B wrote: > > pt., 28 sty 2022 o 16:50 Andy Shevchenko > > napisa=C5=82(a): > > > On Fri, Jan 28, 2022 at 03:59:40PM +0100, Jan D=C4=85bro=C5=9B wrote: > > > > pt., 28 sty 2022 o 15:48 Jan Dabros napisa=C5=82= (a): > > ... > > > > > > +struct psp_mbox { > > > > > + u32 cmd_fields; > > > > > > > > + phys_addr_t i2c_req_addr; > > > > > > But phys_addr_t is platform-dependent type. Perhaps you meant to use = u64 > > > here > > > always? > > > > Once I remove the "depends on X86_64" I believe this should be left > > platform-dependent. > > If it's a protocol or HW layout, it may not be platform-dependent. Right you are correct, will keep this as 64bit variable. > > > > > > +} __packed; > > ... > > > > > > + if (psp_send_cmd(req)) > > > > > > > > + return -EIO; > > > > > > Why is error code shadowed? > > > > > > > Just as a side note - it wasn't modified in v2 when moving above to > > psp_send_check_i2c_req(), but let me explain why I have introduced this > > initially. > > > > We have two means of timeouts in the context of this driver: > > 1. Timeout of internal mailbox, which means we cannot communicate with = a > > PSP for a programmed timeout. This timeout is encountered inside > > psp_send_cmd(). > > 2. Timeout of i2c arbitration - which means that we can communicate wit= h > > PSP, but PSP refuses to release i2c bus for too long. This timeout is > > returned by psp_send_i2c_req() in case of error. > > (side note: both error conditions are very unlikely to happen at runtim= e) > > > > I wanted to clearly distinguish between these two and thus put all erro= rs > > around mailbox into "-EIO category", which is actually true. > > At very least this code needs more or less the above to be put as a comme= nt. ACK > > ... > > > > > > +cleanup: > > > > > + mutex_unlock(&psp_i2c_access_mutex); > > > > > + return 0; > > > > > > Not sure I understand why we ignore all above errors here. > > > > > > > Actually we are not ignoring them, since each error sets "psp_i2c_mbox_= fail > > =3D true;". This means that if there is any error on x86-PSP interface,= we > > are ignoring i2c-arbitration and just fall back to normal (that is > > no-quirk) operation. > > > > From the i2c-client perspective (who is eventually gathering error code > > from above) I think we can claim that everything is fine, since bus is > > granted to it. For developers there is an error message in case some de= bug > > will be necessary. > > Perhaps needs a comment (sorry, if I overlooked it). ACK. > > ... > > > > > > + if (!dev || !dev->dev) > > > > > + return -ENODEV; > > > > > > At which circumstances may we get > > > dev !=3D NULL > > > dev->dev =3D=3D NULL > > > ? > > > > > > ... > > > > > > > > if (!dev || !dev->dev) > > > > > - return 0; > > > > > + return -ENODEV; > > > > > > I see the same here, perhaps Hans knows the answer :-) > > > > Right, so I must admit that I simply used *-baytrail.c as a reference a= nd > > thinking that additional check shouldn't hurt us (always better than no= t > > enough safety..). Looking more at this now - `dw_i2c_plat_probe()` will > > boil-out earlier if `dev->dev =3D=3D NULL`. Should I remove this extra = check in > > *-baytrail.c in the same commit? > > Maybe. Please, double check that it's not needed indeed. Confirmed that this is unnecessary. Best Regards, Jan > > -- > With Best Regards, > Andy Shevchenko > >