Skip to content

Commit 2428750

Browse files
committed
Merge branch 'bits/030-misc' into asahi-wip
2 parents b96162f + ff7a6b6 commit 2428750

21 files changed

Lines changed: 266 additions & 66 deletions

File tree

arch/arm64/include/asm/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
#define DIRECT_MAP_PHYSMEM_END __pa(PAGE_END - 1)
114114

115-
#define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT)
115+
#define MIN_THREAD_SHIFT (15 + KASAN_THREAD_SHIFT)
116116

117117
/*
118118
* VMAP'd stacks are allocated at page granularity, so we must ensure that such

drivers/base/core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,32 @@ static void fw_devlink_link_device(struct device *dev)
23312331
__fw_devlink_link_to_suppliers(dev, fwnode);
23322332
}
23332333

2334+
/**
2335+
* fw_devlink_count_absent_consumers - Return how many consumers have
2336+
* either not been created yet, or do not yet have a driver attached.
2337+
* @fwnode: fwnode of the supplier
2338+
*/
2339+
int fw_devlink_count_absent_consumers(struct fwnode_handle *fwnode)
2340+
{
2341+
struct fwnode_link *link, *tmp;
2342+
struct device_link *dlink, *dtmp;
2343+
struct device *sup_dev = get_dev_from_fwnode(fwnode);
2344+
int count = 0;
2345+
2346+
list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook)
2347+
count++;
2348+
2349+
if (!sup_dev)
2350+
return count;
2351+
2352+
list_for_each_entry_safe(dlink, dtmp, &sup_dev->links.consumers, s_node)
2353+
if (dlink->consumer->links.status != DL_DEV_DRIVER_BOUND)
2354+
count++;
2355+
2356+
return count;
2357+
}
2358+
EXPORT_SYMBOL_GPL(fw_devlink_count_absent_consumers);
2359+
23342360
/* Device links support end. */
23352361

23362362
static struct kobject *dev_kobj;

drivers/base/firmware_loader/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ static int fw_decompress_xz(struct device *dev, struct fw_priv *fw_priv,
471471
static char fw_path_para[256];
472472
static const char * const fw_path[] = {
473473
fw_path_para,
474+
"/lib/firmware/vendor/" UTS_RELEASE,
475+
"/lib/firmware/vendor",
474476
"/lib/firmware/updates/" UTS_RELEASE,
475477
"/lib/firmware/updates",
476478
"/lib/firmware/" UTS_RELEASE,

drivers/gpu/drm/tiny/simpledrm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,12 @@ static int simpledrm_probe(struct platform_device *pdev)
10301030
struct drm_device *dev;
10311031
int ret;
10321032

1033+
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
1034+
if (ret)
1035+
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
1036+
if (ret)
1037+
return dev_err_probe(&pdev->dev, ret, "Failed to set dma mask\n");
1038+
10331039
sdev = simpledrm_device_create(&simpledrm_driver, pdev);
10341040
if (IS_ERR(sdev))
10351041
return PTR_ERR(sdev);

drivers/i2c/busses/i2c-pasemi-core.c

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/* Register offsets */
2222
#define REG_MTXFIFO 0x00
2323
#define REG_MRXFIFO 0x04
24+
#define REG_XFSTA 0x0c
2425
#define REG_SMSTA 0x14
2526
#define REG_IMASK 0x18
2627
#define REG_CTL 0x1c
@@ -52,6 +53,8 @@
5253
#define CTL_UJM BIT(8)
5354
#define CTL_CLK_M GENMASK(7, 0)
5455

56+
#define TRANSFER_TIMEOUT_MS 100
57+
5558
static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val)
5659
{
5760
dev_dbg(smbus->dev, "smbus write reg %x val %08x\n", reg, val);
@@ -80,23 +83,51 @@ static void pasemi_reset(struct pasemi_smbus *smbus)
8083
reinit_completion(&smbus->irq_completion);
8184
}
8285

83-
static void pasemi_smb_clear(struct pasemi_smbus *smbus)
86+
static int pasemi_smb_clear(struct pasemi_smbus *smbus)
8487
{
85-
unsigned int status;
88+
unsigned int status, xfstatus;
89+
int timeout = TRANSFER_TIMEOUT_MS;
8690

8791
status = reg_read(smbus, REG_SMSTA);
92+
93+
/* First wait for the bus to go idle */
94+
while ((status & (SMSTA_XIP | SMSTA_JAM)) && timeout--) {
95+
msleep(1);
96+
status = reg_read(smbus, REG_SMSTA);
97+
}
98+
99+
xfstatus = reg_read(smbus, REG_XFSTA);
100+
101+
if (timeout < 0) {
102+
dev_warn(smbus->dev, "Bus is still stuck (status 0x%08x xfstatus 0x%08x)\n",
103+
status, xfstatus);
104+
return -EIO;
105+
}
106+
107+
/* If any badness happened or there is data in the FIFOs, reset the FIFOs */
108+
if ((status & (SMSTA_MRNE | SMSTA_JMD | SMSTA_MTO | SMSTA_TOM | SMSTA_MTN | SMSTA_MTA)) ||
109+
!(status & SMSTA_MTE)) {
110+
dev_warn(smbus->dev, "Issuing reset due to status 0x%08x (xfstatus 0x%08x)\n",
111+
status, xfstatus);
112+
pasemi_reset(smbus);
113+
}
114+
115+
/* Clear the flags */
88116
reg_write(smbus, REG_SMSTA, status);
117+
118+
return 0;
89119
}
90120

91121
static int pasemi_smb_waitready(struct pasemi_smbus *smbus)
92122
{
93-
int timeout = 100;
123+
int timeout = TRANSFER_TIMEOUT_MS;
94124
unsigned int status;
95125

96126
if (smbus->use_irq) {
97127
reinit_completion(&smbus->irq_completion);
98-
reg_write(smbus, REG_IMASK, SMSTA_XEN | SMSTA_MTN);
99-
wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100));
128+
/* XEN should be set when a transaction terminates, whether due to error or not */
129+
reg_write(smbus, REG_IMASK, SMSTA_XEN);
130+
wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(timeout));
100131
reg_write(smbus, REG_IMASK, 0);
101132
status = reg_read(smbus, REG_SMSTA);
102133
} else {
@@ -107,16 +138,32 @@ static int pasemi_smb_waitready(struct pasemi_smbus *smbus)
107138
}
108139
}
109140

