Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2335290rwa; Mon, 22 Aug 2022 06:14:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR787LYvzwChyl/uFsddRFcztaUWEQvEj4AcNX3Mud3mbg+gzv8iSasJXmI3HKfEnlQFfy+3 X-Received: by 2002:a17:90b:4d12:b0:1f7:a6d1:24c1 with SMTP id mw18-20020a17090b4d1200b001f7a6d124c1mr22733230pjb.15.1661174050435; Mon, 22 Aug 2022 06:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661174050; cv=none; d=google.com; s=arc-20160816; b=Vh39Ewi5mtxOw5LJoMatLO0WZCVjdiS+ffTt/jKZF9yTQ/D+PdI1QrBK/Y9UgvGpzs rVm0DRZ39o73DaIQ7vULGypVOo4VXfpH9yTNscmXigpdjyr1X+ygfBeFwWbHne4vPN7o L8R1kNr75cifFH1s3aEYtlZzo/EJtblpKm0ruz1xxZHPz5wFP+PGd9FLEyeUIka33JeT QJbzJoTc8DpjR7YLCCWHtdYWmnU/ku4j7F53x6PdqgAoZBZ+PaCtgplRc1Xk8dLPa9nV LO2MvqZQHWeQKxhZVIfvNDK4TYjuq6q9pyhRRpw3Y90eT9/PCCLtrkuv9C5Te8yfrfXh BgJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Pmaf/7Gcj7yUXj9lfFijn0lHnAtMyFGBEGv7jKC4glY=; b=x/h5DzJ1o2OjkG0JcedW1gHh139taiYFrFwd7w3LfFBRe+R8yd44ibGRhhXo7hUC/l DPlmq9SSGwdrB/rPAyu654l3vhDTYrXtaa/gMVuq4QBwBPqIsCDQXZOMuJsHslqS1xXB OhXHubKhWyrI1R8UFpB4Jh5sB8J1AFwwOdu1ZteMiEoAwWKVfX+TwtFdwyWq0xRpehBM BABRFsq44h4f38gLVFlsrf9T2/2Og21xd6RGhvkNizjCjHTOrKW+NrrSksNhVPm721/b 9OoWDZhg0OnMR16jrdDTrK/K7Q+vA+TId+cdVLbU+D2hSIjEWTAIWyUhRjerWRjxl1o6 aH2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="VnJFQ/Gq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a634418000000b0041bd0985ea9si12706041pga.671.2022.08.22.06.13.59; Mon, 22 Aug 2022 06:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="VnJFQ/Gq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235033AbiHVNMp (ORCPT + 99 others); Mon, 22 Aug 2022 09:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234521AbiHVNMm (ORCPT ); Mon, 22 Aug 2022 09:12:42 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCE4533E3A; Mon, 22 Aug 2022 06:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=Pmaf/7Gcj7yUXj9lfFijn0lHnAtMyFGBEGv7jKC4glY=; b=VnJFQ/GqGILH+2rdH6itFRAGSC t+CAGFHwsZHEpc2+rLLnHKJO8AcBu7Bkz/zVbbedoZW3xnc0JQgkfY7cdeXGJhmvPKZpcXj9v4iaE iaKe79K8QNuEtyf8+C2amwgJJ87YGAQK6OJ5ftv0P4RacuXG2iz9ecXxyz6v1a7zIaqc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oQ7EM-00EDzw-L8; Mon, 22 Aug 2022 15:12:38 +0200 Date: Mon, 22 Aug 2022 15:12:38 +0200 From: Andrew Lunn To: Arun Ramadoss Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Woojung Huh , UNGLinuxDriver@microchip.com, Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Tristram Ha Subject: Re: [RFC Patch net-next v2] net: dsa: microchip: lan937x: enable interrupt for internal phy link detection Message-ID: References: <20220822092017.5671-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220822092017.5671-1-arun.ramadoss@microchip.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 22, 2022 at 02:50:17PM +0530, Arun Ramadoss wrote: > This patch enables the interrupts for internal phy link detection for > LAN937x. The interrupt enable bits are active low. It first enables port > interrupt and then port phy interrupt. Also patch register the irq > thread and in the ISR routine it clears the POR_READY_STS bit. > POR_READY_STS bit is write one clear bit and all other bit in the > register are read only. Since phy interrupts are handled by the lan937x > phy layer, switch interrupt routine does not read the phy layer > interrupts. > +static irqreturn_t lan937x_switch_irq_thread(int irq, void *dev_id) > +{ > + struct ksz_device *dev = dev_id; > + irqreturn_t result = IRQ_NONE; > + u32 data; > + int ret; > + > + /* Read global interrupt status register */ > + ret = ksz_read32(dev, REG_SW_INT_STATUS__4, &data); > + if (ret) > + return result; > + > + if (data & POR_READY_INT) { > + ret = ksz_write32(dev, REG_SW_INT_STATUS__4, POR_READY_INT); > + if (ret) > + return result; > + } > + > + return result; > +} I don't understand how this all fits together. How do you get from this interrupt handler into the PHY interrupt handler? The hardware looks similar to the mv88e6xxx driver. You have a top level interrupt controller which indicates a port has some sort of interrupt handler. This is the mv88e6xxx_g1_irq_thread_work(). It finds which port triggered the interrupt and then hands the interrupt off to the nested interrupt handler. mv88e6xxx_g2_irq_thread_fn() is the nested per port interrupt handler. It reads the per port interrupt status register, find the interrupt handler and calls the nested interrupt handler. This all glues together because phylib does a request_threaded_irq() for the PHY interrupt, so this last nested interrupt handler is in phylib. Andrew