From patchwork Tue Jul 21 13:13:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1333030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B9zZy0R9kz9sSd for ; Tue, 21 Jul 2020 23:14:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBFr4+oS; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBFr4+oS; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B9zZw3c52zDqlV for ; Tue, 21 Jul 2020 23:14:32 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=lvivier@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBFr4+oS; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBFr4+oS; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4B9zZR2d3xzDqlF for ; Tue, 21 Jul 2020 23:14:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595337237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+Ll6MbHww41FqMOC0SpgY9baX9y3/8RNmsoUq/zbVd0=; b=gBFr4+oS3mjl1nHA8FU9f80K8VOGYiz6kvhY5UrTW10CRZQL6HvmrSkhL0KdpVqSkj9aNR 5wGk2xbcheFsP1afxQ96VpyL87fh4sBhorqoIdxRTFaBjOOl7ebuFcguIZuhcvkgQxzIo7 PehSWc3rYVbdnyiLqkXq6Gj4eydLeKE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595337237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+Ll6MbHww41FqMOC0SpgY9baX9y3/8RNmsoUq/zbVd0=; b=gBFr4+oS3mjl1nHA8FU9f80K8VOGYiz6kvhY5UrTW10CRZQL6HvmrSkhL0KdpVqSkj9aNR 5wGk2xbcheFsP1afxQ96VpyL87fh4sBhorqoIdxRTFaBjOOl7ebuFcguIZuhcvkgQxzIo7 PehSWc3rYVbdnyiLqkXq6Gj4eydLeKE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-7Pn7-daKPByzME8C-OQG4Q-1; Tue, 21 Jul 2020 09:13:54 -0400 X-MC-Unique: 7Pn7-daKPByzME8C-OQG4Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2F3758; Tue, 21 Jul 2020 13:13:53 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 445A076216; Tue, 21 Jul 2020 13:13:52 +0000 (UTC) From: Laurent Vivier To: slof@lists.ozlabs.org Date: Tue, 21 Jul 2020 15:13:51 +0200 Message-Id: <20200721131351.106014-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [SLOF] [PATCH] usb: don't use 64bit accessors X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" A recent change in QEMU[1] breaks the 64bit access for XHCI and makes it unusable. QEMU always reports the AC64 bit so 64bit should be supported, but in fact SLOF doesn't check for this bit and always does a 64bit access. We need to fix QEMU to allow 64bit access when it reports AC64, but we need also to fix SLOF to not use 64bit access when the AC64 bit is not set. The easiest way to do that is, like linux kernel in xhci_read_64() and xhci_write_64() (see drivers/usb/host/xhci.h), to access always a 64bit register using two 32bit accesses, as the specs allow that. [1] 5d971f9e6725 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"") Signed-off-by: Laurent Vivier --- lib/libusb/tools.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/libusb/tools.h b/lib/libusb/tools.h index f531175c10a6..5758334b0247 100644 --- a/lib/libusb/tools.h +++ b/lib/libusb/tools.h @@ -54,13 +54,21 @@ static inline void write_reg16(uint16_t *reg, uint16_t value) static inline uint64_t read_reg64(uint64_t *reg) { - return bswap_64(ci_read_64(reg)); + uint32_t *p = (uint32_t*)reg; + uint32_t low, high; + + low = read_reg32(p); + high = read_reg32(p + 1); + + return low + ((uint64_t)high << 32); } static inline void write_reg64(uint64_t *reg, uint64_t value) { - mb(); - ci_write_64(reg, bswap_64(value)); + uint32_t *p = (uint32_t*)reg; + + write_reg32(p, value); + write_reg32(p + 1, value >> 32); } static inline uint32_t ci_read_reg(uint32_t *reg)