From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796309012; b=aV0GFeUNIx7x8MjbeYLqFI6XH7PLKVT2cxvK/RX7MUIdgdHDgubJC9VdWYLb7u8f0lcq SGL5k+2nHrVAfwNhP2RKPJ1Zbyg6j+wT/RaalMflz+pn401LJ089ERrR0Kex2enMZXAc8 CzejKT4LB8ive4d47tuKeHf1ipa1t59qMGXsE5fOfEtr6aiUXJH2FdrTvL+AMgLF/COiL gg6NXbu4e19vklNuDPMGaykONGiGF+2bBqr3lKIb4f71zBQ2EKIQpEBL1csAzuh/SSXi5 LOWDDtUJGZAXonB9g7CENlh6nQ+j+ThYfkO8d5lyugvHHFciXGoUzcTrTEtPpWsEDaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309012; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=bRXTqm28FpT4eAhoyAGnSiDh3PeRikWOyo/upuMQakU=; b=NEGv5z7GsRzIjfLDnw+rdBEni9/pAsxSNw9czoFV0JV/71NVzFFkC/uSi1WZdCLCeV/E ujSFq2cgQ6xRQ7CasFUA4Ue9lPNPhCDOpxeDaXNpWupJGhsyHKU8+cJumeeQZj3pHZ1K2 fRugCf53ETzdElRpPxmNsRwOTJuM6Iin/6rPlyam6Wwe2+WhmMDrlRedbm4mmeD/btlpj 1PG5ifGzDEwj7tR1APebf4b/bQdxJAPg9kiutN4ivE4Vgiml38oQ52286wSsIYLTSz5nJ lJgWfPBOalGHVsEKR0Xm0Qx57ukRunKw1aMixKTxgaDVFdYOW+A0yieug9G4L1wLcVg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=MhYSBmg7; arc=none smtp.remote-ip=198.175.65.13 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9314606A33D for ; Thu, 3 Dec 2026 14:43:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A9314606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=MhYSBmg7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796309012; x=1827845012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bRXTqm28FpT4eAhoyAGnSiDh3PeRikWOyo/upuMQakU=; b=MhYSBmg7vGoLIms6A1eZxnXN87OktzdNeLghY3W3meSupZWZrzC3jjjq aQlN4n4i2BzEwWpgUjH0Uq32Omg6H2P9OxvU0ZXU1xEmccULm2oaZZqgY 9jRXeVlowfloggCiibLrrRi1UpWM9lhUgtFpEA6FcmE/WhbgndwYPTD9c GJZ/9RKEIjw1W7U07dXgglspbH+10TD37jMndXFk+/M37jEkG/XADg63s HmwspSD5vKnVo8a4Pjdfvyw28/Ge9/xPiD77jD6LHqBWCLk43qWAfBIm8 b1ZHQ35fbAKPDhg8CXSWto8WSTRF9QkkD/C88zAGFCuxFvs4BkKqpxq9Z A==; X-CSE-ConnectionGUID: unQ6gyQFSxaZ1yt0jegs4w== X-CSE-MsgGUID: zSCq6QSZStaJXTSUU5JXBw== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5182631" X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; d="scan'208";a="5182631" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 06:43:32 -0800 X-CSE-ConnectionGUID: 7Qmj2Lp2RQKV40+D7P7vIw== X-CSE-MsgGUID: CHPQDpN8QF+dWL2ZueEVUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; d="scan'208";a="14024146" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa001.jf.intel.com with ESMTP; 03 Dec 2026 06:43:31 -0800 Received: by black.igk.intel.com (Postfix, from userid 1058) id DA5D298; Thu, 03 Dec 2026 15:43:29 +0100 (CET) From: Niklas Neronin To: mathias.nyman@linux.intel.com Cc: linux-usb@vger.kernel.org, Niklas Neronin Subject: [PATCH v3 10/12] usb: xhci: rework USB2 PORTHLPMC macros Date: Thu, 3 Dec 2026 15:42:42 +0100 Message-ID: <20261203144244.1680587-11-niklas.neronin@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261203144244.1680587-1-niklas.neronin@linux.intel.com> References: <20261203144244.1680587-1-niklas.neronin@linux.intel.com> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Replace the PORT_HIRDM(), PORT_L1_TIMEOUT() and PORT_BESLD() helpers with GENMASK() based field masks, and use FIELD_PREP() to build the PORTHLPMC value in xhci_calculate_usb2_hw_lpm_params(). While at it, document the PORTHLPMC register layout as described in xHCI 5.4.11.2. No functional change. Signed-off-by: Niklas Neronin --- drivers/usb/host/xhci-port.h | 19 +++++++++++++------ drivers/usb/host/xhci.c | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-port.h b/drivers/usb/host/xhci-port.h index 664aa19f00b3..c0a23caad40e 100644 --- a/drivers/usb/host/xhci-port.h +++ b/drivers/usb/host/xhci-port.h @@ -173,13 +173,20 @@ /* bits 15:0 - Link Soft Error Count, if LSECC=1 else RsvdP */ /* bits 31:16 - RsvdP */ -/* USB2 Protocol PORTHLPMC */ -#define PORT_HIRDM(p)((p) & 3) -#define PORT_L1_TIMEOUT(p)(((p) & 0xff) << 2) -#define PORT_BESLD(p)(((p) & 0xf) << 10) - +/* USB2 Port Hardware LPM Control Register (PORTHLPMC), xHCI 5.4.11.2 */ +/* bits 1:0 - Host Initiated Resume Duration Mode (HIRDM) */ +#define PORT_HIRDM_MASK GENMASK(1, 0) +/* + * bits 9:2 - L1 Timeout, L1 inactivity timer value. + * 0x00: 128 us (default). + * 0x01-0xff: 256 us to 65280 us, in 256 us increments. + */ +#define PORT_L1_TIMEOUT_MASK GENMASK(9, 2) /* use 512 microseconds as USB2 LPM L1 default timeout. */ -#define XHCI_L1_TIMEOUT 512 +#define XHCI_L1_TIMEOUT 512 +/* bits 13:10 - Best Effort Service Latency Deep (BESLD) */ +#define PORT_BESLD_MASK GENMASK(13, 10) +/* bits 31:14 - RsvdP */ /* Set default HIRD/BESL value to 4 (350/400us) for USB2 L1 LPM resume latency. * Safe to use with mixed HIRD and BESL systems (host and device) and is used diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 7a42361608f6..c9a68c42d769 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4665,7 +4665,8 @@ static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev) hirdm = 1; } - return PORT_BESLD(besld) | PORT_L1_TIMEOUT(l1) | PORT_HIRDM(hirdm); + return FIELD_PREP(PORT_BESLD_MASK, besld) | FIELD_PREP(PORT_L1_TIMEOUT_MASK, l1) | + FIELD_PREP(PORT_HIRDM_MASK, hirdm); } static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, -- 2.50.1