From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7CDD2222A9 for ; Sat, 16 May 2026 13:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778939690; cv=none; b=ScNKG5WEEfVwOUpawxPyE8CpJqWALTVE4BRO8jmWXTriViqQ2XNDH0JiMqmtzlQ3P0xxCPx2/FkGzukFfZy0XhEZGI2gLb8pPtfX8sTSm3wlyIfYGmHMyOZmRTpebqBFHrQ1MISnwHxvU2iXgPLE0bOOeOgPPrrgz4btUj967aQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778939690; c=relaxed/simple; bh=oAd8+u9veKXMSzawomfdaIEz00uqz+8Kr29J7YGDexM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cCeFrGasEwJr8NZIA2QOWHI8vCnn78jND0GPTxOq+57aK/9Uo4Vn0ZxfgWX6y0wegIKRcNu7YJCxUcrfMJf+NhFY21mGzR+GnIvRNpGDhUekoOdRNgJM/okwD6N5n30x7r2Z+xBMRZq23ZJ89XjUDnYFYytl9mTenwmpc5CegDk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YvmT7tZW; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YvmT7tZW" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso4116835e9.0 for ; Sat, 16 May 2026 06:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778939687; x=1779544487; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9IW/+7uckKhQmoH+ll6/6XySLsCP/Qj0il6Jj7grGd0=; b=YvmT7tZWsAm4kXzMyKF5SLdTMIq55kT5GsGj2N7Uk/8H0qRL0gXSqkKae6g4rTuEQb hQjmsow+Qbe+XJJVVK1EdBu4cKlszmscp/ML+oQlRLrT1bkNwe4A9x4iUUCMQB0u8rJy GMZ1xMMFIprpn4PKTq8idjl45qmEG9ZVCwID4N9UAfOE9/5mfxNI524fO8wQkES/53Hp Jbk9LUnD2q5xRVQhNMZMtcK7WAidl1uZfceZiM+sK7BR8pOKJ1GQfAAhpbxGxFj0SXzO A0VFYOWGiOECZ+w4xifK19xEmO9d5Kwuat0H06R+4BEubnrQ6sHyY/RT2VIM/+8TM3So wh/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778939687; x=1779544487; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9IW/+7uckKhQmoH+ll6/6XySLsCP/Qj0il6Jj7grGd0=; b=rlogDMppQrwlohCVXD3gd45eB9mPOznnv3X1v/K1Af1OCmiH6TmP80D3s4rep4rsXm ZP/2IfsnCa87TNJ0cl1ODcZ6gln5K0n5E5zaZn3XvCx+dHXlGYzAahBHjQu9kDjCkLm0 KnFoWwfhjOWdmqpor9OW6N6yuvkyk5lU8hOJO3Ig8ZO6xnSHNwKbZE4eVtT85WxARDN0 B+WWFsYTLInx7zlw1d4hzmf7T4WtRbyIjkre1+to8IvNchueV1nAP75l+iSeDA67Nq8r 9gWNDiUdUltU160ghcHhbRFPEUn9ebJiKoLxz6frbjVZpKQS+PRFFBbOJzrB1sGLrqsn SRrQ== X-Forwarded-Encrypted: i=1; AFNElJ90j9w0bIDLyl8nL8ppUv5zROsCtsAW5EYLmVFVJVc6Tu4czWmTIK5GQnxFSqXK+lxrEMcsfctabLk/0pU=@vger.kernel.org X-Gm-Message-State: AOJu0YxvqLX3Nuah/rjsOwFPRTNRgRbgX93s4BmhmwtTn8UuKqTtdqgH 70OriTP1c+sj4IOg4trGmz8UDkgKykgc+7ZHdv3jMYMSF+PqrUCZXDkI X-Gm-Gg: Acq92OE1eXdGuMBoC9GxXpJQS4sTbZAPEBfTrgSTTC7xlKJPiNNqhbaG5MUM5w/UlO6 XwYfe7aCJXzTkr2lfyGccqV/9KEFN29OdGWO6gmonC/Q81s6AD87Qb2dpXt/ZJQPXAJfEV3mjql enR09qAU0Q1mwc+N/3DeGeg/z5ckm/QUNuJg92cigK6EPCcIKKXZwoK4aUcxcTxyLiHiB9X+QAS 5xYsyclxUAu+BGPIketERq/bzrAyuFQkIp5YEn8u+vkhxtCr7HS73ut9odqWUfQ/hKfcUQ+Y9t/ 368hWbcjboW8Lw83SA/rOuraJIFiwKcQRjGQIV7C7BiG/nIXlFMJSHya7YAS7s570kZLmRSFUlF xRoViVwsqpj0UWoTGO1dX8nPfsnVXa/9c6u0MhiBVsba/nNg6v6TH/NuOngPXCZtifAe5DcQlFY L+9C+iO1Cp1BySxl3N7oT7sI/5zA== X-Received: by 2002:a05:600c:3e07:b0:48f:d1c0:721e with SMTP id 5b1f17b1804b1-48fe60d7823mr118973705e9.12.1778939686924; Sat, 16 May 2026 06:54:46 -0700 (PDT) Received: from builder ([2001:9e8:f136:a916:be24:11ff:fe30:5d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe537c788sm123360645e9.12.2026.05.16.06.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 06:54:46 -0700 (PDT) From: Jonas Jelonek To: Russell King , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Chevallier Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Simon Horman , Jonas Jelonek Subject: [PATCH net-next v8 0/2] net: sfp: extend SMBus support Date: Sat, 16 May 2026 13:54:40 +0000 Message-ID: <20260516135442.2234729-1-jelonek.jonas@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Today, the SFP driver only drives I2C adapters that advertise full I2C_FUNC_I2C, or SMBus-only adapters via single-byte transfers (with hwmon disabled). Several SoCs ship I2C/SMBus-only controllers that support more than just byte access -- e.g. word and I2C block -- and have SFP cages wired to them. Today, those adapters either work poorly or not at all. This series teaches the SFP driver to use the larger SMBus access modes when the adapter advertises them, and along the way starts honoring i2c_adapter quirks on read/write length so adapters that cap below the SFP block size are handled correctly. Patch 1 is a small prep doing only the quirks handling; patch 2 extends the SMBus path itself. Capability matrix supported by patch 2: - BYTE only: single-byte access (unchanged). - BYTE + WORD: word for >=2-byte chunks, byte tail. - I2C_BLOCK present: block as the universal transport. - WORD only (no BYTE/BLOCK): accepted with WARN_ONCE; works for even-length transfers, odd-length transfers will error at xfer time. Adapters with asymmetric R/W capabilities (e.g. only READ_I2C_BLOCK without WRITE_I2C_BLOCK) remain functionally correct but use the worse-supported direction's max for both directions, since i2c_max_block_size is a single field. No mainline I2C driver was seen advertising such asymmetry; per-direction sizes can be added later if needed. --- v7 -> v8: - avoid leaking uninitialized memory on short reads by zero-initializing i2c_smbus_data variable (Simon) - theoretical issue without practical impact raised at [1] not addressed but acknowledged at [2] v7: https://lore.kernel.org/netdev/20260507093301.1144740-1-jelonek.jonas@gmail.com/ v6 -> v7: - use i2c_block_size instead of i2c_max_block_size (Maxime) - move WARN_ONCE into 'else if ()' (Maxime) - reword comments - included Maxime's Reviewed-by for patch 1 v6: https://lore.kernel.org/netdev/20260505200647.1125311-1-jelonek.jonas@gmail.com/ v5 -> v6: - Split adapter-quirks handling into a separate prep patch (1/2). - Use I2C_SMBUS_I2C_BLOCK_DATA in the block-write branch (was I2C_SMBUS_WORD_DATA), so block writes actually transfer this_len bytes (also flagged by Jakub's AI bot review). - In sfp_smbus_read/write, check i2c_smbus_xfer() return before copying smbus_data into the caller's buffer. - Use I2C_BLOCK as the universal transport when available (carries any length 1..32); drop the this_len > 2 guard on the block branches. - Broaden the SMBus gate to also accept BLOCK-only adapters (Russell). - Accept word-only adapters with WARN_ONCE rather than rejecting them (Andrew). - Add a short comment in sfp_i2c_configure() explaining the access hierarchy (Maxime). - Use the all-bits-set form via i2c_check_functionality() for the composite I2C_FUNC_SMBUS_* checks (Russell). v5: https://lore.kernel.org/netdev/20260116113105.244592-1-jelonek.jonas@gmail.com/ v4 -> v5: - made a more general approach, also covering word access v4: https://lore.kernel.org/netdev/20260109101321.2804-1-jelonek.jonas@gmail.com/ v3 -> v4: - fix formal issues v3: https://lore.kernel.org/netdev/20260105161242.578487-1-jelonek.jonas@gmail.com/ v2 -> v3: - fix previous attempt of v2 to fix return value v2: https://lore.kernel.org/netdev/20260105154653.575397-1-jelonek.jonas@gmail.com/ v1 -> v2: - return number of written bytes instead of zero v1: https://lore.kernel.org/netdev/20251228213331.472887-1-jelonek.jonas@gmail.com/ [1] https://lore.kernel.org/netdev/20260510164726.1401317-1-horms@kernel.org/ [2] https://lore.kernel.org/netdev/5129a58d-8852-4395-85e1-8991934810b8@gmail.com/ --- Jonas Jelonek (2): net: sfp: apply I2C adapter quirks to limit block size net: sfp: extend SMBus support drivers/net/phy/sfp.c | 146 +++++++++++++++++++++++++++++++++--------- 1 file changed, 117 insertions(+), 29 deletions(-) base-commit: 822d4a8e390a08ccfaf2abb347ae670b230b196f -- 2.51.0