Bug 229510 - src/sys/arm/freescale/vybrid/vf_ehci.c:393: duplicate condition ?
Summary: src/sys/arm/freescale/vybrid/vf_ehci.c:393: duplicate condition ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ian Lepore
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-04 10:41 UTC by David Binderman
Modified: 2019-04-22 04:36 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-04 10:41:00 UTC
src/sys/arm/freescale/vybrid/vf_ehci.c:393] -> [src/sys/arm/freescale/vybrid/vf_ehci.c:399]: (warning) Identical condition 'sc->sc_flags&EHCI_SCFLG_DONEINIT', second condition is always false

Source code is

        if (sc->sc_flags & EHCI_SCFLG_DONEINIT)
                return (0);

        /*
         * only call ehci_detach() after ehci_init()
         */
        if (sc->sc_flags & EHCI_SCFLG_DONEINIT) {
                ehci_detach(sc);
                sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
        }

Is the sc_flags field volatile and is changed by some other thread ?
Comment 1 commit-hook freebsd_committer freebsd_triage 2018-07-05 15:35:11 UTC
A commit references this bug:

Author: ian
Date: Thu Jul  5 15:34:17 UTC 2018
New revision: 335985
URL: https://svnweb.freebsd.org/changeset/base/335985

Log:
  Remove a test and early-out which just can't possibly be right.  It causes
  detach() to do nothing if attach() succeeded, which is the opposite of
  what's needed.  Also, move device_delete_children() from the end to the
  beginning of detach(), so that children won't be trying to make use of the
  hardware we're in the process of shutting down.

  PR:		229510

Changes:
  head/sys/arm/freescale/vybrid/vf_ehci.c
Comment 2 David Binderman 2018-07-05 19:49:35 UTC
Same thing somewhere else

src/sys/arm/samsung/exynos/exynos5_ehci.c:357] -> [src/sys/arm/samsung/exynos/exynos5_ehci.c:363]: (warning) Identical condition 'sc->sc_flags&EHCI_SCFLG_DONEINIT', second condition is always false
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-04-22 04:08:29 UTC
A commit references this bug:

Author: ian
Date: Mon Apr 22 04:07:52 UTC 2019
New revision: 346520
URL: https://svnweb.freebsd.org/changeset/base/346520

Log:
  MFC r335982, r335985, r335988-r335989

  r335982:
  Fix an out-of-bounds array access... the irq data for teardown is in two
  arrays, as elements 0 and 1 of one array and elements 1 and 2 of the other.
  Run the loop 0..1 instead of 1..2 and use named constants to offset into
  one of the arrays.

  PR:		229508

  r335985:
  Remove a test and early-out which just can't possibly be right.  It causes
  detach() to do nothing if attach() succeeded, which is the opposite of
  what's needed.  Also, move device_delete_children() from the end to the
  beginning of detach(), so that children won't be trying to make use of the
  hardware we're in the process of shutting down.

  PR:		229510

  r335988:
  Add a missing call to usb_bus_mem_free_all() when detaching.

  r335989:
  Detach all children before beginning to tear down the hardware, instead of
  doing it last.  Also, remove the local tracking of whether usb's busdma
  memory allocation got done, because it's safe to call the free_all
  function even if it wasn't.

Changes:
_U  stable/11/
  stable/11/sys/arm/freescale/imx/imx_gpio.c
  stable/11/sys/arm/freescale/vybrid/vf_ehci.c
  stable/11/sys/dev/usb/controller/ehci_imx.c