[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/4] usb: dbgp: Fix return values for reset prep and startup


  • To: Connor Davis <connojdavis@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Fri, 14 May 2021 11:33:45 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lXQKrwoTgPb4jcMsO6+QH5R8pHFpAUlcHmVrmYQ365E=; b=Rkig+iBVeK1qWgv0LHy9/popSDBgSJEQaJh4vFd0r6CTYVpGP+d90xLwCsbVGAVoFzPZkgjCVBZdXvkVH2whv22wgbuXSSgenZV63zAo/DSRXvJQPVrk/K9ImjmlgvLLVp2N/hl9J5ClDGaPMtrW8xjlz4mzUDFsbfsKQYwkA9OPC89fKdl6OT16QL5ttdi2aEy2ER0RLmKdKw6fWncbuD91aswyvgTe6Jgn6I01Dm81JHByQRSXNvtMSbxFdxV/MRAnMx2ybs48rA9ZZF5II06JspntEuGXHhlYCR+Q8DZ6Bgx9/Vb5oHRHHbdFgZgNM1xQqZqBvdoJeruqvNUAVw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RzMjXKEWorApQIg8dQae0d5Ik9/S3aU1L2JW/f+qTWtzIlifUW0nCxYOwYydxfj39Qnfb6r8g+q8r1d04cjOeGrafvtKrhvO+oBcDxrhYxvmx7CLR0kX9xlxcaTOtWOfbSqx1gHWfafnVe8gYDpfxEq0pfiQuxxzLKrqwukHVkDu7m7EJSGwrKykhLmrycpgbBcVI+ixkavrtssvuz43AosjtwrQ4iqFtWMA08YPCVNtVhRMJCcmIbQLDRA9knjd29ZRPjxsFzPfXrVaoUE10gs0VV0+azBaJY6FB9YY5AMgB4QZiRijLPTXlUt1DZt7+HmYmdF+hoNo2bw1L15kKg==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=oracle.com;
  • Cc: Douglas Anderson <dianders@xxxxxxxxxxxx>, "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>, Chunfeng Yun <chunfeng.yun@xxxxxxxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>, Sumit Garg <sumit.garg@xxxxxxxxxx>, Lee Jones <lee.jones@xxxxxxxxxx>, linux-usb@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 14 May 2021 15:34:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 5/13/21 8:56 PM, Connor Davis wrote:
> Callers of dbgp_reset_prep treat a 0 return value as "stop using
> the debug port", which means they don't make any subsequent calls to
> dbgp_reset_prep or dbgp_external_startup.
>
> To ensure the callers' interpretation is correct, first return -EPERM
> from xen_dbgp_op if !xen_initial_domain(). This ensures that
> both xen_dbgp_reset_prep and xen_dbgp_external_startup return 0
> iff the PHYSDEVOP_DBGP_RESET_{PREPARE,DONE} hypercalls succeed. Also
> update xen_dbgp_reset_prep and xen_dbgp_external_startup to return
> -EPERM when !CONFIG_XEN_DOM0 for consistency.
>
> Next, return nonzero from dbgp_reset_prep if xen_dbgp_reset_prep returns
> 0. The nonzero value ensures that callers of dbgp_reset_prep will
> subsequently call dbgp_external_startup when it is safe to do so.
>
> Also invert the return values from dbgp_external_startup for
> consistency with dbgp_reset_prep (this inversion has no functional
> change since no callers actually check the value).
>
> Signed-off-by: Connor Davis <connojdavis@xxxxxxxxx>


For Xen bits:


Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>


For the rest it seems to me that error code passing could be improved: if it's 
0 or 1 it should be bool. Or pass actual error code, with zero for no-error 
case, such as ...


> ---
>  drivers/usb/early/ehci-dbgp.c |  9 ++++++---
>  drivers/xen/dbgp.c            |  2 +-
>  include/linux/usb/ehci-dbgp.h | 14 +++++++++-----
>  3 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
> index 45b42d8f6453..ff993d330c01 100644
> --- a/drivers/usb/early/ehci-dbgp.c
> +++ b/drivers/usb/early/ehci-dbgp.c
> @@ -970,8 +970,8 @@ int dbgp_reset_prep(struct usb_hcd *hcd)
>       int ret = xen_dbgp_reset_prep(hcd);
>       u32 ctrl;
>  
> -     if (ret)
> -             return ret;
> +     if (!ret)
> +             return 1;


... here or ...


>  
>       dbgp_not_safe = 1;
>       if (!ehci_debug)
> @@ -995,7 +995,10 @@ EXPORT_SYMBOL_GPL(dbgp_reset_prep);
>  
>  int dbgp_external_startup(struct usb_hcd *hcd)
>  {
> -     return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
> +     if (!xen_dbgp_external_startup(hcd))
> +             return 1;


... here.


-boris





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.