110-
/* Got NACK? */
111-
if (status & SMSTA_MTN)
112-
return -ENXIO;
141+
/* Controller timeout? */
142+
if (status & SMSTA_TOM) {
143+
dev_warn(smbus->dev, "Controller timeout, status 0x%08x\n", status);
144+
return -EIO;
145+
}
113146

114-
if (timeout < 0) {
115-
dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);
116-
reg_write(smbus, REG_SMSTA, status);
147+
/* Peripheral timeout? */
148+
if (status & SMSTA_MTO) {
149+
dev_warn(smbus->dev, "Peripheral timeout, status 0x%08x\n", status);
117150
return -ETIME;
118151
}
119152

153+
/* Still stuck in a transaction? */
154+
if (status & SMSTA_XIP) {
155+
dev_warn(smbus->dev, "Bus stuck, status 0x%08x\n", status);
156+
return -EIO;
157+
}
158+
159+
/* Arbitration loss? */
160+
if (status & SMSTA_MTA)
161+
return -EBUSY;
162+
163+
/* Got NACK? */
164+
if (status & SMSTA_MTN)
165+
return -ENXIO;
166+
120167
/* Clear XEN */
121168
reg_write(smbus, REG_SMSTA, SMSTA_XEN);
122169

@@ -177,7 +224,8 @@ static int pasemi_i2c_xfer(struct i2c_adapter *adapter,
177224
struct pasemi_smbus *smbus = adapter->algo_data;
178225
int ret, i;
179226

180-
pasemi_smb_clear(smbus);
227+
if (pasemi_smb_clear(smbus))
228+
return -EIO;
181229

182230
ret = 0;
183231

@@ -200,7 +248,8 @@ static int pasemi_smb_xfer(struct i2c_adapter *adapter,
200248
addr <<= 1;
201249
read_flag = read_write == I2C_SMBUS_READ;
202250

203-
pasemi_smb_clear(smbus);
251+
if (pasemi_smb_clear(smbus))
252+
return -EIO;
204253

205254
switch (size) {
206255
case I2C_SMBUS_QUICK:

drivers/mmc/core/core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,10 +2277,11 @@ void mmc_rescan(struct work_struct *work)
22772277
* while initializing the legacy SD interface. Therefore, let's start
22782278
* with UHS-II for now.
22792279
*/
2280-
if (!mmc_attach_sd_uhs2(host)) {
2281-
mmc_release_host(host);
2282-
goto out;
2283-
}
2280+
if (host->caps2 & MMC_CAP2_SD_UHS2)
2281+
if (!mmc_attach_sd_uhs2(host)) {
2282+
mmc_release_host(host);
2283+
goto out;
2284+
}
22842285

22852286
for (i = 0; i < ARRAY_SIZE(freqs); i++) {
22862287
unsigned int freq = freqs[i];

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/debugfs.h>
2828
#include <linux/acpi.h>
2929
#include <linux/dmi.h>
30+
#include <linux/of.h>
3031

3132
#include <linux/mmc/host.h>
3233
#include <linux/mmc/mmc.h>
@@ -2129,6 +2130,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21292130
struct sdhci_host *host;
21302131
int ret, bar = first_bar + slotno;
21312132
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2133+
u32 cd_debounce_delay_ms;
21322134

21332135
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
21342136
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2195,6 +2197,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21952197
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21962198
device_init_wakeup(&pdev->dev, true);
21972199

2200+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2201+
&cd_debounce_delay_ms))
2202+
cd_debounce_delay_ms = 200;
2203+
21982204
if (slot->cd_idx >= 0) {
21992205
struct gpiod_lookup_table *cd_gpio_lookup_table;
22002206

@@ -2213,14 +2219,24 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22132219
ret = mmc_gpiod_request_cd(host->mmc, NULL,
22142220
slot->cd_idx,
22152221
slot->cd_override_level,
2216-
0);
2222+
cd_debounce_delay_ms * 1000);
22172223
if (ret == -EPROBE_DEFER)
22182224
goto remove;
22192225

22202226
if (ret) {
22212227
dev_warn(&pdev->dev, "failed to setup card detect gpio\n");
22222228
slot->cd_idx = -1;
22232229
}
2230+
} else if (is_of_node(pdev->dev.fwnode)) {
2231+
/* Allow all OF systems to use a CD GPIO if provided */
2232+
2233+
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2234+
slot->cd_override_level,
2235+
cd_debounce_delay_ms * 1000);
2236+
if (ret == -EPROBE_DEFER)
2237+
goto remove;
2238+
else if (ret == 0)
2239+
slot->cd_idx = 0;
22242240
}
22252241

