t113i不查网线启动,内核[ cut here ]崩溃问题解决

前言

环境介绍:

1.编译环境

Ubuntu 18.04.5 LTS

2.SDK

T113-i_v1.0

3.单板

迅龙TLT113-EVM-A1.1-000 + 自制底板


# 一、现象

插上网线启动,内核打印信息正常
在这里插入图片描述
不插网线启动,内核存在CPU崩溃打印[ cut here ]
在这里插入图片描述

二、问题根因

根据错误提示找到
/home/zfeng/T113- v1.8/kernel/linux-5.4/drivers/net/phy/phy.c:839 phy stop
phy_stop用于中止soc的gmac与phy的链接。

/**
 * phy_stop - Bring down the PHY link, and stop checking the status
 * @phydev: target phy_device struct
 */
void phy_stop(struct phy_device *phydev)
{
	if (!phy_is_started(phydev)) {
		WARN(1, "called from state %s\n",
		     phy_state_to_str(phydev->state));
		return;
	}

	mutex_lock(&phydev->lock);

	phydev->state = PHY_HALTED;

	mutex_unlock(&phydev->lock);

	phy_state_machine(&phydev->state_queue.work);
	phy_stop_machine(phydev);

	/* Cannot call flush_scheduled_work() here as desired because
	 * of rtnl_lock(), but PHY_HALTED shall guarantee irq handler
	 * will not reenable interrupts.
	 */
}
EXPORT_SYMBOL(phy_stop);

phy_stop该函数在
/home/zfeng/T113-i_v1.0/kernel/linux-5.4/drivers/net/ethernet/allwinner/sunxi-gmac.c→geth_phy_release引用

static int geth_phy_release(struct net_device *ndev)
{
... ...
	/* Stop and disconnect the PHY */
	if (phydev)
		phy_stop(phydev);
... ...
}

而函数geth_phy_release 在static int geth_stop(struct net_device *ndev)、static int geth_open(struct net_device *ndev)都有被引用。

static int geth_stop(struct net_device *ndev)
{
... ...
	/* Release PHY resources */
	geth_phy_release(ndev);
... ...
}
static int geth_open(struct net_device *ndev)
{
... ...
if (!priv->is_suspend) {
	ret = geth_dma_desc_init(ndev);
	if (ret) {
		ret = -EINVAL;
		goto desc_err;//当没插入网线,会执行desc_err 中断网络配置
	}
}
... ...
//该内容被跳过了
if (ndev->phydev)
	phy_start(ndev->phydev);
... ...
desc_err:
geth_phy_release(ndev);
... ...
}

从geth_open函数可以看到,当没插入网线,会执行desc_err 中断网络配置,跳过 phy_start(ndev->phydev),直接执行geth_phy_release的phy_stop(phydev),导致cpu执行了空指针或是空函数出错。
如果从启动正常把网线插入,geth_open将正常执行完,phy_start(ndev->phydev)也会正常执行,这样当将网络down,geth_stop可以正常执行phy_stop不会报错。

三、问题解决

根据上述,只要在geth_phy_release将phy_start(ndev->phydev)有没有正常执行区分开来,就可以轻松把问题解决,增加phy_start_flag标志位。
修改如下:

static int geth_open(struct net_device *ndev)
{	
	... ...
	int phy_start_flag = 0;
	... ... 
	if (ndev->phydev)
	{
		phy_start(ndev->phydev);
		phy_start_flag = 1;
	}
	... ...
desc_err:
	geth_phy_release(ndev, phy_start_flag);
	... ...
}

static int geth_phy_release(struct net_device *ndev, int phy_start_flag)
{
	... ... 
	// /* Stop and disconnect the PHY */
	if (phydev && phy_start_flag)
		phy_stop(phydev);
	 ... ...
}
全志T113-i是一款嵌入式处理器平台,Linux 5.4 内核中的 `CONFIG_TTY_DEV_NAME` 变量是一个编译选项,它用于控制tty设备(通常是串口)的名称生成。这个变量通常在内核配置菜单中设置。 要在Linux 5.4 内核源码树下配置 `CONFIG_TTY_DEV_NAME`,你需要按照以下步骤操作: 1. **克隆或下载Linux内核源码**: 首先,从Linux内核官方仓库(https://github.com/torvalds/linux)克隆或下载最新的5.4版本。 2. **进入内核目录**: 使用终端进入你刚刚下载的内核源码目录,例如: ``` cd /path/to/linux-5.4/ ``` 3. **启动配置工具**: 运行 `make menuconfig` 或者 `make xconfig`(取决于你的系统),这将打开交互式的配置界面。 4. **查找并选择配置项**: 在内核配置菜单中,导航到 "Device Drivers" -> "Serial support" -> "Generic character device driver options" 然后查找 "CONFIG_TTY_DEV_NAME"。这个选项可能会隐藏在较深的层级下,如 "Character Device Support" 或 "TTY support" 中。 5. **启用或禁用**:如果该选项前面有 "+" 标记,表示它默认未启用,你可以点击它将其选中(变成 "-")来启用;如果已经有 "-" 标记,则可以取消选中以禁用。 6. **保存配置并编译**: 完成配置后,记得保存并编译内核,命令如下: ``` make && make modules_install ``` 7. **安装内核更新**: 如果一切顺利,新的内核会替换当前运行的内核,或者需要手动重启系统加载新内核。 请注意,具体的路径可能会因内核版本或配置选项组织略有不同,建议根据实际的内核源码查看确切位置。同时,如果你不确定如何操作,查阅内核文档或搜索相关的教程会有帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值