22262242
if (chip->fixes && chip->fixes->add_host)

drivers/mmc/host/sdhci-pci-gli.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,8 @@ static const struct sdhci_ops sdhci_gl9755_ops = {
19661966

19671967
const struct sdhci_pci_fixes sdhci_gl9755 = {
19681968
.quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
1969-
.quirks2 = SDHCI_QUIRK2_BROKEN_DDR50,
1969+
// disable non-working UHS-II mode on apple silicon devices
1970+
.quirks2 = SDHCI_QUIRK2_BROKEN_DDR50 | SDHCI_QUIRK2_BROKEN_UHS2,
19701971
.probe_slot = gli_probe_slot_gl9755,
19711972
.add_host = sdhci_pci_uhs2_add_host,
19721973
.remove_host = sdhci_pci_uhs2_remove_host,

drivers/mmc/host/sdhci-uhs2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ static void __sdhci_uhs2_add_host_v4(struct sdhci_host *host, u32 caps1)
11621162
mmc = host->mmc;
11631163

11641164
/* Support UHS2 */
1165-
if (caps1 & SDHCI_SUPPORT_UHS2)
1165+
if ((caps1 & SDHCI_SUPPORT_UHS2) &&
1166+
!(host->quirks2 & SDHCI_QUIRK2_BROKEN_UHS2))
11661167
mmc->caps2 |= MMC_CAP2_SD_UHS2;
11671168

11681169
max_current_caps2 = sdhci_readl(host, SDHCI_MAX_CURRENT_1);

drivers/mmc/host/sdhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ struct sdhci_host {
537537
/* Issue CMD and DATA reset together */
538538
#define SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER (1<<19)
539539

540+
#define SDHCI_QUIRK2_BROKEN_UHS2 (1<<27)
541+
540542
int irq; /* Device IRQ */
541543
void __iomem *ioaddr; /* Mapped address */
542544
phys_addr_t mapbase; /* physical address base */

0 commit comments

Comments
 (0)